@@ -10,16 +10,16 @@ discard block |
||
10 | 10 | * @property SimpleExtComponent $_bsComponent |
11 | 11 | * @property string identifier |
12 | 12 | */ |
13 | -trait BaseHtmlEventsTrait{ |
|
13 | +trait BaseHtmlEventsTrait { |
|
14 | 14 | |
15 | - protected $_events=array (); |
|
15 | + protected $_events=array(); |
|
16 | 16 | |
17 | 17 | public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
18 | - if ($stopPropagation === true) { |
|
19 | - $jsCode="event.stopPropagation();" . $jsCode; |
|
18 | + if ($stopPropagation===true) { |
|
19 | + $jsCode="event.stopPropagation();".$jsCode; |
|
20 | 20 | } |
21 | - if ($preventDefault === true) { |
|
22 | - $jsCode="event.preventDefault();" . $jsCode; |
|
21 | + if ($preventDefault===true) { |
|
22 | + $jsCode="event.preventDefault();".$jsCode; |
|
23 | 23 | } |
24 | 24 | return $this->_addEvent($event, $jsCode); |
25 | 25 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | if (is_array($this->_events[$event])) { |
30 | 30 | $this->_events[$event][]=$jsCode; |
31 | 31 | } else { |
32 | - $this->_events[$event]=array ($this->_events[$event],$jsCode ); |
|
32 | + $this->_events[$event]=array($this->_events[$event], $jsCode); |
|
33 | 33 | } |
34 | 34 | } else { |
35 | 35 | $this->_events[$event]=$jsCode; |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | return $this->onClick($jsCode); |
50 | 50 | } |
51 | 51 | |
52 | - public function onCreate($jsCode){ |
|
53 | - if(isset($this->_events["_create"])){ |
|
52 | + public function onCreate($jsCode) { |
|
53 | + if (isset($this->_events["_create"])) { |
|
54 | 54 | $this->_events["_create"][]=$jsCode; |
55 | - }else{ |
|
55 | + } else { |
|
56 | 56 | $this->_events["_create"]=[$jsCode]; |
57 | 57 | } |
58 | 58 | return $this; |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | public function addEventsOnRun(JsUtils $js=NULL) { |
62 | 62 | $this->_eventsOnCreate($js); |
63 | 63 | if (isset($this->_bsComponent)) { |
64 | - foreach ( $this->_events as $event => $jsCode ) { |
|
64 | + foreach ($this->_events as $event => $jsCode) { |
|
65 | 65 | $code=$jsCode; |
66 | 66 | if (is_array($jsCode)) { |
67 | 67 | $code=""; |
68 | - foreach ( $jsCode as $jsC ) { |
|
68 | + foreach ($jsCode as $jsC) { |
|
69 | 69 | if ($jsC instanceof AjaxCall) { |
70 | - $code.="\n" . $jsC->compile($js); |
|
70 | + $code.="\n".$jsC->compile($js); |
|
71 | 71 | } else { |
72 | - $code.="\n" . $jsC; |
|
72 | + $code.="\n".$jsC; |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | } elseif ($jsCode instanceof AjaxCall) { |
@@ -77,24 +77,24 @@ discard block |
||
77 | 77 | } |
78 | 78 | $this->_bsComponent->addEvent($event, $code); |
79 | 79 | } |
80 | - $this->_events=array (); |
|
80 | + $this->_events=array(); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | - protected function _eventsOnCreate(JsUtils $js=NULL){ |
|
85 | - if(isset($this->_events["_create"])){ |
|
84 | + protected function _eventsOnCreate(JsUtils $js=NULL) { |
|
85 | + if (isset($this->_events["_create"])) { |
|
86 | 86 | $create=$this->_events["_create"]; |
87 | - if(\is_array($create)){ |
|
87 | + if (\is_array($create)) { |
|
88 | 88 | $create=\implode("", $create); |
89 | 89 | } |
90 | - if(isset($js) && $create!=="") |
|
91 | - $js->exec($create,true); |
|
90 | + if (isset($js) && $create!=="") |
|
91 | + $js->exec($create, true); |
|
92 | 92 | unset($this->_events["_create"]); |
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | 96 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
97 | - $params=array ("url" => $url,"responseElement" => $responseElement ); |
|
97 | + $params=array("url" => $url, "responseElement" => $responseElement); |
|
98 | 98 | $params=array_merge($params, $parameters); |
99 | 99 | $this->_addEvent($event, new AjaxCall($operation, $params)); |
100 | 100 | return $this; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | public function jsDoJquery($jqueryCall, $param="") { |
130 | - return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . Javascript::prep_value($param) . ");"; |
|
130 | + return "$('#".$this->identifier."').".$jqueryCall."(".Javascript::prep_value($param).");"; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | public function executeOnRun($jsCode) { |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | use BaseHtmlEventsTrait; |
18 | 18 | protected $_template; |
19 | 19 | protected $tagName; |
20 | - protected $properties=array (); |
|
21 | - protected $_wrapBefore=array (); |
|
22 | - protected $_wrapAfter=array (); |
|
20 | + protected $properties=array(); |
|
21 | + protected $_wrapBefore=array(); |
|
22 | + protected $_wrapAfter=array(); |
|
23 | 23 | protected $_bsComponent; |
24 | 24 | |
25 | 25 | public function getBsComponent() { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | protected function getTemplate(JsUtils $js=NULL) { |
35 | - return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
35 | + return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function getProperties() { |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | |
57 | 57 | public function addToProperty($name, $value, $separator=" ") { |
58 | 58 | if (\is_array($value)) { |
59 | - foreach ( $value as $v ) { |
|
59 | + foreach ($value as $v) { |
|
60 | 60 | $this->addToProperty($name, $v, $separator); |
61 | 61 | } |
62 | - } else if ($value !== "" && $this->propertyContains($name, $value) === false) { |
|
62 | + } else if ($value!=="" && $this->propertyContains($name, $value)===false) { |
|
63 | 63 | $v=@$this->properties[$name]; |
64 | - if (isset($v) && $v !== "") |
|
65 | - $v=$v . $separator . $value; |
|
64 | + if (isset($v) && $v!=="") |
|
65 | + $v=$v.$separator.$value; |
|
66 | 66 | else |
67 | 67 | $v=$value; |
68 | 68 | |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | |
79 | 79 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
80 | 80 | $result=$this->getTemplate($js); |
81 | - foreach ( $this as $key => $value ) { |
|
82 | - if (JString::startswith($key, "_") === false && $key !== "events") { |
|
81 | + foreach ($this as $key => $value) { |
|
82 | + if (JString::startswith($key, "_")===false && $key!=="events") { |
|
83 | 83 | if (is_array($value)) { |
84 | 84 | $v=PropertyWrapper::wrap($value, $js); |
85 | 85 | } else { |
86 | 86 | $v=$value; |
87 | 87 | } |
88 | - $result=str_ireplace("%" . $key . "%", $v, $result); |
|
88 | + $result=str_ireplace("%".$key."%", $v, $result); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | if (isset($js)===true) { |
92 | 92 | $this->run($js); |
93 | - if (isset($view) === true) { |
|
93 | + if (isset($view)===true) { |
|
94 | 94 | $js->addViewElement($this->identifier, $result, $view); |
95 | 95 | } |
96 | 96 | } |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | |
100 | 100 | protected function ctrl($name, $value, $typeCtrl) { |
101 | 101 | if (is_array($typeCtrl)) { |
102 | - if (array_search($value, $typeCtrl) === false) { |
|
103 | - throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}"); |
|
102 | + if (array_search($value, $typeCtrl)===false) { |
|
103 | + throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
104 | 104 | } |
105 | 105 | } else { |
106 | 106 | if (!$typeCtrl($value)) { |
107 | - throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name); |
|
107 | + throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | return true; |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
122 | - if ($this->ctrl($name, $value, $typeCtrl) === true) |
|
122 | + if ($this->ctrl($name, $value, $typeCtrl)===true) |
|
123 | 123 | return $this->setProperty($name, $value); |
124 | 124 | return $this; |
125 | 125 | } |
126 | 126 | |
127 | 127 | protected function setMemberCtrl(&$name, $value, $typeCtrl) { |
128 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
128 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
129 | 129 | return $name=$value; |
130 | 130 | } |
131 | 131 | return $this; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") { |
135 | 135 | if (is_array($typeCtrl)) { |
136 | 136 | $this->removeOldValues($name, $typeCtrl); |
137 | - $name.=$separator . $value; |
|
137 | + $name.=$separator.$value; |
|
138 | 138 | } |
139 | 139 | return $this; |
140 | 140 | } |
@@ -156,17 +156,17 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
159 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
159 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
160 | 160 | if (is_array($typeCtrl)) { |
161 | 161 | $this->removeOldValues($name, $typeCtrl); |
162 | 162 | } |
163 | - $name.=$separator . $value; |
|
163 | + $name.=$separator.$value; |
|
164 | 164 | } |
165 | 165 | return $this; |
166 | 166 | } |
167 | 167 | |
168 | 168 | protected function addToMember(&$name, $value, $separator=" ") { |
169 | - $name=str_ireplace($value, "", $name) . $separator . $value; |
|
169 | + $name=str_ireplace($value, "", $name).$separator.$value; |
|
170 | 170 | return $this; |
171 | 171 | } |
172 | 172 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | public function addToPropertyCtrlCheck($name, $value, $typeCtrl) { |
187 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
187 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
188 | 188 | return $this->addToProperty($name, $value); |
189 | 189 | } |
190 | 190 | return $this; |
@@ -212,26 +212,26 @@ discard block |
||
212 | 212 | } |
213 | 213 | |
214 | 214 | public function fromArray($array) { |
215 | - foreach ( $this as $key => $value ) { |
|
216 | - if(array_key_exists($key, $array)===true) |
|
217 | - $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
215 | + foreach ($this as $key => $value) { |
|
216 | + if (array_key_exists($key, $array)===true) |
|
217 | + $this->_callSetter("set".ucfirst($key), $key, $array[$key], $array); |
|
218 | 218 | } |
219 | - foreach ( $array as $key => $value ) { |
|
220 | - if($this->_callSetter($key, $key, $value, $array)===false){ |
|
221 | - $this->_callSetter("set" . ucfirst($key), $key, $value, $array); |
|
219 | + foreach ($array as $key => $value) { |
|
220 | + if ($this->_callSetter($key, $key, $value, $array)===false) { |
|
221 | + $this->_callSetter("set".ucfirst($key), $key, $value, $array); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | return $array; |
225 | 225 | } |
226 | 226 | |
227 | - private function _callSetter($setter,$key,$value,&$array){ |
|
227 | + private function _callSetter($setter, $key, $value, &$array) { |
|
228 | 228 | $result=false; |
229 | 229 | if (method_exists($this, $setter) && !JString::startswith($key, "_")) { |
230 | 230 | try { |
231 | 231 | $this->$setter($value); |
232 | 232 | unset($array[$key]); |
233 | 233 | $result=true; |
234 | - } catch ( \Exception $e ) { |
|
234 | + }catch (\Exception $e) { |
|
235 | 235 | $result=false; |
236 | 236 | } |
237 | 237 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | |
241 | 241 | public function fromDatabaseObjects($objects, $function) { |
242 | 242 | if (isset($objects)) { |
243 | - foreach ( $objects as $object ) { |
|
243 | + foreach ($objects as $object) { |
|
244 | 244 | $this->fromDatabaseObject($object, $function); |
245 | 245 | } |
246 | 246 | } |
@@ -264,33 +264,33 @@ discard block |
||
264 | 264 | if (is_array($elements)) { |
265 | 265 | $flag=false; |
266 | 266 | $index=0; |
267 | - while ( !$flag && $index < sizeof($elements) ) { |
|
267 | + while (!$flag && $index<sizeof($elements)) { |
|
268 | 268 | if ($elements[$index] instanceof BaseHtml) |
269 | - $flag=($elements[$index]->getIdentifier() === $identifier); |
|
269 | + $flag=($elements[$index]->getIdentifier()===$identifier); |
|
270 | 270 | $index++; |
271 | 271 | } |
272 | - if ($flag === true) |
|
273 | - return $elements[$index - 1]; |
|
272 | + if ($flag===true) |
|
273 | + return $elements[$index-1]; |
|
274 | 274 | } elseif ($elements instanceof BaseHtml) { |
275 | - if ($elements->getIdentifier() === $identifier) |
|
275 | + if ($elements->getIdentifier()===$identifier) |
|
276 | 276 | return $elements; |
277 | 277 | } |
278 | 278 | return null; |
279 | 279 | } |
280 | 280 | |
281 | - protected function getElementByPropertyValue($propertyName,$value, $elements) { |
|
281 | + protected function getElementByPropertyValue($propertyName, $value, $elements) { |
|
282 | 282 | if (is_array($elements)) { |
283 | 283 | $flag=false; |
284 | 284 | $index=0; |
285 | - while ( !$flag && $index < sizeof($elements) ) { |
|
285 | + while (!$flag && $index<sizeof($elements)) { |
|
286 | 286 | if ($elements[$index] instanceof BaseHtml) |
287 | - $flag=($elements[$index]->propertyContains($propertyName, $value) === true); |
|
287 | + $flag=($elements[$index]->propertyContains($propertyName, $value)===true); |
|
288 | 288 | $index++; |
289 | 289 | } |
290 | - if ($flag === true) |
|
291 | - return $elements[$index - 1]; |
|
290 | + if ($flag===true) |
|
291 | + return $elements[$index-1]; |
|
292 | 292 | } elseif ($elements instanceof BaseHtml) { |
293 | - if ($elements->propertyContains($propertyName, $value) === true) |
|
293 | + if ($elements->propertyContains($propertyName, $value)===true) |
|
294 | 294 | return $elements; |
295 | 295 | } |
296 | 296 | return null; |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | trait HtmlLinkTrait { |
6 | 6 | |
7 | - abstract public function setProperty($name,$value); |
|
7 | + abstract public function setProperty($name, $value); |
|
8 | 8 | abstract public function getProperty($name); |
9 | 9 | |
10 | 10 | public function setHref($value) { |
@@ -14,8 +14,8 @@ |
||
14 | 14 | */ |
15 | 15 | public function setAttachment($toElement, $side=Side::BOTH) { |
16 | 16 | if (isset($toElement)) { |
17 | - $toElement->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
17 | + $toElement->addToPropertyCtrl("class", "attached", array("attached")); |
|
18 | 18 | } |
19 | - return $this->addToPropertyCtrl("class", $side . " attached", Side::getConstantValues("attached")); |
|
19 | + return $this->addToPropertyCtrl("class", $side." attached", Side::getConstantValues("attached")); |
|
20 | 20 | } |
21 | 21 | } |
22 | 22 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | trait LabeledIconTrait { |
14 | 14 | |
15 | 15 | abstract public function addToProperty($name, $value, $separator=" "); |
16 | - abstract public function addContent($content,$before=false); |
|
16 | + abstract public function addContent($content, $before=false); |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Adds an icon before or after |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | * @param boolean $labeled |
23 | 23 | * @return \Ajax\semantic\html\elements\HtmlIcon |
24 | 24 | */ |
25 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
25 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
26 | 26 | $iconO=$icon; |
27 | - if(\is_string($icon)){ |
|
27 | + if (\is_string($icon)) { |
|
28 | 28 | $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
29 | 29 | } |
30 | - if($labeled!==false){ |
|
31 | - $direction=($before===true)?Direction::LEFT:Direction::RIGHT; |
|
30 | + if ($labeled!==false) { |
|
31 | + $direction=($before===true) ? Direction::LEFT : Direction::RIGHT; |
|
32 | 32 | $this->addToProperty("class", $direction." labeled icon"); |
33 | 33 | $this->tagName="div"; |
34 | 34 | } |
35 | - $this->addContent($iconO,$before); |
|
35 | + $this->addContent($iconO, $before); |
|
36 | 36 | return $iconO; |
37 | 37 | } |
38 | 38 | } |
39 | 39 | \ No newline at end of file |
@@ -14,89 +14,89 @@ |
||
14 | 14 | */ |
15 | 15 | class HtmlGridRow extends HtmlBsDoubleElement { |
16 | 16 | private $cols; |
17 | - public function __construct($identifier,$numCols=NULL){ |
|
18 | - parent::__construct($identifier,"div"); |
|
17 | + public function __construct($identifier, $numCols=NULL) { |
|
18 | + parent::__construct($identifier, "div"); |
|
19 | 19 | $this->setProperty("class", "row"); |
20 | 20 | $this->cols=array(); |
21 | - if(isset($numCols)){ |
|
22 | - $numCols=min(12,$numCols); |
|
23 | - $numCols=max(1,$numCols); |
|
21 | + if (isset($numCols)) { |
|
22 | + $numCols=min(12, $numCols); |
|
23 | + $numCols=max(1, $numCols); |
|
24 | 24 | $width=12/$numCols; |
25 | - for ($i=0;$i<$numCols;$i++){ |
|
26 | - $this->addCol(CssSize::SIZE_MD,$width); |
|
25 | + for ($i=0; $i<$numCols; $i++) { |
|
26 | + $this->addCol(CssSize::SIZE_MD, $width); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | - public function addCol($size=CssSize::SIZE_MD,$width=1){ |
|
32 | - $col=new HtmlGridCol($this->identifier."-col-".(sizeof($this->cols)+1),$size,$width); |
|
31 | + public function addCol($size=CssSize::SIZE_MD, $width=1) { |
|
32 | + $col=new HtmlGridCol($this->identifier."-col-".(sizeof($this->cols)+1), $size, $width); |
|
33 | 33 | $this->cols[]=$col; |
34 | 34 | return $col; |
35 | 35 | } |
36 | 36 | |
37 | - public function addColAt($size=CssSize::SIZE_MD,$width=1,$offset=1){ |
|
38 | - $col=$this->addCol($size,$width); |
|
39 | - return $col->setOffset($size, max($offset,sizeof($this->cols)+1)); |
|
37 | + public function addColAt($size=CssSize::SIZE_MD, $width=1, $offset=1) { |
|
38 | + $col=$this->addCol($size, $width); |
|
39 | + return $col->setOffset($size, max($offset, sizeof($this->cols)+1)); |
|
40 | 40 | } |
41 | 41 | |
42 | - public function getCol($index,$force=true){ |
|
42 | + public function getCol($index, $force=true) { |
|
43 | 43 | $result=null; |
44 | - if($index<sizeof($this->cols)+1){ |
|
44 | + if ($index<sizeof($this->cols)+1) { |
|
45 | 45 | $result=$this->cols[$index-1]; |
46 | - }else if ($force){ |
|
47 | - $result=$this->addColAt(CssSize::SIZE_MD,1,$index); |
|
46 | + } else if ($force) { |
|
47 | + $result=$this->addColAt(CssSize::SIZE_MD, 1, $index); |
|
48 | 48 | } |
49 | 49 | return $result; |
50 | 50 | } |
51 | 51 | |
52 | - public function getColAt($offset,$force=true){ |
|
52 | + public function getColAt($offset, $force=true) { |
|
53 | 53 | $result=null; |
54 | - foreach ($this->cols as $col){ |
|
54 | + foreach ($this->cols as $col) { |
|
55 | 55 | $offsets=$col->getOffsets(); |
56 | - if($result=array_search($offset, $offsets)){ |
|
56 | + if ($result=array_search($offset, $offsets)) { |
|
57 | 57 | break; |
58 | 58 | } |
59 | 59 | } |
60 | - if(!$result || isset($result)===false){ |
|
61 | - $result=$this->getCol($offset,$force); |
|
60 | + if (!$result || isset($result)===false) { |
|
61 | + $result=$this->getCol($offset, $force); |
|
62 | 62 | } |
63 | 63 | return $result; |
64 | 64 | } |
65 | 65 | |
66 | 66 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
67 | 67 | |
68 | - foreach ($this->cols as $col){ |
|
68 | + foreach ($this->cols as $col) { |
|
69 | 69 | $this->addContent($col); |
70 | 70 | } |
71 | - return parent::compile($js,$view); |
|
71 | + return parent::compile($js, $view); |
|
72 | 72 | } |
73 | 73 | public function getCols() { |
74 | 74 | return $this->cols; |
75 | 75 | } |
76 | 76 | |
77 | - public function setContentForAll($content){ |
|
78 | - foreach ($this->cols as $col){ |
|
77 | + public function setContentForAll($content) { |
|
78 | + foreach ($this->cols as $col) { |
|
79 | 79 | $col->setContent($content); |
80 | 80 | } |
81 | 81 | } |
82 | - public function merge($size=CssSize::SIZE_MD,$start,$width){ |
|
83 | - $col=$this->getColAt($start,false); |
|
84 | - if(isset($col)){ |
|
85 | - $col->setWidth($size,$width+1); |
|
86 | - $this->delete($size,$start+1, $width); |
|
82 | + public function merge($size=CssSize::SIZE_MD, $start, $width) { |
|
83 | + $col=$this->getColAt($start, false); |
|
84 | + if (isset($col)) { |
|
85 | + $col->setWidth($size, $width+1); |
|
86 | + $this->delete($size, $start+1, $width); |
|
87 | 87 | } |
88 | 88 | } |
89 | - public function delete($size=CssSize::SIZE_MD,$start,$width){ |
|
90 | - while($start<sizeof($this->cols)+1 && $width>0){ |
|
91 | - $col=$this->getColAt($start,false); |
|
92 | - if(isset($col)){ |
|
89 | + public function delete($size=CssSize::SIZE_MD, $start, $width) { |
|
90 | + while ($start<sizeof($this->cols)+1 && $width>0) { |
|
91 | + $col=$this->getColAt($start, false); |
|
92 | + if (isset($col)) { |
|
93 | 93 | $widthCol=$col->getWidth($size); |
94 | - if($widthCol<=$width){ |
|
94 | + if ($widthCol<=$width) { |
|
95 | 95 | unset($this->cols[$start-1]); |
96 | - $this->cols = array_values($this->cols); |
|
96 | + $this->cols=array_values($this->cols); |
|
97 | 97 | $width=$width-$widthCol; |
98 | 98 | } |
99 | - }else{ |
|
99 | + } else { |
|
100 | 100 | $width=0; |
101 | 101 | } |
102 | 102 | } |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | } |
19 | 19 | |
20 | 20 | public function setContent($content) { |
21 | - $this->content=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", new HtmlSemDoubleElement("", "div", "center", $content)); |
|
21 | + $this->content=new HtmlSemDoubleElement("content-".$this->identifier, "div", "content", new HtmlSemDoubleElement("", "div", "center", $content)); |
|
22 | 22 | return $this; |
23 | 23 | } |
24 | 24 | |
25 | 25 | public function asIcon($icon, $title, $subHeader=NULL) { |
26 | - $header=new HtmlHeader("header-" . $this->identifier); |
|
26 | + $header=new HtmlHeader("header-".$this->identifier); |
|
27 | 27 | $header->asIcon($icon, $title, $subHeader); |
28 | - if ($this->_inverted === false) |
|
28 | + if ($this->_inverted===false) |
|
29 | 29 | $header->setInverted(); |
30 | 30 | return $this->setContent($header); |
31 | 31 | } |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | |
43 | 43 | public function run(JsUtils $js) { |
44 | 44 | if ($this->_container instanceof HtmlSingleElement) |
45 | - $this->_bsComponent=$js->semantic()->dimmer("#" . $this->_container->getIdentifier(), $this->_params); |
|
45 | + $this->_bsComponent=$js->semantic()->dimmer("#".$this->_container->getIdentifier(), $this->_params); |
|
46 | 46 | return parent::run($js); |
47 | 47 | } |
48 | 48 | |
49 | 49 | public function jsShow() { |
50 | 50 | if (isset($this->_container)) |
51 | - return '$("#.' . $this->_container->getIdentifier() . ').dimmer("show");'; |
|
51 | + return '$("#.'.$this->_container->getIdentifier().').dimmer("show");'; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function setBlurring() { |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | use Ajax\semantic\html\base\constants\Direction; |
9 | 9 | |
10 | 10 | class HtmlSearch extends HtmlSemDoubleElement { |
11 | - private $_elements=array (); |
|
12 | - private $_searchFields=array ("title" ); |
|
11 | + private $_elements=array(); |
|
12 | + private $_searchFields=array("title"); |
|
13 | 13 | private $_local=false; |
14 | 14 | |
15 | 15 | public function __construct($identifier, $placeholder=NULL, $icon=NULL) { |
16 | - parent::__construct("search-" . $identifier, "div", "ui search", array ()); |
|
16 | + parent::__construct("search-".$identifier, "div", "ui search", array()); |
|
17 | 17 | $this->createField($placeholder, $icon); |
18 | 18 | $this->createResult(); |
19 | 19 | $this->_params["type"]="standard"; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | private function createResult() { |
35 | - $this->content["result"]=new HtmlSemDoubleElement("results-" . $this->identifier, "div", "results"); |
|
35 | + $this->content["result"]=new HtmlSemDoubleElement("results-".$this->identifier, "div", "results"); |
|
36 | 36 | return $this->content["result"]; |
37 | 37 | } |
38 | 38 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | public function setUrl($url) { |
52 | - $this->_params["apiSettings"]="%{url: %quote%" . $url . "%quote%}%"; |
|
52 | + $this->_params["apiSettings"]="%{url: %quote%".$url."%quote%}%"; |
|
53 | 53 | return $this; |
54 | 54 | } |
55 | 55 | |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | public function run(JsUtils $js) { |
75 | - $this->_params["onSelect"]='%function(result,response){$(%quote%#' . $this->identifier . '%quote%).trigger(%quote%onSelect%quote%, {%quote%result%quote%: result, %quote%response%quote%:response} );}%'; |
|
75 | + $this->_params["onSelect"]='%function(result,response){$(%quote%#'.$this->identifier.'%quote%).trigger(%quote%onSelect%quote%, {%quote%result%quote%: result, %quote%response%quote%:response} );}%'; |
|
76 | 76 | $searchFields=\json_encode($this->_searchFields); |
77 | 77 | $searchFields=str_ireplace("\"", "%quote%", $searchFields); |
78 | - $this->_params["searchFields"]="%" . $searchFields . "%"; |
|
79 | - if ($this->_local === true) { |
|
78 | + $this->_params["searchFields"]="%".$searchFields."%"; |
|
79 | + if ($this->_local===true) { |
|
80 | 80 | $this->_params["source"]="%content%"; |
81 | - $this->addEvent("beforeExecute", "var content=" . $this->resultsToJson() . ";"); |
|
81 | + $this->addEvent("beforeExecute", "var content=".$this->resultsToJson().";"); |
|
82 | 82 | } |
83 | - if (isset($this->_bsComponent) === false) { |
|
84 | - $this->_bsComponent=$js->semantic()->search("#" . $this->identifier, $this->_params); |
|
83 | + if (isset($this->_bsComponent)===false) { |
|
84 | + $this->_bsComponent=$js->semantic()->search("#".$this->identifier, $this->_params); |
|
85 | 85 | } |
86 | 86 | $this->addEventsOnRun($js); |
87 | 87 | return $this->_bsComponent; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
17 | 17 | |
18 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
18 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
19 | 19 | protected function addLoading(&$retour, $responseElement) { |
20 | 20 | $loading_notifier='<div class="ajax-loader">'; |
21 | 21 | if ($this->ajaxLoader=='') { |
@@ -28,20 +28,20 @@ discard block |
||
28 | 28 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
29 | 29 | } |
30 | 30 | |
31 | - public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
32 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
31 | + public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
32 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
33 | 33 | } |
34 | - public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
35 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
34 | + public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
35 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
36 | 36 | } |
37 | 37 | |
38 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
39 | - if(JString::isNull($params)){$params="{}";} |
|
38 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
39 | + if (JString::isNull($params)) {$params="{}"; } |
|
40 | 40 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
41 | 41 | $retour=$this->_getAjaxUrl($url, $attr); |
42 | 42 | $responseElement=$this->_getResponseElement($responseElement); |
43 | 43 | $retour.="var self=this;\n"; |
44 | - if($hasLoader===true){ |
|
44 | + if ($hasLoader===true) { |
|
45 | 45 | $this->addLoading($retour, $responseElement); |
46 | 46 | } |
47 | 47 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
@@ -51,30 +51,30 @@ discard block |
||
51 | 51 | return $retour; |
52 | 52 | } |
53 | 53 | |
54 | - protected function _getAjaxUrl($url,$attr){ |
|
54 | + protected function _getAjaxUrl($url, $attr) { |
|
55 | 55 | $url=$this->_correctAjaxUrl($url); |
56 | 56 | $retour="url='".$url."';\n"; |
57 | 57 | $slash="/"; |
58 | - if(JString::endswith($url, "/")===true) |
|
58 | + if (JString::endswith($url, "/")===true) |
|
59 | 59 | $slash=""; |
60 | - if(JString::isNotNull($attr)){ |
|
60 | + if (JString::isNotNull($attr)) { |
|
61 | 61 | if ($attr==="value") |
62 | 62 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
63 | 63 | elseif ($attr==="html") |
64 | 64 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
65 | - elseif($attr!=null && $attr!=="") |
|
65 | + elseif ($attr!=null && $attr!=="") |
|
66 | 66 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
67 | 67 | } |
68 | 68 | return $retour; |
69 | 69 | } |
70 | 70 | |
71 | - protected function _getOnAjaxDone($responseElement,$jsCallback){ |
|
71 | + protected function _getOnAjaxDone($responseElement, $jsCallback) { |
|
72 | 72 | $retour=""; |
73 | 73 | if ($responseElement!=="") { |
74 | - if(JString::startswith($responseElement, "\"-")===true){ |
|
74 | + if (JString::startswith($responseElement, "\"-")===true) { |
|
75 | 75 | $responseElement=\str_replace("\"-", "\"", $responseElement); |
76 | 76 | $retour="\t$({$responseElement}).replaceWith( data );\n"; |
77 | - }else{ |
|
77 | + } else { |
|
78 | 78 | $retour="\t$({$responseElement}).html( data );\n"; |
79 | 79 | } |
80 | 80 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | return $retour; |
83 | 83 | } |
84 | 84 | |
85 | - protected function _getResponseElement($responseElement){ |
|
85 | + protected function _getResponseElement($responseElement) { |
|
86 | 86 | if ($responseElement!=="") { |
87 | 87 | $responseElement=Javascript::prep_value($responseElement); |
88 | 88 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | protected function _correctAjaxUrl($url) { |
93 | 93 | if ($url!=="/" && JString::endsWith($url, "/")===true) |
94 | 94 | $url=substr($url, 0, strlen($url)-1); |
95 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
95 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
96 | 96 | $url=$this->jsUtils->getUrl($url); |
97 | 97 | } |
98 | 98 | return $url; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param string $jsCallback javascript code to execute after the request |
107 | 107 | * @param boolean $immediatly |
108 | 108 | */ |
109 | - public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
109 | + public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
110 | 110 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
111 | 111 | $retour=$this->_getAjaxUrl($url, $attr); |
112 | 112 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @param string $url the request address |
128 | 128 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
129 | 129 | */ |
130 | - public function _jsonOn($event,$element, $url,$parameters=array()) { |
|
130 | + public function _jsonOn($event, $element, $url, $parameters=array()) { |
|
131 | 131 | $preventDefault=true; |
132 | 132 | $stopPropagation=true; |
133 | 133 | $jsCallback=null; |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | $params="{}"; |
138 | 138 | $immediatly=true; |
139 | 139 | extract($parameters); |
140 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
140 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -149,19 +149,19 @@ discard block |
||
149 | 149 | * @param string $context jquery DOM element, array container. |
150 | 150 | * @param boolean $immediatly |
151 | 151 | */ |
152 | - public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$immediatly=false) { |
|
152 | + public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $immediatly=false) { |
|
153 | 153 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
154 | 154 | $retour=$this->_getAjaxUrl($url, $attr); |
155 | - if($context===null){ |
|
155 | + if ($context===null) { |
|
156 | 156 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
157 | - $newElm = "$('#'+newId)"; |
|
158 | - }else{ |
|
157 | + $newElm="$('#'+newId)"; |
|
158 | + } else { |
|
159 | 159 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
160 | - $newElm = $context.".find('#'+newId)"; |
|
160 | + $newElm=$context.".find('#'+newId)"; |
|
161 | 161 | } |
162 | 162 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
163 | 163 | $retour.="\tdata=$.parseJSON(data);$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone();newElm.attr('id',newId);\n"; |
164 | - $retour.= $appendTo; |
|
164 | + $retour.=$appendTo; |
|
165 | 165 | $retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('[['+key+']]')>-1){\n"."\t\t\t\tcontent=$(html.split('[['+key+']]').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n"; |
166 | 166 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
167 | 167 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -176,26 +176,26 @@ discard block |
||
176 | 176 | * @param string $url the request address |
177 | 177 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null) |
178 | 178 | */ |
179 | - public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) { |
|
179 | + public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
180 | 180 | $preventDefault=true; |
181 | 181 | $stopPropagation=true; |
182 | 182 | $jsCallback=null; |
183 | 183 | $attr="id"; |
184 | 184 | $method="get"; |
185 | - $context = null; |
|
185 | + $context=null; |
|
186 | 186 | $params="{}"; |
187 | 187 | $immediatly=true; |
188 | 188 | extract($parameters); |
189 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
189 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
190 | 190 | } |
191 | 191 | |
192 | - public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
192 | + public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
193 | 193 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
194 | 194 | $retour=$this->_getAjaxUrl($url, $attr); |
195 | 195 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
196 | 196 | $responseElement=$this->_getResponseElement($responseElement); |
197 | 197 | $retour.="var self=this;\n"; |
198 | - if($hasLoader===true){ |
|
198 | + if ($hasLoader===true) { |
|
199 | 199 | $this->addLoading($retour, $responseElement); |
200 | 200 | } |
201 | 201 | $retour.="$.post(url,params).done(function( data ) {\n"; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @param string $responseElement |
223 | 223 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
224 | 224 | */ |
225 | - public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
225 | + public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
226 | 226 | $preventDefault=true; |
227 | 227 | $stopPropagation=true; |
228 | 228 | $jsCallback=null; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $hasLoader=true; |
231 | 231 | $immediatly=true; |
232 | 232 | extract($parameters); |
233 | - return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
233 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @param string $responseElement |
244 | 244 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
245 | 245 | */ |
246 | - public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
246 | + public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
247 | 247 | $preventDefault=true; |
248 | 248 | $stopPropagation=true; |
249 | 249 | $jsCallback=null; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $hasLoader=true; |
252 | 252 | $immediatly=true; |
253 | 253 | extract($parameters); |
254 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
254 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @param string $responseElement |
265 | 265 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true) |
266 | 266 | */ |
267 | - public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
267 | + public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
268 | 268 | $preventDefault=true; |
269 | 269 | $stopPropagation=true; |
270 | 270 | $validation=false; |
@@ -273,6 +273,6 @@ discard block |
||
273 | 273 | $hasLoader=true; |
274 | 274 | $immediatly=true; |
275 | 275 | extract($parameters); |
276 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
276 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | \ No newline at end of file |