@@ -8,17 +8,17 @@ |
||
8 | 8 | class HtmlFormInput extends HtmlFormField { |
9 | 9 | use TextFieldsTrait; |
10 | 10 | |
11 | - public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
|
12 | - if(!isset($placeholder) && $type==="text") |
|
11 | + public function __construct($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
12 | + if (!isset($placeholder) && $type==="text") |
|
13 | 13 | $placeholder=$label; |
14 | - parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
|
14 | + parent::__construct("field-".$identifier, new HtmlInput($identifier, $type, $value, $placeholder), $label); |
|
15 | 15 | $this->_identifier=$identifier; |
16 | 16 | } |
17 | 17 | |
18 | - public function getDataField(){ |
|
19 | - $field= $this->getField(); |
|
18 | + public function getDataField() { |
|
19 | + $field=$this->getField(); |
|
20 | 20 | //TODO check getField |
21 | - if($field instanceof HtmlInput) |
|
21 | + if ($field instanceof HtmlInput) |
|
22 | 22 | $field=$field->getDataField(); |
23 | 23 | return $field; |
24 | 24 | } |
@@ -9,8 +9,9 @@ discard block |
||
9 | 9 | use TextFieldsTrait; |
10 | 10 | |
11 | 11 | public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
12 | - if(!isset($placeholder) && $type==="text") |
|
13 | - $placeholder=$label; |
|
12 | + if(!isset($placeholder) && $type==="text") { |
|
13 | + $placeholder=$label; |
|
14 | + } |
|
14 | 15 | parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
15 | 16 | $this->_identifier=$identifier; |
16 | 17 | } |
@@ -18,8 +19,9 @@ discard block |
||
18 | 19 | public function getDataField(){ |
19 | 20 | $field= $this->getField(); |
20 | 21 | //TODO check getField |
21 | - if($field instanceof HtmlInput) |
|
22 | - $field=$field->getDataField(); |
|
22 | + if($field instanceof HtmlInput) { |
|
23 | + $field=$field->getDataField(); |
|
24 | + } |
|
23 | 25 | return $field; |
24 | 26 | } |
25 | 27 | } |
26 | 28 | \ No newline at end of file |
@@ -9,10 +9,10 @@ discard block |
||
9 | 9 | class HtmlFormTextarea extends HtmlFormField { |
10 | 10 | use TextFieldsTrait; |
11 | 11 | |
12 | - public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) { |
|
13 | - if(!isset($placeholder)) |
|
12 | + public function __construct($identifier, $label=NULL, $value=NULL, $placeholder=NULL, $rows=NULL) { |
|
13 | + if (!isset($placeholder)) |
|
14 | 14 | $placeholder=$label; |
15 | - parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label); |
|
15 | + parent::__construct("field-".$identifier, new HtmlTextarea($identifier, $value, $placeholder, $rows), $label); |
|
16 | 16 | $this->_identifier=$identifier; |
17 | 17 | } |
18 | 18 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * Defines the textarea row count |
21 | 21 | * @param int $count |
22 | 22 | */ |
23 | - public function setRows($count){ |
|
23 | + public function setRows($count) { |
|
24 | 24 | $this->getField()->setRows($count); |
25 | 25 | } |
26 | 26 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | return $this->content["field"]; |
29 | 29 | } |
30 | 30 | |
31 | - public function setName($name){ |
|
32 | - $this->getDataField()->setProperty("name",$name); |
|
31 | + public function setName($name) { |
|
32 | + $this->getDataField()->setProperty("name", $name); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | \ No newline at end of file |
@@ -10,8 +10,9 @@ |
||
10 | 10 | use TextFieldsTrait; |
11 | 11 | |
12 | 12 | public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) { |
13 | - if(!isset($placeholder)) |
|
14 | - $placeholder=$label; |
|
13 | + if(!isset($placeholder)) { |
|
14 | + $placeholder=$label; |
|
15 | + } |
|
15 | 16 | parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label); |
16 | 17 | $this->_identifier=$identifier; |
17 | 18 | } |
@@ -7,26 +7,26 @@ |
||
7 | 7 | |
8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
9 | 9 | |
10 | - public function __construct($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false,$associative=true) { |
|
11 | - parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label); |
|
10 | + public function __construct($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false, $associative=true) { |
|
11 | + parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label); |
|
12 | 12 | $this->_identifier=$identifier; |
13 | 13 | } |
14 | 14 | |
15 | - public function setItems($items){ |
|
15 | + public function setItems($items) { |
|
16 | 16 | return $this->getField()->setItems($items); |
17 | 17 | } |
18 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
19 | - return $this->getField()->addItem($item,$value,$image); |
|
18 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
19 | + return $this->getField()->addItem($item, $value, $image); |
|
20 | 20 | } |
21 | - public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$associative=true){ |
|
22 | - return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative); |
|
21 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $associative=true) { |
|
22 | + return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative); |
|
23 | 23 | } |
24 | 24 | |
25 | - public function getDataField(){ |
|
25 | + public function getDataField() { |
|
26 | 26 | return $this->getField()->getInput(); |
27 | 27 | } |
28 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
29 | - $this->getField()->asSelect($name,$multiple,$selection); |
|
28 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
29 | + $this->getField()->asSelect($name, $multiple, $selection); |
|
30 | 30 | return $this; |
31 | 31 | } |
32 | 32 | } |
33 | 33 | \ No newline at end of file |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | use Ajax\JsUtils; |
11 | 11 | |
12 | 12 | class HtmlInput extends HtmlSemDoubleElement { |
13 | - use IconTrait,TextFieldsTrait,FieldTrait; |
|
13 | + use IconTrait, TextFieldsTrait, FieldTrait; |
|
14 | 14 | |
15 | 15 | public function __construct($identifier, $type="text", $value="", $placeholder="") { |
16 | - parent::__construct("div-" . $identifier, "div", "ui input"); |
|
16 | + parent::__construct("div-".$identifier, "div", "ui input"); |
|
17 | 17 | $this->_identifier=$identifier; |
18 | - $this->content=[ "field" => new \Ajax\common\html\html5\HtmlInput($identifier, $type, $value, $placeholder) ]; |
|
19 | - $this->_states=[ State::DISABLED,State::FOCUS,State::ERROR ]; |
|
20 | - $this->_variations=[ Variation::TRANSPARENT ]; |
|
18 | + $this->content=["field" => new \Ajax\common\html\html5\HtmlInput($identifier, $type, $value, $placeholder)]; |
|
19 | + $this->_states=[State::DISABLED, State::FOCUS, State::ERROR]; |
|
20 | + $this->_variations=[Variation::TRANSPARENT]; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function getField() { |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | |
38 | 38 | public function run(JsUtils $js) { |
39 | 39 | $result=parent::run($js); |
40 | - $result->attach("#" . $this->getDataField()->getIdentifier()); |
|
40 | + $result->attach("#".$this->getDataField()->getIdentifier()); |
|
41 | 41 | return $result; |
42 | 42 | } |
43 | 43 | |
44 | - public function setTransparent(){ |
|
44 | + public function setTransparent() { |
|
45 | 45 | return $this->addToProperty("class", "transparent"); |
46 | 46 | } |
47 | 47 | } |
48 | 48 | \ No newline at end of file |
@@ -7,22 +7,22 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // Get the input |
10 | -$source = file_get_contents($argv[1]); |
|
10 | +$source=file_get_contents($argv[1]); |
|
11 | 11 | |
12 | 12 | // make traits to classes |
13 | -$regexp = '#trait([\s]+[\S]+[\s]*){#'; |
|
14 | -$replace = 'class$1{'; |
|
15 | -$source = preg_replace($regexp, $replace, $source); |
|
13 | +$regexp='#trait([\s]+[\S]+[\s]*){#'; |
|
14 | +$replace='class$1{'; |
|
15 | +$source=preg_replace($regexp, $replace, $source); |
|
16 | 16 | |
17 | 17 | // use traits by extending them (classes that not extending a class) |
18 | -$regexp = '#class([\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
19 | -$replace = 'class$1 extends $3 $2 {'; |
|
20 | -$source = preg_replace($regexp, $replace, $source); |
|
18 | +$regexp='#class([\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
19 | +$replace='class$1 extends $3 $2 {'; |
|
20 | +$source=preg_replace($regexp, $replace, $source); |
|
21 | 21 | |
22 | 22 | // use traits by extending them (classes that already extending a class) |
23 | -$regexp = '#class([\s]+[\S]+[\s]+extends[\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
24 | -$replace = 'class$1, $3 $2{'; |
|
25 | -$source = preg_replace($regexp, $replace, $source); |
|
23 | +$regexp='#class([\s]+[\S]+[\s]+extends[\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
24 | +$replace='class$1, $3 $2{'; |
|
25 | +$source=preg_replace($regexp, $replace, $source); |
|
26 | 26 | |
27 | 27 | // Output |
28 | 28 | echo $source; |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | * @property string $identifier |
15 | 15 | */ |
16 | 16 | trait BaseTrait { |
17 | - protected $_variations=[ ]; |
|
18 | - protected $_states=[ ]; |
|
17 | + protected $_variations=[]; |
|
18 | + protected $_states=[]; |
|
19 | 19 | protected $_baseClass; |
20 | 20 | |
21 | 21 | abstract protected function setPropertyCtrl($name, $value, $typeCtrl); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | abstract public function setProperty($name, $value); |
30 | 30 | |
31 | - abstract public function addContent($content,$before=false); |
|
31 | + abstract public function addContent($content, $before=false); |
|
32 | 32 | |
33 | 33 | abstract public function onCreate($jsCode); |
34 | 34 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $this->setProperty("class", $this->_baseClass); |
50 | 50 | if (\is_string($variations)) |
51 | 51 | $variations=\explode(" ", $variations); |
52 | - foreach ( $variations as $variation ) { |
|
52 | + foreach ($variations as $variation) { |
|
53 | 53 | $this->addVariation($variation); |
54 | 54 | } |
55 | 55 | return $this; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | public function addVariations($variations=array()) { |
64 | 64 | if (\is_string($variations)) |
65 | 65 | $variations=\explode(" ", $variations); |
66 | - foreach ( $variations as $variation ) { |
|
66 | + foreach ($variations as $variation) { |
|
67 | 67 | $this->addVariation($variation); |
68 | 68 | } |
69 | 69 | return $this; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | public function addStates($states=array()) { |
73 | 73 | if (\is_string($states)) |
74 | 74 | $states=\explode(" ", $states); |
75 | - foreach ( $states as $state ) { |
|
75 | + foreach ($states as $state) { |
|
76 | 76 | $this->addState($state); |
77 | 77 | } |
78 | 78 | return $this; |
@@ -82,17 +82,17 @@ discard block |
||
82 | 82 | $this->setProperty("class", $this->_baseClass); |
83 | 83 | if (\is_string($states)) |
84 | 84 | $states=\explode(" ", $states); |
85 | - foreach ( $states as $state ) { |
|
85 | + foreach ($states as $state) { |
|
86 | 86 | $this->addState($state); |
87 | 87 | } |
88 | 88 | return $this; |
89 | 89 | } |
90 | 90 | |
91 | 91 | public function addIcon($icon, $before=true) { |
92 | - return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before); |
|
92 | + return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before); |
|
93 | 93 | } |
94 | 94 | |
95 | - public function addSticky($context="body"){ |
|
95 | + public function addSticky($context="body") { |
|
96 | 96 | $this->onCreate("$('#".$this->identifier."').sticky({ context: '".$context."'});"); |
97 | 97 | return $this; |
98 | 98 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @return HtmlSemDoubleElement |
114 | 114 | */ |
115 | 115 | public function setDisabled($disable=true) { |
116 | - if($disable) |
|
116 | + if ($disable) |
|
117 | 117 | $this->addToProperty("class", "disabled"); |
118 | 118 | return $this; |
119 | 119 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return HtmlSemDoubleElement |
141 | 141 | */ |
142 | - public function asHeader(){ |
|
142 | + public function asHeader() { |
|
143 | 143 | return $this->addToProperty("class", "header"); |
144 | 144 | } |
145 | 145 | |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | * show it is currently the active user selection |
148 | 148 | * @return HtmlSemDoubleElement |
149 | 149 | */ |
150 | - public function setActive($value=true){ |
|
151 | - if($value) |
|
150 | + public function setActive($value=true) { |
|
151 | + if ($value) |
|
152 | 152 | $this->addToProperty("class", "active"); |
153 | 153 | return $this; |
154 | 154 | } |
155 | 155 | |
156 | - public function setAttached($value=true){ |
|
157 | - if($value) |
|
158 | - $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
156 | + public function setAttached($value=true) { |
|
157 | + if ($value) |
|
158 | + $this->addToPropertyCtrl("class", "attached", array("attached")); |
|
159 | 159 | return $this; |
160 | 160 | } |
161 | 161 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | public function setFloated($direction="right") { |
174 | - return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
|
174 | + return $this->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated")); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | public function floatRight() { |
@@ -186,14 +186,14 @@ discard block |
||
186 | 186 | return $this->_baseClass; |
187 | 187 | } |
188 | 188 | |
189 | - protected function addBehavior(&$array,$key,$value,$before="",$after=""){ |
|
190 | - if(\is_string($value)){ |
|
191 | - if(isset($array[$key])){ |
|
189 | + protected function addBehavior(&$array, $key, $value, $before="", $after="") { |
|
190 | + if (\is_string($value)) { |
|
191 | + if (isset($array[$key])) { |
|
192 | 192 | $p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, ""); |
193 | 193 | $array[$key]=$before.$p.$value.$after; |
194 | - }else |
|
194 | + } else |
|
195 | 195 | $array[$key]=$before.$value.$after; |
196 | - }else |
|
196 | + } else |
|
197 | 197 | $array[$key]=$value; |
198 | 198 | return $this; |
199 | 199 | } |
@@ -47,8 +47,9 @@ discard block |
||
47 | 47 | |
48 | 48 | public function setVariations($variations) { |
49 | 49 | $this->setProperty("class", $this->_baseClass); |
50 | - if (\is_string($variations)) |
|
51 | - $variations=\explode(" ", $variations); |
|
50 | + if (\is_string($variations)) { |
|
51 | + $variations=\explode(" ", $variations); |
|
52 | + } |
|
52 | 53 | foreach ( $variations as $variation ) { |
53 | 54 | $this->addVariation($variation); |
54 | 55 | } |
@@ -61,8 +62,9 @@ discard block |
||
61 | 62 | } |
62 | 63 | |
63 | 64 | public function addVariations($variations=array()) { |
64 | - if (\is_string($variations)) |
|
65 | - $variations=\explode(" ", $variations); |
|
65 | + if (\is_string($variations)) { |
|
66 | + $variations=\explode(" ", $variations); |
|
67 | + } |
|
66 | 68 | foreach ( $variations as $variation ) { |
67 | 69 | $this->addVariation($variation); |
68 | 70 | } |
@@ -70,8 +72,9 @@ discard block |
||
70 | 72 | } |
71 | 73 | |
72 | 74 | public function addStates($states=array()) { |
73 | - if (\is_string($states)) |
|
74 | - $states=\explode(" ", $states); |
|
75 | + if (\is_string($states)) { |
|
76 | + $states=\explode(" ", $states); |
|
77 | + } |
|
75 | 78 | foreach ( $states as $state ) { |
76 | 79 | $this->addState($state); |
77 | 80 | } |
@@ -80,8 +83,9 @@ discard block |
||
80 | 83 | |
81 | 84 | public function setStates($states) { |
82 | 85 | $this->setProperty("class", $this->_baseClass); |
83 | - if (\is_string($states)) |
|
84 | - $states=\explode(" ", $states); |
|
86 | + if (\is_string($states)) { |
|
87 | + $states=\explode(" ", $states); |
|
88 | + } |
|
85 | 89 | foreach ( $states as $state ) { |
86 | 90 | $this->addState($state); |
87 | 91 | } |
@@ -113,8 +117,9 @@ discard block |
||
113 | 117 | * @return HtmlSemDoubleElement |
114 | 118 | */ |
115 | 119 | public function setDisabled($disable=true) { |
116 | - if($disable) |
|
117 | - $this->addToProperty("class", "disabled"); |
|
120 | + if($disable) { |
|
121 | + $this->addToProperty("class", "disabled"); |
|
122 | + } |
|
118 | 123 | return $this; |
119 | 124 | } |
120 | 125 | |
@@ -148,14 +153,16 @@ discard block |
||
148 | 153 | * @return HtmlSemDoubleElement |
149 | 154 | */ |
150 | 155 | public function setActive($value=true){ |
151 | - if($value) |
|
152 | - $this->addToProperty("class", "active"); |
|
156 | + if($value) { |
|
157 | + $this->addToProperty("class", "active"); |
|
158 | + } |
|
153 | 159 | return $this; |
154 | 160 | } |
155 | 161 | |
156 | 162 | public function setAttached($value=true){ |
157 | - if($value) |
|
158 | - $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
163 | + if($value) { |
|
164 | + $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
165 | + } |
|
159 | 166 | return $this; |
160 | 167 | } |
161 | 168 | |
@@ -191,10 +198,12 @@ discard block |
||
191 | 198 | if(isset($array[$key])){ |
192 | 199 | $p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, ""); |
193 | 200 | $array[$key]=$before.$p.$value.$after; |
194 | - }else |
|
195 | - $array[$key]=$before.$value.$after; |
|
196 | - }else |
|
197 | - $array[$key]=$value; |
|
201 | + } else { |
|
202 | + $array[$key]=$before.$value.$after; |
|
203 | + } |
|
204 | + } else { |
|
205 | + $array[$key]=$value; |
|
206 | + } |
|
198 | 207 | return $this; |
199 | 208 | } |
200 | 209 | } |
201 | 210 | \ No newline at end of file |
@@ -63,6 +63,9 @@ discard block |
||
63 | 63 | |
64 | 64 | |
65 | 65 | |
66 | + /** |
|
67 | + * @param string $op |
|
68 | + */ |
|
66 | 69 | protected function _generateBehavior($op,$params,JsUtils $js){ |
67 | 70 | if(isset($this->_urls[$op])){ |
68 | 71 | $params=\array_merge($params,["attr"=>"data-ajax"]); |
@@ -139,6 +142,9 @@ discard block |
||
139 | 142 | } |
140 | 143 | } |
141 | 144 | |
145 | + /** |
|
146 | + * @param string $checkedClass |
|
147 | + */ |
|
142 | 148 | protected function _generateRow($instance,&$table,$checkedClass=null){ |
143 | 149 | $this->_instanceViewer->setInstance($instance); |
144 | 150 | InstanceViewer::$index++; |
@@ -215,6 +221,9 @@ discard block |
||
215 | 221 | return $this; |
216 | 222 | } |
217 | 223 | |
224 | + /** |
|
225 | + * @param PositionInTable $part |
|
226 | + */ |
|
218 | 227 | private function addToolbarRow($part,$table,$captions){ |
219 | 228 | $hasPart=$table->hasPart($part); |
220 | 229 | if($hasPart){ |
@@ -254,7 +263,7 @@ discard block |
||
254 | 263 | * Paginates the DataTable element with a Semantic HtmlPaginationMenu component |
255 | 264 | * @param number $page the active page number |
256 | 265 | * @param number $total_rowcount the total number of items |
257 | - * @param number $items_per_page The number of items per page |
|
266 | + * @param integer $items_per_page The number of items per page |
|
258 | 267 | * @param number $pages_visibles The number of visible pages in the Pagination component |
259 | 268 | * @return DataTable |
260 | 269 | */ |
@@ -265,9 +274,9 @@ discard block |
||
265 | 274 | |
266 | 275 | /** |
267 | 276 | * Auto Paginates the DataTable element with a Semantic HtmlPaginationMenu component |
268 | - * @param number $page the active page number |
|
269 | - * @param number $items_per_page The number of items per page |
|
270 | - * @param number $pages_visibles The number of visible pages in the Pagination component |
|
277 | + * @param integer $page the active page number |
|
278 | + * @param integer $items_per_page The number of items per page |
|
279 | + * @param integer $pages_visibles The number of visible pages in the Pagination component |
|
271 | 280 | * @return DataTable |
272 | 281 | */ |
273 | 282 | public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){ |
@@ -333,6 +342,9 @@ discard block |
||
333 | 342 | return $this; |
334 | 343 | } |
335 | 344 | |
345 | + /** |
|
346 | + * @return string |
|
347 | + */ |
|
336 | 348 | public function getRefreshSelector() { |
337 | 349 | if(isset($this->_refreshSelector)) |
338 | 350 | return $this->_refreshSelector; |
@@ -55,10 +55,12 @@ discard block |
||
55 | 55 | $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
56 | 56 | $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
57 | 57 | } |
58 | - if(\is_array($this->_deleteBehavior)) |
|
59 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
60 | - if(\is_array($this->_editBehavior)) |
|
61 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
58 | + if(\is_array($this->_deleteBehavior)) { |
|
59 | + $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
60 | + } |
|
61 | + if(\is_array($this->_editBehavior)) { |
|
62 | + $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
63 | + } |
|
62 | 64 | return parent::run($js); |
63 | 65 | } |
64 | 66 | |
@@ -94,12 +96,14 @@ discard block |
||
94 | 96 | $table->setRowCount(0, \sizeof($captions)); |
95 | 97 | $this->_generateHeader($table,$captions); |
96 | 98 | |
97 | - if(isset($this->_compileParts)) |
|
98 | - $table->setCompileParts($this->_compileParts); |
|
99 | + if(isset($this->_compileParts)) { |
|
100 | + $table->setCompileParts($this->_compileParts); |
|
101 | + } |
|
99 | 102 | |
100 | 103 | if(isset($this->_searchField) && isset($js)){ |
101 | - if(isset($this->_urls["refresh"])) |
|
102 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
104 | + if(isset($this->_urls["refresh"])) { |
|
105 | + $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
106 | + } |
|
103 | 107 | } |
104 | 108 | |
105 | 109 | $this->_generateContent($table); |
@@ -159,8 +163,9 @@ discard block |
||
159 | 163 | $field=$ck->getField(); |
160 | 164 | $field->setProperty("value",$id); |
161 | 165 | $field->setProperty("name", "selection[]"); |
162 | - if(isset($checkedClass)) |
|
163 | - $field->setClass($checkedClass); |
|
166 | + if(isset($checkedClass)) { |
|
167 | + $field->setClass($checkedClass); |
|
168 | + } |
|
164 | 169 | \array_unshift($values, $ck); |
165 | 170 | } |
166 | 171 | $result=$table->newRow(); |
@@ -173,8 +178,9 @@ discard block |
||
173 | 178 | |
174 | 179 | protected function _generatePagination($table,$js=NULL){ |
175 | 180 | if(isset($this->_toolbar)){ |
176 | - if($this->_toolbarPosition==PositionInTable::FOOTER) |
|
177 | - $this->_toolbar->setFloated("left"); |
|
181 | + if($this->_toolbarPosition==PositionInTable::FOOTER) { |
|
182 | + $this->_toolbar->setFloated("left"); |
|
183 | + } |
|
178 | 184 | } |
179 | 185 | $footer=$table->getFooter(); |
180 | 186 | $footer->mergeCol(); |
@@ -231,7 +237,7 @@ discard block |
||
231 | 237 | $hasPart=$table->hasPart($part); |
232 | 238 | if($hasPart){ |
233 | 239 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
234 | - }else{ |
|
240 | + } else{ |
|
235 | 241 | $row=$table->getPart($part)->getRow(0); |
236 | 242 | } |
237 | 243 | $row->mergeCol(); |
@@ -256,7 +262,7 @@ discard block |
||
256 | 262 | $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
257 | 263 | $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
258 | 264 | $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
259 | - }else{ |
|
265 | + } else{ |
|
260 | 266 | $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
261 | 267 | } |
262 | 268 | return $this; |
@@ -330,8 +336,9 @@ discard block |
||
330 | 336 | |
331 | 337 | protected function getTargetSelector() { |
332 | 338 | $result=$this->_targetSelector; |
333 | - if(!isset($result)) |
|
334 | - $result="#".$this->identifier; |
|
339 | + if(!isset($result)) { |
|
340 | + $result="#".$this->identifier; |
|
341 | + } |
|
335 | 342 | return $result; |
336 | 343 | } |
337 | 344 | |
@@ -346,8 +353,9 @@ discard block |
||
346 | 353 | } |
347 | 354 | |
348 | 355 | public function getRefreshSelector() { |
349 | - if(isset($this->_refreshSelector)) |
|
350 | - return $this->_refreshSelector; |
|
356 | + if(isset($this->_refreshSelector)) { |
|
357 | + return $this->_refreshSelector; |
|
358 | + } |
|
351 | 359 | return "#".$this->identifier." tbody"; |
352 | 360 | } |
353 | 361 | |
@@ -362,8 +370,9 @@ discard block |
||
362 | 370 | */ |
363 | 371 | public function show($modelInstance){ |
364 | 372 | if(\is_array($modelInstance)){ |
365 | - if(\is_array(array_values($modelInstance)[0])) |
|
366 | - $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
373 | + if(\is_array(array_values($modelInstance)[0])) { |
|
374 | + $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
375 | + } |
|
367 | 376 | } |
368 | 377 | $this->_modelInstance=$modelInstance; |
369 | 378 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | */ |
25 | 25 | class DataTable extends Widget { |
26 | - use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait; |
|
26 | + use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait; |
|
27 | 27 | protected $_searchField; |
28 | 28 | protected $_urls; |
29 | 29 | protected $_pagination; |
@@ -39,35 +39,35 @@ discard block |
||
39 | 39 | protected $_sortable; |
40 | 40 | |
41 | 41 | |
42 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
43 | - parent::__construct($identifier, $model,$modelInstance); |
|
44 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
|
42 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
43 | + parent::__construct($identifier, $model, $modelInstance); |
|
44 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
|
45 | 45 | $this->_urls=[]; |
46 | - $this->_emptyMessage=new HtmlMessage("","nothing to display"); |
|
46 | + $this->_emptyMessage=new HtmlMessage("", "nothing to display"); |
|
47 | 47 | $this->_emptyMessage->setIcon("info circle"); |
48 | 48 | } |
49 | 49 | |
50 | - public function run(JsUtils $js){ |
|
51 | - if($this->_hasCheckboxes && isset($js)){ |
|
50 | + public function run(JsUtils $js) { |
|
51 | + if ($this->_hasCheckboxes && isset($js)) { |
|
52 | 52 | $this->_runCheckboxes($js); |
53 | 53 | } |
54 | - if($this->_visibleHover){ |
|
55 | - $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
56 | - $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
54 | + if ($this->_visibleHover) { |
|
55 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
56 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
57 | 57 | } |
58 | - if(\is_array($this->_deleteBehavior)) |
|
59 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
60 | - if(\is_array($this->_editBehavior)) |
|
61 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
58 | + if (\is_array($this->_deleteBehavior)) |
|
59 | + $this->_generateBehavior("delete", $this->_deleteBehavior, $js); |
|
60 | + if (\is_array($this->_editBehavior)) |
|
61 | + $this->_generateBehavior("edit", $this->_editBehavior, $js); |
|
62 | 62 | return parent::run($js); |
63 | 63 | } |
64 | 64 | |
65 | 65 | |
66 | 66 | |
67 | - protected function _generateBehavior($op,$params,JsUtils $js){ |
|
68 | - if(isset($this->_urls[$op])){ |
|
69 | - $params=\array_merge($params,["attr"=>"data-ajax"]); |
|
70 | - $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector(),$params); |
|
67 | + protected function _generateBehavior($op, $params, JsUtils $js) { |
|
68 | + if (isset($this->_urls[$op])) { |
|
69 | + $params=\array_merge($params, ["attr"=>"data-ajax"]); |
|
70 | + $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector(), $params); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -80,137 +80,137 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | |
83 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
84 | - if(!$this->_generated){ |
|
83 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
84 | + if (!$this->_generated) { |
|
85 | 85 | $this->_instanceViewer->setInstance($this->_model); |
86 | 86 | $captions=$this->_instanceViewer->getCaptions(); |
87 | 87 | |
88 | 88 | $table=$this->content["table"]; |
89 | 89 | |
90 | - if($this->_hasCheckboxes){ |
|
90 | + if ($this->_hasCheckboxes) { |
|
91 | 91 | $this->_generateMainCheckbox($captions); |
92 | 92 | } |
93 | 93 | |
94 | 94 | $table->setRowCount(0, \sizeof($captions)); |
95 | - $this->_generateHeader($table,$captions); |
|
95 | + $this->_generateHeader($table, $captions); |
|
96 | 96 | |
97 | - if(isset($this->_compileParts)) |
|
97 | + if (isset($this->_compileParts)) |
|
98 | 98 | $table->setCompileParts($this->_compileParts); |
99 | 99 | |
100 | - if(isset($this->_searchField) && isset($js)){ |
|
101 | - if(isset($this->_urls["refresh"])) |
|
102 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
100 | + if (isset($this->_searchField) && isset($js)) { |
|
101 | + if (isset($this->_urls["refresh"])) |
|
102 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | $this->_generateContent($table); |
106 | 106 | |
107 | - if($this->_hasCheckboxes && $table->hasPart("thead")){ |
|
107 | + if ($this->_hasCheckboxes && $table->hasPart("thead")) { |
|
108 | 108 | $table->getHeader()->getCell(0, 0)->addClass("no-sort"); |
109 | 109 | } |
110 | 110 | |
111 | - if(isset($this->_toolbar)){ |
|
111 | + if (isset($this->_toolbar)) { |
|
112 | 112 | $this->_setToolbarPosition($table, $captions); |
113 | 113 | } |
114 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
115 | - $this->_generatePagination($table,$js); |
|
114 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
115 | + $this->_generatePagination($table, $js); |
|
116 | 116 | } |
117 | 117 | |
118 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
118 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
119 | 119 | $this->_compileForm(); |
120 | 120 | |
121 | 121 | $this->_generated=true; |
122 | 122 | } |
123 | - return parent::compile($js,$view); |
|
123 | + return parent::compile($js, $view); |
|
124 | 124 | } |
125 | 125 | |
126 | - protected function _generateHeader(HtmlTable $table,$captions){ |
|
126 | + protected function _generateHeader(HtmlTable $table, $captions) { |
|
127 | 127 | $table->setHeaderValues($captions); |
128 | - if(isset($this->_sortable)){ |
|
128 | + if (isset($this->_sortable)) { |
|
129 | 129 | $table->setSortable($this->_sortable); |
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | 133 | |
134 | 134 | |
135 | - protected function _generateContent($table){ |
|
135 | + protected function _generateContent($table) { |
|
136 | 136 | $objects=$this->_modelInstance; |
137 | - if(isset($this->_pagination)){ |
|
137 | + if (isset($this->_pagination)) { |
|
138 | 138 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
139 | 139 | } |
140 | 140 | InstanceViewer::setIndex(0); |
141 | 141 | $table->fromDatabaseObjects($objects, function($instance) use($table){ |
142 | 142 | return $this->_generateRow($instance, $table); |
143 | 143 | }); |
144 | - if($table->getRowCount()==0){ |
|
144 | + if ($table->getRowCount()==0) { |
|
145 | 145 | $result=$table->addRow(); |
146 | 146 | $result->mergeRow(); |
147 | 147 | $result->setValues([$this->_emptyMessage]); |
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | - protected function _generateRow($instance,&$table,$checkedClass=null){ |
|
151 | + protected function _generateRow($instance, &$table, $checkedClass=null) { |
|
152 | 152 | $this->_instanceViewer->setInstance($instance); |
153 | 153 | InstanceViewer::$index++; |
154 | - $values= $this->_instanceViewer->getValues(); |
|
154 | + $values=$this->_instanceViewer->getValues(); |
|
155 | 155 | $id=$this->_instanceViewer->getIdentifier(); |
156 | - if($this->_hasCheckboxes){ |
|
157 | - $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,""); |
|
156 | + if ($this->_hasCheckboxes) { |
|
157 | + $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, ""); |
|
158 | 158 | $ck->setOnChange("event.stopPropagation();"); |
159 | 159 | $field=$ck->getField(); |
160 | - $field->setProperty("value",$id); |
|
160 | + $field->setProperty("value", $id); |
|
161 | 161 | $field->setProperty("name", "selection[]"); |
162 | - if(isset($checkedClass)) |
|
162 | + if (isset($checkedClass)) |
|
163 | 163 | $field->setClass($checkedClass); |
164 | 164 | \array_unshift($values, $ck); |
165 | 165 | } |
166 | 166 | $result=$table->newRow(); |
167 | 167 | $result->setIdentifier($this->identifier."-tr-".$id); |
168 | - $result->setProperty("data-ajax",$id); |
|
168 | + $result->setProperty("data-ajax", $id); |
|
169 | 169 | $result->setValues($values); |
170 | - $result->addToProperty("class",$this->_rowClass); |
|
170 | + $result->addToProperty("class", $this->_rowClass); |
|
171 | 171 | return $result; |
172 | 172 | } |
173 | 173 | |
174 | - protected function _generatePagination($table,$js=NULL){ |
|
175 | - if(isset($this->_toolbar)){ |
|
176 | - if($this->_toolbarPosition==PositionInTable::FOOTER) |
|
174 | + protected function _generatePagination($table, $js=NULL) { |
|
175 | + if (isset($this->_toolbar)) { |
|
176 | + if ($this->_toolbarPosition==PositionInTable::FOOTER) |
|
177 | 177 | $this->_toolbar->setFloated("left"); |
178 | 178 | } |
179 | 179 | $footer=$table->getFooter(); |
180 | 180 | $footer->mergeCol(); |
181 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
181 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
182 | 182 | $menu->floatRight(); |
183 | 183 | $menu->setActiveItem($this->_pagination->getPage()-1); |
184 | 184 | $footer->addValues($menu); |
185 | - $this->_associatePaginationBehavior($menu,$js); |
|
185 | + $this->_associatePaginationBehavior($menu, $js); |
|
186 | 186 | } |
187 | 187 | |
188 | - protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){ |
|
189 | - if(isset($this->_urls["refresh"])){ |
|
190 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
188 | + protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) { |
|
189 | + if (isset($this->_urls["refresh"])) { |
|
190 | + $menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | - protected function _getFieldName($index){ |
|
194 | + protected function _getFieldName($index) { |
|
195 | 195 | return parent::_getFieldName($index)."[]"; |
196 | 196 | } |
197 | 197 | |
198 | - protected function _getFieldCaption($index){ |
|
198 | + protected function _getFieldCaption($index) { |
|
199 | 199 | return null; |
200 | 200 | } |
201 | 201 | |
202 | - protected function _setToolbarPosition($table,$captions=NULL){ |
|
203 | - switch ($this->_toolbarPosition){ |
|
202 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
203 | + switch ($this->_toolbarPosition) { |
|
204 | 204 | case PositionInTable::BEFORETABLE: |
205 | 205 | case PositionInTable::AFTERTABLE: |
206 | - if(isset($this->_compileParts)===false){ |
|
206 | + if (isset($this->_compileParts)===false) { |
|
207 | 207 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
208 | 208 | } |
209 | 209 | break; |
210 | 210 | case PositionInTable::HEADER: |
211 | 211 | case PositionInTable::FOOTER: |
212 | 212 | case PositionInTable::BODY: |
213 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
213 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
214 | 214 | break; |
215 | 215 | } |
216 | 216 | } |
@@ -222,23 +222,23 @@ discard block |
||
222 | 222 | * @param callable $callback function called after the field compilation |
223 | 223 | * @return DataTable |
224 | 224 | */ |
225 | - public function afterCompile($index,$callback){ |
|
226 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
225 | + public function afterCompile($index, $callback) { |
|
226 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
227 | 227 | return $this; |
228 | 228 | } |
229 | 229 | |
230 | - private function addToolbarRow($part,$table,$captions){ |
|
230 | + private function addToolbarRow($part, $table, $captions) { |
|
231 | 231 | $hasPart=$table->hasPart($part); |
232 | - if($hasPart){ |
|
232 | + if ($hasPart) { |
|
233 | 233 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
234 | - }else{ |
|
234 | + } else { |
|
235 | 235 | $row=$table->getPart($part)->getRow(0); |
236 | 236 | } |
237 | 237 | $row->mergeCol(); |
238 | 238 | $row->setValues([$this->_toolbar]); |
239 | 239 | } |
240 | 240 | |
241 | - public function getHtmlComponent(){ |
|
241 | + public function getHtmlComponent() { |
|
242 | 242 | return $this->content["table"]; |
243 | 243 | } |
244 | 244 | |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | * @return DataTable |
253 | 253 | */ |
254 | 254 | public function setUrls($urls) { |
255 | - if(\is_array($urls)){ |
|
256 | - $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
|
257 | - $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
|
258 | - $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
|
259 | - }else{ |
|
260 | - $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
|
255 | + if (\is_array($urls)) { |
|
256 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
257 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
258 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
259 | + } else { |
|
260 | + $this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls]; |
|
261 | 261 | } |
262 | 262 | return $this; |
263 | 263 | } |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | * @param number $pages_visibles The number of visible pages in the Pagination component |
271 | 271 | * @return DataTable |
272 | 272 | */ |
273 | - public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){ |
|
274 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount); |
|
273 | + public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) { |
|
274 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
275 | 275 | return $this; |
276 | 276 | } |
277 | 277 | |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | * @param number $pages_visibles The number of visible pages in the Pagination component |
283 | 283 | * @return DataTable |
284 | 284 | */ |
285 | - public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){ |
|
286 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page); |
|
285 | + public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) { |
|
286 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page); |
|
287 | 287 | return $this; |
288 | 288 | } |
289 | 289 | |
@@ -293,20 +293,20 @@ discard block |
||
293 | 293 | * @param array $compileParts |
294 | 294 | * @return DataTable |
295 | 295 | */ |
296 | - public function refresh($compileParts=["tbody"]){ |
|
296 | + public function refresh($compileParts=["tbody"]) { |
|
297 | 297 | $this->_compileParts=$compileParts; |
298 | 298 | return $this; |
299 | 299 | } |
300 | 300 | |
301 | 301 | |
302 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
302 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
303 | 303 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
304 | 304 | } |
305 | 305 | |
306 | - public function getSearchField(){ |
|
307 | - if(isset($this->_searchField)===false){ |
|
308 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
309 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
306 | + public function getSearchField() { |
|
307 | + if (isset($this->_searchField)===false) { |
|
308 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
309 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
310 | 310 | } |
311 | 311 | return $this->_searchField; |
312 | 312 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | return $this; |
323 | 323 | } |
324 | 324 | |
325 | - public function asForm(){ |
|
325 | + public function asForm() { |
|
326 | 326 | return $this->getForm(); |
327 | 327 | } |
328 | 328 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | |
331 | 331 | protected function getTargetSelector() { |
332 | 332 | $result=$this->_targetSelector; |
333 | - if(!isset($result)) |
|
333 | + if (!isset($result)) |
|
334 | 334 | $result="#".$this->identifier; |
335 | 335 | return $result; |
336 | 336 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | } |
347 | 347 | |
348 | 348 | public function getRefreshSelector() { |
349 | - if(isset($this->_refreshSelector)) |
|
349 | + if (isset($this->_refreshSelector)) |
|
350 | 350 | return $this->_refreshSelector; |
351 | 351 | return "#".$this->identifier." tbody"; |
352 | 352 | } |
@@ -360,9 +360,9 @@ discard block |
||
360 | 360 | * {@inheritDoc} |
361 | 361 | * @see \Ajax\common\Widget::show() |
362 | 362 | */ |
363 | - public function show($modelInstance){ |
|
364 | - if(\is_array($modelInstance)){ |
|
365 | - if(\is_array(array_values($modelInstance)[0])) |
|
363 | + public function show($modelInstance) { |
|
364 | + if (\is_array($modelInstance)) { |
|
365 | + if (\is_array(array_values($modelInstance)[0])) |
|
366 | 366 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
367 | 367 | } |
368 | 368 | $this->_modelInstance=$modelInstance; |
@@ -397,8 +397,8 @@ discard block |
||
397 | 397 | return $this; |
398 | 398 | } |
399 | 399 | |
400 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
401 | - $this->getTable()->setActiveRowSelector($class,$event,$multiple); |
|
400 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
401 | + $this->getTable()->setActiveRowSelector($class, $event, $multiple); |
|
402 | 402 | return $this; |
403 | 403 | } |
404 | 404 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | protected $ajaxTransition; |
18 | 18 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
19 | 19 | |
20 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
20 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
21 | 21 | protected function addLoading(&$retour, $responseElement) { |
22 | 22 | $loading_notifier='<div class="ajax-loader">'; |
23 | 23 | if ($this->ajaxLoader=='') { |
@@ -30,66 +30,66 @@ discard block |
||
30 | 30 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
31 | 31 | } |
32 | 32 | |
33 | - public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
34 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
33 | + public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
34 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
35 | 35 | } |
36 | - public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
37 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
36 | + public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
37 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
38 | 38 | } |
39 | 39 | |
40 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
41 | - if(JString::isNull($params)){$params="{}";} |
|
40 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
41 | + if (JString::isNull($params)) {$params="{}"; } |
|
42 | 42 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
43 | 43 | $retour=$this->_getAjaxUrl($url, $attr); |
44 | 44 | $responseElement=$this->_getResponseElement($responseElement); |
45 | 45 | $retour.="var self=this;\n"; |
46 | - if($hasLoader===true){ |
|
46 | + if ($hasLoader===true) { |
|
47 | 47 | $this->addLoading($retour, $responseElement); |
48 | 48 | } |
49 | 49 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
50 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
50 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
51 | 51 | if ($immediatly) |
52 | 52 | $this->jquery_code_for_compile[]=$retour; |
53 | 53 | return $retour; |
54 | 54 | } |
55 | 55 | |
56 | - protected function setAjaxDataCall($params){ |
|
56 | + protected function setAjaxDataCall($params) { |
|
57 | 57 | $result=null; |
58 | - if(!\is_callable($params)){ |
|
59 | - $result=function ($responseElement,$jqueryDone="html") use($params){ |
|
60 | - return AjaxTransition::{$params}($responseElement,$jqueryDone); |
|
58 | + if (!\is_callable($params)) { |
|
59 | + $result=function($responseElement, $jqueryDone="html") use($params){ |
|
60 | + return AjaxTransition::{$params}($responseElement, $jqueryDone); |
|
61 | 61 | }; |
62 | 62 | } |
63 | 63 | return $result; |
64 | 64 | } |
65 | 65 | |
66 | - protected function _getAjaxUrl($url,$attr){ |
|
66 | + protected function _getAjaxUrl($url, $attr) { |
|
67 | 67 | $url=$this->_correctAjaxUrl($url); |
68 | 68 | $retour="url='".$url."';"; |
69 | 69 | $slash="/"; |
70 | - if(JString::endswith($url, "/")===true) |
|
70 | + if (JString::endswith($url, "/")===true) |
|
71 | 71 | $slash=""; |
72 | - if(JString::isNotNull($attr)){ |
|
72 | + if (JString::isNotNull($attr)) { |
|
73 | 73 | if ($attr==="value") |
74 | 74 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
75 | 75 | elseif ($attr==="html") |
76 | 76 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
77 | - elseif($attr!=null && $attr!=="") |
|
77 | + elseif ($attr!=null && $attr!=="") |
|
78 | 78 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
79 | 79 | } |
80 | 80 | return $retour; |
81 | 81 | } |
82 | 82 | |
83 | - protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback){ |
|
84 | - $retour="";$call=null; |
|
83 | + protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback) { |
|
84 | + $retour=""; $call=null; |
|
85 | 85 | if ($responseElement!=="") { |
86 | - if(isset($ajaxTransition)){ |
|
86 | + if (isset($ajaxTransition)) { |
|
87 | 87 | $call=$this->setAjaxDataCall($ajaxTransition); |
88 | - }elseif(isset($this->ajaxTransition)){ |
|
88 | + }elseif (isset($this->ajaxTransition)) { |
|
89 | 89 | $call=$this->ajaxTransition; |
90 | 90 | } |
91 | - if(\is_callable($call)) |
|
92 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
91 | + if (\is_callable($call)) |
|
92 | + $retour="\t".$call($responseElement, $jqueryDone).";\n"; |
|
93 | 93 | else |
94 | 94 | $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
95 | 95 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | return $retour; |
98 | 98 | } |
99 | 99 | |
100 | - protected function _getResponseElement($responseElement){ |
|
100 | + protected function _getResponseElement($responseElement) { |
|
101 | 101 | if ($responseElement!=="") { |
102 | 102 | $responseElement=Javascript::prep_value($responseElement); |
103 | 103 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | protected function _correctAjaxUrl($url) { |
108 | 108 | if ($url!=="/" && JString::endsWith($url, "/")===true) |
109 | 109 | $url=substr($url, 0, strlen($url)-1); |
110 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
110 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
111 | 111 | $url=$this->jsUtils->getUrl($url); |
112 | 112 | } |
113 | 113 | return $url; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @param string $jsCallback javascript code to execute after the request |
122 | 122 | * @param boolean $immediatly |
123 | 123 | */ |
124 | - public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
124 | + public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
125 | 125 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
126 | 126 | $retour=$this->_getAjaxUrl($url, $attr); |
127 | 127 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param string $url the request address |
143 | 143 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
144 | 144 | */ |
145 | - public function _jsonOn($event,$element, $url,$parameters=array()) { |
|
145 | + public function _jsonOn($event, $element, $url, $parameters=array()) { |
|
146 | 146 | $preventDefault=true; |
147 | 147 | $stopPropagation=true; |
148 | 148 | $jsCallback=null; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $params="{}"; |
153 | 153 | $immediatly=true; |
154 | 154 | extract($parameters); |
155 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
155 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -164,22 +164,22 @@ discard block |
||
164 | 164 | * @param string $context jquery DOM element, array container. |
165 | 165 | * @param boolean $immediatly |
166 | 166 | */ |
167 | - public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$immediatly=false) { |
|
167 | + public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $immediatly=false) { |
|
168 | 168 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
169 | 169 | $retour=$this->_getAjaxUrl($url, $attr); |
170 | - if($context===null){ |
|
170 | + if ($context===null) { |
|
171 | 171 | $parent="$('".$maskSelector."').parent()"; |
172 | - $newElm = "$('#'+newId)"; |
|
173 | - }else{ |
|
172 | + $newElm="$('#'+newId)"; |
|
173 | + } else { |
|
174 | 174 | $parent=$context; |
175 | - $newElm = $context.".find('#'+newId)"; |
|
175 | + $newElm=$context.".find('#'+newId)"; |
|
176 | 176 | } |
177 | 177 | $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
178 | 178 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
179 | 179 | $retour.=$parent.".find('._json').remove();"; |
180 | 180 | $retour.="\tdata=$.parseJSON(data);$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone(); |
181 | 181 | newElm.attr('id',newId);\n;newElm.addClass('_json').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n"; |
182 | - $retour.= $appendTo; |
|
182 | + $retour.=$appendTo; |
|
183 | 183 | $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"; |
184 | 184 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
185 | 185 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -194,30 +194,30 @@ discard block |
||
194 | 194 | * @param string $url the request address |
195 | 195 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null) |
196 | 196 | */ |
197 | - public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) { |
|
197 | + public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
198 | 198 | $preventDefault=true; |
199 | 199 | $stopPropagation=true; |
200 | 200 | $jsCallback=null; |
201 | 201 | $attr="id"; |
202 | 202 | $method="get"; |
203 | - $context = null; |
|
203 | + $context=null; |
|
204 | 204 | $params="{}"; |
205 | 205 | $immediatly=true; |
206 | 206 | extract($parameters); |
207 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
207 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
208 | 208 | } |
209 | 209 | |
210 | - public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
210 | + public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
211 | 211 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
212 | 212 | $retour=$this->_getAjaxUrl($url, $attr); |
213 | 213 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
214 | 214 | $responseElement=$this->_getResponseElement($responseElement); |
215 | 215 | $retour.="var self=this;\n"; |
216 | - if($hasLoader===true){ |
|
216 | + if ($hasLoader===true) { |
|
217 | 217 | $this->addLoading($retour, $responseElement); |
218 | 218 | } |
219 | 219 | $retour.="$.post(url,params).done(function( data ) {\n"; |
220 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
220 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
221 | 221 | |
222 | 222 | if ($validation) { |
223 | 223 | $retour="$('#".$form."').validate({submitHandler: function(form) { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @param string $responseElement |
241 | 241 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxTransition"=>null,"jqueryDone"=>"html") |
242 | 242 | */ |
243 | - public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
243 | + public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
244 | 244 | $preventDefault=true; |
245 | 245 | $stopPropagation=true; |
246 | 246 | $jsCallback=null; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $jqueryDone="html"; |
251 | 251 | $ajaxTransition=null; |
252 | 252 | extract($parameters); |
253 | - return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
253 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @param string $responseElement |
264 | 264 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxTransition"=>null) |
265 | 265 | */ |
266 | - public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
266 | + public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
267 | 267 | $preventDefault=true; |
268 | 268 | $stopPropagation=true; |
269 | 269 | $jsCallback=null; |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $jqueryDone="html"; |
274 | 274 | $ajaxTransition=null; |
275 | 275 | extract($parameters); |
276 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
276 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * @param string $responseElement |
287 | 287 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxTransition"=>null,"immediatly"=>true) |
288 | 288 | */ |
289 | - public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
289 | + public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
290 | 290 | $preventDefault=true; |
291 | 291 | $stopPropagation=true; |
292 | 292 | $validation=false; |
@@ -297,6 +297,6 @@ discard block |
||
297 | 297 | $jqueryDone="html"; |
298 | 298 | $ajaxTransition=null; |
299 | 299 | extract($parameters); |
300 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
300 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | \ No newline at end of file |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | } |
49 | 49 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
50 | 50 | $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
51 | - if ($immediatly) |
|
52 | - $this->jquery_code_for_compile[]=$retour; |
|
51 | + if ($immediatly) { |
|
52 | + $this->jquery_code_for_compile[]=$retour; |
|
53 | + } |
|
53 | 54 | return $retour; |
54 | 55 | } |
55 | 56 | |
@@ -67,15 +68,17 @@ discard block |
||
67 | 68 | $url=$this->_correctAjaxUrl($url); |
68 | 69 | $retour="url='".$url."';"; |
69 | 70 | $slash="/"; |
70 | - if(JString::endswith($url, "/")===true) |
|
71 | - $slash=""; |
|
71 | + if(JString::endswith($url, "/")===true) { |
|
72 | + $slash=""; |
|
73 | + } |
|
72 | 74 | if(JString::isNotNull($attr)){ |
73 | - if ($attr==="value") |
|
74 | - $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
75 | - elseif ($attr==="html") |
|
76 | - $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
77 | - elseif($attr!=null && $attr!=="") |
|
78 | - $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
75 | + if ($attr==="value") { |
|
76 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
77 | + } elseif ($attr==="html") { |
|
78 | + $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
79 | + } elseif($attr!=null && $attr!=="") { |
|
80 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
81 | + } |
|
79 | 82 | } |
80 | 83 | return $retour; |
81 | 84 | } |
@@ -85,13 +88,14 @@ discard block |
||
85 | 88 | if ($responseElement!=="") { |
86 | 89 | if(isset($ajaxTransition)){ |
87 | 90 | $call=$this->setAjaxDataCall($ajaxTransition); |
88 | - }elseif(isset($this->ajaxTransition)){ |
|
91 | + } elseif(isset($this->ajaxTransition)){ |
|
89 | 92 | $call=$this->ajaxTransition; |
90 | 93 | } |
91 | - if(\is_callable($call)) |
|
92 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
93 | - else |
|
94 | - $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
|
94 | + if(\is_callable($call)) { |
|
95 | + $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
96 | + } else { |
|
97 | + $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
|
98 | + } |
|
95 | 99 | } |
96 | 100 | $retour.="\t".$jsCallback."\n"; |
97 | 101 | return $retour; |
@@ -105,8 +109,9 @@ discard block |
||
105 | 109 | } |
106 | 110 | |
107 | 111 | protected function _correctAjaxUrl($url) { |
108 | - if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
109 | - $url=substr($url, 0, strlen($url)-1); |
|
112 | + if ($url!=="/" && JString::endsWith($url, "/")===true) { |
|
113 | + $url=substr($url, 0, strlen($url)-1); |
|
114 | + } |
|
110 | 115 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
111 | 116 | $url=$this->jsUtils->getUrl($url); |
112 | 117 | } |
@@ -130,8 +135,9 @@ discard block |
||
130 | 135 | $retour.="\t".$jsCallback."\n". |
131 | 136 | "\t$(document).trigger('jsonReady',[data]);\n". |
132 | 137 | "});\n"; |
133 | - if ($immediatly) |
|
134 | - $this->jquery_code_for_compile[]=$retour; |
|
138 | + if ($immediatly) { |
|
139 | + $this->jquery_code_for_compile[]=$retour; |
|
140 | + } |
|
135 | 141 | return $retour; |
136 | 142 | } |
137 | 143 | |
@@ -170,7 +176,7 @@ discard block |
||
170 | 176 | if($context===null){ |
171 | 177 | $parent="$('".$maskSelector."').parent()"; |
172 | 178 | $newElm = "$('#'+newId)"; |
173 | - }else{ |
|
179 | + } else{ |
|
174 | 180 | $parent=$context; |
175 | 181 | $newElm = $context.".find('#'+newId)"; |
176 | 182 | } |
@@ -183,8 +189,9 @@ discard block |
||
183 | 189 | $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"; |
184 | 190 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
185 | 191 | $retour.="\t".$jsCallback."\n"."});\n"; |
186 | - if ($immediatly) |
|
187 | - $this->jquery_code_for_compile[]=$retour; |
|
192 | + if ($immediatly) { |
|
193 | + $this->jquery_code_for_compile[]=$retour; |
|
194 | + } |
|
188 | 195 | return $retour; |
189 | 196 | } |
190 | 197 | /** |
@@ -225,8 +232,9 @@ discard block |
||
225 | 232 | }});\n"; |
226 | 233 | $retour.="$('#".$form."').submit();\n"; |
227 | 234 | } |
228 | - if ($immediatly) |
|
229 | - $this->jquery_code_for_compile[]=$retour; |
|
235 | + if ($immediatly) { |
|
236 | + $this->jquery_code_for_compile[]=$retour; |
|
237 | + } |
|
230 | 238 | return $retour; |
231 | 239 | } |
232 | 240 |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
26 | 26 | * @param string|callable $ajaxTransition |
27 | 27 | */ |
28 | - public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
29 | - return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
28 | + public function get($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
29 | + return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * @param string $jsCallback javascript code to execute after the request |
38 | 38 | * @param boolean $immediatly |
39 | 39 | */ |
40 | - public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
41 | - return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context,$immediatly); |
|
40 | + public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
41 | + return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context, $immediatly); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * @param string $url the request address |
49 | 49 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
50 | 50 | */ |
51 | - public function jsonOn($event,$element, $url,$parameters=array()) { |
|
52 | - return $this->js->_jsonOn($event, $element, $url,$parameters); |
|
51 | + public function jsonOn($event, $element, $url, $parameters=array()) { |
|
52 | + return $this->js->_jsonOn($event, $element, $url, $parameters); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param string $jsCallback javascript code to execute after the request |
72 | 72 | */ |
73 | 73 | public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL) { |
74 | - return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback,"id", NULL,true); |
|
74 | + return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, "id", NULL, true); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param string $jsCallback javascript code to execute after the request |
84 | 84 | */ |
85 | 85 | public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL) { |
86 | - return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback,"id", NULL, false); |
|
86 | + return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, "id", NULL, false); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * @param string $url the request url |
94 | 94 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
95 | 95 | */ |
96 | - public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) { |
|
97 | - return $this->js->_jsonArrayOn($event,$element,$maskSelector, $url, $parameters); |
|
96 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
97 | + return $this->js->_jsonArrayOn($event, $element, $maskSelector, $url, $parameters); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
109 | 109 | * @param string|callable $ajaxTransition |
110 | 110 | */ |
111 | - public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id",$jqueryDone="html",$ajaxTransition=null) { |
|
112 | - return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false,$jqueryDone,$ajaxTransition); |
|
111 | + public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $jqueryDone="html", $ajaxTransition=null) { |
|
112 | + return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false, $jqueryDone, $ajaxTransition); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
149 | 149 | * @param string|callable $ajaxTransition |
150 | 150 | */ |
151 | - public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
152 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
151 | + public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
152 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
165 | 165 | * @param string|callable $ajaxTransition |
166 | 166 | */ |
167 | - public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
168 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
167 | + public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
168 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null) |
180 | 180 | */ |
181 | 181 | public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
182 | - return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
182 | + return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
206 | 206 | * @param string|callable $ajaxTransition |
207 | 207 | */ |
208 | - public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
209 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
208 | + public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
209 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
222 | 222 | * @param string|callable $ajaxTransition |
223 | 223 | */ |
224 | - public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
225 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
224 | + public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
225 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null) |
237 | 237 | */ |
238 | 238 | public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
239 | - return $this->js->_postFormOn($event,$element, $url, $form, $responseElement, $parameters); |
|
239 | + return $this->js->_postFormOn($event, $element, $url, $form, $responseElement, $parameters); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |