Server IP : 1.179.227.78 / Your IP : 10.104.4.41 Web Server : Apache System : Linux afdc-mdu34 5.4.0-153-generic #170-Ubuntu SMP Fri Jun 16 13:43:31 UTC 2023 x86_64 User : www ( 1001) PHP Version : 7.4.30 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/afdc-mdu34.rtarf.mi.th/joomla/components/com_weblinks/helpers/ |
Upload File : |
<?php /** * @package Joomla.Administrator * @subpackage Weblinks * * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Weblinks Component Route Helper. * * @since 1.5 */ abstract class WeblinksHelperRoute { protected static $lookup; protected static $lang_lookup = array(); /** * Get the route of the weblink * * @param integer $id Web link ID * @param integer $catid Category ID * @param string $language Language * * @return string */ public static function getWeblinkRoute($id, $catid, $language = 0) { $needles = array('weblink' => array((int) $id)); // Create the link $link = 'index.php?option=com_weblinks&view=weblink&id=' . $id; if ($catid > 1) { $categories = JCategories::getInstance('Weblinks'); $category = $categories->get($catid); if ($category) { $needles['category'] = array_reverse($category->getPath()); $needles['categories'] = $needles['category']; $link .= '&catid=' . $catid; } } if ($language && $language != "*" && JLanguageMultilang::isEnabled()) { self::buildLanguageLookup(); if (isset(self::$lang_lookup[$language])) { $link .= '&lang=' . self::$lang_lookup[$language]; $needles['language'] = $language; } } if ($item = self::_findItem($needles)) { $link .= '&Itemid=' . $item; } return $link; } /** * Ge the form route * * @param integer $id The id of the weblink. * @param string $return The return page variable. * * @return string */ public static function getFormRoute($id, $return = null) { // Create the link. if ($id) { $link = 'index.php?option=com_weblinks&task=weblink.edit&w_id=' . $id; } else { $link = 'index.php?option=com_weblinks&task=weblink.add&w_id=0'; } if ($return) { $link .= '&return=' . $return; } return $link; } /** * Get the Category Route * * @param JCategoryNode|string|integer $catid JCategoryNode object or category ID * @param integer $language Language code * * @return string */ public static function getCategoryRoute($catid, $language = 0) { if ($catid instanceof JCategoryNode) { $id = $catid->id; $category = $catid; } else { $id = (int) $catid; $category = JCategories::getInstance('Weblinks')->get($id); } if ($id < 1 || !($category instanceof JCategoryNode)) { $link = ''; } else { $needles = array(); // Create the link $link = 'index.php?option=com_weblinks&view=category&id=' . $id; $catids = array_reverse($category->getPath()); $needles['category'] = $catids; $needles['categories'] = $catids; if ($language && $language != "*" && JLanguageMultilang::isEnabled()) { self::buildLanguageLookup(); if (isset(self::$lang_lookup[$language])) { $link .= '&lang=' . self::$lang_lookup[$language]; $needles['language'] = $language; } } if ($item = self::_findItem($needles)) { $link .= '&Itemid=' . $item; } } return $link; } /** * Do a language lookup * * @return void */ protected static function buildLanguageLookup() { if (count(self::$lang_lookup) == 0) { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('a.sef AS sef') ->select('a.lang_code AS lang_code') ->from('#__languages AS a'); $db->setQuery($query); $langs = $db->loadObjectList(); foreach ($langs as $lang) { self::$lang_lookup[$lang->lang_code] = $lang->sef; } } } /** * Find items per given $needles * * @param array $needles A given array of needles to find * * @return void */ protected static function _findItem($needles = null) { $app = JFactory::getApplication(); $menus = $app->getMenu('site'); $language = isset($needles['language']) ? $needles['language'] : '*'; // Prepare the reverse lookup array. if (!isset(self::$lookup[$language])) { self::$lookup[$language] = array(); $component = JComponentHelper::getComponent('com_weblinks'); $attributes = array('component_id'); $values = array($component->id); if ($language != '*') { $attributes[] = 'language'; $values[] = array($needles['language'], '*'); } $items = $menus->getItems($attributes, $values); if ($items) { foreach ($items as $item) { if (isset($item->query) && isset($item->query['view'])) { $view = $item->query['view']; if (!isset(self::$lookup[$language][$view])) { self::$lookup[$language][$view] = array(); } if (isset($item->query['id'])) { /** * Here it will become a bit tricky * language != * can override existing entries * language == * cannot override existing entries */ if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*') { self::$lookup[$language][$view][$item->query['id']] = $item->id; } } } } } } if ($needles) { foreach ($needles as $view => $ids) { if (isset(self::$lookup[$language][$view])) { foreach ($ids as $id) { if (isset(self::$lookup[$language][$view][(int) $id])) { return self::$lookup[$language][$view][(int) $id]; } } } } } // Check if the active menuitem matches the requested language $active = $menus->getActive(); if ($active && ($language == '*' || in_array($active->language, array('*', $language)) || !JLanguageMultilang::isEnabled())) { return $active->id; } // If not found, return language specific home link $default = $menus->getDefault($language); return !empty($default->id) ? $default->id : null; } }