@@ -13,21 +13,21 @@ discard block |
||
| 13 | 13 | use Ajax\semantic\html\elements\html5\HtmlDatalist; |
| 14 | 14 | |
| 15 | 15 | class HtmlInput extends HtmlSemDoubleElement { |
| 16 | - use IconTrait,TextFieldsTrait,FieldTrait; |
|
| 16 | + use IconTrait, TextFieldsTrait, FieldTrait; |
|
| 17 | 17 | |
| 18 | - public function __construct($identifier, $type = "text", $value = "", $placeholder = "") { |
|
| 19 | - parent::__construct("div-" . $identifier, "div", "ui input"); |
|
| 20 | - $this->_identifier = $identifier; |
|
| 21 | - $this->_libraryId = $identifier; |
|
| 22 | - $this->content = [ |
|
| 18 | + public function __construct($identifier, $type="text", $value="", $placeholder="") { |
|
| 19 | + parent::__construct("div-".$identifier, "div", "ui input"); |
|
| 20 | + $this->_identifier=$identifier; |
|
| 21 | + $this->_libraryId=$identifier; |
|
| 22 | + $this->content=[ |
|
| 23 | 23 | "field" => new HtmlInput5($identifier, $type, $value, $placeholder) |
| 24 | 24 | ]; |
| 25 | - $this->_states = [ |
|
| 25 | + $this->_states=[ |
|
| 26 | 26 | State::DISABLED, |
| 27 | 27 | State::FOCUS, |
| 28 | 28 | State::ERROR |
| 29 | 29 | ]; |
| 30 | - $this->_variations = [ |
|
| 30 | + $this->_variations=[ |
|
| 31 | 31 | Variation::TRANSPARENT |
| 32 | 32 | ]; |
| 33 | 33 | } |
@@ -40,16 +40,16 @@ discard block |
||
| 40 | 40 | return $this->content["field"]; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public static function outline($identifier, $icon, $value = "", $placeholder = "") { |
|
| 44 | - $result = new HtmlInput($identifier, "text", $value, $placeholder); |
|
| 43 | + public static function outline($identifier, $icon, $value="", $placeholder="") { |
|
| 44 | + $result=new HtmlInput($identifier, "text", $value, $placeholder); |
|
| 45 | 45 | $result->addToProperty("class", "transparent"); |
| 46 | 46 | $result->addIcon($icon)->setOutline(); |
| 47 | 47 | return $result; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public function run(JsUtils $js) { |
| 51 | - $result = parent::run($js); |
|
| 52 | - $result->attach("#" . $this->getDataField() |
|
| 51 | + $result=parent::run($js); |
|
| 52 | + $result->attach("#".$this->getDataField() |
|
| 53 | 53 | ->getIdentifier()); |
| 54 | 54 | return $result; |
| 55 | 55 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | return $this->addToProperty("class", "transparent"); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - public function compile_once(\Ajax\JsUtils $js = NULL, &$view = NULL) { |
|
| 61 | + public function compile_once(\Ajax\JsUtils $js=NULL, &$view=NULL) { |
|
| 62 | 62 | parent::compile_once($js, $view); |
| 63 | 63 | if (isset($this->content['file'])) { |
| 64 | 64 | $this->onCreate(Javascript::fileUploadBehavior($this->identifier)); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | public function addDataList($items) { |
| 69 | - $dl = new HtmlDatalist('list-' . $this->identifier); |
|
| 69 | + $dl=new HtmlDatalist('list-'.$this->identifier); |
|
| 70 | 70 | $dl->addItems($items); |
| 71 | 71 | $this->getDataField()->setProperty('list', $dl->getIdentifier()); |
| 72 | 72 | $this->getDataField()->wrap($dl); |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | protected function createItem($value) { |
| 14 | - $elm = new HtmlDoubleElement("", "option"); |
|
| 14 | + $elm=new HtmlDoubleElement("", "option"); |
|
| 15 | 15 | $elm->setProperty("value", $value); |
| 16 | 16 | $elm->setContent($value); |
| 17 | 17 | return $elm; |
@@ -63,8 +63,9 @@ discard block |
||
| 63 | 63 | $retour .= $this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null)) . "});\n"; |
| 64 | 64 | |
| 65 | 65 | $retour = $this->_addJsCondition($jsCondition, $retour); |
| 66 | - if ($immediatly) |
|
| 67 | - $this->jquery_code_for_compile[] = $retour; |
|
| 66 | + if ($immediatly) { |
|
| 67 | + $this->jquery_code_for_compile[] = $retour; |
|
| 68 | + } |
|
| 68 | 69 | return $retour; |
| 69 | 70 | } |
| 70 | 71 | |
@@ -119,8 +120,9 @@ discard block |
||
| 119 | 120 | $retour .= "url=url+'" . $slash . "'+$(this).html();\n"; |
| 120 | 121 | } elseif (\substr($attr, 0, 3) === "js:") { |
| 121 | 122 | $retour .= "url=url+'" . $slash . "'+" . \substr($attr, 3) . ";\n"; |
| 122 | - } elseif ($attr !== null && $attr !== "") |
|
| 123 | - $retour .= "url=url+'" . $slash . "'+($(this).attr('" . $attr . "')||'');\n"; |
|
| 123 | + } elseif ($attr !== null && $attr !== "") { |
|
| 124 | + $retour .= "url=url+'" . $slash . "'+($(this).attr('" . $attr . "')||'');\n"; |
|
| 125 | + } |
|
| 124 | 126 | } |
| 125 | 127 | return $retour; |
| 126 | 128 | } |
@@ -144,10 +146,11 @@ discard block |
||
| 144 | 146 | } elseif (isset($this->ajaxTransition)) { |
| 145 | 147 | $call = $this->ajaxTransition; |
| 146 | 148 | } |
| 147 | - if (\is_callable($call)) |
|
| 148 | - $retour = "\t" . $call($responseElement, $jqueryDone) . ";\n"; |
|
| 149 | - else |
|
| 150 | - $retour = "\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
| 149 | + if (\is_callable($call)) { |
|
| 150 | + $retour = "\t" . $call($responseElement, $jqueryDone) . ";\n"; |
|
| 151 | + } else { |
|
| 152 | + $retour = "\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
| 153 | + } |
|
| 151 | 154 | } |
| 152 | 155 | if (isset($history)) { |
| 153 | 156 | if ($this->params["autoActiveLinks"]) { |
@@ -170,8 +173,9 @@ discard block |
||
| 170 | 173 | } |
| 171 | 174 | |
| 172 | 175 | protected function _correctAjaxUrl($url) { |
| 173 | - if ($url !== "/" && JString::endsWith($url, "/") === true) |
|
| 174 | - $url = substr($url, 0, strlen($url) - 1); |
|
| 176 | + if ($url !== "/" && JString::endsWith($url, "/") === true) { |
|
| 177 | + $url = substr($url, 0, strlen($url) - 1); |
|
| 178 | + } |
|
| 175 | 179 | if (strncmp($url, 'http://', 7) != 0 && strncmp($url, 'https://', 8) != 0) { |
| 176 | 180 | $url = $this->getUrl($url); |
| 177 | 181 | } |
@@ -195,8 +199,9 @@ discard block |
||
| 195 | 199 | public static function _implodeParams($parameters) { |
| 196 | 200 | $allParameters = []; |
| 197 | 201 | foreach ($parameters as $params) { |
| 198 | - if (isset($params)) |
|
| 199 | - $allParameters[] = self::_correctParams($params); |
|
| 202 | + if (isset($params)) { |
|
| 203 | + $allParameters[] = self::_correctParams($params); |
|
| 204 | + } |
|
| 200 | 205 | } |
| 201 | 206 | return \implode("+'&'+", $allParameters); |
| 202 | 207 | } |
@@ -222,8 +227,9 @@ discard block |
||
| 222 | 227 | |
| 223 | 228 | protected function setDefaultParameters(&$parameters, $default) { |
| 224 | 229 | foreach ($default as $k => $v) { |
| 225 | - if (! isset($parameters[$k])) |
|
| 226 | - $parameters[$k] = $v; |
|
| 230 | + if (! isset($parameters[$k])) { |
|
| 231 | + $parameters[$k] = $v; |
|
| 232 | + } |
|
| 227 | 233 | } |
| 228 | 234 | } |
| 229 | 235 | |
@@ -755,8 +761,9 @@ discard block |
||
| 755 | 761 | $retour .= "$('#" . $form . "').submit();\n"; |
| 756 | 762 | } |
| 757 | 763 | $retour = $this->_addJsCondition($jsCondition, $retour); |
| 758 | - if ($immediatly) |
|
| 759 | - $this->jquery_code_for_compile[] = $retour; |
|
| 764 | + if ($immediatly) { |
|
| 765 | + $this->jquery_code_for_compile[] = $retour; |
|
| 766 | + } |
|
| 760 | 767 | return $retour; |
| 761 | 768 | } |
| 762 | 769 | |
@@ -15,63 +15,63 @@ 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 === 'response') { |
|
| 41 | + } elseif ($hasLoader==='response') { |
|
| 42 | 42 | $this->addResponseLoading($retour, $responseElement, $ajaxLoader); |
| 43 | - } elseif ($hasLoader === 'internal') { |
|
| 44 | - $retour .= "\n$(this).addClass('loading');"; |
|
| 43 | + } elseif ($hasLoader==='internal') { |
|
| 44 | + $retour.="\n$(this).addClass('loading');"; |
|
| 45 | 45 | } |
| 46 | - $ajaxParameters = [ |
|
| 46 | + $ajaxParameters=[ |
|
| 47 | 47 | "url" => "url", |
| 48 | - "method" => "'" . \strtoupper($method) . "'" |
|
| 48 | + "method" => "'".\strtoupper($method)."'" |
|
| 49 | 49 | ]; |
| 50 | 50 | |
| 51 | - $ajaxParameters["async"] = ($async ? "true" : "false"); |
|
| 51 | + $ajaxParameters["async"]=($async ? "true" : "false"); |
|
| 52 | 52 | |
| 53 | 53 | if (isset($params)) { |
| 54 | - $ajaxParameters["data"] = self::_correctParams($params, $parameters); |
|
| 54 | + $ajaxParameters["data"]=self::_correctParams($params, $parameters); |
|
| 55 | 55 | } |
| 56 | 56 | if (isset($headers)) { |
| 57 | - $ajaxParameters["headers"] = $headers; |
|
| 57 | + $ajaxParameters["headers"]=$headers; |
|
| 58 | 58 | } |
| 59 | 59 | if (isset($partial)) { |
| 60 | - $ajaxParameters["xhr"] = "xhrProvider"; |
|
| 61 | - $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 | + $ajaxParameters["xhr"]="xhrProvider"; |
|
| 61 | + $retour.="var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;".$partial.";}; };"; |
|
| 62 | 62 | } |
| 63 | 63 | $this->createAjaxParameters($ajaxParameters, $parameters); |
| 64 | - $retour .= "$.ajax({" . $this->implodeAjaxParameters($ajaxParameters) . "}).done(function( data, textStatus, jqXHR ) {\n"; |
|
| 65 | - $retour .= $this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null)) . "});\n"; |
|
| 64 | + $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n"; |
|
| 65 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null))."});\n"; |
|
| 66 | 66 | |
| 67 | - $retour = $this->_addJsCondition($jsCondition, $retour); |
|
| 67 | + $retour=$this->_addJsCondition($jsCondition, $retour); |
|
| 68 | 68 | if ($immediatly) |
| 69 | - $this->jquery_code_for_compile[] = $retour; |
|
| 69 | + $this->jquery_code_for_compile[]=$retour; |
|
| 70 | 70 | return $retour; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | protected function createAjaxParameters(&$original, $parameters) { |
| 74 | - $validParameters = [ |
|
| 74 | + $validParameters=[ |
|
| 75 | 75 | "contentType" => "%value%", |
| 76 | 76 | "dataType" => "'%value%'", |
| 77 | 77 | "beforeSend" => "function(jqXHR,settings){%value%}", |
@@ -80,21 +80,21 @@ discard block |
||
| 80 | 80 | ]; |
| 81 | 81 | foreach ($validParameters as $param => $mask) { |
| 82 | 82 | if (isset($parameters[$param])) { |
| 83 | - $original[$param] = \str_replace("%value%", $parameters[$param], $mask); |
|
| 83 | + $original[$param]=\str_replace("%value%", $parameters[$param], $mask); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | protected function implodeAjaxParameters($ajaxParameters) { |
| 89 | - $s = ''; |
|
| 89 | + $s=''; |
|
| 90 | 90 | foreach ($ajaxParameters as $k => $v) { |
| 91 | - if ($s !== '') { |
|
| 92 | - $s .= ','; |
|
| 91 | + if ($s!=='') { |
|
| 92 | + $s.=','; |
|
| 93 | 93 | } |
| 94 | 94 | if (is_array($v)) { |
| 95 | - $s .= "'{$k}':{" . self::implodeAjaxParameters($v) . "}"; |
|
| 95 | + $s.="'{$k}':{".self::implodeAjaxParameters($v)."}"; |
|
| 96 | 96 | } else { |
| 97 | - $s .= "'{$k}':{$v}"; |
|
| 97 | + $s.="'{$k}':{$v}"; |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | return $s; |
@@ -102,27 +102,27 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | protected function _addJsCondition($jsCondition, $jsSource) { |
| 104 | 104 | if (isset($jsCondition)) { |
| 105 | - return "if(" . $jsCondition . "){\n" . $jsSource . "\n}"; |
|
| 105 | + return "if(".$jsCondition."){\n".$jsSource."\n}"; |
|
| 106 | 106 | } |
| 107 | 107 | return $jsSource; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | protected function _getAjaxUrl($url, $attr) { |
| 111 | - $url = $this->_correctAjaxUrl($url); |
|
| 112 | - $retour = "url='" . $url . "';"; |
|
| 113 | - $slash = "/"; |
|
| 114 | - if (JString::endswith($url, "/") === true) { |
|
| 115 | - $slash = ""; |
|
| 111 | + $url=$this->_correctAjaxUrl($url); |
|
| 112 | + $retour="url='".$url."';"; |
|
| 113 | + $slash="/"; |
|
| 114 | + if (JString::endswith($url, "/")===true) { |
|
| 115 | + $slash=""; |
|
| 116 | 116 | } |
| 117 | 117 | if (JString::isNotNull($attr)) { |
| 118 | - if ($attr === "value") { |
|
| 119 | - $retour .= "url=url+'" . $slash . "'+$(this).val();\n"; |
|
| 120 | - } elseif ($attr === "html") { |
|
| 121 | - $retour .= "url=url+'" . $slash . "'+$(this).html();\n"; |
|
| 122 | - } elseif (\substr($attr, 0, 3) === "js:") { |
|
| 123 | - $retour .= "url=url+'" . $slash . "'+" . \substr($attr, 3) . ";\n"; |
|
| 124 | - } elseif ($attr !== null && $attr !== "") |
|
| 125 | - $retour .= "url=url+'" . $slash . "'+($(this).attr('" . $attr . "')||'');\n"; |
|
| 118 | + if ($attr==="value") { |
|
| 119 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 120 | + } elseif ($attr==="html") { |
|
| 121 | + $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
| 122 | + } elseif (\substr($attr, 0, 3)==="js:") { |
|
| 123 | + $retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n"; |
|
| 124 | + } elseif ($attr!==null && $attr!=="") |
|
| 125 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 126 | 126 | } |
| 127 | 127 | return $retour; |
| 128 | 128 | } |
@@ -131,99 +131,99 @@ discard block |
||
| 131 | 131 | return "window.onpopstate = function(e){if(e.state){var target=e.state.jqueryDone;$(e.state.selector)[target](e.state.html);}};"; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - protected function autoActiveLinks($previousURL = "window.location.href") { |
|
| 135 | - $result = "\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}"; |
|
| 136 | - $result .= "\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;"; |
|
| 134 | + protected function autoActiveLinks($previousURL="window.location.href") { |
|
| 135 | + $result="\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}"; |
|
| 136 | + $result.="\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;"; |
|
| 137 | 137 | return $result; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader = false, $history = null) { |
|
| 141 | - $retour = ""; |
|
| 142 | - $call = null; |
|
| 140 | + protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader=false, $history=null) { |
|
| 141 | + $retour=""; |
|
| 142 | + $call=null; |
|
| 143 | 143 | if (JString::isNotNull($responseElement)) { |
| 144 | 144 | if (isset($ajaxTransition)) { |
| 145 | - $call = $this->setAjaxDataCall($ajaxTransition); |
|
| 145 | + $call=$this->setAjaxDataCall($ajaxTransition); |
|
| 146 | 146 | } elseif (isset($this->ajaxTransition)) { |
| 147 | - $call = $this->ajaxTransition; |
|
| 147 | + $call=$this->ajaxTransition; |
|
| 148 | 148 | } |
| 149 | 149 | if (\is_callable($call)) |
| 150 | - $retour = "\t" . $call($responseElement, $jqueryDone) . ";\n"; |
|
| 150 | + $retour="\t".$call($responseElement, $jqueryDone).";\n"; |
|
| 151 | 151 | else |
| 152 | - $retour = "\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
| 152 | + $retour="\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
| 153 | 153 | } |
| 154 | 154 | if (isset($history)) { |
| 155 | 155 | if ($this->params["autoActiveLinks"]) { |
| 156 | - $retour .= $this->autoActiveLinks("url"); |
|
| 156 | + $retour.=$this->autoActiveLinks("url"); |
|
| 157 | 157 | } |
| 158 | - $retour .= "\nwindow.history.pushState({'html':data,'selector':" . Javascript::prep_value($history) . ",'jqueryDone':'{$jqueryDone}'},'', url);"; |
|
| 158 | + $retour.="\nwindow.history.pushState({'html':data,'selector':".Javascript::prep_value($history).",'jqueryDone':'{$jqueryDone}'},'', url);"; |
|
| 159 | 159 | } |
| 160 | - if ($hasLoader === "internal") { |
|
| 161 | - $retour .= "\n$(self).removeClass('loading');"; |
|
| 160 | + if ($hasLoader==="internal") { |
|
| 161 | + $retour.="\n$(self).removeClass('loading');"; |
|
| 162 | 162 | } |
| 163 | - $retour .= "\t" . $jsCallback . "\n"; |
|
| 163 | + $retour.="\t".$jsCallback."\n"; |
|
| 164 | 164 | return $retour; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | protected function _getResponseElement($responseElement) { |
| 168 | 168 | if (JString::isNotNull($responseElement)) { |
| 169 | - $responseElement = Javascript::prep_jquery_selector($responseElement); |
|
| 169 | + $responseElement=Javascript::prep_jquery_selector($responseElement); |
|
| 170 | 170 | } |
| 171 | 171 | return $responseElement; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | protected function _correctAjaxUrl($url) { |
| 175 | - if ($url !== "/" && JString::endsWith($url, "/") === true) |
|
| 176 | - $url = substr($url, 0, strlen($url) - 1); |
|
| 177 | - if (strncmp($url, 'http://', 7) != 0 && strncmp($url, 'https://', 8) != 0) { |
|
| 178 | - $url = $this->getUrl($url); |
|
| 175 | + if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
| 176 | + $url=substr($url, 0, strlen($url)-1); |
|
| 177 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
| 178 | + $url=$this->getUrl($url); |
|
| 179 | 179 | } |
| 180 | 180 | return $url; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - public static function _correctParams($params, $ajaxParameters = []) { |
|
| 183 | + public static function _correctParams($params, $ajaxParameters=[]) { |
|
| 184 | 184 | if (JString::isNull($params)) { |
| 185 | 185 | return ""; |
| 186 | 186 | } |
| 187 | 187 | if (\preg_match("@^\{.*?\}$@", $params)) { |
| 188 | - if (! isset($ajaxParameters['contentType']) || ! JString::contains($ajaxParameters['contentType'], 'json')) { |
|
| 189 | - return '$.param(' . $params . ')'; |
|
| 188 | + if (!isset($ajaxParameters['contentType']) || !JString::contains($ajaxParameters['contentType'], 'json')) { |
|
| 189 | + return '$.param('.$params.')'; |
|
| 190 | 190 | } else { |
| 191 | - return 'JSON.stringify(' . $params . ')'; |
|
| 191 | + return 'JSON.stringify('.$params.')'; |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | return $params; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | public static function _implodeParams($parameters) { |
| 198 | - $allParameters = []; |
|
| 198 | + $allParameters=[]; |
|
| 199 | 199 | foreach ($parameters as $params) { |
| 200 | 200 | if (isset($params)) |
| 201 | - $allParameters[] = self::_correctParams($params); |
|
| 201 | + $allParameters[]=self::_correctParams($params); |
|
| 202 | 202 | } |
| 203 | 203 | return \implode("+'&'+", $allParameters); |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - protected function addLoading(&$retour, $responseElement, $ajaxLoader = null) { |
|
| 207 | - if (! isset($ajaxLoader)) { |
|
| 208 | - $ajaxLoader = $this->ajaxLoader; |
|
| 206 | + protected function addLoading(&$retour, $responseElement, $ajaxLoader=null) { |
|
| 207 | + if (!isset($ajaxLoader)) { |
|
| 208 | + $ajaxLoader=$this->ajaxLoader; |
|
| 209 | 209 | } |
| 210 | - $loading_notifier = '<div class="ajax-loader ui active inverted dimmer">' . $ajaxLoader . '</div>'; |
|
| 211 | - $retour .= "\t\t{$responseElement}.append('{$loading_notifier}');\n"; |
|
| 210 | + $loading_notifier='<div class="ajax-loader ui active inverted dimmer">'.$ajaxLoader.'</div>'; |
|
| 211 | + $retour.="\t\t{$responseElement}.append('{$loading_notifier}');\n"; |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - protected function addResponseLoading(&$retour, $responseElement, $ajaxLoader = null) { |
|
| 215 | - if (! isset($ajaxLoader)) { |
|
| 216 | - $ajaxLoader = $this->ajaxLoader; |
|
| 214 | + protected function addResponseLoading(&$retour, $responseElement, $ajaxLoader=null) { |
|
| 215 | + if (!isset($ajaxLoader)) { |
|
| 216 | + $ajaxLoader=$this->ajaxLoader; |
|
| 217 | 217 | } |
| 218 | - $loading_notifier = '<div class="ajax-loader">' . $ajaxLoader . '</div>'; |
|
| 219 | - $retour .= "{$responseElement}.empty();\n"; |
|
| 220 | - $retour .= "\t\t{$responseElement}.prepend('{$loading_notifier}');\n"; |
|
| 218 | + $loading_notifier='<div class="ajax-loader">'.$ajaxLoader.'</div>'; |
|
| 219 | + $retour.="{$responseElement}.empty();\n"; |
|
| 220 | + $retour.="\t\t{$responseElement}.prepend('{$loading_notifier}');\n"; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | protected function setAjaxDataCall($params) { |
| 224 | - $result = null; |
|
| 225 | - if (! \is_callable($params)) { |
|
| 226 | - $result = function ($responseElement, $jqueryDone = "html") use ($params) { |
|
| 224 | + $result=null; |
|
| 225 | + if (!\is_callable($params)) { |
|
| 226 | + $result=function($responseElement, $jqueryDone="html") use ($params) { |
|
| 227 | 227 | return AjaxTransition::{$params}($responseElement, $jqueryDone); |
| 228 | 228 | }; |
| 229 | 229 | } |
@@ -232,13 +232,13 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | protected function setDefaultParameters(&$parameters, $default) { |
| 234 | 234 | foreach ($default as $k => $v) { |
| 235 | - if (! isset($parameters[$k])) |
|
| 236 | - $parameters[$k] = $v; |
|
| 235 | + if (!isset($parameters[$k])) |
|
| 236 | + $parameters[$k]=$v; |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | public function setAjaxLoader($loader) { |
| 241 | - $this->ajaxLoader = $loader; |
|
| 241 | + $this->ajaxLoader=$loader; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * @param string $responseElement |
| 250 | 250 | * selector of the HTML element displaying the answer |
| 251 | 251 | */ |
| 252 | - private function _get($url, $responseElement = "", $parameters = []) { |
|
| 252 | + private function _get($url, $responseElement="", $parameters=[]) { |
|
| 253 | 253 | return $this->_ajax("get", $url, $responseElement, $parameters); |
| 254 | 254 | } |
| 255 | 255 | |
@@ -263,8 +263,8 @@ discard block |
||
| 263 | 263 | * @param array $parameters |
| 264 | 264 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 265 | 265 | */ |
| 266 | - public function get($url, $responseElement = "", $parameters = []) { |
|
| 267 | - $parameters["immediatly"] = true; |
|
| 266 | + public function get($url, $responseElement="", $parameters=[]) { |
|
| 267 | + $parameters["immediatly"]=true; |
|
| 268 | 268 | return $this->_get($url, $responseElement, $parameters); |
| 269 | 269 | } |
| 270 | 270 | |
@@ -280,8 +280,8 @@ discard block |
||
| 280 | 280 | * @param array $parameters |
| 281 | 281 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 282 | 282 | */ |
| 283 | - public function ajax($method, $url, $responseElement = "", $parameters = []) { |
|
| 284 | - $parameters["immediatly"] = true; |
|
| 283 | + public function ajax($method, $url, $responseElement="", $parameters=[]) { |
|
| 284 | + $parameters["immediatly"]=true; |
|
| 285 | 285 | return $this->_ajax($method, $url, $responseElement, $parameters); |
| 286 | 286 | } |
| 287 | 287 | |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * $immediatly |
| 304 | 304 | * @return string |
| 305 | 305 | */ |
| 306 | - public function ajaxInterval($method, $url, $interval, $globalName = null, $responseElement = "", $parameters = [], $immediatly = true) { |
|
| 306 | + public function ajaxInterval($method, $url, $interval, $globalName=null, $responseElement="", $parameters=[], $immediatly=true) { |
|
| 307 | 307 | return $this->interval($this->ajaxDeferred($method, $url, $responseElement, $parameters), $interval, $globalName, $immediatly); |
| 308 | 308 | } |
| 309 | 309 | |
@@ -319,8 +319,8 @@ discard block |
||
| 319 | 319 | * @param array $parameters |
| 320 | 320 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 321 | 321 | */ |
| 322 | - public function ajaxDeferred($method, $url, $responseElement = "", $parameters = []) { |
|
| 323 | - $parameters["immediatly"] = false; |
|
| 322 | + public function ajaxDeferred($method, $url, $responseElement="", $parameters=[]) { |
|
| 323 | + $parameters["immediatly"]=false; |
|
| 324 | 324 | return $this->_ajax($method, $url, $responseElement, $parameters); |
| 325 | 325 | } |
| 326 | 326 | |
@@ -334,15 +334,15 @@ discard block |
||
| 334 | 334 | * @param array $parameters |
| 335 | 335 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null) |
| 336 | 336 | */ |
| 337 | - private function _json($url, $method = "get", $parameters = []) { |
|
| 338 | - $parameters = \array_merge($parameters, [ |
|
| 337 | + private function _json($url, $method="get", $parameters=[]) { |
|
| 338 | + $parameters=\array_merge($parameters, [ |
|
| 339 | 339 | "hasLoader" => false |
| 340 | 340 | ]); |
| 341 | - $jsCallback = isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
| 342 | - $context = isset($parameters['context']) ? $parameters['context'] : "document"; |
|
| 343 | - $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"; |
|
| 344 | - $retour .= "\t$(document).trigger('jsonReady',[data]);\n"; |
|
| 345 | - $parameters["jsCallback"] = $retour; |
|
| 341 | + $jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
| 342 | + $context=isset($parameters['context']) ? $parameters['context'] : "document"; |
|
| 343 | + $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"; |
|
| 344 | + $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
|
| 345 | + $parameters["jsCallback"]=$retour; |
|
| 346 | 346 | return $this->_ajax($method, $url, null, $parameters); |
| 347 | 347 | } |
| 348 | 348 | |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | * @param array $parameters |
| 357 | 357 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null) |
| 358 | 358 | */ |
| 359 | - public function json($url, $method = "get", $parameters = []) { |
|
| 359 | + public function json($url, $method="get", $parameters=[]) { |
|
| 360 | 360 | return $this->_json($url, $method, $parameters); |
| 361 | 361 | } |
| 362 | 362 | |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | * @param array $parameters |
| 373 | 373 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true,"before"=>null) |
| 374 | 374 | */ |
| 375 | - public function jsonOn($event, $element, $url, $method = "get", $parameters = array()) { |
|
| 375 | + public function jsonOn($event, $element, $url, $method="get", $parameters=array()) { |
|
| 376 | 376 | $this->setDefaultParameters($parameters, [ |
| 377 | 377 | "preventDefault" => true, |
| 378 | 378 | "stopPropagation" => true, |
@@ -391,8 +391,8 @@ discard block |
||
| 391 | 391 | * @param array $parameters |
| 392 | 392 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null) |
| 393 | 393 | */ |
| 394 | - public function jsonDeferred($url, $method = "get", $parameters = []) { |
|
| 395 | - $parameters["immediatly"] = false; |
|
| 394 | + public function jsonDeferred($url, $method="get", $parameters=[]) { |
|
| 395 | + $parameters["immediatly"]=false; |
|
| 396 | 396 | return $this->_json($url, $method, $parameters); |
| 397 | 397 | } |
| 398 | 398 | |
@@ -407,29 +407,29 @@ discard block |
||
| 407 | 407 | * @param array $parameters |
| 408 | 408 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json","before"=>null) |
| 409 | 409 | */ |
| 410 | - private function _jsonArray($maskSelector, $url, $method = "get", $parameters = []) { |
|
| 411 | - $parameters = \array_merge($parameters, [ |
|
| 410 | + private function _jsonArray($maskSelector, $url, $method="get", $parameters=[]) { |
|
| 411 | + $parameters=\array_merge($parameters, [ |
|
| 412 | 412 | "hasLoader" => false |
| 413 | 413 | ]); |
| 414 | - $rowClass = isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json"; |
|
| 415 | - $jsCallback = isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
| 416 | - $context = isset($parameters['context']) ? $parameters['context'] : null; |
|
| 417 | - if ($context === null) { |
|
| 418 | - $parent = "$('" . $maskSelector . "').parent()"; |
|
| 419 | - $newElm = "$('#'+newId)"; |
|
| 414 | + $rowClass=isset($parameters['rowClass']) ? $parameters['rowClass'] : "_json"; |
|
| 415 | + $jsCallback=isset($parameters['jsCallback']) ? $parameters['jsCallback'] : ""; |
|
| 416 | + $context=isset($parameters['context']) ? $parameters['context'] : null; |
|
| 417 | + if ($context===null) { |
|
| 418 | + $parent="$('".$maskSelector."').parent()"; |
|
| 419 | + $newElm="$('#'+newId)"; |
|
| 420 | 420 | } else { |
| 421 | - $parent = $context; |
|
| 422 | - $newElm = $context . ".find('#'+newId)"; |
|
| 421 | + $parent=$context; |
|
| 422 | + $newElm=$context.".find('#'+newId)"; |
|
| 423 | 423 | } |
| 424 | - $appendTo = "\t\tnewElm.appendTo(" . $parent . ");\n"; |
|
| 425 | - $retour = $parent . ".find('.{$rowClass}').remove();"; |
|
| 426 | - $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(); |
|
| 424 | + $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
|
| 425 | + $retour=$parent.".find('.{$rowClass}').remove();"; |
|
| 426 | + $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(); |
|
| 427 | 427 | 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"; |
| 428 | - $retour .= $appendTo; |
|
| 429 | - $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"; |
|
| 430 | - $retour .= "\t$(document).trigger('jsonReady',[data]);\n"; |
|
| 431 | - $retour .= "\t" . $jsCallback; |
|
| 432 | - $parameters["jsCallback"] = $retour; |
|
| 428 | + $retour.=$appendTo; |
|
| 429 | + $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"; |
|
| 430 | + $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
|
| 431 | + $retour.="\t".$jsCallback; |
|
| 432 | + $parameters["jsCallback"]=$retour; |
|
| 433 | 433 | return $this->_ajax($method, $url, null, $parameters); |
| 434 | 434 | } |
| 435 | 435 | |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | * @param array $parameters |
| 445 | 445 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json","before"=>null) |
| 446 | 446 | */ |
| 447 | - public function jsonArray($maskSelector, $url, $method = "get", $parameters = []) { |
|
| 447 | + public function jsonArray($maskSelector, $url, $method="get", $parameters=[]) { |
|
| 448 | 448 | return $this->_jsonArray($maskSelector, $url, $method, $parameters); |
| 449 | 449 | } |
| 450 | 450 | |
@@ -459,8 +459,8 @@ discard block |
||
| 459 | 459 | * @param array $parameters |
| 460 | 460 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"rowClass"=>"_json","before"=>null) |
| 461 | 461 | */ |
| 462 | - public function jsonArrayDeferred($maskSelector, $url, $method = "get", $parameters) { |
|
| 463 | - $parameters["immediatly"] = false; |
|
| 462 | + public function jsonArrayDeferred($maskSelector, $url, $method="get", $parameters) { |
|
| 463 | + $parameters["immediatly"]=false; |
|
| 464 | 464 | return $this->jsonArray($maskSelector, $url, $method, $parameters); |
| 465 | 465 | } |
| 466 | 466 | |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | * @param array $parameters |
| 477 | 477 | * default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true,"before"=>null) |
| 478 | 478 | */ |
| 479 | - public function jsonArrayOn($event, $element, $maskSelector, $url, $method = "get", $parameters = array()) { |
|
| 479 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $method="get", $parameters=array()) { |
|
| 480 | 480 | $this->setDefaultParameters($parameters, [ |
| 481 | 481 | "preventDefault" => true, |
| 482 | 482 | "stopPropagation" => true, |
@@ -496,8 +496,8 @@ discard block |
||
| 496 | 496 | * @param array $parameters |
| 497 | 497 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 498 | 498 | */ |
| 499 | - public function getDeferred($url, $responseElement = "", $parameters = []) { |
|
| 500 | - $parameters["immediatly"] = false; |
|
| 499 | + public function getDeferred($url, $responseElement="", $parameters=[]) { |
|
| 500 | + $parameters["immediatly"]=false; |
|
| 501 | 501 | return $this->_get($url, $responseElement, $parameters); |
| 502 | 502 | } |
| 503 | 503 | |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | * @param array $parameters |
| 517 | 517 | * 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) |
| 518 | 518 | */ |
| 519 | - public function getOn($event, $element, $url, $responseElement = "", $parameters = array()) { |
|
| 519 | + public function getOn($event, $element, $url, $responseElement="", $parameters=array()) { |
|
| 520 | 520 | $this->setDefaultParameters($parameters, [ |
| 521 | 521 | "preventDefault" => true, |
| 522 | 522 | "stopPropagation" => true, |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | * @param array $parameters |
| 541 | 541 | * 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) |
| 542 | 542 | */ |
| 543 | - public function ajaxOn($event, $element, $url, $responseElement = "", $parameters = array()) { |
|
| 543 | + public function ajaxOn($event, $element, $url, $responseElement="", $parameters=array()) { |
|
| 544 | 544 | $this->setDefaultParameters($parameters, [ |
| 545 | 545 | "preventDefault" => true, |
| 546 | 546 | "stopPropagation" => true, |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | * @param array $parameters |
| 564 | 564 | * 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) |
| 565 | 565 | */ |
| 566 | - public function ajaxOnClick($element, $url, $responseElement = "", $parameters = array()) { |
|
| 566 | + public function ajaxOnClick($element, $url, $responseElement="", $parameters=array()) { |
|
| 567 | 567 | return $this->ajaxOn("click", $element, $url, $responseElement, $parameters); |
| 568 | 568 | } |
| 569 | 569 | |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | * @param array $parameters |
| 581 | 581 | * 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) |
| 582 | 582 | */ |
| 583 | - public function getOnClick($element, $url, $responseElement = "", $parameters = array()) { |
|
| 583 | + public function getOnClick($element, $url, $responseElement="", $parameters=array()) { |
|
| 584 | 584 | return $this->getOn("click", $element, $url, $responseElement, $parameters); |
| 585 | 585 | } |
| 586 | 586 | |
@@ -595,15 +595,15 @@ discard block |
||
| 595 | 595 | * 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) |
| 596 | 596 | * @return $this |
| 597 | 597 | */ |
| 598 | - public function getHref($element, $responseElement = "", $parameters = array()) { |
|
| 599 | - $parameters["attr"] = "href"; |
|
| 598 | + public function getHref($element, $responseElement="", $parameters=array()) { |
|
| 599 | + $parameters["attr"]="href"; |
|
| 600 | 600 | if (JString::isNull($responseElement)) { |
| 601 | - $responseElement = '%$(self).attr("data-target")%'; |
|
| 601 | + $responseElement='%$(self).attr("data-target")%'; |
|
| 602 | 602 | } else { |
| 603 | - $responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%'; |
|
| 603 | + $responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%'; |
|
| 604 | 604 | } |
| 605 | - if (! isset($parameters["historize"])) { |
|
| 606 | - $parameters["historize"] = true; |
|
| 605 | + if (!isset($parameters["historize"])) { |
|
| 606 | + $parameters["historize"]=true; |
|
| 607 | 607 | } |
| 608 | 608 | return $this->getOnClick($element, "", $responseElement, $parameters); |
| 609 | 609 | } |
@@ -619,21 +619,21 @@ discard block |
||
| 619 | 619 | * 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) |
| 620 | 620 | * @return $this |
| 621 | 621 | */ |
| 622 | - public function postHref($element, $responseElement = "", $parameters = array()) { |
|
| 623 | - $parameters["attr"] = "href"; |
|
| 622 | + public function postHref($element, $responseElement="", $parameters=array()) { |
|
| 623 | + $parameters["attr"]="href"; |
|
| 624 | 624 | if (JString::isNull($responseElement)) { |
| 625 | - $responseElement = '%$(this).attr("data-target")%'; |
|
| 625 | + $responseElement='%$(this).attr("data-target")%'; |
|
| 626 | 626 | } else { |
| 627 | - $responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%'; |
|
| 627 | + $responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%'; |
|
| 628 | 628 | } |
| 629 | - if (! isset($parameters["historize"])) { |
|
| 630 | - $parameters["historize"] = true; |
|
| 629 | + if (!isset($parameters["historize"])) { |
|
| 630 | + $parameters["historize"]=true; |
|
| 631 | 631 | } |
| 632 | 632 | return $this->postOnClick($element, "", "{}", $responseElement, $parameters); |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | - private function _post($url, $params = "{}", $responseElement = "", $parameters = []) { |
|
| 636 | - $parameters["params"] = $params; |
|
| 635 | + private function _post($url, $params="{}", $responseElement="", $parameters=[]) { |
|
| 636 | + $parameters["params"]=$params; |
|
| 637 | 637 | return $this->_ajax("POST", $url, $responseElement, $parameters); |
| 638 | 638 | } |
| 639 | 639 | |
@@ -649,8 +649,8 @@ discard block |
||
| 649 | 649 | * @param array $parameters |
| 650 | 650 | * default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 651 | 651 | */ |
| 652 | - public function post($url, $params = "{}", $responseElement = "", $parameters = []) { |
|
| 653 | - $parameters['immediatly'] = true; |
|
| 652 | + public function post($url, $params="{}", $responseElement="", $parameters=[]) { |
|
| 653 | + $parameters['immediatly']=true; |
|
| 654 | 654 | return $this->_post($url, $params, $responseElement, $parameters); |
| 655 | 655 | } |
| 656 | 656 | |
@@ -667,8 +667,8 @@ discard block |
||
| 667 | 667 | * @param array $parameters |
| 668 | 668 | * default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 669 | 669 | */ |
| 670 | - public function postDeferred($url, $params = "{}", $responseElement = "", $parameters = []) { |
|
| 671 | - $parameters["immediatly"] = false; |
|
| 670 | + public function postDeferred($url, $params="{}", $responseElement="", $parameters=[]) { |
|
| 671 | + $parameters["immediatly"]=false; |
|
| 672 | 672 | return $this->_post($url, $params, $responseElement, $parameters); |
| 673 | 673 | } |
| 674 | 674 | |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | * @param array $parameters |
| 688 | 688 | * 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) |
| 689 | 689 | */ |
| 690 | - public function postOn($event, $element, $url, $params = "{}", $responseElement = "", $parameters = array()) { |
|
| 690 | + public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 691 | 691 | $this->setDefaultParameters($parameters, [ |
| 692 | 692 | "preventDefault" => true, |
| 693 | 693 | "stopPropagation" => true, |
@@ -710,66 +710,66 @@ discard block |
||
| 710 | 710 | * @param array $parameters |
| 711 | 711 | * 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) |
| 712 | 712 | */ |
| 713 | - public function postOnClick($element, $url, $params = "{}", $responseElement = "", $parameters = array()) { |
|
| 713 | + public function postOnClick($element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 714 | 714 | return $this->postOn("click", $element, $url, $params, $responseElement, $parameters); |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | - private function _postForm($url, $form, $responseElement, $parameters = []) { |
|
| 717 | + private function _postForm($url, $form, $responseElement, $parameters=[]) { |
|
| 718 | 718 | if (isset($this->params["ajax"])) { |
| 719 | 719 | extract($this->params["ajax"]); |
| 720 | 720 | } |
| 721 | - $params = "{}"; |
|
| 722 | - $validation = false; |
|
| 721 | + $params="{}"; |
|
| 722 | + $validation=false; |
|
| 723 | 723 | \extract($parameters); |
| 724 | - $async = ($async) ? "true" : "false"; |
|
| 725 | - $jsCallback = isset($jsCallback) ? $jsCallback : ""; |
|
| 726 | - $retour = $this->_getAjaxUrl($url, $attr); |
|
| 727 | - $retour .= "\n$('#" . $form . "').trigger('ajaxSubmit');"; |
|
| 728 | - if (! isset($contentType) || $contentType != 'false') { |
|
| 729 | - $retour .= "\nvar params=$('#" . $form . "').serialize();\n"; |
|
| 724 | + $async=($async) ? "true" : "false"; |
|
| 725 | + $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
|
| 726 | + $retour=$this->_getAjaxUrl($url, $attr); |
|
| 727 | + $retour.="\n$('#".$form."').trigger('ajaxSubmit');"; |
|
| 728 | + if (!isset($contentType) || $contentType!='false') { |
|
| 729 | + $retour.="\nvar params=$('#".$form."').serialize();\n"; |
|
| 730 | 730 | if (isset($params)) { |
| 731 | - $retour .= "params+='&'+" . self::_correctParams($params) . ";\n"; |
|
| 731 | + $retour.="params+='&'+".self::_correctParams($params).";\n"; |
|
| 732 | 732 | } |
| 733 | 733 | } else { |
| 734 | - $retour .= "\nvar params=new FormData($('#" . $form . "')[0]);\n"; |
|
| 734 | + $retour.="\nvar params=new FormData($('#".$form."')[0]);\n"; |
|
| 735 | 735 | } |
| 736 | - $responseElement = $this->_getResponseElement($responseElement); |
|
| 737 | - $retour .= "var self=this;\n"; |
|
| 738 | - $before = isset($before) ? $before : ""; |
|
| 739 | - $retour .= $before; |
|
| 740 | - if ($hasLoader === true) { |
|
| 736 | + $responseElement=$this->_getResponseElement($responseElement); |
|
| 737 | + $retour.="var self=this;\n"; |
|
| 738 | + $before=isset($before) ? $before : ""; |
|
| 739 | + $retour.=$before; |
|
| 740 | + if ($hasLoader===true) { |
|
| 741 | 741 | $this->addLoading($retour, $responseElement, $ajaxLoader); |
| 742 | - } elseif ($hasLoader === 'response') { |
|
| 742 | + } elseif ($hasLoader==='response') { |
|
| 743 | 743 | $this->addResponseLoading($retour, $responseElement, $ajaxLoader); |
| 744 | - } elseif ($hasLoader === 'internal') { |
|
| 745 | - $retour .= "\n$(this).addClass('loading');"; |
|
| 744 | + } elseif ($hasLoader==='internal') { |
|
| 745 | + $retour.="\n$(this).addClass('loading');"; |
|
| 746 | 746 | } |
| 747 | - $ajaxParameters = [ |
|
| 747 | + $ajaxParameters=[ |
|
| 748 | 748 | "url" => "url", |
| 749 | 749 | "method" => "'POST'", |
| 750 | 750 | "data" => "params", |
| 751 | 751 | "async" => $async |
| 752 | 752 | ]; |
| 753 | 753 | if (isset($headers)) { |
| 754 | - $ajaxParameters["headers"] = $headers; |
|
| 754 | + $ajaxParameters["headers"]=$headers; |
|
| 755 | 755 | } |
| 756 | 756 | if (isset($partial)) { |
| 757 | - $ajaxParameters["xhr"] = "xhrProvider"; |
|
| 758 | - $retour .= "var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;" . $partial . ";}; };"; |
|
| 757 | + $ajaxParameters["xhr"]="xhrProvider"; |
|
| 758 | + $retour.="var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;".$partial.";}; };"; |
|
| 759 | 759 | } |
| 760 | 760 | $this->createAjaxParameters($ajaxParameters, $parameters); |
| 761 | - $retour .= "$.ajax({" . $this->implodeAjaxParameters($ajaxParameters) . "}).done(function( data ) {\n"; |
|
| 762 | - $retour .= $this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader) . "});\n"; |
|
| 761 | + $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data ) {\n"; |
|
| 762 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader)."});\n"; |
|
| 763 | 763 | |
| 764 | 764 | if ($validation) { |
| 765 | - $retour = "$('#" . $form . "').validate({submitHandler: function(form) { |
|
| 766 | - " . $retour . " |
|
| 765 | + $retour="$('#".$form."').validate({submitHandler: function(form) { |
|
| 766 | + " . $retour." |
|
| 767 | 767 | }});\n"; |
| 768 | - $retour .= "$('#" . $form . "').submit();\n"; |
|
| 768 | + $retour.="$('#".$form."').submit();\n"; |
|
| 769 | 769 | } |
| 770 | - $retour = $this->_addJsCondition($jsCondition, $retour); |
|
| 770 | + $retour=$this->_addJsCondition($jsCondition, $retour); |
|
| 771 | 771 | if ($immediatly) |
| 772 | - $this->jquery_code_for_compile[] = $retour; |
|
| 772 | + $this->jquery_code_for_compile[]=$retour; |
|
| 773 | 773 | return $retour; |
| 774 | 774 | } |
| 775 | 775 | |
@@ -785,8 +785,8 @@ discard block |
||
| 785 | 785 | * @param array $parameters |
| 786 | 786 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 787 | 787 | */ |
| 788 | - public function postForm($url, $form, $responseElement, $parameters = []) { |
|
| 789 | - $parameters["immediatly"] = true; |
|
| 788 | + public function postForm($url, $form, $responseElement, $parameters=[]) { |
|
| 789 | + $parameters["immediatly"]=true; |
|
| 790 | 790 | return $this->_postForm($url, $form, $responseElement, $parameters); |
| 791 | 791 | } |
| 792 | 792 | |
@@ -803,8 +803,8 @@ discard block |
||
| 803 | 803 | * @param array $parameters |
| 804 | 804 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
| 805 | 805 | */ |
| 806 | - public function postFormDeferred($url, $form, $responseElement, $parameters = []) { |
|
| 807 | - $parameters["immediatly"] = false; |
|
| 806 | + public function postFormDeferred($url, $form, $responseElement, $parameters=[]) { |
|
| 807 | + $parameters["immediatly"]=false; |
|
| 808 | 808 | return $this->_postForm($url, $form, $responseElement, $parameters); |
| 809 | 809 | } |
| 810 | 810 | |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | * @param array $parameters |
| 822 | 822 | * 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) |
| 823 | 823 | */ |
| 824 | - public function postFormOn($event, $element, $url, $form, $responseElement = "", $parameters = array()) { |
|
| 824 | + public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 825 | 825 | $this->setDefaultParameters($parameters, [ |
| 826 | 826 | "preventDefault" => true, |
| 827 | 827 | "stopPropagation" => true, |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | * @param array $parameters |
| 843 | 843 | * 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) |
| 844 | 844 | */ |
| 845 | - public function postFormOnClick($element, $url, $form, $responseElement = "", $parameters = array()) { |
|
| 845 | + public function postFormOnClick($element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 846 | 846 | return $this->postFormOn("click", $element, $url, $form, $responseElement, $parameters); |
| 847 | 847 | } |
| 848 | 848 | } |
@@ -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,10 +24,11 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public function setBasic($very = false) { |
| 26 | 26 | $table = $this->_self; |
| 27 | - if ($very) |
|
| 28 | - $table->addToPropertyCtrl("class", "very", array( |
|
| 27 | + if ($very) { |
|
| 28 | + $table->addToPropertyCtrl("class", "very", array( |
|
| 29 | 29 | "very" |
| 30 | 30 | )); |
| 31 | + } |
|
| 31 | 32 | return $table->addToPropertyCtrl("class", "basic", array( |
| 32 | 33 | "basic" |
| 33 | 34 | )); |
@@ -35,10 +36,11 @@ discard block |
||
| 35 | 36 | |
| 36 | 37 | public function setCompact($very = false) { |
| 37 | 38 | $table = $this->_self; |
| 38 | - if ($very) |
|
| 39 | - $table->addToPropertyCtrl("class", "very", array( |
|
| 39 | + if ($very) { |
|
| 40 | + $table->addToPropertyCtrl("class", "very", array( |
|
| 40 | 41 | "very" |
| 41 | 42 | )); |
| 43 | + } |
|
| 42 | 44 | return $table->addToPropertyCtrl("class", "compact", array( |
| 43 | 45 | "compact" |
| 44 | 46 | )); |
@@ -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 | } |
@@ -72,8 +72,9 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | protected function getItemToAdd($item) { |
| 74 | 74 | $itemO = parent::getItemToAdd($item); |
| 75 | - if ($itemO instanceof AbstractCheckbox) |
|
| 76 | - $itemO->addClass("item"); |
|
| 75 | + if ($itemO instanceof AbstractCheckbox) { |
|
| 76 | + $itemO->addClass("item"); |
|
| 77 | + } |
|
| 77 | 78 | return $itemO; |
| 78 | 79 | } |
| 79 | 80 | |
@@ -179,8 +180,9 @@ discard block |
||
| 179 | 180 | if (isset($masterItem)) { |
| 180 | 181 | if (\is_array($masterItem)) { |
| 181 | 182 | $masterO = new HtmlFormCheckbox("master-" . $identifier, @$masterItem[0], @$masterItem[1]); |
| 182 | - if (isset($name)) |
|
| 183 | - $masterO->setName($name); |
|
| 183 | + if (isset($name)) { |
|
| 184 | + $masterO->setName($name); |
|
| 185 | + } |
|
| 184 | 186 | if (isset($masterItem[1])) { |
| 185 | 187 | if (\array_search($masterItem[1], $values) !== false) { |
| 186 | 188 | $masterO->getDataField()->setProperty("checked", ""); |
@@ -204,8 +206,9 @@ discard block |
||
| 204 | 206 | if (\array_search($val, $values) !== false) { |
| 205 | 207 | $itemO->getDataField()->setProperty("checked", ""); |
| 206 | 208 | } |
| 207 | - if (isset($name)) |
|
| 208 | - $itemO->setName($name); |
|
| 209 | + if (isset($name)) { |
|
| 210 | + $itemO->setName($name); |
|
| 211 | + } |
|
| 209 | 212 | $itemO->setClass("item"); |
| 210 | 213 | $fields[] = $itemO; |
| 211 | 214 | } |
@@ -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; |
@@ -151,25 +151,29 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | public function getColPosition($colIndex) { |
| 154 | - if ($this->_container->_isMerged() !== true) |
|
| 155 | - return $colIndex; |
|
| 154 | + if ($this->_container->_isMerged() !== true) { |
|
| 155 | + return $colIndex; |
|
| 156 | + } |
|
| 156 | 157 | $pos = 0; |
| 157 | 158 | $rows = $this->_container->getContent(); |
| 158 | 159 | for ($i = 0; $i < $this->_row; $i ++) { |
| 159 | 160 | $max = \min($colIndex, $rows[$i]->count()); |
| 160 | 161 | for ($j = 0; $j < $max; $j ++) { |
| 161 | 162 | $rowspan = $rows[$i]->getItem($j)->getRowspan(); |
| 162 | - if ($rowspan + $i > $this->_row) |
|
| 163 | - $pos ++; |
|
| 163 | + if ($rowspan + $i > $this->_row) { |
|
| 164 | + $pos ++; |
|
| 165 | + } |
|
| 164 | 166 | } |
| 165 | 167 | } |
| 166 | - if ($pos > $colIndex) |
|
| 167 | - return NULL; |
|
| 168 | + if ($pos > $colIndex) { |
|
| 169 | + return NULL; |
|
| 170 | + } |
|
| 168 | 171 | $count = $this->count(); |
| 169 | 172 | for ($i = 0; $i < $count; $i ++) { |
| 170 | 173 | $pos += $this->content[$i]->getColspan(); |
| 171 | - if ($pos >= $colIndex + 1) |
|
| 172 | - return $i; |
|
| 174 | + if ($pos >= $colIndex + 1) { |
|
| 175 | + return $i; |
|
| 176 | + } |
|
| 173 | 177 | } |
| 174 | 178 | return null; |
| 175 | 179 | } |
@@ -192,8 +196,9 @@ discard block |
||
| 192 | 196 | public function containsStr($needle) { |
| 193 | 197 | $cells = $this->content; |
| 194 | 198 | foreach ($cells as $cell) { |
| 195 | - if (\strpos($cell->getContent(), $needle) !== false) |
|
| 196 | - return true; |
|
| 199 | + if (\strpos($cell->getContent(), $needle) !== false) { |
|
| 200 | + return true; |
|
| 201 | + } |
|
| 197 | 202 | } |
| 198 | 203 | return false; |
| 199 | 204 | } |
@@ -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 | } |
@@ -108,15 +108,17 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | public function getColspan() { |
| 110 | 110 | $colspan = 1; |
| 111 | - if (\array_key_exists("colspan", $this->properties)) |
|
| 112 | - $colspan = $this->getProperty("colspan"); |
|
| 111 | + if (\array_key_exists("colspan", $this->properties)) { |
|
| 112 | + $colspan = $this->getProperty("colspan"); |
|
| 113 | + } |
|
| 113 | 114 | return $colspan; |
| 114 | 115 | } |
| 115 | 116 | |
| 116 | 117 | public function getRowspan() { |
| 117 | 118 | $rowspan = 1; |
| 118 | - if (\array_key_exists("rowspan", $this->properties)) |
|
| 119 | - $rowspan = $this->getProperty("rowspan"); |
|
| 119 | + if (\array_key_exists("rowspan", $this->properties)) { |
|
| 120 | + $rowspan = $this->getProperty("rowspan"); |
|
| 121 | + } |
|
| 120 | 122 | return $rowspan; |
| 121 | 123 | } |
| 122 | 124 | |
@@ -155,7 +157,8 @@ discard block |
||
| 155 | 157 | } |
| 156 | 158 | |
| 157 | 159 | public function compile(JsUtils $js = NULL, &$view = NULL) { |
| 158 | - if (! $this->_deleted) |
|
| 159 | - return parent::compile($js, $view); |
|
| 160 | + if (! $this->_deleted) { |
|
| 161 | + return parent::compile($js, $view); |
|
| 162 | + } |
|
| 160 | 163 | } |
| 161 | 164 | } |
@@ -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 | } |
@@ -32,8 +32,9 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function __construct($identifier, $tagName = "tbody", $rowCount = NULL, $colCount = NULL) { |
| 34 | 34 | parent::__construct($identifier, $tagName, ""); |
| 35 | - if (isset($rowCount) && isset($colCount)) |
|
| 36 | - $this->setRowCount($rowCount, $colCount); |
|
| 35 | + if (isset($rowCount) && isset($colCount)) { |
|
| 36 | + $this->setRowCount($rowCount, $colCount); |
|
| 37 | + } |
|
| 37 | 38 | } |
| 38 | 39 | |
| 39 | 40 | /** |
@@ -193,10 +194,11 @@ discard block |
||
| 193 | 194 | $values = \array_fill(0, $count, $values); |
| 194 | 195 | $isArray = false; |
| 195 | 196 | } |
| 196 | - if (JArray::dimension($values) == 1 && $isArray) |
|
| 197 | - $values = [ |
|
| 197 | + if (JArray::dimension($values) == 1 && $isArray) { |
|
| 198 | + $values = [ |
|
| 198 | 199 | $values |
| 199 | 200 | ]; |
| 201 | + } |
|
| 200 | 202 | |
| 201 | 203 | $count = \min(\sizeof($values), $count); |
| 202 | 204 | |
@@ -223,8 +225,9 @@ discard block |
||
| 223 | 225 | $count = $this->count(); |
| 224 | 226 | for ($i = 0; $i < $count; $i ++) { |
| 225 | 227 | $cell = $this->getCell($i, $colIndex); |
| 226 | - if ($cell instanceof BaseTrait) |
|
| 227 | - $cell->addVariations($variations); |
|
| 228 | + if ($cell instanceof BaseTrait) { |
|
| 229 | + $cell->addVariations($variations); |
|
| 230 | + } |
|
| 228 | 231 | } |
| 229 | 232 | return $this; |
| 230 | 233 | } |
@@ -233,8 +236,9 @@ discard block |
||
| 233 | 236 | $count = $this->count(); |
| 234 | 237 | for ($i = 0; $i < $count; $i ++) { |
| 235 | 238 | $cell = $this->getCell($i, $colIndex); |
| 236 | - if (isset($cell)) |
|
| 237 | - $cell->addToProperty($name, $value); |
|
| 239 | + if (isset($cell)) { |
|
| 240 | + $cell->addToProperty($name, $value); |
|
| 241 | + } |
|
| 238 | 242 | } |
| 239 | 243 | return $this; |
| 240 | 244 | } |
@@ -252,8 +256,9 @@ discard block |
||
| 252 | 256 | $count = $this->count(); |
| 253 | 257 | for ($i = 0; $i < $count; $i ++) { |
| 254 | 258 | $index = $this->content[$i]->getColPosition($colIndex); |
| 255 | - if ($index !== NULL) |
|
| 256 | - $this->getCell($i, $index)->$function(); |
|
| 259 | + if ($index !== NULL) { |
|
| 260 | + $this->getCell($i, $index)->$function(); |
|
| 261 | + } |
|
| 257 | 262 | } |
| 258 | 263 | return $this; |
| 259 | 264 | } |
@@ -264,8 +269,9 @@ discard block |
||
| 264 | 269 | $maxRow = $this->content[$i]->count(); |
| 265 | 270 | $index = $maxRow - $colIndex - 1; |
| 266 | 271 | if (($cell = $this->getCell($i, $index)) !== NULL) { |
| 267 | - if ($cell->getColspan() == 1) |
|
| 268 | - $cell->$function(); |
|
| 272 | + if ($cell->getColspan() == 1) { |
|
| 273 | + $cell->$function(); |
|
| 274 | + } |
|
| 269 | 275 | } |
| 270 | 276 | } |
| 271 | 277 | return $this; |
@@ -311,8 +317,9 @@ discard block |
||
| 311 | 317 | */ |
| 312 | 318 | public function getColCount() { |
| 313 | 319 | $result = 0; |
| 314 | - if ($this->count() > 0) |
|
| 315 | - $result = $this->getItem(0)->count(); |
|
| 320 | + if ($this->count() > 0) { |
|
| 321 | + $result = $this->getItem(0)->count(); |
|
| 322 | + } |
|
| 316 | 323 | return $result; |
| 317 | 324 | } |
| 318 | 325 | |
@@ -337,15 +344,17 @@ discard block |
||
| 337 | 344 | |
| 338 | 345 | public function toDelete($rowIndex, $colIndex) { |
| 339 | 346 | $row = $this->getItem($rowIndex); |
| 340 | - if (isset($row) === true) |
|
| 341 | - $row->toDelete($colIndex); |
|
| 347 | + if (isset($row) === true) { |
|
| 348 | + $row->toDelete($colIndex); |
|
| 349 | + } |
|
| 342 | 350 | return $this; |
| 343 | 351 | } |
| 344 | 352 | |
| 345 | 353 | public function toRowspanned($rowIndex, $colIndex) { |
| 346 | 354 | $row = $this->getItem($rowIndex); |
| 347 | - if (isset($row) === true) |
|
| 348 | - $row->toRowspanned($colIndex); |
|
| 355 | + if (isset($row) === true) { |
|
| 356 | + $row->toRowspanned($colIndex); |
|
| 357 | + } |
|
| 349 | 358 | return $this; |
| 350 | 359 | } |
| 351 | 360 | |
@@ -455,8 +464,9 @@ discard block |
||
| 455 | 464 | foreach ($rows as $row) { |
| 456 | 465 | $cell = $row->getItem($colIndex); |
| 457 | 466 | $value = $cell->getContent(); |
| 458 | - if ($functionExists) |
|
| 459 | - $value = \call_user_func($function, $value); |
|
| 467 | + if ($functionExists) { |
|
| 468 | + $value = \call_user_func($function, $value); |
|
| 469 | + } |
|
| 460 | 470 | if ($value !== $identiqual) { |
| 461 | 471 | if ($counter > 0 && isset($cellToMerge)) { |
| 462 | 472 | $cellToMerge->setRowspanned($counter); |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | class HtmlGridSystem extends HtmlBsDoubleElement { |
| 17 | 17 | private $rows; |
| 18 | 18 | |
| 19 | - public function __construct($identifier,$numRows=1,$numCols=NULL){ |
|
| 20 | - parent::__construct($identifier,"div"); |
|
| 19 | + public function __construct($identifier, $numRows=1, $numCols=NULL) { |
|
| 20 | + parent::__construct($identifier, "div"); |
|
| 21 | 21 | $this->setProperty("class", "container-fluid"); |
| 22 | 22 | $this->rows=array(); |
| 23 | - $this->setNumRows($numRows,$numCols); |
|
| 23 | + $this->setNumRows($numRows, $numCols); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | * @param int $numCols |
| 29 | 29 | * @return \Ajax\bootstrap\html\content\HtmlGridRow |
| 30 | 30 | */ |
| 31 | - public function addRow($numCols=NULL){ |
|
| 32 | - $row=new HtmlGridRow($this->identifier."-row-".(sizeof($this->rows)+1),$numCols); |
|
| 31 | + public function addRow($numCols=NULL) { |
|
| 32 | + $row=new HtmlGridRow($this->identifier."-row-".(sizeof($this->rows)+1), $numCols); |
|
| 33 | 33 | $this->rows[]=$row; |
| 34 | 34 | return $row; |
| 35 | 35 | } |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | * @param boolean $force add the row at $index if true |
| 41 | 41 | * @return \Ajax\bootstrap\html\content\HtmlGridRow |
| 42 | 42 | */ |
| 43 | - public function getRow($index,$force=true){ |
|
| 44 | - if($index<sizeof($this->rows)){ |
|
| 43 | + public function getRow($index, $force=true) { |
|
| 44 | + if ($index<sizeof($this->rows)) { |
|
| 45 | 45 | $result=$this->rows[$index-1]; |
| 46 | - }else if ($force){ |
|
| 46 | + } else if ($force) { |
|
| 47 | 47 | $this->setNumRows($index); |
| 48 | 48 | $result=$this->rows[$index-1]; |
| 49 | 49 | } |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | * @param int $numCols |
| 57 | 57 | * @return \Ajax\bootstrap\html\HtmlGridSystem |
| 58 | 58 | */ |
| 59 | - public function setNumRows($numRows,$numCols=NULL){ |
|
| 60 | - for($i=sizeof($this->rows);$i<$numRows;$i++){ |
|
| 59 | + public function setNumRows($numRows, $numCols=NULL) { |
|
| 60 | + for ($i=sizeof($this->rows); $i<$numRows; $i++) { |
|
| 61 | 61 | $this->addRow($numCols); |
| 62 | 62 | } |
| 63 | 63 | return $this; |
@@ -69,10 +69,10 @@ discard block |
||
| 69 | 69 | * @param boolean $force add the cell at $row,$col if true |
| 70 | 70 | * @return HtmlGridCol |
| 71 | 71 | */ |
| 72 | - public function getCell($row,$col,$force=true){ |
|
| 73 | - $row=$this->getRow($row,$force); |
|
| 74 | - if(isset($row)){ |
|
| 75 | - $col=$row->getCol($col,$force); |
|
| 72 | + public function getCell($row, $col, $force=true) { |
|
| 73 | + $row=$this->getRow($row, $force); |
|
| 74 | + if (isset($row)) { |
|
| 75 | + $col=$row->getCol($col, $force); |
|
| 76 | 76 | } |
| 77 | 77 | return $col; |
| 78 | 78 | } |
@@ -82,22 +82,22 @@ discard block |
||
| 82 | 82 | * @param int $col |
| 83 | 83 | * @return HtmlGridCol |
| 84 | 84 | */ |
| 85 | - public function getCellAt($row,$col,$force=true){ |
|
| 86 | - $row=$this->getRow($row,$force); |
|
| 87 | - if(isset($row)){ |
|
| 88 | - $col=$row->getColAt($col,$force); |
|
| 85 | + public function getCellAt($row, $col, $force=true) { |
|
| 86 | + $row=$this->getRow($row, $force); |
|
| 87 | + if (isset($row)) { |
|
| 88 | + $col=$row->getColAt($col, $force); |
|
| 89 | 89 | } |
| 90 | 90 | return $col; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 94 | - foreach ($this->rows as $row){ |
|
| 94 | + foreach ($this->rows as $row) { |
|
| 95 | 95 | $this->addContent($row); |
| 96 | 96 | } |
| 97 | - return parent::compile($js,$view); |
|
| 97 | + return parent::compile($js, $view); |
|
| 98 | 98 | } |
| 99 | - public function setContentForAll($content){ |
|
| 100 | - foreach ($this->rows as $row){ |
|
| 99 | + public function setContentForAll($content) { |
|
| 100 | + foreach ($this->rows as $row) { |
|
| 101 | 101 | $row->setContentForAll($content); |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | public function getRow($index,$force=true){ |
| 44 | 44 | if($index<sizeof($this->rows)){ |
| 45 | 45 | $result=$this->rows[$index-1]; |
| 46 | - }else if ($force){ |
|
| 46 | + } else if ($force){ |
|
| 47 | 47 | $this->setNumRows($index); |
| 48 | 48 | $result=$this->rows[$index-1]; |
| 49 | 49 | } |