[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/components/com_contact/src/View/Category/ -> HtmlView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  com_contact
   6   *
   7   * @copyright   (C) 2006 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\Contact\Site\View\Category;
  12  
  13  use Joomla\CMS\HTML\HTMLHelper;
  14  use Joomla\CMS\Mail\MailHelper;
  15  use Joomla\CMS\MVC\View\CategoryView;
  16  use Joomla\Component\Contact\Site\Helper\RouteHelper;
  17  
  18  // phpcs:disable PSR1.Files.SideEffects
  19  \defined('_JEXEC') or die;
  20  // phpcs:enable PSR1.Files.SideEffects
  21  
  22  /**
  23   * HTML View class for the Contacts component
  24   *
  25   * @since  1.5
  26   */
  27  class HtmlView extends CategoryView
  28  {
  29      /**
  30       * @var    string  The name of the extension for the category
  31       * @since  3.2
  32       */
  33      protected $extension = 'com_contact';
  34  
  35      /**
  36       * @var    string  Default title to use for page title
  37       * @since  3.2
  38       */
  39      protected $defaultPageTitle = 'COM_CONTACT_DEFAULT_PAGE_TITLE';
  40  
  41      /**
  42       * @var    string  The name of the view to link individual items to
  43       * @since  3.2
  44       */
  45      protected $viewName = 'contact';
  46  
  47      /**
  48       * Run the standard Joomla plugins
  49       *
  50       * @var    boolean
  51       * @since  3.5
  52       */
  53      protected $runPlugins = true;
  54  
  55      /**
  56       * Execute and display a template script.
  57       *
  58       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  59       *
  60       * @return  void
  61       */
  62      public function display($tpl = null)
  63      {
  64          parent::commonCategoryDisplay();
  65  
  66          // Flag indicates to not add limitstart=0 to URL
  67          $this->pagination->hideEmptyLimitstart = true;
  68  
  69          // Prepare the data.
  70          // Compute the contact slug.
  71          foreach ($this->items as $item) {
  72              $item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
  73              $temp       = $item->params;
  74              $item->params = clone $this->params;
  75              $item->params->merge($temp);
  76  
  77              if ($item->params->get('show_email_headings', 0) == 1) {
  78                  $item->email_to = trim($item->email_to);
  79  
  80                  if (!empty($item->email_to) && MailHelper::isEmailAddress($item->email_to)) {
  81                      $item->email_to = HTMLHelper::_('email.cloak', $item->email_to);
  82                  } else {
  83                      $item->email_to = '';
  84                  }
  85              }
  86          }
  87  
  88          parent::display($tpl);
  89      }
  90  
  91      /**
  92       * Prepares the document
  93       *
  94       * @return  void
  95       */
  96      protected function prepareDocument()
  97      {
  98          parent::prepareDocument();
  99  
 100          parent::addFeed();
 101  
 102          if ($this->menuItemMatchCategory) {
 103              // If the active menu item is linked directly to the category being displayed, no further process is needed
 104              return;
 105          }
 106  
 107          // Get ID of the category from active menu item
 108          $menu = $this->menu;
 109  
 110          if (
 111              $menu && $menu->component == 'com_contact' && isset($menu->query['view'])
 112              && in_array($menu->query['view'], ['categories', 'category'])
 113          ) {
 114              $id = $menu->query['id'];
 115          } else {
 116              $id = 0;
 117          }
 118  
 119          $path     = [['title' => $this->category->title, 'link' => '']];
 120          $category = $this->category->getParent();
 121  
 122          while ($category !== null && $category->id != $id && $category->id !== 'root') {
 123              $path[]   = ['title' => $category->title, 'link' => RouteHelper::getCategoryRoute($category->id, $category->language)];
 124              $category = $category->getParent();
 125          }
 126  
 127          $path = array_reverse($path);
 128  
 129          foreach ($path as $item) {
 130              $this->pathway->addItem($item['title'], $item['link']);
 131          }
 132      }
 133  }


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