Completed
Push — master ( 3ded41...1b9fb1 )
by Jean-Christophe
03:08
created
Ajax/common/html/BaseHtml.php 3 patches
Doc Comments   +14 added lines patch added patch discarded remove patch
@@ -55,6 +55,10 @@  discard block
 block discarded – undo
55 55
 
56 56
 
57 57
 
58
+	/**
59
+	 * @param string $name
60
+	 * @param string[] $typeCtrl
61
+	 */
58 62
 	protected function setMemberCtrl(&$name, $value, $typeCtrl) {
59 63
 		if ($this->ctrl($name, $value, $typeCtrl) === true) {
60 64
 			return $name=$value;
@@ -72,6 +76,10 @@  discard block
 block discarded – undo
72 76
 
73 77
 
74 78
 
79
+	/**
80
+	 * @param string $name
81
+	 * @param string[] $typeCtrl
82
+	 */
75 83
 	protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") {
76 84
 		if ($this->ctrl($name, $value, $typeCtrl) === true) {
77 85
 			if (\is_array($typeCtrl)) {
@@ -82,6 +90,9 @@  discard block
 block discarded – undo
82 90
 		return $this;
83 91
 	}
84 92
 
93
+	/**
94
+	 * @param string $name
95
+	 */
85 96
 	protected function addToMember(&$name, $value, $separator=" ") {
86 97
 		$name=str_ireplace($value, "", $name) . $separator . $value;
87 98
 		return $this;
@@ -94,6 +105,9 @@  discard block
 block discarded – undo
94 105
 		$oldValue=trim($oldValue);
95 106
 	}
96 107
 
108
+	/**
109
+	 * @param \Closure $callback
110
+	 */
97 111
 	protected function _getElementBy($callback,$elements){
98 112
 		if (\is_array($elements)) {
99 113
 			$flag=false;
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -15,21 +15,21 @@  discard block
 block discarded – undo
15 15
  * @version 1.3
16 16
  */
17 17
 abstract class BaseHtml extends BaseWidget {
18
-	use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait;
18
+	use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait;
19 19
 	protected $_template;
20 20
 	protected $tagName;
21
-	protected $_wrapBefore=array ();
22
-	protected $_wrapAfter=array ();
21
+	protected $_wrapBefore=array();
22
+	protected $_wrapAfter=array();
23 23
 	protected $_bsComponent;
24 24
 
25
-	private function _callSetter($setter,$key,$value,&$array){
25
+	private function _callSetter($setter, $key, $value, &$array) {
26 26
 		$result=false;
27 27
 		if (method_exists($this, $setter) && !JString::startswith($key, "_")) {
28 28
 			try {
29 29
 				$this->$setter($value);
30 30
 				unset($array[$key]);
31 31
 				$result=true;
32
-			} catch ( \Exception $e ) {
32
+			}catch (\Exception $e) {
33 33
 				$result=false;
34 34
 			}
35 35
 		}
@@ -37,17 +37,17 @@  discard block
 block discarded – undo
37 37
 	}
38 38
 
39 39
 	protected function getTemplate(JsUtils $js=NULL) {
40
-		return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js);
40
+		return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js);
41 41
 	}
42 42
 
43 43
 	protected function ctrl($name, $value, $typeCtrl) {
44 44
 		if (\is_array($typeCtrl)) {
45
-			if (array_search($value, $typeCtrl) === false) {
46
-				throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}");
45
+			if (array_search($value, $typeCtrl)===false) {
46
+				throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
47 47
 			}
48 48
 		} else {
49 49
 			if (!$typeCtrl($value)) {
50
-				throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name);
50
+				throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name);
51 51
 			}
52 52
 		}
53 53
 		return true;
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 
58 58
 	protected function setMemberCtrl(&$name, $value, $typeCtrl) {
59
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
59
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
60 60
 			return $name=$value;
61 61
 		}
62 62
 		return $this;
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") {
66 66
 		if (\is_array($typeCtrl)) {
67 67
 			$this->removeOldValues($name, $typeCtrl);
68
-			$name.=$separator . $value;
68
+			$name.=$separator.$value;
69 69
 		}
70 70
 		return $this;
71 71
 	}
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
 
74 74
 
75 75
 	protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") {
76
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
76
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
77 77
 			if (\is_array($typeCtrl)) {
78 78
 				$this->removeOldValues($name, $typeCtrl);
79 79
 			}
80
-			$name.=$separator . $value;
80
+			$name.=$separator.$value;
81 81
 		}
82 82
 		return $this;
83 83
 	}
84 84
 
85 85
 	protected function addToMember(&$name, $value, $separator=" ") {
86
-		$name=str_ireplace($value, "", $name) . $separator . $value;
86
+		$name=str_ireplace($value, "", $name).$separator.$value;
87 87
 		return $this;
88 88
 	}
89 89
 
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
 		$oldValue=trim($oldValue);
95 95
 	}
