Added temp workaround for gh-238 to insure component behave correctly with cache enabled on website
This commit is contained in:
@ -38,18 +38,30 @@ jimport('joomla.application.component.controller');
|
||||
class ###Component###Controller extends JControllerLegacy
|
||||
{
|
||||
/**
|
||||
* display task
|
||||
* Method to display a view.
|
||||
*
|
||||
* @param boolean $cachable If true, the view output will be cached.
|
||||
* @param boolean $urlparams An array of safe URL parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
|
||||
*
|
||||
* @return JController This object to support chaining.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function display($cachable = false, $urlparams = false)
|
||||
{
|
||||
// set default view if not set
|
||||
$view = $this->input->getCmd('view', '###SITE_DEFAULT_VIEW###');
|
||||
$this->input->set('view', $view);
|
||||
$isEdit = $this->checkEditView($view);
|
||||
$layout = $this->input->get('layout', null, 'WORD');
|
||||
$id = $this->input->getInt('id');
|
||||
$cachable = true;
|
||||
// $cachable = true; (TODO) working on a fix [gh-238](https://github.com/vdm-io/Joomla-Component-Builder/issues/238)
|
||||
|
||||
// insure that the view is not cashable if edit view or if user is logged in
|
||||
$user = JFactory::getUser();
|
||||
if ($user->get('id') || $isEdit)
|
||||
{
|
||||
$cachable = false;
|
||||
}
|
||||
|
||||
// Check for edit form.
|
||||
if($isEdit)
|
||||
@ -81,8 +93,33 @@ class ###Component###Controller extends JControllerLegacy
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// we may need to make this more dynamic in the future. (TODO)
|
||||
$safeurlparams = array(
|
||||
'catid' => 'INT',
|
||||
'id' => 'INT',
|
||||
'cid' => 'ARRAY',
|
||||
'year' => 'INT',
|
||||
'month' => 'INT',
|
||||
'limit' => 'UINT',
|
||||
'limitstart' => 'UINT',
|
||||
'showall' => 'INT',
|
||||
'return' => 'BASE64',
|
||||
'filter' => 'STRING',
|
||||
'filter_order' => 'CMD',
|
||||
'filter_order_Dir' => 'CMD',
|
||||
'filter-search' => 'STRING',
|
||||
'print' => 'BOOLEAN',
|
||||
'lang' => 'CMD',
|
||||
'Itemid' => 'INT');
|
||||
|
||||
return parent::display($cachable, $urlparams);
|
||||
// should these not merge?
|
||||
if (###Component###Helper::checkArray($urlparams))
|
||||
{
|
||||
$safeurlparams = ###Component###Helper::mergeArrays(array($urlparams, $safeurlparams));
|
||||
}
|
||||
|
||||
return parent::display($cachable, $safeurlparams);
|
||||
}
|
||||
|
||||
protected function checkEditView($view)
|
||||
|
Reference in New Issue
Block a user