[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/components/com_content/src/Helper/ -> RouteHelper.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  com_content
   6   *
   7   * @copyright   (C) 2007 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\Content\Site\Helper;
  12  
  13  use Joomla\CMS\Categories\CategoryNode;
  14  use Joomla\CMS\Language\Multilanguage;
  15  
  16  // phpcs:disable PSR1.Files.SideEffects
  17  \defined('_JEXEC') or die;
  18  // phpcs:enable PSR1.Files.SideEffects
  19  
  20  /**
  21   * Content Component Route Helper.
  22   *
  23   * @since  1.5
  24   */
  25  abstract class RouteHelper
  26  {
  27      /**
  28       * Get the article route.
  29       *
  30       * @param   integer  $id        The route of the content item.
  31       * @param   integer  $catid     The category ID.
  32       * @param   integer  $language  The language code.
  33       * @param   string   $layout    The layout value.
  34       *
  35       * @return  string  The article route.
  36       *
  37       * @since   1.5
  38       */
  39      public static function getArticleRoute($id, $catid = 0, $language = 0, $layout = null)
  40      {
  41          // Create the link
  42          $link = 'index.php?option=com_content&view=article&id=' . $id;
  43  
  44          if ((int) $catid > 1) {
  45              $link .= '&catid=' . $catid;
  46          }
  47  
  48          if ($language && $language !== '*' && Multilanguage::isEnabled()) {
  49              $link .= '&lang=' . $language;
  50          }
  51  
  52          if ($layout) {
  53              $link .= '&layout=' . $layout;
  54          }
  55  
  56          return $link;
  57      }
  58  
  59      /**
  60       * Get the category route.
  61       *
  62       * @param   integer  $catid     The category ID.
  63       * @param   integer  $language  The language code.
  64       * @param   string   $layout    The layout value.
  65       *
  66       * @return  string  The article route.
  67       *
  68       * @since   1.5
  69       */
  70      public static function getCategoryRoute($catid, $language = 0, $layout = null)
  71      {
  72          if ($catid instanceof CategoryNode) {
  73              $id = $catid->id;
  74          } else {
  75              $id = (int) $catid;
  76          }
  77  
  78          if ($id < 1) {
  79              return '';
  80          }
  81  
  82          $link = 'index.php?option=com_content&view=category&id=' . $id;
  83  
  84          if ($language && $language !== '*' && Multilanguage::isEnabled()) {
  85              $link .= '&lang=' . $language;
  86          }
  87  
  88          if ($layout) {
  89              $link .= '&layout=' . $layout;
  90          }
  91  
  92          return $link;
  93      }
  94  
  95      /**
  96       * Get the form route.
  97       *
  98       * @param   integer  $id  The form ID.
  99       *
 100       * @return  string  The article route.
 101       *
 102       * @since   1.5
 103       */
 104      public static function getFormRoute($id)
 105      {
 106          return 'index.php?option=com_content&task=article.edit&a_id=' . (int) $id;
 107      }
 108  }


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