96 96
 
97
-	protected function _getElementBy($callback,$elements){
97
+	protected function _getElementBy($callback, $elements) {
98 98
 		if (\is_array($elements)) {
99 99
 			$flag=false;
100 100
 			$index=0;
101
-			while ( !$flag && $index < sizeof($elements) ) {
101
+			while (!$flag && $index<sizeof($elements)) {
102 102
 				if ($elements[$index] instanceof BaseHtml)
103 103
 					$flag=($callback($elements[$index]));
104 104
 					$index++;
105 105
 			}
106
-			if ($flag === true)
107
-				return $elements[$index - 1];
106
+			if ($flag===true)
107
+				return $elements[$index-1];
108 108
 		} elseif ($elements instanceof BaseHtml) {
109 109
 			if ($callback($elements))
110 110
 				return $elements;
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
 	}
140 140
 
141 141
 	public function fromArray($array) {
142
-		foreach ( $this as $key => $value ) {
143
-			if(array_key_exists($key, $array)===true)
144
-				$this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array);
142
+		foreach ($this as $key => $value) {
143
+			if (array_key_exists($key, $array)===true)
144
+				$this->_callSetter("set".ucfirst($key), $key, $array[$key], $array);
145 145
 		}
146
-		foreach ( $array as $key => $value ) {
147
-			if($this->_callSetter($key, $key, $value, $array)===false){
148
-				$this->_callSetter("set" . ucfirst($key), $key, $value, $array);
146
+		foreach ($array as $key => $value) {
147
+			if ($this->_callSetter($key, $key, $value, $array)===false) {
148
+				$this->_callSetter("set".ucfirst($key), $key, $value, $array);
149 149
 			}
150 150
 		}
151 151
 		return $array;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 
154 154
 	public function fromDatabaseObjects($objects, $function) {
155 155
 		if (isset($objects)) {
156
-			foreach ( $objects as $object ) {
156
+			foreach ($objects as $object) {
157 157
 				$this->fromDatabaseObject($object, $function);
158 158
 			}
159 159
 		}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
 
176 176
 	public function getElementById($identifier, $elements) {
177
-		return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier;}, $elements);
177
+		return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier; }, $elements);
178 178
 	}
179 179
 
180 180
 	public function getBsComponent() {
@@ -188,19 +188,19 @@  discard block
 block discarded – undo
188 188
 
189 189
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
190 190
 		$result=$this->getTemplate($js);
191
-		foreach ( $this as $key => $value ) {
192
-			if (JString::startswith($key, "_") === false && $key !== "events") {
191
+		foreach ($this as $key => $value) {
192
+			if (JString::startswith($key, "_")===false && $key!=="events") {
193 193
 				if (\is_array($value)) {
194 194
 					$v=PropertyWrapper::wrap($value, $js);
195 195
 				} else {
196 196
 					$v=$value;
197 197
 				}
198
-				$result=str_ireplace("%" . $key . "%", $v, $result);
198
+				$result=str_ireplace("%".$key."%", $v, $result);
199 199
 			}
200 200
 		}
201 201
 		if (isset($js)===true) {
202 202
 			$this->run($js);
203
-			if (isset($view) === true) {
203
+			if (isset($view)===true) {
204 204
 				$js->addViewElement($this->identifier, $result, $view);
205 205
 			}
206 206
 		}
Please login to merge, or discard this patch.
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -99,15 +99,18 @@  discard block
 block discarded – undo
99 99
 			$flag=false;
100 100
 			$index=0;
101 101
 			while ( !$flag && $index < sizeof($elements) ) {
102
-				if ($elements[$index] instanceof BaseHtml)
103
-					$flag=($callback($elements[$index]));
102
+				if ($elements[$index] instanceof BaseHtml) {
103
+									$flag=($callback($elements[$index]));
104
+				}
104 105
 					$index++;
105 106
 			}
106
-			if ($flag === true)
107
-				return $elements[$index - 1];
107
+			if ($flag === true) {
108
+							return $elements[$index - 1];
109
+			}
108 110
 		} elseif ($elements instanceof BaseHtml) {
109
-			if ($callback($elements))
110
-				return $elements;
111
+			if ($callback($elements)) {
112
+							return $elements;
113
+			}
111 114
 		}
112 115
 		return null;
113 116
 	}
@@ -140,8 +143,9 @@  discard block
 block discarded – undo
140 143
 
141 144
 	public function fromArray($array) {
142 145
 		foreach ( $this as $key => $value ) {
143
-			if(array_key_exists($key, $array)===true)
144
-				$this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array);
146
+			if(array_key_exists($key, $array)===true) {
147
+							$this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array);
148
+			}
145 149
 		}
146 150
 		foreach ( $array as $key => $value ) {
147 151
 			if($this->_callSetter($key, $key, $value, $array)===false){
Please login to merge, or discard this patch.
Ajax/semantic/html/content/InternalPopup.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,64 +14,64 @@
 block discarded – undo
14 14
 	protected $params;
15 15
 	protected $semElement;
16 16
 
17
-	public function __construct($semElement,$title="",$content="",$variation=NULL,$params=array()){
17
+	public function __construct($semElement, $title="", $content="", $variation=NULL, $params=array()) {
18 18
 		$this->semElement=$semElement;
19 19
 		$this->title=$title;
20 20
 		$this->content=$content;
21
-		$this->setAttributes($variation,$params);
21
+		$this->setAttributes($variation, $params);
22 22
 	}
23 23
 
24 24
 	public function setHtml($html) {
25
-		$this->html= $html;
25
+		$this->html=$html;
26 26
 		return $this;
27 27
 	}
28 28
 
29
-	public function setAttributes($variation=NULL,$params=array()){
29
+	public function setAttributes($variation=NULL, $params=array()) {
30 30
 		$this->variation=$variation;
31 31
 		$this->params=$params;
32 32
 	}
33 33
 
34
-	public function onShow($jsCode){
34
+	public function onShow($jsCode) {
35 35
 		$this->params["onShow"]=$jsCode;
36 36
 	}
37 37
 
38
-	public function compile(JsUtils $js=NULL){
39
-		if(JString::isNotNull($this->title)){
38
+	public function compile(JsUtils $js=NULL) {
39
+		if (JString::isNotNull($this->title)) {
40 40
 			$this->semElement->addToProperty("data-title", $this->title);
41 41
 		}
42
-		if(JString::isNotNull($this->content)){
42
+		if (JString::isNotNull($this->content)) {
43 43
 			$this->semElement->addToProperty("data-content", $this->content);
44 44
 		}
45 45
 		$this->_compileHtml($js);
46
-		if(JString::isNotNull($this->variation)){
46
+		if (JString::isNotNull($this->variation)) {
47 47
 			$this->semElement->addToProperty("data-variation", $this->variation);
48 48
 		}
49 49
 	}
50 50
 
51
-	private function _compileHtml(JsUtils $js=NULL){
52
-		if(JString::isNotNull($this->html)){
51
+	private function _compileHtml(JsUtils $js=NULL) {
52
+		if (JString::isNotNull($this->html)) {
53 53
 			$html=$this->html;
54
-			if(\is_array($html)){
54
+			if (\is_array($html)) {
55 55
 				\array_walk($html, function(&$item) use($js){
56
-					if($item instanceof HtmlSemDoubleElement){
56
+					if ($item instanceof HtmlSemDoubleElement) {
57 57
 						$comp=$item->compile($js);
58
-						if(isset($js)){
58
+						if (isset($js)) {
59 59
 							$bs=$item->run($js);
60
-							if(isset($bs))
60
+							if (isset($bs))
61 61
 								$this->params['onShow']=$bs->getScript();
62 62
 						}
63 63
 						$item=$comp;
64 64
 					}
65 65
 				});
66
-				$html=\implode("",$html);
66
+				$html=\implode("", $html);
67 67
 			}
68 68
 			$html=\str_replace("\"", "'", $html);
69 69
 			$this->semElement->addToProperty("data-html", $html);
70 70
 		}
71 71
 	}
72 72
 
73
-	public function run(JsUtils $js){
74
-		$js->semantic()->popup("#".$this->semElement->getIdentifier(),$this->params);
73
+	public function run(JsUtils $js) {
74
+		$js->semantic()->popup("#".$this->semElement->getIdentifier(), $this->params);
75 75
 	}
76 76
 
77 77
 }
78 78
\ No newline at end of file
Please login to merge, or discard this patch.