Completed
Push — master ( db82f0...0ba4b1 )
by Jean-Christophe
03:22
created

HtmlSemDoubleElement::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
3
namespace Ajax\semantic\html\base;
4
5
use Ajax\common\html\HtmlDoubleElement;
6
use Ajax\JsUtils;
7
use Ajax\semantic\html\content\InternalPopup;
8
use Phalcon\Mvc\View;
9
use Ajax\semantic\html\elements\HtmlIcon;
10
use Ajax\semantic\html\base\traits\BaseTrait;
11
12
/**
13
 * Base class for Semantic double elements
14
 * @author jc
15
 * @version 1.001
16
 */
17
class HtmlSemDoubleElement extends HtmlDoubleElement {
18
	use BaseTrait;
19
	protected $_popup=NULL;
20
21
	public function __construct($identifier, $tagName="p",$baseClass="ui") {
22
		parent::__construct($identifier, $tagName);
23
		$this->_baseClass=$baseClass;
24
		$this->setClass($baseClass);
25
	}
26
27
	public function setPopupAttributes($variation=NULL,$popupEvent=NULL){
28
		if(isset($this->_popup))
29
			$this->_popup->setAttributes($variation,$popupEvent);
30
	}
31
32
	public function addPopup($title="",$content="",$variation=NULL,$params=array()){
33
		$this->_popup=new InternalPopup($this,$title,$content,$variation,$params);
34
		return $this;
35
	}
36
37
	public function addPopupHtml($html="",$variation=NULL,$params=array()){
38
		$this->_popup=new InternalPopup($this);
39
		$this->_popup->setHtml($html);
40
		$this->_popup->setAttributes($variation,$params);
41
		return $this;
42
	}
43
44
	/**
45
	 * Adds an icon before or after
46
	 * @param string|HtmlIcon $icon
47
	 * @param boolean $before
48
	 * @param boolean $labeled
49
	 * @return \Ajax\semantic\html\elements\HtmlIcon
50
	 */
51
	public function addIcon($icon,$before=true,$labeled=false){
52
		$iconO=$icon;
53
		if(\is_string($icon)){
54
			$iconO=new HtmlIcon("icon-".$this->identifier, $icon);
55
		}
56
		if($labeled!==false){
57
			$this->addToProperty("class", "labeled icon");
58
			$this->tagName="div";
59
		}
60
		$this->addContent($iconO,$before);
61
		return $iconO;
0 ignored issues
show
Bug Compatibility introduced by
The expression return $iconO; of type string|Ajax\semantic\html\elements\HtmlIcon is incompatible with the return type documented by Ajax\semantic\html\base\...mDoubleElement::addIcon of type Ajax\semantic\html\elements\HtmlIcon as it can also be of type string which is not included in this return type.
Loading history...
62
	}
63
64
	public function compile(JsUtils $js=NULL, View $view=NULL){
65
		if(isset($this->_popup))
66
			$this->_popup->compile();
67
		return parent::compile($js,$view);
68
	}
69
	public function run(JsUtils $js){
70
		parent::run($js);
71
		if(isset($this->_popup)){
72
			$this->_popup->run($js);
73
			//$this->addEventsOnRun($js);
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
74
			//return $this->_bsComponent;
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
75
		}
76
	}
77
/*
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
78
	public function __call($name, $arguments){
79
		$type=\substr($name, 0,3);
80
		$name=\strtolower(\substr($name, 3));
81
		$names=\array_merge($this->_variations,$this->_states);
82
		$argument=@$arguments[0];
83
		if(\array_search($name, $names)!==FALSE){
84
			switch ($type){
85
				case "set":
86
					if($argument===false){
87
						$this->removePropertyValue("class", $name);
88
					}else {
89
						$this->setProperty("class", $this->_baseClass." ".$name);
90
					}
91
					break;
92
				case "add":
93
					$this->addToPropertyCtrl("class", $name,array($name));
94
					break;
95
				default:
96
					throw new \Exception("Méthode ".$type.$name." inexistante.");
97
			}
98
		}else{
99
			throw new \Exception("Propriété ".$name." inexistante.");
100
		}
101
		return $this;
102
	}
103
	*/
104
}