Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
663db51
Remove deprecated code
SharkyKZ Oct 10, 2019
b142a79
Use get()
SharkyKZ Oct 10, 2019
3832eaa
Move variable
SharkyKZ Oct 10, 2019
c208c16
Merge branch '4.0-dev' into j4/deprecated/MenuItem
SharkyKZ Oct 10, 2019
2ec4d26
Merge branch '4.0-dev' into j4/deprecated/MenuItem
SharkyKZ Oct 13, 2019
9137ad0
Merge branch '4.0-dev' into j4/deprecated/MenuItem
SharkyKZ Oct 15, 2019
a5bdd1e
Merge remote-tracking branch 'upstream/4.0-dev' into j4/deprecated/Me…
SharkyKZ Oct 19, 2019
7d4d451
Merge remote-tracking branch 'upstream/4.0-dev' into j4/deprecated/Me…
SharkyKZ Oct 19, 2019
3f74507
Merge remote-tracking branch 'upstream/4.0-dev' into j4/deprecated/Me…
SharkyKZ Oct 22, 2019
4d19459
More replacements
SharkyKZ Oct 22, 2019
1e74a6d
Merge remote-tracking branch 'upstream/4.0-dev' into j4/deprecated/Me…
SharkyKZ Oct 22, 2019
f486a02
Instantiate class manually
SharkyKZ Oct 22, 2019
a6b2a53
Merge remote-tracking branch 'upstream/4.0-dev' into j4/deprecated/Me…
SharkyKZ Oct 23, 2019
9307b01
More `params` replacements
SharkyKZ Oct 23, 2019
6d11a68
Use iterator
SharkyKZ Oct 26, 2019
e48f62e
Merge remote-tracking branch 'upstream/4.0-dev' into j4/deprecated/Me…
SharkyKZ Oct 26, 2019
9e9158f
Merge remote-tracking branch 'upstream/4.0-dev' into j4/deprecated/Me…
SharkyKZ Nov 11, 2019
bbc5473
Cleanup
SharkyKZ Nov 11, 2019
4ededb2
Typo
SharkyKZ Nov 11, 2019
8629203
Merge remote-tracking branch 'upstream/4.0-dev' into j4/deprecated/Me…
SharkyKZ Nov 11, 2019
2894b31
Merge remote-tracking branch 'upstream/4.0-dev' into j4/deprecated/Me…
SharkyKZ Nov 12, 2019
7f3ba20
Remove target property for base class
SharkyKZ Nov 12, 2019
1ee3685
Remove duplicate line
SharkyKZ Nov 12, 2019
e7c8118
Fix notice
SharkyKZ Nov 12, 2019
8a46292
Fix notice and links not opening in new window
SharkyKZ Nov 12, 2019
089f81d
Fix notice
SharkyKZ Nov 13, 2019
3b20260
Merge branch '4.0-dev' into j4/deprecated/MenuItem
SharkyKZ Nov 13, 2019
b1d500c
Merge branch '4.0-dev' into j4/deprecated/MenuItem
SharkyKZ Nov 14, 2019
0460dd6
Merge branch '4.0-dev' into j4/deprecated/MenuItem
SharkyKZ Nov 14, 2019
0b16efc
Merge branch '4.0-dev' into j4/deprecated/MenuItem
SharkyKZ Nov 21, 2019
d9f3548
Merge remote-tracking branch 'upstream/4.0-dev' into j4/deprecated/Me…
SharkyKZ Nov 26, 2019
fb69c39
Add class for administrator menu items
SharkyKZ Nov 26, 2019
96155d0
Merge branch '4.0-dev' into j4/deprecated/MenuItem
SharkyKZ Nov 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 41 additions & 45 deletions administrator/components/com_menus/Helper/MenusHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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')
{
Expand All @@ -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');
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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)
{
Expand All @@ -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(
Expand All @@ -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,
Expand All @@ -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))
Expand Down Expand Up @@ -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
*/
Expand All @@ -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)
Expand All @@ -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
*
Expand All @@ -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);
Expand All @@ -756,7 +753,7 @@ public static function resolveAlias(&$item)

try
{
$obj = $db->setQuery($query)->loadObject();
$obj = new AdministratorMenuItem($db->setQuery($query)->loadAssoc());

if (!$obj)
{
Expand All @@ -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
*
Expand All @@ -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
*
Expand Down Expand Up @@ -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')
Expand All @@ -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
Expand All @@ -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;
}
}
8 changes: 4 additions & 4 deletions administrator/components/com_menus/View/Menu/XmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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)
Expand Down
Loading