@@ -8,23 +8,23 @@ discard block |
||
8 | 8 | |
9 | 9 | protected $image; |
10 | 10 | |
11 | - public function __construct($identifier, $content = NULL) { |
|
11 | + public function __construct($identifier, $content=NULL) { |
|
12 | 12 | parent::__construct($identifier, "item", $content); |
13 | 13 | } |
14 | 14 | |
15 | 15 | protected function initContent($content) { |
16 | 16 | if (\is_array($content)) { |
17 | - if (JArray::isAssociative($content) === false) { |
|
18 | - $icon = $content[0] ?? null; |
|
19 | - $title = $content[1] ?? null; |
|
20 | - $desc = $content[2] ?? null; |
|
17 | + if (JArray::isAssociative($content)===false) { |
|
18 | + $icon=$content[0] ?? null; |
|
19 | + $title=$content[1] ?? null; |
|
20 | + $desc=$content[2] ?? null; |
|
21 | 21 | } else { |
22 | - $icon = $content["icon"] ?? null; |
|
23 | - $image = $content["image"] ?? null; |
|
24 | - $title = $content["title"] ?? null; |
|
25 | - $header = $content["header"] ?? null; |
|
26 | - $desc = $content["description"] ?? null; |
|
27 | - $items = $content["items"] ?? null; |
|
22 | + $icon=$content["icon"] ?? null; |
|
23 | + $image=$content["image"] ?? null; |
|
24 | + $title=$content["title"] ?? null; |
|
25 | + $header=$content["header"] ?? null; |
|
26 | + $desc=$content["description"] ?? null; |
|
27 | + $items=$content["items"] ?? null; |
|
28 | 28 | } |
29 | 29 | if (isset($icon)) { |
30 | 30 | $this->setIcon($icon); |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | - public function addList($items = array(), $ordered = false) { |
|
49 | - $list = new HtmlList("", $items); |
|
48 | + public function addList($items=array(), $ordered=false) { |
|
49 | + $list=new HtmlList("", $items); |
|
50 | 50 | if ($ordered) |
51 | 51 | $list->setOrdered(); |
52 | 52 | $list->setClass("list"); |
53 | - $this->content["list"] = $list; |
|
53 | + $this->content["list"]=$list; |
|
54 | 54 | return $list; |
55 | 55 | } |
56 | 56 |
@@ -47,8 +47,9 @@ |
||
47 | 47 | |
48 | 48 | public function addList($items = array(), $ordered = false) { |
49 | 49 | $list = new HtmlList("", $items); |
50 | - if ($ordered) |
|
51 | - $list->setOrdered(); |
|
50 | + if ($ordered) { |
|
51 | + $list->setOrdered(); |
|
52 | + } |
|
52 | 53 | $list->setClass("list"); |
53 | 54 | $this->content["list"] = $list; |
54 | 55 | return $list; |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | protected $_placeholder; |
11 | 11 | |
12 | - public function __construct($identifier, $type = "text", $value = NULL, $placeholder = NULL) { |
|
12 | + public function __construct($identifier, $type="text", $value=NULL, $placeholder=NULL) { |
|
13 | 13 | parent::__construct($identifier, "input"); |
14 | 14 | $this->setProperty("name", $identifier); |
15 | 15 | $this->setValue($value); |
@@ -27,23 +27,23 @@ discard block |
||
27 | 27 | return $this->setProperty("type", $value); |
28 | 28 | } |
29 | 29 | |
30 | - public function forceValue($value = 'true') { |
|
31 | - $this->wrap('<input type="hidden" value="false" name="' . $this->identifier . '"/>'); |
|
30 | + public function forceValue($value='true') { |
|
31 | + $this->wrap('<input type="hidden" value="false" name="'.$this->identifier.'"/>'); |
|
32 | 32 | $this->setValue($value); |
33 | 33 | return $this; |
34 | 34 | } |
35 | 35 | |
36 | 36 | public function setPlaceholder($value) { |
37 | 37 | if (JString::isNotNull($value)) |
38 | - $this->_placeholder = $value; |
|
38 | + $this->_placeholder=$value; |
|
39 | 39 | return $this; |
40 | 40 | } |
41 | 41 | |
42 | - public function compile(JsUtils $js = NULL, &$view = NULL) { |
|
43 | - $value = $this->_placeholder; |
|
42 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
43 | + $value=$this->_placeholder; |
|
44 | 44 | if (JString::isNull($value)) { |
45 | 45 | if (JString::isNotNull($this->getProperty("name"))) |
46 | - $value = \ucfirst($this->getProperty("name")); |
|
46 | + $value=\ucfirst($this->getProperty("name")); |
|
47 | 47 | } |
48 | 48 | $this->setProperty("placeholder", $value); |
49 | 49 | return parent::compile($js, $view); |
@@ -18,8 +18,9 @@ discard block |
||
18 | 18 | } |
19 | 19 | |
20 | 20 | public function setValue($value) { |
21 | - if (isset($value)) |
|
22 | - $this->setProperty("value", $value); |
|
21 | + if (isset($value)) { |
|
22 | + $this->setProperty("value", $value); |
|
23 | + } |
|
23 | 24 | return $this; |
24 | 25 | } |
25 | 26 | |
@@ -34,16 +35,18 @@ discard block |
||
34 | 35 | } |
35 | 36 | |
36 | 37 | public function setPlaceholder($value) { |
37 | - if (JString::isNotNull($value)) |
|
38 | - $this->_placeholder = $value; |
|
38 | + if (JString::isNotNull($value)) { |
|
39 | + $this->_placeholder = $value; |
|
40 | + } |
|
39 | 41 | return $this; |
40 | 42 | } |
41 | 43 | |
42 | 44 | public function compile(JsUtils $js = NULL, &$view = NULL) { |
43 | 45 | $value = $this->_placeholder; |
44 | 46 | if (JString::isNull($value)) { |
45 | - if (JString::isNotNull($this->getProperty("name"))) |
|
46 | - $value = \ucfirst($this->getProperty("name")); |
|
47 | + if (JString::isNotNull($this->getProperty("name"))) { |
|
48 | + $value = \ucfirst($this->getProperty("name")); |
|
49 | + } |
|
47 | 50 | } |
48 | 51 | $this->setProperty("placeholder", $value); |
49 | 52 | return parent::compile($js, $view); |
@@ -4,64 +4,64 @@ |
||
4 | 4 | class JString { |
5 | 5 | |
6 | 6 | public static function contains($hay, $needle) { |
7 | - return strpos($hay, "$needle") !== false; |
|
7 | + return strpos($hay, "$needle")!==false; |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | public static function startswith($hay, $needle) { |
11 | - return substr($hay, 0, strlen($needle)) === $needle; |
|
11 | + return substr($hay, 0, strlen($needle))===$needle; |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | public static function endswith($hay, $needle) { |
15 | - return substr($hay, - strlen($needle)) === $needle; |
|
15 | + return substr($hay, - strlen($needle))===$needle; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public static function isNull($s) { |
19 | - return (! isset($s) || NULL === $s || "" === $s); |
|
19 | + return (!isset($s) || NULL===$s || ""===$s); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public static function isNotNull($s) { |
23 | - return (isset($s) && NULL !== $s && "" !== $s); |
|
23 | + return (isset($s) && NULL!==$s && ""!==$s); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public static function isBoolean($value) { |
27 | - return \is_bool($value) || $value == 1 || $value == 0; |
|
27 | + return \is_bool($value) || $value==1 || $value==0; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public static function isBooleanTrue($value) { |
31 | - return $value == 1 || $value; |
|
31 | + return $value==1 || $value; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | public static function isBooleanFalse($value) { |
35 | - return $value == 0 || ! $value; |
|
35 | + return $value==0 || !$value; |
|
36 | 36 | } |
37 | 37 | |
38 | - public static function camelCaseToSeparated($input, $separator = " ") { |
|
39 | - return strtolower(preg_replace('/(?<!^)[A-Z]/', $separator . '$0', $input)); |
|
38 | + public static function camelCaseToSeparated($input, $separator=" ") { |
|
39 | + return strtolower(preg_replace('/(?<!^)[A-Z]/', $separator.'$0', $input)); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public static function replaceAtFirst($subject, $from, $to) { |
43 | - $from = '/\A' . preg_quote($from, '/') . '/'; |
|
43 | + $from='/\A'.preg_quote($from, '/').'/'; |
|
44 | 44 | return \preg_replace($from, $to, $subject, 1); |
45 | 45 | } |
46 | 46 | |
47 | 47 | public static function replaceAtLast($subject, $from, $to) { |
48 | - $from = '/' . preg_quote($from, '/') . '\z/'; |
|
48 | + $from='/'.preg_quote($from, '/').'\z/'; |
|
49 | 49 | return \preg_replace($from, $to, $subject, 1); |
50 | 50 | } |
51 | 51 | |
52 | 52 | public static function replaceAtFirstAndLast($subject, $fromFirst, $toFirst, $fromLast, $toLast) { |
53 | - $s = self::replaceAtFirst($subject, $fromFirst, $toFirst); |
|
53 | + $s=self::replaceAtFirst($subject, $fromFirst, $toFirst); |
|
54 | 54 | return self::replaceAtLast($s, $fromLast, $toLast); |
55 | 55 | } |
56 | 56 | |
57 | - public static function getValueBetween(&$str, $before = "{{", $after = "}}") { |
|
58 | - $matches = []; |
|
59 | - $result = null; |
|
60 | - $_before = \preg_quote($before); |
|
61 | - $_after = \preg_quote($after); |
|
62 | - if (\preg_match('/' . $_before . '(.*?)' . $_after . '/s', $str, $matches) === 1) { |
|
63 | - $result = $matches[1]; |
|
64 | - $str = \str_replace($before . $result . $after, "", $str); |
|
57 | + public static function getValueBetween(&$str, $before="{{", $after="}}") { |
|
58 | + $matches=[]; |
|
59 | + $result=null; |
|
60 | + $_before=\preg_quote($before); |
|
61 | + $_after=\preg_quote($after); |
|
62 | + if (\preg_match('/'.$_before.'(.*?)'.$_after.'/s', $str, $matches)===1) { |
|
63 | + $result=$matches[1]; |
|
64 | + $str=\str_replace($before.$result.$after, "", $str); |
|
65 | 65 | } |
66 | 66 | return $result; |
67 | 67 | } |
@@ -67,8 +67,9 @@ |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | public static function doubleBackSlashes($value) { |
70 | - if (\is_string($value)) |
|
71 | - return \str_replace("\\", "\\\\", $value); |
|
70 | + if (\is_string($value)) { |
|
71 | + return \str_replace("\\", "\\\\", $value); |
|
72 | + } |
|
72 | 73 | return $value; |
73 | 74 | } |
74 | 75 |
@@ -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 | } |