File manager - Edit - /home/opticamezl/www/newok/Menu.zip
Back
PK X �\��) �) AbstractMenu.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Menu; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\User\User; use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Menu class * * @since 1.5 */ abstract class AbstractMenu { /** * Array to hold the menu items * * @var MenuItem[] * * @since 4.0.0 */ protected $items = []; /** * Identifier of the default menu item. Key of the array is the language. * * @var integer[] * * @since 4.0.0 */ protected $default = []; /** * Identifier of the active menu item * * @var integer * * @since 4.0.0 */ protected $active = 0; /** * Menu instances container. * * @var AbstractMenu[] * * @since 1.7 * * @deprecated 4.3 will be removed in 6.0 * Use the MenuFactoryInterface from the container instead * Example: Factory::getContainer()->get(MenuFactoryInterface::class)->createMenu($client, $options) */ public static $instances = []; /** * User object to check access levels for * * @var User * * @since 3.9.26 */ protected $storedUser; /** * Flag for checking if the menu items have been loaded * * @var boolean * * @since 4.0.0 */ private $itemsLoaded = false; /** * Class constructor * * @param array $options An array of configuration options. * * @since 1.5 */ public function __construct($options = []) { /** * It is preferred NOT to inject and store the user when constructing the menu object, * at least for the Menu object used by Joomla. * The menu object can be built very early in the request, from an onAfterInitialise event * but the user can be updated later (by the Remember me plugin for instance). As the stored * user object is not updated, the menu will render incorrectly, not complying with * menu items access levels. * * @see https://github.com/joomla/joomla-cms/issues/11541 */ $this->storedUser = isset($options['user']) && $options['user'] instanceof User ? $options['user'] : null; } /** * Returns a Menu object * * @param string $client The name of the client * @param array $options An associative array of options * * @return AbstractMenu A menu object. * * @since 1.5 * * @throws \Exception * * @deprecated 4.3 will be removed in 6.0 * Use the MenuFactoryInterface from the container instead * Example: Factory::getContainer()->get(MenuFactoryInterface::class)->createMenu($client, $options) */ public static function getInstance($client, $options = []) { if (!$client) { throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_MENU_LOAD', $client), 500); } if (empty(self::$instances[$client])) { self::$instances[$client] = Factory::getContainer()->get(MenuFactoryInterface::class)->createMenu($client, $options); } return self::$instances[$client]; } /** * Setter for the current user used to build menu. * * @param User $user The new user to set. * * @return void * * @since 3.9.26 */ public function setUser($user) { $this->storedUser = $user; } /** * Get menu item by id * * @param integer $id The item id * * @return MenuItem|null The item object if the ID exists or null if not found * * @since 1.5 */ public function getItem($id) { $result = null; if (isset($this->getMenu()[$id])) { $result = &$this->getMenu()[$id]; } return $result; } /** * Set the default item by id and language code. * * @param integer $id The menu item id. * @param string $language The language code (since 1.6). * * @return boolean True if a menu item with the given ID exists * * @since 1.5 */ public function setDefault($id, $language = '*') { if (isset($this->getMenu()[$id])) { $this->default[$language] = $id; return true; } return false; } /** * Get the default item by language code. * * @param string $language The language code, default value of * means all. * * @return MenuItem|null The item object or null when not found for given language * * @since 1.5 */ public function getDefault($language = '*') { // Get menu items first to ensure defaults have been populated $items = $this->getMenu(); if (\array_key_exists($language, $this->default)) { return $items[$this->default[$language]]; } if (\array_key_exists('*', $this->default)) { return $items[$this->default['*']]; } return null; } /** * Set the default item by id * * @param integer $id The item id * * @return MenuItem|null The menu item representing the given ID if present or null otherwise * * @since 1.5 */ public function setActive($id) { if (isset($this->getMenu()[$id])) { $this->active = $id; return $this->getMenu()[$id]; } return null; } /** * Get menu item by id. * * @return MenuItem|null The item object if an active menu item has been set or null * * @since 1.5 */ public function getActive() { if ($this->active) { return $this->getMenu()[$this->active]; } return null; } /** * Gets menu items by attribute * * @param mixed $attributes The field name(s). * @param mixed $values The value(s) of the field. If an array, need to match field names * each attribute may have multiple values to lookup for. * @param boolean $firstonly If true, only returns the first item found * * @return MenuItem|MenuItem[] An array of menu item objects or a single object if the $firstonly parameter is true * * @since 1.5 */ public function getItems($attributes, $values, $firstonly = false) { $items = []; $attributes = (array) $attributes; $values = (array) $values; $count = \count($attributes); foreach ($this->getMenu() as $item) { if (!\is_object($item)) { continue; } $test = true; for ($i = 0; $i < $count; $i++) { if (\is_array($values[$i])) { if (!\in_array($item->{$attributes[$i]}, $values[$i])) { $test = false; break; } } else { if ($item->{$attributes[$i]} != $values[$i]) { $test = false; break; } } } if ($test) { if ($firstonly) { return $item; } $items[] = $item; } } return $items; } /** * Gets the parameter object for a certain menu item * * @param integer $id The item id * * @return Registry * * @since 1.5 */ public function getParams($id) { if ($menu = $this->getItem($id)) { return $menu->getParams(); } return new Registry(); } /** * Getter for the menu array * * @return MenuItem[] * * @since 1.5 */ public function getMenu() { if (!$this->itemsLoaded) { $this->load(); foreach ($this->items as $item) { if ($item->home) { $this->default[trim($item->language)] = $item->id; } } $this->itemsLoaded = true; } return $this->items; } /** * Method to check Menu object authorization against an access control object and optionally an access extension object * * @param integer $id The menu id * * @return boolean * * @since 1.5 */ public function authorise($id) { $menu = $this->getItem($id); if ($menu) { $access = (int) $menu->access; // If the access level is public we don't need to load the user session if ($access === 1) { return true; } return \in_array($access, $this->user->getAuthorisedViewLevels(), true); } return true; } /** * Loads the menu items * * @return array * * @since 1.5 */ abstract public function load(); /** * Internal getter for the user. Returns the injected * one if any, or the current one if none. * * @return User * * @since 3.9.26 */ protected function getUser() { return empty($this->storedUser) ? Factory::getUser() : $this->storedUser; } /** * Magic getter for the user object. Returns the injected * one if any, or the current one if none. * * Using a magic getter to preserve B/C when we stopped storing the user object upon construction of the menu object. * As the user property is not initialized anymore, this getter ensures any class extending * this one can still use $instance->user and get a proper value. * * @param string $propName Name of the missing or protected property. * * @return User|null * * @since 3.9.26 */ public function __get($propName) { if ($propName === 'user') { return empty($this->storedUser) ? Factory::getUser() : $this->storedUser; } return null; } } PK X �\7B�F� � MenuFactory.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Menu; use Joomla\CMS\Cache\CacheControllerFactoryAwareInterface; use Joomla\CMS\Cache\CacheControllerFactoryAwareTrait; use Joomla\CMS\Language\Text; use Joomla\Database\DatabaseAwareTrait; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Default factory for creating Menu objects * * @since 4.0.0 */ class MenuFactory implements MenuFactoryInterface { use CacheControllerFactoryAwareTrait; use DatabaseAwareTrait; /** * Creates a new Menu object for the requested format. * * @param string $client The name of the client * @param array $options An associative array of options * * @return AbstractMenu * * @since 4.0.0 * @throws \InvalidArgumentException */ public function createMenu(string $client, array $options = []): AbstractMenu { // Create a Menu object $classname = __NAMESPACE__ . '\\' . ucfirst(strtolower($client)) . 'Menu'; if (!class_exists($classname)) { throw new \InvalidArgumentException(Text::sprintf('JLIB_APPLICATION_ERROR_MENU_LOAD', $client), 500); } if (!array_key_exists('db', $options)) { $options['db'] = $this->getDatabase(); } $instance = new $classname($options); if ($instance instanceof CacheControllerFactoryAwareInterface) { $instance->setCacheControllerFactory($this->getCacheControllerFactory()); } return $instance; } } PK X �\@���A A MenuItem.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Menu; use Joomla\CMS\Tree\NodeInterface; use Joomla\CMS\Tree\NodeTrait; use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Object representing a menu item * * @since 3.7.0 */ #[\AllowDynamicProperties] class MenuItem implements NodeInterface { use NodeTrait; /** * Primary key * * @var integer * @since 3.7.0 */ public $id; /** * The type of menu this item belongs to * * @var integer * @since 3.7.0 */ public $menutype; /** * The display title of the menu item * * @var string * @since 3.7.0 */ public $title; /** * The SEF alias of the menu item * * @var string * @since 3.7.0 */ public $alias; /** * A note associated with the menu item * * @var string * @since 3.7.0 */ public $note; /** * The computed path of the menu item based on the alias field, this is populated from the `path` field in the `#__menu` table * * @var string * @since 3.7.0 */ public $route; /** * The actual link the menu item refers to * * @var string * @since 3.7.0 */ public $link; /** * The type of link * * @var string * @since 3.7.0 */ public $type; /** * The relative level in the tree * * @var integer * @since 3.7.0 */ public $level; /** * The assigned language for this item * * @var string * @since 3.7.0 */ public $language; /** * The click behaviour of the link * * @var integer * @since 3.7.0 */ public $browserNav; /** * The access level required to view the menu item * * @var integer * @since 3.7.0 */ public $access; /** * The menu item parameters * * @var string|Registry * @since 3.7.0 * @note This field is protected to require reading this field to proxy through the getter to convert the params to a Registry instance */ protected $params; /** * Indicates if this menu item is the home or default page * * @var integer * @since 3.7.0 */ public $home; /** * The image of the menu item * * @var string * @since 3.7.0 */ public $img; /** * The optional template style applied to this menu item * * @var integer * @since 3.7.0 */ public $template_style_id; /** * The extension ID of the component this menu item is for * * @var integer * @since 3.7.0 */ public $component_id; /** * The parent menu item in the menu tree * * @var integer * @since 3.7.0 */ public $parent_id; /** * The name of the component this menu item is for * * @var string * @since 3.7.0 */ public $component; /** * The tree of parent menu items * * @var array * @since 3.7.0 */ public $tree = []; /** * An array of the query string values for this item * * @var array * @since 3.7.0 */ public $query = []; /** * Class constructor * * @param array $data The menu item data to load * * @since 3.7.0 */ public function __construct($data = []) { foreach ((array) $data as $key => $value) { $this->$key = $value; } } /** * Returns the menu item parameters * * @return Registry * * @since 3.7.0 */ public function getParams() { if (!($this->params instanceof Registry)) { try { $this->params = new Registry($this->params); } catch (\RuntimeException $e) { /* * Joomla shipped with a broken sample json string for 4 years which caused fatals with new * error checks. So for now we catch the exception here - but one day we should remove it and require * valid JSON. */ $this->params = new Registry(); } } return $this->params; } /** * Sets the menu item parameters * * @param Registry|string $params The data to be stored as the parameters * * @return void * * @since 3.7.0 */ public function setParams($params) { $this->params = $params; } } PK X �\�*�Z Z AdministratorMenu.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Menu; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Menu class. * * @since 1.5 */ class AdministratorMenu extends AbstractMenu { /** * Loads the menu items * * @return array * * @since 4.0.0 */ public function load() { return []; } } PK X �\?&*O6 6 MenuFactoryInterface.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Menu; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Interface defining a factory which can create Menu objects * * @since 4.0.0 */ interface MenuFactoryInterface { /** * Creates a new Menu object for the requested format. * * @param string $client The name of the client * @param array $options An associative array of options * * @return AbstractMenu * * @since 4.0.0 */ public function createMenu(string $client, array $options = []): AbstractMenu; } PK X �\n\wRd d AdministratorMenuItem.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Menu; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Object representing an administrator menu item * * @since 4.0.0 */ class AdministratorMenuItem extends MenuItem { /** * The target attribute of the link * * @var string|null * @since 4.0.0 */ public $target; /** * The icon image of the menu item * * @var string|null * @since 4.0.0 */ public $icon; /** * The icon image of the link * * @var string|null * @since 4.0.0 */ public $iconImage; } PK X �\�l�v$ v$ SiteMenu.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Menu; use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\Cache\CacheControllerFactoryAwareInterface; use Joomla\CMS\Cache\CacheControllerFactoryAwareTrait; use Joomla\CMS\Cache\Controller\CallbackController; use Joomla\CMS\Cache\Exception\CacheExceptionInterface; use Joomla\CMS\Factory; use Joomla\CMS\Language\Language; use Joomla\CMS\Language\Multilanguage; use Joomla\CMS\Language\Text; use Joomla\Database\DatabaseDriver; use Joomla\Database\Exception\ExecutionFailureException; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Menu class * * @since 1.5 */ class SiteMenu extends AbstractMenu implements CacheControllerFactoryAwareInterface { use CacheControllerFactoryAwareTrait; /** * Application object * * @var CMSApplication * @since 3.5 */ protected $app; /** * Database driver * * @var DatabaseDriver * @since 3.5 */ protected $db; /** * Language object * * @var Language * @since 3.5 */ protected $language; /** * Class constructor * * @param array $options An array of configuration options. * * @since 1.5 */ public function __construct($options = []) { // Extract the internal dependencies before calling the parent constructor since it calls $this->load() $this->app = isset($options['app']) && $options['app'] instanceof CMSApplication ? $options['app'] : Factory::getApplication(); $this->language = isset($options['language']) && $options['language'] instanceof Language ? $options['language'] : Factory::getLanguage(); if (!isset($options['db']) || !($options['db'] instanceof DatabaseDriver)) { @trigger_error(sprintf('Database will be mandatory in 5.0.'), E_USER_DEPRECATED); $options['db'] = Factory::getContainer()->get(DatabaseDriver::class); } $this->db = $options['db']; parent::__construct($options); } /** * Loads the entire menu table into memory. * * @return boolean True on success, false on failure * * @since 1.5 */ public function load() { $loader = function () { $currentDate = Factory::getDate()->toSql(); $query = $this->db->getQuery(true) ->select( $this->db->quoteName( [ 'm.id', 'm.menutype', 'm.title', 'm.alias', 'm.note', 'm.link', 'm.type', 'm.level', 'm.language', 'm.browserNav', 'm.access', 'm.params', 'm.home', 'm.img', 'm.template_style_id', 'm.component_id', 'm.parent_id', ] ) ) ->select( $this->db->quoteName( [ 'm.path', 'e.element', ], [ 'route', 'component', ] ) ) ->from($this->db->quoteName('#__menu', 'm')) ->join( 'LEFT', $this->db->quoteName('#__extensions', 'e'), $this->db->quoteName('m.component_id') . ' = ' . $this->db->quoteName('e.extension_id') ) ->where( [ $this->db->quoteName('m.published') . ' = 1', $this->db->quoteName('m.parent_id') . ' > 0', $this->db->quoteName('m.client_id') . ' = 0', ] ) ->extendWhere( 'AND', [ $this->db->quoteName('m.publish_up') . ' IS NULL', $this->db->quoteName('m.publish_up') . ' <= :currentDate1', ], 'OR' ) ->bind(':currentDate1', $currentDate) ->extendWhere( 'AND', [ $this->db->quoteName('m.publish_down') . ' IS NULL', $this->db->quoteName('m.publish_down') . ' >= :currentDate2', ], 'OR' ) ->bind(':currentDate2', $currentDate) ->order($this->db->quoteName('m.lft')); $items = []; $iterator = $this->db->setQuery($query)->getIterator(); foreach ($iterator as $item) { $items[$item->id] = new MenuItem((array) $item); } return $items; }; try { /** @var CallbackController $cache */ $cache = $this->getCacheControllerFactory()->createCacheController('callback', ['defaultgroup' => 'com_menus']); $this->items = $cache->get($loader, [], md5(\get_class($this)), false); } catch (CacheExceptionInterface $e) { try { $this->items = $loader(); } catch (ExecutionFailureException $databaseException) { $this->app->enqueueMessage(Text::sprintf('JERROR_LOADING_MENUS', $databaseException->getMessage()), 'warning'); return false; } } catch (ExecutionFailureException $e) { $this->app->enqueueMessage(Text::sprintf('JERROR_LOADING_MENUS', $e->getMessage()), 'warning'); return false; } foreach ($this->items as &$item) { // Get parent information. $parent_tree = []; if (isset($this->items[$item->parent_id])) { $item->setParent($this->items[$item->parent_id]); $parent_tree = $this->items[$item->parent_id]->tree; } // Create tree. $parent_tree[] = $item->id; $item->tree = $parent_tree; // Create the query array. $url = str_replace('index.php?', '', $item->link); $url = str_replace('&', '&', $url); parse_str($url, $item->query); } return true; } /** * Gets menu items by attribute * * @param string $attributes The field name * @param string $values The value of the field * @param boolean $firstonly If true, only returns the first item found * * @return MenuItem|MenuItem[] An array of menu item objects or a single object if the $firstonly parameter is true * * @since 1.6 */ public function getItems($attributes, $values, $firstonly = false) { $attributes = (array) $attributes; $values = (array) $values; if ($this->app->isClient('site')) { // Filter by language if not set if (($key = array_search('language', $attributes)) === false) { if (Multilanguage::isEnabled()) { $attributes[] = 'language'; $values[] = [Factory::getLanguage()->getTag(), '*']; } } elseif ($values[$key] === null) { unset($attributes[$key], $values[$key]); } // Filter by access level if not set if (($key = array_search('access', $attributes)) === false) { $attributes[] = 'access'; $values[] = $this->user->getAuthorisedViewLevels(); } elseif ($values[$key] === null) { unset($attributes[$key], $values[$key]); } } // Reset arrays or we get a notice if some values were unset $attributes = array_values($attributes); $values = array_values($values); return parent::getItems($attributes, $values, $firstonly); } /** * Get menu item by id * * @param string $language The language code. * * @return MenuItem|null The item object or null when not found for given language * * @since 1.6 */ public function getDefault($language = '*') { // Get menu items first to ensure defaults have been populated $items = $this->getMenu(); if (\array_key_exists($language, $this->default) && $this->app->isClient('site') && $this->app->getLanguageFilter()) { return $items[$this->default[$language]]; } if (\array_key_exists('*', $this->default)) { return $items[$this->default['*']]; } } } PK X �\��) �) AbstractMenu.phpnu �[��� PK X �\7B�F� � �) MenuFactory.phpnu �[��� PK X �\@���A A �0 MenuItem.phpnu �[��� PK X �\�*�Z Z qD AdministratorMenu.phpnu �[��� PK X �\?&*O6 6 G MenuFactoryInterface.phpnu �[��� PK X �\n\wRd d �J AdministratorMenuItem.phpnu �[��� PK X �\�l�v$ v$ ;N SiteMenu.phpnu �[��� PK = �r
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0 |
proxy
|
phpinfo
|
Settings