diff --git a/administrator/components/com_menus/Helper/MenusHelper.php b/administrator/components/com_menus/Helper/MenusHelper.php
index d6806b32f0222..b0d36eb3ca53a 100644
--- a/administrator/components/com_menus/Helper/MenusHelper.php
+++ b/administrator/components/com_menus/Helper/MenusHelper.php
@@ -17,7 +17,7 @@
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Language\Text;
-use Joomla\CMS\Menu\MenuItem;
+use Joomla\CMS\Menu\AdministratorMenuItem;
use Joomla\CMS\Table\Table;
use Joomla\Database\DatabaseInterface;
use Joomla\Database\ParameterType;
@@ -316,13 +316,13 @@ public static function getAssociations($pk)
* @param boolean $enabledOnly Whether to load only enabled/published menu items.
* @param int[] $exclude The menu items to exclude from the list
*
- * @return MenuItem A root node with the menu items as children
+ * @return AdministratorMenuItem A root node with the menu items as children
*
* @since 4.0.0
*/
public static function getMenuItems($menutype, $enabledOnly = false, $exclude = array())
{
- $root = new MenuItem;
+ $root = new AdministratorMenuItem;
$db = Factory::getContainer()->get(DatabaseInterface::class);
$query = $db->getQuery(true);
@@ -382,15 +382,13 @@ public static function getMenuItems($menutype, $enabledOnly = false, $exclude =
foreach ($iterator as $item)
{
- $menuItems[$item->id] = new MenuItem((array) $item);
+ $menuItems[$item->id] = new AdministratorMenuItem((array) $item);
}
unset($iterator);
foreach ($menuItems as $menuitem)
{
- $menuitem->params = new Registry($menuitem->params);
-
// Resolve the alias item to get the original item
if ($menuitem->type == 'alias')
{
@@ -399,10 +397,10 @@ public static function getMenuItems($menutype, $enabledOnly = false, $exclude =
if ($menuitem->link = in_array($menuitem->type, array('separator', 'heading', 'container')) ? '#' : trim($menuitem->link))
{
- $menuitem->submenu = array();
- $menuitem->class = $menuitem->img ?? '';
- $menuitem->scope = $menuitem->scope ?? null;
- $menuitem->browserNav = $menuitem->browserNav ? '_blank' : '';
+ $menuitem->submenu = array();
+ $menuitem->class = $menuitem->img ?? '';
+ $menuitem->scope = $menuitem->scope ?? null;
+ $menuitem->target = $menuitem->browserNav ? '_blank' : '';
}
$menuitem->ajaxbadge = $menuitem->getParams()->get('ajax-badge');
@@ -456,8 +454,8 @@ public static function installPreset($preset, $menutype)
/**
* Method to install a preset menu item into database and link it to the given menutype
*
- * @param MenuItem $node The parent node of the items to process
- * @param string $menutype The target menutype
+ * @param AdministratorMenuItem $node The parent node of the items to process
+ * @param string $menutype The target menutype
*
* @return void
*
@@ -542,7 +540,7 @@ protected static function installPresetItems($node, $menutype)
}
// Translate "hideitems" param value from "element" into "menu-item-id"
- if ($item->type == 'container' && count($hideitems = (array) $item->params->get('hideitems')))
+ if ($item->type == 'container' && count($hideitems = (array) $item->getParams()->get('hideitems')))
{
foreach ($hideitems as &$hel)
{
@@ -558,7 +556,7 @@ protected static function installPresetItems($node, $menutype)
->whereIn($db->quoteName('component_id'), $hideitems);
$hideitems = $db->setQuery($query)->loadColumn();
- $item->params->set('hideitems', $hideitems);
+ $item->getParams()->set('hideitems', $hideitems);
}
$record = array(
@@ -567,7 +565,7 @@ protected static function installPresetItems($node, $menutype)
'alias' => $item->alias,
'type' => $item->type,
'link' => $item->link,
- 'browserNav' => $item->browserNav ? 1 : 0,
+ 'browserNav' => $item->browserNav,
'img' => $item->class,
'access' => $item->access,
'component_id' => array_search($item->element, $components) ?: 0,
@@ -576,7 +574,7 @@ protected static function installPresetItems($node, $menutype)
'published' => 1,
'language' => '*',
'home' => 0,
- 'params' => (string) $item->params,
+ 'params' => (string) $item->getParams(),
);
if (!$table->bind($record))
@@ -689,11 +687,11 @@ public static function getPresets()
/**
* 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?
- * @param MenuItem $parent Root node of the menu
+ * @param string $name The preset name
+ * @param bool $fallback Fallback to default (joomla) preset if the specified one could not be loaded?
+ * @param AdministratorMenuItem $parent Root node of the menu
*
- * @return MenuItem
+ * @return AdministratorMenuItem
*
* @since 4.0.0
*/
@@ -703,7 +701,7 @@ public static function loadPreset($name, $fallback = true, $parent = null)
if (!$parent)
{
- $parent = new MenuItem;
+ $parent = new AdministratorMenuItem;
}
if (isset($presets[$name]) && ($xml = simplexml_load_file($presets[$name]->path, null, LIBXML_NOCDATA)) && $xml instanceof \SimpleXMLElement)
@@ -724,7 +722,7 @@ public static function loadPreset($name, $fallback = true, $parent = null)
/**
* Method to resolve the menu item alias type menu item
*
- * @param \stdClass &$item The alias object
+ * @param AdministratorMenuItem &$item The alias object
*
* @return void
*
@@ -736,8 +734,7 @@ public static function resolveAlias(&$item)
while ($obj->type == 'alias')
{
- $params = new Registry($obj->params);
- $aliasTo = (int) $params->get('aliasoptions');
+ $aliasTo = (int) $obj->getParams()->get('aliasoptions');
$db = Factory::getDbo();
$query = $db->getQuery(true);
@@ -756,7 +753,7 @@ public static function resolveAlias(&$item)
try
{
- $obj = $db->setQuery($query)->loadObject();
+ $obj = new AdministratorMenuItem($db->setQuery($query)->loadAssoc());
if (!$obj)
{
@@ -782,7 +779,7 @@ public static function resolveAlias(&$item)
/**
* Parse the flat list of menu items and prepare the hierarchy of them using parent-child relationship.
*
- * @param MenuItem $item Menu item to preprocess
+ * @param AdministratorMenuItem $item Menu item to preprocess
*
* @return void
*
@@ -798,18 +795,18 @@ public static function preprocess($item)
if ($item->link = in_array($item->type, array('separator', 'heading', 'container')) ? '#' : trim($item->link))
{
- $item->class = $item->img ?? '';
- $item->scope = $item->scope ?? null;
- $item->browserNav = $item->browserNav ? '_blank' : '';
+ $item->class = $item->img ?? '';
+ $item->scope = $item->scope ?? null;
+ $item->target = $item->browserNav ? '_blank' : '';
}
}
/**
* Load a menu tree from an XML file
*
- * @param \SimpleXMLElement[] $elements The xml menuitem nodes
- * @param MenuItem $parent The menu hierarchy list to be populated
- * @param string[] $replace The substring replacements for iterator type items
+ * @param \SimpleXMLElement[] $elements The xml menuitem nodes
+ * @param AdministratorMenuItem $parent The menu hierarchy list to be populated
+ * @param string[] $replace The substring replacements for iterator type items
*
* @return void
*
@@ -923,30 +920,28 @@ protected static function loadXml($elements, $parent, $replace = array())
*/
protected static function parseXmlNode($node, $replace = array())
{
- $item = new MenuItem;
+ $item = new AdministratorMenuItem;
$item->id = null;
$item->type = (string) $node['type'];
$item->title = (string) $node['title'];
- $item->target = (string) $node['target'];
$item->alias = (string) $node['alias'];
$item->link = (string) $node['link'];
$item->target = (string) $node['target'];
$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->scope = (string) $node['scope'] ?: 'default';
- $item->permission = (string) $node['permission'];
$item->ajaxbadge = (string) $node['ajax-badge'];
$item->dashboard = (string) $node['dashboard'];
- $item->setParams(new Registry(trim($node->params)));
- $item->getParams()->set('menu-permission', (string) $node['permission']);
+
+ $params = new Registry(trim($node->params));
+ $params->set('menu-permission', (string) $node['permission']);
if ($item->type == 'separator' && trim($item->title, '- '))
{
- $item->getParams()->set('text_separator', 1);
+ $params->set('text_separator', 1);
}
if ($item->type == 'heading' || $item->type == 'container')
@@ -956,11 +951,11 @@ protected static function parseXmlNode($node, $replace = array())
if ((string) $node['quicktask'])
{
- $item->getParams()->set('menu-quicktask', true);
- $item->getParams()->set('menu-quicktask-link', (string) $node['quicktask']);
- $item->getParams()->set('menu-quicktask-title', (string) $node['quicktask-title']);
- $item->getParams()->set('menu-quicktask-icon', (string) $node['quicktask-icon']);
- $item->getParams()->set('menu-quicktask-permission', (string) $node['quicktask-permission']);
+ $params->set('menu-quicktask', true);
+ $params->set('menu-quicktask-link', (string) $node['quicktask']);
+ $params->set('menu-quicktask-title', (string) $node['quicktask-title']);
+ $params->set('menu-quicktask-icon', (string) $node['quicktask-icon']);
+ $params->set('menu-quicktask-permission', (string) $node['quicktask-permission']);
}
// Translate attributes for iterator values
@@ -971,10 +966,11 @@ protected static function parseXmlNode($node, $replace = array())
$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);
- $params = $item->getParams();
$params->set('menu-quicktask-link', str_replace("{sql:$var}", $val, $params->get('menu-quicktask-link')));
}
+ $item->setParams($params);
+
return $item;
}
}
diff --git a/administrator/components/com_menus/View/Menu/XmlView.php b/administrator/components/com_menus/View/Menu/XmlView.php
index 5ca1db84ea172..1ef01e9564fab 100644
--- a/administrator/components/com_menus/View/Menu/XmlView.php
+++ b/administrator/components/com_menus/View/Menu/XmlView.php
@@ -149,9 +149,9 @@ protected function addXmlChild($xml, $item)
$node['target'] = '_blank';
}
- if (count($item->params))
+ if (count($item->getParams()))
{
- $hideitems = $item->params->get('hideitems');
+ $hideitems = $item->getParams()->get('hideitems');
if (count($hideitems))
{
@@ -166,10 +166,10 @@ protected function addXmlChild($xml, $item)
$hideitems = $db->setQuery($query)->loadColumn();
- $item->params->set('hideitems', $hideitems);
+ $item->getParams()->set('hideitems', $hideitems);
}
- $node->addChild('params', (string) $item->params);
+ $node->addChild('params', (string) $item->getParams());
}
foreach ($item->submenu as $sub)
diff --git a/administrator/modules/mod_menu/Menu/CssMenu.php b/administrator/modules/mod_menu/Menu/CssMenu.php
index 48ea96077573d..29bf975dba8cc 100644
--- a/administrator/modules/mod_menu/Menu/CssMenu.php
+++ b/administrator/modules/mod_menu/Menu/CssMenu.php
@@ -14,7 +14,7 @@
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Language\Text;
-use Joomla\CMS\Menu\MenuItem;
+use Joomla\CMS\Menu\AdministratorMenuItem;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Uri\Uri;
use Joomla\Component\Menus\Administrator\Helper\MenusHelper;
@@ -31,16 +31,16 @@ class CssMenu
/**
* The root of the menu
*
- * @var MenuItem
+ * @var AdministratorMenuItem
*
* @since 4.0.0
*/
protected $root;
/**
- * An array of MenuItem nodes
+ * An array of AdministratorMenuItem nodes
*
- * @var MenuItem[]
+ * @var AdministratorMenuItem[]
*
* @since 4.0.0
*/
@@ -92,7 +92,7 @@ class CssMenu
public function __construct(CMSApplication $application)
{
$this->application = $application;
- $this->root = new MenuItem;
+ $this->root = new AdministratorMenuItem;
}
/**
@@ -101,7 +101,7 @@ public function __construct(CMSApplication $application)
* @param Registry $params Menu configuration parameters
* @param bool $enabled Whether the menu should be enabled or disabled
*
- * @return MenuItem Root node of the menu tree
+ * @return AdministratorMenuItem Root node of the menu tree
*
* @since 3.7.0
*/
@@ -128,21 +128,21 @@ public function load($params, $enabled)
$this->params->set('recovery', true);
// In recovery mode, load the preset inside a special root node.
- $this->root = new MenuItem(['level' => 0]);
- $heading = new MenuItem(['title' => 'MOD_MENU_RECOVERY_MENU_ROOT', 'type' => 'heading']);
+ $this->root = new AdministratorMenuItem(['level' => 0]);
+ $heading = new AdministratorMenuItem(['title' => 'MOD_MENU_RECOVERY_MENU_ROOT', 'type' => 'heading']);
$this->root->addChild($heading);
MenusHelper::loadPreset('default', true, $heading);
$this->preprocess($this->root);
- $this->root->addChild(new MenuItem(['type' => 'separator']));
+ $this->root->addChild(new AdministratorMenuItem(['type' => 'separator']));
// Add link to exit recovery mode
$uri = clone Uri::getInstance();
$uri->setVar('recover_menu', 0);
- $this->root->addChild(new MenuItem(['title' => 'MOD_MENU_RECOVERY_EXIT', 'type' => 'url', 'url' => $uri->toString()]));
+ $this->root->addChild(new AdministratorMenuItem(['title' => 'MOD_MENU_RECOVERY_EXIT', 'type' => 'url', 'url' => $uri->toString()]));
return $this->root;
}
@@ -156,8 +156,8 @@ public function load($params, $enabled)
/**
* Method to render a given level of a menu using provided layout file
*
- * @param string $layoutFile The layout file to be used to render
- * @param MenuItem $node Node to render the children of
+ * @param string $layoutFile The layout file to be used to render
+ * @param AdministratorMenuItem $node Node to render the children of
*
* @return void
*
@@ -182,8 +182,8 @@ public function renderSubmenu($layoutFile, $node)
/**
* Check the flat list of menu items for important links
*
- * @param MenuItem $node The menu items array
- * @param Registry $params Module options
+ * @param AdministratorMenuItem $node The menu items array
+ * @param Registry $params Module options
*
* @return boolean Whether to show recovery menu
*
@@ -253,7 +253,7 @@ protected function check($node, Registry $params)
/**
* Filter and perform other preparatory tasks for loaded menu items based on access rights and module configurations for display
*
- * @param MenuItem $parent A menu item to process
+ * @param AdministratorMenuItem $parent A menu item to process
*
* @return array
*
@@ -269,15 +269,17 @@ protected function preprocess($parent)
/**
* Trigger onPreprocessMenuItems for the current level of backend menu items.
- * $children is an array of MenuItem objects. A plugin can traverse the whole tree,
+ * $children is an array of AdministratorMenuItem objects. A plugin can traverse the whole tree,
* but new nodes will only be run through this method if their parents have not been processed yet.
*/
$this->application->triggerEvent('onPreprocessMenuItems', array('com_menus.administrator.module', $children, $this->params, $this->enabled));
foreach ($children as $item)
{
+ $itemParams = $item->getParams();
+
// Exclude item with menu item option set to exclude from menu modules
- if ($item->getParams()->get('menu_show', 1) == 0)
+ if ($itemParams->get('menu_show', 1) == 0)
{
$parent->removeChild($item);
continue;
@@ -429,7 +431,7 @@ protected function preprocess($parent)
// Populate automatic children for container items
if ($item->type === 'container')
{
- $exclude = (array) $item->params->get('hideitems') ?: array();
+ $exclude = (array) $itemParams->get('hideitems') ?: array();
$components = MenusHelper::getMenuItems('main', false, $exclude);
// We are adding the nodes first to preprocess them, then sort them and add them again.
@@ -477,7 +479,7 @@ protected function preprocess($parent)
$language->load($item->element . '.sys', JPATH_ADMINISTRATOR . '/components/' . $item->element, null, false, true);
}
- if ($item->type === 'separator' && $item->params->get('text_separator') == 0)
+ if ($item->type === 'separator' && $itemParams->get('text_separator') == 0)
{
$item->title = '';
}
@@ -498,7 +500,7 @@ protected function preprocess($parent)
* Method to get the CSS class name for an icon identifier or create one if
* a custom image path is passed as the identifier
*
- * @param MenuItem $node Node to get icon data from
+ * @param AdministratorMenuItem $node Node to get icon data from
*
* @return string CSS class name
*
diff --git a/administrator/modules/mod_menu/tmpl/default_submenu.php b/administrator/modules/mod_menu/tmpl/default_submenu.php
index 0be25f3c903d2..d283cb51394dc 100644
--- a/administrator/modules/mod_menu/tmpl/default_submenu.php
+++ b/administrator/modules/mod_menu/tmpl/default_submenu.php
@@ -21,7 +21,8 @@
* =========================================================================================================
*/
/** @var \Joomla\Module\Menu\Administrator\Menu\CssMenu $this */
-$class = '';
+$class = '';
+$currentParams = $current->getParams();
// Build the CSS class suffix
if (!$this->enabled)
@@ -40,7 +41,7 @@
{
$class = ' class="parent"';
}
- elseif ($current->get('class') === 'scrollable-menu')
+ elseif ($current->class === 'scrollable-menu')
{
$class = ' class="dropdown scrollable-menu"';
}
@@ -81,19 +82,19 @@
$linkClass = ' class="' . implode(' ', $linkClass) . '" ';
// Get the menu link
-$link = $current->get('link');
+$link = $current->link;
// Get the menu image class
-$itemIconClass = $current->get('params')['menu_icon'];
+$itemIconClass = $currentParams->get('menu_icon');
// Get the menu image
-$itemImage = $current->get('params')['menu_image'];
+$itemImage = $currentParams->get('menu_image');
// Get the menu icon
$icon = $this->getIconClass($current);
$iconClass = ($icon != '' && $current->level == 1) ? '' : '';
$ajax = $current->ajaxbadge ? '' : '';
-$iconImage = $current->get('icon');
+$iconImage = $current->icon;
$homeImage = '';
if ($iconClass === '' && $itemIconClass)
@@ -147,7 +148,7 @@
echo '' . Text::_($current->title) . '' . $ajax;
}
-if ($current->getParams()->get('menu-quicktask', false))
+if ($currentParams->get('menu-quicktask', false))
{
$params = $current->getParams();
$user = $this->application->getIdentity();
@@ -181,7 +182,7 @@
{
if ($current->level > 1)
{
- $id = $current->get('id') ? ' id="menu-' . strtolower($current->get('id')) . '"' : '';
+ $id = $current->id ? ' id="menu-' . strtolower($current->id) . '"' : '';
echo '
' . "\n";
}
diff --git a/administrator/modules/mod_submenu/Menu/Menu.php b/administrator/modules/mod_submenu/Menu/Menu.php
index 7be662df022ee..ab1588df9c08b 100644
--- a/administrator/modules/mod_submenu/Menu/Menu.php
+++ b/administrator/modules/mod_submenu/Menu/Menu.php
@@ -51,10 +51,12 @@ public static function preprocess($parent)
foreach ($children as $item)
{
+ $itemParams = $item->getParams();
+
// Exclude item with menu item option set to exclude from menu modules
- if ($item->permission)
+ if ($itemParams->get('menu-permission'))
{
- @list($action, $asset) = explode(';', $item->permission);
+ @list($action, $asset) = explode(';', $itemParams->get('menu-permission'));
if (!$user->authorise($action, $asset))
{
@@ -66,7 +68,7 @@ public static function preprocess($parent)
// Populate automatic children for container items
if ($item->type === 'container')
{
- $exclude = (array) $item->params->get('hideitems') ?: array();
+ $exclude = (array) $itemParams->get('hideitems') ?: array();
$components = MenusHelper::getMenuItems('main', false, $exclude);
// We are adding the nodes first to preprocess them, then sort them and add them again.
@@ -192,7 +194,7 @@ public static function preprocess($parent)
$language->load($item->element . '.sys', JPATH_ADMINISTRATOR . '/components/' . $item->element, null, false, true);
}
- if ($item->type === 'separator' && $item->params->get('text_separator') == 0)
+ if ($item->type === 'separator' && $item->getParams()->get('text_separator') == 0)
{
$item->title = '';
}
diff --git a/administrator/modules/mod_submenu/tmpl/default.php b/administrator/modules/mod_submenu/tmpl/default.php
index ec3d21bf2bf60..0089a2fee69bd 100644
--- a/administrator/modules/mod_submenu/tmpl/default.php
+++ b/administrator/modules/mod_submenu/tmpl/default.php
@@ -28,7 +28,7 @@
getParams(); ?>
get('menu_show', 1)) : ?>
- target) ? ' target="' . $item->target . '"' : ''; ?>>
+ target ? ' target="' . $item->target . '"' : ''; ?>>
get('menu_image'))) : ?>
get('menu_image'), ENT_QUOTES, 'UTF-8');
diff --git a/components/com_contact/Model/CategoriesModel.php b/components/com_contact/Model/CategoriesModel.php
index 7a0a4a51f8fcf..28e2608eff851 100644
--- a/components/com_contact/Model/CategoriesModel.php
+++ b/components/com_contact/Model/CategoriesModel.php
@@ -114,11 +114,14 @@ public function getItems()
$app = Factory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
- $params = new Registry;
if ($active)
{
- $params->loadString($active->params);
+ $params = $active->getParams();
+ }
+ else
+ {
+ $params = new Registry;
}
$options = array();
diff --git a/components/com_contact/Model/CategoryModel.php b/components/com_contact/Model/CategoryModel.php
index 3dd79fc9dbfbe..34830720c2043 100644
--- a/components/com_contact/Model/CategoryModel.php
+++ b/components/com_contact/Model/CategoryModel.php
@@ -271,11 +271,13 @@ protected function populateState($ordering = null, $direction = null)
$params = ComponentHelper::getParams('com_contact');
// Get list ordering default from the parameters
- $menuParams = new Registry;
-
if ($menu = $app->getMenu()->getActive())
{
- $menuParams->loadString($menu->params);
+ $menuParams = $menu->getParams();
+ }
+ else
+ {
+ $menuParams = new Registry;
}
$mergedParams = clone $params;
@@ -361,11 +363,14 @@ public function getCategory()
$app = Factory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
- $params = new Registry;
if ($active)
{
- $params->loadString($active->params);
+ $params = $active->getParams();
+ }
+ else
+ {
+ $params = new Registry;
}
$options = array();
diff --git a/components/com_content/Model/CategoriesModel.php b/components/com_content/Model/CategoriesModel.php
index 69251d9a4ba6d..f834a1c3012ca 100644
--- a/components/com_content/Model/CategoriesModel.php
+++ b/components/com_content/Model/CategoriesModel.php
@@ -113,11 +113,14 @@ public function getItems($recursive = false)
$app = Factory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
- $params = new Registry;
if ($active)
{
- $params->loadString($active->params);
+ $params = $active->getParams();
+ }
+ else
+ {
+ $params = new Registry;
}
$options = array();
diff --git a/components/com_content/Model/CategoryModel.php b/components/com_content/Model/CategoryModel.php
index 538cb0273fc2b..4070055ae7c6a 100644
--- a/components/com_content/Model/CategoryModel.php
+++ b/components/com_content/Model/CategoryModel.php
@@ -143,11 +143,14 @@ protected function populateState($ordering = null, $direction = null)
// Load the parameters. Merge Global and Menu Item params into new object
$params = $app->getParams();
- $menuParams = new Registry;
if ($menu = $app->getMenu()->getActive())
{
- $menuParams->loadString($menu->params);
+ $menuParams = $menu->getParams();
+ }
+ else
+ {
+ $menuParams = new Registry;
}
$mergedParams = clone $menuParams;
diff --git a/components/com_content/Model/FeaturedModel.php b/components/com_content/Model/FeaturedModel.php
index 15053add24296..44887e1fe28f8 100644
--- a/components/com_content/Model/FeaturedModel.php
+++ b/components/com_content/Model/FeaturedModel.php
@@ -55,11 +55,14 @@ protected function populateState($ordering = null, $direction = null)
$this->setState('list.start', $limitstart);
$params = $this->state->params;
- $menuParams = new Registry;
if ($menu = $app->getMenu()->getActive())
{
- $menuParams->loadString($menu->params);
+ $menuParams = $menu->getParams();
+ }
+ else
+ {
+ $menuParams = new Registry;
}
$mergedParams = clone $menuParams;
diff --git a/components/com_newsfeeds/Model/CategoriesModel.php b/components/com_newsfeeds/Model/CategoriesModel.php
index f08ed8767731a..8609d9135b3af 100644
--- a/components/com_newsfeeds/Model/CategoriesModel.php
+++ b/components/com_newsfeeds/Model/CategoriesModel.php
@@ -116,11 +116,14 @@ public function getItems()
$app = Factory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
- $params = new Registry;
if ($active)
{
- $params->loadString($active->params);
+ $params = $active->getParams();
+ }
+ else
+ {
+ $params = new Registry;
}
$options = array();
diff --git a/components/com_newsfeeds/Model/CategoryModel.php b/components/com_newsfeeds/Model/CategoryModel.php
index e45e26bc4a099..a44480fb0a992 100644
--- a/components/com_newsfeeds/Model/CategoryModel.php
+++ b/components/com_newsfeeds/Model/CategoryModel.php
@@ -287,11 +287,14 @@ public function getCategory()
$app = Factory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
- $params = new Registry;
if ($active)
{
- $params->loadString($active->params);
+ $params = $active->getParams();
+ }
+ else
+ {
+ $params = new Registry;
}
$options = array();
diff --git a/components/com_tags/View/Tag/HtmlView.php b/components/com_tags/View/Tag/HtmlView.php
index 4e77779f913c8..5fe51116bc658 100644
--- a/components/com_tags/View/Tag/HtmlView.php
+++ b/components/com_tags/View/Tag/HtmlView.php
@@ -300,7 +300,7 @@ protected function _prepareDocument()
// Highest priority for "Browser Page Title".
if ($menu)
{
- $title = $menu->params->get('page_title', '');
+ $title = $menu->getParams()->get('page_title', '');
}
if ($this->tags_title)
diff --git a/components/com_users/Controller/UserController.php b/components/com_users/Controller/UserController.php
index 4a1ef453c401e..d0d2dc37b7036 100644
--- a/components/com_users/Controller/UserController.php
+++ b/components/com_users/Controller/UserController.php
@@ -243,7 +243,7 @@ public function menulogout()
{
// Get the ItemID of the page to redirect after logout
$app = $this->app;
- $itemid = $app->getMenu()->getActive()->params->get('logout');
+ $itemid = $app->getMenu()->getActive()->getParams()->get('logout');
// Get the language of the page when multilang is on
if (Multilanguage::isEnabled())
diff --git a/libraries/src/Application/CMSApplication.php b/libraries/src/Application/CMSApplication.php
index c27b4c07ae4f4..7d299310c9603 100644
--- a/libraries/src/Application/CMSApplication.php
+++ b/libraries/src/Application/CMSApplication.php
@@ -1004,10 +1004,10 @@ protected function route()
if ($active !== null
&& $active->type === 'alias'
- && $active->params->get('alias_redirect')
+ && $active->getParams()->get('alias_redirect')
&& \in_array($this->input->getMethod(), array('GET', 'HEAD'), true))
{
- $item = $this->getMenu()->getItem($active->params->get('aliasoptions'));
+ $item = $this->getMenu()->getItem($active->getParams()->get('aliasoptions'));
if ($item !== null)
{
diff --git a/libraries/src/Application/SiteApplication.php b/libraries/src/Application/SiteApplication.php
index e787a8b95e932..d65f890b38eb4 100644
--- a/libraries/src/Application/SiteApplication.php
+++ b/libraries/src/Application/SiteApplication.php
@@ -333,7 +333,7 @@ public function getParams($option = null)
// Get show_page_heading from com_menu global settings
$params[$hash]->def('show_page_heading', $temp->get('show_page_heading'));
- $params[$hash]->merge($menu->params);
+ $params[$hash]->merge($menu->getParams());
$title = $menu->title;
}
else
diff --git a/libraries/src/Menu/AbstractMenu.php b/libraries/src/Menu/AbstractMenu.php
index 4b8e400ded333..b1e45dd1fa4c8 100644
--- a/libraries/src/Menu/AbstractMenu.php
+++ b/libraries/src/Menu/AbstractMenu.php
@@ -286,7 +286,7 @@ public function getParams($id)
{
if ($menu = $this->getItem($id))
{
- return $menu->params;
+ return $menu->getParams();
}
return new Registry;
diff --git a/libraries/src/Menu/AdministratorMenuItem.php b/libraries/src/Menu/AdministratorMenuItem.php
new file mode 100644
index 0000000000000..56a4cefa4464c
--- /dev/null
+++ b/libraries/src/Menu/AdministratorMenuItem.php
@@ -0,0 +1,43 @@
+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
*
@@ -312,44 +249,4 @@ 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 = $this->$property ?? null;
- $this->$property = $value;
-
- return $previous;
- }
}
diff --git a/libraries/src/Menu/SiteMenu.php b/libraries/src/Menu/SiteMenu.php
index 08cd426e328eb..06aa45c370119 100644
--- a/libraries/src/Menu/SiteMenu.php
+++ b/libraries/src/Menu/SiteMenu.php
@@ -151,10 +151,10 @@ public function load()
->bind(':currentDate2', $currentDate)
->order($this->db->quoteName('m.lft'));
- $items = [];
- $this->db->setQuery($query);
+ $items = [];
+ $iterator = $this->db->setQuery($query)->getIterator();
- foreach ($this->db->getIterator() as $item)
+ foreach ($iterator as $item)
{
$items[$item->id] = new MenuItem((array) $item);
}
diff --git a/libraries/src/Pathway/SitePathway.php b/libraries/src/Pathway/SitePathway.php
index 5aaa066ba48ea..c04de20dfbff0 100644
--- a/libraries/src/Pathway/SitePathway.php
+++ b/libraries/src/Pathway/SitePathway.php
@@ -77,7 +77,7 @@ public function __construct(SiteApplication $app = null)
case 'alias':
// If this is an alias use the item id stored in the parameters to make the link.
- $url = 'index.php?Itemid=' . $link->params->get('aliasoptions');
+ $url = 'index.php?Itemid=' . $link->getParams()->get('aliasoptions');
break;
default:
diff --git a/libraries/src/Router/SiteRouter.php b/libraries/src/Router/SiteRouter.php
index 060d607401a2b..16b443edc73ee 100644
--- a/libraries/src/Router/SiteRouter.php
+++ b/libraries/src/Router/SiteRouter.php
@@ -279,7 +279,7 @@ public function parseSefRoute(&$router, &$uri)
{
if ($found->type === 'alias')
{
- $newItem = $this->menu->getItem($found->params->get('aliasoptions'));
+ $newItem = $this->menu->getItem($found->getParams()->get('aliasoptions'));
if ($newItem)
{
@@ -341,7 +341,7 @@ public function parseRawRoute(&$router, &$uri)
if ($item && $item->type === 'alias')
{
- $newItem = $this->menu->getItem($item->params->get('aliasoptions'));
+ $newItem = $this->menu->getItem($item->getParams()->get('aliasoptions'));
if ($newItem)
{
diff --git a/modules/mod_menu/Helper/MenuHelper.php b/modules/mod_menu/Helper/MenuHelper.php
index d7d736732abdd..3e988df9fff1a 100644
--- a/modules/mod_menu/Helper/MenuHelper.php
+++ b/modules/mod_menu/Helper/MenuHelper.php
@@ -66,8 +66,9 @@ public static function getList(&$params)
foreach ($items as $i => $item)
{
$item->parent = false;
+ $itemParams = $item->getParams();
- if (isset($items[$lastitem]) && $items[$lastitem]->id == $item->parent_id && $item->params->get('menu_show', 1) == 1)
+ if (isset($items[$lastitem]) && $items[$lastitem]->id == $item->parent_id && $itemParams->get('menu_show', 1) == 1)
{
$items[$lastitem]->parent = true;
}
@@ -82,7 +83,7 @@ public static function getList(&$params)
}
// Exclude item with menu item option set to exclude from menu modules
- if (($item->params->get('menu_show', 1) == 0) || \in_array($item->parent_id, $hidden_parents))
+ if (($itemParams->get('menu_show', 1) == 0) || \in_array($item->parent_id, $hidden_parents))
{
$hidden_parents[] = $item->id;
unset($items[$i]);
@@ -123,12 +124,12 @@ public static function getList(&$params)
break;
case 'alias':
- $item->flink = 'index.php?Itemid=' . $item->params->get('aliasoptions');
+ $item->flink = 'index.php?Itemid=' . $itemParams->get('aliasoptions');
// Get the language of the target menu item when site is multilingual
if (Multilanguage::isEnabled())
{
- $newItem = Factory::getApplication()->getMenu()->getItem((int) $item->params->get('aliasoptions'));
+ $newItem = Factory::getApplication()->getMenu()->getItem((int) $itemParams->get('aliasoptions'));
// Use language code if not set to ALL
if ($newItem != null && $newItem->language && $newItem->language !== '*')
@@ -145,7 +146,7 @@ public static function getList(&$params)
if ((strpos($item->flink, 'index.php?') !== false) && strcasecmp(substr($item->flink, 0, 4), 'http'))
{
- $item->flink = Route::_($item->flink, true, $item->params->get('secure'));
+ $item->flink = Route::_($item->flink, true, $itemParams->get('secure'));
}
else
{
@@ -155,12 +156,12 @@ public static function getList(&$params)
// We prevent the double encoding because for some reason the $item is shared for menu modules and we get double encoding
// when the cause of that is found the argument should be removed
$item->title = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8', false);
- $item->anchor_css = htmlspecialchars($item->params->get('menu-anchor_css', ''), ENT_COMPAT, 'UTF-8', false);
- $item->anchor_title = htmlspecialchars($item->params->get('menu-anchor_title', ''), ENT_COMPAT, 'UTF-8', false);
- $item->anchor_rel = htmlspecialchars($item->params->get('menu-anchor_rel', ''), ENT_COMPAT, 'UTF-8', false);
- $item->menu_image = $item->params->get('menu_image', '') ?
- htmlspecialchars($item->params->get('menu_image', ''), ENT_COMPAT, 'UTF-8', false) : '';
- $item->menu_image_css = htmlspecialchars($item->params->get('menu_image_css', ''), ENT_COMPAT, 'UTF-8', false);
+ $item->anchor_css = htmlspecialchars($itemParams->get('menu-anchor_css', ''), ENT_COMPAT, 'UTF-8', false);
+ $item->anchor_title = htmlspecialchars($itemParams->get('menu-anchor_title', ''), ENT_COMPAT, 'UTF-8', false);
+ $item->anchor_rel = htmlspecialchars($itemParams->get('menu-anchor_rel', ''), ENT_COMPAT, 'UTF-8', false);
+ $item->menu_image = $itemParams->get('menu_image', '') ?
+ htmlspecialchars($itemParams->get('menu_image', ''), ENT_COMPAT, 'UTF-8', false) : '';
+ $item->menu_image_css = htmlspecialchars($itemParams->get('menu_image_css', ''), ENT_COMPAT, 'UTF-8', false);
}
if (isset($items[$lastitem]))
diff --git a/modules/mod_menu/tmpl/default.php b/modules/mod_menu/tmpl/default.php
index 9c6586a23ed40..699b471d0a54b 100644
--- a/modules/mod_menu/tmpl/default.php
+++ b/modules/mod_menu/tmpl/default.php
@@ -26,14 +26,15 @@
class="mod-menu nav mod-list">
&$item)
{
- $class = 'nav-item';
+ $itemParams = $item->getParams();
+ $class = 'nav-item';
if ($item->id == $default_id)
{
$class .= ' default';
}
- if ($item->id == $active_id || ($item->type === 'alias' && $item->params->get('aliasoptions') == $active_id))
+ if ($item->id == $active_id || ($item->type === 'alias' && $itemParams->get('aliasoptions') == $active_id))
{
$class .= ' current';
}
@@ -44,7 +45,7 @@
}
elseif ($item->type === 'alias')
{
- $aliasToId = $item->params->get('aliasoptions');
+ $aliasToId = $itemParams->get('aliasoptions');
if (count($path) > 0 && $aliasToId == $path[count($path) - 1])
{
diff --git a/modules/mod_menu/tmpl/default_component.php b/modules/mod_menu/tmpl/default_component.php
index 6844fe0312dda..73fcebd04d328 100644
--- a/modules/mod_menu/tmpl/default_component.php
+++ b/modules/mod_menu/tmpl/default_component.php
@@ -43,7 +43,7 @@
$linktype = HTMLHelper::_('image', $item->menu_image, $item->title);
}
- if ($item->params->get('menu_text', 1))
+ if ($itemParams->get('menu_text', 1))
{
$linktype .= '' . $item->title . '';
}
diff --git a/modules/mod_menu/tmpl/default_heading.php b/modules/mod_menu/tmpl/default_heading.php
index 5ecaffae82f54..ea646525f5a6c 100644
--- a/modules/mod_menu/tmpl/default_heading.php
+++ b/modules/mod_menu/tmpl/default_heading.php
@@ -27,7 +27,7 @@
$linktype = HTMLHelper::_('image', $item->menu_image, $item->title);
}
- if ($item->params->get('menu_text', 1))
+ if ($itemParams->get('menu_text', 1))
{
$linktype .= '' . $item->title . '';
}
diff --git a/modules/mod_menu/tmpl/default_separator.php b/modules/mod_menu/tmpl/default_separator.php
index 272789a69c21d..3a3004f6d31a2 100644
--- a/modules/mod_menu/tmpl/default_separator.php
+++ b/modules/mod_menu/tmpl/default_separator.php
@@ -27,7 +27,7 @@
$linktype = HTMLHelper::_('image', $item->menu_image, $item->title);
}
- if ($item->params->get('menu_text', 1))
+ if ($itemParams->get('menu_text', 1))
{
$linktype .= '' . $item->title . '';
}
diff --git a/modules/mod_menu/tmpl/default_url.php b/modules/mod_menu/tmpl/default_url.php
index 3b0f4055c4f4a..df8c5e5999b08 100644
--- a/modules/mod_menu/tmpl/default_url.php
+++ b/modules/mod_menu/tmpl/default_url.php
@@ -43,7 +43,7 @@
$linktype = HTMLHelper::_('image', $item->menu_image, $item->title);
}
- if ($item->params->get('menu_text', 1))
+ if ($itemParams->get('menu_text', 1))
{
$linktype .= '' . $item->title . '';
}
diff --git a/plugins/system/languagefilter/languagefilter.php b/plugins/system/languagefilter/languagefilter.php
index d920128bbd628..00289cb2be720 100644
--- a/plugins/system/languagefilter/languagefilter.php
+++ b/plugins/system/languagefilter/languagefilter.php
@@ -673,7 +673,7 @@ public function onUserLogin($user, $options = array())
* In that case we use the redirect as defined in the menu item.
* Otherwise we redirect, when available, to the user preferred site language.
*/
- if ($active && !$active->params['login_redirect_url'])
+ if ($active && !$active->getParams()->get('login_redirect_url'))
{
if ($assoc)
{
diff --git a/templates/cassiopeia/error.php b/templates/cassiopeia/error.php
index caf66bcdfd314..712a14f48bbff 100644
--- a/templates/cassiopeia/error.php
+++ b/templates/cassiopeia/error.php
@@ -27,7 +27,7 @@
$itemid = $app->input->getCmd('Itemid', '');
$sitename = htmlspecialchars($app->get('sitename'), ENT_QUOTES, 'UTF-8');
$menu = $app->getMenu()->getActive();
-$pageclass = $menu !== null ? $menu->params->get('pageclass_sfx', '') : '';
+$pageclass = $menu !== null ? $menu->getParams()->get('pageclass_sfx', '') : '';
// Add JavaScript Frameworks
HTMLHelper::_('bootstrap.framework');
diff --git a/templates/cassiopeia/index.php b/templates/cassiopeia/index.php
index acc667d1f03e4..4bfa800b40c96 100644
--- a/templates/cassiopeia/index.php
+++ b/templates/cassiopeia/index.php
@@ -28,7 +28,7 @@
$itemid = $app->input->getCmd('Itemid', '');
$sitename = htmlspecialchars($app->get('sitename'), ENT_QUOTES, 'UTF-8');
$menu = $app->getMenu()->getActive();
-$pageclass = $menu->params->get('pageclass_sfx');
+$pageclass = $menu->getParams()->get('pageclass_sfx');
// Enable assets
$wa->enableAsset('template.cassiopeia.' . ($this->direction === 'rtl' ? 'rtl' : 'ltr'));