Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/joomla4/ |
| [Home] [System Details] [Kill Me] |
PK
��[r%�ZZAbstractMenu.phpnu�[���<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Menu;
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Menu class
*
* @since 1.5
* @note Will become abstract in Joomla 4
*/
class AbstractMenu
{
/**
* Array to hold the menu items
*
* @var MenuItem[]
* @since 1.5
* @deprecated 4.0 Will convert to $items
*/
protected $_items = array();
/**
* Identifier of the default menu item
*
* @var integer
* @since 1.5
* @deprecated 4.0 Will convert to $default
*/
protected $_default = array();
/**
* Identifier of the active menu item
*
* @var integer
* @since 1.5
* @deprecated 4.0 Will convert to $active
*/
protected $_active = 0;
/**
* Menu instances container.
*
* @var AbstractMenu[]
* @since 1.7
*/
protected static $instances = array();
/**
* User object to check access levels for
*
* @var \JUser
* @since 3.5
*/
protected $user;
/**
* Class constructor
*
* @param array $options An array of configuration options.
*
* @since 1.5
*/
public function __construct($options = array())
{
// Load the menu items
$this->load();
foreach ($this->_items as $item)
{
if ($item->home)
{
$this->_default[trim($item->language)] = $item->id;
}
}
$this->user = isset($options['user']) &&
$options['user'] instanceof \JUser ? $options['user'] :
\JFactory::getUser();
}
/**
* 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
*/
public static function getInstance($client, $options = array())
{
if (empty(self::$instances[$client]))
{
// Create a Menu object
$classname = 'JMenu' . ucfirst($client);
if (!class_exists($classname))
{
// @deprecated 4.0 Everything in this block is deprecated but the
warning is only logged after the file_exists
// Load the menu object
$info = \JApplicationHelper::getClientInfo($client, true);
if (is_object($info))
{
$path = $info->path . '/includes/menu.php';
\JLoader::register($classname, $path);
if (class_exists($classname))
{
\JLog::add('Non-autoloadable Menu subclasses are deprecated,
support will be removed in 4.0.', \JLog::WARNING,
'deprecated');
}
}
}
if (!class_exists($classname))
{
throw new
\Exception(\JText::sprintf('JLIB_APPLICATION_ERROR_MENU_LOAD',
$client), 500);
}
self::$instances[$client] = new $classname($options);
}
return self::$instances[$client];
}
/**
* 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->_items[$id]))
{
$result = &$this->_items[$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->_items[$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 = '*')
{
if (array_key_exists($language, $this->_default))
{
return $this->_items[$this->_default[$language]];
}
if (array_key_exists('*', $this->_default))
{
return $this->_items[$this->_default['*']];
}
return;
}
/**
* 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->_items[$id]))
{
$this->_active = $id;
return $this->_items[$id];
}
return;
}
/**
* 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->_items[$this->_active];
}
return;
}
/**
* 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 = array();
$attributes = (array) $attributes;
$values = (array) $values;
$count = count($attributes);
foreach ($this->_items 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->params;
}
return new Registry;
}
/**
* Getter for the menu array
*
* @return MenuItem[]
*
* @since 1.5
*/
public function getMenu()
{
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)
{
return in_array((int) $menu->access,
$this->user->getAuthorisedViewLevels());
}
return true;
}
/**
* Loads the menu items
*
* @return array
*
* @since 1.5
*/
public function load()
{
return array();
}
}
PK
��[��vvAdministratorMenu.phpnu�[���<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Menu;
defined('JPATH_PLATFORM') or die;
/**
* Menu class.
*
* @since 1.5
*/
class AdministratorMenu extends AbstractMenu
{
}
PK
��[��L�%�%MenuHelper.phpnu�[���<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Menu;
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Menu Helper utility
*
* @since 3.8.0
*/
class MenuHelper
{
/**
* List of preset include paths
*
* @var array
*
* @since 3.8.0
*/
protected static $presets = null;
/**
* Private constructor
*
* @since 3.8.0
*/
private function __construct()
{
}
/**
* Add a custom preset externally via plugin or any other means.
* WARNING: Presets with same name will replace previously added preset
*except* Joomla's default preset (joomla)
*
* @param string $name The unique identifier for the preset.
* @param string $title The display label for the preset.
* @param string $path The path to the preset file.
* @param bool $replace Whether to replace the preset with the same
name if any (except 'joomla').
*
* @return void
*
* @since 3.8.0
*/
public static function addPreset($name, $title, $path, $replace = true)
{
if (static::$presets === null)
{
static::getPresets();
}
if ($name == 'joomla')
{
$replace = false;
}
if (($replace || !array_key_exists($name, static::$presets)) &&
is_file($path))
{
$preset = new \stdClass;
$preset->name = $name;
$preset->title = $title;
$preset->path = $path;
static::$presets[$name] = $preset;
}
}
/**
* Get a list of available presets.
*
* @return \stdClass[]
*
* @since 3.8.0
*/
public static function getPresets()
{
if (static::$presets === null)
{
// Important: 'null' will cause infinite recursion.
static::$presets = array();
static::addPreset('joomla',
'JLIB_MENUS_PRESET_JOOMLA', JPATH_ADMINISTRATOR .
'/components/com_menus/presets/joomla.xml');
static::addPreset('modern',
'JLIB_MENUS_PRESET_MODERN', JPATH_ADMINISTRATOR .
'/components/com_menus/presets/modern.xml');
// Load from template folder automatically
$app = \JFactory::getApplication();
$tpl = JPATH_THEMES . '/' . $app->getTemplate() .
'/html/com_menus/presets';
if (is_dir($tpl))
{
jimport('joomla.filesystem.folder');
$files = \JFolder::files($tpl, '\.xml$');
foreach ($files as $file)
{
$name = substr($file, 0, -4);
$title = str_replace('-', ' ', $name);
static::addPreset(strtolower($name), ucwords($title), $tpl .
'/' . $file);
}
}
}
return static::$presets;
}
/**
* Load the menu items from a preset file into a hierarchical list of
objects
*
* @param string $name The preset name
* @param bool $fallback Fallback to default (joomla) preset if the
specified one could not be loaded?
*
* @return \stdClass[]
*
* @since 3.8.0
*/
public static function loadPreset($name, $fallback = true)
{
$items = array();
$presets = static::getPresets();
if (isset($presets[$name]) && ($xml =
simplexml_load_file($presets[$name]->path, null, LIBXML_NOCDATA))
&& $xml instanceof \SimpleXMLElement)
{
static::loadXml($xml, $items);
}
elseif ($fallback && isset($presets['joomla']))
{
if (($xml = simplexml_load_file($presets['joomla']->path,
null, LIBXML_NOCDATA)) && $xml instanceof \SimpleXMLElement)
{
static::loadXml($xml, $items);
}
}
return $items;
}
/**
* Method to resolve the menu item alias type menu item
*
* @param \stdClass &$item The alias object
*
* @return void
*
* @since 3.8.0
*/
public static function resolveAlias(&$item)
{
$obj = $item;
while ($obj->type == 'alias')
{
$params = new Registry($obj->params);
$aliasTo = $params->get('aliasoptions');
$db = \JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('a.id, a.link, a.type, e.element')
->from('#__menu a')
->where('a.id = ' . (int) $aliasTo)
->join('left', '#__extensions e ON e.id =
a.component_id = e.id');
try
{
$obj = $db->setQuery($query)->loadObject();
if (!$obj)
{
$item->link = '';
return;
}
}
catch (\Exception $e)
{
$item->link = '';
return;
}
}
$item->id = $obj->id;
$item->link = $obj->link;
$item->type = $obj->type;
$item->element = $obj->element;
}
/**
* Parse the flat list of menu items and prepare the hierarchy of them
using parent-child relationship.
*
* @param \stdClass[] $menuItems List of menu items loaded from
database
*
* @return \stdClass[]
*
* @since 3.8.0
*/
public static function createLevels($menuItems)
{
$result = array();
$result[1] = array();
foreach ($menuItems as $i => &$item)
{
// Resolve the alias item to get the original item
if ($item->type == 'alias')
{
static::resolveAlias($item);
}
if ($item->link = in_array($item->type,
array('separator', 'heading', 'container')) ?
'#' : trim($item->link))
{
$item->submenu = array();
$item->class = isset($item->img) ? $item->img :
'';
$item->scope = isset($item->scope) ? $item->scope : null;
$item->browserNav = $item->browserNav ? '_blank' :
'';
$result[$item->parent_id][$item->id] = $item;
}
}
// Move each of the items under respective parent menu items.
if (count($result[1]))
{
foreach ($result as $parentId => &$mItems)
{
foreach ($mItems as &$mItem)
{
if (isset($result[$mItem->id]))
{
$mItem->submenu = &$result[$mItem->id];
}
}
}
}
// Return only top level items, subtree follows
return $result[1];
}
/**
* Load a menu tree from an XML file
*
* @param \SimpleXMLElement[] $elements The xml menuitem nodes
* @param \stdClass[] &$items The menu hierarchy list to
be populated
* @param string[] $replace The substring replacements for
iterator type items
*
* @return void
*
* @since 3.8.0
*/
protected static function loadXml($elements, &$items, $replace =
array())
{
foreach ($elements as $element)
{
if ($element->getName() != 'menuitem')
{
continue;
}
$select = (string) $element['sql_select'];
$from = (string) $element['sql_from'];
/**
* Following is a repeatable group based on simple database query. This
requires sql_* attributes (sql_select and sql_from are required)
* The values can be used like - "{sql:columnName}" in any
attribute of repeated elements.
* The repeated elements are place inside this xml node but they will be
populated in the same level in the rendered menu
*/
if ($select && $from)
{
$hidden = $element['hidden'] == 'true';
$where = (string) $element['sql_where'];
$order = (string) $element['sql_order'];
$group = (string) $element['sql_group'];
$lJoin = (string) $element['sql_leftjoin'];
$iJoin = (string) $element['sql_innerjoin'];
$db = \JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($select)->from($from);
if ($where)
{
$query->where($where);
}
if ($order)
{
$query->order($order);
}
if ($group)
{
$query->group($group);
}
if ($lJoin)
{
$query->leftJoin($lJoin);
}
if ($iJoin)
{
$query->innerJoin($iJoin);
}
$results = $db->setQuery($query)->loadObjectList();
// Skip the entire group if no items to iterate over.
if ($results)
{
// Show the repeatable group heading node only if not set as hidden.
if (!$hidden)
{
$items[] = static::parseXmlNode($element, $replace);
}
// Iterate over the matching records, items goes in the same level
(not $item->submenu) as this node.
foreach ($results as $result)
{
static::loadXml($element->menuitem, $items, $result);
}
}
}
else
{
$item = static::parseXmlNode($element, $replace);
// Process the child nodes
static::loadXml($element->menuitem, $item->submenu, $replace);
$items[] = $item;
}
}
}
/**
* Create a menu item node from an xml element
*
* @param \SimpleXMLElement $node A menuitem element from preset
xml
* @param string[] $replace The values to substitute in the
title, link and element texts
*
* @return \stdClass
*
* @since 3.8.0
*/
protected static function parseXmlNode($node, $replace = array())
{
$item = new \stdClass;
$item->id = null;
$item->type = (string) $node['type'];
$item->title = (string) $node['title'];
$item->link = (string) $node['link'];
$item->element = (string) $node['element'];
$item->class = (string) $node['class'];
$item->icon = (string) $node['icon'];
$item->browserNav = (string) $node['target'];
$item->access = (int) $node['access'];
$item->params = new Registry(trim($node->params));
$item->scope = (string) $node['scope'] ?:
'default';
$item->submenu = array();
if ($item->type == 'separator' &&
trim($item->title, '- '))
{
$item->params->set('text_separator', 1);
}
// Translate attributes for iterator values
foreach ($replace as $var => $val)
{
$item->title = str_replace("{sql:$var}", $val,
$item->title);
$item->element = str_replace("{sql:$var}", $val,
$item->element);
$item->link = str_replace("{sql:$var}", $val,
$item->link);
$item->class = str_replace("{sql:$var}", $val,
$item->class);
$item->icon = str_replace("{sql:$var}", $val,
$item->icon);
}
return $item;
}
}
PK
��[��BBMenuItem.phpnu�[���<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Menu;
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* Object representing a menu item
*
* @since 3.7.0
* @note This class will no longer extend stdClass in Joomla 4
*/
class MenuItem extends \stdClass
{
/**
* 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 string
* @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 = array();
/**
* An array of the query string values for this item
*
* @var array
* @since 3.7.0
*/
public $query = array();
/**
* Class constructor
*
* @param array $data The menu item data to load
*
* @since 3.7.0
*/
public function __construct($data = array())
{
foreach ((array) $data as $key => $value)
{
$this->$key = $value;
}
}
/**
* Method to get certain otherwise inaccessible properties from the form
field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.7.0
* @deprecated 4.0 Access the item parameters through the `getParams()`
method
*/
public function __get($name)
{
if ($name === 'params')
{
return $this->getParams();
}
return $this->get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form
field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.7.0
* @deprecated 4.0 Set the item parameters through the `setParams()`
method
*/
public function __set($name, $value)
{
if ($name === 'params')
{
$this->setParams($value);
return;
}
$this->set($name, $value);
}
/**
* Method check if a certain otherwise inaccessible properties of the form
field object is set.
*
* @param string $name The property name to check.
*
* @return boolean
*
* @since 3.7.1
* @deprecated 4.0 Deprecated without replacement
*/
public function __isset($name)
{
if ($name === 'params')
{
return !($this->params instanceof Registry);
}
return $this->get($name) !== null;
}
/**
* 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;
}
/**
* Returns a property of the object or the default value if the property
is not set.
*
* @param string $property The name of the property.
* @param mixed $default The default value.
*
* @return mixed The value of the property.
*
* @since 3.7.0
* @deprecated 4.0
*/
public function get($property, $default = null)
{
if (isset($this->$property))
{
return $this->$property;
}
return $default;
}
/**
* Modifies a property of the object, creating it if it does not already
exist.
*
* @param string $property The name of the property.
* @param mixed $value The value of the property to set.
*
* @return mixed Previous value of the property.
*
* @since 3.7.0
* @deprecated 4.0
*/
public function set($property, $value = null)
{
$previous = isset($this->$property) ? $this->$property : null;
$this->$property = $value;
return $previous;
}
}
PK
��[a�Z::Node/Component.phpnu�[���<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Menu\Node;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Menu\Node;
/**
* A Component type of node for MenuTree
*
* @see Node
*
* @since 3.8.0
*/
class Component extends Node
{
/**
* Node Title
*
* @var string
*
* @since 3.8.0
*/
protected $title = null;
/**
* The component name for this node link
*
* @var string
*
* @since 3.8.0
*/
protected $element = null;
/**
* Node Link
*
* @var string
*
* @since 3.8.0
*/
protected $link = null;
/**
* Link Target
*
* @var string
*
* @since 3.8.0
*/
protected $target = null;
/**
* Link title icon
*
* @var string
*
* @since 3.8.0
*/
protected $icon = null;
/**
* Constructor for the class.
*
* @param string $title The title of the node
* @param string $element The component name
* @param string $link The node link
* @param string $target The link target
* @param string $class The CSS class for the node
* @param string $id The node id
* @param string $icon The title icon for the node
*
* @since 3.8.0
*/
public function __construct($title, $element, $link, $target = null,
$class = null, $id = null, $icon = null)
{
$this->title = $title;
$this->element = $element;
$this->link = $link ? \JFilterOutput::ampReplace($link) :
'index.php?option=' . $element;
$this->target = $target;
$this->class = $class;
$this->id = $id;
$this->icon = $icon;
parent::__construct();
}
/**
* Get an attribute value
*
* @param string $name The attribute name
*
* @return mixed
*
* @since 3.8.0
*/
public function get($name)
{
switch ($name)
{
case 'title':
case 'element':
case 'link':
case 'target':
case 'icon':
return $this->$name;
}
return parent::get($name);
}
}
PK
��[发��Node/Container.phpnu�[���<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Menu\Node;
defined('JPATH_PLATFORM') or die;
/**
* A Container type of node for MenuTree
*
* @see Node
*
* @since 3.8.0
*/
class Container extends Heading
{
}
PK��[���N��Node/Heading.phpnu�[���<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Menu\Node;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Menu\Node;
/**
* A Heading type of node for MenuTree
*
* @see Node
*
* @since 3.8.0
*/
class Heading extends Node
{
/**
* Node Title
*
* @var string
*
* @since 3.8.0
*/
protected $title = null;
/**
* Node Link
*
* @var string
*
* @since 3.8.0
*/
protected $link = '#';
/**
* Link title icon
*
* @var string
*
* @since 3.8.0
*/
protected $icon = null;
/**
* Constructor for the class.
*
* @param string $title The title of the node
* @param string $class The CSS class for the node
* @param string $id The node id
* @param string $icon The title icon for the node
*
* @since 3.8.0
*/
public function __construct($title, $class = null, $id = null, $icon =
null)
{
$this->title = $title;
$this->class = $class;
$this->id = $id;
$this->icon = $icon;
parent::__construct();
}
/**
* Get an attribute value
*
* @param string $name The attribute name
*
* @return mixed
*
* @since 3.8.0
*/
public function get($name)
{
switch ($name)
{
case 'title':
case 'link':
case 'icon':
return $this->$name;
}
return parent::get($name);
}
}
PK��[��Node/Separator.phpnu�[���<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Menu\Node;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Menu\Node;
/**
* A Separator type of node for MenuTree
*
* @see Node
*
* @since 3.8.0
*/
class Separator extends Node
{
/**
* Node Title
*
* @var string
*
* @since 3.8.0
*/
protected $title = null;
/**
* Constructor for the class.
*
* @param string $title The title of the node
*
* @since 3.8.0
*/
public function __construct($title = null)
{
$this->title = trim($title, '- ') ? $title : null;
parent::__construct();
}
/**
* Get an attribute value
*
* @param string $name The attribute name
*
* @return mixed
*
* @since 3.8.0
*/
public function get($name)
{
switch ($name)
{
case 'title':
return $this->$name;
}
return parent::get($name);
}
}
PK��[emfNode/Url.phpnu�[���<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Menu\Node;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Menu\Node;
/**
* An external Url type of node for MenuTree
*
* @see Node
*
* @since 3.8.0
*/
class Url extends Node
{
/**
* Node Title
*
* @var string
*
* @since 3.8.0
*/
protected $title = null;
/**
* Node Link
*
* @var string
*
* @since 3.8.0
*/
protected $link = null;
/**
* Link Target
*
* @var string
*
* @since 3.8.0
*/
protected $target = null;
/**
* Link title icon
*
* @var string
*
* @since 3.8.0
*/
protected $icon = null;
/**
* Constructor for the class.
*
* @param string $title The title of the node
* @param string $link The node link
* @param string $target The link target
* @param string $class The CSS class for the node
* @param string $id The node id
* @param string $icon The title icon for the node
*
* @since 3.8.0
*/
public function __construct($title, $link, $target = null, $class = null,
$id = null, $icon = null)
{
$this->title = $title;
$this->link = \JFilterOutput::ampReplace($link);
$this->target = $target;
$this->class = $class;
$this->id = $id;
$this->icon = $icon;
parent::__construct();
}
/**
* Get an attribute value
*
* @param string $name The attribute name
*
* @return mixed
*
* @since 3.8.0
*/
public function get($name)
{
switch ($name)
{
case 'title':
case 'link':
case 'target':
case 'icon':
return $this->$name;
}
return parent::get($name);
}
}
PK��[���SccNode.phpnu�[���<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Menu;
defined('JPATH_PLATFORM') or die;
use Joomla\Registry\Registry;
/**
* A Node for MenuTree
*
* @see Tree
*
* @since 3.8.0
*/
class Node
{
/**
* Node Id
*
* @var string
*
* @since 3.8.0
*/
protected $id = null;
/**
* CSS Class for node
*
* @var string
*
* @since 3.8.0
*/
protected $class = null;
/**
* Whether this node is active
*
* @var bool
*
* @since 3.8.0
*/
protected $active = false;
/**
* Additional custom node params
*
* @var Registry
*
* @since 3.8.0
*/
protected $params;
/**
* Parent node object
*
* @var Node
*
* @since 3.8.0
*/
protected $parent = null;
/**
* Array of Children node objects
*
* @var Node[]
*
* @since 3.8.0
*/
protected $children = array();
/**
* Constructor
*
* @since 3.8.0
*/
public function __construct()
{
$this->params = new Registry;
}
/**
* Add child to this node
*
* If the child already has a parent, the link is unset
*
* @param Node $child The child to be added
*
* @return Node The new added child
*
* @since 3.8.0
*/
public function addChild(Node $child)
{
$hash = spl_object_hash($child);
if (isset($child->parent))
{
$child->parent->removeChild($child);
}
$child->parent = $this;
$this->children[$hash] = $child;
return $child;
}
/**
* Remove a child from this node
*
* If the child exists it is unset
*
* @param Node $child The child to be added
*
* @return void
*
* @since 3.8.0
*/
public function removeChild(Node $child)
{
$hash = spl_object_hash($child);
if (isset($this->children[$hash]))
{
$child->parent = null;
unset($this->children[$hash]);
}
}
/**
* Test if this node has a parent
*
* @return boolean True if there is a parent
*
* @since 3.8.0
*/
public function hasParent()
{
return isset($this->parent);
}
/**
* Get the parent of this node
*
* @return Node The Node object's parent or null for no parent
*
* @since 3.8.0
*/
public function getParent()
{
return $this->parent;
}
/**
* Test if this node has children
*
* @return boolean
*
* @since 3.8.0
*/
public function hasChildren()
{
return count($this->children) > 0;
}
/**
* Get the children of this node
*
* @return Node[] The children
*
* @since 3.8.0
*/
public function getChildren()
{
return $this->children;
}
/**
* Find the current node depth in the tree hierarchy
*
* @return integer The node level in the hierarchy, where ROOT == 0,
First level menu item == 1, and so on.
*
* @since 3.8.0
*/
public function getLevel()
{
return $this->hasParent() ? $this->getParent()->getLevel() + 1 :
0;
}
/**
* Check whether the object instance node is the root node
*
* @return boolean
*
* @since 3.8.0
*/
public function isRoot()
{
return !$this->hasParent();
}
/**
* Set the active state on or off
*
* @param bool $active The new active state
*
* @return void
*
* @since 3.8.0
*/
public function setActive($active)
{
$this->active = (bool) $active;
}
/**
* set the params array
*
* @param Registry $params The params attributes
*
* @return void
*
* @since 3.8.0
*/
public function setParams(Registry $params)
{
$this->params = $params;
}
/**
* Get the param value from the node params
*
* @param string $key The param name
*
* @return mixed
*
* @since 3.8.0
*/
public function getParam($key)
{
return isset($this->params[$key]) ? $this->params[$key] : null;
}
/**
* Get an attribute value
*
* @param string $name The attribute name
*
* @return mixed
*
* @since 3.8.0
*/
public function get($name)
{
switch ($name)
{
case 'id':
case 'class':
case 'active':
case 'params':
return $this->$name;
}
return null;
}
}
PK��[�����SiteMenu.phpnu�[���<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Menu;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Language\Language;
use Joomla\CMS\Language\Multilanguage;
/**
* Menu class
*
* @since 1.5
*/
class SiteMenu extends AbstractMenu
{
/**
* Application object
*
* @var CMSApplication
* @since 3.5
*/
protected $app;
/**
* Database driver
*
* @var \JDatabaseDriver
* @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 = array())
{
// 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'] : \JFactory::getApplication();
$this->db = isset($options['db']) &&
$options['db'] instanceof \JDatabaseDriver ?
$options['db'] : \JFactory::getDbo();
$this->language = isset($options['language']) &&
$options['language'] instanceof Language ?
$options['language'] : \JFactory::getLanguage();
parent::__construct($options);
}
/**
* Loads the entire menu table into memory.
*
* @return boolean True on success, false on failure
*
* @since 1.5
*/
public function load()
{
// For PHP 5.3 compat we can't use $this in the lambda function
below
$db = $this->db;
$loader = function () use ($db)
{
$query = $db->getQuery(true)
->select('m.id, m.menutype, m.title, m.alias, m.note, m.path AS
route, m.link, m.type, m.level, m.language')
->select($db->quoteName('m.browserNav') . ',
m.access, m.params, m.home, m.img, m.template_style_id, m.component_id,
m.parent_id')
->select('e.element as component')
->from('#__menu AS m')
->join('LEFT', '#__extensions AS e ON m.component_id
= e.extension_id')
->where('m.published = 1')
->where('m.parent_id > 0')
->where('m.client_id = 0')
->order('m.lft');
// Set the query
$db->setQuery($query);
return $db->loadObjectList('id',
'Joomla\\CMS\\Menu\\MenuItem');
};
try
{
/** @var \JCacheControllerCallback $cache */
$cache = \JFactory::getCache('com_menus',
'callback');
$this->_items = $cache->get($loader, array(),
md5(get_class($this)), false);
}
catch (\JCacheException $e)
{
try
{
$this->_items = $loader();
}
catch (\JDatabaseExceptionExecuting $databaseException)
{
\JError::raiseWarning(500,
\JText::sprintf('JERROR_LOADING_MENUS',
$databaseException->getMessage()));
return false;
}
}
catch (\JDatabaseExceptionExecuting $e)
{
\JError::raiseWarning(500,
\JText::sprintf('JERROR_LOADING_MENUS', $e->getMessage()));
return false;
}
foreach ($this->_items as &$item)
{
// Get parent information.
$parent_tree = array();
if (isset($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[] = array(\JFactory::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 = '*')
{
if (array_key_exists($language, $this->_default) &&
$this->app->isClient('site') &&
$this->app->getLanguageFilter())
{
return $this->_items[$this->_default[$language]];
}
if (array_key_exists('*', $this->_default))
{
return $this->_items[$this->_default['*']];
}
return;
}
}
PK��[��_��Tree.phpnu�[���<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
namespace Joomla\CMS\Menu;
defined('JPATH_PLATFORM') or die;
/**
* Menu Tree class to represent a menu tree hierarchy
*
* @since 3.8.0
*/
class Tree
{
/**
* The root menu node
*
* @var Node
*
* @since 3.8.0
*/
protected $root = null;
/**
* The current working menu node
*
* @var Node
*
* @since 3.8.0
*/
protected $current = null;
/**
* The CSS style array
*
* @var string[]
*
* @since 3.8.0
*/
protected $css = array();
/**
* Constructor
*
* @since 3.8.0
*/
public function __construct()
{
$this->root = new Node;
$this->current = $this->root;
}
/**
* Get the root node
*
* @return Node
*
* @since 3.8.0
*/
public function getRoot()
{
return $this->root;
}
/**
* Get the current node
*
* @return Node
*
* @since 3.8.0
*/
public function getCurrent()
{
return $this->current;
}
/**
* Get the current node
*
* @param Node $node The node to be set as current
*
* @return void
*
* @since 3.8.0
*/
public function setCurrent($node)
{
if ($node)
{
$this->current = $node;
}
}
/**
* Method to get the parent and set it as active optionally
*
* @param bool $setCurrent Set that parent as the current node for
further working
*
* @return Node
*
* @since 3.8.0
*/
public function getParent($setCurrent = true)
{
$parent = $this->current->getParent();
if ($setCurrent)
{
$this->setCurrent($parent);
}
return $parent;
}
/**
* Method to reset the working pointer to the root node and optionally
clear all menu nodes
*
* @param bool $clear Whether to clear the existing menu items or just
reset the pointer to root element
*
* @return Node The root node
*
* @since 3.8.0
*/
public function reset($clear = false)
{
if ($clear)
{
$this->root = new Node;
$this->css = array();
}
$this->current = $this->root;
return $this->current;
}
/**
* Method to add a child
*
* @param Node $node The node to process
* @param bool $setCurrent Set this new child as the current node for
further working
*
* @return Node The newly added node
*
* @since 3.8.0
*/
public function addChild(Node $node, $setCurrent = false)
{
$this->current->addChild($node);
if ($setCurrent)
{
$this->setCurrent($node);
}
return $node;
}
/**
* Method to get the CSS class name for an icon identifier or create one
if
* a custom image path is passed as the identifier
*
* @return string CSS class name
*
* @since 3.8.0
*/
public function getIconClass()
{
static $classes = array();
$identifier = $this->current->get('class');
// Top level is special
if (trim($identifier) == '' ||
!$this->current->hasParent())
{
return null;
}
if (!isset($classes[$identifier]))
{
// We were passed a class name
if (substr($identifier, 0, 6) == 'class:')
{
$class = substr($identifier, 6);
}
// We were passed background icon url. Build the CSS class for the icon
else
{
$class = preg_replace('#\.[^.]*$#', '',
basename($identifier));
$class = preg_replace('#\.\.[^A-Za-z0-9\.\_\- ]#',
'', $class);
if ($class)
{
$this->css[] = ".menu-$class {background: url($identifier)
no-repeat;}";
}
}
$classes[$identifier] = "menu-$class";
}
return $classes[$identifier];
}
/**
* Get the CSS declarations for this tree
*
* @return string[]
*
* @since 3.8.0
*/
public function getCss()
{
return $this->css;
}
}
PK
��[r%�ZZAbstractMenu.phpnu�[���PK
��[��vv�AdministratorMenu.phpnu�[���PK
��[��L�%�%UMenuHelper.phpnu�[���PK
��[��BBNCMenuItem.phpnu�[���PK
��[a�Z::�\Node/Component.phpnu�[���PK
��[发��HeNode/Container.phpnu�[���PK��[���N��&gNode/Heading.phpnu�[���PK��[��@mNode/Separator.phpnu�[���PK��[emf�qNode/Url.phpnu�[���PK��[���Scc�xNode.phpnu�[���PK��[�������SiteMenu.phpnu�[���PK��[��_��\�Tree.phpnu�[���PK�c