Exemplo n.º 1
0
 /**
  * Method to display a view
  */
 public function display($cachable = false, $urlparams = false)
 {
     require_once JPATH_COMPONENT . '/helpers/helper.php';
     // Load the submenu.
     SnippetsHelper::addSubmenu(JFactory::getApplication()->input->get('view', 'list'));
     $view = JFactory::getApplication()->input->get('view', 'list');
     $layout = JFactory::getApplication()->input->get('layout', 'default');
     $id = JFactory::getApplication()->input->getInt('id');
     // redirect to list if view is invalid
     if ($view != 'list' && $view != 'item') {
         $this->setRedirect(JRoute::_('index.php?option=com_snippets', false));
         return false;
     }
     // Check for edit form.
     if ($view == 'item' && $layout == 'edit' && !$this->checkEditId('com_snippets.edit.item', $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_snippets', false));
         return false;
     }
     parent::display();
 }