Source for file view.html.php

Documentation is available at view.html.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_users
  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
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * User notes list view
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_users
  17.  * @since       2.5
  18.  */
  19. class UsersViewNotes extends JViewLegacy
  20. {
  21.     /**
  22.      * A list of user note objects.
  23.      *
  24.      * @var    array 
  25.      * @since  2.5
  26.      */
  27.     protected $items;
  28.  
  29.     /**
  30.      * The pagination object.
  31.      *
  32.      * @var    JPagination 
  33.      * @since  2.5
  34.      */
  35.     protected $pagination;
  36.  
  37.     /**
  38.      * The model state.
  39.      *
  40.      * @var    JObject 
  41.      * @since  2.5
  42.      */
  43.     protected $state;
  44.  
  45.     /**
  46.      * The model state.
  47.      *
  48.      * @var    JUser 
  49.      * @since  2.5
  50.      */
  51.     protected $user;
  52.  
  53.     /**
  54.      * Override the display method for the view.
  55.      *
  56.      * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  57.      *
  58.      * @return  mixed  A string if successful, otherwise a JError object.
  59.      *
  60.      * @since   2.5
  61.      */
  62.     public function display($tpl null)
  63.     {
  64.         // Initialise view variables.
  65.         $this->items      = $this->get('Items');
  66.         $this->pagination = $this->get('Pagination');
  67.         $this->state      = $this->get('State');
  68.         $this->user       = $this->get('User');
  69.  
  70.         UsersHelper::addSubmenu('notes');
  71.  
  72.         // Check for errors.
  73.         if (count($errors $this->get('Errors')))
  74.         {
  75.             throw new Exception(implode("\n"$errors)500);
  76.         }
  77.  
  78.         // Get the component HTML helpers
  79.         JHtml::addIncludePath(JPATH_COMPONENT '/helpers/html');
  80.  
  81.         // turn parameters into registry objects
  82.         foreach ($this->items as $item)
  83.         {
  84.             $item->cparams new JRegistry;
  85.             $item->cparams->loadString($item->category_params);
  86.         }
  87.  
  88.         $this->addToolbar();
  89.         $this->sidebar JHtmlSidebar::render();
  90.         parent::display($tpl);
  91.     }
  92.  
  93.     /**
  94.      * Display the toolbar.
  95.      *
  96.      * @return  void 
  97.      *
  98.      * @since   2.5
  99.      */
  100.     protected function addToolbar()
  101.     {
  102.         $canDo UsersHelper::getActions();
  103.  
  104.         JToolbarHelper::title(JText::_('COM_USERS_VIEW_NOTES_TITLE')'users user');
  105.  
  106.         if ($canDo->get('core.create'))
  107.         {
  108.             JToolbarHelper::addNew('note.add');
  109.         }
  110.  
  111.         if ($canDo->get('core.edit'))
  112.         {
  113.             JToolbarHelper::editList('note.edit');
  114.         }
  115.  
  116.         if ($canDo->get('core.edit.state'))
  117.         {
  118.             JToolbarHelper::divider();
  119.             JToolbarHelper::publish('notes.publish''JTOOLBAR_PUBLISH'true);
  120.             JToolbarHelper::unpublish('notes.unpublish''JTOOLBAR_UNPUBLISH'true);
  121.  
  122.             JToolbarHelper::divider();
  123.             JToolbarHelper::archiveList('notes.archive');
  124.             JToolbarHelper::checkin('notes.checkin');
  125.         }
  126.  
  127.         if ($this->state->get('filter.state'== -&& $canDo->get('core.delete'))
  128.         {
  129.             JToolbarHelper::deleteList('''notes.delete''JTOOLBAR_EMPTY_TRASH');
  130.             JToolbarHelper::divider();
  131.         }
  132.         elseif ($canDo->get('core.edit.state'))
  133.         {
  134.             JToolbarHelper::trash('notes.trash');
  135.             JToolbarHelper::divider();
  136.         }
  137.  
  138.         if ($canDo->get('core.admin'))
  139.         {
  140.             JToolbarHelper::preferences('com_users');
  141.             JToolbarHelper::divider();
  142.         }
  143.         JToolbarHelper::help('JHELP_USERS_USER_NOTES');
  144.  
  145.         JHtmlSidebar::setAction('index.php?option=com_users&view=notes');
  146.  
  147.         JHtmlSidebar::addFilter(
  148.             JText::_('JOPTION_SELECT_PUBLISHED'),
  149.             'filter_published',
  150.             JHtml::_('select.options'JHtml::_('jgrid.publishedOptions')'value''text'$this->state->get('filter.state')true)
  151.         );
  152.  
  153.         JHtmlSidebar::addFilter(
  154.             JText::_('JOPTION_SELECT_CATEGORY'),
  155.             'filter_category_id',
  156.             JHtml::_('select.options'JHtml::_('category.options''com_users.notes')'value''text'$this->state->get('filter.category_id'))
  157.         );
  158.     }
  159.  
  160.     /**
  161.      * Returns an array of fields the table can be sorted by
  162.      *
  163.      * @return  array  Array containing the field name to sort by as the key and display text as value
  164.      *
  165.      * @since   3.0
  166.      */
  167.     protected function getSortFields()
  168.     {
  169.         return array(
  170.             'u.name' => JText::_('COM_USERS_USER_HEADING'),
  171.             'a.subject' => JText::_('COM_USERS_SUBJECT_HEADING'),
  172.             'c.title' => JText::_('COM_USERS_CATEGORY_HEADING'),
  173.             'a.state' => JText::_('JSTATUS'),
  174.             'a.review_time' => JText::_('COM_USERS_REVIEW_HEADING'),
  175.             'a.id' => JText::_('JGRID_HEADING_ID')
  176.         );
  177.     }
  178. }

Documentation generated on Tue, 19 Nov 2013 15:18:09 +0100 by phpDocumentor 1.4.3