Beispiel #1
0
 /**
  * Add the page title and toolbar.
  *
  */
 protected function addToolbar()
 {
     $isNew = $this->item->id == 0;
     $canDo = SnippetsHelper::getActions();
     JHtml::stylesheet('nnframework/style.min.css', false, true);
     JHtml::stylesheet('snippets/style.min.css', false, true);
     JFactory::getApplication()->input->set('hidemainmenu', true);
     // Set document title
     JFactory::getDocument()->setTitle(JText::_('SNIPPETS') . ': ' . JText::_('NN_ITEM'));
     // Set ToolBar title
     JToolbarHelper::title(JText::_('SNIPPETS') . ': ' . JText::_('NN_ITEM'), 'snippets icon-nonumber');
     // If not checked out, can save the item.
     if ($canDo->get('core.edit')) {
         JToolbarHelper::apply('item.apply');
         JToolbarHelper::save('item.save');
     }
     if ($canDo->get('core.edit') && $canDo->get('core.create')) {
         JToolbarHelper::save2new('item.save2new');
     }
     if (!$isNew && $canDo->get('core.create')) {
         JToolbarHelper::save2copy('item.save2copy');
     }
     if (empty($this->item->id)) {
         JToolbarHelper::cancel('item.cancel');
     } else {
         JToolbarHelper::cancel('item.cancel', 'JTOOLBAR_CLOSE');
     }
 }
Beispiel #2
0
 /**
  * Add the page title and toolbar.
  *
  */
 protected function addToolbar()
 {
     $state = $this->get('State');
     $canDo = SnippetsHelper::getActions();
     $viewLayout = JFactory::getApplication()->input->get('layout', 'default');
     JHtml::stylesheet('nnframework/style.min.css', false, true);
     JHtml::stylesheet('com_snippets/style.min.css', false, true);
     if ($viewLayout == 'import') {
         // Set document title
         JFactory::getDocument()->setTitle(JText::_('SNIPPETS') . ': ' . JText::_('NN_IMPORT_ITEMS'));
         // Set ToolBar title
         JToolbarHelper::title(JText::_('SNIPPETS') . ': ' . JText::_('NN_IMPORT_ITEMS'), 'snippets icon-nonumber');
         // Set toolbar items for the page
         JToolBarHelper::back('JTOOLBAR_BACK', 'index.php?option=com_snippets');
     } else {
         // Set document title
         JFactory::getDocument()->setTitle(JText::_('SNIPPETS') . ': ' . JText::_('NN_LIST'));
         // Set ToolBar title
         JToolbarHelper::title(JText::_('SNIPPETS') . ': ' . JText::_('NN_LIST'), 'snippets icon-nonumber');
         // Set toolbar items for the page
         if ($canDo->get('core.create')) {
             JToolbarHelper::addNew('item.add');
         }
         if ($canDo->get('core.edit')) {
             JToolbarHelper::editList('item.edit');
         }
         if ($canDo->get('core.create')) {
             JToolbarHelper::custom('list.copy', 'copy', 'copy', 'JTOOLBAR_DUPLICATE', true);
         }
         if ($canDo->get('core.edit.state') && $state->get('filter.state') != 2) {
             JToolbarHelper::publish('list.publish', 'JTOOLBAR_PUBLISH', true);
             JToolbarHelper::unpublish('list.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         }
         if ($canDo->get('core.delete') && $state->get('filter.state') == -2) {
             JToolbarHelper::deleteList('', 'list.delete', 'JTOOLBAR_EMPTY_TRASH');
         } else {
             if ($canDo->get('core.edit.state')) {
                 JToolbarHelper::trash('list.trash');
             }
         }
         if ($canDo->get('core.create')) {
             JToolbarHelper::custom('list.export', 'box-remove', 'box-remove', 'NN_EXPORT');
             JToolbarHelper::custom('list.import', 'box-add', 'box-add', 'NN_IMPORT', false);
         }
         if ($canDo->get('core.admin')) {
             JToolbarHelper::preferences('com_snippets');
         }
     }
 }
 /**
  * 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();
 }