[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  com_contact
   6   *
   7   * @copyright   (C) 2017 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\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   * Contact Component Route Helper
  22   *
  23   * @static
  24   * @package     Joomla.Site
  25   * @subpackage  com_contact
  26   * @since       1.5
  27   */
  28  abstract class RouteHelper
  29  {
  30      /**
  31       * Get the URL route for a contact from a contact ID, contact category ID and language
  32       *
  33       * @param   integer  $id        The id of the contact
  34       * @param   integer  $catid     The id of the contact's category
  35       * @param   mixed    $language  The id of the language being used.
  36       *
  37       * @return  string  The link to the contact
  38       *
  39       * @since   1.5
  40       */
  41      public static function getContactRoute($id, $catid, $language = 0)
  42      {
  43          // Create the link
  44          $link = 'index.php?option=com_contact&view=contact&id=' . $id;
  45  
  46          if ($catid > 1) {
  47              $link .= '&catid=' . $catid;
  48          }
  49  
  50          if ($language && $language !== '*' && Multilanguage::isEnabled()) {
  51              $link .= '&lang=' . $language;
  52          }
  53  
  54          return $link;
  55      }
  56  
  57      /**
  58       * Get the URL route for a contact category from a contact category ID and language
  59       *
  60       * @param   mixed  $catid     The id of the contact's category either an integer id or an instance of CategoryNode
  61       * @param   mixed  $language  The id of the language being used.
  62       *
  63       * @return  string  The link to the contact
  64       *
  65       * @since   1.5
  66       */
  67      public static function getCategoryRoute($catid, $language = 0)
  68      {
  69          if ($catid instanceof CategoryNode) {
  70              $id = $catid->id;
  71          } else {
  72              $id       = (int) $catid;
  73          }
  74  
  75          if ($id < 1) {
  76              $link = '';
  77          } else {
  78              // Create the link
  79              $link = 'index.php?option=com_contact&view=category&id=' . $id;
  80  
  81              if ($language && $language !== '*' && Multilanguage::isEnabled()) {
  82                  $link .= '&lang=' . $language;
  83              }
  84          }
  85  
  86          return $link;
  87      }
  88  }


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