[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  com_newsfeeds
   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\Newsfeeds\Site\View\Category;
  12  
  13  use Joomla\CMS\MVC\View\CategoryView;
  14  use Joomla\Component\Newsfeeds\Site\Helper\RouteHelper;
  15  
  16  // phpcs:disable PSR1.Files.SideEffects
  17  \defined('_JEXEC') or die;
  18  // phpcs:enable PSR1.Files.SideEffects
  19  
  20  /**
  21   * HTML View class for the Newsfeeds component
  22   *
  23   * @since  1.0
  24   */
  25  class HtmlView extends CategoryView
  26  {
  27      /**
  28       * @var    string  Default title to use for page title
  29       * @since  3.2
  30       */
  31      protected $defaultPageTitle = 'COM_NEWSFEEDS_DEFAULT_PAGE_TITLE';
  32  
  33      /**
  34       * @var    string  The name of the extension for the category
  35       * @since  3.2
  36       */
  37      protected $extension = 'com_newsfeeds';
  38  
  39      /**
  40       * @var    string  The name of the view to link individual items to
  41       * @since  3.2
  42       */
  43      protected $viewName = 'newsfeed';
  44  
  45      /**
  46       * Execute and display a template script.
  47       *
  48       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  49       *
  50       * @return  void
  51       */
  52      public function display($tpl = null)
  53      {
  54          $this->commonCategoryDisplay();
  55  
  56          // Flag indicates to not add limitstart=0 to URL
  57          $this->pagination->hideEmptyLimitstart = true;
  58  
  59          // Prepare the data.
  60          // Compute the newsfeed slug.
  61          foreach ($this->items as $item) {
  62              $item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
  63              $temp       = $item->params;
  64              $item->params = clone $this->params;
  65              $item->params->merge($temp);
  66          }
  67  
  68          parent::display($tpl);
  69      }
  70  
  71      /**
  72       * Prepares the document
  73       *
  74       * @return  void
  75       */
  76      protected function prepareDocument()
  77      {
  78          parent::prepareDocument();
  79  
  80          $menu = $this->menu;
  81          $id = (int) @$menu->query['id'];
  82  
  83          if (
  84              $menu && (!isset($menu->query['option']) || $menu->query['option'] !== 'com_newsfeeds' || $menu->query['view'] === 'newsfeed'
  85              || $id != $this->category->id)
  86          ) {
  87              $path = array(array('title' => $this->category->title, 'link' => ''));
  88              $category = $this->category->getParent();
  89  
  90              while (
  91                  (!isset($menu->query['option']) || $menu->query['option'] !== 'com_newsfeeds' || $menu->query['view'] === 'newsfeed'
  92                  || $id != $category->id) && $category->id > 1
  93              ) {
  94                  $path[] = array('title' => $category->title, 'link' => RouteHelper::getCategoryRoute($category->id, $category->language));
  95                  $category = $category->getParent();
  96              }
  97  
  98              $path = array_reverse($path);
  99  
 100              foreach ($path as $item) {
 101                  $this->pathway->addItem($item['title'], $item['link']);
 102              }
 103          }
 104      }
 105  }


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