Joomla! PHP Cross Reference Web Portals

Source: /administrator/components/com_categories/views/categories/view.html.php - 242 lines - 7859 bytes - Summary - Text - Print

   1  <?php
   2  /**
   3   * @package     Joomla.Administrator
   4   * @subpackage  com_categories
   5   *
   6   * @copyright   Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
   7   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  defined('_JEXEC') or die;
  11  
  12  /**
  13   * Categories view class for the Category package.
  14   *
  15   * @package     Joomla.Administrator
  16   * @subpackage  com_categories
  17   * @since       1.6
  18   */
  19  class CategoriesViewCategories extends JViewLegacy
  20  {
  21      protected $items;
  22  
  23      protected $pagination;
  24  
  25      protected $state;
  26  
  27      protected $assoc;
  28  
  29      /**
  30       * Display the view
  31       */
  32  	public function display($tpl = null)
  33      {
  34          $this->state        = $this->get('State');
  35          $this->items        = $this->get('Items');
  36          $this->pagination    = $this->get('Pagination');
  37          $this->assoc        = $this->get('Assoc');
  38  
  39          // Check for errors.
  40          if (count($errors = $this->get('Errors')))
  41          {
  42              JError::raiseError(500, implode("\n", $errors));
  43              return false;
  44          }
  45  
  46          // Preprocess the list of items to find ordering divisions.
  47          foreach ($this->items as &$item)
  48          {
  49              $this->ordering[$item->parent_id][] = $item->id;
  50          }
  51  
  52          // Levels filter.
  53          $options    = array();
  54          $options[]    = JHtml::_('select.option', '1', JText::_('J1'));
  55          $options[]    = JHtml::_('select.option', '2', JText::_('J2'));
  56          $options[]    = JHtml::_('select.option', '3', JText::_('J3'));
  57          $options[]    = JHtml::_('select.option', '4', JText::_('J4'));
  58          $options[]    = JHtml::_('select.option', '5', JText::_('J5'));
  59          $options[]    = JHtml::_('select.option', '6', JText::_('J6'));
  60          $options[]    = JHtml::_('select.option', '7', JText::_('J7'));
  61          $options[]    = JHtml::_('select.option', '8', JText::_('J8'));
  62          $options[]    = JHtml::_('select.option', '9', JText::_('J9'));
  63          $options[]    = JHtml::_('select.option', '10', JText::_('J10'));
  64  
  65          $this->f_levels = $options;
  66  
  67          $this->addToolbar();
  68          $this->sidebar = JHtmlSidebar::render();
  69          parent::display($tpl);
  70      }
  71  
  72      /**
  73       * Add the page title and toolbar.
  74       *
  75       * @since    1.6
  76       */
  77  	protected function addToolbar()
  78      {
  79          $categoryId    = $this->state->get('filter.category_id');
  80          $component    = $this->state->get('filter.component');
  81          $section    = $this->state->get('filter.section');
  82          $canDo        = null;
  83          $user        = JFactory::getUser();
  84  
  85          // Get the toolbar object instance
  86          $bar = JToolBar::getInstance('toolbar');
  87  
  88          // Avoid nonsense situation.
  89          if ($component == 'com_categories')
  90          {
  91              return;
  92          }
  93  
  94          // Need to load the menu language file as mod_menu hasn't been loaded yet.
  95          $lang = JFactory::getLanguage();
  96              $lang->load($component, JPATH_BASE, null, false, false)
  97          ||    $lang->load($component, JPATH_ADMINISTRATOR.'/components/'.$component, null, false, false)
  98          ||    $lang->load($component, JPATH_BASE, $lang->getDefault(), false, false)
  99          ||    $lang->load($component, JPATH_ADMINISTRATOR.'/components/'.$component, $lang->getDefault(), false, false);
 100  
 101          // Load the category helper.
 102          require_once  JPATH_COMPONENT.'/helpers/categories.php';
 103  
 104          // Get the results for each action.
 105          $canDo = CategoriesHelper::getActions($component, $categoryId);
 106  
 107          // If a component categories title string is present, let's use it.
 108          if ($lang->hasKey($component_title_key = strtoupper($component.($section?"_$section":'')).'_CATEGORIES_TITLE'))
 109          {
 110              $title = JText::_($component_title_key);
 111          }
 112          // Else if the component section string exits, let's use it
 113          elseif ($lang->hasKey($component_section_key = strtoupper($component.($section?"_$section":''))))
 114          {
 115              $title = JText::sprintf('COM_CATEGORIES_CATEGORIES_TITLE', $this->escape(JText::_($component_section_key)));
 116          }
 117          // Else use the base title
 118          else
 119          {
 120              $title = JText::_('COM_CATEGORIES_CATEGORIES_BASE_TITLE');
 121          }
 122  
 123          // Load specific css component
 124          JHtml::_('stylesheet', $component.'/administrator/categories.css', array(), true);
 125  
 126          // Prepare the toolbar.
 127          JToolbarHelper::title($title, 'categories '.substr($component, 4).($section?"-$section":'').'-categories');
 128  
 129          if ($canDo->get('core.create') || (count($user->getAuthorisedCategories($component, 'core.create'))) > 0 )
 130          {
 131              JToolbarHelper::addNew('category.add');
 132          }
 133  
 134          if ($canDo->get('core.edit') || $canDo->get('core.edit.own'))
 135          {
 136              JToolbarHelper::editList('category.edit');
 137          }
 138  
 139          if ($canDo->get('core.edit.state'))
 140          {
 141              JToolbarHelper::publish('categories.publish', 'JTOOLBAR_PUBLISH', true);
 142              JToolbarHelper::unpublish('categories.unpublish', 'JTOOLBAR_UNPUBLISH', true);
 143              JToolbarHelper::archiveList('categories.archive');
 144          }
 145  
 146          if (JFactory::getUser()->authorise('core.admin'))
 147          {
 148              JToolbarHelper::checkin('categories.checkin');
 149          }
 150  
 151          if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete', $component))
 152          {
 153              JToolbarHelper::deleteList('', 'categories.delete', 'JTOOLBAR_EMPTY_TRASH');
 154          }
 155          elseif ($canDo->get('core.edit.state')) {
 156              JToolbarHelper::trash('categories.trash');
 157          }
 158  
 159          // Add a batch button
 160          if ($canDo->get('core.edit'))
 161          {
 162              JHtml::_('bootstrap.modal', 'collapseModal');
 163              $title = JText::_('JTOOLBAR_BATCH');
 164              $dhtml = "<button data-toggle=\"modal\" data-target=\"#collapseModal\" class=\"btn btn-small\">
 165                          <i class=\"icon-checkbox-partial\" title=\"$title\"></i>
 166                          $title</button>";
 167              $bar->appendButton('Custom', $dhtml, 'batch');
 168          }
 169  
 170          if ($canDo->get('core.admin'))
 171          {
 172              JToolbarHelper::custom('categories.rebuild', 'refresh.png', 'refresh_f2.png', 'JTOOLBAR_REBUILD', false);
 173              JToolbarHelper::preferences($component);
 174          }
 175  
 176          // Compute the ref_key if it does exist in the component
 177          if (!$lang->hasKey($ref_key = strtoupper($component.($section?"_$section":'')).'_CATEGORIES_HELP_KEY'))
 178          {
 179              $ref_key = 'JHELP_COMPONENTS_'.strtoupper(substr($component, 4).($section?"_$section":'')).'_CATEGORIES';
 180          }
 181  
 182          // Get help for the categories view for the component by
 183          // -remotely searching in a language defined dedicated URL: *component*_HELP_URL
 184          // -locally  searching in a component help file if helpURL param exists in the component and is set to ''
 185          // -remotely searching in a component URL if helpURL param exists in the component and is NOT set to ''
 186          if ($lang->hasKey($lang_help_url = strtoupper($component).'_HELP_URL'))
 187          {
 188              $debug = $lang->setDebug(false);
 189              $url = JText::_($lang_help_url);
 190              $lang->setDebug($debug);
 191          }
 192          else {
 193              $url = null;
 194          }
 195          JToolbarHelper::help($ref_key, JComponentHelper::getParams($component)->exists('helpURL'), $url);
 196  
 197          JHtmlSidebar::setAction('index.php?option=com_categories&view=categories');
 198  
 199          JHtmlSidebar::addFilter(
 200              JText::_('JOPTION_SELECT_MAX_LEVELS'),
 201              'filter_level',
 202              JHtml::_('select.options', $this->f_levels, 'value', 'text', $this->state->get('filter.level'))
 203          );
 204  
 205          JHtmlSidebar::addFilter(
 206              JText::_('JOPTION_SELECT_PUBLISHED'),
 207              'filter_published',
 208              JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true)
 209          );
 210  
 211          JHtmlSidebar::addFilter(
 212              JText::_('JOPTION_SELECT_ACCESS'),
 213              'filter_access',
 214              JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access'))
 215          );
 216  
 217          JHtmlSidebar::addFilter(
 218              JText::_('JOPTION_SELECT_LANGUAGE'),
 219              'filter_language',
 220              JHtml::_('select.options', JHtml::_('contentlanguage.existing', true, true), 'value', 'text', $this->state->get('filter.language'))
 221          );
 222      }
 223  
 224      /**
 225       * Returns an array of fields the table can be sorted by
 226       *
 227       * @return  array  Array containing the field name to sort by as the key and display text as value
 228       *
 229       * @since   3.0
 230       */
 231  	protected function getSortFields()
 232      {
 233          return array(
 234              'a.lft' => JText::_('JGRID_HEADING_ORDERING'),
 235              'a.state' => JText::_('JSTATUS'),
 236              'a.title' => JText::_('JGLOBAL_TITLE'),
 237              'a.access' => JText::_('JGRID_HEADING_ACCESS'),
 238              'language' => JText::_('JGRID_HEADING_LANGUAGE'),
 239              'a.id' => JText::_('JGRID_HEADING_ID')
 240          );
 241      }
 242  }

title

Description

title

Description

title

Description

title

title

Body