@@ -123,8 +123,9 @@ |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | public function run(JsUtils $js){ |
| 126 | - if(JString::isNotNull($this->_identifier)) |
|
| 127 | - $js->execOn("click", "#".$this->_identifier." .ui.toggle", 'var active=$(this).hasClass("active");$(this).children("i").toggleClass("up",active).toggleClass("down",!active);var nextTd=$(this).closest("td").next("td");nextTd.children(":not(.toggle-caption)").toggle(active);nextTd.children(".toggle-caption").toggle(!active);$(this).trigger({type:"toggled",active: active,caption: nextTd.children(".toggle-caption")});'); |
|
| 126 | + if(JString::isNotNull($this->_identifier)) { |
|
| 127 | + $js->execOn("click", "#".$this->_identifier." .ui.toggle", 'var active=$(this).hasClass("active");$(this).children("i").toggleClass("up",active).toggleClass("down",!active);var nextTd=$(this).closest("td").next("td");nextTd.children(":not(.toggle-caption)").toggle(active);nextTd.children(".toggle-caption").toggle(!active);$(this).trigger({type:"toggled",active: active,caption: nextTd.children(".toggle-caption")});'); |
|
| 128 | + } |
|
| 128 | 129 | parent::run($js); |
| 129 | 130 | } |
| 130 | 131 | } |
@@ -16,8 +16,9 @@ discard block |
||
| 16 | 16 | * @param mixed $view |
| 17 | 17 | */ |
| 18 | 18 | protected function _compileLibrary(BaseGui $library, &$view=NULL){ |
| 19 | - if(isset($view)) |
|
| 20 | - $library->compileHtml($this, $view); |
|
| 19 | + if(isset($view)) { |
|
| 20 | + $library->compileHtml($this, $view); |
|
| 21 | + } |
|
| 21 | 22 | if ($library->isAutoCompile()) { |
| 22 | 23 | $library->compile(true); |
| 23 | 24 | } |
@@ -36,7 +37,9 @@ discard block |
||
| 36 | 37 | } |
| 37 | 38 | |
| 38 | 39 | protected function minify($input) { |
| 39 | - if(trim($input) === "") return $input; |
|
| 40 | + if(trim($input) === "") { |
|
| 41 | + return $input; |
|
| 42 | + } |
|
| 40 | 43 | $input= preg_replace( |
| 41 | 44 | array( |
| 42 | 45 | // Remove comment(s) |
@@ -109,15 +109,18 @@ discard block |
||
| 109 | 109 | $flag=false; |
| 110 | 110 | $index=0; |
| 111 | 111 | while ( !$flag && $index < sizeof($elements) ) { |
| 112 | - if ($elements[$index] instanceof BaseHtml) |
|
| 113 | - $flag=($callback($elements[$index])); |
|
| 112 | + if ($elements[$index] instanceof BaseHtml) { |
|
| 113 | + $flag=($callback($elements[$index])); |
|
| 114 | + } |
|
| 114 | 115 | $index++; |
| 115 | 116 | } |
| 116 | - if ($flag === true) |
|
| 117 | - return $elements[$index - 1]; |
|
| 117 | + if ($flag === true) { |
|
| 118 | + return $elements[$index - 1]; |
|
| 119 | + } |
|
| 118 | 120 | } elseif ($elements instanceof BaseHtml) { |
| 119 | - if ($callback($elements)) |
|
| 120 | - return $elements; |
|
| 121 | + if ($callback($elements)) { |
|
| 122 | + return $elements; |
|
| 123 | + } |
|
| 121 | 124 | } |
| 122 | 125 | return null; |
| 123 | 126 | } |
@@ -143,8 +146,9 @@ discard block |
||
| 143 | 146 | |
| 144 | 147 | public function fromArray($array) { |
| 145 | 148 | foreach ( $this as $key => $value ) { |
| 146 | - if(array_key_exists($key, $array)===true) |
|
| 147 | - $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
| 149 | + if(array_key_exists($key, $array)===true) { |
|
| 150 | + $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
| 151 | + } |
|
| 148 | 152 | } |
| 149 | 153 | foreach ( $array as $key => $value ) { |
| 150 | 154 | if($this->_callSetter($key, $key, $value, $array)===false){ |
@@ -213,11 +217,11 @@ discard block |
||
| 213 | 217 | if(\strstr($result, "%{$key}%")!==false){ |
| 214 | 218 | if (\is_array($value)) { |
| 215 | 219 | $v=PropertyWrapper::wrap($value, $js,$view); |
| 216 | - }elseif($value instanceof \stdClass){ |
|
| 220 | + } elseif($value instanceof \stdClass){ |
|
| 217 | 221 | $v=\print_r($value,true); |
| 218 | - }elseif ($value instanceof BaseHtml){ |
|
| 222 | + } elseif ($value instanceof BaseHtml){ |
|
| 219 | 223 | $v=$value->compile($js,$view); |
| 220 | - }else{ |
|
| 224 | + } else{ |
|
| 221 | 225 | $v=$value; |
| 222 | 226 | } |
| 223 | 227 | $result=str_replace("%{$key}%", $v, $result); |
@@ -345,8 +345,9 @@ discard block |
||
| 345 | 345 | $result= $this->getBody()->_addRow($result); |
| 346 | 346 | } |
| 347 | 347 | if(isset($this->_afterCompileEvents["onNewRow"])){ |
| 348 | - if(\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
| 349 | - $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
| 348 | + if(\is_callable($this->_afterCompileEvents["onNewRow"])) { |
|
| 349 | + $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
| 350 | + } |
|
| 350 | 351 | } |
| 351 | 352 | return $result; |
| 352 | 353 | } |
@@ -375,8 +376,9 @@ discard block |
||
| 375 | 376 | } |
| 376 | 377 | } |
| 377 | 378 | $result= parent::run($js); |
| 378 | - if(isset($this->_footer)) |
|
| 379 | - $this->_footer->run($js); |
|
| 379 | + if(isset($this->_footer)) { |
|
| 380 | + $this->_footer->run($js); |
|
| 381 | + } |
|
| 380 | 382 | $this->_runned=true; |
| 381 | 383 | return $result; |
| 382 | 384 | } |
@@ -417,8 +419,9 @@ discard block |
||
| 417 | 419 | |
| 418 | 420 | public function setColWidth($colIndex,$width){ |
| 419 | 421 | $part=$this->_getFirstPart(); |
| 420 | - if($part!==null && $part->count()>0) |
|
| 421 | - $part->getCell(0, $colIndex)->setWidth($width); |
|
| 422 | + if($part!==null && $part->count()>0) { |
|
| 423 | + $part->getCell(0, $colIndex)->setWidth($width); |
|
| 424 | + } |
|
| 422 | 425 | return $this; |
| 423 | 426 | } |
| 424 | 427 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | foreach ($items as $k=>$v){ |
| 25 | 25 | $this->addItem([$k,$v]); |
| 26 | 26 | } |
| 27 | - }else{ |
|
| 27 | + } else{ |
|
| 28 | 28 | foreach ($items as $item){ |
| 29 | 29 | $this->addItem($item); |
| 30 | 30 | } |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | * @return \Ajax\common\html\HtmlDoubleElement |
| 81 | 81 | */ |
| 82 | 82 | public function getItem($index) { |
| 83 | - if (is_int($index)&& isset($this->content[$index])) |
|
| 84 | - return $this->content[$index]; |
|
| 85 | - else { |
|
| 83 | + if (is_int($index)&& isset($this->content[$index])) { |
|
| 84 | + return $this->content[$index]; |
|
| 85 | + } else { |
|
| 86 | 86 | $elm=$this->getElementById($index, $this->content); |
| 87 | 87 | return $elm; |
| 88 | 88 | } |
@@ -144,10 +144,11 @@ discard block |
||
| 144 | 144 | $i=0; |
| 145 | 145 | foreach ($properties as $k=>$v){ |
| 146 | 146 | $c=$this->content[$i++]; |
| 147 | - if(isset($c)) |
|
| 148 | - $c->setProperty($k,$v); |
|
| 149 | - else |
|
| 150 | - return $this; |
|
| 147 | + if(isset($c)) { |
|
| 148 | + $c->setProperty($k,$v); |
|
| 149 | + } else { |
|
| 150 | + return $this; |
|
| 151 | + } |
|
| 151 | 152 | } |
| 152 | 153 | return $this; |
| 153 | 154 | } |
@@ -165,8 +166,7 @@ discard block |
||
| 165 | 166 | foreach ($values as $i=>$value){ |
| 166 | 167 | if(isset($this->content[$i])){ |
| 167 | 168 | $this->content[$i]->setProperty($property,$value); |
| 168 | - } |
|
| 169 | - else{ |
|
| 169 | + } else{ |
|
| 170 | 170 | return $this; |
| 171 | 171 | } |
| 172 | 172 | } |
@@ -186,8 +186,7 @@ discard block |
||
| 186 | 186 | foreach ($values as $i=>$value){ |
| 187 | 187 | if(isset($this->content[$i])){ |
| 188 | 188 | $this->content[$i++]->addToProperty($property,$value); |
| 189 | - } |
|
| 190 | - else{ |
|
| 189 | + } else{ |
|
| 191 | 190 | return $this; |
| 192 | 191 | } |
| 193 | 192 | } |
@@ -216,8 +215,9 @@ discard block |
||
| 216 | 215 | foreach ( $this->content as $index=>$item ) { |
| 217 | 216 | if($item instanceof HtmlDoubleElement){ |
| 218 | 217 | $href=""; |
| 219 | - if(isset($hrefs[$index])) |
|
| 220 | - $href=$hrefs[$index]; |
|
| 218 | + if(isset($hrefs[$index])) { |
|
| 219 | + $href=$hrefs[$index]; |
|
| 220 | + } |
|
| 221 | 221 | $item->asLink($href,$target); |
| 222 | 222 | } |
| 223 | 223 | } |
@@ -33,8 +33,9 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function getProperty($name) { |
| 36 | - if (array_key_exists($name, $this->_self->properties)) |
|
| 37 | - return $this->_self->properties[$name]; |
|
| 36 | + if (array_key_exists($name, $this->_self->properties)) { |
|
| 37 | + return $this->_self->properties[$name]; |
|
| 38 | + } |
|
| 38 | 39 | } |
| 39 | 40 | |
| 40 | 41 | /** |
@@ -76,8 +77,9 @@ discard block |
||
| 76 | 77 | } |
| 77 | 78 | |
| 78 | 79 | protected function addToPropertyUnique($name, $value, $typeCtrl) { |
| 79 | - if (is_string($typeCtrl) && @class_exists($typeCtrl, true)) |
|
| 80 | - $typeCtrl=$typeCtrl::getConstants(); |
|
| 80 | + if (is_string($typeCtrl) && @class_exists($typeCtrl, true)) { |
|
| 81 | + $typeCtrl=$typeCtrl::getConstants(); |
|
| 82 | + } |
|
| 81 | 83 | if (\is_array($typeCtrl)) { |
| 82 | 84 | $this->_self->removeOldValues($this->_self->properties[$name], $typeCtrl); |
| 83 | 85 | } |
@@ -96,8 +98,9 @@ discard block |
||
| 96 | 98 | } |
| 97 | 99 | |
| 98 | 100 | public function removeProperty($name) { |
| 99 | - if (\array_key_exists($name, $this->_self->properties)) |
|
| 100 | - unset($this->_self->properties[$name]); |
|
| 101 | + if (\array_key_exists($name, $this->_self->properties)) { |
|
| 102 | + unset($this->_self->properties[$name]); |
|
| 103 | + } |
|
| 101 | 104 | return $this; |
| 102 | 105 | } |
| 103 | 106 | |
@@ -110,8 +113,9 @@ discard block |
||
| 110 | 113 | } |
| 111 | 114 | |
| 112 | 115 | protected function setPropertyCtrl($name, $value, $typeCtrl) { |
| 113 | - if ($this->_self->ctrl($name, $value, $typeCtrl) === true) |
|
| 114 | - return $this->_self->setProperty($name, $value); |
|
| 116 | + if ($this->_self->ctrl($name, $value, $typeCtrl) === true) { |
|
| 117 | + return $this->_self->setProperty($name, $value); |
|
| 118 | + } |
|
| 115 | 119 | return $this; |
| 116 | 120 | } |
| 117 | 121 | |
@@ -59,8 +59,9 @@ |
||
| 59 | 59 | $callback.=$js->trigger("#".$id." [name='selection[]']","change",false)."$('#".$id." tbody .ui.checkbox').checkbox();".$js->execOn("change", "#".$id." [name='selection[]']", $this->_getCheckedChange($js)); |
| 60 | 60 | $callback.=$this->_generatePaginationScript($id); |
| 61 | 61 | if(isset($this->_urls["refresh"])){ |
| 62 | - if(isset($menu)) |
|
| 63 | - $js->jsonArrayOn("click", "#".$menu->getIdentifier()." a","#".$this->_identifier." tr.".$this->_modelClass, $this->_urls["refresh"],"post",["params"=>"{'p':$(this).attr('data-page'),'_model':'".JString::doubleBackSlashes($this->_model)."'}","jsCallback"=>$callback]); |
|
| 62 | + if(isset($menu)) { |
|
| 63 | + $js->jsonArrayOn("click", "#".$menu->getIdentifier()." a","#".$this->_identifier." tr.".$this->_modelClass, $this->_urls["refresh"],"post",["params"=>"{'p':$(this).attr('data-page'),'_model':'".JString::doubleBackSlashes($this->_model)."'}","jsCallback"=>$callback]); |
|
| 64 | + } |
|
| 64 | 65 | } |
| 65 | 66 | } |
| 66 | 67 | |
@@ -32,15 +32,17 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public function addContent($content,$before=false) { |
| 34 | 34 | if (!\is_array($this->content)) { |
| 35 | - if(isset($this->content)) |
|
| 36 | - $this->content=array ($this->content); |
|
| 37 | - else |
|
| 38 | - $this->content=array(); |
|
| 35 | + if(isset($this->content)) { |
|
| 36 | + $this->content=array ($this->content); |
|
| 37 | + } else { |
|
| 38 | + $this->content=array(); |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | + if($before) { |
|
| 42 | + array_unshift($this->content,$content); |
|
| 43 | + } else { |
|
| 44 | + $this->content []=$content; |
|
| 39 | 45 | } |
| 40 | - if($before) |
|
| 41 | - array_unshift($this->content,$content); |
|
| 42 | - else |
|
| 43 | - $this->content []=$content; |
|
| 44 | 46 | return $this; |
| 45 | 47 | } |
| 46 | 48 | |
@@ -78,9 +80,9 @@ discard block |
||
| 78 | 80 | $instances=[]; |
| 79 | 81 | if($content instanceof $class){ |
| 80 | 82 | $instances[]=$content; |
| 81 | - }elseif($content instanceof HtmlDoubleElement){ |
|
| 83 | + } elseif($content instanceof HtmlDoubleElement){ |
|
| 82 | 84 | $instances=\array_merge($instances,$content->getContentInstances($class)); |
| 83 | - }elseif (\is_array($content)){ |
|
| 85 | + } elseif (\is_array($content)){ |
|
| 84 | 86 | foreach ($content as $element){ |
| 85 | 87 | $instances=\array_merge($instances,$this->_getContentInstances($class, $element)); |
| 86 | 88 | } |
@@ -93,10 +95,12 @@ discard block |
||
| 93 | 95 | * @return HtmlDoubleElement |
| 94 | 96 | */ |
| 95 | 97 | public function asLink($href=NULL,$target=NULL) { |
| 96 | - if (isset($href)) |
|
| 97 | - $this->setProperty("href", $href); |
|
| 98 | - if(isset($target)) |
|
| 99 | - $this->setProperty("target", $target); |
|
| 98 | + if (isset($href)) { |
|
| 99 | + $this->setProperty("href", $href); |
|
| 100 | + } |
|
| 101 | + if(isset($target)) { |
|
| 102 | + $this->setProperty("target", $target); |
|
| 103 | + } |
|
| 100 | 104 | return $this->setTagName("a"); |
| 101 | 105 | } |
| 102 | 106 | |
@@ -121,7 +125,7 @@ discard block |
||
| 121 | 125 | $this->_editableContent=$frm; |
| 122 | 126 | $keypress=""; |
| 123 | 127 | $focusOut=""; |
| 124 | - }else{ |
|
| 128 | + } else{ |
|
| 125 | 129 | $focusOut="if(e.relatedTarget==null)elm.trigger('endEdit');"; |
| 126 | 130 | $this->_editableContent=$field; |
| 127 | 131 | $keypress="$('#".$idF."').keyup(function(e){if(e.which == 13) {\$('#".$idE."').trigger('validate',{value: $('#'+idF+' input').val()});}if(e.keyCode===27) {\$('#".$idE."').trigger('endEdit');}});"; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $this->_generateFields($form, [$v], $headers, $i, $wrappers,$nb++); |
| 65 | 65 | $i++; |
| 66 | 66 | } |
| 67 | - }else{ |
|
| 67 | + } else{ |
|
| 68 | 68 | $separators[]=$count; |
| 69 | 69 | for($i=0;$i<$size;$i++){ |
| 70 | 70 | $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
@@ -78,17 +78,19 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | protected function _generateFields($form,$values,$headers,$sepFirst,$wrappers,$nb){ |
| 80 | 80 | $wrapper=null; |
| 81 | - if(isset($headers[$sepFirst+1])) |
|
| 82 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
| 81 | + if(isset($headers[$sepFirst+1])) { |
|
| 82 | + $form->addHeader($headers[$sepFirst+1],4,true); |
|
| 83 | + } |
|
| 83 | 84 | if(isset($wrappers[$sepFirst+1])){ |
| 84 | 85 | $wrapper=$wrappers[$sepFirst+1]; |
| 85 | 86 | } |
| 86 | 87 | if(\sizeof($values)===1){ |
| 87 | 88 | $added=$form->addField($values[0]); |
| 88 | - }elseif(\sizeof($values)>1){ |
|
| 89 | + } elseif(\sizeof($values)>1){ |
|
| 89 | 90 | $added=$form->addFields($values); |
| 90 | - }else |
|
| 91 | - return; |
|
| 91 | + } else { |
|
| 92 | + return; |
|
| 93 | + } |
|
| 92 | 94 | if(isset($wrapper)){ |
| 93 | 95 | $added->wrap($wrapper[0],$wrapper[1]); |
| 94 | 96 | } |