Source for file view.html.php

Documentation is available at view.html.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_modules
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 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.  * View class for a list of modules.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_modules
  17.  * @since       1.6
  18.  */
  19. {
  20.     protected $items;
  21.  
  22.     protected $pagination;
  23.  
  24.     protected $state;
  25.  
  26.     /**
  27.      * Display the view
  28.      */
  29.     public function display($tpl null)
  30.     {
  31.         $this->items        = $this->get('Items');
  32.         $this->pagination    = $this->get('Pagination');
  33.         $this->state        = $this->get('State');
  34.  
  35.         // Check for errors.
  36.         if (count($errors $this->get('Errors')))
  37.         {
  38.             JError::raiseError(500implode("\n"$errors));
  39.             return false;
  40.         }
  41.  
  42.         // Check if there are no matching items
  43.         if (!count($this->items)){
  44.             JFactory::getApplication()->enqueueMessage(
  45.                 JText::_('COM_MODULES_MSG_MANAGE_NO_MODULES'),
  46.                 'warning'
  47.             );
  48.         }
  49.  
  50.         $this->addToolbar();
  51.         // Include the component HTML helpers.
  52.         JHtml::addIncludePath(JPATH_COMPONENT '/helpers/html');
  53.         parent::display($tpl);
  54.     }
  55.  
  56.     /**
  57.      * Add the page title and toolbar.
  58.      *
  59.      * @since   1.6
  60.      */
  61.     protected function addToolbar()
  62.     {
  63.         $state    $this->get('State');
  64.         $canDo    ModulesHelper::getActions();
  65.         $user  JFactory::getUser();
  66.  
  67.         // Get the toolbar object instance
  68.         $bar JToolBar::getInstance('toolbar');
  69.  
  70.         JToolbarHelper::title(JText::_('COM_MODULES_MANAGER_MODULES')'cube module');
  71.  
  72.         if ($canDo->get('core.create'))
  73.         {
  74.             // Instantiate a new JLayoutFile instance and render the layout
  75.             $layout new JLayoutFile('toolbar.newmodule');
  76.  
  77.             $bar->appendButton('Custom'$layout->render(array())'new');
  78.         }
  79.  
  80.         if ($canDo->get('core.edit'))
  81.         {
  82.             JToolbarHelper::editList('module.edit');
  83.         }
  84.  
  85.         if ($canDo->get('core.create'))
  86.         {
  87.             JToolbarHelper::custom('modules.duplicate''copy.png''copy_f2.png''JTOOLBAR_DUPLICATE'true);
  88.         }
  89.  
  90.         if ($canDo->get('core.edit.state'))
  91.         {
  92.             JToolbarHelper::publish('modules.publish''JTOOLBAR_PUBLISH'true);
  93.             JToolbarHelper::unpublish('modules.unpublish''JTOOLBAR_UNPUBLISH'true);
  94.             JToolbarHelper::checkin('modules.checkin');
  95.         }
  96.  
  97.         if ($state->get('filter.state'== -&& $canDo->get('core.delete'))
  98.         {
  99.             JToolbarHelper::deleteList('''modules.delete''JTOOLBAR_EMPTY_TRASH');
  100.         elseif ($canDo->get('core.edit.state'))
  101.         {
  102.             JToolbarHelper::trash('modules.trash');
  103.         }
  104.  
  105.         // Add a batch button
  106.         if ($user->authorise('core.create''com_modules'&& $user->authorise('core.edit''com_modules'&& $user->authorise('core.edit.state''com_modules'))
  107.         {
  108.             JHtml::_('bootstrap.modal''collapseModal');
  109.             $title JText::_('JTOOLBAR_BATCH');
  110.  
  111.             // Instantiate a new JLayoutFile instance and render the batch button
  112.             $layout new JLayoutFile('joomla.toolbar.batch');
  113.  
  114.             $dhtml $layout->render(array('title' => $title));
  115.             $bar->appendButton('Custom'$dhtml'batch');
  116.         }
  117.  
  118.         if ($canDo->get('core.admin'))
  119.         {
  120.             JToolbarHelper::preferences('com_modules');
  121.         }
  122.         JToolbarHelper::help('JHELP_EXTENSIONS_MODULE_MANAGER');
  123.  
  124.         JHtmlSidebar::addEntry(
  125.             JText::_('JSITE'),
  126.             'index.php?option=com_modules&filter_client_id=0',
  127.             $this->state->get('filter.client_id'== 0
  128.         );
  129.  
  130.         JHtmlSidebar::addEntry(
  131.             JText::_('JADMINISTRATOR'),
  132.             'index.php?option=com_modules&filter_client_id=1',
  133.             $this->state->get('filter.client_id'== 1
  134.         );
  135.  
  136.         JHtmlSidebar::setAction('index.php?option=com_modules');
  137.  
  138.         JHtmlSidebar::addFilter(
  139.             // @todo we need a label for this
  140.             '',
  141.             'filter_client_id',
  142.             JHtml::_('select.options'ModulesHelper::getClientOptions()'value''text'$this->state->get('filter.client_id')),
  143.             false
  144.         );
  145.  
  146.         JHtmlSidebar::addFilter(
  147.             JText::_('JOPTION_SELECT_PUBLISHED'),
  148.             'filter_state',
  149.             JHtml::_('select.options'ModulesHelper::getStateOptions()'value''text'$this->state->get('filter.state'))
  150.         );
  151.  
  152.         JHtmlSidebar::addFilter(
  153.             JText::_('COM_MODULES_OPTION_SELECT_POSITION'),
  154.             'filter_position',
  155.             JHtml::_('select.options'ModulesHelper::getPositions($this->state->get('filter.client_id'))'value''text'$this->state->get('filter.position'))
  156.         );
  157.  
  158.         JHtmlSidebar::addFilter(
  159.             JText::_('COM_MODULES_OPTION_SELECT_MODULE'),
  160.             'filter_module',
  161.             JHtml::_('select.options'ModulesHelper::getModules($this->state->get('filter.client_id'))'value''text'$this->state->get('filter.module'))
  162.         );
  163.  
  164.         JHtmlSidebar::addFilter(
  165.             JText::_('JOPTION_SELECT_ACCESS'),
  166.             'filter_access',
  167.             JHtml::_('select.options'JHtml::_('access.assetgroups')'value''text'$this->state->get('filter.access'))
  168.         );
  169.  
  170.         JHtmlSidebar::addFilter(
  171.             JText::_('JOPTION_SELECT_LANGUAGE'),
  172.             'filter_language',
  173.             JHtml::_('select.options'JHtml::_('contentlanguage.existing'truetrue)'value''text'$this->state->get('filter.language'))
  174.         );
  175.  
  176.         $this->sidebar JHtmlSidebar::render();
  177.     }
  178.  
  179.     /**
  180.      * Returns an array of fields the table can be sorted by
  181.      *
  182.      * @return  array  Array containing the field name to sort by as the key and display text as value
  183.      *
  184.      * @since   3.0
  185.      */
  186.     protected function getSortFields()
  187.     {
  188.         return array(
  189.             'ordering' => JText::_('JGRID_HEADING_ORDERING'),
  190.             'a.published' => JText::_('JSTATUS'),
  191.             'a.title' => JText::_('JGLOBAL_TITLE'),
  192.             'position' => JText::_('COM_MODULES_HEADING_POSITION'),
  193.             'name' => JText::_('COM_MODULES_HEADING_MODULE'),
  194.             'pages' => JText::_('COM_MODULES_HEADING_PAGES'),
  195.             'a.access' => JText::_('JGRID_HEADING_ACCESS'),
  196.             'language_title' => JText::_('JGRID_HEADING_LANGUAGE'),
  197.             'a.id' => JText::_('JGRID_HEADING_ID')
  198.         );
  199.     }
  200. }

Documentation generated on Tue, 19 Nov 2013 15:17:44 +0100 by phpDocumentor 1.4.3