@@ -10,15 +10,15 @@ discard block |
||
| 10 | 10 | protected $_modelInstance; |
| 11 | 11 | protected $_instanceViewer; |
| 12 | 12 | |
| 13 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 13 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 14 | 14 | parent::__construct($identifier); |
| 15 | 15 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
| 16 | 16 | $this->setModel($model); |
| 17 | - if(isset($modelInstance)); |
|
| 17 | + if (isset($modelInstance)); |
|
| 18 | 18 | $this->show($modelInstance); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function show($modelInstance){ |
|
| 21 | + public function show($modelInstance) { |
|
| 22 | 22 | $this->_modelInstance=$modelInstance; |
| 23 | 23 | } |
| 24 | 24 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public abstract function getHtmlComponent(); |
| 44 | 44 | |
| 45 | - public function setColor($color){ |
|
| 45 | + public function setColor($color) { |
|
| 46 | 46 | return $this->getHtmlComponent()->setColor($color); |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | \ No newline at end of file |
@@ -17,18 +17,18 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public function __construct(JsUtils $js) { |
| 19 | 19 | parent::__construct($js); |
| 20 | - $this->events=array (); |
|
| 20 | + $this->events=array(); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | protected function compileEvents() { |
| 24 | - foreach ( $this->events as $event => $jsCode ) { |
|
| 25 | - if($event=="execute"){ |
|
| 24 | + foreach ($this->events as $event => $jsCode) { |
|
| 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 | - if(isset($this->itemSelector)){ |
|
| 31 | + if (isset($this->itemSelector)) { |
|
| 32 | 32 | $selector.=" ".$this->itemSelector; |
| 33 | 33 | } |
| 34 | 34 | $this->jquery_code_for_compile []="$( \"".$selector."\" ).on(\"".$event."\" , function( event, data ) {".$jsCode."});"; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | $result=implode("\n", $this->jquery_code_for_compile); |
| 41 | 41 | $result=str_ireplace("\"%", "", $result); |
| 42 | 42 | $result=str_ireplace("%\"", "", $result); |
| 43 | - $result=str_replace(array ( |
|
| 43 | + $result=str_replace(array( |
|
| 44 | 44 | "\\n", |
| 45 | 45 | "\\r", |
| 46 | 46 | "\\t" |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | public function getScript() { |
| 52 | 52 | $allParams=$this->params; |
| 53 | - $this->jquery_code_for_compile=array (); |
|
| 53 | + $this->jquery_code_for_compile=array(); |
|
| 54 | 54 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).");"; |
| 55 | 55 | $this->compileEvents(); |
| 56 | 56 | return $this->compileJQueryCode(); |
@@ -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); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
| 16 | 16 | |
| 17 | 17 | public abstract function _prep_value($value); |
| 18 | - public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
| 18 | + public abstract 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=$this->_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 |
@@ -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 | |
@@ -8,34 +8,34 @@ discard block |
||
| 8 | 8 | private $page_count; |
| 9 | 9 | private $pages_visibles; |
| 10 | 10 | |
| 11 | - public function __construct($items_per_page=10,$pages_visibles=4,$page=1){ |
|
| 11 | + public function __construct($items_per_page=10, $pages_visibles=4, $page=1) { |
|
| 12 | 12 | $this->items_per_page=$items_per_page; |
| 13 | 13 | $this->page=$page; |
| 14 | 14 | $this->pages_visibles=$pages_visibles; |
| 15 | 15 | $this->visible=true; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public function getObjects($objects){ |
|
| 19 | - $offset = ($this->page - 1) * $this->items_per_page; |
|
| 18 | + public function getObjects($objects) { |
|
| 19 | + $offset=($this->page-1)*$this->items_per_page; |
|
| 20 | 20 | $os=$objects; |
| 21 | - if(\is_array($os)===false){ |
|
| 21 | + if (\is_array($os)===false) { |
|
| 22 | 22 | $os=[]; |
| 23 | - foreach ($objects as $o){ |
|
| 23 | + foreach ($objects as $o) { |
|
| 24 | 24 | $os[]=$o; |
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | - $this->page_count = 0; |
|
| 27 | + $this->page_count=0; |
|
| 28 | 28 | $row_count=\sizeof($os); |
| 29 | - if (0 === $row_count) { |
|
| 29 | + if (0===$row_count) { |
|
| 30 | 30 | $this->visible=false; |
| 31 | 31 | } else { |
| 32 | 32 | $this->visible=true; |
| 33 | - $this->page_count = (int)ceil($row_count / $this->items_per_page); |
|
| 34 | - if($this->page > $this->page_count+1) { |
|
| 35 | - $this->page = 1; |
|
| 33 | + $this->page_count=(int)ceil($row_count/$this->items_per_page); |
|
| 34 | + if ($this->page>$this->page_count+1) { |
|
| 35 | + $this->page=1; |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | - return array_slice($os, $offset,$this->items_per_page); |
|
| 38 | + return array_slice($os, $offset, $this->items_per_page); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function getItemsPerPage() { |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | return $this->page_count; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - public function getPagesNumbers(){ |
|
| 73 | - $middle= (int)ceil(($this->pages_visibles-1)/ 2); |
|
| 72 | + public function getPagesNumbers() { |
|
| 73 | + $middle=(int)ceil(($this->pages_visibles-1)/2); |
|
| 74 | 74 | $first=$this->page-$middle; |
| 75 | - if($first<1){ |
|
| 75 | + if ($first<1) { |
|
| 76 | 76 | $first=1; |
| 77 | 77 | } |
| 78 | 78 | $last=$first+$this->pages_visibles-1; |
| 79 | - if($last>$this->page_count){ |
|
| 79 | + if ($last>$this->page_count) { |
|
| 80 | 80 | $last=$this->page_count; |
| 81 | 81 | } |
| 82 | 82 | return \range($first, $last); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | * @param array $instances |
| 14 | 14 | * @return DataTable |
| 15 | 15 | */ |
| 16 | - public function dataTable($identifier,$model, $instances){ |
|
| 17 | - return $this->addHtmlComponent(new DataTable($identifier,$model,$instances)); |
|
| 16 | + public function dataTable($identifier, $model, $instances) { |
|
| 17 | + return $this->addHtmlComponent(new DataTable($identifier, $model, $instances)); |
|
| 18 | 18 | } |
| 19 | 19 | } |
| 20 | 20 | \ No newline at end of file |
@@ -7,20 +7,20 @@ |
||
| 7 | 7 | |
| 8 | 8 | use Ajax\semantic\html\elements\HtmlIcon; |
| 9 | 9 | |
| 10 | -class HtmlPaginationMenu extends HtmlMenu{ |
|
| 10 | +class HtmlPaginationMenu extends HtmlMenu { |
|
| 11 | 11 | private $_page; |
| 12 | - public function __construct( $identifier, $items=array() ){ |
|
| 13 | - parent::__construct( $identifier,$items); |
|
| 12 | + public function __construct($identifier, $items=array()) { |
|
| 13 | + parent::__construct($identifier, $items); |
|
| 14 | 14 | } |
| 15 | 15 | /** |
| 16 | 16 | * {@inheritDoc} |
| 17 | 17 | * @see \Ajax\common\html\BaseHtml::compile() |
| 18 | 18 | */ |
| 19 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 20 | - $this->insertItem(new HtmlIcon("", "left chevron"))->setProperty("data-page", \max([1,$this->_page-1])); |
|
| 21 | - $this->addItem(new HtmlIcon("", "right chevron"))->setProperty("data-page", \min([\sizeof($this->content)-2,$this->_page+1])); |
|
| 19 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 20 | + $this->insertItem(new HtmlIcon("", "left chevron"))->setProperty("data-page", \max([1, $this->_page-1])); |
|
| 21 | + $this->addItem(new HtmlIcon("", "right chevron"))->setProperty("data-page", \min([\sizeof($this->content)-2, $this->_page+1])); |
|
| 22 | 22 | $this->asPagination(); |
| 23 | - return parent::compile($js,$view); |
|
| 23 | + return parent::compile($js, $view); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public function setActiveItem($index) { |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public function __construct($identifier, $rowCount, $colCount) { |
| 23 | 23 | parent::__construct($identifier, "table", "ui table"); |
| 24 | - $this->content=array (); |
|
| 24 | + $this->content=array(); |
|
| 25 | 25 | $this->setRowCount($rowCount, $colCount); |
| 26 | - $this->_variations=[ Variation::CELLED,Variation::PADDED,Variation::COMPACT ]; |
|
| 27 | - $this->_compileParts=["thead","tbody","tfoot"]; |
|
| 26 | + $this->_variations=[Variation::CELLED, Variation::PADDED, Variation::COMPACT]; |
|
| 27 | + $this->_compileParts=["thead", "tbody", "tfoot"]; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | * @return HtmlTableContent |
| 34 | 34 | */ |
| 35 | 35 | public function getPart($key) { |
| 36 | - if (\array_key_exists($key, $this->content) === false) { |
|
| 36 | + if (\array_key_exists($key, $this->content)===false) { |
|
| 37 | 37 | $this->content[$key]=new HtmlTableContent("", $key); |
| 38 | - if ($key !== "tbody") { |
|
| 38 | + if ($key!=="tbody") { |
|
| 39 | 39 | $this->content[$key]->setRowCount(1, $this->_colCount); |
| 40 | 40 | } |
| 41 | 41 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @return boolean |
| 73 | 73 | */ |
| 74 | 74 | public function hasPart($key) { |
| 75 | - return \array_key_exists($key, $this->content) === true; |
|
| 75 | + return \array_key_exists($key, $this->content)===true; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | private function colAlign($colIndex, $function) { |
| 179 | 179 | if (\is_array($colIndex)) { |
| 180 | - foreach ( $colIndex as $cIndex ) { |
|
| 180 | + foreach ($colIndex as $cIndex) { |
|
| 181 | 181 | $this->colAlign($cIndex, $function); |
| 182 | 182 | } |
| 183 | 183 | } else { |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | public function setBasic($very=false) { |
| 197 | 197 | if ($very) |
| 198 | - $this->addToPropertyCtrl("class", "very", array ("very" )); |
|
| 199 | - return $this->addToPropertyCtrl("class", "basic", array ("basic" )); |
|
| 198 | + $this->addToPropertyCtrl("class", "very", array("very")); |
|
| 199 | + return $this->addToPropertyCtrl("class", "basic", array("basic")); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | public function setCollapsing() { |
@@ -257,12 +257,12 @@ discard block |
||
| 257 | 257 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile() |
| 258 | 258 | */ |
| 259 | 259 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 260 | - if(\sizeof($this->_compileParts)<3){ |
|
| 260 | + if (\sizeof($this->_compileParts)<3) { |
|
| 261 | 261 | $this->_template="%content%"; |
| 262 | 262 | $this->refresh(); |
| 263 | - }else{ |
|
| 263 | + } else { |
|
| 264 | 264 | if ($this->propertyContains("class", "sortable")) { |
| 265 | - $this->addEvent("execute", "$('#" . $this->identifier . "').tablesort();"); |
|
| 265 | + $this->addEvent("execute", "$('#".$this->identifier."').tablesort();"); |
|
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | $this->content=JArray::sortAssociative($this->content, $this->_compileParts); |
@@ -293,14 +293,14 @@ discard block |
||
| 293 | 293 | return $this; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - public function refresh(){ |
|
| 296 | + public function refresh() { |
|
| 297 | 297 | $this->_footer=$this->getFooter(); |
| 298 | 298 | $this->addEvent("execute", '$("#'.$this->identifier.' tfoot").replaceWith("'.\addslashes($this->_footer).'");'); |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - public function run(JsUtils $js){ |
|
| 302 | - $result= parent::run($js); |
|
| 303 | - if(isset($this->_footer)) |
|
| 301 | + public function run(JsUtils $js) { |
|
| 302 | + $result=parent::run($js); |
|
| 303 | + if (isset($this->_footer)) |
|
| 304 | 304 | $this->_footer->run($js); |
| 305 | 305 | return $result; |
| 306 | 306 | } |
@@ -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 | |
@@ -10,13 +10,13 @@ discard block |
||
| 10 | 10 | use Ajax\JsUtils; |
| 11 | 11 | |
| 12 | 12 | class HtmlInput extends HtmlSemDoubleElement { |
| 13 | - use IconTrait,TextFieldsTrait,FieldTrait; |
|
| 13 | + use IconTrait, TextFieldsTrait, FieldTrait; |
|
| 14 | 14 | |
| 15 | 15 | public function __construct($identifier, $type="text", $value="", $placeholder="") { |
| 16 | - parent::__construct("div-" . $identifier, "div", "ui input"); |
|
| 17 | - $this->content=[ "field" => new \Ajax\common\html\html5\HtmlInput($identifier, $type, $value, $placeholder) ]; |
|
| 18 | - $this->_states=[ State::DISABLED,State::FOCUS,State::ERROR ]; |
|
| 19 | - $this->_variations=[ Variation::TRANSPARENT ]; |
|
| 16 | + parent::__construct("div-".$identifier, "div", "ui input"); |
|
| 17 | + $this->content=["field" => new \Ajax\common\html\html5\HtmlInput($identifier, $type, $value, $placeholder)]; |
|
| 18 | + $this->_states=[State::DISABLED, State::FOCUS, State::ERROR]; |
|
| 19 | + $this->_variations=[Variation::TRANSPARENT]; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function getField() { |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public function run(JsUtils $js) { |
| 38 | 38 | $result=parent::run($js); |
| 39 | - $result->attach("#" . $this->getDataField()->getIdentifier()); |
|
| 39 | + $result->attach("#".$this->getDataField()->getIdentifier()); |
|
| 40 | 40 | return $result; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function setTransparent(){ |
|
| 43 | + public function setTransparent() { |
|
| 44 | 44 | return $this->addToProperty("class", "transparent"); |
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | \ No newline at end of file |
@@ -38,6 +38,10 @@ discard block |
||
| 38 | 38 | parent::run($js); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | + /** |
|
| 42 | + * @param string $identifier |
|
| 43 | + * @param string $model |
|
| 44 | + */ |
|
| 41 | 45 | public function __construct($identifier,$model,$modelInstance=NULL) { |
| 42 | 46 | parent::__construct($identifier, $model,$modelInstance); |
| 43 | 47 | $this->_instanceViewer=new InstanceViewer(); |
@@ -164,21 +168,34 @@ discard block |
||
| 164 | 168 | return $this; |
| 165 | 169 | } |
| 166 | 170 | |
| 171 | + /** |
|
| 172 | + * @param \Closure $field |
|
| 173 | + */ |
|
| 167 | 174 | public function addField($field){ |
| 168 | 175 | $this->_instanceViewer->addField($field); |
| 169 | 176 | return $this; |
| 170 | 177 | } |
| 171 | 178 | |
| 179 | + /** |
|
| 180 | + * @param integer $index |
|
| 181 | + * @param \Closure $field |
|
| 182 | + */ |
|
| 172 | 183 | public function insertField($index,$field){ |
| 173 | 184 | $this->_instanceViewer->insertField($index, $field); |
| 174 | 185 | return $this; |
| 175 | 186 | } |
| 176 | 187 | |
| 188 | + /** |
|
| 189 | + * @param \Closure $field |
|
| 190 | + */ |
|
| 177 | 191 | public function insertInField($index,$field){ |
| 178 | 192 | $this->_instanceViewer->insertInField($index, $field); |
| 179 | 193 | return $this; |
| 180 | 194 | } |
| 181 | 195 | |
| 196 | + /** |
|
| 197 | + * @param \Closure $callback |
|
| 198 | + */ |
|
| 182 | 199 | public function setValueFunction($index,$callback){ |
| 183 | 200 | $this->_instanceViewer->setValueFunction($index, $callback); |
| 184 | 201 | return $this; |
@@ -222,16 +239,16 @@ discard block |
||
| 222 | 239 | /** |
| 223 | 240 | * @param string $caption |
| 224 | 241 | * @param callable $callback |
| 225 | - * @return callable |
|
| 242 | + * @return \Closure |
|
| 226 | 243 | */ |
| 227 | 244 | private function getFieldButtonCallable($caption,$callback=null){ |
| 228 | 245 | return $this->getCallable($this->getFieldButton($caption),$callback); |
| 229 | 246 | } |
| 230 | 247 | |
| 231 | 248 | /** |
| 232 | - * @param mixed $object |
|
| 249 | + * @param HtmlButton $object |
|
| 233 | 250 | * @param callable $callback |
| 234 | - * @return callable |
|
| 251 | + * @return \Closure |
|
| 235 | 252 | */ |
| 236 | 253 | private function getCallable($object,$callback=null){ |
| 237 | 254 | $result=function($instance) use($object,$callback){ |
@@ -290,12 +307,20 @@ discard block |
||
| 290 | 307 | return $this; |
| 291 | 308 | } |
| 292 | 309 | |
| 310 | + /** |
|
| 311 | + * @param string $icon |
|
| 312 | + * @param string $class |
|
| 313 | + */ |
|
| 293 | 314 | private function addDefaultButton($icon,$class=null,$callback=null){ |
| 294 | 315 | $bt=$this->getDefaultButton($icon,$class); |
| 295 | 316 | $this->addField($this->getCallable($bt,$callback)); |
| 296 | 317 | return $this; |
| 297 | 318 | } |
| 298 | 319 | |
| 320 | + /** |
|
| 321 | + * @param string $icon |
|
| 322 | + * @param string $class |
|
| 323 | + */ |
|
| 299 | 324 | private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){ |
| 300 | 325 | $bt=$this->getDefaultButton($icon,$class); |
| 301 | 326 | $this->insertInField($index,$this->getCallable($bt,$callback)); |
@@ -458,6 +483,9 @@ discard block |
||
| 458 | 483 | return $this; |
| 459 | 484 | } |
| 460 | 485 | |
| 486 | + /** |
|
| 487 | + * @param string $prefix |
|
| 488 | + */ |
|
| 461 | 489 | private function _getFieldIdentifier($prefix){ |
| 462 | 490 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
| 463 | 491 | } |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | protected $_compileParts; |
| 29 | 29 | protected $_toolbarPosition; |
| 30 | 30 | |
| 31 | - public function run(JsUtils $js){ |
|
| 32 | - if($this->_hasCheckboxes && isset($js)){ |
|
| 31 | + public function run(JsUtils $js) { |
|
| 32 | + if ($this->_hasCheckboxes && isset($js)) { |
|
| 33 | 33 | $js->execOn("change", "#".$this->identifier." [name='selection[]']", " |
| 34 | 34 | var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true; |
| 35 | 35 | \$checkbox.each(function() {if($(this).prop('checked')){allUnchecked = false;}else{allChecked = false;}}); |
@@ -38,21 +38,21 @@ discard block |
||
| 38 | 38 | parent::run($js); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 42 | - parent::__construct($identifier, $model,$modelInstance); |
|
| 41 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 42 | + parent::__construct($identifier, $model, $modelInstance); |
|
| 43 | 43 | $this->_instanceViewer=new InstanceViewer(); |
| 44 | - $this->content=["table"=>new HtmlTable($identifier, 0,0)]; |
|
| 44 | + $this->content=["table"=>new HtmlTable($identifier, 0, 0)]; |
|
| 45 | 45 | $this->_toolbarPosition=PositionInTable::BEFORETABLE; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 48 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 49 | 49 | $this->_instanceViewer->setInstance($this->_model); |
| 50 | 50 | $captions=$this->_instanceViewer->getCaptions(); |
| 51 | 51 | |
| 52 | 52 | $table=$this->content["table"]; |
| 53 | 53 | |
| 54 | - if($this->_hasCheckboxes){ |
|
| 55 | - $ck=new HtmlCheckbox("main-ck-".$this->identifier,""); |
|
| 54 | + if ($this->_hasCheckboxes) { |
|
| 55 | + $ck=new HtmlCheckbox("main-ck-".$this->identifier, ""); |
|
| 56 | 56 | $ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);"); |
| 57 | 57 | $ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);"); |
| 58 | 58 | \array_unshift($captions, $ck); |
@@ -60,43 +60,43 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | $table->setRowCount(0, \sizeof($captions)); |
| 62 | 62 | $table->setHeaderValues($captions); |
| 63 | - if(isset($this->_compileParts)) |
|
| 63 | + if (isset($this->_compileParts)) |
|
| 64 | 64 | $table->setCompileParts($this->_compileParts); |
| 65 | - if(isset($this->_searchField)){ |
|
| 66 | - if(isset($js)) |
|
| 67 | - $this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
|
| 65 | + if (isset($this->_searchField)) { |
|
| 66 | + if (isset($js)) |
|
| 67 | + $this->_searchField->postOn("change", $this->_urls, "{'s':$(this).val()}", "-#".$this->identifier." tbody", ["preventDefault"=>false]); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $this->_generateContent($table); |
| 71 | 71 | |
| 72 | - if($this->_hasCheckboxes){ |
|
| 73 | - if($table->hasPart("thead")) |
|
| 74 | - $table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort"); |
|
| 72 | + if ($this->_hasCheckboxes) { |
|
| 73 | + if ($table->hasPart("thead")) |
|
| 74 | + $table->getHeader()->getCell(0, 0)->addToProperty("class", "no-sort"); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
| 77 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
| 78 | 78 | $this->_generatePagination($table); |
| 79 | 79 | } |
| 80 | - if(isset($this->_toolbar)){ |
|
| 80 | + if (isset($this->_toolbar)) { |
|
| 81 | 81 | $this->_setToolbarPosition($table, $captions); |
| 82 | 82 | } |
| 83 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
| 84 | - return parent::compile($js,$view); |
|
| 83 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
| 84 | + return parent::compile($js, $view); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - private function _generateContent($table){ |
|
| 87 | + private function _generateContent($table) { |
|
| 88 | 88 | $objects=$this->_modelInstance; |
| 89 | - if(isset($this->_pagination)){ |
|
| 89 | + if (isset($this->_pagination)) { |
|
| 90 | 90 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
| 91 | 91 | } |
| 92 | 92 | InstanceViewer::setIndex(0); |
| 93 | - $table->fromDatabaseObjects($objects, function($instance){ |
|
| 93 | + $table->fromDatabaseObjects($objects, function($instance) { |
|
| 94 | 94 | $this->_instanceViewer->setInstance($instance); |
| 95 | - $result= $this->_instanceViewer->getValues(); |
|
| 96 | - if($this->_hasCheckboxes){ |
|
| 97 | - $ck=new HtmlCheckbox("ck-".$this->identifier,""); |
|
| 95 | + $result=$this->_instanceViewer->getValues(); |
|
| 96 | + if ($this->_hasCheckboxes) { |
|
| 97 | + $ck=new HtmlCheckbox("ck-".$this->identifier, ""); |
|
| 98 | 98 | $field=$ck->getField(); |
| 99 | - $field->setProperty("value",$this->_instanceViewer->getIdentifier()); |
|
| 99 | + $field->setProperty("value", $this->_instanceViewer->getIdentifier()); |
|
| 100 | 100 | $field->setProperty("name", "selection[]"); |
| 101 | 101 | \array_unshift($result, $ck); |
| 102 | 102 | } |
@@ -104,25 +104,25 @@ discard block |
||
| 104 | 104 | }); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - private function _generatePagination($table){ |
|
| 107 | + private function _generatePagination($table) { |
|
| 108 | 108 | $footer=$table->getFooter(); |
| 109 | 109 | $footer->mergeCol(); |
| 110 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
| 110 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
| 111 | 111 | $menu->floatRight(); |
| 112 | 112 | $menu->setActiveItem($this->_pagination->getPage()-1); |
| 113 | 113 | $footer->setValues($menu); |
| 114 | - $menu->postOnClick($this->_urls,"{'p':$(this).attr('data-page')}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
|
| 114 | + $menu->postOnClick($this->_urls, "{'p':$(this).attr('data-page')}", "-#".$this->identifier." tbody", ["preventDefault"=>false]); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - private function _setToolbarPosition($table,$captions){ |
|
| 118 | - switch ($this->_toolbarPosition){ |
|
| 117 | + private function _setToolbarPosition($table, $captions) { |
|
| 118 | + switch ($this->_toolbarPosition) { |
|
| 119 | 119 | case PositionInTable::BEFORETABLE:case PositionInTable::AFTERTABLE: |
| 120 | - if(isset($this->_compileParts)===false){ |
|
| 120 | + if (isset($this->_compileParts)===false) { |
|
| 121 | 121 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 122 | 122 | } |
| 123 | 123 | break; |
| 124 | 124 | case PositionInTable::HEADER:case PositionInTable::FOOTER: case PositionInTable::BODY: |
| 125 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
| 125 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
| 126 | 126 | break; |
| 127 | 127 | } |
| 128 | 128 | } |
@@ -134,12 +134,12 @@ discard block |
||
| 134 | 134 | * @param callable $callback function called after the field compilation |
| 135 | 135 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 136 | 136 | */ |
| 137 | - public function afterCompile($index,$callback){ |
|
| 138 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
| 137 | + public function afterCompile($index, $callback) { |
|
| 138 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
| 139 | 139 | return $this; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - private function addToolbarRow($part,$table,$captions){ |
|
| 142 | + private function addToolbarRow($part, $table, $captions) { |
|
| 143 | 143 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 144 | 144 | $row->mergeCol(); |
| 145 | 145 | $row->setValues([$this->_toolbar]); |
@@ -154,42 +154,42 @@ discard block |
||
| 154 | 154 | return $this; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - public function setCaptions($captions){ |
|
| 157 | + public function setCaptions($captions) { |
|
| 158 | 158 | $this->_instanceViewer->setCaptions($captions); |
| 159 | 159 | return $this; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - public function setFields($fields){ |
|
| 162 | + public function setFields($fields) { |
|
| 163 | 163 | $this->_instanceViewer->setVisibleProperties($fields); |
| 164 | 164 | return $this; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - public function addField($field){ |
|
| 167 | + public function addField($field) { |
|
| 168 | 168 | $this->_instanceViewer->addField($field); |
| 169 | 169 | return $this; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - public function insertField($index,$field){ |
|
| 172 | + public function insertField($index, $field) { |
|
| 173 | 173 | $this->_instanceViewer->insertField($index, $field); |
| 174 | 174 | return $this; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - public function insertInField($index,$field){ |
|
| 177 | + public function insertInField($index, $field) { |
|
| 178 | 178 | $this->_instanceViewer->insertInField($index, $field); |
| 179 | 179 | return $this; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - public function setValueFunction($index,$callback){ |
|
| 182 | + public function setValueFunction($index, $callback) { |
|
| 183 | 183 | $this->_instanceViewer->setValueFunction($index, $callback); |
| 184 | 184 | return $this; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - public function setIdentifierFunction($callback){ |
|
| 187 | + public function setIdentifierFunction($callback) { |
|
| 188 | 188 | $this->_instanceViewer->setIdentifierFunction($callback); |
| 189 | 189 | return $this; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - public function getHtmlComponent(){ |
|
| 192 | + public function getHtmlComponent() { |
|
| 193 | 193 | return $this->content["table"]; |
| 194 | 194 | } |
| 195 | 195 | |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | return $this; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - public function paginate($items_per_page=10,$page=1){ |
|
| 206 | - $this->_pagination=new Pagination($items_per_page,4,$page); |
|
| 205 | + public function paginate($items_per_page=10, $page=1) { |
|
| 206 | + $this->_pagination=new Pagination($items_per_page, 4, $page); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | public function getHasCheckboxes() { |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | return $this; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - public function refresh($compileParts=["tbody"]){ |
|
| 218 | + public function refresh($compileParts=["tbody"]) { |
|
| 219 | 219 | $this->_compileParts=$compileParts; |
| 220 | 220 | return $this; |
| 221 | 221 | } |
@@ -224,8 +224,8 @@ discard block |
||
| 224 | 224 | * @param callable $callback |
| 225 | 225 | * @return callable |
| 226 | 226 | */ |
| 227 | - private function getFieldButtonCallable($caption,$callback=null){ |
|
| 228 | - return $this->getCallable($this->getFieldButton($caption),$callback); |
|
| 227 | + private function getFieldButtonCallable($caption, $callback=null) { |
|
| 228 | + return $this->getCallable($this->getFieldButton($caption), $callback); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -233,11 +233,11 @@ discard block |
||
| 233 | 233 | * @param callable $callback |
| 234 | 234 | * @return callable |
| 235 | 235 | */ |
| 236 | - private function getCallable($object,$callback=null){ |
|
| 237 | - $result=function($instance) use($object,$callback){ |
|
| 238 | - if(isset($callback)){ |
|
| 239 | - if(\is_callable($callback)){ |
|
| 240 | - $callback($object,$instance); |
|
| 236 | + private function getCallable($object, $callback=null) { |
|
| 237 | + $result=function($instance) use($object, $callback){ |
|
| 238 | + if (isset($callback)) { |
|
| 239 | + if (\is_callable($callback)) { |
|
| 240 | + $callback($object, $instance); |
|
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | return $object; |
@@ -249,9 +249,9 @@ discard block |
||
| 249 | 249 | * @param string $caption |
| 250 | 250 | * @return HtmlButton |
| 251 | 251 | */ |
| 252 | - private function getFieldButton($caption){ |
|
| 253 | - $bt=new HtmlButton("",$caption); |
|
| 254 | - $bt->setProperty("data-ajax",$this->_instanceViewer->getIdentifier()); |
|
| 252 | + private function getFieldButton($caption) { |
|
| 253 | + $bt=new HtmlButton("", $caption); |
|
| 254 | + $bt->setProperty("data-ajax", $this->_instanceViewer->getIdentifier()); |
|
| 255 | 255 | return $bt; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -261,8 +261,8 @@ discard block |
||
| 261 | 261 | * @param callable $callback |
| 262 | 262 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 263 | 263 | */ |
| 264 | - public function addFieldButton($caption,$callback=null){ |
|
| 265 | - $this->addField($this->getFieldButtonCallable($caption,$callback)); |
|
| 264 | + public function addFieldButton($caption, $callback=null) { |
|
| 265 | + $this->addField($this->getFieldButtonCallable($caption, $callback)); |
|
| 266 | 266 | return $this; |
| 267 | 267 | } |
| 268 | 268 | |
@@ -273,8 +273,8 @@ discard block |
||
| 273 | 273 | * @param callable $callback |
| 274 | 274 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 275 | 275 | */ |
| 276 | - public function insertFieldButton($index,$caption,$callback=null){ |
|
| 277 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$callback)); |
|
| 276 | + public function insertFieldButton($index, $caption, $callback=null) { |
|
| 277 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $callback)); |
|
| 278 | 278 | return $this; |
| 279 | 279 | } |
| 280 | 280 | |
@@ -285,55 +285,55 @@ discard block |
||
| 285 | 285 | * @param callable $callback |
| 286 | 286 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 287 | 287 | */ |
| 288 | - public function insertInFieldButton($index,$caption,$callback=null){ |
|
| 289 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$callback)); |
|
| 288 | + public function insertInFieldButton($index, $caption, $callback=null) { |
|
| 289 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $callback)); |
|
| 290 | 290 | return $this; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - private function addDefaultButton($icon,$class=null,$callback=null){ |
|
| 294 | - $bt=$this->getDefaultButton($icon,$class); |
|
| 295 | - $this->addField($this->getCallable($bt,$callback)); |
|
| 293 | + private function addDefaultButton($icon, $class=null, $callback=null) { |
|
| 294 | + $bt=$this->getDefaultButton($icon, $class); |
|
| 295 | + $this->addField($this->getCallable($bt, $callback)); |
|
| 296 | 296 | return $this; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){ |
|
| 300 | - $bt=$this->getDefaultButton($icon,$class); |
|
| 301 | - $this->insertInField($index,$this->getCallable($bt,$callback)); |
|
| 299 | + private function insertDefaultButtonIn($index, $icon, $class=null, $callback=null) { |
|
| 300 | + $bt=$this->getDefaultButton($icon, $class); |
|
| 301 | + $this->insertInField($index, $this->getCallable($bt, $callback)); |
|
| 302 | 302 | return $this; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - private function getDefaultButton($icon,$class=null){ |
|
| 305 | + private function getDefaultButton($icon, $class=null) { |
|
| 306 | 306 | $bt=$this->getFieldButton(""); |
| 307 | 307 | $bt->asIcon($icon); |
| 308 | - if(isset($class)) |
|
| 308 | + if (isset($class)) |
|
| 309 | 309 | $bt->addToProperty("class", $class); |
| 310 | 310 | return $bt; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - public function addDeleteButton($callback=null){ |
|
| 314 | - return $this->addDefaultButton("remove","delete red basic",$callback); |
|
| 313 | + public function addDeleteButton($callback=null) { |
|
| 314 | + return $this->addDefaultButton("remove", "delete red basic", $callback); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - public function addEditButton($callback=null){ |
|
| 318 | - return $this->addDefaultButton("edit","edit basic",$callback); |
|
| 317 | + public function addEditButton($callback=null) { |
|
| 318 | + return $this->addDefaultButton("edit", "edit basic", $callback); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - public function addEditDeleteButtons($callbackEdit=null,$callbackDelete=null){ |
|
| 321 | + public function addEditDeleteButtons($callbackEdit=null, $callbackDelete=null) { |
|
| 322 | 322 | $this->addEditButton($callbackEdit); |
| 323 | 323 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
| 324 | - $this->insertDeleteButtonIn($index,$callbackDelete); |
|
| 324 | + $this->insertDeleteButtonIn($index, $callbackDelete); |
|
| 325 | 325 | return $this; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - public function insertDeleteButtonIn($index,$callback=null){ |
|
| 329 | - return $this->insertDefaultButtonIn($index,"remove","delete red basic",$callback); |
|
| 328 | + public function insertDeleteButtonIn($index, $callback=null) { |
|
| 329 | + return $this->insertDefaultButtonIn($index, "remove", "delete red basic", $callback); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - public function insertEditButtonIn($index,$callback=null){ |
|
| 333 | - return $this->insertDefaultButtonIn($index,"edit","edit basic",$callback); |
|
| 332 | + public function insertEditButtonIn($index, $callback=null) { |
|
| 333 | + return $this->insertDefaultButtonIn($index, "edit", "edit basic", $callback); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - public function setSelectable(){ |
|
| 336 | + public function setSelectable() { |
|
| 337 | 337 | $this->content["table"]->setSelectable(); |
| 338 | 338 | return $this; |
| 339 | 339 | } |
@@ -341,8 +341,8 @@ discard block |
||
| 341 | 341 | /** |
| 342 | 342 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
| 343 | 343 | */ |
| 344 | - public function getToolbar(){ |
|
| 345 | - if(isset($this->_toolbar)===false){ |
|
| 344 | + public function getToolbar() { |
|
| 345 | + if (isset($this->_toolbar)===false) { |
|
| 346 | 346 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
| 347 | 347 | $this->_toolbar->setSecondary(); |
| 348 | 348 | } |
@@ -353,37 +353,37 @@ discard block |
||
| 353 | 353 | * @param unknown $element |
| 354 | 354 | * @return \Ajax\common\html\HtmlDoubleElement |
| 355 | 355 | */ |
| 356 | - public function addInToolbar($element){ |
|
| 356 | + public function addInToolbar($element) { |
|
| 357 | 357 | $tb=$this->getToolbar(); |
| 358 | 358 | return $tb->addItem($element); |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - public function addItemInToolbar($caption,$icon=NULL){ |
|
| 361 | + public function addItemInToolbar($caption, $icon=NULL) { |
|
| 362 | 362 | $result=$this->addInToolbar($caption); |
| 363 | 363 | $result->addIcon($icon); |
| 364 | 364 | return $result; |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - public function addButtonInToolbar($caption){ |
|
| 368 | - $bt=new HtmlButton("",$caption); |
|
| 367 | + public function addButtonInToolbar($caption) { |
|
| 368 | + $bt=new HtmlButton("", $caption); |
|
| 369 | 369 | return $this->addInToolbar($bt); |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
| 373 | - $bt=new HtmlButton("",$caption); |
|
| 374 | - $bt->addIcon($icon,$before,$labeled); |
|
| 372 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
| 373 | + $bt=new HtmlButton("", $caption); |
|
| 374 | + $bt->addIcon($icon, $before, $labeled); |
|
| 375 | 375 | return $this->addInToolbar($bt); |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | |
| 379 | - public function addSearchInToolbar(){ |
|
| 379 | + public function addSearchInToolbar() { |
|
| 380 | 380 | return $this->addInToolbar($this->getSearchField())->setPosition("right"); |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - public function getSearchField(){ |
|
| 384 | - if(isset($this->_searchField)===false){ |
|
| 385 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
| 386 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
| 383 | + public function getSearchField() { |
|
| 384 | + if (isset($this->_searchField)===false) { |
|
| 385 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
| 386 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
| 387 | 387 | } |
| 388 | 388 | return $this->_searchField; |
| 389 | 389 | } |
@@ -393,36 +393,36 @@ discard block |
||
| 393 | 393 | return $this; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - public function fieldAsImage($index,$size=Size::SMALL,$circular=false){ |
|
| 397 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
| 398 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
| 396 | + public function fieldAsImage($index, $size=Size::SMALL, $circular=false) { |
|
| 397 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
| 398 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
| 399 | 399 | return $image; |
| 400 | 400 | } |
| 401 | 401 | ); |
| 402 | 402 | return $this; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - public function fieldAsAvatar($index){ |
|
| 406 | - $this->setValueFunction($index,function($img){return (new HtmlImage("",$img))->asAvatar();}); |
|
| 405 | + public function fieldAsAvatar($index) { |
|
| 406 | + $this->setValueFunction($index, function($img) {return (new HtmlImage("", $img))->asAvatar(); }); |
|
| 407 | 407 | return $this; |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - public function fieldAsRadio($index,$name=NULL){ |
|
| 411 | - $this->setValueFunction($index,function($value)use ($index,$name){ |
|
| 412 | - if(isset($name)===false){ |
|
| 410 | + public function fieldAsRadio($index, $name=NULL) { |
|
| 411 | + $this->setValueFunction($index, function($value)use ($index, $name){ |
|
| 412 | + if (isset($name)===false) { |
|
| 413 | 413 | $name=$this->_instanceViewer->getCaption($index)."[]"; |
| 414 | 414 | } |
| 415 | - $radio=new HtmlRadio($this->_getFieldIdentifier("radio"),$name,$value,$value); |
|
| 415 | + $radio=new HtmlRadio($this->_getFieldIdentifier("radio"), $name, $value, $value); |
|
| 416 | 416 | return $radio; |
| 417 | 417 | } |
| 418 | 418 | ); |
| 419 | 419 | return $this; |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | - public function fieldAsInput($index,$name=NULL,$type="text",$placeholder=""){ |
|
| 423 | - $this->setValueFunction($index,function($value) use($index,$name,$type,$placeholder){ |
|
| 424 | - $input=new HtmlInput($this->_getFieldIdentifier("input"),$type,$value,$placeholder); |
|
| 425 | - if(isset($name)===false){ |
|
| 422 | + public function fieldAsInput($index, $name=NULL, $type="text", $placeholder="") { |
|
| 423 | + $this->setValueFunction($index, function($value) use($index, $name, $type, $placeholder){ |
|
| 424 | + $input=new HtmlInput($this->_getFieldIdentifier("input"), $type, $value, $placeholder); |
|
| 425 | + if (isset($name)===false) { |
|
| 426 | 426 | $name=$this->_instanceViewer->getCaption($index)."[]"; |
| 427 | 427 | } |
| 428 | 428 | $input->getField()->setProperty("name", $name); |
@@ -433,32 +433,32 @@ discard block |
||
| 433 | 433 | return $this; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - public function fieldAsCheckbox($index,$name=NULL){ |
|
| 437 | - $this->setValueFunction($index,function($value) use($index,$name){ |
|
| 438 | - $checkbox=new HtmlCheckbox($this->_getFieldIdentifier("ck"),"",$value); |
|
| 436 | + public function fieldAsCheckbox($index, $name=NULL) { |
|
| 437 | + $this->setValueFunction($index, function($value) use($index, $name){ |
|
| 438 | + $checkbox=new HtmlCheckbox($this->_getFieldIdentifier("ck"), "", $value); |
|
| 439 | 439 | $checkbox->setChecked(JString::isBooleanTrue($value)); |
| 440 | - if(isset($name)===false){ |
|
| 440 | + if (isset($name)===false) { |
|
| 441 | 441 | $name=$this->_instanceViewer->getCaption($index)."[]"; |
| 442 | 442 | } |
| 443 | 443 | $checkbox->getField()->setProperty("name", $name); |
| 444 | - return $checkbox;} |
|
| 444 | + return $checkbox; } |
|
| 445 | 445 | ); |
| 446 | 446 | return $this; |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$name=NULL){ |
|
| 450 | - $this->setValueFunction($index,function($value) use($index,$elements,$multiple,$name){ |
|
| 451 | - $dd=new HtmlDropdown($this->_getFieldIdentifier("dd"),$value,$elements); |
|
| 452 | - if(isset($name)===false){ |
|
| 449 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $name=NULL) { |
|
| 450 | + $this->setValueFunction($index, function($value) use($index, $elements, $multiple, $name){ |
|
| 451 | + $dd=new HtmlDropdown($this->_getFieldIdentifier("dd"), $value, $elements); |
|
| 452 | + if (isset($name)===false) { |
|
| 453 | 453 | $name=$this->_instanceViewer->getCaption($index)."[]"; |
| 454 | 454 | } |
| 455 | - $dd->asSelect($name,$multiple); |
|
| 456 | - return $dd;} |
|
| 455 | + $dd->asSelect($name, $multiple); |
|
| 456 | + return $dd; } |
|
| 457 | 457 | ); |
| 458 | 458 | return $this; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - private function _getFieldIdentifier($prefix){ |
|
| 461 | + private function _getFieldIdentifier($prefix) { |
|
| 462 | 462 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | \ No newline at end of file |
@@ -60,18 +60,21 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | $table->setRowCount(0, \sizeof($captions)); |
| 62 | 62 | $table->setHeaderValues($captions); |
| 63 | - if(isset($this->_compileParts)) |
|
| 64 | - $table->setCompileParts($this->_compileParts); |
|
| 63 | + if(isset($this->_compileParts)) { |
|
| 64 | + $table->setCompileParts($this->_compileParts); |
|
| 65 | + } |
|
| 65 | 66 | if(isset($this->_searchField)){ |
| 66 | - if(isset($js)) |
|
| 67 | - $this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
|
| 67 | + if(isset($js)) { |
|
| 68 | + $this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
|
| 69 | + } |
|
| 68 | 70 | } |
| 69 | 71 | |
| 70 | 72 | $this->_generateContent($table); |
| 71 | 73 | |
| 72 | 74 | if($this->_hasCheckboxes){ |
| 73 | - if($table->hasPart("thead")) |
|
| 74 | - $table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort"); |
|
| 75 | + if($table->hasPart("thead")) { |
|
| 76 | + $table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort"); |
|
| 77 | + } |
|
| 75 | 78 | } |
| 76 | 79 | |
| 77 | 80 | if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
@@ -305,8 +308,9 @@ discard block |
||
| 305 | 308 | private function getDefaultButton($icon,$class=null){ |
| 306 | 309 | $bt=$this->getFieldButton(""); |
| 307 | 310 | $bt->asIcon($icon); |
| 308 | - if(isset($class)) |
|
| 309 | - $bt->addToProperty("class", $class); |
|
| 311 | + if(isset($class)) { |
|
| 312 | + $bt->addToProperty("class", $class); |
|
| 313 | + } |
|
| 310 | 314 | return $bt; |
| 311 | 315 | } |
| 312 | 316 | |
@@ -395,7 +399,9 @@ discard block |
||
| 395 | 399 | |
| 396 | 400 | public function fieldAsImage($index,$size=Size::SMALL,$circular=false){ |
| 397 | 401 | $this->setValueFunction($index,function($img) use($size,$circular){ |
| 398 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
| 402 | + $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular) { |
|
| 403 | + $image->setCircular(); |
|
| 404 | + } |
|
| 399 | 405 | return $image; |
| 400 | 406 | } |
| 401 | 407 | ); |