1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ajax\semantic\html\content; |
4
|
|
|
|
5
|
|
|
use Ajax\semantic\html\base\HtmlSemDoubleElement; |
6
|
|
|
use Ajax\semantic\html\elements\HtmlIcon; |
7
|
|
|
use Ajax\service\JArray; |
8
|
|
|
use Ajax\semantic\html\base\constants\StepStatus; |
9
|
|
|
|
10
|
|
|
class HtmlStepItem extends HtmlSemDoubleElement { |
11
|
|
|
|
12
|
|
|
public function __construct($identifier, $content) { |
13
|
|
|
parent::__construct($identifier, "div", "step"); |
14
|
|
|
$this->content=array(); |
15
|
|
|
if(\is_array($content)){ |
16
|
|
|
if(JArray::isAssociative($content)===false){ |
17
|
|
|
$icon=JArray::getValue($content, "icon",0); |
18
|
|
|
$title=JArray::getValue($content, "title",1); |
19
|
|
|
$desc=JArray::getValue($content, "description",2); |
20
|
|
|
$status=JArray::getValue($content, "status",3); |
21
|
|
|
}else{ |
22
|
|
|
$icon=@$content["icon"]; |
23
|
|
|
$title=@$content["title"]; |
24
|
|
|
$desc=@$content["description"]; |
25
|
|
|
$status=@$content["status"]; |
26
|
|
|
} |
27
|
|
|
if(isset($icon)===true){ |
28
|
|
|
$this->setIcon($icon); |
29
|
|
|
} |
30
|
|
|
if(isset($status)===true){ |
31
|
|
|
$this->setStatus($status); |
32
|
|
|
} |
33
|
|
|
if(isset($title)===true){ |
34
|
|
|
$this->setTitle($title,$desc); |
35
|
|
|
} |
36
|
|
|
}else{ |
37
|
|
|
$this->setContent($content); |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function setIcon($icon){ |
42
|
|
|
$this->content["icon"]=new HtmlIcon("icon-".$this->identifier, $icon); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
private function createContent(){ |
46
|
|
|
$this->content["content"]=new HtmlSemDoubleElement("content-".$this->identifier,"div","content"); |
47
|
|
|
return $this->content["content"]; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function setTitle($title,$description=NULL){ |
51
|
|
|
$title=new HtmlSemDoubleElement("","div","title",$title); |
52
|
|
|
if(\array_key_exists("content", $this->content)===false){ |
53
|
|
|
$this->createContent(); |
54
|
|
|
} |
55
|
|
|
$this->content["content"]->addContent($title); |
56
|
|
|
if(isset($description)){ |
57
|
|
|
$description=new HtmlSemDoubleElement("","div","description",$description); |
58
|
|
|
$this->content["content"]->addContent($description); |
59
|
|
|
} |
60
|
|
|
return $this; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function setActive(){ |
64
|
|
|
return $this->setStatus(StepStatus::ACTIVE); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function setCompleted(){ |
68
|
|
|
return $this->setStatus(StepStatus::COMPLETED); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function setStatus($status){ |
72
|
|
|
return $this->addToPropertyCtrl("class", $status, StepStatus::getConstants()); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function asLink(){ |
76
|
|
|
return $this->setTagName("a"); |
77
|
|
|
} |
78
|
|
|
public function removeStatus(){ |
79
|
|
|
$this->removePropertyValues("class", StepStatus::getConstants()); |
80
|
|
|
} |
81
|
|
|
} |