@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | * @version 1.3 |
16 | 16 | */ |
17 | 17 | abstract class BaseHtml extends BaseWidget { |
18 | - use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait; |
|
18 | + use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait; |
|
19 | 19 | protected $_template; |
20 | 20 | protected $tagName; |
21 | - protected $_wrapBefore=array (); |
|
22 | - protected $_wrapAfter=array (); |
|
21 | + protected $_wrapBefore=array(); |
|
22 | + protected $_wrapAfter=array(); |
|
23 | 23 | protected $_bsComponent; |
24 | 24 | protected $_compiled=false; |
25 | 25 | |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | */ |
31 | 31 | abstract public function run(JsUtils $js); |
32 | 32 | |
33 | - private function _callSetter($setter,$key,$value,&$array){ |
|
33 | + private function _callSetter($setter, $key, $value, &$array) { |
|
34 | 34 | $result=false; |
35 | 35 | if (method_exists($this, $setter) && !JString::startswith($key, "_")) { |
36 | 36 | try { |
37 | 37 | $this->$setter($value); |
38 | 38 | unset($array[$key]); |
39 | 39 | $result=true; |
40 | - } catch ( \Exception $e ) { |
|
40 | + }catch (\Exception $e) { |
|
41 | 41 | $result=false; |
42 | 42 | } |
43 | 43 | } |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | protected function getTemplate(JsUtils $js=NULL) { |
48 | - return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
48 | + return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | protected function ctrl($name, $value, $typeCtrl) { |
52 | 52 | if (\is_array($typeCtrl)) { |
53 | - if (array_search($value, $typeCtrl) === false) { |
|
54 | - throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}"); |
|
53 | + if (array_search($value, $typeCtrl)===false) { |
|
54 | + throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}"); |
|
55 | 55 | } |
56 | 56 | } else { |
57 | 57 | if (!$typeCtrl($value)) { |
58 | - throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name); |
|
58 | + throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | return true; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | |
66 | 66 | protected function setMemberCtrl(&$name, $value, $typeCtrl) { |
67 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
67 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
68 | 68 | return $name=$value; |
69 | 69 | } |
70 | 70 | return $this; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") { |
74 | 74 | if (\is_array($typeCtrl)) { |
75 | 75 | $this->removeOldValues($name, $typeCtrl); |
76 | - $name.=$separator . $value; |
|
76 | + $name.=$separator.$value; |
|
77 | 77 | } |
78 | 78 | return $this; |
79 | 79 | } |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | |
82 | 82 | |
83 | 83 | protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") { |
84 | - if ($this->ctrl($name, $value, $typeCtrl) === true) { |
|
84 | + if ($this->ctrl($name, $value, $typeCtrl)===true) { |
|
85 | 85 | if (\is_array($typeCtrl)) { |
86 | 86 | $this->removeOldValues($name, $typeCtrl); |
87 | 87 | } |
88 | - $name.=$separator . $value; |
|
88 | + $name.=$separator.$value; |
|
89 | 89 | } |
90 | 90 | return $this; |
91 | 91 | } |
92 | 92 | |
93 | 93 | protected function addToMember(&$name, $value, $separator=" ") { |
94 | - $name=str_ireplace($value, "", $name) . $separator . $value; |
|
94 | + $name=str_ireplace($value, "", $name).$separator.$value; |
|
95 | 95 | return $this; |
96 | 96 | } |
97 | 97 | |
@@ -102,18 +102,18 @@ discard block |
||
102 | 102 | $oldValue=trim($oldValue); |
103 | 103 | } |
104 | 104 | |
105 | - protected function _getElementBy($callback,$elements){ |
|
105 | + protected function _getElementBy($callback, $elements) { |
|
106 | 106 | if (\is_array($elements)) { |
107 | 107 | $elements=\array_values($elements); |
108 | 108 | $flag=false; |
109 | 109 | $index=0; |
110 | - while ( !$flag && $index < sizeof($elements) ) { |
|
110 | + while (!$flag && $index<sizeof($elements)) { |
|
111 | 111 | if ($elements[$index] instanceof BaseHtml) |
112 | 112 | $flag=($callback($elements[$index])); |
113 | 113 | $index++; |
114 | 114 | } |
115 | - if ($flag === true) |
|
116 | - return $elements[$index - 1]; |
|
115 | + if ($flag===true) |
|
116 | + return $elements[$index-1]; |
|
117 | 117 | } elseif ($elements instanceof BaseHtml) { |
118 | 118 | if ($callback($elements)) |
119 | 119 | return $elements; |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | public function fromArray($array) { |
144 | - foreach ( $this as $key => $value ) { |
|
145 | - if(array_key_exists($key, $array)===true) |
|
146 | - $this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array); |
|
144 | + foreach ($this as $key => $value) { |
|
145 | + if (array_key_exists($key, $array)===true) |
|
146 | + $this->_callSetter("set".ucfirst($key), $key, $array[$key], $array); |
|
147 | 147 | } |
148 | - foreach ( $array as $key => $value ) { |
|
149 | - if($this->_callSetter($key, $key, $value, $array)===false){ |
|
150 | - $this->_callSetter("set" . ucfirst($key), $key, $value, $array); |
|
148 | + foreach ($array as $key => $value) { |
|
149 | + if ($this->_callSetter($key, $key, $value, $array)===false) { |
|
150 | + $this->_callSetter("set".ucfirst($key), $key, $value, $array); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | return $array; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | |
156 | 156 | public function fromDatabaseObjects($objects, $function) { |
157 | 157 | if (isset($objects)) { |
158 | - foreach ( $objects as $object ) { |
|
158 | + foreach ($objects as $object) { |
|
159 | 159 | $this->fromDatabaseObject($object, $function); |
160 | 160 | } |
161 | 161 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | |
178 | 178 | public function getElementById($identifier, $elements) { |
179 | - return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier;}, $elements); |
|
179 | + return $this->_getElementBy(function($element) use ($identifier){return $element->getIdentifier()===$identifier; }, $elements); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | public function getBsComponent() { |
@@ -191,24 +191,24 @@ discard block |
||
191 | 191 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
192 | 192 | } |
193 | 193 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
194 | - if(!$this->_compiled){ |
|
195 | - $this->compile_once($js,$view); |
|
194 | + if (!$this->_compiled) { |
|
195 | + $this->compile_once($js, $view); |
|
196 | 196 | $this->_compiled=true; |
197 | 197 | } |
198 | 198 | $result=$this->getTemplate($js); |
199 | - foreach ( $this as $key => $value ) { |
|
200 | - if (JString::startswith($key, "_") === false && $key !== "events") { |
|
199 | + foreach ($this as $key => $value) { |
|
200 | + if (JString::startswith($key, "_")===false && $key!=="events") { |
|
201 | 201 | if (\is_array($value)) { |
202 | 202 | $v=PropertyWrapper::wrap($value, $js); |
203 | 203 | } else { |
204 | 204 | $v=$value; |
205 | 205 | } |
206 | - $result=str_ireplace("%" . $key . "%", $v, $result); |
|
206 | + $result=str_ireplace("%".$key."%", $v, $result); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | if (isset($js)===true) { |
210 | 210 | $this->run($js); |
211 | - if (isset($view) === true) { |
|
211 | + if (isset($view)===true) { |
|
212 | 212 | $js->addViewElement($this->_identifier, $result, $view); |
213 | 213 | } |
214 | 214 | } |
@@ -17,18 +17,18 @@ discard block |
||
17 | 17 | |
18 | 18 | public function __construct($identifier, $elements=array(), $asIcons=false) { |
19 | 19 | parent::__construct($identifier, "div", "ui buttons"); |
20 | - if ($asIcons === true) |
|
20 | + if ($asIcons===true) |
|
21 | 21 | $this->asIcons(); |
22 | 22 | $this->addElements($elements, $asIcons); |
23 | 23 | } |
24 | - protected function createItem($value){ |
|
24 | + protected function createItem($value) { |
|
25 | 25 | return new HtmlButton("", $value); |
26 | 26 | } |
27 | 27 | |
28 | - public function addDropdown($items,$asCombo=false){ |
|
29 | - $dd= new HtmlDropdown("dd-".$this->identifier,null,$items); |
|
28 | + public function addDropdown($items, $asCombo=false) { |
|
29 | + $dd=new HtmlDropdown("dd-".$this->identifier, null, $items); |
|
30 | 30 | $dd->asButton(); |
31 | - if($asCombo){ |
|
31 | + if ($asCombo) { |
|
32 | 32 | $dd->setAction("combo"); |
33 | 33 | $dd->addToProperty("class", "combo"); |
34 | 34 | } |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | |
39 | 39 | public function addElement($element, $asIcon=false) { |
40 | 40 | $item=$this->addItem($element); |
41 | - if($asIcon) |
|
41 | + if ($asIcon) |
|
42 | 42 | $item->asIcon($element); |
43 | 43 | return $item; |
44 | 44 | } |
45 | 45 | |
46 | 46 | public function addElements($elements, $asIcons=false) { |
47 | - foreach ( $elements as $element ) { |
|
47 | + foreach ($elements as $element) { |
|
48 | 48 | $this->addElement($element, $asIcons); |
49 | 49 | } |
50 | 50 | return $this; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public function insertOr($aferIndex=0, $or="or") { |
54 | 54 | $orElement=new HtmlSemDoubleElement("", "div", "or"); |
55 | 55 | $orElement->setProperty("data-text", $or); |
56 | - array_splice($this->content, $aferIndex + 1, 0, array ($orElement )); |
|
56 | + array_splice($this->content, $aferIndex+1, 0, array($orElement)); |
|
57 | 57 | return $this; |
58 | 58 | } |
59 | 59 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | public function asIcons() { |
69 | - foreach ( $this->content as $item ) { |
|
70 | - if($item instanceof HtmlButton) |
|
69 | + foreach ($this->content as $item) { |
|
70 | + if ($item instanceof HtmlButton) |
|
71 | 71 | $item->asIcon($item->getContent()); |
72 | 72 | } |
73 | 73 | return $this->addToProperty("class", "icons"); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
101 | 101 | */ |
102 | 102 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
103 | - foreach ( $this->content as $element ) { |
|
103 | + foreach ($this->content as $element) { |
|
104 | 104 | $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
105 | 105 | } |
106 | 106 | return $this; |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | |
113 | 113 | public function addClasses($classes=array()) { |
114 | 114 | $i=0; |
115 | - if(!\is_array($classes)){ |
|
116 | - $classes=array_fill (0,$this->count(),$classes); |
|
115 | + if (!\is_array($classes)) { |
|
116 | + $classes=array_fill(0, $this->count(), $classes); |
|
117 | 117 | } |
118 | - foreach ( $this->content as $button ) { |
|
118 | + foreach ($this->content as $button) { |
|
119 | 119 | $button->addToProperty("class", $classes[$i++]); |
120 | 120 | } |
121 | 121 | return $this; |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | $this->addElement($function($object)); |
130 | 130 | } |
131 | 131 | |
132 | - public function run(JsUtils $js){ |
|
133 | - $result= parent::run($js); |
|
132 | + public function run(JsUtils $js) { |
|
133 | + $result=parent::run($js); |
|
134 | 134 | return $result->setItemSelector(".ui.button"); |
135 | 135 | } |
136 | 136 | } |
137 | 137 | \ No newline at end of file |
@@ -13,24 +13,24 @@ discard block |
||
13 | 13 | use Ajax\semantic\html\collections\form\traits\FieldTrait; |
14 | 14 | |
15 | 15 | class HtmlDropdown extends HtmlSemDoubleElement { |
16 | - use FieldTrait,LabeledIconTrait { |
|
16 | + use FieldTrait, LabeledIconTrait { |
|
17 | 17 | addIcon as addIconP; |
18 | 18 | } |
19 | 19 | protected $mClass="menu"; |
20 | 20 | protected $mTagName="div"; |
21 | - protected $items=array (); |
|
22 | - protected $_params=array("action"=>"nothing","on"=>"hover"); |
|
21 | + protected $items=array(); |
|
22 | + protected $_params=array("action"=>"nothing", "on"=>"hover"); |
|
23 | 23 | protected $input; |
24 | 24 | protected $value; |
25 | 25 | protected $_associative; |
26 | 26 | |
27 | - public function __construct($identifier, $value="", $items=array(),$associative=true) { |
|
27 | + public function __construct($identifier, $value="", $items=array(), $associative=true) { |
|
28 | 28 | parent::__construct($identifier, "div"); |
29 | 29 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
30 | 30 | $this->setProperty("class", "ui dropdown"); |
31 | 31 | $content=[]; |
32 | - if(isset($value)){ |
|
33 | - $text=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
32 | + if (isset($value)) { |
|
33 | + $text=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
34 | 34 | $text->setClass("text"); |
35 | 35 | $content=[$text]; |
36 | 36 | $this->setValue($value); |
@@ -42,29 +42,29 @@ discard block |
||
42 | 42 | $this->addItems($items); |
43 | 43 | } |
44 | 44 | |
45 | - public function getField(){ |
|
45 | + public function getField() { |
|
46 | 46 | return $this->input; |
47 | 47 | } |
48 | 48 | |
49 | - public function getDataField(){ |
|
49 | + public function getDataField() { |
|
50 | 50 | return $this->input; |
51 | 51 | } |
52 | 52 | |
53 | - public function addItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
54 | - $itemO=$this->beforeAddItem($item,$value,$image,$description); |
|
53 | + public function addItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
54 | + $itemO=$this->beforeAddItem($item, $value, $image, $description); |
|
55 | 55 | $this->items[]=$itemO; |
56 | 56 | return $itemO; |
57 | 57 | } |
58 | 58 | |
59 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
59 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
60 | 60 | $this->removeArrow(); |
61 | - $this->addIconP($icon,$before,$labeled); |
|
61 | + $this->addIconP($icon, $before, $labeled); |
|
62 | 62 | return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter(""); |
63 | 63 | } |
64 | 64 | |
65 | - public function addIcons($icons){ |
|
65 | + public function addIcons($icons) { |
|
66 | 66 | $count=$this->count(); |
67 | - for ($i=0;$i<\sizeof($icons) && $i<$count;$i++){ |
|
67 | + for ($i=0; $i<\sizeof($icons) && $i<$count; $i++) { |
|
68 | 68 | $this->getItem($i)->addIcon($icons[$i]); |
69 | 69 | } |
70 | 70 | } |
@@ -75,33 +75,33 @@ discard block |
||
75 | 75 | * @param number $position |
76 | 76 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
77 | 77 | */ |
78 | - public function insertItem($item,$position=0){ |
|
78 | + public function insertItem($item, $position=0) { |
|
79 | 79 | $itemO=$this->beforeAddItem($item); |
80 | - $start = array_slice($this->items, 0, $position); |
|
81 | - $end = array_slice($this->items, $position); |
|
82 | - $start[] = $item; |
|
80 | + $start=array_slice($this->items, 0, $position); |
|
81 | + $end=array_slice($this->items, $position); |
|
82 | + $start[]=$item; |
|
83 | 83 | $this->items=array_merge($start, $end); |
84 | 84 | return $itemO; |
85 | 85 | } |
86 | 86 | |
87 | - protected function removeArrow(){ |
|
88 | - if(\sizeof($this->content)>1){ |
|
87 | + protected function removeArrow() { |
|
88 | + if (\sizeof($this->content)>1) { |
|
89 | 89 | unset($this->content["arrow"]); |
90 | 90 | $this->content=\array_values($this->content); |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | - protected function beforeAddItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
94 | + protected function beforeAddItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
95 | 95 | $itemO=$item; |
96 | - if(\is_array($item)){ |
|
96 | + if (\is_array($item)) { |
|
97 | 97 | $description=JArray::getValue($item, "description", 3); |
98 | 98 | $value=JArray::getValue($item, "value", 1); |
99 | 99 | $image=JArray::getValue($item, "image", 2); |
100 | 100 | $item=JArray::getValue($item, "item", 0); |
101 | 101 | } |
102 | - if(!$item instanceof HtmlDropdownItem){ |
|
103 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description); |
|
104 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
102 | + if (!$item instanceof HtmlDropdownItem) { |
|
103 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image, $description); |
|
104 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
105 | 105 | $this->addToProperty("class", "vertical"); |
106 | 106 | } |
107 | 107 | return $itemO; |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | $this->addItem($function($object)); |
115 | 115 | } |
116 | 116 | |
117 | - public function addInput($name){ |
|
118 | - if(!isset($name)) |
|
117 | + public function addInput($name) { |
|
118 | + if (!isset($name)) |
|
119 | 119 | $name="input-".$this->identifier; |
120 | 120 | $this->setAction("activate"); |
121 | - $this->input=new HtmlInput($name,"hidden"); |
|
121 | + $this->input=new HtmlInput($name, "hidden"); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | * @param string $icon |
128 | 128 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
129 | 129 | */ |
130 | - public function addSearchInputItem($placeHolder=NULL,$icon=NULL){ |
|
131 | - return $this->addItem(HtmlDropdownItem::searchInput($placeHolder,$icon)); |
|
130 | + public function addSearchInputItem($placeHolder=NULL, $icon=NULL) { |
|
131 | + return $this->addItem(HtmlDropdownItem::searchInput($placeHolder, $icon)); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | 135 | * Adds a divider item |
136 | 136 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
137 | 137 | */ |
138 | - public function addDividerItem(){ |
|
138 | + public function addDividerItem() { |
|
139 | 139 | return $this->addItem(HtmlDropdownItem::divider()); |
140 | 140 | } |
141 | 141 | |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | * @param string $icon |
146 | 146 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
147 | 147 | */ |
148 | - public function addHeaderItem($caption=NULL,$icon=NULL){ |
|
149 | - return $this->addItem(HtmlDropdownItem::header($caption,$icon)); |
|
148 | + public function addHeaderItem($caption=NULL, $icon=NULL) { |
|
149 | + return $this->addItem(HtmlDropdownItem::header($caption, $icon)); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param string $color |
156 | 156 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
157 | 157 | */ |
158 | - public function addCircularLabelItem($caption,$color){ |
|
158 | + public function addCircularLabelItem($caption, $color) { |
|
159 | 159 | return $this->addItem(HtmlDropdownItem::circular($caption, $color)); |
160 | 160 | } |
161 | 161 | |
@@ -164,88 +164,88 @@ discard block |
||
164 | 164 | * @param string $image |
165 | 165 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
166 | 166 | */ |
167 | - public function addMiniAvatarImageItem($caption,$image){ |
|
167 | + public function addMiniAvatarImageItem($caption, $image) { |
|
168 | 168 | return $this->addItem(HtmlDropdownItem::avatar($caption, $image)); |
169 | 169 | } |
170 | 170 | |
171 | - public function addItems($items){ |
|
172 | - if(\is_array($items) && $this->_associative){ |
|
173 | - foreach ($items as $k=>$v){ |
|
171 | + public function addItems($items) { |
|
172 | + if (\is_array($items) && $this->_associative) { |
|
173 | + foreach ($items as $k=>$v) { |
|
174 | 174 | $this->addItem($v)->setData($k); |
175 | 175 | } |
176 | - }else{ |
|
177 | - foreach ($items as $item){ |
|
176 | + } else { |
|
177 | + foreach ($items as $item) { |
|
178 | 178 | $this->addItem($item); |
179 | 179 | } |
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
183 | - public function getItem($index){ |
|
183 | + public function getItem($index) { |
|
184 | 184 | return $this->items[$index]; |
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
188 | 188 | * @return int |
189 | 189 | */ |
190 | - public function count(){ |
|
190 | + public function count() { |
|
191 | 191 | return \sizeof($this->items); |
192 | 192 | } |
193 | 193 | /** |
194 | 194 | * @param boolean $dropdown |
195 | 195 | */ |
196 | - public function asDropdown($dropdown){ |
|
197 | - if($dropdown===false){ |
|
196 | + public function asDropdown($dropdown) { |
|
197 | + if ($dropdown===false) { |
|
198 | 198 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
199 | 199 | $dropdown="menu"; |
200 | - }else{ |
|
200 | + } else { |
|
201 | 201 | $dropdown="dropdown"; |
202 | 202 | $this->mClass="menu"; |
203 | 203 | } |
204 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
204 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
205 | 205 | } |
206 | 206 | |
207 | - public function setVertical(){ |
|
208 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
207 | + public function setVertical() { |
|
208 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
209 | 209 | } |
210 | 210 | |
211 | - public function setInline(){ |
|
212 | - return $this->addToPropertyCtrl("class", "inline",["inline"]); |
|
211 | + public function setInline() { |
|
212 | + return $this->addToPropertyCtrl("class", "inline", ["inline"]); |
|
213 | 213 | } |
214 | 214 | |
215 | - public function setSimple(){ |
|
216 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
215 | + public function setSimple() { |
|
216 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
217 | 217 | } |
218 | 218 | |
219 | - public function asButton($floating=false){ |
|
219 | + public function asButton($floating=false) { |
|
220 | 220 | $this->removeArrow(); |
221 | - if($floating) |
|
221 | + if ($floating) |
|
222 | 222 | $this->addToProperty("class", "floating"); |
223 | 223 | $this->removePropertyValue("class", "selection"); |
224 | 224 | return $this->addToProperty("class", "button"); |
225 | 225 | } |
226 | 226 | |
227 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
228 | - if(isset($name)) |
|
227 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
228 | + if (isset($name)) |
|
229 | 229 | $this->addInput($name); |
230 | - if($multiple) |
|
230 | + if ($multiple) |
|
231 | 231 | $this->addToProperty("class", "multiple"); |
232 | - if ($selection){ |
|
233 | - if($this->propertyContains("class", "button")===false) |
|
234 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
232 | + if ($selection) { |
|
233 | + if ($this->propertyContains("class", "button")===false) |
|
234 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
235 | 235 | } |
236 | 236 | return $this; |
237 | 237 | } |
238 | 238 | |
239 | - public function asSearch($name=NULL,$multiple=false,$selection=true){ |
|
240 | - $this->asSelect($name,$multiple,$selection); |
|
239 | + public function asSearch($name=NULL, $multiple=false, $selection=true) { |
|
240 | + $this->asSelect($name, $multiple, $selection); |
|
241 | 241 | return $this->addToProperty("class", "search"); |
242 | 242 | } |
243 | 243 | |
244 | - public function setSelect($name=NULL,$multiple=false){ |
|
245 | - if(!isset($name)) |
|
244 | + public function setSelect($name=NULL, $multiple=false) { |
|
245 | + if (!isset($name)) |
|
246 | 246 | $name="select-".$this->identifier; |
247 | 247 | $this->input=null; |
248 | - if($multiple){ |
|
248 | + if ($multiple) { |
|
249 | 249 | $this->setProperty("multiple", true); |
250 | 250 | $this->addToProperty("class", "multiple"); |
251 | 251 | } |
@@ -253,37 +253,37 @@ discard block |
||
253 | 253 | $this->tagName="select"; |
254 | 254 | $this->setProperty("name", $name); |
255 | 255 | $this->content=null; |
256 | - foreach ($this->items as $item){ |
|
256 | + foreach ($this->items as $item) { |
|
257 | 257 | $item->asOption(); |
258 | 258 | } |
259 | 259 | return $this; |
260 | 260 | } |
261 | 261 | |
262 | - public function asSubmenu($pointing=NULL){ |
|
262 | + public function asSubmenu($pointing=NULL) { |
|
263 | 263 | $this->setClass("ui dropdown link item"); |
264 | - if(isset($pointing)){ |
|
264 | + if (isset($pointing)) { |
|
265 | 265 | $this->setPointing($pointing); |
266 | 266 | } |
267 | 267 | return $this; |
268 | 268 | } |
269 | 269 | |
270 | - public function setPointing($value=Direction::NONE){ |
|
271 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
270 | + public function setPointing($value=Direction::NONE) { |
|
271 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
272 | 272 | } |
273 | 273 | |
274 | - public function setValue($value){ |
|
274 | + public function setValue($value) { |
|
275 | 275 | $this->value=$value; |
276 | 276 | return $this; |
277 | 277 | } |
278 | - private function applyValue(){ |
|
278 | + private function applyValue() { |
|
279 | 279 | $value=$this->value; |
280 | - if(isset($this->input) && isset($value)){ |
|
280 | + if (isset($this->input) && isset($value)) { |
|
281 | 281 | $this->input->setProperty("value", $value); |
282 | - }else{ |
|
282 | + } else { |
|
283 | 283 | $this->setProperty("value", $value); |
284 | 284 | } |
285 | 285 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
286 | - if(isset($textElement)) |
|
286 | + if (isset($textElement)) |
|
287 | 287 | $textElement->setContent($value); |
288 | 288 | return $this; |
289 | 289 | } |
@@ -293,35 +293,35 @@ discard block |
||
293 | 293 | * @see BaseHtml::run() |
294 | 294 | */ |
295 | 295 | public function run(JsUtils $js) { |
296 | - if($this->propertyContains("class", "simple")===false){ |
|
297 | - if(isset($this->_bsComponent)===false) |
|
298 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
296 | + if ($this->propertyContains("class", "simple")===false) { |
|
297 | + if (isset($this->_bsComponent)===false) |
|
298 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params); |
|
299 | 299 | $this->addEventsOnRun($js); |
300 | 300 | return $this->_bsComponent; |
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
304 | - public function setCompact(){ |
|
304 | + public function setCompact() { |
|
305 | 305 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
306 | 306 | } |
307 | 307 | |
308 | - public function setAction($action){ |
|
308 | + public function setAction($action) { |
|
309 | 309 | $this->_params["action"]=$action; |
310 | 310 | } |
311 | 311 | |
312 | - public function setFullTextSearch($value){ |
|
312 | + public function setFullTextSearch($value) { |
|
313 | 313 | $this->_params["fullTextSearch"]=$value; |
314 | 314 | } |
315 | 315 | |
316 | 316 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
317 | 317 | $this->applyValue(); |
318 | - return parent::compile($js,$view); |
|
318 | + return parent::compile($js, $view); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | public function getInput() { |
322 | 322 | return $this->input; |
323 | 323 | } |
324 | 324 | public function addAction($action, $direction=Direction::RIGHT, $icon=NULL, $labeled=false) { |
325 | - return $this->_addAction($this, $action,$direction,$icon,$labeled); |
|
325 | + return $this->_addAction($this, $action, $direction, $icon, $labeled); |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | \ No newline at end of file |
@@ -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; |
@@ -40,35 +40,35 @@ discard block |
||
40 | 40 | protected $_hiddenColumns; |
41 | 41 | |
42 | 42 | |
43 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
44 | - parent::__construct($identifier, $model,$modelInstance); |
|
45 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
|
43 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
44 | + parent::__construct($identifier, $model, $modelInstance); |
|
45 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
|
46 | 46 | $this->_urls=[]; |
47 | - $this->_emptyMessage=new HtmlMessage("","nothing to display"); |
|
47 | + $this->_emptyMessage=new HtmlMessage("", "nothing to display"); |
|
48 | 48 | $this->_emptyMessage->setIcon("info circle"); |
49 | 49 | } |
50 | 50 | |
51 | - public function run(JsUtils $js){ |
|
52 | - if($this->_hasCheckboxes && isset($js)){ |
|
51 | + public function run(JsUtils $js) { |
|
52 | + if ($this->_hasCheckboxes && isset($js)) { |
|
53 | 53 | $this->_runCheckboxes($js); |
54 | 54 | } |
55 | - if($this->_visibleHover){ |
|
56 | - $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
57 | - $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
55 | + if ($this->_visibleHover) { |
|
56 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
57 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
58 | 58 | } |
59 | - if(\is_array($this->_deleteBehavior)) |
|
60 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
61 | - if(\is_array($this->_editBehavior)) |
|
62 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
59 | + if (\is_array($this->_deleteBehavior)) |
|
60 | + $this->_generateBehavior("delete", $this->_deleteBehavior, $js); |
|
61 | + if (\is_array($this->_editBehavior)) |
|
62 | + $this->_generateBehavior("edit", $this->_editBehavior, $js); |
|
63 | 63 | return parent::run($js); |
64 | 64 | } |
65 | 65 | |
66 | 66 | |
67 | 67 | |
68 | - protected function _generateBehavior($op,$params,JsUtils $js){ |
|
69 | - if(isset($this->_urls[$op])){ |
|
70 | - $params=\array_merge($params,["attr"=>"data-ajax"]); |
|
71 | - $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector(),$params); |
|
68 | + protected function _generateBehavior($op, $params, JsUtils $js) { |
|
69 | + if (isset($this->_urls[$op])) { |
|
70 | + $params=\array_merge($params, ["attr"=>"data-ajax"]); |
|
71 | + $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector(), $params); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -81,149 +81,149 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | |
84 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
85 | - if(!$this->_generated){ |
|
84 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
85 | + if (!$this->_generated) { |
|
86 | 86 | $this->_instanceViewer->setInstance($this->_model); |
87 | 87 | $captions=$this->_instanceViewer->getCaptions(); |
88 | 88 | |
89 | 89 | $table=$this->content["table"]; |
90 | 90 | |
91 | - if($this->_hasCheckboxes){ |
|
91 | + if ($this->_hasCheckboxes) { |
|
92 | 92 | $this->_generateMainCheckbox($captions); |
93 | 93 | } |
94 | 94 | |
95 | 95 | $table->setRowCount(0, \sizeof($captions)); |
96 | - $this->_generateHeader($table,$captions); |
|
96 | + $this->_generateHeader($table, $captions); |
|
97 | 97 | |
98 | - if(isset($this->_compileParts)) |
|
98 | + if (isset($this->_compileParts)) |
|
99 | 99 | $table->setCompileParts($this->_compileParts); |
100 | 100 | |
101 | - if(isset($this->_searchField) && isset($js)){ |
|
102 | - if(isset($this->_urls["refresh"])) |
|
103 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
101 | + if (isset($this->_searchField) && isset($js)) { |
|
102 | + if (isset($this->_urls["refresh"])) |
|
103 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | $this->_generateContent($table); |
107 | 107 | |
108 | - if($this->_hasCheckboxes && $table->hasPart("thead")){ |
|
108 | + if ($this->_hasCheckboxes && $table->hasPart("thead")) { |
|
109 | 109 | $table->getHeader()->getCell(0, 0)->addClass("no-sort"); |
110 | 110 | } |
111 | 111 | |
112 | - if(isset($this->_toolbar)){ |
|
112 | + if (isset($this->_toolbar)) { |
|
113 | 113 | $this->_setToolbarPosition($table, $captions); |
114 | 114 | } |
115 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
116 | - $this->_generatePagination($table,$js); |
|
115 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
116 | + $this->_generatePagination($table, $js); |
|
117 | 117 | } |
118 | 118 | |
119 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
119 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
120 | 120 | $this->_compileForm(); |
121 | - if(isset($this->_hiddenColumns)) |
|
121 | + if (isset($this->_hiddenColumns)) |
|
122 | 122 | $this->_hideColumns(); |
123 | 123 | $this->_generated=true; |
124 | 124 | } |
125 | - return parent::compile($js,$view); |
|
125 | + return parent::compile($js, $view); |
|
126 | 126 | } |
127 | 127 | |
128 | - protected function _hideColumns(){ |
|
128 | + protected function _hideColumns() { |
|
129 | 129 | $table=$this->getTable(); |
130 | - foreach ($this->_hiddenColumns as $colIndex){ |
|
130 | + foreach ($this->_hiddenColumns as $colIndex) { |
|
131 | 131 | $table->hideColumn($colIndex); |
132 | 132 | } |
133 | 133 | return $this; |
134 | 134 | } |
135 | 135 | |
136 | - protected function _generateHeader(HtmlTable $table,$captions){ |
|
136 | + protected function _generateHeader(HtmlTable $table, $captions) { |
|
137 | 137 | $table->setHeaderValues($captions); |
138 | - if(isset($this->_sortable)){ |
|
138 | + if (isset($this->_sortable)) { |
|
139 | 139 | $table->setSortable($this->_sortable); |
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | 143 | |
144 | 144 | |
145 | - protected function _generateContent($table){ |
|
145 | + protected function _generateContent($table) { |
|
146 | 146 | $objects=$this->_modelInstance; |
147 | - if(isset($this->_pagination)){ |
|
147 | + if (isset($this->_pagination)) { |
|
148 | 148 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
149 | 149 | } |
150 | 150 | InstanceViewer::setIndex(0); |
151 | 151 | $table->fromDatabaseObjects($objects, function($instance) use($table){ |
152 | 152 | return $this->_generateRow($instance, $table); |
153 | 153 | }); |
154 | - if($table->getRowCount()==0){ |
|
154 | + if ($table->getRowCount()==0) { |
|
155 | 155 | $result=$table->addRow(); |
156 | 156 | $result->mergeRow(); |
157 | 157 | $result->setValues([$this->_emptyMessage]); |
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | - protected function _generateRow($instance,&$table,$checkedClass=null){ |
|
161 | + protected function _generateRow($instance, &$table, $checkedClass=null) { |
|
162 | 162 | $this->_instanceViewer->setInstance($instance); |
163 | 163 | InstanceViewer::$index++; |
164 | - $values= $this->_instanceViewer->getValues(); |
|
164 | + $values=$this->_instanceViewer->getValues(); |
|
165 | 165 | $id=$this->_instanceViewer->getIdentifier(); |
166 | - if($this->_hasCheckboxes){ |
|
167 | - $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,""); |
|
166 | + if ($this->_hasCheckboxes) { |
|
167 | + $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, ""); |
|
168 | 168 | $ck->setOnChange("event.stopPropagation();"); |
169 | 169 | $field=$ck->getField(); |
170 | - $field->setProperty("value",$id); |
|
170 | + $field->setProperty("value", $id); |
|
171 | 171 | $field->setProperty("name", "selection[]"); |
172 | - if(isset($checkedClass)) |
|
172 | + if (isset($checkedClass)) |
|
173 | 173 | $field->setClass($checkedClass); |
174 | 174 | \array_unshift($values, $ck); |
175 | 175 | } |
176 | 176 | $result=$table->newRow(); |
177 | 177 | $result->setIdentifier($this->identifier."-tr-".$id); |
178 | - $result->setProperty("data-ajax",$id); |
|
178 | + $result->setProperty("data-ajax", $id); |
|
179 | 179 | $result->setValues($values); |
180 | - $result->addToProperty("class",$this->_rowClass); |
|
180 | + $result->addToProperty("class", $this->_rowClass); |
|
181 | 181 | return $result; |
182 | 182 | } |
183 | 183 | |
184 | - protected function _generatePagination($table,$js=NULL){ |
|
185 | - if(isset($this->_toolbar)){ |
|
186 | - if($this->_toolbarPosition==PositionInTable::FOOTER) |
|
184 | + protected function _generatePagination($table, $js=NULL) { |
|
185 | + if (isset($this->_toolbar)) { |
|
186 | + if ($this->_toolbarPosition==PositionInTable::FOOTER) |
|
187 | 187 | $this->_toolbar->setFloated("left"); |
188 | 188 | } |
189 | 189 | $footer=$table->getFooter(); |
190 | 190 | $footer->mergeCol(); |
191 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
191 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
192 | 192 | $menu->floatRight(); |
193 | 193 | $menu->setActiveItem($this->_pagination->getPage()-1); |
194 | 194 | $footer->addValues($menu); |
195 | - $this->_associatePaginationBehavior($menu,$js); |
|
195 | + $this->_associatePaginationBehavior($menu, $js); |
|
196 | 196 | } |
197 | 197 | |
198 | - protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){ |
|
199 | - if(isset($this->_urls["refresh"])){ |
|
200 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
198 | + protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) { |
|
199 | + if (isset($this->_urls["refresh"])) { |
|
200 | + $menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - protected function _getFieldName($index){ |
|
204 | + protected function _getFieldName($index) { |
|
205 | 205 | $fieldName=parent::_getFieldName($index); |
206 | - if(\is_object($fieldName)) |
|
206 | + if (\is_object($fieldName)) |
|
207 | 207 | $fieldName="field-".$index; |
208 | 208 | return $fieldName."[]"; |
209 | 209 | } |
210 | 210 | |
211 | - protected function _getFieldCaption($index){ |
|
211 | + protected function _getFieldCaption($index) { |
|
212 | 212 | return null; |
213 | 213 | } |
214 | 214 | |
215 | - protected function _setToolbarPosition($table,$captions=NULL){ |
|
216 | - switch ($this->_toolbarPosition){ |
|
215 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
216 | + switch ($this->_toolbarPosition) { |
|
217 | 217 | case PositionInTable::BEFORETABLE: |
218 | 218 | case PositionInTable::AFTERTABLE: |
219 | - if(isset($this->_compileParts)===false){ |
|
219 | + if (isset($this->_compileParts)===false) { |
|
220 | 220 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
221 | 221 | } |
222 | 222 | break; |
223 | 223 | case PositionInTable::HEADER: |
224 | 224 | case PositionInTable::FOOTER: |
225 | 225 | case PositionInTable::BODY: |
226 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
226 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
227 | 227 | break; |
228 | 228 | } |
229 | 229 | } |
@@ -235,23 +235,23 @@ discard block |
||
235 | 235 | * @param callable $callback function called after the field compilation |
236 | 236 | * @return DataTable |
237 | 237 | */ |
238 | - public function afterCompile($index,$callback){ |
|
239 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
238 | + public function afterCompile($index, $callback) { |
|
239 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
240 | 240 | return $this; |
241 | 241 | } |
242 | 242 | |
243 | - private function addToolbarRow($part,$table,$captions){ |
|
243 | + private function addToolbarRow($part, $table, $captions) { |
|
244 | 244 | $hasPart=$table->hasPart($part); |
245 | - if($hasPart){ |
|
245 | + if ($hasPart) { |
|
246 | 246 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
247 | - }else{ |
|
247 | + } else { |
|
248 | 248 | $row=$table->getPart($part)->getRow(0); |
249 | 249 | } |
250 | 250 | $row->mergeCol(); |
251 | 251 | $row->setValues([$this->_toolbar]); |
252 | 252 | } |
253 | 253 | |
254 | - public function getHtmlComponent(){ |
|
254 | + public function getHtmlComponent() { |
|
255 | 255 | return $this->content["table"]; |
256 | 256 | } |
257 | 257 | |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | * @return DataTable |
266 | 266 | */ |
267 | 267 | public function setUrls($urls) { |
268 | - if(\is_array($urls)){ |
|
269 | - $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
|
270 | - $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
|
271 | - $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
|
272 | - }else{ |
|
273 | - $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
|
268 | + if (\is_array($urls)) { |
|
269 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
270 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
271 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
272 | + } else { |
|
273 | + $this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls]; |
|
274 | 274 | } |
275 | 275 | return $this; |
276 | 276 | } |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | * @param number $pages_visibles The number of visible pages in the Pagination component |
284 | 284 | * @return DataTable |
285 | 285 | */ |
286 | - public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){ |
|
287 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount); |
|
286 | + public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) { |
|
287 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
288 | 288 | return $this; |
289 | 289 | } |
290 | 290 | |
@@ -295,8 +295,8 @@ discard block |
||
295 | 295 | * @param number $pages_visibles The number of visible pages in the Pagination component |
296 | 296 | * @return DataTable |
297 | 297 | */ |
298 | - public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){ |
|
299 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page); |
|
298 | + public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) { |
|
299 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page); |
|
300 | 300 | return $this; |
301 | 301 | } |
302 | 302 | |
@@ -306,20 +306,20 @@ discard block |
||
306 | 306 | * @param array $compileParts |
307 | 307 | * @return DataTable |
308 | 308 | */ |
309 | - public function refresh($compileParts=["tbody"]){ |
|
309 | + public function refresh($compileParts=["tbody"]) { |
|
310 | 310 | $this->_compileParts=$compileParts; |
311 | 311 | return $this; |
312 | 312 | } |
313 | 313 | |
314 | 314 | |
315 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
315 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
316 | 316 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
317 | 317 | } |
318 | 318 | |
319 | - public function getSearchField(){ |
|
320 | - if(isset($this->_searchField)===false){ |
|
321 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
322 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
319 | + public function getSearchField() { |
|
320 | + if (isset($this->_searchField)===false) { |
|
321 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
322 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
323 | 323 | } |
324 | 324 | return $this->_searchField; |
325 | 325 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | return $this; |
336 | 336 | } |
337 | 337 | |
338 | - public function asForm(){ |
|
338 | + public function asForm() { |
|
339 | 339 | return $this->getForm(); |
340 | 340 | } |
341 | 341 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | |
344 | 344 | protected function getTargetSelector() { |
345 | 345 | $result=$this->_targetSelector; |
346 | - if(!isset($result)) |
|
346 | + if (!isset($result)) |
|
347 | 347 | $result="#".$this->identifier; |
348 | 348 | return $result; |
349 | 349 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | } |
360 | 360 | |
361 | 361 | public function getRefreshSelector() { |
362 | - if(isset($this->_refreshSelector)) |
|
362 | + if (isset($this->_refreshSelector)) |
|
363 | 363 | return $this->_refreshSelector; |
364 | 364 | return "#".$this->identifier." tbody"; |
365 | 365 | } |
@@ -377,9 +377,9 @@ discard block |
||
377 | 377 | * {@inheritDoc} |
378 | 378 | * @see \Ajax\common\Widget::show() |
379 | 379 | */ |
380 | - public function show($modelInstance){ |
|
381 | - if(\is_array($modelInstance)){ |
|
382 | - if(\is_array(array_values($modelInstance)[0])) |
|
380 | + public function show($modelInstance) { |
|
381 | + if (\is_array($modelInstance)) { |
|
382 | + if (\is_array(array_values($modelInstance)[0])) |
|
383 | 383 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
384 | 384 | } |
385 | 385 | $this->_modelInstance=$modelInstance; |
@@ -414,13 +414,13 @@ discard block |
||
414 | 414 | return $this; |
415 | 415 | } |
416 | 416 | |
417 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
418 | - $this->getTable()->setActiveRowSelector($class,$event,$multiple); |
|
417 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
418 | + $this->getTable()->setActiveRowSelector($class, $event, $multiple); |
|
419 | 419 | return $this; |
420 | 420 | } |
421 | 421 | |
422 | - public function hideColumn($colIndex){ |
|
423 | - if(!\is_array($this->_hiddenColumns)) |
|
422 | + public function hideColumn($colIndex) { |
|
423 | + if (!\is_array($this->_hiddenColumns)) |
|
424 | 424 | $this->_hiddenColumns=[]; |
425 | 425 | $this->_hiddenColumns[]=$colIndex; |
426 | 426 | return $this; |