/** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { JRequest::setVar('hidemainmenu', true); $user = JFactory::getUser(); $userId = $user->get('id'); $isNew = $this->item->id == 0; $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); // Since we don't track these assets at the item level, use the category id. $canDo = FaqsHelper::getActions($this->item->catid, 0); JToolBarHelper::title(JText::_('COM_FAQS_MANAGER_FAQ'), 'faqs.png'); // If not checked out, can save the item. if (!$checkedOut && ($canDo->get('core.edit') || count($user->getAuthorisedCategories('com_faqs', 'core.create')))) { JToolBarHelper::apply('faq.apply'); JToolBarHelper::save('faq.save'); } if (!$checkedOut && count($user->getAuthorisedCategories('com_faqs', 'core.create'))) { JToolBarHelper::save2new('faq.save2new'); } // If an existing item, can save to a copy. if (!$isNew && count($user->getAuthorisedCategories('com_faqs', 'core.create')) > 0) { JToolBarHelper::save2copy('faq.save2copy'); } if (empty($this->item->id)) { JToolBarHelper::cancel('faq.cancel'); } else { JToolBarHelper::cancel('faq.cancel', 'JTOOLBAR_CLOSE'); } JToolBarHelper::divider(); JToolBarHelper::help('JHELP_COMPONENTS_FAQS_LINKS_EDIT'); }
/** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT . '/helpers/faqs.php'; $state = $this->get('State'); $canDo = FaqsHelper::getActions($state->get('filter.category_id')); $user = JFactory::getUser(); JToolBarHelper::title(JText::_('COM_FAQS_MANAGER_FAQS'), 'faqs.png'); if (count($user->getAuthorisedCategories('com_faqs', 'core.create')) > 0) { JToolBarHelper::addNew('faq.add'); } if ($canDo->get('core.edit')) { JToolBarHelper::editList('faq.edit'); } if ($canDo->get('core.edit.state')) { JToolBarHelper::divider(); JToolBarHelper::publish('faqs.publish', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::unpublish('faqs.unpublish', 'JTOOLBAR_UNPUBLISH', true); JToolBarHelper::divider(); JToolBarHelper::archiveList('faqs.archive'); JToolBarHelper::checkin('faqs.checkin'); } if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'faqs.delete', 'JTOOLBAR_EMPTY_TRASH'); JToolBarHelper::divider(); } elseif ($canDo->get('core.edit.state')) { JToolBarHelper::trash('faqs.trash'); JToolBarHelper::divider(); } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_faqs'); JToolBarHelper::divider(); } JToolBarHelper::help('JHELP_COMPONENTS_FAQS_LINKS'); }
/** * Method to display a view. * * @param boolean $cachable If true, the view output will be cached * @param array $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. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT . '/helpers/faqs.php'; // Load the submenu. FaqsHelper::addSubmenu(JRequest::getCmd('view', 'faqs')); $view = JRequest::getCmd('view', 'faqs'); $layout = JRequest::getCmd('layout', 'default'); $id = JRequest::getInt('id'); // Check for edit form. if ($view == 'faq' && $layout == 'edit' && !$this->checkEditId('com_faqs.edit.faq', $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_faqs&view=faqs', false)); return false; } parent::display(); return $this; }