[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/components/com_tags/src/View/Tags/ -> FeedView.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  com_tags
   6   *
   7   * @copyright   (C) 2013 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\Tags\Site\View\Tags;
  12  
  13  use Joomla\CMS\Document\Feed\FeedItem;
  14  use Joomla\CMS\Factory;
  15  use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
  16  use Joomla\CMS\Router\Route;
  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 Tags component all tags view
  24   *
  25   * @since  3.1
  26   */
  27  class FeedView extends BaseHtmlView
  28  {
  29      /**
  30       * Execute and display a template script.
  31       *
  32       * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  33       *
  34       * @return  mixed  A string if successful, otherwise an Error object.
  35       */
  36      public function display($tpl = null)
  37      {
  38          $app                  = Factory::getApplication();
  39          $this->document->link = Route::_('index.php?option=com_tags&view=tags');
  40  
  41          $app->input->set('limit', $app->get('feed_limit'));
  42          $siteEmail = $app->get('mailfrom');
  43          $fromName  = $app->get('fromname');
  44          $feedEmail = $app->get('feed_email', 'none');
  45  
  46          $this->document->editor = $fromName;
  47  
  48          if ($feedEmail !== 'none') {
  49              $this->document->editorEmail = $siteEmail;
  50          }
  51  
  52          // Get some data from the model
  53          $items = $this->get('Items');
  54  
  55          foreach ($items as $item) {
  56              // Strip HTML from feed item title
  57              $title = $this->escape($item->title);
  58              $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
  59  
  60              // Strip HTML from feed item description text
  61              $description = $item->description;
  62              $author      = $item->created_by_alias ?: $item->created_by_user_name;
  63              $date        = $item->created_time ? date('r', strtotime($item->created_time)) : '';
  64  
  65              // Load individual item creator class
  66              $feeditem = new FeedItem();
  67              $feeditem->title       = $title;
  68              $feeditem->link        = '/index.php?option=com_tags&view=tag&id=' . (int) $item->id;
  69              $feeditem->description = $description;
  70              $feeditem->date        = $date;
  71              $feeditem->category    = 'All Tags';
  72              $feeditem->author      = $author;
  73  
  74              if ($feedEmail === 'site') {
  75                  $feeditem->authorEmail = $siteEmail;
  76              }
  77  
  78              if ($feedEmail === 'author') {
  79                  $feeditem->authorEmail = $item->email;
  80              }
  81  
  82              // Loads item info into RSS array
  83              $this->document->addItem($feeditem);
  84          }
  85      }
  86  }


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