@@ -24,9 +24,9 @@ discard block |
||
| 24 | 24 | foreach ( $this->events as $event => $jsCode ) { |
| 25 | 25 | if($event=="execute"){ |
| 26 | 26 | $this->jquery_code_for_compile []=$jsCode; |
| 27 | - }else if($event=="beforeExecute"){ |
|
| 27 | + } else if($event=="beforeExecute"){ |
|
| 28 | 28 | \array_unshift($this->jquery_code_for_compile, $jsCode); |
| 29 | - }else{ |
|
| 29 | + } else{ |
|
| 30 | 30 | $selector=$this->attachTo; |
| 31 | 31 | if(isset($this->itemSelector)){ |
| 32 | 32 | $selector.=" ".$this->itemSelector; |
@@ -75,8 +75,9 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | protected function setParamCtrl($key, $value, $typeCtrl) { |
| 77 | 77 | if (is_array($typeCtrl)) { |
| 78 | - if (array_search($value, $typeCtrl)===false) |
|
| 79 | - throw new \Exception("La valeur passée a propriété `".$key."` pour le composant `".$this->uiName."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
| 78 | + if (array_search($value, $typeCtrl)===false) { |
|
| 79 | + throw new \Exception("La valeur passée a propriété `".$key."` pour le composant `".$this->uiName."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
| 80 | + } |
|
| 80 | 81 | } else { |
| 81 | 82 | if (!$typeCtrl($value)) { |
| 82 | 83 | throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key." au composant ".$this->uiName); |
@@ -46,8 +46,9 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
| 48 | 48 | $retour.=$this->_getOnAjaxDone($responseElement, $jsCallback)."});\n"; |
| 49 | - if ($immediatly) |
|
| 50 | - $this->jquery_code_for_compile[]=$retour; |
|
| 49 | + if ($immediatly) { |
|
| 50 | + $this->jquery_code_for_compile[]=$retour; |
|
| 51 | + } |
|
| 51 | 52 | return $retour; |
| 52 | 53 | } |
| 53 | 54 | |
@@ -55,15 +56,17 @@ discard block |
||
| 55 | 56 | $url=$this->_correctAjaxUrl($url); |
| 56 | 57 | $retour="url='".$url."';\n"; |
| 57 | 58 | $slash="/"; |
| 58 | - if(JString::endswith($url, "/")===true) |
|
| 59 | - $slash=""; |
|
| 59 | + if(JString::endswith($url, "/")===true) { |
|
| 60 | + $slash=""; |
|
| 61 | + } |
|
| 60 | 62 | if(JString::isNotNull($attr)){ |
| 61 | - if ($attr==="value") |
|
| 62 | - $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 63 | - elseif ($attr==="html") |
|
| 64 | - $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
| 65 | - elseif($attr!=null && $attr!=="") |
|
| 66 | - $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 63 | + if ($attr==="value") { |
|
| 64 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 65 | + } elseif ($attr==="html") { |
|
| 66 | + $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
| 67 | + } elseif($attr!=null && $attr!=="") { |
|
| 68 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 69 | + } |
|
| 67 | 70 | } |
| 68 | 71 | return $retour; |
| 69 | 72 | } |
@@ -74,7 +77,7 @@ discard block |
||
| 74 | 77 | if(JString::startswith($responseElement, "\"-")===true){ |
| 75 | 78 | $responseElement=\str_replace("\"-", "\"", $responseElement); |
| 76 | 79 | $retour="\t$({$responseElement}).replaceWith( data );\n"; |
| 77 | - }else{ |
|
| 80 | + } else{ |
|
| 78 | 81 | $retour="\t$({$responseElement}).html( data );\n"; |
| 79 | 82 | } |
| 80 | 83 | } |
@@ -90,8 +93,9 @@ discard block |
||
| 90 | 93 | } |
| 91 | 94 | |
| 92 | 95 | protected function _correctAjaxUrl($url) { |
| 93 | - if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
| 94 | - $url=substr($url, 0, strlen($url)-1); |
|
| 96 | + if ($url!=="/" && JString::endsWith($url, "/")===true) { |
|
| 97 | + $url=substr($url, 0, strlen($url)-1); |
|
| 98 | + } |
|
| 95 | 99 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
| 96 | 100 | $url=$this->jsUtils->getUrl($url); |
| 97 | 101 | } |
@@ -115,8 +119,9 @@ discard block |
||
| 115 | 119 | $retour.="\t".$jsCallback."\n". |
| 116 | 120 | "\t$(document).trigger('jsonReady',[data]);\n". |
| 117 | 121 | "});\n"; |
| 118 | - if ($immediatly) |
|
| 119 | - $this->jquery_code_for_compile[]=$retour; |
|
| 122 | + if ($immediatly) { |
|
| 123 | + $this->jquery_code_for_compile[]=$retour; |
|
| 124 | + } |
|
| 120 | 125 | return $retour; |
| 121 | 126 | } |
| 122 | 127 | |
@@ -155,7 +160,7 @@ discard block |
||
| 155 | 160 | if($context===null){ |
| 156 | 161 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
| 157 | 162 | $newElm = "$('#'+newId)"; |
| 158 | - }else{ |
|
| 163 | + } else{ |
|
| 159 | 164 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
| 160 | 165 | $newElm = $context.".find('#'+newId)"; |
| 161 | 166 | } |
@@ -165,8 +170,9 @@ discard block |
||
| 165 | 170 | $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 | 171 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 167 | 172 | $retour.="\t".$jsCallback."\n"."});\n"; |
| 168 | - if ($immediatly) |
|
| 169 | - $this->jquery_code_for_compile[]=$retour; |
|
| 173 | + if ($immediatly) { |
|
| 174 | + $this->jquery_code_for_compile[]=$retour; |
|
| 175 | + } |
|
| 170 | 176 | return $retour; |
| 171 | 177 | } |
| 172 | 178 | /** |
@@ -207,8 +213,9 @@ discard block |
||
| 207 | 213 | }});\n"; |
| 208 | 214 | $retour.="$('#".$form."').submit();\n"; |
| 209 | 215 | } |
| 210 | - if ($immediatly) |
|
| 211 | - $this->jquery_code_for_compile[]=$retour; |
|
| 216 | + if ($immediatly) { |
|
| 217 | + $this->jquery_code_for_compile[]=$retour; |
|
| 218 | + } |
|
| 212 | 219 | return $retour; |
| 213 | 220 | } |
| 214 | 221 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | if(isset($this->_toolbar) && isset($this->_compileParts)===false){ |
| 45 | 45 | if($this->_toolbarPosition===PositionInTable::BEFORETABLE){ |
| 46 | 46 | $this->content["before"]=$this->_toolbar; |
| 47 | - }elseif($this->_toolbarPosition===PositionInTable::BEFORETABLE){ |
|
| 47 | + } elseif($this->_toolbarPosition===PositionInTable::BEFORETABLE){ |
|
| 48 | 48 | $this->content["after"]=$this->_toolbar; |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -63,11 +63,13 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | $table->setRowCount(0, \sizeof($captions)); |
| 65 | 65 | $table->setHeaderValues($captions); |
| 66 | - if(isset($this->_compileParts)) |
|
| 67 | - $table->setCompileParts($this->_compileParts); |
|
| 66 | + if(isset($this->_compileParts)) { |
|
| 67 | + $table->setCompileParts($this->_compileParts); |
|
| 68 | + } |
|
| 68 | 69 | if(isset($this->_searchField)){ |
| 69 | - if(isset($js)) |
|
| 70 | - $this->_searchField->postOn("change", $this->_searchUrl,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
|
| 70 | + if(isset($js)) { |
|
| 71 | + $this->_searchField->postOn("change", $this->_searchUrl,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
|
| 72 | + } |
|
| 71 | 73 | } |
| 72 | 74 | |
| 73 | 75 | $objects=$this->_modelInstance; |
@@ -88,8 +90,9 @@ discard block |
||
| 88 | 90 | return $result; |
| 89 | 91 | }); |
| 90 | 92 | if($this->_hasCheckboxes){ |
| 91 | - if($table->hasPart("thead")) |
|
| 92 | - $table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort"); |
|
| 93 | + if($table->hasPart("thead")) { |
|
| 94 | + $table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort"); |
|
| 95 | + } |
|
| 93 | 96 | } |
| 94 | 97 | |
| 95 | 98 | if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
@@ -102,9 +105,9 @@ discard block |
||
| 102 | 105 | $menu->postOnClick($this->_searchUrl,"{'p':$(this).attr('data-page')}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
| 103 | 106 | } |
| 104 | 107 | if(isset($this->_toolbar)){ |
| 105 | - if($this->_toolbarPosition===PositionInTable::FOOTER) |
|
| 106 | - $this->addToolbarRow("tfoot",$table, $captions); |
|
| 107 | - elseif($this->_toolbarPosition===PositionInTable::HEADER){ |
|
| 108 | + if($this->_toolbarPosition===PositionInTable::FOOTER) { |
|
| 109 | + $this->addToolbarRow("tfoot",$table, $captions); |
|
| 110 | + } elseif($this->_toolbarPosition===PositionInTable::HEADER){ |
|
| 108 | 111 | $this->addToolbarRow("thead",$table, $captions); |
| 109 | 112 | } |
| 110 | 113 | } |
@@ -278,8 +281,9 @@ discard block |
||
| 278 | 281 | private function getDefaultButton($icon,$class=null){ |
| 279 | 282 | $bt=$this->getFieldButton(""); |
| 280 | 283 | $bt->asIcon($icon); |
| 281 | - if(isset($class)) |
|
| 282 | - $bt->addToProperty("class", $class); |
|
| 284 | + if(isset($class)) { |
|
| 285 | + $bt->addToProperty("class", $class); |
|
| 286 | + } |
|
| 283 | 287 | return $bt; |
| 284 | 288 | } |
| 285 | 289 | |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | public function __construct($instance=NULL,$captions=NULL){ |
| 15 | 15 | $this->values=[]; |
| 16 | - if(isset($instance)) |
|
| 17 | - $this->setInstance($instance); |
|
| 16 | + if(isset($instance)) { |
|
| 17 | + $this->setInstance($instance); |
|
| 18 | + } |
|
| 18 | 19 | $this->setCaptions($captions); |
| 19 | 20 | } |
| 20 | 21 | |
@@ -51,8 +52,9 @@ discard block |
||
| 51 | 52 | |
| 52 | 53 | public function getCkValue(){ |
| 53 | 54 | $value=self::$index; |
| 54 | - if(isset($this->values["ck"])) |
|
| 55 | - $value=$this->values["ck"](self::$index,$this->instance); |
|
| 55 | + if(isset($this->values["ck"])) { |
|
| 56 | + $value=$this->values["ck"](self::$index,$this->instance); |
|
| 57 | + } |
|
| 56 | 58 | self::$index++; |
| 57 | 59 | return $value; |
| 58 | 60 | } |
@@ -69,14 +71,15 @@ discard block |
||
| 69 | 71 | if(isset($this->values[$index])){ |
| 70 | 72 | $value= $this->values[$index]($value); |
| 71 | 73 | } |
| 72 | - }else{ |
|
| 73 | - if(\is_callable($property)) |
|
| 74 | - $value=$property($this->instance); |
|
| 75 | - elseif(\is_array($property)){ |
|
| 74 | + } else{ |
|
| 75 | + if(\is_callable($property)) { |
|
| 76 | + $value=$property($this->instance); |
|
| 77 | + } elseif(\is_array($property)){ |
|
| 76 | 78 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
| 77 | 79 | $value=\implode("", $values); |
| 78 | - }else |
|
| 79 | - $value=$property; |
|
| 80 | + } else { |
|
| 81 | + $value=$property; |
|
| 82 | + } |
|
| 80 | 83 | } |
| 81 | 84 | return $value; |
| 82 | 85 | } |
@@ -91,10 +94,10 @@ discard block |
||
| 91 | 94 | if(isset($vb[$index])){ |
| 92 | 95 | if(\is_array($vb[$index])){ |
| 93 | 96 | $this->visibleProperties[$index][]=$field; |
| 94 | - }else{ |
|
| 97 | + } else{ |
|
| 95 | 98 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
| 96 | 99 | } |
| 97 | - }else{ |
|
| 100 | + } else{ |
|
| 98 | 101 | return $this->insertField($index, $field); |
| 99 | 102 | } |
| 100 | 103 | return $this; |
@@ -122,24 +125,25 @@ discard block |
||
| 122 | 125 | $this->reflect=new \ReflectionClass($instance); |
| 123 | 126 | if(\sizeof($this->visibleProperties)===0){ |
| 124 | 127 | $this->properties=$this->getDefaultProperties(); |
| 125 | - }else{ |
|
| 128 | + } else{ |
|
| 126 | 129 | foreach ($this->visibleProperties as $property){ |
| 127 | 130 | if(\is_callable($property)){ |
| 128 | 131 | $this->properties[]=$property; |
| 129 | - }elseif(\is_string($property)){ |
|
| 132 | + } elseif(\is_string($property)){ |
|
| 130 | 133 | try{ |
| 131 | 134 | $rProperty=$this->reflect->getProperty($property); |
| 132 | 135 | $this->properties[]=$rProperty; |
| 133 | - }catch(\Exception $e){ |
|
| 136 | + } catch(\Exception $e){ |
|
| 134 | 137 | $this->properties[]=$property; |
| 135 | 138 | } |
| 136 | - }elseif(\is_int($property)){ |
|
| 139 | + } elseif(\is_int($property)){ |
|
| 137 | 140 | $props=$this->getDefaultProperties(); |
| 138 | - if(isset($props[$property])) |
|
| 139 | - $this->properties[]=$props[$property]; |
|
| 140 | - else |
|
| 141 | - $this->properties[]=$property; |
|
| 142 | - }else{ |
|
| 141 | + if(isset($props[$property])) { |
|
| 142 | + $this->properties[]=$props[$property]; |
|
| 143 | + } else { |
|
| 144 | + $this->properties[]=$property; |
|
| 145 | + } |
|
| 146 | + } else{ |
|
| 143 | 147 | $this->properties[]=$property; |
| 144 | 148 | } |
| 145 | 149 | } |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | private function afterInsert($item) { |
| 61 | - if (!$item instanceof HtmlMenu && $item->propertyContains("class", "header")===false) |
|
| 62 | - $item->addToPropertyCtrl("class", "item", array ("item" )); |
|
| 63 | - else { |
|
| 61 | + if (!$item instanceof HtmlMenu && $item->propertyContains("class", "header")===false) { |
|
| 62 | + $item->addToPropertyCtrl("class", "item", array ("item" )); |
|
| 63 | + } else { |
|
| 64 | 64 | $this->setSecondary(); |
| 65 | 65 | } |
| 66 | 66 | return $item; |
@@ -75,8 +75,9 @@ discard block |
||
| 75 | 75 | public function addItem($item) { |
| 76 | 76 | $number=$item; |
| 77 | 77 | $item=parent::addItem($this->getItemToInsert($item)); |
| 78 | - if(\is_int($number)) |
|
| 79 | - $item->setProperty("data-page", $number); |
|
| 78 | + if(\is_int($number)) { |
|
| 79 | + $item->setProperty("data-page", $number); |
|
| 80 | + } |
|
| 80 | 81 | return $this->afterInsert($item); |
| 81 | 82 | } |
| 82 | 83 | |
@@ -149,10 +150,11 @@ discard block |
||
| 149 | 150 | } |
| 150 | 151 | |
| 151 | 152 | public function setSecondary($value=true) { |
| 152 | - if($value) |
|
| 153 | - $this->addToProperty("class", "secondary"); |
|
| 154 | - else |
|
| 155 | - $this->removePropertyValue("class", "secondary"); |
|
| 153 | + if($value) { |
|
| 154 | + $this->addToProperty("class", "secondary"); |
|
| 155 | + } else { |
|
| 156 | + $this->removePropertyValue("class", "secondary"); |
|
| 157 | + } |
|
| 156 | 158 | return $this; |
| 157 | 159 | } |
| 158 | 160 | |
@@ -172,8 +174,9 @@ discard block |
||
| 172 | 174 | $this->apply(function (HtmlDoubleElement &$item) { |
| 173 | 175 | $item->setTagName("a"); |
| 174 | 176 | }); |
| 175 | - if ($vertical === true) |
|
| 176 | - $this->setVertical(); |
|
| 177 | + if ($vertical === true) { |
|
| 178 | + $this->setVertical(); |
|
| 179 | + } |
|
| 177 | 180 | return $this->addToProperty("class", "tabular"); |
| 178 | 181 | } |
| 179 | 182 | |
@@ -202,10 +205,11 @@ discard block |
||
| 202 | 205 | */ |
| 203 | 206 | public function fromDatabaseObject($object, $function) { |
| 204 | 207 | $return=$function($object); |
| 205 | - if (\is_array($return)) |
|
| 206 | - $this->addItems($return); |
|
| 207 | - else |
|
| 208 | - $this->addItem($return); |
|
| 208 | + if (\is_array($return)) { |
|
| 209 | + $this->addItems($return); |
|
| 210 | + } else { |
|
| 211 | + $this->addItem($return); |
|
| 212 | + } |
|
| 209 | 213 | } |
| 210 | 214 | |
| 211 | 215 | /** |
@@ -194,8 +194,9 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | public function setBasic($very=false) { |
| 197 | - if ($very) |
|
| 198 | - $this->addToPropertyCtrl("class", "very", array ("very" )); |
|
| 197 | + if ($very) { |
|
| 198 | + $this->addToPropertyCtrl("class", "very", array ("very" )); |
|
| 199 | + } |
|
| 199 | 200 | return $this->addToPropertyCtrl("class", "basic", array ("basic" )); |
| 200 | 201 | } |
| 201 | 202 | |
@@ -260,7 +261,7 @@ discard block |
||
| 260 | 261 | if(\sizeof($this->_compileParts)<3){ |
| 261 | 262 | $this->_template="%content%"; |
| 262 | 263 | $this->refresh(); |
| 263 | - }else{ |
|
| 264 | + } else{ |
|
| 264 | 265 | if ($this->propertyContains("class", "sortable")) { |
| 265 | 266 | $this->addEvent("execute", "$('#" . $this->identifier . "').tablesort();"); |
| 266 | 267 | } |
@@ -300,8 +301,9 @@ discard block |
||
| 300 | 301 | |
| 301 | 302 | public function run(JsUtils $js){ |
| 302 | 303 | $result= parent::run($js); |
| 303 | - if(isset($this->_footer)) |
|
| 304 | - $this->_footer->run($js); |
|
| 304 | + if(isset($this->_footer)) { |
|
| 305 | + $this->_footer->run($js); |
|
| 306 | + } |
|
| 305 | 307 | return $result; |
| 306 | 308 | } |
| 307 | 309 | |
@@ -11,14 +11,15 @@ discard block |
||
| 11 | 11 | public function setContent($content){ |
| 12 | 12 | if($content==="-"){ |
| 13 | 13 | $this->asDivider(); |
| 14 | - }elseif($content==="-search-"){ |
|
| 14 | + } elseif($content==="-search-"){ |
|
| 15 | 15 | $values=\explode(",",$content,-1); |
| 16 | 16 | $this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."),JArray::getDefaultValue($values, 1, "search")); |
| 17 | - }elseif(JString::startswith($content, "-")){ |
|
| 17 | + } elseif(JString::startswith($content, "-")){ |
|
| 18 | 18 | $content=\ltrim($content,"-"); |
| 19 | 19 | $this->asHeader($content); |
| 20 | - }else |
|
| 21 | - parent::setContent($content); |
|
| 20 | + } else { |
|
| 21 | + parent::setContent($content); |
|
| 22 | + } |
|
| 22 | 23 | return $this; |
| 23 | 24 | } |
| 24 | 25 | |
@@ -30,11 +31,13 @@ discard block |
||
| 30 | 31 | public function asSearchInput($placeholder=NULL,$icon=NULL){ |
| 31 | 32 | $this->setClass("ui icon search input"); |
| 32 | 33 | $input=new HtmlInput("search-".$this->identifier); |
| 33 | - if(isset($placeholder)) |
|
| 34 | - $input->setProperty("placeholder", $placeholder); |
|
| 34 | + if(isset($placeholder)) { |
|
| 35 | + $input->setProperty("placeholder", $placeholder); |
|
| 36 | + } |
|
| 35 | 37 | $this->content=$input; |
| 36 | - if(isset($icon)) |
|
| 37 | - $this->addIcon($icon); |
|
| 38 | + if(isset($icon)) { |
|
| 39 | + $this->addIcon($icon); |
|
| 40 | + } |
|
| 38 | 41 | return $this; |
| 39 | 42 | } |
| 40 | 43 | |
@@ -57,8 +60,9 @@ discard block |
||
| 57 | 60 | $this->setClass("header"); |
| 58 | 61 | $this->tagName="div"; |
| 59 | 62 | $this->content=$caption; |
| 60 | - if(isset($icon)) |
|
| 61 | - $this->addIcon($icon,Direction::LEFT); |
|
| 63 | + if(isset($icon)) { |
|
| 64 | + $this->addIcon($icon,Direction::LEFT); |
|
| 65 | + } |
|
| 62 | 66 | return $this; |
| 63 | 67 | } |
| 64 | 68 | |