コード例 #1
0
ファイル: controller.php プロジェクト: esorone/efcpw
 /**
  * Method to display a view.
  *
  * @param	boolean			If true, the view output will be cached
  * @param	array			An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return	JControllerLegacy		This object to support chaining.
  * 
  */
 public function display($cachable = false, $url_params = false)
 {
     if (version_compare(JVERSION, '3.0', 'lt')) {
         $view = JRequest::getCmd('view', $this->default_view);
         $layout = JRequest::getCmd('layout', 'default');
         $id = JRequest::getInt('id');
     } else {
         $view = $this->input->get('view', $this->default_view);
         $layout = $this->input->get('layout', 'default');
         $id = $this->input->getInt('id');
     }
     // Load the submenu.
     ComponentArchitectHelper::addSubmenu($view);
     // Check for edit form.
     switch ($view) {
         case 'component':
             if ($layout == 'edit' and !$this->checkEditId('com_componentarchitect.edit.component', $id)) {
                 // Somehow the person just went to the form - we don't allow that.
                 $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
                 $this->setMessage($this->getError(), 'error');
                 $this->setRedirect(JRoute::_('index.php?option=com_componentarchitect&view=components', false));
                 return false;
             }
             break;
         case 'componentobject':
             if ($layout == 'edit' and !$this->checkEditId('com_componentarchitect.edit.componentobject', $id)) {
                 // Somehow the person just went to the form - we don't allow that.
                 $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
                 $this->setMessage($this->getError(), 'error');
                 $this->setRedirect(JRoute::_('index.php?option=com_componentarchitect&view=componentobjects', false));
                 return false;
             }
             break;
         case 'fieldset':
             if ($layout == 'edit' and !$this->checkEditId('com_componentarchitect.edit.fieldset', $id)) {
                 // Somehow the person just went to the form - we don't allow that.
                 $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
                 $this->setMessage($this->getError(), 'error');
                 $this->setRedirect(JRoute::_('index.php?option=com_componentarchitect&view=fieldsets', false));
                 return false;
             }
             break;
         case 'field':
             if ($layout == 'edit' and !$this->checkEditId('com_componentarchitect.edit.field', $id)) {
                 // Somehow the person just went to the form - we don't allow that.
                 $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
                 $this->setMessage($this->getError(), 'error');
                 $this->setRedirect(JRoute::_('index.php?option=com_componentarchitect&view=fields', false));
                 return false;
             }
             break;
         case 'fieldtype':
             if ($layout == 'edit' and !$this->checkEditId('com_componentarchitect.edit.fieldtype', $id)) {
                 // Somehow the person just went to the form - we don't allow that.
                 $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
                 $this->setMessage($this->getError(), 'error');
                 $this->setRedirect(JRoute::_('index.php?option=com_componentarchitect&view=fieldtypes', false));
                 return false;
             }
             break;
         case 'codetemplate':
             if ($layout == 'edit' and !$this->checkEditId('com_componentarchitect.edit.codetemplate', $id)) {
                 // Somehow the person just went to the form - we don't allow that.
                 $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
                 $this->setMessage($this->getError(), 'error');
                 $this->setRedirect(JRoute::_('index.php?option=com_componentarchitect&view=codetemplates', false));
                 return false;
             }
             break;
     }
     parent::display();
     return $this;
 }