- md5
- fb8a20942494988bd33f85849216aeeb
- sha1
- 2db8b264e0a6acfbda9ceaa897f9b3041696b6c4
- sha256
- 4e937cb5accdc73ffe1e40cdd0b8f9987601a4eb67bba2c4876498e7cfcffcf9
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
<?php
/**
* @package Joomla.Administrator
* @subpackage mod_menu
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Module\Menu\Administrator\Menu;
defined('_JEXEC') or die;
use Joomla\CMS\Uri\Uri;
use Joomla\Filter\OutputFilter;
/**
* A Node for JAdminCssMenu
*
* @see JAdminCssMenu
* @since 1.5
*/
class MenuNode
{
/**
* Node Title
*
* @var string
*/
public $title = null;
/**
* Node Id
*
* @var string
*/
public $id = null;
/**
* Node Link
*
* @var string
*/
public $link = null;
/**
* Link Target
*
* @var string
*/
public $target = null;
/**
* CSS Class for node
*
* @var string
*/
public $class = null;
/**
* Active Node?
*
* @var boolean
*/
public $active = false;
/**
* Parent node
*
* @var MenuNode
*/
protected $_parent = null;
/**
* Array of Children
*
* @var array
*/
protected $_children = array();
/**
* Constructor for the class.
*
* @param string $title The title of the node
* @param string $link The node link
* @param string $class The CSS class for the node
* @param boolean $active True if node is active, false otherwise
* @param string $target The link target
* @param string $titleicon The title icon for the node
*/
public function __construct($title, $link = null, $class = null, $active = false, $target = null, $titleicon = null)
{
$this->title = $titleicon ? $title . $titleicon : $title;
$this->link = OutputFilter::ampReplace($link);
$this->class = $class;
$this->active = $active;
$this->id = null;
if (!empty($link) && $link !== '#')
{
$uri = new Uri($link);
$params = $uri->getQuery(true);
$parts = array();
foreach ($params as $value)
{
$parts[] = str_replace(array('.', '_'), '-', $value);
}
$this->id = implode('-', $parts);
}
$this->target = $target;
}
/**
* Add child to this node
*
* If the child already has a parent, the link is unset
*
* @param MenuNode &$child The child to be added
*
* @return void
*/
public function addChild(MenuNode &$child)
{
$child->setParent($this);
}
/**
* Set the parent of a this node
*
* If the node already has a parent, the link is unset
*
* @param JMenuNode &$parent The JMenuNode for parent to be set or null
*
* @return void
*/
public function setParent(MenuNode &$parent = null)
{
$hash = spl_object_hash($this);
if (!is_null($this->_parent))
{
unset($this->_parent->_children[$hash]);
}
if (!is_null($parent))
{
$parent->_children[$hash] = &$this;
}
$this->_parent = &$parent;
}
/**
* Get the children of this node
*
* @return array The children
*/
public function &getChildren()
{
return $this->_children;
}
/**
* Get the parent of this node
*
* @return mixed JMenuNode object with the parent or null for no parent
*/
public function &getParent()
{
return $this->_parent;
}
/**
* Test if this node has children
*
* @return boolean True if there are children
*/
public function hasChildren()
{
return (bool) count($this->_children);
}
/**
* Test if this node has a parent
*
* @return boolean True if there is a parent
*/
public function hasParent()
{
return $this->getParent() != null;
}
}
The same content is in 2 releases, Joomla 4.0.0-alpha5 to 4.0.0-alpha6. See them all, or every version of this file.