[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_users/src/View/Notes/ -> HtmlView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_users
   6   *
   7   * @copyright   (C) 2011 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  namespace Joomla\Component\Users\Administrator\View\Notes;
  12  
  13  use Joomla\CMS\Helper\ContentHelper;
  14  use Joomla\CMS\Language\Text;
  15  use Joomla\CMS\MVC\View\GenericDataException;
  16  use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
  17  use Joomla\CMS\Object\CMSObject;
  18  use Joomla\CMS\Toolbar\Toolbar;
  19  use Joomla\CMS\Toolbar\ToolbarHelper;
  20  use Joomla\CMS\User\User;
  21  use Joomla\Registry\Registry;
  22  
  23  // phpcs:disable PSR1.Files.SideEffects
  24  \defined('_JEXEC') or die;
  25  // phpcs:enable PSR1.Files.SideEffects
  26  
  27  /**
  28   * User notes list view
  29   *
  30   * @since  2.5
  31   */
  32  class HtmlView extends BaseHtmlView
  33  {
  34      /**
  35       * A list of user note objects.
  36       *
  37       * @var    array
  38       * @since  2.5
  39       */
  40      protected $items;
  41  
  42      /**
  43       * The pagination object.
  44       *
  45       * @var    \Joomla\CMS\Pagination\Pagination
  46       * @since  2.5
  47       */
  48      protected $pagination;
  49  
  50      /**
  51       * The model state.
  52       *
  53       * @var    CMSObject
  54       * @since  2.5
  55       */
  56      protected $state;
  57  
  58      /**
  59       * The model state.
  60       *
  61       * @var    User
  62       * @since  2.5
  63       */
  64      protected $user;
  65  
  66      /**
  67       * Form object for search filters
  68       *
  69       * @var    \Joomla\CMS\Form\Form
  70       *
  71       * @since  4.0.0
  72       */
  73      public $filterForm;
  74  
  75      /**
  76       * The active search filters
  77       *
  78       * @var    array
  79       * @since  4.0.0
  80       */
  81      public $activeFilters;
  82  
  83      /**
  84       * Is this view an Empty State
  85       *
  86       * @var  boolean
  87       * @since 4.0.0
  88       */
  89      private $isEmptyState = false;
  90  
  91      /**
  92       * Override the display method for the view.
  93       *
  94       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  95       *
  96       * @return  void
  97       *
  98       * @since   2.5
  99       */
 100      public function display($tpl = null)
 101      {
 102          // Initialise view variables.
 103          $this->items         = $this->get('Items');
 104          $this->pagination    = $this->get('Pagination');
 105          $this->state         = $this->get('State');
 106          $this->user          = $this->get('User');
 107          $this->filterForm    = $this->get('FilterForm');
 108          $this->activeFilters = $this->get('ActiveFilters');
 109  
 110          if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
 111              $this->setLayout('emptystate');
 112          }
 113  
 114          // Check for errors.
 115          if (\count($errors = $this->get('Errors'))) {
 116              throw new GenericDataException(implode("\n", $errors), 500);
 117          }
 118  
 119          // Turn parameters into registry objects
 120          foreach ($this->items as $item) {
 121              $item->cparams = new Registry($item->category_params);
 122          }
 123  
 124          $this->addToolbar();
 125          parent::display($tpl);
 126      }
 127  
 128      /**
 129       * Display the toolbar.
 130       *
 131       * @return  void
 132       *
 133       * @since   2.5
 134       */
 135      protected function addToolbar()
 136      {
 137          $canDo = ContentHelper::getActions('com_users', 'category', $this->state->get('filter.category_id'));
 138  
 139          ToolbarHelper::title(Text::_('COM_USERS_VIEW_NOTES_TITLE'), 'users user');
 140  
 141          // Get the toolbar object instance
 142          $toolbar = Toolbar::getInstance('toolbar');
 143  
 144          if ($canDo->get('core.create')) {
 145              $toolbar->addNew('note.add');
 146          }
 147  
 148          if (!$this->isEmptyState && ($canDo->get('core.edit.state') || $canDo->get('core.admin'))) {
 149              $dropdown = $toolbar->dropdownButton('status-group')
 150                  ->text('JTOOLBAR_CHANGE_STATUS')
 151                  ->toggleSplit(false)
 152                  ->icon('icon-ellipsis-h')
 153                  ->buttonClass('btn btn-action')
 154                  ->listCheck(true);
 155  
 156              $childBar = $dropdown->getChildToolbar();
 157  
 158              if ($canDo->get('core.edit.state')) {
 159                  $childBar->publish('notes.publish')->listCheck(true);
 160                  $childBar->unpublish('notes.unpublish')->listCheck(true);
 161                  $childBar->archive('notes.archive')->listCheck(true);
 162                  $childBar->checkin('notes.checkin')->listCheck(true);
 163              }
 164  
 165              if ($this->state->get('filter.published') != -2 && $canDo->get('core.edit.state')) {
 166                  $childBar->trash('notes.trash');
 167              }
 168          }
 169  
 170          if (!$this->isEmptyState && $this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
 171              $toolbar->delete('notes.delete')
 172                  ->text('JTOOLBAR_EMPTY_TRASH')
 173                  ->message('JGLOBAL_CONFIRM_DELETE')
 174                  ->listCheck(true);
 175          }
 176  
 177          if ($canDo->get('core.admin') || $canDo->get('core.options')) {
 178              $toolbar->preferences('com_users');
 179          }
 180  
 181          $toolbar->help('User_Notes');
 182      }
 183  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer