/** * Add the page title and toolbar. * * @return void * * @throws Exception */ protected function addToolbar() { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $isNew = $this->item->id == 0; if (isset($this->item->checked_out)) { $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); } else { $checkedOut = false; } $canDo = VocabHelper::getActions(); JToolBarHelper::title(JText::_('COM_VOCAB_TITLE_SUBJECT'), 'subject.png'); // If not checked out, can save the item. if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) { JToolBarHelper::apply('subject.apply', 'JTOOLBAR_APPLY'); JToolBarHelper::save('subject.save', 'JTOOLBAR_SAVE'); } if (!$checkedOut && $canDo->get('core.create')) { JToolBarHelper::custom('subject.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); } // If an existing item, can save to a copy. if (!$isNew && $canDo->get('core.create')) { JToolBarHelper::custom('subject.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); } // Button for version control if ($this->state->params->get('save_history', 1) && $user->authorise('core.edit')) { JToolbarHelper::versions('com_vocab.subject', $this->item->id); } if (empty($this->item->id)) { JToolBarHelper::cancel('subject.cancel', 'JTOOLBAR_CANCEL'); } else { JToolBarHelper::cancel('subject.cancel', 'JTOOLBAR_CLOSE'); } }
/** * Add the page title and toolbar. * * @return void * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT . '/helpers/vocab.php'; $state = $this->get('State'); $canDo = VocabHelper::getActions($state->get('filter.category_id')); JToolBarHelper::title(JText::_('COM_VOCAB_TITLE_FREQUENCIES'), 'frequencies.png'); // Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/frequency'; if (file_exists($formPath)) { if ($canDo->get('core.create')) { JToolBarHelper::addNew('frequency.add', 'JTOOLBAR_NEW'); JToolbarHelper::custom('frequencies.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true); } if ($canDo->get('core.edit') && isset($this->items[0])) { JToolBarHelper::editList('frequency.edit', 'JTOOLBAR_EDIT'); } } if ($canDo->get('core.edit.state')) { if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::custom('frequencies.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::custom('frequencies.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); } elseif (isset($this->items[0])) { // If this component does not use state then show a direct delete button as we can not trash JToolBarHelper::deleteList('', 'frequencies.delete', 'JTOOLBAR_DELETE'); } if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::archiveList('frequencies.archive', 'JTOOLBAR_ARCHIVE'); } if (isset($this->items[0]->checked_out)) { JToolBarHelper::custom('frequencies.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); } } // Show trash and delete for components that uses the state field if (isset($this->items[0]->state)) { if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'frequencies.delete', 'JTOOLBAR_EMPTY_TRASH'); JToolBarHelper::divider(); } elseif ($canDo->get('core.edit.state')) { JToolBarHelper::trash('frequencies.trash', 'JTOOLBAR_TRASH'); JToolBarHelper::divider(); } } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_vocab'); } // Set sidebar action - New in 3.0 JHtmlSidebar::setAction('index.php?option=com_vocab&view=frequencies'); $this->extra_sidebar = ''; JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true)); }
/** * Add the page title and toolbar. * * @return void * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT . '/helpers/vocab.php'; $state = $this->get('State'); $canDo = VocabHelper::getActions($state->get('filter.category_id')); JToolBarHelper::title(JText::_('COM_VOCAB_TITLE_CONTENTS'), 'contents.png'); // Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/content'; if (file_exists($formPath)) { if ($canDo->get('core.create')) { JToolBarHelper::addNew('content.add', 'JTOOLBAR_NEW'); JToolbarHelper::custom('contents.duplicate', 'copy.png', 'copy_f2.png', 'JTOOLBAR_DUPLICATE', true); } if ($canDo->get('core.edit') && isset($this->items[0])) { JToolBarHelper::editList('content.edit', 'JTOOLBAR_EDIT'); } } if ($canDo->get('core.edit.state')) { if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::custom('contents.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::custom('contents.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); } elseif (isset($this->items[0])) { // If this component does not use state then show a direct delete button as we can not trash JToolBarHelper::deleteList('', 'contents.delete', 'JTOOLBAR_DELETE'); } if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::archiveList('contents.archive', 'JTOOLBAR_ARCHIVE'); } if (isset($this->items[0]->checked_out)) { JToolBarHelper::custom('contents.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); } } // Show trash and delete for components that uses the state field if (isset($this->items[0]->state)) { if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'contents.delete', 'JTOOLBAR_EMPTY_TRASH'); JToolBarHelper::divider(); } elseif ($canDo->get('core.edit.state')) { JToolBarHelper::trash('contents.trash', 'JTOOLBAR_TRASH'); JToolBarHelper::divider(); } } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_vocab'); } // Set sidebar action - New in 3.0 JHtmlSidebar::setAction('index.php?option=com_vocab&view=contents'); $this->extra_sidebar = ''; //Filter for the field subject; jimport('joomla.form.form'); $options = array(); JForm::addFormPath(JPATH_COMPONENT . '/models/forms'); $form = JForm::getInstance('com_vocab.content', 'content'); $field = $form->getField('subject'); $query = $form->getFieldAttribute('filter_subject', 'query'); $translate = $form->getFieldAttribute('filter_subject', 'translate'); $key = $form->getFieldAttribute('filter_subject', 'key_field'); $value = $form->getFieldAttribute('filter_subject', 'value_field'); // Get the database object. $db = JFactory::getDBO(); // Set the query and get the result list. $db->setQuery($query); $items = $db->loadObjectlist(); // Build the field options. if (!empty($items)) { foreach ($items as $item) { if ($translate == true) { $options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value})); } else { $options[] = JHtml::_('select.option', $item->{$key}, $item->{$value}); } } } JHtmlSidebar::addFilter('$Subject', 'filter_subject', JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.subject')), true); //Filter for the field category; jimport('joomla.form.form'); $options = array(); JForm::addFormPath(JPATH_COMPONENT . '/models/forms'); $form = JForm::getInstance('com_vocab.content', 'content'); $field = $form->getField('category'); $query = $form->getFieldAttribute('filter_category', 'query'); $translate = $form->getFieldAttribute('filter_category', 'translate'); $key = $form->getFieldAttribute('filter_category', 'key_field'); $value = $form->getFieldAttribute('filter_category', 'value_field'); // Get the database object. $db = JFactory::getDBO(); // Set the query and get the result list. $db->setQuery($query); $items = $db->loadObjectlist(); // Build the field options. if (!empty($items)) { foreach ($items as $item) { if ($translate == true) { $options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value})); } else { $options[] = JHtml::_('select.option', $item->{$key}, $item->{$value}); } } } JHtmlSidebar::addFilter('$Category', 'filter_category', JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.category')), true); //Filter for the field frequency; jimport('joomla.form.form'); $options = array(); JForm::addFormPath(JPATH_COMPONENT . '/models/forms'); $form = JForm::getInstance('com_vocab.content', 'content'); $field = $form->getField('frequency'); $query = $form->getFieldAttribute('filter_frequency', 'query'); $translate = $form->getFieldAttribute('filter_frequency', 'translate'); $key = $form->getFieldAttribute('filter_frequency', 'key_field'); $value = $form->getFieldAttribute('filter_frequency', 'value_field'); // Get the database object. $db = JFactory::getDBO(); // Set the query and get the result list. $db->setQuery($query); $items = $db->loadObjectlist(); // Build the field options. if (!empty($items)) { foreach ($items as $item) { if ($translate == true) { $options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value})); } else { $options[] = JHtml::_('select.option', $item->{$key}, $item->{$value}); } } } JHtmlSidebar::addFilter('$Frequency', 'filter_frequency', JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.frequency')), true); //Filter for the field pos; jimport('joomla.form.form'); $options = array(); JForm::addFormPath(JPATH_COMPONENT . '/models/forms'); $form = JForm::getInstance('com_vocab.content', 'content'); $field = $form->getField('pos'); $query = $form->getFieldAttribute('filter_pos', 'query'); $translate = $form->getFieldAttribute('filter_pos', 'translate'); $key = $form->getFieldAttribute('filter_pos', 'key_field'); $value = $form->getFieldAttribute('filter_pos', 'value_field'); // Get the database object. $db = JFactory::getDBO(); // Set the query and get the result list. $db->setQuery($query); $items = $db->loadObjectlist(); // Build the field options. if (!empty($items)) { foreach ($items as $item) { if ($translate == true) { $options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value})); } else { $options[] = JHtml::_('select.option', $item->{$key}, $item->{$value}); } } } JHtmlSidebar::addFilter('$PoS', 'filter_pos', JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.pos')), true); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true)); }