1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ajax\semantic\html\collections; |
4
|
|
|
|
5
|
|
|
use Ajax\bootstrap\html\HtmlLink; |
6
|
|
|
use Ajax\common\html\html5\HtmlCollection; |
7
|
|
|
/** |
8
|
|
|
* Semantic Menu component |
9
|
|
|
* @see http://semantic-ui.com/collections/menu.html |
10
|
|
|
* @author jc |
11
|
|
|
* @version 1.001 |
12
|
|
|
*/ |
13
|
|
|
class HtmlMenu extends HtmlCollection { |
14
|
|
|
|
15
|
|
|
public function __construct($identifier, $items=array()) { |
16
|
|
|
parent::__construct($identifier, "div"); |
17
|
|
|
$this->setClass("ui menu"); |
18
|
|
|
foreach ($items as $item){ |
19
|
|
|
$this->addItem($item); |
20
|
|
|
} |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Sets the menu type |
25
|
|
|
* @param string $type one of text,item |
26
|
|
|
* @return \Ajax\semantic\html\collections\HtmlMenu |
27
|
|
|
*/ |
28
|
|
|
public function setType($type=""){ |
29
|
|
|
return $this->addToPropertyCtrl("class", $type, array("","item","text")); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function setActiveItem($index){ |
33
|
|
|
$item=$this->getItem($index); |
34
|
|
|
if($item!==null){ |
35
|
|
|
$item->addToProperty("class", "active"); |
36
|
|
|
} |
37
|
|
|
return $this; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* {@inheritDoc} |
42
|
|
|
* @see \Ajax\common\html\html5\HtmlCollection::addItem() |
43
|
|
|
*/ |
44
|
|
|
public function addItem($item){ |
45
|
|
|
$item=parent::addItem($item); |
46
|
|
|
$item->addToProperty("class", "item"); |
47
|
|
|
} |
48
|
|
|
/** |
49
|
|
|
* {@inheritDoc} |
50
|
|
|
* @see \Ajax\common\html\html5\HtmlCollection::createItem() |
51
|
|
|
*/ |
52
|
|
|
protected function createItem($value) { |
53
|
|
|
$itemO=new HtmlLink("item-".\sizeof($this->content),"",$value); |
|
|
|
|
54
|
|
|
return $itemO->setClass("item"); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function setInverted(){ |
58
|
|
|
return $this->addToProperty("class", "inverted"); |
59
|
|
|
} |
60
|
|
|
} |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.