Exemplo n.º 1
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     JFactory::getApplication()->input->set('hidemainmenu', 1);
     $option = JFactory::getApplication()->input->get('option');
     $view = JFactory::getApplication()->input->get('view');
     $lang = JFactory::getLanguage();
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $isNew = $this->item->id == 0;
     $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId);
     $canDo = RokCandyHelper::getActions($this->state->get('filter.category_id'));
     JToolBarHelper::title(JText::_('COM_ROKCANDY_MANAGER_MACRO'), 'rokcandy.png');
     // Build the actions for new and existing records.
     if ($isNew) {
         // For new records, check the create permission.
         if ($isNew && count($user->getAuthorisedCategories('com_rokcandy', 'core.create')) > 0) {
             JToolBarHelper::apply('candymacro.apply');
             JToolBarHelper::save('candymacro.save');
             JToolBarHelper::save2new('candymacro.save2new');
         }
         JToolBarHelper::cancel('candymacro.cancel');
     } else {
         // Can't save the record if it's checked out.
         if (!$checkedOut) {
             // Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
             if ($canDo->get('core.edit') || $canDo->get('core.edit.own') && $this->item->created_by == $userId) {
                 JToolBarHelper::apply('candymacro.apply');
                 JToolBarHelper::save('candymacro.save');
                 // We can save this record, but check the create permission to see if we can return to make a new one.
                 if ($canDo->get('core.create')) {
                     JToolBarHelper::save2new('candymacro.save2new');
                 }
             }
         }
         // If checked out, we can still save
         if ($canDo->get('core.create')) {
             JToolBarHelper::save2copy('candymacro.save2copy');
         }
         JToolBarHelper::cancel('candymacro.cancel', 'JTOOLBAR_CLOSE');
     }
     JToolBarHelper::divider();
     JToolBarHelper::help(strtoupper($option) . '_' . strtoupper($view) . '_HELP_URL', TRUE, '', $option);
 }
Exemplo n.º 2
0
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/rokcandy.php';
     $option = JFactory::getApplication()->input->get('option');
     $view = JFactory::getApplication()->input->get('view');
     $lang = JFactory::getLanguage();
     $canDo = RokCandyHelper::getActions($this->state->get('filter.category_id'));
     $user = JFactory::getUser();
     JToolBarHelper::title(JText::_('COM_ROKCANDY_MANAGER_MACRO'), 'rokcandy.png');
     if ($canDo->get('core.create') || count($user->getAuthorisedCategories('com_rokcandy', 'core.create')) > 0) {
         JToolBarHelper::addNew('candymacro.add');
     }
     if ($canDo->get('core.edit') || $canDo->get('core.edit.own')) {
         JToolBarHelper::editList('candymacro.edit');
     }
     if ($canDo->get('core.edit.state')) {
         JToolBarHelper::divider();
         JToolBarHelper::publish('candymacros.publish', 'JTOOLBAR_PUBLISH', true);
         JToolBarHelper::unpublish('candymacros.unpublish', 'JTOOLBAR_UNPUBLISH', true);
         JToolBarHelper::divider();
         JToolBarHelper::archiveList('candymacros.archive');
         JToolBarHelper::checkin('candymacros.checkin');
     }
     if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
         JToolBarHelper::deleteList('', 'candymacros.delete', 'JTOOLBAR_EMPTY_TRASH');
         JToolBarHelper::divider();
     } elseif ($canDo->get('core.edit.state')) {
         JToolBarHelper::trash('candymacros.trash');
         JToolBarHelper::divider();
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::preferences('com_rokcandy');
         JToolBarHelper::divider();
     }
     JToolBarHelper::help(strtoupper($option) . '_' . strtoupper($view) . '_HELP_URL', TRUE, '', $option);
     $version = new JVersion();
     if (version_compare($version->getShortVersion(), '3.0', '>=')) {
         JHtmlSidebar::setAction('index.php?option=com_rokcandy');
         JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true));
         JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_CATEGORY'), 'filter_category_id', JHtml::_('select.options', JHtml::_('category.options', 'com_rokcandy'), 'value', 'text', $this->state->get('filter.category_id')));
     }
 }