|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ajax\semantic\html\elements; |
|
4
|
|
|
|
|
5
|
|
|
use Ajax\semantic\html\base\HtmlSemCollection; |
|
6
|
|
|
use Ajax\semantic\html\content\HtmlStepItem; |
|
7
|
|
|
use Ajax\JsUtils; |
|
8
|
|
|
|
|
9
|
|
|
use Ajax\common\html\HtmlDoubleElement; |
|
10
|
|
|
use Ajax\semantic\html\base\constants\Side; |
|
11
|
|
|
|
|
12
|
|
|
class HtmlStep extends HtmlSemCollection{ |
|
13
|
|
|
protected $_activeStep; |
|
14
|
|
|
protected $_startStep; |
|
15
|
|
|
|
|
16
|
|
|
public function __construct( $identifier,$steps=array()){ |
|
17
|
|
|
parent::__construct( $identifier,"div", "ui steps"); |
|
18
|
|
|
$this->addItems($steps); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* {@inheritDoc} |
|
24
|
|
|
* @see \Ajax\common\html\html5\HtmlCollection::createItem() |
|
25
|
|
|
*/ |
|
26
|
|
|
protected function createItem($value) { |
|
27
|
|
|
$itemO=new HtmlStepItem("item-".\sizeof($this->content),$value); |
|
28
|
|
|
return $itemO; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param string|array $step |
|
33
|
|
|
* @return HtmlStepItem |
|
34
|
|
|
*/ |
|
35
|
|
|
public function addStep($step){ |
|
36
|
|
|
return $this->addItem($step); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function setOrdered(){ |
|
40
|
|
|
return $this->addToProperty("class", "ordered"); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function isOrdered(){ |
|
44
|
|
|
return $this->propertyContains("class", "ordered"); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function setVertical(){ |
|
48
|
|
|
return $this->addToProperty("class", "vertical"); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
protected function defineActiveStep(){ |
|
52
|
|
|
$activestep=$this->_activeStep; |
|
53
|
|
|
$count=$this->count(); |
|
54
|
|
|
if(!$this->isOrdered()){ |
|
55
|
|
|
for($i=$this->_startStep;$i<$count;$i++){ |
|
56
|
|
|
$step=$this->content[$i]; |
|
57
|
|
|
$step->removeStatus(); |
|
58
|
|
|
if($i<$activestep) |
|
59
|
|
|
$step->setCompleted(); |
|
60
|
|
|
elseif ($i===$activestep) |
|
61
|
|
|
$step->setActive(); |
|
62
|
|
|
else |
|
63
|
|
|
$step->setDisabled(); |
|
64
|
|
|
} |
|
65
|
|
|
}else{ |
|
66
|
|
|
foreach ($this->content as $step){ |
|
67
|
|
|
$step->removeStatus(); |
|
68
|
|
|
} |
|
69
|
|
|
if($activestep<$count) |
|
70
|
|
|
$this->content[$activestep]->setActive(); |
|
71
|
|
|
} |
|
72
|
|
|
return $this; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
76
|
|
|
if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
77
|
|
|
$this->defineActiveStep(); |
|
78
|
|
|
return parent::compile($js,$view); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function setActiveStep($_activeStep) { |
|
82
|
|
|
$this->_activeStep=$_activeStep; |
|
83
|
|
|
return $this; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function setAttached($side="",HtmlDoubleElement $toElement=NULL){ |
|
87
|
|
|
if(isset($toElement)){ |
|
88
|
|
|
$toElement->addToPropertyCtrl("class", "attached",array("attached")); |
|
89
|
|
|
} |
|
90
|
|
|
return $this->addToPropertyCtrl("class", $side." attached",Side::getConstantValues("attached")); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function setStartStep($_startStep) { |
|
94
|
|
|
$this->_startStep=$_startStep; |
|
95
|
|
|
return $this; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
} |
|
99
|
|
|
|