| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Ajax\semantic\html\elements; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Ajax\semantic\html\base\HtmlSemDoubleElement; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Ajax\common\html\HtmlDoubleElement; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Ajax\semantic\html\base\traits\TextAlignmentTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Ajax\semantic\html\base\constants\HeaderSize; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Ajax\semantic\html\elements\html5\HtmlImg; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Ajax\semantic\html\base\traits\AttachedTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | class HtmlHeader extends HtmlSemDoubleElement { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | 	use TextAlignmentTrait,AttachedTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 	protected $image; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 	public function __construct($identifier, $niveau=1, $content=NULL, $type="page") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 		parent::__construct($identifier, "div", "ui header"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 		$this->_template="<%tagName% %properties%>%image%%content%</%tagName%>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 		if (isset($type)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 			if ($type == "page") { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 				$this->asPageHeader($niveau); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 			} else | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 				$this->asContentHeader($niveau); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 		$this->content=$content; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	public function asPageHeader($niveau) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 		$this->tagName="h" . $niveau; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  | 	public function asContentHeader($niveau) { | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  | 		$this->tagName="div"; | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  | 		if (\is_int($niveau)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  | 			$niveau=HeaderSize::getConstantValues()[$niveau]; | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  | 		$this->setSize($niveau); | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 	public function asIcon($icon, $title, $subHeader=NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 		$this->addToProperty("class", "icon"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 		$this->image=new HtmlIcon("icon-" . $this->identifier, $icon); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 		return $this->asTitle($title, $subHeader); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	public function asImage($src, $title, $subHeader=NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 		$this->image=new HtmlImg("img-" . $this->identifier, $src, $title); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 		return $this->asTitle($title, $subHeader); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 	public function asTitle($title, $subHeader=NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 		if (!\is_object($title)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 			$this->content=new HtmlDoubleElement("content-" . $this->identifier, "div"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 			$this->content->setContent($title); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 			$this->content=$title; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 		$this->content->setClass("content"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		if (isset($subHeader)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 			$sub=new HtmlDoubleElement("subheader-" . $this->identifier, "div"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 			$sub->setClass("sub header"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 			$sub->setContent($subHeader); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 			$this->content->addContent($sub); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 		return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 	public function getImage() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 		return $this->image; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 	public function setCircular() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 		if (isset($this->image)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 			$this->image->setCircular(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 		return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 	public function setDividing() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 		return $this->addToProperty("class", "dividing"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 	public function setBlock() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 		return $this->addToProperty("class", "block"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 	public static function image($identifier, $image, $niveau=1, $header=NULL, $subHeader=NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 		$result=new HtmlHeader($identifier, $niveau, $header); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 		$result->asImage($image, $header, $subHeader); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 		$result->getImage()->addToProperty("class", "mini rounded"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 		return $result; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 92 |  |  | 	} | 
            
                                                        
            
                                    
            
            
                | 93 |  |  | } |