|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ajax\semantic\html\elements; |
|
4
|
|
|
|
|
5
|
|
|
use Ajax\semantic\html\base\HtmlSemDoubleElement; |
|
6
|
|
|
use Ajax\semantic\html\base\Size; |
|
7
|
|
|
use Ajax\common\html\HtmlDoubleElement; |
|
8
|
|
|
|
|
9
|
|
|
class HtmlHeader extends HtmlSemDoubleElement { |
|
10
|
|
|
protected $image; |
|
11
|
|
|
public function __construct($identifier, $niveau=1,$content=NULL,$type="page") { |
|
12
|
|
|
parent::__construct($identifier, "div"); |
|
13
|
|
|
$this->_template="<%tagName% %properties%>%image%%content%</%tagName%>"; |
|
14
|
|
|
$this->setClass("ui header"); |
|
15
|
|
|
if(isset($type)){ |
|
16
|
|
|
if($type=="page"){ |
|
17
|
|
|
$this->asPageHeader($niveau); |
|
18
|
|
|
}else |
|
19
|
|
|
$this->asContentHeader($niveau); |
|
20
|
|
|
} |
|
21
|
|
|
$this->content=$content; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function asPageHeader($niveau){ |
|
25
|
|
|
$this->tagName="h".$niveau; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function asContentHeader($niveau){ |
|
29
|
|
|
$this->tagName="div"; |
|
30
|
|
|
if(\is_int($niveau)){ |
|
31
|
|
|
$niveau=Size::getConstantValues()[$niveau]; |
|
32
|
|
|
} |
|
33
|
|
|
$this->setSize($niveau); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function asIcon($icon,$title,$subHeader=NULL){ |
|
37
|
|
|
$this->addToProperty("class", "icon"); |
|
38
|
|
|
$this->image=new HtmlIcon("icon-".$this->identifier, $icon); |
|
39
|
|
|
return $this->asTitle($title,$subHeader); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function asImage($src,$title,$subHeader=NULL){ |
|
43
|
|
|
$this->image=new HtmlImage("img-".$this->identifier, $src,$title); |
|
44
|
|
|
return $this->asTitle($title,$subHeader); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function asTitle($title,$subHeader=NULL){ |
|
48
|
|
|
if(!\is_object($title)){ |
|
49
|
|
|
$this->content=new HtmlDoubleElement("content-".$this->identifier,"div"); |
|
50
|
|
|
$this->content->setContent($title); |
|
51
|
|
|
}else{ |
|
52
|
|
|
$this->content=$title; |
|
53
|
|
|
} |
|
54
|
|
|
$this->content->setClass("content"); |
|
55
|
|
|
if(isset($subHeader)){ |
|
56
|
|
|
$sub=new HtmlDoubleElement("subheader-".$this->identifier,"div"); |
|
57
|
|
|
$sub->setClass("sub header"); |
|
58
|
|
|
$sub->setContent($subHeader); |
|
59
|
|
|
$this->content->addContent($sub); |
|
60
|
|
|
} |
|
61
|
|
|
return $this; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function getImage() { |
|
65
|
|
|
return $this->image; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
} |