@@ -15,61 +15,61 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | protected $ajaxTransition; |
| 17 | 17 | |
| 18 | - protected $ajaxLoader = "<div class=\"ui active centered inline text loader\">Loading</div>"; |
|
| 18 | + protected $ajaxLoader="<div class=\"ui active centered inline text loader\">Loading</div>"; |
|
| 19 | 19 | |
| 20 | 20 | abstract public function getUrl($url); |
| 21 | 21 | |
| 22 | - abstract public function _add_event($element, $js, $event, $preventDefault = false, $stopPropagation = false, $immediatly = true); |
|
| 22 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
| 23 | 23 | |
| 24 | - abstract public function interval($jsCode, $time, $globalName = null, $immediatly = true); |
|
| 24 | + abstract public function interval($jsCode, $time, $globalName=null, $immediatly=true); |
|
| 25 | 25 | |
| 26 | - protected function _ajax($method, $url, $responseElement = "", $parameters = []) { |
|
| 26 | + protected function _ajax($method, $url, $responseElement="", $parameters=[]) { |
|
| 27 | 27 | if (isset($this->params["ajax"])) { |
| 28 | 28 | extract($this->params["ajax"]); |
| 29 | 29 | } |
| 30 | 30 | extract($parameters); |
| 31 | 31 | |
| 32 | - $jsCallback = isset($jsCallback) ? $jsCallback : ""; |
|
| 33 | - $retour = $this->_getAjaxUrl($url, $attr); |
|
| 34 | - $originalSelector = $responseElement; |
|
| 35 | - $responseElement = $this->_getResponseElement($responseElement); |
|
| 36 | - $retour .= "var self=this;\n"; |
|
| 37 | - $before = isset($before) ? $before : ""; |
|
| 38 | - $retour .= $before; |
|
| 39 | - if ($hasLoader === true && JString::isNotNull($responseElement)) { |
|
| 32 | + $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
|
| 33 | + $retour=$this->_getAjaxUrl($url, $attr); |
|
| 34 | + $originalSelector=$responseElement; |
|
| 35 | + $responseElement=$this->_getResponseElement($responseElement); |
|
| 36 | + $retour.="var self=this;\n"; |
|
| 37 | + $before=isset($before) ? $before : ""; |
|
| 38 | + $retour.=$before; |
|
| 39 | + if ($hasLoader===true && JString::isNotNull($responseElement)) { |
|
| 40 | 40 | $this->addLoading($retour, $responseElement, $ajaxLoader); |
| 41 | - } elseif ($hasLoader === "internal") { |
|
| 42 | - $retour .= "\n$(this).addClass('loading');"; |
|
| 41 | + } elseif ($hasLoader==="internal") { |
|
| 42 | + $retour.="\n$(this).addClass('loading');"; |
|
| 43 | 43 | } |
| 44 | - $ajaxParameters = [ |
|
| 44 | + $ajaxParameters=[ |
|
| 45 | 45 | "url" => "url", |
| 46 | - "method" => "'" . \strtoupper($method) . "'" |
|
| 46 | + "method" => "'".\strtoupper($method)."'" |
|
| 47 | 47 | ]; |
| 48 | 48 | |
| 49 | - $ajaxParameters["async"] = ($async ? "true" : "false"); |
|
| 49 | + $ajaxParameters["async"]=($async ? "true" : "false"); |
|
| 50 | 50 | |
| 51 | 51 | if (isset($params)) { |
| 52 | - $ajaxParameters["data"] = self::_correctParams($params, $parameters); |
|
| 52 | + $ajaxParameters["data"]=self::_correctParams($params, $parameters); |
|
| 53 | 53 | } |
| 54 | 54 | if (isset($headers)) { |
| 55 | - $ajaxParameters["headers"] = $headers; |
|
| 55 | + $ajaxParameters["headers"]=$headers; |
|
| 56 | 56 | } |
| 57 | 57 | if (isset($partial)) { |
| 58 | - $ajaxParameters["xhr"] = "xhrProvider"; |
|
| 59 | - $retour .= "var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;" . $partial . ";}; };"; |
|
| 58 | + $ajaxParameters["xhr"]="xhrProvider"; |
|
| 59 | + $retour.="var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;".$partial.";}; };"; |
|
| 60 | 60 | } |
| 61 | 61 | $this->createAjaxParameters($ajaxParameters, $parameters); |
| 62 | - $retour .= "$.ajax({" . $this->implodeAjaxParameters($ajaxParameters) . "}).done(function( data, textStatus, jqXHR ) {\n"; |
|
| 63 | - $retour .= $this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null)) . "});\n"; |
|
| 62 | + $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n"; |
|
| 63 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null))."});\n"; |
|
| 64 | 64 | |
| 65 | - $retour = $this->_addJsCondition($jsCondition, $retour); |
|
| 65 | + $retour=$this->_addJsCondition($jsCondition, $retour); |
|
| 66 | 66 | if ($immediatly) |
| 67 | - $this->jquery_code_for_compile[] = $retour; |
|
| 67 | + $this->jquery_code_for_compile[]=$retour; |
|
| 68 | 68 | return $retour; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | protected function createAjaxParameters(&$original, $parameters) { |
| 72 | - $validParameters = [ |
|
| 72 | + $validParameters=[ |
|
| 73 | 73 | "contentType" => "%value%", |
| 74 | 74 | "dataType" => "'%value%'", |
| 75 | 75 | "beforeSend" => "function(jqXHR,settings){%value%}", |
@@ -78,21 +78,21 @@ discard block |
||
| 78 | 78 | ]; |
| 79 | 79 | foreach ($validParameters as $param => $mask) { |
| 80 | 80 | if (isset($parameters[$param])) { |
| 81 | - $original[$param] = \str_replace("%value%", $parameters[$param], $mask); |
|
| 81 | + $original[$param]=\str_replace("%value%", $parameters[$param], $mask); |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | protected function implodeAjaxParameters($ajaxParameters) { |
| 87 | - $s = ''; |
|
| 87 | + $s=''; |
|
| 88 | 88 | foreach ($ajaxParameters as $k => $v) { |
| 89 | - if ($s !== '') { |
|
| 90 | - $s .= ','; |
|
| 89 | + if ($s!=='') { |
|
| 90 | + $s.=','; |
|
| 91 | 91 | } |
| 92 | 92 | if (is_array($v)) { |
| 93 | - $s .= "'{$k}':{" . self::implodeAjaxParameters($v) . "}"; |
|
| 93 | + $s.="'{$k}':{".self::implodeAjaxParameters($v)."}"; |
|
| 94 | 94 | } else { |
| 95 | - $s .= "'{$k}':{$v}"; |
|
| 95 | + $s.="'{$k}':{$v}"; |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | return $s; |
@@ -100,27 +100,27 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | protected function _addJsCondition($jsCondition, $jsSource) { |
| 102 | 102 | if (isset($jsCondition)) { |
| 103 | - return "if(" . $jsCondition . "){\n" . $jsSource . "\n}"; |
|
| 103 | + return "if(".$jsCondition."){\n".$jsSource."\n}"; |
|
| 104 | 104 | } |
| 105 | 105 | return $jsSource; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | protected function _getAjaxUrl($url, $attr) { |
| 109 | - $url = $this->_correctAjaxUrl($url); |
|
| 110 | - $retour = "url='" . $url . "';"; |
|
| 111 | - $slash = "/"; |
|
| 112 | - if (JString::endswith($url, "/") === true) { |
|
| 113 | - $slash = ""; |
|
| 109 | + $url=$this->_correctAjaxUrl($url); |
|
| 110 | + $retour="url='".$url."';"; |
|
| 111 | + $slash="/"; |
|
| 112 | + if (JString::endswith($url, "/")===true) { |
|
| 113 | + $slash=""; |
|
| 114 | 114 | } |
| 115 | 115 | if (JString::isNotNull($attr)) { |
| 116 | - if ($attr === "value") { |
|
| 117 | - $retour .= "url=url+'" . $slash . "'+$(this).val();\n"; |
|
| 118 | - } elseif ($attr === "html") { |
|
| 119 | - $retour .= "url=url+'" . $slash . "'+$(this).html();\n"; |
|
| 120 | - } elseif (\substr($attr, 0, 3) === "js:") { |
|
| 121 | - $retour .= "url=url+'" . $slash . "'+" . \substr($attr, 3) . ";\n"; |
|
| 122 | - } elseif ($attr !== null && $attr !== "") |
|
| 123 | - $retour .= "url=url+'" . $slash . "'+($(this).attr('" . $attr . "')||'');\n"; |
|
| 116 | + if ($attr==="value") { |
|
| 117 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 118 | + } elseif ($attr==="html") { |
|
| 119 | + $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
| 120 | + } elseif (\substr($attr, 0, 3)==="js:") { |
|
| 121 | + $retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n"; |
|
| 122 | + } elseif ($attr!==null && $attr!=="") |
|
| 123 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 124 | 124 | } |
| 125 | 125 | return $retour; |
| 126 | 126 | } |
@@ -129,91 +129,91 @@ discard block |
||
| 129 | 129 | return "window.onpopstate = function(e){if(e.state){var target=e.state.jqueryDone;$(e.state.selector)[target](e.state.html);}};"; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - protected function autoActiveLinks($previousURL = "window.location.href") { |
|
| 133 | - $result = "\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}"; |
|
| 134 | - $result .= "\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;"; |
|
| 132 | + protected function autoActiveLinks($previousURL="window.location.href") { |
|
| 133 | + $result="\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}"; |
|
| 134 | + $result.="\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;"; |
|
| 135 | 135 | return $result; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader = false, $history = null) { |
|
| 139 | - $retour = ""; |
|
| 140 | - $call = null; |
|
| 138 | + protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader=false, $history=null) { |
|
| 139 | + $retour=""; |
|
| 140 | + $call=null; |
|
| 141 | 141 | if (JString::isNotNull($responseElement)) { |
| 142 | 142 | if (isset($ajaxTransition)) { |
| 143 | - $call = $this->setAjaxDataCall($ajaxTransition); |
|
| 143 | + $call=$this->setAjaxDataCall($ajaxTransition); |
|
| 144 | 144 | } elseif (isset($this->ajaxTransition)) { |
| 145 | - $call = $this->ajaxTransition; |
|
| 145 | + $call=$this->ajaxTransition; |
|
| 146 | 146 | } |
| 147 | 147 | if (\is_callable($call)) |
| 148 | - $retour = "\t" . $call($responseElement, $jqueryDone) . ";\n"; |
|
| 148 | + $retour="\t".$call($responseElement, $jqueryDone).";\n"; |
|
| 149 | 149 | else |
| 150 | - $retour = "\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
| 150 | + $retour="\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
| 151 | 151 | } |
| 152 | 152 | if (isset($history)) { |
| 153 | 153 | if ($this->params["autoActiveLinks"]) { |
| 154 | - $retour .= $this->autoActiveLinks("url"); |
|
| 154 | + $retour.=$this->autoActiveLinks("url"); |
|
| 155 | 155 | } |
| 156 | - $retour .= "\nwindow.history.pushState({'html':data,'selector':" . Javascript::prep_value($history) . ",'jqueryDone':'{$jqueryDone}'},'', url);"; |
|
| 156 | + $retour.="\nwindow.history.pushState({'html':data,'selector':".Javascript::prep_value($history).",'jqueryDone':'{$jqueryDone}'},'', url);"; |
|
| 157 | 157 | } |
| 158 | - if ($hasLoader === "internal") { |
|
| 159 | - $retour .= "\n$(self).removeClass('loading');"; |
|
| 158 | + if ($hasLoader==="internal") { |
|
| 159 | + $retour.="\n$(self).removeClass('loading');"; |
|
| 160 | 160 | } |
| 161 | - $retour .= "\t" . $jsCallback . "\n"; |
|
| 161 | + $retour.="\t".$jsCallback."\n"; |
|
| 162 | 162 | return $retour; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | protected function _getResponseElement($responseElement) { |
| 166 | 166 | if (JString::isNotNull($responseElement)) { |
| 167 | - $responseElement = Javascript::prep_jquery_selector($responseElement); |
|
| 167 | + $responseElement=Javascript::prep_jquery_selector($responseElement); |
|
| 168 | 168 | } |
| 169 | 169 | return $responseElement; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | protected function _correctAjaxUrl($url) { |
| 173 | - if ($url !== "/" && JString::endsWith($url, "/") === true) |
|
| 174 | - $url = substr($url, 0, strlen($url) - 1); |
|
| 175 | - if (strncmp($url, 'http://', 7) != 0 && strncmp($url, 'https://', 8) != 0) { |
|
| 176 | - $url = $this->getUrl($url); |
|
| 173 | + if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
| 174 | + $url=substr($url, 0, strlen($url)-1); |
|
| 175 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
| 176 | + $url=$this->getUrl($url); |
|
| 177 | 177 | } |
| 178 | 178 | return $url; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - public static function _correctParams($params, $ajaxParameters = []) { |
|
| 181 | + public static function _correctParams($params, $ajaxParameters=[]) { |
|
| 182 | 182 | if (JString::isNull($params)) { |
| 183 | 183 | return ""; |
| 184 | 184 | } |
| 185 | 185 | if (\preg_match("@^\{.*?\}$@", $params)) { |
| 186 | - if (! isset($ajaxParameters['contentType']) || ! JString::contains($ajaxParameters['contentType'], 'json')) { |
|
| 187 | - return '$.param(' . $params . ')'; |
|
| 186 | + if (!isset($ajaxParameters['contentType']) || !JString::contains($ajaxParameters['contentType'], 'json')) { |
|
| 187 | + return '$.param('.$params.')'; |
|
| 188 | 188 | } else { |
| 189 | - return 'JSON.stringify(' . $params . ')'; |
|
| 189 | + return 'JSON.stringify('.$params.')'; |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | return $params; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | public static function _implodeParams($parameters) { |
| 196 | - $allParameters = []; |
|
| 196 | + $allParameters=[]; |
|
| 197 | 197 | foreach ($parameters as $params) { |
| 198 | 198 | if (isset($params)) |
| 199 | - $allParameters[] = self::_correctParams($params); |
|
| 199 | + $allParameters[]=self::_correctParams($params); |
|
| 200 | 200 | } |
| 201 | 201 | return \implode("+'&'+", $allParameters); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - protected function addLoading(&$retour, $responseElement, $ajaxLoader = null) { |
|
| 205 | - if (! isset($ajaxLoader)) { |
|
| 206 | - $ajaxLoader = $this->ajaxLoader; |
|
| 204 | + protected function addLoading(&$retour, $responseElement, $ajaxLoader=null) { |
|
| 205 | + if (!isset($ajaxLoader)) { |
|
| 206 | + $ajaxLoader=$this->ajaxLoader; |
|
| 207 | 207 | } |
| 208 | - $loading_notifier = '<div class="ajax-loader">' . $ajaxLoader . '</div>'; |
|
| 209 | - $retour .= "{$responseElement}.empty();\n"; |
|
| 210 | - $retour .= "\t\t{$responseElement}.prepend('{$loading_notifier}');\n"; |
|
| 208 | + $loading_notifier='<div class="ajax-loader">'.$ajaxLoader.'</div>'; |
|
| 209 | + $retour.="{$responseElement}.empty();\n"; |
|
| 210 | + $retour.="\t\t{$responseElement}.prepend('{$loading_notifier}');\n"; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | protected function setAjaxDataCall($params) { |
| 214 | - $result = null; |
|
| 215 | - if (! \is_callable($params)) { |
|
| 216 | - $result = function ($responseElement, $jqueryDone = "html") use ($params) { |
|
| 214 | + $result=null; |
|
| 215 | + if (!\is_callable($params)) { |
|
| 216 | + $result=function($responseElement, $jqueryDone="html") use ($params) { |
|
| 217 | 217 | return AjaxTransition::{$params}($responseElement, $jqueryDone); |
| 218 | 218 | }; |
| 219 | 219 | } |
@@ -222,13 +222,13 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | protected function setDefaultParameters(&$parameters, $default) { |
| 224 | 224 | foreach ($default as $k => $v) { |
| 225 | - if (! isset($parameters[$k])) |
|
| 226 | - $parameters[$k] = $v; |
|
| 225 | + if (!isset($parameters[$k])) |
|
| 226 | + $parameters[$k]=$v; |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | public function setAjaxLoader($loader) { |
| 231 | - $this->ajaxLoader = $loader; |
|
| 231 | + $this->ajaxLoader=$loader; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | /** |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * @param string $responseElement |
| 240 | 240 | * selector of the HTML element displaying the answer |
| 241 | 241 | */ |
| 242 | - private function _get($url, $responseElement = "", $parameters = []) { |
|
| 242 | + private function _get($url, $responseElement="", $parameters=[]) { |
|
| 243 | 243 | return $this->_ajax("get", $url, $responseElement, $parameters); |
| 244 | 244 | } |
| 245 | 245 | |
@@ -253,8 +253,8 @@ discard block |
||
| 253 | 253 | * @param array $parameters |
| 254 | 254 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 255 | 255 | */ |
| 256 | - public function get($url, $responseElement = "", $parameters = []) { |
|
| 257 | - $parameters["immediatly"] = true; |
|
| 256 | + public function get($url, $responseElement="", $parameters=[]) { |
|
| 257 | + $parameters["immediatly"]=true; |
|
| 258 | 258 | return $this->_get($url, $responseElement, $parameters); |
| 259 | 259 | } |
| 260 | 260 | |
@@ -270,8 +270,8 @@ discard block |
||
| 270 | 270 | * @param array $parameters |
| 271 | 271 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 272 | 272 | */ |
| 273 | - public function ajax($method, $url, $responseElement = "", $parameters = []) { |
|
| 274 | - $parameters["immediatly"] = true; |
|
| 273 | + public function ajax($method, $url, $responseElement="", $parameters=[]) { |
|
| 274 | + $parameters["immediatly"]=true; |
|
| 275 | 275 | return $this->_ajax($method, $url, $responseElement, $parameters); |
| 276 | 276 | } |
| 277 | 277 | |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * $immediatly |
| 294 | 294 | * @return string |
| 295 | 295 | */ |
| 296 | - public function ajaxInterval($method, $url, $interval, $globalName = null, $responseElement = "", $parameters = [], $immediatly = true) { |
|
| 296 | + public function ajaxInterval($method, $url, $interval, $globalName=null, $responseElement="", $parameters=[], $immediatly=true) { |
|
| 297 | 297 | return $this->interval($this->ajaxDeferred($method, $url, $responseElement, $parameters), $interval, $globalName, $immediatly); |
| 298 | 298 | } |
| 299 | 299 | |
@@ -309,8 +309,8 @@ discard block |
||
| 309 | 309 | * @param array $parameters |
| 310 | 310 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 311 | 311 | */ |
| 312 | - public function ajaxDeferred($method, $url, $responseElement = "", $parameters = []) { |
|
| 313 | - $parameters["immediatly"] = false; |
|
| 312 | + public function ajaxDeferred($method, $url, $responseElement="", $parameters=[]) { |
|
| 313 | + $parameters["immediatly"]=false; |
|
| 314 | 314 | return $this->_ajax($method, $url, $responseElement, $parameters); |
| 315 | 315 | } |
| 316 | 316 | |
@@ -324,15 +324,15 @@ discard block |
||
| 324 | 324 | * @param array $parameters |
| 325 | 325 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null) |
| 326 | 326 | */ |
| 327 | - private function _json($url, $method = "get", $parameters = []) { |
|
| 328 | - $parameters = \array_merge($parameters, [ |
|
| 327 | + private function _json($url, $method="get", $parameters=[]) { |
|
| 328 | + $parameters=\array_merge($parameters, [ |
|
| 329 | 329 | "hasLoader" => false |
| 330 | 330 | ]); |
| 331 | - $jsCallback = isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
| 332 | - $context = isset($parameters['context']) ? $parameters['context'] : "document"; |
|
| 333 | - $retour = "\tdata=($.isPlainObject(data))?data:JSON.parse(data);\t" . $jsCallback . ";" . "\n\tfor(var key in data){" . "if($('#'+key," . $context . ").length){ if($('#'+key," . $context . ").is('[value]')) { $('#'+key," . $context . ").val(data[key]);} else { $('#'+key," . $context . ").html(data[key]); }}};\n"; |
|
| 334 | - $retour .= "\t$(document).trigger('jsonReady',[data]);\n"; |
|
| 335 | - $parameters["jsCallback"] = $retour; |
|
| 331 | + $jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
| 332 | + $context=isset($parameters['context']) ? $parameters['context'] : "document"; |
|
| 333 | + $retour="\tdata=($.isPlainObject(data))?data:JSON.parse(data);\t".$jsCallback.";"."\n\tfor(var key in data){"."if($('#'+key,".$context.").length){ if($('#'+key,".$context.").is('[value]')) { $('#'+key,".$context.").val(data[key]);} else { $('#'+key,".$context.").html(data[key]); }}};\n"; |
|
| 334 | + $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
|
| 335 | + $parameters["jsCallback"]=$retour; |
|
| 336 | 336 | return $this->_ajax($method, $url, null, $parameters); |
| 337 | 337 | } |
| 338 | 338 | |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | * @param array $parameters |
| 347 | 347 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null) |
| 348 | 348 | */ |
| 349 | - public function json($url, $method = "get", $parameters = []) { |
|
| 349 | + public function json($url, $method="get", $parameters=[]) { |
|
| 350 | 350 | return $this->_json($url, $method, $parameters); |
| 351 | 351 | } |
| 352 | 352 | |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | * @param array $parameters |
| 363 | 363 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true,"before"=>null) |
| 364 | 364 | */ |
| 365 | - public function jsonOn($event, $element, $url, $method = "get", $parameters = array()) { |
|
| 365 | + public function jsonOn($event, $element, $url, $method="get", $parameters=array()) { |
|
| 366 | 366 | $this->setDefaultParameters($parameters, [ |
| 367 | 367 | "preventDefault" => true, |
| 368 | 368 | "stopPropagation" => true, |
@@ -381,8 +381,8 @@ discard block |
||
| 381 | 381 | * @param array $parameters |
| 382 | 382 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null) |
| 383 | 383 | */ |
| 384 | - public function jsonDeferred($url, $method = "get", $parameters = []) { |
|
| 385 | - $parameters["immediatly"] = false; |
|
| 384 | + public function jsonDeferred($url, $method="get", $parameters=[]) { |
|
| 385 | + $parameters["immediatly"]=false; |
|
| 386 | 386 | return $this->_json($url, $method, $parameters); |
| 387 | 387 | } |
| 388 | 388 | |
@@ -397,29 +397,29 @@ discard block |
||
| 397 | 397 | * @param array $parameters |
| 398 | 398 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json","before"=>null) |
| 399 | 399 | */ |
| 400 | - private function _jsonArray($maskSelector, $url, $method = "get", $parameters = []) { |
|
| 401 | - $parameters = \array_merge($parameters, [ |
|
| 400 | + private function _jsonArray($maskSelector, $url, $method="get", $parameters=[]) { |
|
| 401 | + $parameters=\array_merge($parameters, [ |
|
| 402 | 402 | "hasLoader" => false |
| 403 | 403 | ]); |
| 404 | - $rowClass = isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json"; |
|
| 405 | - $jsCallback = isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
| 406 | - $context = isset($parameters['context']) ? $parameters['context'] : null; |
|
| 407 | - if ($context === null) { |
|
| 408 | - $parent = "$('" . $maskSelector . "').parent()"; |
|
| 409 | - $newElm = "$('#'+newId)"; |
|
| 404 | + $rowClass=isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json"; |
|
| 405 | + $jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
| 406 | + $context=isset($parameters['context']) ? $parameters['context'] : null; |
|
| 407 | + if ($context===null) { |
|
| 408 | + $parent="$('".$maskSelector."').parent()"; |
|
| 409 | + $newElm="$('#'+newId)"; |
|
| 410 | 410 | } else { |
| 411 | - $parent = $context; |
|
| 412 | - $newElm = $context . ".find('#'+newId)"; |
|
| 411 | + $parent=$context; |
|
| 412 | + $newElm=$context.".find('#'+newId)"; |
|
| 413 | 413 | } |
| 414 | - $appendTo = "\t\tnewElm.appendTo(" . $parent . ");\n"; |
|
| 415 | - $retour = $parent . ".find('.{$rowClass}').remove();"; |
|
| 416 | - $retour .= "\tdata=($.isPlainObject(data)||$.isArray(data))?data:JSON.parse(data);\n$.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(); |
|
| 414 | + $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
|
| 415 | + $retour=$parent.".find('.{$rowClass}').remove();"; |
|
| 416 | + $retour.="\tdata=($.isPlainObject(data)||$.isArray(data))?data:JSON.parse(data);\n$.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(); |
|
| 417 | 417 | newElm.attr('id',newId);\n;newElm.addClass('{$rowClass}').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n"; |
| 418 | - $retour .= $appendTo; |
|
| 419 | - $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"; |
|
| 420 | - $retour .= "\t$(document).trigger('jsonReady',[data]);\n"; |
|
| 421 | - $retour .= "\t" . $jsCallback; |
|
| 422 | - $parameters["jsCallback"] = $retour; |
|
| 418 | + $retour.=$appendTo; |
|
| 419 | + $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"; |
|
| 420 | + $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
|
| 421 | + $retour.="\t".$jsCallback; |
|
| 422 | + $parameters["jsCallback"]=$retour; |
|
| 423 | 423 | return $this->_ajax($method, $url, null, $parameters); |
| 424 | 424 | } |
| 425 | 425 | |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | * @param array $parameters |
| 435 | 435 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json","before"=>null) |
| 436 | 436 | */ |
| 437 | - public function jsonArray($maskSelector, $url, $method = "get", $parameters = []) { |
|
| 437 | + public function jsonArray($maskSelector, $url, $method="get", $parameters=[]) { |
|
| 438 | 438 | return $this->_jsonArray($maskSelector, $url, $method, $parameters); |
| 439 | 439 | } |
| 440 | 440 | |
@@ -449,8 +449,8 @@ discard block |
||
| 449 | 449 | * @param array $parameters |
| 450 | 450 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"rowClass"=>"_json","before"=>null) |
| 451 | 451 | */ |
| 452 | - public function jsonArrayDeferred($maskSelector, $url, $method = "get", $parameters) { |
|
| 453 | - $parameters["immediatly"] = false; |
|
| 452 | + public function jsonArrayDeferred($maskSelector, $url, $method="get", $parameters) { |
|
| 453 | + $parameters["immediatly"]=false; |
|
| 454 | 454 | return $this->jsonArray($maskSelector, $url, $method, $parameters); |
| 455 | 455 | } |
| 456 | 456 | |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | * @param array $parameters |
| 467 | 467 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true,"before"=>null) |
| 468 | 468 | */ |
| 469 | - public function jsonArrayOn($event, $element, $maskSelector, $url, $method = "get", $parameters = array()) { |
|
| 469 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $method="get", $parameters=array()) { |
|
| 470 | 470 | $this->setDefaultParameters($parameters, [ |
| 471 | 471 | "preventDefault" => true, |
| 472 | 472 | "stopPropagation" => true, |
@@ -486,8 +486,8 @@ discard block |
||
| 486 | 486 | * @param array $parameters |
| 487 | 487 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 488 | 488 | */ |
| 489 | - public function getDeferred($url, $responseElement = "", $parameters = []) { |
|
| 490 | - $parameters["immediatly"] = false; |
|
| 489 | + public function getDeferred($url, $responseElement="", $parameters=[]) { |
|
| 490 | + $parameters["immediatly"]=false; |
|
| 491 | 491 | return $this->_get($url, $responseElement, $parameters); |
| 492 | 492 | } |
| 493 | 493 | |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | * @param array $parameters |
| 507 | 507 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false,"before"=>null) |
| 508 | 508 | */ |
| 509 | - public function getOn($event, $element, $url, $responseElement = "", $parameters = array()) { |
|
| 509 | + public function getOn($event, $element, $url, $responseElement="", $parameters=array()) { |
|
| 510 | 510 | $this->setDefaultParameters($parameters, [ |
| 511 | 511 | "preventDefault" => true, |
| 512 | 512 | "stopPropagation" => true, |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | * @param array $parameters |
| 531 | 531 | * default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 532 | 532 | */ |
| 533 | - public function ajaxOn($event, $element, $url, $responseElement = "", $parameters = array()) { |
|
| 533 | + public function ajaxOn($event, $element, $url, $responseElement="", $parameters=array()) { |
|
| 534 | 534 | $this->setDefaultParameters($parameters, [ |
| 535 | 535 | "preventDefault" => true, |
| 536 | 536 | "stopPropagation" => true, |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | * @param array $parameters |
| 554 | 554 | * default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 555 | 555 | */ |
| 556 | - public function ajaxOnClick($element, $url, $responseElement = "", $parameters = array()) { |
|
| 556 | + public function ajaxOnClick($element, $url, $responseElement="", $parameters=array()) { |
|
| 557 | 557 | return $this->ajaxOn("click", $element, $url, $responseElement, $parameters); |
| 558 | 558 | } |
| 559 | 559 | |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | * @param array $parameters |
| 571 | 571 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 572 | 572 | */ |
| 573 | - public function getOnClick($element, $url, $responseElement = "", $parameters = array()) { |
|
| 573 | + public function getOnClick($element, $url, $responseElement="", $parameters=array()) { |
|
| 574 | 574 | return $this->getOn("click", $element, $url, $responseElement, $parameters); |
| 575 | 575 | } |
| 576 | 576 | |
@@ -585,15 +585,15 @@ discard block |
||
| 585 | 585 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null) |
| 586 | 586 | * @return $this |
| 587 | 587 | */ |
| 588 | - public function getHref($element, $responseElement = "", $parameters = array()) { |
|
| 589 | - $parameters["attr"] = "href"; |
|
| 588 | + public function getHref($element, $responseElement="", $parameters=array()) { |
|
| 589 | + $parameters["attr"]="href"; |
|
| 590 | 590 | if (JString::isNull($responseElement)) { |
| 591 | - $responseElement = '%$(self).attr("data-target")%'; |
|
| 591 | + $responseElement='%$(self).attr("data-target")%'; |
|
| 592 | 592 | } else { |
| 593 | - $responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%'; |
|
| 593 | + $responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%'; |
|
| 594 | 594 | } |
| 595 | - if (! isset($parameters["historize"])) { |
|
| 596 | - $parameters["historize"] = true; |
|
| 595 | + if (!isset($parameters["historize"])) { |
|
| 596 | + $parameters["historize"]=true; |
|
| 597 | 597 | } |
| 598 | 598 | return $this->getOnClick($element, "", $responseElement, $parameters); |
| 599 | 599 | } |
@@ -609,21 +609,21 @@ discard block |
||
| 609 | 609 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null) |
| 610 | 610 | * @return $this |
| 611 | 611 | */ |
| 612 | - public function postHref($element, $responseElement = "", $parameters = array()) { |
|
| 613 | - $parameters["attr"] = "href"; |
|
| 612 | + public function postHref($element, $responseElement="", $parameters=array()) { |
|
| 613 | + $parameters["attr"]="href"; |
|
| 614 | 614 | if (JString::isNull($responseElement)) { |
| 615 | - $responseElement = '%$(this).attr("data-target")%'; |
|
| 615 | + $responseElement='%$(this).attr("data-target")%'; |
|
| 616 | 616 | } else { |
| 617 | - $responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%'; |
|
| 617 | + $responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%'; |
|
| 618 | 618 | } |
| 619 | - if (! isset($parameters["historize"])) { |
|
| 620 | - $parameters["historize"] = true; |
|
| 619 | + if (!isset($parameters["historize"])) { |
|
| 620 | + $parameters["historize"]=true; |
|
| 621 | 621 | } |
| 622 | 622 | return $this->postOnClick($element, "", "{}", $responseElement, $parameters); |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | - private function _post($url, $params = "{}", $responseElement = "", $parameters = []) { |
|
| 626 | - $parameters["params"] = $params; |
|
| 625 | + private function _post($url, $params="{}", $responseElement="", $parameters=[]) { |
|
| 626 | + $parameters["params"]=$params; |
|
| 627 | 627 | return $this->_ajax("POST", $url, $responseElement, $parameters); |
| 628 | 628 | } |
| 629 | 629 | |
@@ -639,8 +639,8 @@ discard block |
||
| 639 | 639 | * @param array $parameters |
| 640 | 640 | * default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 641 | 641 | */ |
| 642 | - public function post($url, $params = "{}", $responseElement = "", $parameters = []) { |
|
| 643 | - $parameters['immediatly'] = true; |
|
| 642 | + public function post($url, $params="{}", $responseElement="", $parameters=[]) { |
|
| 643 | + $parameters['immediatly']=true; |
|
| 644 | 644 | return $this->_post($url, $params, $responseElement, $parameters); |
| 645 | 645 | } |
| 646 | 646 | |
@@ -657,8 +657,8 @@ discard block |
||
| 657 | 657 | * @param array $parameters |
| 658 | 658 | * default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 659 | 659 | */ |
| 660 | - public function postDeferred($url, $params = "{}", $responseElement = "", $parameters = []) { |
|
| 661 | - $parameters["immediatly"] = false; |
|
| 660 | + public function postDeferred($url, $params="{}", $responseElement="", $parameters=[]) { |
|
| 661 | + $parameters["immediatly"]=false; |
|
| 662 | 662 | return $this->_post($url, $params, $responseElement, $parameters); |
| 663 | 663 | } |
| 664 | 664 | |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | * @param array $parameters |
| 678 | 678 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 679 | 679 | */ |
| 680 | - public function postOn($event, $element, $url, $params = "{}", $responseElement = "", $parameters = array()) { |
|
| 680 | + public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 681 | 681 | $this->setDefaultParameters($parameters, [ |
| 682 | 682 | "preventDefault" => true, |
| 683 | 683 | "stopPropagation" => true, |
@@ -700,64 +700,64 @@ discard block |
||
| 700 | 700 | * @param array $parameters |
| 701 | 701 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"before"=>null) |
| 702 | 702 | */ |
| 703 | - public function postOnClick($element, $url, $params = "{}", $responseElement = "", $parameters = array()) { |
|
| 703 | + public function postOnClick($element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 704 | 704 | return $this->postOn("click", $element, $url, $params, $responseElement, $parameters); |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | - private function _postForm($url, $form, $responseElement, $parameters = []) { |
|
| 707 | + private function _postForm($url, $form, $responseElement, $parameters=[]) { |
|
| 708 | 708 | if (isset($this->params["ajax"])) { |
| 709 | 709 | extract($this->params["ajax"]); |
| 710 | 710 | } |
| 711 | - $params = "{}"; |
|
| 712 | - $validation = false; |
|
| 711 | + $params="{}"; |
|
| 712 | + $validation=false; |
|
| 713 | 713 | \extract($parameters); |
| 714 | - $async = ($async) ? "true" : "false"; |
|
| 715 | - $jsCallback = isset($jsCallback) ? $jsCallback : ""; |
|
| 716 | - $retour = $this->_getAjaxUrl($url, $attr); |
|
| 717 | - $retour .= "\n$('#" . $form . "').trigger('ajaxSubmit');"; |
|
| 718 | - if (! isset($contentType) || $contentType != 'false') { |
|
| 719 | - $retour .= "\nvar params=$('#" . $form . "').serialize();\n"; |
|
| 714 | + $async=($async) ? "true" : "false"; |
|
| 715 | + $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
|
| 716 | + $retour=$this->_getAjaxUrl($url, $attr); |
|
| 717 | + $retour.="\n$('#".$form."').trigger('ajaxSubmit');"; |
|
| 718 | + if (!isset($contentType) || $contentType!='false') { |
|
| 719 | + $retour.="\nvar params=$('#".$form."').serialize();\n"; |
|
| 720 | 720 | if (isset($params)) { |
| 721 | - $retour .= "params+='&'+" . self::_correctParams($params) . ";\n"; |
|
| 721 | + $retour.="params+='&'+".self::_correctParams($params).";\n"; |
|
| 722 | 722 | } |
| 723 | 723 | } else { |
| 724 | - $retour .= "\nvar params=new FormData($('#" . $form . "')[0]);\n"; |
|
| 724 | + $retour.="\nvar params=new FormData($('#".$form."')[0]);\n"; |
|
| 725 | 725 | } |
| 726 | - $responseElement = $this->_getResponseElement($responseElement); |
|
| 727 | - $retour .= "var self=this;\n"; |
|
| 728 | - $before = isset($before) ? $before : ""; |
|
| 729 | - $retour .= $before; |
|
| 730 | - if ($hasLoader === true) { |
|
| 726 | + $responseElement=$this->_getResponseElement($responseElement); |
|
| 727 | + $retour.="var self=this;\n"; |
|
| 728 | + $before=isset($before) ? $before : ""; |
|
| 729 | + $retour.=$before; |
|
| 730 | + if ($hasLoader===true) { |
|
| 731 | 731 | $this->addLoading($retour, $responseElement, $ajaxLoader); |
| 732 | - } elseif ($hasLoader === "internal") { |
|
| 733 | - $retour .= "\n$(this).addClass('loading');"; |
|
| 732 | + } elseif ($hasLoader==="internal") { |
|
| 733 | + $retour.="\n$(this).addClass('loading');"; |
|
| 734 | 734 | } |
| 735 | - $ajaxParameters = [ |
|
| 735 | + $ajaxParameters=[ |
|
| 736 | 736 | "url" => "url", |
| 737 | 737 | "method" => "'POST'", |
| 738 | 738 | "data" => "params", |
| 739 | 739 | "async" => $async |
| 740 | 740 | ]; |
| 741 | 741 | if (isset($headers)) { |
| 742 | - $ajaxParameters["headers"] = $headers; |
|
| 742 | + $ajaxParameters["headers"]=$headers; |
|
| 743 | 743 | } |
| 744 | 744 | if (isset($partial)) { |
| 745 | - $ajaxParameters["xhr"] = "xhrProvider"; |
|
| 746 | - $retour .= "var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;" . $partial . ";}; };"; |
|
| 745 | + $ajaxParameters["xhr"]="xhrProvider"; |
|
| 746 | + $retour.="var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;".$partial.";}; };"; |
|
| 747 | 747 | } |
| 748 | 748 | $this->createAjaxParameters($ajaxParameters, $parameters); |
| 749 | - $retour .= "$.ajax({" . $this->implodeAjaxParameters($ajaxParameters) . "}).done(function( data ) {\n"; |
|
| 750 | - $retour .= $this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader) . "});\n"; |
|
| 749 | + $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data ) {\n"; |
|
| 750 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader)."});\n"; |
|
| 751 | 751 | |
| 752 | 752 | if ($validation) { |
| 753 | - $retour = "$('#" . $form . "').validate({submitHandler: function(form) { |
|
| 754 | - " . $retour . " |
|
| 753 | + $retour="$('#".$form."').validate({submitHandler: function(form) { |
|
| 754 | + " . $retour." |
|
| 755 | 755 | }});\n"; |
| 756 | - $retour .= "$('#" . $form . "').submit();\n"; |
|
| 756 | + $retour.="$('#".$form."').submit();\n"; |
|
| 757 | 757 | } |
| 758 | - $retour = $this->_addJsCondition($jsCondition, $retour); |
|
| 758 | + $retour=$this->_addJsCondition($jsCondition, $retour); |
|
| 759 | 759 | if ($immediatly) |
| 760 | - $this->jquery_code_for_compile[] = $retour; |
|
| 760 | + $this->jquery_code_for_compile[]=$retour; |
|
| 761 | 761 | return $retour; |
| 762 | 762 | } |
| 763 | 763 | |
@@ -773,8 +773,8 @@ discard block |
||
| 773 | 773 | * @param array $parameters |
| 774 | 774 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 775 | 775 | */ |
| 776 | - public function postForm($url, $form, $responseElement, $parameters = []) { |
|
| 777 | - $parameters["immediatly"] = true; |
|
| 776 | + public function postForm($url, $form, $responseElement, $parameters=[]) { |
|
| 777 | + $parameters["immediatly"]=true; |
|
| 778 | 778 | return $this->_postForm($url, $form, $responseElement, $parameters); |
| 779 | 779 | } |
| 780 | 780 | |
@@ -791,8 +791,8 @@ discard block |
||
| 791 | 791 | * @param array $parameters |
| 792 | 792 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 793 | 793 | */ |
| 794 | - public function postFormDeferred($url, $form, $responseElement, $parameters = []) { |
|
| 795 | - $parameters["immediatly"] = false; |
|
| 794 | + public function postFormDeferred($url, $form, $responseElement, $parameters=[]) { |
|
| 795 | + $parameters["immediatly"]=false; |
|
| 796 | 796 | return $this->_postForm($url, $form, $responseElement, $parameters); |
| 797 | 797 | } |
| 798 | 798 | |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | * @param array $parameters |
| 810 | 810 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false,"before"=>null) |
| 811 | 811 | */ |
| 812 | - public function postFormOn($event, $element, $url, $form, $responseElement = "", $parameters = array()) { |
|
| 812 | + public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 813 | 813 | $this->setDefaultParameters($parameters, [ |
| 814 | 814 | "preventDefault" => true, |
| 815 | 815 | "stopPropagation" => true, |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | * @param array $parameters |
| 831 | 831 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false,"before"=>null) |
| 832 | 832 | */ |
| 833 | - public function postFormOnClick($element, $url, $form, $responseElement = "", $parameters = array()) { |
|
| 833 | + public function postFormOnClick($element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 834 | 834 | return $this->postFormOn("click", $element, $url, $form, $responseElement, $parameters); |
| 835 | 835 | } |
| 836 | 836 | } |
@@ -10,9 +10,9 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | trait TableTrait { |
| 12 | 12 | |
| 13 | - abstract public function addEvent($event, $jsCode, $stopPropagation = false, $preventDefault = false); |
|
| 13 | + abstract public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false); |
|
| 14 | 14 | |
| 15 | - abstract public function getOn($event, $url, $responseElement = "", $parameters = array()); |
|
| 15 | + abstract public function getOn($event, $url, $responseElement="", $parameters=array()); |
|
| 16 | 16 | |
| 17 | 17 | protected function addToPropertyTable($property, $value) { |
| 18 | 18 | return $this->_self->addToProperty($property, $value); |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | return $this->addToPropertyTable("class", "celled"); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function setBasic($very = false) { |
|
| 26 | - $table = $this->_self; |
|
| 25 | + public function setBasic($very=false) { |
|
| 26 | + $table=$this->_self; |
|
| 27 | 27 | if ($very) |
| 28 | 28 | $table->addToPropertyCtrl("class", "very", array( |
| 29 | 29 | "very" |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | )); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function setCompact($very = false) { |
|
| 37 | - $table = $this->_self; |
|
| 36 | + public function setCompact($very=false) { |
|
| 37 | + $table=$this->_self; |
|
| 38 | 38 | if ($very) |
| 39 | 39 | $table->addToPropertyCtrl("class", "very", array( |
| 40 | 40 | "very" |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | return $this->addToPropertyTable("class", "structured"); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - public function setSortable($colIndex = NULL) { |
|
| 60 | - $table = $this->_self; |
|
| 59 | + public function setSortable($colIndex=NULL) { |
|
| 60 | + $table=$this->_self; |
|
| 61 | 61 | if (isset($colIndex) && $table->hasPart("thead")) { |
| 62 | 62 | $table->getHeader()->sort($colIndex); |
| 63 | 63 | } |
@@ -80,29 +80,29 @@ discard block |
||
| 80 | 80 | return $this->addToPropertyTable("class", "striped"); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - public function onRowClick($jsCode, $stopPropagation = false, $preventDefault = false) { |
|
| 83 | + public function onRowClick($jsCode, $stopPropagation=false, $preventDefault=false) { |
|
| 84 | 84 | return $this->onRow("click", $jsCode, $stopPropagation, $preventDefault); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public function onRow($event, $jsCode, $stopPropagation = false, $preventDefault = false) { |
|
| 88 | - return $this->_self->addEvent($event . "{{tbody tr}}", $jsCode, $stopPropagation, $preventDefault); |
|
| 87 | + public function onRow($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
|
| 88 | + return $this->_self->addEvent($event."{{tbody tr}}", $jsCode, $stopPropagation, $preventDefault); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - public function getOnRow($event, $url, $responseElement = "", $parameters = array()) { |
|
| 92 | - $jsCondition = '!$(this).closest("tr").hasClass("active")'; |
|
| 91 | + public function getOnRow($event, $url, $responseElement="", $parameters=array()) { |
|
| 92 | + $jsCondition='!$(this).closest("tr").hasClass("active")'; |
|
| 93 | 93 | if (isset($parameters['jsCondition'])) { |
| 94 | - $jsCondition = '(' . $parameters['jsCondition'] . ' && ' . $jsCondition . ')'; |
|
| 94 | + $jsCondition='('.$parameters['jsCondition'].' && '.$jsCondition.')'; |
|
| 95 | 95 | } |
| 96 | - $parameters = \array_merge($parameters, [ |
|
| 96 | + $parameters=\array_merge($parameters, [ |
|
| 97 | 97 | "stopPropagation" => false, |
| 98 | 98 | "preventDefault" => false, |
| 99 | 99 | "jsCondition" => $jsCondition |
| 100 | 100 | ]); |
| 101 | - $selector = "tbody tr"; |
|
| 101 | + $selector="tbody tr"; |
|
| 102 | 102 | if (isset($parameters["selector"])) { |
| 103 | - $selector = $parameters["selector"]; |
|
| 103 | + $selector=$parameters["selector"]; |
|
| 104 | 104 | } |
| 105 | - return $this->_self->getOn($event . "{{" . $selector . "}}", $url, $responseElement, $parameters); |
|
| 105 | + return $this->_self->getOn($event."{{".$selector."}}", $url, $responseElement, $parameters); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | public function onPageChange($jsCode) { |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | return $this->_self->getBsComponent()->getScript(); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public function addEventsOnRun(JsUtils $js = NULL) { |
|
| 123 | - $script = parent::addEventsOnRun($js); |
|
| 124 | - $innerScript = $this->_self->getInnerScript(); |
|
| 125 | - if (! isset($innerScript)) { |
|
| 122 | + public function addEventsOnRun(JsUtils $js=NULL) { |
|
| 123 | + $script=parent::addEventsOnRun($js); |
|
| 124 | + $innerScript=$this->_self->getInnerScript(); |
|
| 125 | + if (!isset($innerScript)) { |
|
| 126 | 126 | $this->_self->setInnerScript($script); |
| 127 | 127 | } |
| 128 | 128 | return $script; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | */ |
| 26 | 26 | class DataTable extends Widget { |
| 27 | - use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait; |
|
| 27 | + use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait; |
|
| 28 | 28 | |
| 29 | 29 | protected $_searchField; |
| 30 | 30 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | protected $_displayBehavior; |
| 42 | 42 | |
| 43 | - protected $_visibleHover = false; |
|
| 43 | + protected $_visibleHover=false; |
|
| 44 | 44 | |
| 45 | 45 | protected $_targetSelector; |
| 46 | 46 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | protected $_json; |
| 52 | 52 | |
| 53 | - protected $_rowClass = "_element"; |
|
| 53 | + protected $_rowClass="_element"; |
|
| 54 | 54 | |
| 55 | 55 | protected $_sortable; |
| 56 | 56 | |
@@ -58,25 +58,25 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | protected $_colWidths; |
| 60 | 60 | |
| 61 | - public function __construct($identifier, $model, $modelInstance = NULL) { |
|
| 61 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 62 | 62 | parent::__construct($identifier, $model, $modelInstance); |
| 63 | 63 | $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
| 64 | - $this->_urls = []; |
|
| 65 | - $this->_emptyMessage = new HtmlMessage("", "nothing to display"); |
|
| 64 | + $this->_urls=[]; |
|
| 65 | + $this->_emptyMessage=new HtmlMessage("", "nothing to display"); |
|
| 66 | 66 | $this->_emptyMessage->setIcon("info circle"); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public function run(JsUtils $js) { |
| 70 | - $offset = $js->scriptCount(); |
|
| 70 | + $offset=$js->scriptCount(); |
|
| 71 | 71 | if ($this->_hasCheckboxes && isset($js)) { |
| 72 | 72 | $this->_runCheckboxes($js); |
| 73 | 73 | } |
| 74 | 74 | if ($this->_visibleHover) { |
| 75 | - $js->execOn("mouseover", "#" . $this->identifier . " tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", [ |
|
| 75 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", [ |
|
| 76 | 76 | "preventDefault" => false, |
| 77 | 77 | "stopPropagation" => true |
| 78 | 78 | ]); |
| 79 | - $js->execOn("mouseout", "#" . $this->identifier . " tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", [ |
|
| 79 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", [ |
|
| 80 | 80 | "preventDefault" => false, |
| 81 | 81 | "stopPropagation" => true |
| 82 | 82 | ]); |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | protected function _generateBehavior($op, $params, JsUtils $js) { |
| 98 | 98 | if (isset($this->_urls[$op])) { |
| 99 | - $params = \array_merge($params, [ |
|
| 99 | + $params=\array_merge($params, [ |
|
| 100 | 100 | "attr" => "data-ajax" |
| 101 | 101 | ]); |
| 102 | - $js->ajaxOnClick("#" . $this->identifier . " ._" . $op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
| 102 | + $js->ajaxOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector($op), $params); |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
@@ -118,21 +118,21 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | public function refreshTD($fieldName, $jquery, $view) { |
| 121 | - $index = $this->_getIndex($fieldName); |
|
| 121 | + $index=$this->_getIndex($fieldName); |
|
| 122 | 122 | $this->compile($jquery, $view); |
| 123 | 123 | return $this->refreshTR() |
| 124 | 124 | ->getTable() |
| 125 | 125 | ->getCell(0, $index); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - public function compile(JsUtils $js = NULL, &$view = NULL) { |
|
| 129 | - if (! $this->_generated) { |
|
| 128 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 129 | + if (!$this->_generated) { |
|
| 130 | 130 | if (isset($this->_buttonsColumn)) { |
| 131 | 131 | $this->_instanceViewer->sortColumnContent($this->_buttonsColumn, $this->_buttons); |
| 132 | 132 | } |
| 133 | 133 | $this->_instanceViewer->setInstance($this->_model); |
| 134 | - $captions = $this->_instanceViewer->getCaptions(); |
|
| 135 | - $table = $this->content["table"]; |
|
| 134 | + $captions=$this->_instanceViewer->getCaptions(); |
|
| 135 | + $table=$this->content["table"]; |
|
| 136 | 136 | if ($this->_hasCheckboxes) { |
| 137 | 137 | $this->_generateMainCheckbox($captions); |
| 138 | 138 | } |
@@ -147,14 +147,14 @@ discard block |
||
| 147 | 147 | $this->compileExtraElements($table, $captions); |
| 148 | 148 | $this->_compileSearchFieldBehavior($js); |
| 149 | 149 | |
| 150 | - $this->content = JArray::sortAssociative($this->content, [ |
|
| 150 | + $this->content=JArray::sortAssociative($this->content, [ |
|
| 151 | 151 | PositionInTable::BEFORETABLE, |
| 152 | 152 | "table", |
| 153 | 153 | PositionInTable::AFTERTABLE |
| 154 | 154 | ]); |
| 155 | 155 | $this->_compileForm(); |
| 156 | 156 | $this->_applyStyleAttributes($table); |
| 157 | - $this->_generated = true; |
|
| 157 | + $this->_generated=true; |
|
| 158 | 158 | } |
| 159 | 159 | return parent::compile($js, $view); |
| 160 | 160 | } |
@@ -199,21 +199,21 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | protected function _generateContent($table) { |
| 202 | - $objects = $this->_modelInstance; |
|
| 202 | + $objects=$this->_modelInstance; |
|
| 203 | 203 | if (isset($this->_pagination)) { |
| 204 | - $objects = $this->_pagination->getObjects($this->_modelInstance); |
|
| 204 | + $objects=$this->_pagination->getObjects($this->_modelInstance); |
|
| 205 | 205 | } |
| 206 | 206 | InstanceViewer::setIndex(0); |
| 207 | - $fields = $this->_instanceViewer->getSimpleProperties(); |
|
| 208 | - $groupByFields = $this->_instanceViewer->getGroupByFields(); |
|
| 209 | - if (! is_array($groupByFields)) { |
|
| 210 | - $table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields) { |
|
| 207 | + $fields=$this->_instanceViewer->getSimpleProperties(); |
|
| 208 | + $groupByFields=$this->_instanceViewer->getGroupByFields(); |
|
| 209 | + if (!is_array($groupByFields)) { |
|
| 210 | + $table->fromDatabaseObjects($objects, function($instance) use ($table, $fields) { |
|
| 211 | 211 | return $this->_generateRow($instance, $fields, $table); |
| 212 | 212 | }); |
| 213 | 213 | } else { |
| 214 | - $activeValues = array_combine($groupByFields, array_fill(0, sizeof($groupByFields), null)); |
|
| 215 | - $uuids = []; |
|
| 216 | - $table->fromDatabaseObjects($objects, function ($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids) { |
|
| 214 | + $activeValues=array_combine($groupByFields, array_fill(0, sizeof($groupByFields), null)); |
|
| 215 | + $uuids=[]; |
|
| 216 | + $table->fromDatabaseObjects($objects, function($instance) use ($table, $fields, &$activeValues, $groupByFields, &$uuids) { |
|
| 217 | 217 | $this->_instanceViewer->setInstance($instance); |
| 218 | 218 | foreach ($groupByFields as $index => $gbField) { |
| 219 | 219 | $this->_generateGroupByRow($index, $gbField, $table, $fields, $activeValues, $uuids); |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | return $this->_generateRow($instance, $fields, $table, null, $uuids); |
| 222 | 222 | }); |
| 223 | 223 | } |
| 224 | - if ($table->getRowCount() == 0) { |
|
| 225 | - $result = $table->addRow(); |
|
| 224 | + if ($table->getRowCount()==0) { |
|
| 225 | + $result=$table->addRow(); |
|
| 226 | 226 | $result->mergeRow(); |
| 227 | 227 | $result->setValues([ |
| 228 | 228 | $this->_emptyMessage |
@@ -231,20 +231,20 @@ discard block |
||
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | protected function _generateGroupByRow($index, $gbField, $table, $fields, &$activeValues, &$uuids) { |
| 234 | - $newValue = $this->_instanceViewer->getValue($gbField); |
|
| 235 | - if ($this->getElementContent($activeValues[$gbField]) !== $this->getElementContent($newValue)) { |
|
| 236 | - if ($index == 0) { |
|
| 237 | - $uuids = []; |
|
| 234 | + $newValue=$this->_instanceViewer->getValue($gbField); |
|
| 235 | + if ($this->getElementContent($activeValues[$gbField])!==$this->getElementContent($newValue)) { |
|
| 236 | + if ($index==0) { |
|
| 237 | + $uuids=[]; |
|
| 238 | 238 | } |
| 239 | - $uuid = uniqid("grp"); |
|
| 240 | - $uuids[$gbField] = $uuid; |
|
| 241 | - $id = $this->_instanceViewer->getIdentifier(); |
|
| 242 | - $result = $table->addMergeRow(sizeof($fields) + 1, $newValue); |
|
| 243 | - $result->setIdentifier($this->identifier . "-tr-gb-" . $id); |
|
| 239 | + $uuid=uniqid("grp"); |
|
| 240 | + $uuids[$gbField]=$uuid; |
|
| 241 | + $id=$this->_instanceViewer->getIdentifier(); |
|
| 242 | + $result=$table->addMergeRow(sizeof($fields)+1, $newValue); |
|
| 243 | + $result->setIdentifier($this->identifier."-tr-gb-".$id); |
|
| 244 | 244 | $result->setProperty("data-ajax", $id); |
| 245 | 245 | $result->setProperty("data-group", $uuid); |
| 246 | 246 | $result->addToProperty("class", $this->_rowClass); |
| 247 | - $activeValues[$gbField] = $newValue; |
|
| 247 | + $activeValues[$gbField]=$newValue; |
|
| 248 | 248 | } |
| 249 | 249 | } |
| 250 | 250 | |
@@ -256,9 +256,9 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | public function getFieldValue($index) { |
| 259 | - $index = $this->_getIndex($index); |
|
| 259 | + $index=$this->_getIndex($index); |
|
| 260 | 260 | if (is_numeric($index)) { |
| 261 | - $values = $this->_instanceViewer->getValues(); |
|
| 261 | + $values=$this->_instanceViewer->getValues(); |
|
| 262 | 262 | if (isset($values[$index])) { |
| 263 | 263 | return $values[$index]; |
| 264 | 264 | } |
@@ -266,31 +266,31 @@ discard block |
||
| 266 | 266 | return null; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - protected function _generateRow($instance, $fields, &$table, $checkedClass = null, $uuids = null) { |
|
| 269 | + protected function _generateRow($instance, $fields, &$table, $checkedClass=null, $uuids=null) { |
|
| 270 | 270 | $this->_instanceViewer->setInstance($instance); |
| 271 | - InstanceViewer::$index ++; |
|
| 272 | - $values = $this->_instanceViewer->getValues(); |
|
| 273 | - $id = $this->_instanceViewer->getIdentifier(); |
|
| 274 | - $dataAjax = $id; |
|
| 275 | - $id = $this->cleanIdentifier($id); |
|
| 271 | + InstanceViewer::$index++; |
|
| 272 | + $values=$this->_instanceViewer->getValues(); |
|
| 273 | + $id=$this->_instanceViewer->getIdentifier(); |
|
| 274 | + $dataAjax=$id; |
|
| 275 | + $id=$this->cleanIdentifier($id); |
|
| 276 | 276 | if ($this->_hasCheckboxes) { |
| 277 | - $ck = new HtmlCheckbox("ck-" . $this->identifier . "-" . $id, ""); |
|
| 278 | - $checked = false; |
|
| 277 | + $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, ""); |
|
| 278 | + $checked=false; |
|
| 279 | 279 | if (isset($this->_checkedCallback)) { |
| 280 | - $func = $this->_checkedCallback; |
|
| 281 | - $checked = $func($instance); |
|
| 280 | + $func=$this->_checkedCallback; |
|
| 281 | + $checked=$func($instance); |
|
| 282 | 282 | } |
| 283 | 283 | $ck->setChecked($checked); |
| 284 | 284 | // $ck->setOnChange("event.stopPropagation();"); |
| 285 | - $field = $ck->getField(); |
|
| 285 | + $field=$ck->getField(); |
|
| 286 | 286 | $field->setProperty("value", $dataAjax); |
| 287 | 287 | $field->setProperty("name", "selection[]"); |
| 288 | 288 | if (isset($checkedClass)) |
| 289 | 289 | $field->setClass($checkedClass); |
| 290 | 290 | \array_unshift($values, $ck); |
| 291 | 291 | } |
| 292 | - $result = $table->newRow(); |
|
| 293 | - $result->setIdentifier($this->identifier . "-tr-" . $id); |
|
| 292 | + $result=$table->newRow(); |
|
| 293 | + $result->setIdentifier($this->identifier."-tr-".$id); |
|
| 294 | 294 | $result->setProperty("data-ajax", $dataAjax); |
| 295 | 295 | $result->setValues($values); |
| 296 | 296 | $result->addToProperty("class", $this->_rowClass); |
@@ -303,62 +303,62 @@ discard block |
||
| 303 | 303 | |
| 304 | 304 | protected function _generatePagination($table) { |
| 305 | 305 | if (isset($this->_toolbar)) { |
| 306 | - if ($this->_toolbarPosition == PositionInTable::FOOTER) |
|
| 306 | + if ($this->_toolbarPosition==PositionInTable::FOOTER) |
|
| 307 | 307 | $this->_toolbar->setFloated("left"); |
| 308 | 308 | } |
| 309 | - $footer = $table->getFooter(); |
|
| 309 | + $footer=$table->getFooter(); |
|
| 310 | 310 | $footer->mergeCol(); |
| 311 | 311 | $footer->addValues($this->_pagination->generateMenu($this->identifier)); |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - protected function _associatePaginationBehavior(JsUtils $js = NULL, $offset = null) { |
|
| 314 | + protected function _associatePaginationBehavior(JsUtils $js=NULL, $offset=null) { |
|
| 315 | 315 | if (isset($this->_urls["refresh"])) { |
| 316 | - $menu = $this->_pagination->getMenu(); |
|
| 316 | + $menu=$this->_pagination->getMenu(); |
|
| 317 | 317 | if (isset($menu) && isset($js)) { |
| 318 | - $js->postOnClick("#" . $menu->getIdentifier() . " .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", $this->getRefreshSelector(), [ |
|
| 318 | + $js->postOnClick("#".$menu->getIdentifier()." .item", $this->_urls["refresh"], "{'p':$(this).attr('data-page'),'_model':'".JString::doubleBackSlashes($this->_model)."'}", $this->getRefreshSelector(), [ |
|
| 319 | 319 | "preventDefault" => false, |
| 320 | 320 | "jqueryDone" => "replaceWith", |
| 321 | 321 | "hasLoader" => false, |
| 322 | - "jsCallback" => '$("#' . $this->identifier . '").trigger("pageChange");$("#' . $this->identifier . '").trigger("activeRowChange");' |
|
| 322 | + "jsCallback" => '$("#'.$this->identifier.'").trigger("pageChange");$("#'.$this->identifier.'").trigger("activeRowChange");' |
|
| 323 | 323 | ]); |
| 324 | - $page = $_POST["p"] ?? null; |
|
| 324 | + $page=$_POST["p"] ?? null; |
|
| 325 | 325 | if (isset($page)) { |
| 326 | - $js->execAtLast('$("#' . $this->getIdentifier() . ' .pagination").children("a.item").removeClass("active");$("#' . $this->getIdentifier() . ' .pagination").children("a.item[data-page=' . $page . ']:not(.no-active)").addClass("active");'); |
|
| 326 | + $js->execAtLast('$("#'.$this->getIdentifier().' .pagination").children("a.item").removeClass("active");$("#'.$this->getIdentifier().' .pagination").children("a.item[data-page='.$page.']:not(.no-active)").addClass("active");'); |
|
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - protected function _compileSearchFieldBehavior(JsUtils $js = NULL) { |
|
| 332 | + protected function _compileSearchFieldBehavior(JsUtils $js=NULL) { |
|
| 333 | 333 | if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) { |
| 334 | - $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'" . JString::doubleBackSlashes($this->_model) . "'}", "#" . $this->identifier . " tbody", [ |
|
| 334 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(self).val(),'_model':'".JString::doubleBackSlashes($this->_model)."'}", "#".$this->identifier." tbody", [ |
|
| 335 | 335 | "preventDefault" => false, |
| 336 | 336 | "jqueryDone" => "replaceWith", |
| 337 | 337 | "hasLoader" => "internal", |
| 338 | - "jsCallback" => '$("#' . $this->identifier . '").trigger("searchTerminate",[$(self).val()]);' |
|
| 338 | + "jsCallback" => '$("#'.$this->identifier.'").trigger("searchTerminate",[$(self).val()]);' |
|
| 339 | 339 | ]); |
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - protected function _associateSearchFieldBehavior(JsUtils $js = NULL, $offset = null) {} |
|
| 343 | + protected function _associateSearchFieldBehavior(JsUtils $js=NULL, $offset=null) {} |
|
| 344 | 344 | |
| 345 | 345 | protected function _getFieldName($index) { |
| 346 | - $fieldName = parent::_getFieldName($index); |
|
| 346 | + $fieldName=parent::_getFieldName($index); |
|
| 347 | 347 | if (\is_object($fieldName)) |
| 348 | - $fieldName = "field-" . $index; |
|
| 349 | - return $fieldName . "[]"; |
|
| 348 | + $fieldName="field-".$index; |
|
| 349 | + return $fieldName."[]"; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | protected function _getFieldCaption($index) { |
| 353 | 353 | return null; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - protected function _setToolbarPosition($table, $captions = NULL) { |
|
| 356 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
| 357 | 357 | switch ($this->_toolbarPosition) { |
| 358 | 358 | case PositionInTable::BEFORETABLE: |
| 359 | 359 | case PositionInTable::AFTERTABLE: |
| 360 | - if (isset($this->_compileParts) === false) { |
|
| 361 | - $this->content[$this->_toolbarPosition] = $this->_toolbar; |
|
| 360 | + if (isset($this->_compileParts)===false) { |
|
| 361 | + $this->content[$this->_toolbarPosition]=$this->_toolbar; |
|
| 362 | 362 | } |
| 363 | 363 | break; |
| 364 | 364 | case PositionInTable::HEADER: |
@@ -385,11 +385,11 @@ discard block |
||
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | private function addToolbarRow($part, $table, $captions) { |
| 388 | - $hasPart = $table->hasPart($part); |
|
| 388 | + $hasPart=$table->hasPart($part); |
|
| 389 | 389 | if ($hasPart) { |
| 390 | - $row = $table->getPart($part)->addRow(\sizeof($captions)); |
|
| 390 | + $row=$table->getPart($part)->addRow(\sizeof($captions)); |
|
| 391 | 391 | } else { |
| 392 | - $row = $table->getPart($part)->getRow(0); |
|
| 392 | + $row=$table->getPart($part)->getRow(0); |
|
| 393 | 393 | } |
| 394 | 394 | $row->mergeCol(); |
| 395 | 395 | $row->setValues([ |
@@ -421,12 +421,12 @@ discard block |
||
| 421 | 421 | */ |
| 422 | 422 | public function setUrls($urls) { |
| 423 | 423 | if (\is_array($urls)) { |
| 424 | - $this->_urls["refresh"] = JArray::getValue($urls, "refresh", 0); |
|
| 425 | - $this->_urls["edit"] = JArray::getValue($urls, "edit", 1); |
|
| 426 | - $this->_urls["delete"] = JArray::getValue($urls, "delete", 2); |
|
| 427 | - $this->_urls["display"] = JArray::getValue($urls, "display", 3); |
|
| 424 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
| 425 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
| 426 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
| 427 | + $this->_urls["display"]=JArray::getValue($urls, "display", 3); |
|
| 428 | 428 | } else { |
| 429 | - $this->_urls = [ |
|
| 429 | + $this->_urls=[ |
|
| 430 | 430 | "refresh" => $urls, |
| 431 | 431 | "edit" => $urls, |
| 432 | 432 | "delete" => $urls, |
@@ -449,8 +449,8 @@ discard block |
||
| 449 | 449 | * The number of visible pages in the Pagination component |
| 450 | 450 | * @return DataTable |
| 451 | 451 | */ |
| 452 | - public function paginate($page, $total_rowcount, $items_per_page = 10, $pages_visibles = null) { |
|
| 453 | - $this->_pagination = new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
| 452 | + public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) { |
|
| 453 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
| 454 | 454 | return $this; |
| 455 | 455 | } |
| 456 | 456 | |
@@ -465,8 +465,8 @@ discard block |
||
| 465 | 465 | * The number of visible pages in the Pagination component |
| 466 | 466 | * @return DataTable |
| 467 | 467 | */ |
| 468 | - public function autoPaginate($page = 1, $items_per_page = 10, $pages_visibles = 4) { |
|
| 469 | - $this->_pagination = new Pagination($items_per_page, $pages_visibles, $page); |
|
| 468 | + public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) { |
|
| 469 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page); |
|
| 470 | 470 | return $this; |
| 471 | 471 | } |
| 472 | 472 | |
@@ -475,10 +475,10 @@ discard block |
||
| 475 | 475 | * @param array $compileParts |
| 476 | 476 | * @return DataTable |
| 477 | 477 | */ |
| 478 | - public function refresh($compileParts = [ |
|
| 478 | + public function refresh($compileParts=[ |
|
| 479 | 479 | "tbody" |
| 480 | 480 | ]) { |
| 481 | - $this->_compileParts = $compileParts; |
|
| 481 | + $this->_compileParts=$compileParts; |
|
| 482 | 482 | return $this; |
| 483 | 483 | } |
| 484 | 484 | |
@@ -488,14 +488,14 @@ discard block |
||
| 488 | 488 | * @param string $position |
| 489 | 489 | * @return \Ajax\common\html\HtmlDoubleElement |
| 490 | 490 | */ |
| 491 | - public function addSearchInToolbar($position = Direction::RIGHT) { |
|
| 491 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
| 492 | 492 | return $this->addInToolbar($this->getSearchField()) |
| 493 | 493 | ->setPosition($position); |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | public function getSearchField() { |
| 497 | - if (isset($this->_searchField) === false) { |
|
| 498 | - $this->_searchField = new HtmlInput("search-" . $this->identifier, "search", "", "Search..."); |
|
| 497 | + if (isset($this->_searchField)===false) { |
|
| 498 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
| 499 | 499 | $this->_searchField->addIcon("search", Direction::RIGHT); |
| 500 | 500 | } |
| 501 | 501 | return $this->_searchField; |
@@ -523,9 +523,9 @@ discard block |
||
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | protected function getTargetSelector($op) { |
| 526 | - $result = $this->_targetSelector; |
|
| 527 | - if (! isset($result[$op])) |
|
| 528 | - $result = "#" . $this->identifier; |
|
| 526 | + $result=$this->_targetSelector; |
|
| 527 | + if (!isset($result[$op])) |
|
| 528 | + $result="#".$this->identifier; |
|
| 529 | 529 | return $result[$op]; |
| 530 | 530 | } |
| 531 | 531 | |
@@ -537,20 +537,20 @@ discard block |
||
| 537 | 537 | * @return DataTable |
| 538 | 538 | */ |
| 539 | 539 | public function setTargetSelector($_targetSelector) { |
| 540 | - if (! \is_array($_targetSelector)) { |
|
| 541 | - $_targetSelector = [ |
|
| 540 | + if (!\is_array($_targetSelector)) { |
|
| 541 | + $_targetSelector=[ |
|
| 542 | 542 | "edit" => $_targetSelector, |
| 543 | 543 | "delete" => $_targetSelector |
| 544 | 544 | ]; |
| 545 | 545 | } |
| 546 | - $this->_targetSelector = $_targetSelector; |
|
| 546 | + $this->_targetSelector=$_targetSelector; |
|
| 547 | 547 | return $this; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | public function getRefreshSelector() { |
| 551 | 551 | if (isset($this->_refreshSelector)) |
| 552 | 552 | return $this->_refreshSelector; |
| 553 | - return "#" . $this->identifier . " tbody"; |
|
| 553 | + return "#".$this->identifier." tbody"; |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | /** |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | * @return DataTable |
| 560 | 560 | */ |
| 561 | 561 | public function setRefreshSelector($_refreshSelector) { |
| 562 | - $this->_refreshSelector = $_refreshSelector; |
|
| 562 | + $this->_refreshSelector=$_refreshSelector; |
|
| 563 | 563 | return $this; |
| 564 | 564 | } |
| 565 | 565 | |
@@ -571,9 +571,9 @@ discard block |
||
| 571 | 571 | public function show($modelInstance) { |
| 572 | 572 | if (\is_array($modelInstance)) { |
| 573 | 573 | if (isset($modelInstance[0]) && \is_array(array_values($modelInstance)[0])) |
| 574 | - $modelInstance = \json_decode(\json_encode($modelInstance), FALSE); |
|
| 574 | + $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
| 575 | 575 | } |
| 576 | - $this->_modelInstance = $modelInstance; |
|
| 576 | + $this->_modelInstance=$modelInstance; |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | public function getRowClass() { |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | * @return DataTable |
| 588 | 588 | */ |
| 589 | 589 | public function setRowClass($_rowClass) { |
| 590 | - $this->_rowClass = $_rowClass; |
|
| 590 | + $this->_rowClass=$_rowClass; |
|
| 591 | 591 | return $this; |
| 592 | 592 | } |
| 593 | 593 | |
@@ -598,34 +598,34 @@ discard block |
||
| 598 | 598 | * @return DataTable |
| 599 | 599 | */ |
| 600 | 600 | public function setEmptyMessage($_emptyMessage) { |
| 601 | - $this->_emptyMessage = $_emptyMessage; |
|
| 601 | + $this->_emptyMessage=$_emptyMessage; |
|
| 602 | 602 | return $this; |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | - public function setSortable($colIndex = NULL) { |
|
| 606 | - $this->_sortable = $colIndex; |
|
| 605 | + public function setSortable($colIndex=NULL) { |
|
| 606 | + $this->_sortable=$colIndex; |
|
| 607 | 607 | return $this; |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | - public function setActiveRowSelector($class = "active", $event = "click", $multiple = false) { |
|
| 610 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
| 611 | 611 | $this->_self->setActiveRowSelector($class, $event, $multiple); |
| 612 | 612 | return $this; |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | public function hideColumn($colIndex) { |
| 616 | - if (! \is_array($this->_hiddenColumns)) |
|
| 617 | - $this->_hiddenColumns = []; |
|
| 618 | - $this->_hiddenColumns[] = $colIndex; |
|
| 616 | + if (!\is_array($this->_hiddenColumns)) |
|
| 617 | + $this->_hiddenColumns=[]; |
|
| 618 | + $this->_hiddenColumns[]=$colIndex; |
|
| 619 | 619 | return $this; |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | public function setColWidth($colIndex, $width) { |
| 623 | - $this->_colWidths[$colIndex] = $width; |
|
| 623 | + $this->_colWidths[$colIndex]=$width; |
|
| 624 | 624 | return $this; |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | public function setColWidths($_colWidths) { |
| 628 | - $this->_colWidths = $_colWidths; |
|
| 628 | + $this->_colWidths=$_colWidths; |
|
| 629 | 629 | return $this; |
| 630 | 630 | } |
| 631 | 631 | |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | return $this; |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | - public function trigger($event, $params = "[]") { |
|
| 637 | + public function trigger($event, $params="[]") { |
|
| 638 | 638 | return $this->getHtmlComponent()->trigger($event, $params); |
| 639 | 639 | } |
| 640 | 640 | |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | * @param mixed $_displayBehavior |
| 673 | 673 | */ |
| 674 | 674 | public function setDisplayBehavior($_displayBehavior) { |
| 675 | - $this->_displayBehavior = $_displayBehavior; |
|
| 675 | + $this->_displayBehavior=$_displayBehavior; |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | /** |
@@ -13,9 +13,9 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | protected $_hasCheckedList; |
| 15 | 15 | |
| 16 | - protected $_fireOnInit = false; |
|
| 16 | + protected $_fireOnInit=false; |
|
| 17 | 17 | |
| 18 | - protected $_ckItemChange = ""; |
|
| 18 | + protected $_ckItemChange=""; |
|
| 19 | 19 | |
| 20 | 20 | protected $_maxVisible; |
| 21 | 21 | |
@@ -23,25 +23,25 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | protected $_visibility; |
| 25 | 25 | |
| 26 | - public function __construct($identifier, $items = array()) { |
|
| 26 | + public function __construct($identifier, $items=array()) { |
|
| 27 | 27 | parent::__construct($identifier, "div", "ui list"); |
| 28 | 28 | $this->addItems($items); |
| 29 | - $this->_hasCheckedList = false; |
|
| 29 | + $this->_hasCheckedList=false; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | protected function createItem($value) { |
| 33 | - $count = $this->count(); |
|
| 34 | - $item = new HtmlListItem("item-" . $this->identifier . "-" . $count, $value); |
|
| 33 | + $count=$this->count(); |
|
| 34 | + $item=new HtmlListItem("item-".$this->identifier."-".$count, $value); |
|
| 35 | 35 | return $item; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public function addHeader($niveau, $content) { |
| 39 | - $header = new HtmlHeader("header-" . $this->identifier, $niveau, $content, "page"); |
|
| 39 | + $header=new HtmlHeader("header-".$this->identifier, $niveau, $content, "page"); |
|
| 40 | 40 | $this->wrap($header); |
| 41 | 41 | return $header; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function getItemPart($index, $partName = "header") { |
|
| 44 | + public function getItemPart($index, $partName="header") { |
|
| 45 | 45 | return $this->getItem($index)->getPart($partName); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -49,15 +49,15 @@ discard block |
||
| 49 | 49 | return $this->contentAs($tagName); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function asLinks($hrefs = [], $target = NUll) { |
|
| 52 | + public function asLinks($hrefs=[], $target=NUll) { |
|
| 53 | 53 | $this->addToPropertyCtrl("class", "link", array( |
| 54 | 54 | "link" |
| 55 | 55 | )); |
| 56 | 56 | return parent::asLinks($hrefs, $target); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - public function addList($items = array()) { |
|
| 60 | - $list = new HtmlList("", $items); |
|
| 59 | + public function addList($items=array()) { |
|
| 60 | + $list=new HtmlList("", $items); |
|
| 61 | 61 | $list->setClass("list"); |
| 62 | 62 | return $this->addItem($list); |
| 63 | 63 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | protected function getItemToAdd($item) { |
| 74 | - $itemO = parent::getItemToAdd($item); |
|
| 74 | + $itemO=parent::getItemToAdd($item); |
|
| 75 | 75 | if ($itemO instanceof AbstractCheckbox) |
| 76 | 76 | $itemO->addClass("item"); |
| 77 | 77 | return $itemO; |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | public function run(JsUtils $js) { |
| 93 | - if ($this->_hasCheckedList === true) { |
|
| 94 | - $jsCode = include dirname(__FILE__) . '/../../components/jsTemplates/tplCheckedList.php'; |
|
| 95 | - $jsCode = \str_replace("%identifier%", "#" . $this->identifier, $jsCode); |
|
| 96 | - $jsCode = \str_replace("%fireOnInit%", $this->_fireOnInit, $jsCode); |
|
| 97 | - $jsCode = \str_replace("%onChange%", $this->_ckItemChange, $jsCode); |
|
| 93 | + if ($this->_hasCheckedList===true) { |
|
| 94 | + $jsCode=include dirname(__FILE__).'/../../components/jsTemplates/tplCheckedList.php'; |
|
| 95 | + $jsCode=\str_replace("%identifier%", "#".$this->identifier, $jsCode); |
|
| 96 | + $jsCode=\str_replace("%fireOnInit%", $this->_fireOnInit, $jsCode); |
|
| 97 | + $jsCode=\str_replace("%onChange%", $this->_ckItemChange, $jsCode); |
|
| 98 | 98 | $this->executeOnRun($jsCode); |
| 99 | 99 | } |
| 100 | 100 | /* |
@@ -106,19 +106,19 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | protected function addFollowPoints() { |
| 109 | - $count = $this->count(); |
|
| 110 | - for ($i = $this->_maxVisible; $i < $count; $i ++) { |
|
| 109 | + $count=$this->count(); |
|
| 110 | + for ($i=$this->_maxVisible; $i<$count; $i++) { |
|
| 111 | 111 | $this->getItem($i) |
| 112 | 112 | ->addClass("notVisible") |
| 113 | 113 | ->setProperty("style", "display: none;"); |
| 114 | 114 | } |
| 115 | - $item = $this->addItem("..."); |
|
| 115 | + $item=$this->addItem("..."); |
|
| 116 | 116 | $item->addClass("points"); |
| 117 | - $item->onClick('$(this).hide();$("#' . $this->identifier . ' .notVisible").show();'); |
|
| 117 | + $item->onClick('$(this).hide();$("#'.$this->identifier.' .notVisible").show();'); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | public function onCkItemChange($jsCode) { |
| 121 | - $this->_ckItemChange = $jsCode; |
|
| 121 | + $this->_ckItemChange=$jsCode; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param boolean $fireOnInit |
| 127 | 127 | */ |
| 128 | 128 | public function setFireOnInit($fireOnInit) { |
| 129 | - $this->_fireOnInit = $fireOnInit; |
|
| 129 | + $this->_fireOnInit=$fireOnInit; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | public function setRelaxed() { |
@@ -150,15 +150,15 @@ discard block |
||
| 150 | 150 | * {@inheritdoc} |
| 151 | 151 | * @see \Ajax\common\html\HtmlCollection::compile() |
| 152 | 152 | */ |
| 153 | - public function compile(JsUtils $js = NULL, &$view = NULL) { |
|
| 154 | - if (isset($this->_maxVisible) && $this->_maxVisible < $this->count()) { |
|
| 153 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 154 | + if (isset($this->_maxVisible) && $this->_maxVisible<$this->count()) { |
|
| 155 | 155 | $this->addFollowPoints(); |
| 156 | 156 | if (isset($js)) { |
| 157 | - $visibility = new Visibility($js); |
|
| 158 | - $visibility->attach("#" . $this->identifier); |
|
| 157 | + $visibility=new Visibility($js); |
|
| 158 | + $visibility->attach("#".$this->identifier); |
|
| 159 | 159 | $visibility->setOnTopVisible("$(this).children('.notVisible').hide();$(this).find('.points').show();"); |
| 160 | 160 | $visibility->compile($js, $view); |
| 161 | - $this->_visibility = $visibility; |
|
| 161 | + $this->_visibility=$visibility; |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | return parent::compile($js, $view); |
@@ -173,21 +173,21 @@ discard block |
||
| 173 | 173 | * @param string $notAllChecked |
| 174 | 174 | * @return HtmlList |
| 175 | 175 | */ |
| 176 | - public function addCheckedList($items = array(), $masterItem = NULL, $values = array(), $notAllChecked = false, $name = null) { |
|
| 177 | - $count = $this->count(); |
|
| 178 | - $identifier = $this->identifier . "-" . $count; |
|
| 176 | + public function addCheckedList($items=array(), $masterItem=NULL, $values=array(), $notAllChecked=false, $name=null) { |
|
| 177 | + $count=$this->count(); |
|
| 178 | + $identifier=$this->identifier."-".$count; |
|
| 179 | 179 | if (isset($masterItem)) { |
| 180 | 180 | if (\is_array($masterItem)) { |
| 181 | - $masterO = new HtmlFormCheckbox("master-" . $identifier, @$masterItem[0], @$masterItem[1]); |
|
| 181 | + $masterO=new HtmlFormCheckbox("master-".$identifier, @$masterItem[0], @$masterItem[1]); |
|
| 182 | 182 | if (isset($name)) |
| 183 | 183 | $masterO->setName($name); |
| 184 | 184 | if (isset($masterItem[1])) { |
| 185 | - if (\array_search($masterItem[1], $values) !== false) { |
|
| 185 | + if (\array_search($masterItem[1], $values)!==false) { |
|
| 186 | 186 | $masterO->getDataField()->setProperty("checked", ""); |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | } else { |
| 190 | - $masterO = new HtmlFormCheckbox("master-" . $identifier, $masterItem); |
|
| 190 | + $masterO=new HtmlFormCheckbox("master-".$identifier, $masterItem); |
|
| 191 | 191 | } |
| 192 | 192 | if ($notAllChecked) { |
| 193 | 193 | $masterO->getDataField()->addClass("_notAllChecked"); |
@@ -196,36 +196,36 @@ discard block |
||
| 196 | 196 | $masterO->setClass("item"); |
| 197 | 197 | $this->addItem($masterO); |
| 198 | 198 | } |
| 199 | - $fields = array(); |
|
| 200 | - $i = 0; |
|
| 201 | - $this->setFireOnInit(UString::getBooleanStr($this->_fireOnInit || count($items) < 30)); |
|
| 199 | + $fields=array(); |
|
| 200 | + $i=0; |
|
| 201 | + $this->setFireOnInit(UString::getBooleanStr($this->_fireOnInit || count($items)<30)); |
|
| 202 | 202 | foreach ($items as $val => $caption) { |
| 203 | - $itemO = new HtmlFormCheckbox($identifier . "-" . $i ++, $caption, $val, "child"); |
|
| 204 | - if (\array_search($val, $values) !== false) { |
|
| 203 | + $itemO=new HtmlFormCheckbox($identifier."-".$i++, $caption, $val, "child"); |
|
| 204 | + if (\array_search($val, $values)!==false) { |
|
| 205 | 205 | $itemO->getDataField()->setProperty("checked", ""); |
| 206 | 206 | } |
| 207 | 207 | if (isset($name)) |
| 208 | 208 | $itemO->setName($name); |
| 209 | 209 | $itemO->setClass("item"); |
| 210 | - $fields[] = $itemO; |
|
| 210 | + $fields[]=$itemO; |
|
| 211 | 211 | } |
| 212 | - if (isset($masterO) === true) { |
|
| 213 | - $list = new HtmlList("", $fields); |
|
| 212 | + if (isset($masterO)===true) { |
|
| 213 | + $list=new HtmlList("", $fields); |
|
| 214 | 214 | $list->setClass("list"); |
| 215 | 215 | $masterO->addContent($list); |
| 216 | 216 | } else { |
| 217 | 217 | $this->addList($fields); |
| 218 | 218 | } |
| 219 | - $this->_hasCheckedList = true; |
|
| 219 | + $this->_hasCheckedList=true; |
|
| 220 | 220 | return $this; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | public function setIcons($icons) { |
| 224 | - if (! \is_array($icons)) { |
|
| 225 | - $icons = \array_fill(0, \sizeof($this->content), $icons); |
|
| 224 | + if (!\is_array($icons)) { |
|
| 225 | + $icons=\array_fill(0, \sizeof($this->content), $icons); |
|
| 226 | 226 | } |
| 227 | - $max = \min(\sizeof($icons), \sizeof($this->content)); |
|
| 228 | - for ($i = 0; $i < $max; $i ++) { |
|
| 227 | + $max=\min(\sizeof($icons), \sizeof($this->content)); |
|
| 228 | + for ($i=0; $i<$max; $i++) { |
|
| 229 | 229 | $this->content[$i]->addIcon($icons[$i]); |
| 230 | 230 | } |
| 231 | 231 | return $this; |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * @param mixed $_maxVisible |
| 245 | 245 | */ |
| 246 | 246 | public function setMaxVisible($_maxVisible) { |
| 247 | - $this->_maxVisible = $_maxVisible; |
|
| 247 | + $this->_maxVisible=$_maxVisible; |
|
| 248 | 248 | return $this; |
| 249 | 249 | } |
| 250 | 250 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | public function __construct($identifier) { |
| 24 | 24 | parent::__construct($identifier, "tr", ""); |
| 25 | - $this->_states = [ |
|
| 25 | + $this->_states=[ |
|
| 26 | 26 | State::ACTIVE, |
| 27 | 27 | State::POSITIVE, |
| 28 | 28 | State::NEGATIVE, |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function setColCount($colCount) { |
| 36 | - $count = $this->count(); |
|
| 37 | - for ($i = $count; $i < $colCount; $i ++) { |
|
| 38 | - $item = $this->addItem(NULL); |
|
| 36 | + $count=$this->count(); |
|
| 37 | + for ($i=$count; $i<$colCount; $i++) { |
|
| 38 | + $item=$this->addItem(NULL); |
|
| 39 | 39 | $item->setTagName($this->_tdTagName); |
| 40 | 40 | } |
| 41 | 41 | return $this; |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | * @see \Ajax\common\html\HtmlCollection::createItem() |
| 53 | 53 | */ |
| 54 | 54 | protected function createItem($value) { |
| 55 | - $count = $this->count(); |
|
| 56 | - $td = new HtmlTD("", $value, $this->_tdTagName); |
|
| 55 | + $count=$this->count(); |
|
| 56 | + $td=new HtmlTD("", $value, $this->_tdTagName); |
|
| 57 | 57 | $td->setContainer($this->_container, $this->_row, $count); |
| 58 | 58 | return $td; |
| 59 | 59 | } |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | return parent::getItem($index); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public function setTdTagName($tagName = "td") { |
|
| 70 | - $this->_tdTagName = $tagName; |
|
| 69 | + public function setTdTagName($tagName="td") { |
|
| 70 | + $this->_tdTagName=$tagName; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | * @param int $row |
| 78 | 78 | */ |
| 79 | 79 | public function setContainer($container, $row) { |
| 80 | - $this->_container = $container; |
|
| 81 | - $this->_row = $row; |
|
| 80 | + $this->_container=$container; |
|
| 81 | + $this->_row=$row; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @param mixed $values |
| 88 | 88 | */ |
| 89 | - public function setValues($values = array()) { |
|
| 90 | - return $this->_addOrSetValues($values, function (HtmlTD &$cell, $value) { |
|
| 89 | + public function setValues($values=array()) { |
|
| 90 | + return $this->_addOrSetValues($values, function(HtmlTD &$cell, $value) { |
|
| 91 | 91 | $cell->setValue($value); |
| 92 | 92 | }); |
| 93 | 93 | } |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @param mixed $values |
| 99 | 99 | */ |
| 100 | - public function addValues($values = array()) { |
|
| 101 | - return $this->_addOrSetValues($values, function (HtmlTD &$cell, $value) { |
|
| 100 | + public function addValues($values=array()) { |
|
| 101 | + return $this->_addOrSetValues($values, function(HtmlTD &$cell, $value) { |
|
| 102 | 102 | $cell->addValue($value); |
| 103 | 103 | }); |
| 104 | 104 | } |
@@ -109,18 +109,18 @@ discard block |
||
| 109 | 109 | * @param mixed $values |
| 110 | 110 | */ |
| 111 | 111 | protected function _addOrSetValues($values, $callback) { |
| 112 | - $count = $this->count(); |
|
| 113 | - if (! \is_array($values)) { |
|
| 114 | - $values = \array_fill(0, $count, $values); |
|
| 112 | + $count=$this->count(); |
|
| 113 | + if (!\is_array($values)) { |
|
| 114 | + $values=\array_fill(0, $count, $values); |
|
| 115 | 115 | } else { |
| 116 | - if (JArray::isAssociative($values) === true) { |
|
| 117 | - $values = \array_values($values); |
|
| 116 | + if (JArray::isAssociative($values)===true) { |
|
| 117 | + $values=\array_values($values); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | - $count = \min(\sizeof($values), $count); |
|
| 120 | + $count=\min(\sizeof($values), $count); |
|
| 121 | 121 | |
| 122 | - for ($i = 0; $i < $count; $i ++) { |
|
| 123 | - $cell = $this->content[$i]; |
|
| 122 | + for ($i=0; $i<$count; $i++) { |
|
| 123 | + $cell=$this->content[$i]; |
|
| 124 | 124 | $callback($cell, $values[$i]); |
| 125 | 125 | } |
| 126 | 126 | return $this; |
@@ -138,12 +138,12 @@ discard block |
||
| 138 | 138 | return $this; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - public function mergeCol($colIndex = 0) { |
|
| 141 | + public function mergeCol($colIndex=0) { |
|
| 142 | 142 | return $this->getItem($colIndex)->mergeCol(); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - public function mergeRow($colIndex = 0) { |
|
| 146 | - $row = $this->getItem($colIndex); |
|
| 145 | + public function mergeRow($colIndex=0) { |
|
| 146 | + $row=$this->getItem($colIndex); |
|
| 147 | 147 | if (isset($row)) { |
| 148 | 148 | $this->getItem($colIndex)->mergeRow(); |
| 149 | 149 | } |
@@ -151,31 +151,31 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | public function getColPosition($colIndex) { |
| 154 | - if ($this->_container->_isMerged() !== true) |
|
| 154 | + if ($this->_container->_isMerged()!==true) |
|
| 155 | 155 | return $colIndex; |
| 156 | - $pos = 0; |
|
| 157 | - $rows = $this->_container->getContent(); |
|
| 158 | - for ($i = 0; $i < $this->_row; $i ++) { |
|
| 159 | - $max = \min($colIndex, $rows[$i]->count()); |
|
| 160 | - for ($j = 0; $j < $max; $j ++) { |
|
| 161 | - $rowspan = $rows[$i]->getItem($j)->getRowspan(); |
|
| 162 | - if ($rowspan + $i > $this->_row) |
|
| 163 | - $pos ++; |
|
| 156 | + $pos=0; |
|
| 157 | + $rows=$this->_container->getContent(); |
|
| 158 | + for ($i=0; $i<$this->_row; $i++) { |
|
| 159 | + $max=\min($colIndex, $rows[$i]->count()); |
|
| 160 | + for ($j=0; $j<$max; $j++) { |
|
| 161 | + $rowspan=$rows[$i]->getItem($j)->getRowspan(); |
|
| 162 | + if ($rowspan+$i>$this->_row) |
|
| 163 | + $pos++; |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | - if ($pos > $colIndex) |
|
| 166 | + if ($pos>$colIndex) |
|
| 167 | 167 | return NULL; |
| 168 | - $count = $this->count(); |
|
| 169 | - for ($i = 0; $i < $count; $i ++) { |
|
| 170 | - $pos += $this->content[$i]->getColspan(); |
|
| 171 | - if ($pos >= $colIndex + 1) |
|
| 168 | + $count=$this->count(); |
|
| 169 | + for ($i=0; $i<$count; $i++) { |
|
| 170 | + $pos+=$this->content[$i]->getColspan(); |
|
| 171 | + if ($pos>=$colIndex+1) |
|
| 172 | 172 | return $i; |
| 173 | 173 | } |
| 174 | 174 | return null; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | public function conditionalCellFormat($callback, $format) { |
| 178 | - $cells = $this->content; |
|
| 178 | + $cells=$this->content; |
|
| 179 | 179 | foreach ($cells as $cell) { |
| 180 | 180 | $cell->conditionalCellFormat($callback, $format); |
| 181 | 181 | } |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | public function containsStr($needle) { |
| 193 | - $cells = $this->content; |
|
| 193 | + $cells=$this->content; |
|
| 194 | 194 | foreach ($cells as $cell) { |
| 195 | - if (\strpos($cell->getContent(), $needle) !== false) |
|
| 195 | + if (\strpos($cell->getContent(), $needle)!==false) |
|
| 196 | 196 | return true; |
| 197 | 197 | } |
| 198 | 198 | return false; |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | public function applyCells($callback) { |
| 207 | - $cells = $this->content; |
|
| 207 | + $cells=$this->content; |
|
| 208 | 208 | foreach ($cells as $cell) { |
| 209 | 209 | $cell->apply($callback); |
| 210 | 210 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | public function toRowspanned($colIndex) { |
| 220 | - $cell = $this->getItem($colIndex); |
|
| 220 | + $cell=$this->getItem($colIndex); |
|
| 221 | 221 | $cell->addClass('rowspanned'); |
| 222 | 222 | $cell->setContent(''); |
| 223 | 223 | return $this; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | use Ajax\JsUtils; |
| 12 | 12 | |
| 13 | 13 | class HtmlTD extends HtmlSemDoubleElement { |
| 14 | - use TextAlignmentTrait,TableElementTrait; |
|
| 14 | + use TextAlignmentTrait, TableElementTrait; |
|
| 15 | 15 | |
| 16 | 16 | private $_container; |
| 17 | 17 | |
@@ -19,11 +19,11 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | private $_col; |
| 21 | 21 | |
| 22 | - private $_colMerged = false; |
|
| 22 | + private $_colMerged=false; |
|
| 23 | 23 | |
| 24 | - private $_rowMerged = false; |
|
| 24 | + private $_rowMerged=false; |
|
| 25 | 25 | |
| 26 | - private $_deleted = false; |
|
| 26 | + private $_deleted=false; |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * |
@@ -31,12 +31,12 @@ discard block |
||
| 31 | 31 | * @param mixed $content |
| 32 | 32 | * @param string $tagName |
| 33 | 33 | */ |
| 34 | - public function __construct($identifier, $content = NULL, $tagName = "td") { |
|
| 34 | + public function __construct($identifier, $content=NULL, $tagName="td") { |
|
| 35 | 35 | parent::__construct($identifier, $tagName, "", $content); |
| 36 | - $this->_variations = [ |
|
| 36 | + $this->_variations=[ |
|
| 37 | 37 | Variation::COLLAPSING |
| 38 | 38 | ]; |
| 39 | - $this->_states = [ |
|
| 39 | + $this->_states=[ |
|
| 40 | 40 | State::ACTIVE, |
| 41 | 41 | State::POSITIVE, |
| 42 | 42 | State::NEGATIVE, |
@@ -47,13 +47,13 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function setContainer($container, $row, $col) { |
| 50 | - $this->_container = $container; |
|
| 51 | - $this->_row = $row; |
|
| 52 | - $this->_col = $col; |
|
| 50 | + $this->_container=$container; |
|
| 51 | + $this->_row=$row; |
|
| 52 | + $this->_col=$col; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | public function setValue($value) { |
| 56 | - $this->content = $value; |
|
| 56 | + $this->content=$value; |
|
| 57 | 57 | return $this; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | public function setRowspan($rowspan) { |
| 66 | - $to = min($this->_container->count(), $this->_row + $rowspan - 1); |
|
| 67 | - for ($i = $to; $i > $this->_row; $i --) { |
|
| 66 | + $to=min($this->_container->count(), $this->_row+$rowspan-1); |
|
| 67 | + for ($i=$to; $i>$this->_row; $i--) { |
|
| 68 | 68 | $this->_container->toDelete($i, $this->_col); |
| 69 | 69 | } |
| 70 | 70 | $this->setProperty("rowspan", $rowspan); |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | public function setRowspanned($rowspan) { |
| 75 | - $to = min($this->_container->count(), $this->_row + $rowspan - 1); |
|
| 76 | - for ($i = $to; $i > $this->_row; $i --) { |
|
| 75 | + $to=min($this->_container->count(), $this->_row+$rowspan-1); |
|
| 76 | + for ($i=$to; $i>$this->_row; $i--) { |
|
| 77 | 77 | $this->_container->toRowspanned($i, $this->_col); |
| 78 | 78 | } |
| 79 | 79 | $this->setProperty("rowspan", $rowspan); |
@@ -81,16 +81,16 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | public function mergeRow() { |
| 84 | - if (! $this->_rowMerged) { |
|
| 85 | - $this->_rowMerged = true; |
|
| 84 | + if (!$this->_rowMerged) { |
|
| 85 | + $this->_rowMerged=true; |
|
| 86 | 86 | return $this->setRowspan($this->_container->count()); |
| 87 | 87 | } |
| 88 | 88 | return $this->_container; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | public function mergeCol() { |
| 92 | - if (! $this->_colMerged) { |
|
| 93 | - $this->_colMerged = true; |
|
| 92 | + if (!$this->_colMerged) { |
|
| 93 | + $this->_colMerged=true; |
|
| 94 | 94 | return $this->setColspan($this->_container->getRow($this->_row) |
| 95 | 95 | ->count()); |
| 96 | 96 | } |
@@ -98,25 +98,25 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | public function setColspan($colspan) { |
| 101 | - $to = min($this->_container->getRow($this->_row)->count(), $this->_col + $colspan - 1); |
|
| 102 | - for ($i = $to; $i > $this->_col; $i --) { |
|
| 103 | - $this->_container->delete($this->_row, $this->_col + 1); |
|
| 101 | + $to=min($this->_container->getRow($this->_row)->count(), $this->_col+$colspan-1); |
|
| 102 | + for ($i=$to; $i>$this->_col; $i--) { |
|
| 103 | + $this->_container->delete($this->_row, $this->_col+1); |
|
| 104 | 104 | } |
| 105 | 105 | $this->setProperty("colspan", $colspan); |
| 106 | 106 | return $this->_container; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | public function getColspan() { |
| 110 | - $colspan = 1; |
|
| 110 | + $colspan=1; |
|
| 111 | 111 | if (\array_key_exists("colspan", $this->properties)) |
| 112 | - $colspan = $this->getProperty("colspan"); |
|
| 112 | + $colspan=$this->getProperty("colspan"); |
|
| 113 | 113 | return $colspan; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | public function getRowspan() { |
| 117 | - $rowspan = 1; |
|
| 117 | + $rowspan=1; |
|
| 118 | 118 | if (\array_key_exists("rowspan", $this->properties)) |
| 119 | - $rowspan = $this->getProperty("rowspan"); |
|
| 119 | + $rowspan=$this->getProperty("rowspan"); |
|
| 120 | 120 | return $rowspan; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -132,16 +132,16 @@ discard block |
||
| 132 | 132 | return $this; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - public function setSelectable($href = "#") { |
|
| 135 | + public function setSelectable($href="#") { |
|
| 136 | 136 | if (\is_string($this->content)) { |
| 137 | - $this->content = new HtmlLink("", $href, $this->content); |
|
| 137 | + $this->content=new HtmlLink("", $href, $this->content); |
|
| 138 | 138 | } |
| 139 | 139 | return $this->addToProperty("class", "selectable"); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | public function setWidth($width) { |
| 143 | 143 | if (\is_int($width)) { |
| 144 | - $width = Wide::getConstants()["W" . $width]; |
|
| 144 | + $width=Wide::getConstants()["W".$width]; |
|
| 145 | 145 | } |
| 146 | 146 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
| 147 | 147 | return $this->addToPropertyCtrl("class", "wide", array( |
@@ -150,12 +150,12 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | public function toDelete() { |
| 153 | - $this->_deleted = true; |
|
| 153 | + $this->_deleted=true; |
|
| 154 | 154 | return $this; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - public function compile(JsUtils $js = NULL, &$view = NULL) { |
|
| 158 | - if (! $this->_deleted) |
|
| 157 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 158 | + if (!$this->_deleted) |
|
| 159 | 159 | return parent::compile($js, $view); |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -15,13 +15,13 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | class HtmlTableContent extends HtmlSemCollection { |
| 17 | 17 | |
| 18 | - protected $_tdTagNames = [ |
|
| 18 | + protected $_tdTagNames=[ |
|
| 19 | 19 | "thead" => "th", |
| 20 | 20 | "tbody" => "td", |
| 21 | 21 | "tfoot" => "th" |
| 22 | 22 | ]; |
| 23 | 23 | |
| 24 | - protected $_merged = false; |
|
| 24 | + protected $_merged=false; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param int $rowCount |
| 31 | 31 | * @param int $colCount |
| 32 | 32 | */ |
| 33 | - public function __construct($identifier, $tagName = "tbody", $rowCount = NULL, $colCount = NULL) { |
|
| 33 | + public function __construct($identifier, $tagName="tbody", $rowCount=NULL, $colCount=NULL) { |
|
| 34 | 34 | parent::__construct($identifier, $tagName, ""); |
| 35 | 35 | if (isset($rowCount) && isset($colCount)) |
| 36 | 36 | $this->setRowCount($rowCount, $colCount); |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | * @return HtmlTableContent |
| 44 | 44 | */ |
| 45 | 45 | public function setRowCount($rowCount, $colCount) { |
| 46 | - $count = $this->count(); |
|
| 47 | - for ($i = $count; $i < $rowCount; $i ++) { |
|
| 46 | + $count=$this->count(); |
|
| 47 | + for ($i=$count; $i<$rowCount; $i++) { |
|
| 48 | 48 | $this->addItem($colCount); |
| 49 | 49 | } |
| 50 | 50 | return $this; |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public function refreshTR() { |
| 58 | - $this->_template = "%wrapContentBefore%%content%%wrapContentAfter%"; |
|
| 58 | + $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | * @return HtmlTR |
| 67 | 67 | */ |
| 68 | 68 | protected function createItem($value) { |
| 69 | - $count = $this->count(); |
|
| 70 | - $tr = new HtmlTR(""); |
|
| 69 | + $count=$this->count(); |
|
| 70 | + $tr=new HtmlTR(""); |
|
| 71 | 71 | $tr->setContainer($this, $count); |
| 72 | 72 | $tr->setTdTagName($this->_tdTagNames[$this->tagName]); |
| 73 | - if (isset($value) === true) { |
|
| 73 | + if (isset($value)===true) { |
|
| 74 | 74 | $tr->setColCount($value); |
| 75 | 75 | } |
| 76 | 76 | return $tr; |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | return $this->addItem($row); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - public function addMergeRow($colCount, $value = null) { |
|
| 102 | - $row = $this->addRow($colCount); |
|
| 101 | + public function addMergeRow($colCount, $value=null) { |
|
| 102 | + $row=$this->addRow($colCount); |
|
| 103 | 103 | $row->mergeCol(); |
| 104 | 104 | if (isset($value)) { |
| 105 | 105 | $row->setValues([ |
@@ -125,11 +125,11 @@ discard block |
||
| 125 | 125 | * @return HtmlTD|HtmlDoubleElement |
| 126 | 126 | */ |
| 127 | 127 | public function getCell($row, $col) { |
| 128 | - $row = $this->getItem($row); |
|
| 128 | + $row=$this->getItem($row); |
|
| 129 | 129 | if (isset($row) && $row instanceof HtmlCollection) { |
| 130 | - $col = $row->getItem($col); |
|
| 130 | + $col=$row->getItem($col); |
|
| 131 | 131 | } else { |
| 132 | - $col = $row; |
|
| 132 | + $col=$row; |
|
| 133 | 133 | } |
| 134 | 134 | return $col; |
| 135 | 135 | } |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | * @param mixed $value |
| 151 | 151 | * @return HtmlTableContent |
| 152 | 152 | */ |
| 153 | - public function setCellValue($row, $col, $value = "") { |
|
| 154 | - $cell = $this->getCell($row, $col); |
|
| 155 | - if (isset($cell) === true) { |
|
| 153 | + public function setCellValue($row, $col, $value="") { |
|
| 154 | + $cell=$this->getCell($row, $col); |
|
| 155 | + if (isset($cell)===true) { |
|
| 156 | 156 | $cell->setValue($value); |
| 157 | 157 | } |
| 158 | 158 | return $this; |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @param mixed $values |
| 165 | 165 | */ |
| 166 | - public function setValues($values = array()) { |
|
| 167 | - return $this->_addOrSetValues($values, function (HtmlTR $row, $_values) { |
|
| 166 | + public function setValues($values=array()) { |
|
| 167 | + return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) { |
|
| 168 | 168 | $row->setValues($_values); |
| 169 | 169 | }); |
| 170 | 170 | } |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @param mixed $values |
| 176 | 176 | */ |
| 177 | - public function addValues($values = array()) { |
|
| 178 | - return $this->_addOrSetValues($values, function (HtmlTR $row, $_values) { |
|
| 177 | + public function addValues($values=array()) { |
|
| 178 | + return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) { |
|
| 179 | 179 | $row->addValues($_values); |
| 180 | 180 | }); |
| 181 | 181 | } |
@@ -187,42 +187,42 @@ discard block |
||
| 187 | 187 | * @param callable $callback |
| 188 | 188 | */ |
| 189 | 189 | protected function _addOrSetValues($values, $callback) { |
| 190 | - $count = $this->count(); |
|
| 191 | - $isArray = true; |
|
| 192 | - if (! \is_array($values)) { |
|
| 193 | - $values = \array_fill(0, $count, $values); |
|
| 194 | - $isArray = false; |
|
| 190 | + $count=$this->count(); |
|
| 191 | + $isArray=true; |
|
| 192 | + if (!\is_array($values)) { |
|
| 193 | + $values=\array_fill(0, $count, $values); |
|
| 194 | + $isArray=false; |
|
| 195 | 195 | } |
| 196 | - if (JArray::dimension($values) == 1 && $isArray) |
|
| 197 | - $values = [ |
|
| 196 | + if (JArray::dimension($values)==1 && $isArray) |
|
| 197 | + $values=[ |
|
| 198 | 198 | $values |
| 199 | 199 | ]; |
| 200 | 200 | |
| 201 | - $count = \min(\sizeof($values), $count); |
|
| 201 | + $count=\min(\sizeof($values), $count); |
|
| 202 | 202 | |
| 203 | - for ($i = 0; $i < $count; $i ++) { |
|
| 204 | - $row = $this->content[$i]; |
|
| 203 | + for ($i=0; $i<$count; $i++) { |
|
| 204 | + $row=$this->content[$i]; |
|
| 205 | 205 | $callback($row, $values[$i]); |
| 206 | 206 | } |
| 207 | 207 | return $this; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - public function setColValues($colIndex, $values = array()) { |
|
| 211 | - $count = $this->count(); |
|
| 212 | - if (! \is_array($values)) { |
|
| 213 | - $values = \array_fill(0, $count, $values); |
|
| 210 | + public function setColValues($colIndex, $values=array()) { |
|
| 211 | + $count=$this->count(); |
|
| 212 | + if (!\is_array($values)) { |
|
| 213 | + $values=\array_fill(0, $count, $values); |
|
| 214 | 214 | } |
| 215 | - $count = \min(\sizeof($values), $count); |
|
| 216 | - for ($i = 0; $i < $count; $i ++) { |
|
| 215 | + $count=\min(\sizeof($values), $count); |
|
| 216 | + for ($i=0; $i<$count; $i++) { |
|
| 217 | 217 | $this->getCell($i, $colIndex)->setValue($values[$i]); |
| 218 | 218 | } |
| 219 | 219 | return $this; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - public function addColVariations($colIndex, $variations = array()) { |
|
| 223 | - $count = $this->count(); |
|
| 224 | - for ($i = 0; $i < $count; $i ++) { |
|
| 225 | - $cell = $this->getCell($i, $colIndex); |
|
| 222 | + public function addColVariations($colIndex, $variations=array()) { |
|
| 223 | + $count=$this->count(); |
|
| 224 | + for ($i=0; $i<$count; $i++) { |
|
| 225 | + $cell=$this->getCell($i, $colIndex); |
|
| 226 | 226 | if ($cell instanceof BaseTrait) |
| 227 | 227 | $cell->addVariations($variations); |
| 228 | 228 | } |
@@ -230,41 +230,41 @@ discard block |
||
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | public function addPropertyCol($colIndex, $name, $value) { |
| 233 | - $count = $this->count(); |
|
| 234 | - for ($i = 0; $i < $count; $i ++) { |
|
| 235 | - $cell = $this->getCell($i, $colIndex); |
|
| 233 | + $count=$this->count(); |
|
| 234 | + for ($i=0; $i<$count; $i++) { |
|
| 235 | + $cell=$this->getCell($i, $colIndex); |
|
| 236 | 236 | if (isset($cell)) |
| 237 | 237 | $cell->addToProperty($name, $value); |
| 238 | 238 | } |
| 239 | 239 | return $this; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - public function setRowValues($rowIndex, $values = array()) { |
|
| 243 | - $count = $this->count(); |
|
| 244 | - if (! \is_array($values)) { |
|
| 245 | - $values = \array_fill(0, $count, $values); |
|
| 242 | + public function setRowValues($rowIndex, $values=array()) { |
|
| 243 | + $count=$this->count(); |
|
| 244 | + if (!\is_array($values)) { |
|
| 245 | + $values=\array_fill(0, $count, $values); |
|
| 246 | 246 | } |
| 247 | 247 | $this->getItem($rowIndex)->setValues($values); |
| 248 | 248 | return $this; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | private function colAlign($colIndex, $function) { |
| 252 | - $count = $this->count(); |
|
| 253 | - for ($i = 0; $i < $count; $i ++) { |
|
| 254 | - $index = $this->content[$i]->getColPosition($colIndex); |
|
| 255 | - if ($index !== NULL) |
|
| 252 | + $count=$this->count(); |
|
| 253 | + for ($i=0; $i<$count; $i++) { |
|
| 254 | + $index=$this->content[$i]->getColPosition($colIndex); |
|
| 255 | + if ($index!==NULL) |
|
| 256 | 256 | $this->getCell($i, $index)->$function(); |
| 257 | 257 | } |
| 258 | 258 | return $this; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | private function colAlignFromRight($colIndex, $function) { |
| 262 | - $count = $this->count(); |
|
| 263 | - for ($i = 0; $i < $count; $i ++) { |
|
| 264 | - $maxRow = $this->content[$i]->count(); |
|
| 265 | - $index = $maxRow - $colIndex - 1; |
|
| 266 | - if (($cell = $this->getCell($i, $index)) !== NULL) { |
|
| 267 | - if ($cell->getColspan() == 1) |
|
| 262 | + $count=$this->count(); |
|
| 263 | + for ($i=0; $i<$count; $i++) { |
|
| 264 | + $maxRow=$this->content[$i]->count(); |
|
| 265 | + $index=$maxRow-$colIndex-1; |
|
| 266 | + if (($cell=$this->getCell($i, $index))!==NULL) { |
|
| 267 | + if ($cell->getColspan()==1) |
|
| 268 | 268 | $cell->$function(); |
| 269 | 269 | } |
| 270 | 270 | } |
@@ -310,9 +310,9 @@ discard block |
||
| 310 | 310 | * @return int |
| 311 | 311 | */ |
| 312 | 312 | public function getColCount() { |
| 313 | - $result = 0; |
|
| 314 | - if ($this->count() > 0) |
|
| 315 | - $result = $this->getItem(0)->count(); |
|
| 313 | + $result=0; |
|
| 314 | + if ($this->count()>0) |
|
| 315 | + $result=$this->getItem(0)->count(); |
|
| 316 | 316 | return $result; |
| 317 | 317 | } |
| 318 | 318 | |
@@ -323,10 +323,10 @@ discard block |
||
| 323 | 323 | * @param int $colIndex |
| 324 | 324 | * @return HtmlTableContent |
| 325 | 325 | */ |
| 326 | - public function delete($rowIndex, $colIndex = NULL) { |
|
| 326 | + public function delete($rowIndex, $colIndex=NULL) { |
|
| 327 | 327 | if (isset($colIndex)) { |
| 328 | - $row = $this->getItem($rowIndex); |
|
| 329 | - if (isset($row) === true) { |
|
| 328 | + $row=$this->getItem($rowIndex); |
|
| 329 | + if (isset($row)===true) { |
|
| 330 | 330 | $row->delete($colIndex); |
| 331 | 331 | } |
| 332 | 332 | } else { |
@@ -336,24 +336,24 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | public function toDelete($rowIndex, $colIndex) { |
| 339 | - $row = $this->getItem($rowIndex); |
|
| 340 | - if (isset($row) === true) |
|
| 339 | + $row=$this->getItem($rowIndex); |
|
| 340 | + if (isset($row)===true) |
|
| 341 | 341 | $row->toDelete($colIndex); |
| 342 | 342 | return $this; |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | public function toRowspanned($rowIndex, $colIndex) { |
| 346 | - $row = $this->getItem($rowIndex); |
|
| 347 | - if (isset($row) === true) |
|
| 346 | + $row=$this->getItem($rowIndex); |
|
| 347 | + if (isset($row)===true) |
|
| 348 | 348 | $row->toRowspanned($colIndex); |
| 349 | 349 | return $this; |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - public function mergeCol($rowIndex = 0, $colIndex = 0) { |
|
| 352 | + public function mergeCol($rowIndex=0, $colIndex=0) { |
|
| 353 | 353 | return $this->getItem($rowIndex)->mergeCol($colIndex); |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - public function mergeRow($rowIndex = 0, $colIndex = 0) { |
|
| 356 | + public function mergeRow($rowIndex=0, $colIndex=0) { |
|
| 357 | 357 | return $this->getItem($rowIndex)->mergeRow($colIndex); |
| 358 | 358 | } |
| 359 | 359 | |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | * @return HtmlTableContent |
| 374 | 374 | */ |
| 375 | 375 | public function conditionalCellFormat($callback, $format) { |
| 376 | - $rows = $this->content; |
|
| 376 | + $rows=$this->content; |
|
| 377 | 377 | foreach ($rows as $row) { |
| 378 | 378 | $row->conditionalCellFormat($callback, $format); |
| 379 | 379 | } |
@@ -381,9 +381,9 @@ discard block |
||
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | public function conditionalColFormat($colIndex, $callback, $format) { |
| 384 | - $rows = $this->content; |
|
| 384 | + $rows=$this->content; |
|
| 385 | 385 | foreach ($rows as $row) { |
| 386 | - $cell = $row->getItem($colIndex); |
|
| 386 | + $cell=$row->getItem($colIndex); |
|
| 387 | 387 | $cell->conditionnalCellFormat($callback, $format); |
| 388 | 388 | } |
| 389 | 389 | return $this; |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | * @return HtmlTableContent |
| 397 | 397 | */ |
| 398 | 398 | public function conditionalRowFormat($callback, $format) { |
| 399 | - $rows = $this->content; |
|
| 399 | + $rows=$this->content; |
|
| 400 | 400 | foreach ($rows as $row) { |
| 401 | 401 | $row->conditionalRowFormat($callback, $format); |
| 402 | 402 | } |
@@ -404,9 +404,9 @@ discard block |
||
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | public function hideColumn($colIndex) { |
| 407 | - $rows = $this->content; |
|
| 407 | + $rows=$this->content; |
|
| 408 | 408 | foreach ($rows as $row) { |
| 409 | - $cell = $row->getItem($colIndex); |
|
| 409 | + $cell=$row->getItem($colIndex); |
|
| 410 | 410 | $cell->addToProperty("style", "display:none;"); |
| 411 | 411 | } |
| 412 | 412 | return $this; |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | * @return HtmlTableContent |
| 419 | 419 | */ |
| 420 | 420 | public function applyCells($callback) { |
| 421 | - $rows = $this->content; |
|
| 421 | + $rows=$this->content; |
|
| 422 | 422 | foreach ($rows as $row) { |
| 423 | 423 | $row->applyCells($callback); |
| 424 | 424 | } |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | * @return HtmlTableContent |
| 432 | 432 | */ |
| 433 | 433 | public function applyRows($callback) { |
| 434 | - $rows = $this->content; |
|
| 434 | + $rows=$this->content; |
|
| 435 | 435 | foreach ($rows as $row) { |
| 436 | 436 | $row->apply($callback); |
| 437 | 437 | } |
@@ -446,28 +446,28 @@ discard block |
||
| 446 | 446 | * @see https://fomantic-ui.com/collections/table.html#definition needs rowspanned class |
| 447 | 447 | * @since fomantic-ui 2.4.8 |
| 448 | 448 | */ |
| 449 | - public function mergeIdentiqualValues($colIndex, $function = "strip_tags") { |
|
| 450 | - $rows = $this->content; |
|
| 451 | - $identiqual = null; |
|
| 452 | - $counter = 0; |
|
| 453 | - $cellToMerge = null; |
|
| 454 | - $functionExists = \function_exists($function); |
|
| 449 | + public function mergeIdentiqualValues($colIndex, $function="strip_tags") { |
|
| 450 | + $rows=$this->content; |
|
| 451 | + $identiqual=null; |
|
| 452 | + $counter=0; |
|
| 453 | + $cellToMerge=null; |
|
| 454 | + $functionExists=\function_exists($function); |
|
| 455 | 455 | foreach ($rows as $row) { |
| 456 | - $cell = $row->getItem($colIndex); |
|
| 457 | - $value = $cell->getContent(); |
|
| 456 | + $cell=$row->getItem($colIndex); |
|
| 457 | + $value=$cell->getContent(); |
|
| 458 | 458 | if ($functionExists) |
| 459 | - $value = \call_user_func($function, $value); |
|
| 460 | - if ($value !== $identiqual) { |
|
| 461 | - if ($counter > 0 && isset($cellToMerge)) { |
|
| 459 | + $value=\call_user_func($function, $value); |
|
| 460 | + if ($value!==$identiqual) { |
|
| 461 | + if ($counter>0 && isset($cellToMerge)) { |
|
| 462 | 462 | $cellToMerge->setRowspanned($counter); |
| 463 | 463 | } |
| 464 | - $counter = 0; |
|
| 465 | - $cellToMerge = $cell; |
|
| 466 | - $identiqual = $value; |
|
| 464 | + $counter=0; |
|
| 465 | + $cellToMerge=$cell; |
|
| 466 | + $identiqual=$value; |
|
| 467 | 467 | } |
| 468 | - $counter ++; |
|
| 468 | + $counter++; |
|
| 469 | 469 | } |
| 470 | - if ($counter > 0 && isset($cellToMerge)) { |
|
| 470 | + if ($counter>0 && isset($cellToMerge)) { |
|
| 471 | 471 | $cellToMerge->setRowspanned($counter); |
| 472 | 472 | } |
| 473 | 473 | return $this; |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | public function _setMerged($value) { |
| 481 | - $this->_merged = $value; |
|
| 481 | + $this->_merged=$value; |
|
| 482 | 482 | return $this; |
| 483 | 483 | } |
| 484 | 484 | } |