1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ajax\semantic\html\collections; |
4
|
|
|
|
5
|
|
|
use Ajax\bootstrap\html\HtmlLink; |
6
|
|
|
use Ajax\common\html\HtmlCollection; |
7
|
|
|
use Ajax\semantic\html\base\Pointing; |
8
|
|
|
use Ajax\common\html\HtmlDoubleElement; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Semantic Menu component |
12
|
|
|
* @see http://semantic-ui.com/collections/menu.html |
13
|
|
|
* @author jc |
14
|
|
|
* @version 1.001 |
15
|
|
|
*/ |
16
|
|
|
class HtmlMenu extends HtmlCollection { |
17
|
|
|
|
18
|
|
|
public function __construct($identifier, $items=array()) { |
19
|
|
|
parent::__construct($identifier, "div"); |
20
|
|
|
$this->setClass("ui menu"); |
21
|
|
|
$this->addItems($items); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Sets the menu type |
26
|
|
|
* @param string $type one of text,item |
27
|
|
|
* @return \Ajax\semantic\html\collections\HtmlMenu |
28
|
|
|
*/ |
29
|
|
|
public function setType($type=""){ |
30
|
|
|
return $this->addToPropertyCtrl("class", $type, array("","item","text")); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function setActiveItem($index){ |
34
|
|
|
$item=$this->getItem($index); |
35
|
|
|
if($item!==null){ |
36
|
|
|
$item->addToProperty("class", "active"); |
37
|
|
|
} |
38
|
|
|
return $this; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritDoc} |
43
|
|
|
* @see \Ajax\common\html\html5\HtmlCollection::addItem() |
44
|
|
|
*/ |
45
|
|
|
public function addItem($item){ |
46
|
|
|
$item=parent::addItem($item); |
47
|
|
|
if(!$item instanceof HtmlMenu) |
48
|
|
|
$item->addToPropertyCtrl("class", "item",array("item")); |
49
|
|
|
else{ |
50
|
|
|
$this->setSecondary(); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
/** |
54
|
|
|
* {@inheritDoc} |
55
|
|
|
* @see \Ajax\common\html\html5\HtmlCollection::createItem() |
56
|
|
|
*/ |
57
|
|
|
protected function createItem($value) { |
58
|
|
|
$itemO=new HtmlLink("item-".\sizeof($this->content),"",$value); |
|
|
|
|
59
|
|
|
return $itemO->setClass("item"); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function setInverted(){ |
63
|
|
|
return $this->addToProperty("class", "inverted"); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function setSecondary(){ |
67
|
|
|
return $this->addToProperty("class", "secondary"); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function setVertical(){ |
71
|
|
|
return $this->addToProperty("class", "vertical"); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function setPosition($value="right"){ |
75
|
|
|
return $this->addToPropertyCtrl("class", $value,array("right","left")); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function setPointing($value=Pointing::POINTING){ |
79
|
|
|
return $this->addToPropertyCtrl("class", $value,Pointing::getConstants()); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function asTab($vertical=false){ |
83
|
|
|
$this->apply(function(HtmlDoubleElement &$item){$item->setTagName("a");}); |
84
|
|
|
if($vertical===true) |
85
|
|
|
$this->setVertical(); |
86
|
|
|
return $this->addToProperty("class", "tabular"); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function asPagination(){ |
90
|
|
|
$this->apply(function(HtmlDoubleElement &$item){$item->setTagName("a");}); |
91
|
|
|
return $this->addToProperty("class", "pagination"); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function setFixed(){ |
95
|
|
|
return $this->addToProperty("class", "fixed"); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function setFluid(){ |
99
|
|
|
return $this->addToProperty("class", "fluid"); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function setCompact(){ |
103
|
|
|
return $this->addToProperty("class", "compact"); |
104
|
|
|
} |
105
|
|
|
} |
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.