/** * Add the page title and toolbar. */ 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 = Db8downloadHelper::getActions(); JToolBarHelper::title(JText::_('COM_DB8DOWNLOAD_TITLE_FILE'), 'file.png'); // If not checked out, can save the item. if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) { JToolBarHelper::apply('file.apply', 'JTOOLBAR_APPLY'); JToolBarHelper::save('file.save', 'JTOOLBAR_SAVE'); } if (!$checkedOut && $canDo->get('core.create')) { JToolBarHelper::custom('file.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('file.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); } if (empty($this->item->id)) { JToolBarHelper::cancel('file.cancel', 'JTOOLBAR_CANCEL'); } else { JToolBarHelper::cancel('file.cancel', 'JTOOLBAR_CLOSE'); } }
/** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT . '/helpers/db8download.php'; $state = $this->get('State'); $canDo = Db8downloadHelper::getActions($state->get('filter.category_id')); JToolBarHelper::title(JText::_('COM_DB8DOWNLOAD_TITLE_FILES'), 'files.png'); //Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/file'; if (file_exists($formPath)) { if ($canDo->get('core.create')) { JToolBarHelper::addNew('file.add', 'JTOOLBAR_NEW'); } if ($canDo->get('core.edit') && isset($this->items[0])) { JToolBarHelper::editList('file.edit', 'JTOOLBAR_EDIT'); } } if ($canDo->get('core.edit.state')) { if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::custom('files.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::custom('files.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); } else { if (isset($this->items[0])) { //If this component does not use state then show a direct delete button as we can not trash JToolBarHelper::deleteList('', 'files.delete', 'JTOOLBAR_DELETE'); } } if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::archiveList('files.archive', 'JTOOLBAR_ARCHIVE'); } if (isset($this->items[0]->checked_out)) { JToolBarHelper::custom('files.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('', 'files.delete', 'JTOOLBAR_EMPTY_TRASH'); JToolBarHelper::divider(); } else { if ($canDo->get('core.edit.state')) { JToolBarHelper::trash('files.trash', 'JTOOLBAR_TRASH'); JToolBarHelper::divider(); } } } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_db8download'); } //Set sidebar action - New in 3.0 JHtmlSidebar::setAction('index.php?option=com_db8download&view=files'); }
/** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT . '/helpers/db8download.php'; $state = $this->get('State'); $canDo = Db8downloadHelper::getActions($state->get('filter.category_id')); JToolBarHelper::title(JText::_('COM_DB8DOWNLOAD_TITLE_USERS'), 'users.png'); //Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/user'; if (file_exists($formPath)) { if ($canDo->get('core.create')) { JToolBarHelper::addNew('user.add', 'JTOOLBAR_NEW'); } if ($canDo->get('core.edit') && isset($this->items[0])) { JToolBarHelper::editList('user.edit', 'JTOOLBAR_EDIT'); } } if ($canDo->get('core.edit.state')) { if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::custom('users.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::custom('users.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); } else { if (isset($this->items[0])) { //If this component does not use state then show a direct delete button as we can not trash JToolBarHelper::deleteList('', 'users.delete', 'JTOOLBAR_DELETE'); } } if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::archiveList('users.archive', 'JTOOLBAR_ARCHIVE'); } if (isset($this->items[0]->checked_out)) { JToolBarHelper::custom('users.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('', 'users.delete', 'JTOOLBAR_EMPTY_TRASH'); JToolBarHelper::divider(); } else { if ($canDo->get('core.edit.state')) { JToolBarHelper::trash('users.trash', 'JTOOLBAR_TRASH'); JToolBarHelper::divider(); } } } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_db8download'); } //Set sidebar action - New in 3.0 JHtmlSidebar::setAction('index.php?option=com_db8download&view=users'); $this->extra_sidebar = ''; //Filter for the field file; jimport('joomla.form.form'); $options = array(); JForm::addFormPath(JPATH_COMPONENT . '/models/forms'); $form = JForm::getInstance('com_db8download.user', 'user'); $field = $form->getField('file'); $query = $form->getFieldAttribute('filter_file', 'query'); $translate = $form->getFieldAttribute('filter_file', 'translate'); $key = $form->getFieldAttribute('filter_file', 'key_field'); $value = $form->getFieldAttribute('filter_file', '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('$File', 'filter_file', JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.file')), true); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true)); //Filter for the field created $this->extra_sidebar .= '<div class="other-filters">'; $this->extra_sidebar .= '<small><label for="filter_from_created">' . JText::sprintf('COM_DB8DOWNLOAD_FROM_FILTER', 'Created') . '</label></small>'; $this->extra_sidebar .= JHtml::_('calendar', $this->state->get('filter.created.from'), 'filter_from_created', 'filter_from_created', '%Y-%m-%d', array('style' => 'width:142px;', 'onchange' => 'this.form.submit();')); $this->extra_sidebar .= '<small><label for="filter_to_created">' . JText::sprintf('COM_DB8DOWNLOAD_TO_FILTER', 'Created') . '</label></small>'; $this->extra_sidebar .= JHtml::_('calendar', $this->state->get('filter.created.to'), 'filter_to_created', 'filter_to_created', '%Y-%m-%d', array('style' => 'width:142px;', 'onchange' => 'this.form.submit();')); $this->extra_sidebar .= '</div>'; $this->extra_sidebar .= '<hr class="hr-condensed">'; }