@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | * @property HtmlSemDoubleElement $_self |
16 | 16 | */ |
17 | 17 | trait BaseTrait { |
18 | - protected $_variations=[ ]; |
|
19 | - protected $_states=[ ]; |
|
18 | + protected $_variations=[]; |
|
19 | + protected $_states=[]; |
|
20 | 20 | protected $_baseClass; |
21 | 21 | |
22 | 22 | abstract protected function setPropertyCtrl($name, $value, $typeCtrl); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | abstract public function setProperty($name, $value); |
31 | 31 | |
32 | - abstract public function addContent($content,$before=false); |
|
32 | + abstract public function addContent($content, $before=false); |
|
33 | 33 | |
34 | 34 | abstract public function onCreate($jsCode); |
35 | 35 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $this->_self->setProperty("class", $this->_self->getBaseClass()); |
51 | 51 | if (\is_string($variations)) |
52 | 52 | $variations=\explode(" ", $variations); |
53 | - foreach ( $variations as $variation ) { |
|
53 | + foreach ($variations as $variation) { |
|
54 | 54 | $this->_self->addVariation($variation); |
55 | 55 | } |
56 | 56 | return $this; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | public function addVariations($variations=array()) { |
65 | 65 | if (\is_string($variations)) |
66 | 66 | $variations=\explode(" ", $variations); |
67 | - foreach ( $variations as $variation ) { |
|
67 | + foreach ($variations as $variation) { |
|
68 | 68 | $this->_self->addVariation($variation); |
69 | 69 | } |
70 | 70 | return $this; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function addStates($states=array()) { |
74 | 74 | if (\is_string($states)) |
75 | 75 | $states=\explode(" ", $states); |
76 | - foreach ( $states as $state ) { |
|
76 | + foreach ($states as $state) { |
|
77 | 77 | $this->_self->addState($state); |
78 | 78 | } |
79 | 79 | return $this; |
@@ -83,17 +83,17 @@ discard block |
||
83 | 83 | $this->_self->setProperty("class", $this->_self->getBaseClass()); |
84 | 84 | if (\is_string($states)) |
85 | 85 | $states=\explode(" ", $states); |
86 | - foreach ( $states as $state ) { |
|
86 | + foreach ($states as $state) { |
|
87 | 87 | $this->_self->addState($state); |
88 | 88 | } |
89 | 89 | return $this; |
90 | 90 | } |
91 | 91 | |
92 | 92 | public function addIcon($icon, $before=true) { |
93 | - return $this->_self->addContent(new HtmlIcon("icon-" . $this->_self->getIdentifier(), $icon), $before); |
|
93 | + return $this->_self->addContent(new HtmlIcon("icon-".$this->_self->getIdentifier(), $icon), $before); |
|
94 | 94 | } |
95 | 95 | |
96 | - public function addSticky($context="body"){ |
|
96 | + public function addSticky($context="body") { |
|
97 | 97 | $this->_self->onCreate("$('#".$this->_self->getIdentifier()."').sticky({ context: '".$context."'});"); |
98 | 98 | return $this; |
99 | 99 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @return HtmlSemDoubleElement |
115 | 115 | */ |
116 | 116 | public function setDisabled($disable=true) { |
117 | - if($disable) |
|
117 | + if ($disable) |
|
118 | 118 | $this->_self->addToProperty("class", "disabled"); |
119 | 119 | return $this; |
120 | 120 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return HtmlSemDoubleElement |
142 | 142 | */ |
143 | - public function asHeader(){ |
|
143 | + public function asHeader() { |
|
144 | 144 | return $this->_self->addToProperty("class", "header"); |
145 | 145 | } |
146 | 146 | |
@@ -148,15 +148,15 @@ discard block |
||
148 | 148 | * show it is currently the active user selection |
149 | 149 | * @return HtmlSemDoubleElement |
150 | 150 | */ |
151 | - public function setActive($value=true){ |
|
152 | - if($value) |
|
151 | + public function setActive($value=true) { |
|
152 | + if ($value) |
|
153 | 153 | $this->_self->addToProperty("class", "active"); |
154 | 154 | return $this; |
155 | 155 | } |
156 | 156 | |
157 | - public function setAttached($value=true){ |
|
158 | - if($value) |
|
159 | - $this->_self->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
157 | + public function setAttached($value=true) { |
|
158 | + if ($value) |
|
159 | + $this->_self->addToPropertyCtrl("class", "attached", array("attached")); |
|
160 | 160 | return $this; |
161 | 161 | } |
162 | 162 | |
@@ -164,13 +164,13 @@ discard block |
||
164 | 164 | * can be formatted to appear on dark backgrounds |
165 | 165 | */ |
166 | 166 | public function setInverted($recursive=true) { |
167 | - if($recursive===true){ |
|
167 | + if ($recursive===true) { |
|
168 | 168 | $content=$this->_self->getContent(); |
169 | - if($content instanceof HtmlSemDoubleElement) |
|
169 | + if ($content instanceof HtmlSemDoubleElement) |
|
170 | 170 | $content->setInverted($recursive); |
171 | - elseif(\is_array($content) || $content instanceof \Traversable){ |
|
172 | - foreach ($content as $elm){ |
|
173 | - if($elm instanceof HtmlSemDoubleElement){ |
|
171 | + elseif (\is_array($content) || $content instanceof \Traversable) { |
|
172 | + foreach ($content as $elm) { |
|
173 | + if ($elm instanceof HtmlSemDoubleElement) { |
|
174 | 174 | $elm->setInverted($recursive); |
175 | 175 | } |
176 | 176 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | public function setFloated($direction="right") { |
187 | - return $this->_self->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
|
187 | + return $this->_self->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated")); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | public function floatRight() { |
@@ -199,14 +199,14 @@ discard block |
||
199 | 199 | return $this->_baseClass; |
200 | 200 | } |
201 | 201 | |
202 | - protected function addBehavior(&$array,$key,$value,$before="",$after=""){ |
|
203 | - if(\is_string($value)){ |
|
204 | - if(isset($array[$key])){ |
|
202 | + protected function addBehavior(&$array, $key, $value, $before="", $after="") { |
|
203 | + if (\is_string($value)) { |
|
204 | + if (isset($array[$key])) { |
|
205 | 205 | $p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, ""); |
206 | 206 | $array[$key]=$before.$p.$value.$after; |
207 | - }else |
|
207 | + } else |
|
208 | 208 | $array[$key]=$before.$value.$after; |
209 | - }else{ |
|
209 | + } else { |
|
210 | 210 | $array[$key]=$value; |
211 | 211 | } |
212 | 212 | return $this; |
@@ -2,9 +2,9 @@ discard block |
||
2 | 2 | namespace Ajax\common\traits; |
3 | 3 | use Ajax\common\BaseGui; |
4 | 4 | |
5 | -trait JsUtilsInternalTrait{ |
|
5 | +trait JsUtilsInternalTrait { |
|
6 | 6 | |
7 | - protected $jquery_code_for_compile=array (); |
|
7 | + protected $jquery_code_for_compile=array(); |
|
8 | 8 | |
9 | 9 | protected function _addToCompile($jsScript) { |
10 | 10 | $this->jquery_code_for_compile[]=$jsScript; |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | * @param BaseGui $library |
15 | 15 | * @param mixed $view |
16 | 16 | */ |
17 | - protected function _compileLibrary(BaseGui $library=NULL, &$view=NULL){ |
|
17 | + protected function _compileLibrary(BaseGui $library=NULL, &$view=NULL) { |
|
18 | 18 | if ($library!=NULL) { |
19 | - if(isset($view)) |
|
19 | + if (isset($view)) |
|
20 | 20 | $library->compileHtml($this, $view); |
21 | 21 | if ($library->isAutoCompile()) { |
22 | 22 | $library->compile(true); |
@@ -24,20 +24,20 @@ discard block |
||
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
27 | - protected function defer($script){ |
|
27 | + protected function defer($script) { |
|
28 | 28 | $result="window.defer=function (method) {if (window.jQuery) method(); else setTimeout(function() { defer(method) }, 50);};"; |
29 | 29 | $result.="window.defer(function(){".$script."})"; |
30 | 30 | return $result; |
31 | 31 | } |
32 | 32 | |
33 | - protected function ready($script){ |
|
33 | + protected function ready($script) { |
|
34 | 34 | $result='$(document).ready(function() {'."\n"; |
35 | 35 | $result.=$script.'})'; |
36 | 36 | return $result; |
37 | 37 | } |
38 | 38 | |
39 | 39 | protected function minify($input) { |
40 | - if(trim($input) === "") return $input; |
|
40 | + if (trim($input)==="") return $input; |
|
41 | 41 | return preg_replace( |
42 | 42 | array( |
43 | 43 | // Remove comment(s) |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | * @author jc |
10 | 10 | * @property BaseWidget $_self |
11 | 11 | */ |
12 | -trait BaseHtmlPropertiesTrait{ |
|
12 | +trait BaseHtmlPropertiesTrait { |
|
13 | 13 | |
14 | - protected $properties=array (); |
|
14 | + protected $properties=array(); |
|
15 | 15 | abstract protected function ctrl($name, $value, $typeCtrl); |
16 | 16 | abstract protected function removeOldValues(&$oldValue, $allValues); |
17 | - abstract protected function _getElementBy($callback,$elements); |
|
17 | + abstract protected function _getElementBy($callback, $elements); |
|
18 | 18 | public function getProperties() { |
19 | 19 | return $this->_self->properties; |
20 | 20 | } |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | |
41 | 41 | public function addToProperty($name, $value, $separator=" ") { |
42 | 42 | if (\is_array($value)) { |
43 | - foreach ( $value as $v ) { |
|
43 | + foreach ($value as $v) { |
|
44 | 44 | $this->_self->addToProperty($name, $v, $separator); |
45 | 45 | } |
46 | - } else if ($value !== "" && $this->_self->propertyContains($name, $value) === false) { |
|
46 | + } else if ($value!=="" && $this->_self->propertyContains($name, $value)===false) { |
|
47 | 47 | $v=@$this->_self->properties[$name]; |
48 | - if (isset($v) && $v !== "") |
|
49 | - $v=$v . $separator . $value; |
|
48 | + if (isset($v) && $v!=="") |
|
49 | + $v=$v.$separator.$value; |
|
50 | 50 | else |
51 | 51 | $v=$value; |
52 | 52 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | public function addToPropertyCtrlCheck($name, $value, $typeCtrl) { |
87 | - if ($this->_self->ctrl($name, $value, $typeCtrl) === true) { |
|
87 | + if ($this->_self->ctrl($name, $value, $typeCtrl)===true) { |
|
88 | 88 | return $this->_self->addToProperty($name, $value); |
89 | 89 | } |
90 | 90 | return $this; |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
108 | - if ($this->_self->ctrl($name, $value, $typeCtrl) === true) |
|
108 | + if ($this->_self->ctrl($name, $value, $typeCtrl)===true) |
|
109 | 109 | return $this->_self->setProperty($name, $value); |
110 | 110 | return $this; |
111 | 111 | } |
112 | 112 | |
113 | - protected function getElementByPropertyValue($propertyName,$value, $elements) { |
|
114 | - return $this->_self->_getElementBy(function(BaseHtml $element) use ($propertyName,$value){return $element->propertyContains($propertyName, $value) === true;}, $elements); |
|
113 | + protected function getElementByPropertyValue($propertyName, $value, $elements) { |
|
114 | + return $this->_self->_getElementBy(function(BaseHtml $element) use ($propertyName, $value){return $element->propertyContains($propertyName, $value)===true; }, $elements); |
|
115 | 115 | } |
116 | 116 | } |
@@ -15,11 +15,11 @@ discard block |
||
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 | protected $_compiled=false; |
25 | 25 | |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | */ |
31 | 31 | abstract public function run(JsUtils $js); |
32 | 32 | |
33 | - private function _callSetter($setter,$key,$value,&$array){ |
|
33 | + private function _callSetter($setter, $key, $value, &$array) { |
|
34 | 34 | $result=false; |
35 | 35 | if (method_exists($this, $setter) && !JString::startswith($key, "_")) { |
36 | 36 | try { |
37 | 37 | $this->$setter($value); |
38 | 38 | unset($array[$key]); |
39 | 39 | $result=true; |
40 | - } catch ( \Exception $e ) { |
|
40 | + }catch (\Exception $e) { |
|
41 | 41 | $result=false; |
42 | 42 | } |
43 | 43 | } |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | protected function getTemplate(JsUtils $js=NULL) { |
48 | - return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
48 | + return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | protected function ctrl($name, $value, $typeCtrl) { |
52 | 52 | if (\is_array($typeCtrl)) { |
53 | - if (array_search($value, $typeCtrl) === false) { |
|
54 | - throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}"); |
|
53 | + if (array_search($value, $typeCtrl)===false) { |
|
54 | + throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
55 | 55 | } |
56 | 56 | } else { |
57 | 57 | if (!$typeCtrl($value)) { |
58 | - throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name); |
|
58 | + throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | return true; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | |
66 | 66 | protected function setMemberCtrl(&$name, $value, $typeCtrl) { |
67 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
67 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
68 | 68 | return $name=$value; |
69 | 69 | } |
70 | 70 | return $this; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") { |
74 | 74 | if (\is_array($typeCtrl)) { |
75 | 75 | $this->removeOldValues($name, $typeCtrl); |
76 | - $name.=$separator . $value; |
|
76 | + $name.=$separator.$value; |
|
77 | 77 | } |
78 | 78 | return $this; |
79 | 79 | } |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | |
82 | 82 | |
83 | 83 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
84 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
84 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
85 | 85 | if (\is_array($typeCtrl)) { |
86 | 86 | $this->removeOldValues($name, $typeCtrl); |
87 | 87 | } |
88 | - $name.=$separator . $value; |
|
88 | + $name.=$separator.$value; |
|
89 | 89 | } |
90 | 90 | return $this; |
91 | 91 | } |
92 | 92 | |
93 | 93 | protected function addToMember(&$name, $value, $separator=" ") { |
94 | - $name=str_ireplace($value, "", $name) . $separator . $value; |
|
94 | + $name=str_ireplace($value, "", $name).$separator.$value; |
|
95 | 95 | return $this; |
96 | 96 | } |
97 | 97 | |
@@ -102,18 +102,18 @@ discard block |
||
102 | 102 | $oldValue=trim($oldValue); |
103 | 103 | } |
104 | 104 | |
105 | - protected function _getElementBy($callback,$elements){ |
|
105 | + protected function _getElementBy($callback, $elements) { |
|
106 | 106 | if (\is_array($elements)) { |
107 | 107 | $elements=\array_values($elements); |
108 | 108 | $flag=false; |
109 | 109 | $index=0; |
110 | - while ( !$flag && $index < sizeof($elements) ) { |
|
110 | + while (!$flag && $index<sizeof($elements)) { |
|
111 | 111 | if ($elements[$index] instanceof BaseHtml) |
112 | 112 | $flag=($callback($elements[$index])); |
113 | 113 | $index++; |
114 | 114 | } |
115 | - if ($flag === true) |
|
116 | - return $elements[$index - 1]; |
|
115 | + if ($flag===true) |
|
116 | + return $elements[$index-1]; |
|
117 | 117 | } elseif ($elements instanceof BaseHtml) { |
118 | 118 | if ($callback($elements)) |
119 | 119 | return $elements; |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | public function fromArray($array) { |
144 | - foreach ( $this as $key => $value ) { |
|
145 | - if(array_key_exists($key, $array)===true) |
|
146 | - $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
144 | + foreach ($this as $key => $value) { |
|
145 | + if (array_key_exists($key, $array)===true) |
|
146 | + $this->_callSetter("set".ucfirst($key), $key, $array[$key], $array); |
|
147 | 147 | } |
148 | - foreach ( $array as $key => $value ) { |
|
149 | - if($this->_callSetter($key, $key, $value, $array)===false){ |
|
150 | - $this->_callSetter("set" . ucfirst($key), $key, $value, $array); |
|
148 | + foreach ($array as $key => $value) { |
|
149 | + if ($this->_callSetter($key, $key, $value, $array)===false) { |
|
150 | + $this->_callSetter("set".ucfirst($key), $key, $value, $array); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | return $array; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | |
156 | 156 | public function fromDatabaseObjects($objects, $function) { |
157 | 157 | if (isset($objects)) { |
158 | - foreach ( $objects as $object ) { |
|
158 | + foreach ($objects as $object) { |
|
159 | 159 | $this->fromDatabaseObject($object, $function); |
160 | 160 | } |
161 | 161 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | |
178 | 178 | public function getElementById($identifier, $elements) { |
179 | - return $this->_getElementBy(function(BaseWidget $element) use ($identifier){return $element->getIdentifier()===$identifier;}, $elements); |
|
179 | + return $this->_getElementBy(function(BaseWidget $element) use ($identifier){return $element->getIdentifier()===$identifier; }, $elements); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | public function getBsComponent() { |
@@ -189,11 +189,11 @@ discard block |
||
189 | 189 | } |
190 | 190 | |
191 | 191 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
192 | - if(!$this->_compiled){ |
|
193 | - if(isset($js)){ |
|
192 | + if (!$this->_compiled) { |
|
193 | + if (isset($js)) { |
|
194 | 194 | $beforeCompile=$js->getParam("beforeCompileHtml"); |
195 | - if(\is_callable($beforeCompile)){ |
|
196 | - $beforeCompile($this,$js,$view); |
|
195 | + if (\is_callable($beforeCompile)) { |
|
196 | + $beforeCompile($this, $js, $view); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | $this->_compiled=true; |
@@ -201,21 +201,21 @@ discard block |
||
201 | 201 | } |
202 | 202 | |
203 | 203 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
204 | - $this->compile_once($js,$view); |
|
204 | + $this->compile_once($js, $view); |
|
205 | 205 | $result=$this->getTemplate($js); |
206 | - foreach ( $this as $key => $value ) { |
|
207 | - if (JString::startswith($key, "_") === false && $key !== "events") { |
|
206 | + foreach ($this as $key => $value) { |
|
207 | + if (JString::startswith($key, "_")===false && $key!=="events") { |
|
208 | 208 | if (\is_array($value)) { |
209 | 209 | $v=PropertyWrapper::wrap($value, $js); |
210 | 210 | } else { |
211 | 211 | $v=$value; |
212 | 212 | } |
213 | - $result=str_ireplace("%" . $key . "%", $v, $result); |
|
213 | + $result=str_ireplace("%".$key."%", $v, $result); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | if (isset($js)===true) { |
217 | 217 | $this->run($js); |
218 | - if (isset($view) === true) { |
|
218 | + if (isset($view)===true) { |
|
219 | 219 | $js->addViewElement($this->_identifier, $result, $view); |
220 | 220 | } |
221 | 221 | } |