|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
You may not change or alter any portion of this comment or credits |
|
4
|
|
|
of supporting developers from this source code or any supporting source code |
|
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
|
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Xoops\Html\Menu; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* ItemList - a list of menu items |
|
16
|
|
|
* |
|
17
|
|
|
* @category Xoops\Html\Menu |
|
18
|
|
|
* @package Link |
|
19
|
|
|
* @author Richard Griffith <[email protected]> |
|
20
|
|
|
* @copyright 2016 XOOPS Project (http://xoops.org) |
|
21
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
|
22
|
|
|
* @link http://xoops.org |
|
23
|
|
|
*/ |
|
24
|
|
|
class ItemList extends Item |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* __construct |
|
28
|
|
|
* |
|
29
|
|
|
* @param array $attributes array of attribute name => value pairs |
|
30
|
|
|
* |
|
31
|
|
|
* Possible attributes: |
|
32
|
|
|
* 'items' - Item[] (optional, can be added with addItem()) |
|
33
|
|
|
* 'caption' - link caption (required for dropdowns) |
|
34
|
|
|
* 'icon' - css classes for icon, i.e. "glyphicon glyphicon-ok" |
|
35
|
|
|
* 'id' - element id for container association (i.e. aria-labelledby) |
|
36
|
|
|
* 'dropdown' - override "dropdown" class, i.e. "dropup" |
|
37
|
|
|
*/ |
|
38
|
1 |
|
public function __construct($attributes = array()) |
|
39
|
|
|
{ |
|
40
|
1 |
|
parent::__construct($attributes); |
|
41
|
1 |
|
$this->set('type', Item::TYPE_LIST); |
|
42
|
1 |
|
if (!$this->has('items')) { |
|
43
|
1 |
|
$this->set('items', []); |
|
44
|
|
|
} |
|
45
|
1 |
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Add an item to the ItemList |
|
49
|
|
|
* |
|
50
|
|
|
* @param Item $item item to add |
|
51
|
|
|
* |
|
52
|
|
|
* @return $this for fluent access |
|
53
|
|
|
*/ |
|
54
|
|
|
public function addItem(Item $item) |
|
55
|
|
|
{ |
|
56
|
|
|
$this['items'][] = $item; |
|
57
|
|
|
return $this; |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|