-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmenuitemhierarchy.php
More file actions
128 lines (112 loc) · 3.12 KB
/
Copy pathmenuitemhierarchy.php
File metadata and controls
128 lines (112 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/**
* @package GJFileds
*
* @copyright 0000 Copyright (C) All rights reversed.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL or later
*/
/*##mygruz20130718204543 {
* It's a replacement of the core Menuitem field to show menu items in the
* drop-down list respecting menu hierarchy
/*##mygruz20130718204543 } */
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('groupedlist');
// Import the com_menus helper.
require_once realpath(JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
/**
* Supports an HTML grouped select list of menu item grouped by menu
*
* @package Joomla.Libraries
* @subpackage Form
* @since 1.6
*/
class GJFieldsFormFieldMenuitemhierarchy extends JFormFieldGroupedList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
public $type = 'Menuitemhierarchy';
/**
* Method to get the field option groups.
*
* @return array The field option objects as a nested array in groups.
*
* @since 1.6
*/
protected function getGroups()
{
$groups = array();
// Initialize some field attributes.
$menuType = (string) $this->element['menu_type'];
$published = $this->element['published'] ? explode(',', (string) $this->element['published']) : array();
$disable = $this->element['disable'] ? explode(',', (string) $this->element['disable']) : array();
$language = $this->element['language'] ? explode(',', (string) $this->element['language']) : array();
// Get the menu items.
$items = MenusHelper::getMenuLinks($menuType, 0, 0, $published, $language);
// Build group for a specific menu type.
if ($menuType)
{
// Initialize the group.
$groups[$menuType] = array();
// Build the options array.
foreach ($items as $link)
{
/*##mygruz20130718204314 {
It was:
It became:*/
$repeate = $link->level - 1;
if ($repeate > 0)
{
$link->text = str_repeat('-', $repeate) . ' ' . $link->text;
}
/*##mygruz20130718204314 } */
$groups[$menuType][] = JHtml::_('select.option', $link->value, $link->text, 'value', 'text', in_array($link->type, $disable));
}
}
// Build groups for all menu types.
else
{
// Build the groups arrays.
foreach ($items as $menu)
{
// Initialize the group.
$groups[$menu->menutype] = array();
// Build the options array.
foreach ($menu->links as $link)
{
/*##mygruz20130718204314 {
It was:
It became:*/
$repeate = $link->level - 1;
if ($repeate > 0)
{
$link->text = str_repeat('-', $repeate) . ' ' . $link->text;
}
/*##mygruz20130718204314 } */
$groups[$menu->menutype][] = JHtml::_(
'select.option', $link->value, $link->text, 'value', 'text',
in_array($link->type, $disable)
);
}
}
}
// Merge any additional groups in the XML definition.
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
}
// Preserve compatibility
if (!class_exists('JFormFieldMenuitemhierarchy'))
{
/**
* Old-fashioned field name
*
* @since 1.2.0
*/
class JFormFieldMenuitemhierarchy extends GJFieldsFormFieldMenuitemhierarchy
{
}
}