@@ -32,6 +32,10 @@ discard block |
||
32 | 32 | protected $_targetSelector; |
33 | 33 | |
34 | 34 | |
35 | + /** |
|
36 | + * @param string $identifier |
|
37 | + * @param string $model |
|
38 | + */ |
|
35 | 39 | public function __construct($identifier,$model,$modelInstance=NULL) { |
36 | 40 | parent::__construct($identifier, $model,$modelInstance); |
37 | 41 | $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
@@ -55,6 +59,9 @@ discard block |
||
55 | 59 | |
56 | 60 | |
57 | 61 | |
62 | + /** |
|
63 | + * @param string $op |
|
64 | + */ |
|
58 | 65 | protected function _generateBehavior($op,$params,JsUtils $js){ |
59 | 66 | if(isset($this->_urls[$op])){ |
60 | 67 | $params=\array_merge($params,["attr"=>"data-ajax"]); |
@@ -184,6 +191,9 @@ discard block |
||
184 | 191 | return $this; |
185 | 192 | } |
186 | 193 | |
194 | + /** |
|
195 | + * @param PositionInTable $part |
|
196 | + */ |
|
187 | 197 | private function addToolbarRow($part,$table,$captions){ |
188 | 198 | $hasPart=$table->hasPart($part); |
189 | 199 | if($hasPart){ |
@@ -221,9 +231,9 @@ discard block |
||
221 | 231 | |
222 | 232 | /** |
223 | 233 | * Paginates the DataTable element with a Semantic HtmlPaginationMenu component |
224 | - * @param number $page the active page number |
|
225 | - * @param number $items_per_page |
|
226 | - * @param number $pages_visibles |
|
234 | + * @param integer $page the active page number |
|
235 | + * @param integer $items_per_page |
|
236 | + * @param integer $pages_visibles |
|
227 | 237 | * @param number $total_rowcount |
228 | 238 | * @return DataTable |
229 | 239 | */ |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | */ |
23 | 23 | class DataTable extends Widget { |
24 | - use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait; |
|
24 | + use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait; |
|
25 | 25 | protected $_searchField; |
26 | 26 | protected $_urls; |
27 | 27 | protected $_pagination; |
@@ -32,33 +32,33 @@ discard block |
||
32 | 32 | protected $_targetSelector; |
33 | 33 | |
34 | 34 | |
35 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
36 | - parent::__construct($identifier, $model,$modelInstance); |
|
37 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
|
35 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
36 | + parent::__construct($identifier, $model, $modelInstance); |
|
37 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
|
38 | 38 | $this->_urls=[]; |
39 | 39 | } |
40 | 40 | |
41 | - public function run(JsUtils $js){ |
|
42 | - if($this->_hasCheckboxes && isset($js)){ |
|
41 | + public function run(JsUtils $js) { |
|
42 | + if ($this->_hasCheckboxes && isset($js)) { |
|
43 | 43 | $this->_runCheckboxes($js); |
44 | 44 | } |
45 | - if($this->_visibleHover){ |
|
46 | - $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
47 | - $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
45 | + if ($this->_visibleHover) { |
|
46 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
47 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
48 | 48 | } |
49 | - if(\is_array($this->_deleteBehavior)) |
|
50 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
51 | - if(\is_array($this->_editBehavior)) |
|
52 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
49 | + if (\is_array($this->_deleteBehavior)) |
|
50 | + $this->_generateBehavior("delete", $this->_deleteBehavior, $js); |
|
51 | + if (\is_array($this->_editBehavior)) |
|
52 | + $this->_generateBehavior("edit", $this->_editBehavior, $js); |
|
53 | 53 | return parent::run($js); |
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | 57 | |
58 | - protected function _generateBehavior($op,$params,JsUtils $js){ |
|
59 | - if(isset($this->_urls[$op])){ |
|
60 | - $params=\array_merge($params,["attr"=>"data-ajax"]); |
|
61 | - $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector(),$params); |
|
58 | + protected function _generateBehavior($op, $params, JsUtils $js) { |
|
59 | + if (isset($this->_urls[$op])) { |
|
60 | + $params=\array_merge($params, ["attr"=>"data-ajax"]); |
|
61 | + $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector(), $params); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -71,62 +71,62 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
75 | - if(!$this->_generated){ |
|
74 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
75 | + if (!$this->_generated) { |
|
76 | 76 | $this->_instanceViewer->setInstance($this->_model); |
77 | 77 | $captions=$this->_instanceViewer->getCaptions(); |
78 | 78 | |
79 | 79 | $table=$this->content["table"]; |
80 | 80 | |
81 | - if($this->_hasCheckboxes){ |
|
81 | + if ($this->_hasCheckboxes) { |
|
82 | 82 | $this->_generateMainCheckbox($captions); |
83 | 83 | } |
84 | 84 | |
85 | 85 | $table->setRowCount(0, \sizeof($captions)); |
86 | 86 | $table->setHeaderValues($captions); |
87 | - if(isset($this->_compileParts)) |
|
87 | + if (isset($this->_compileParts)) |
|
88 | 88 | $table->setCompileParts($this->_compileParts); |
89 | 89 | |
90 | - if(isset($this->_searchField) && isset($js)){ |
|
91 | - if(isset($this->_urls["refresh"])) |
|
92 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
90 | + if (isset($this->_searchField) && isset($js)) { |
|
91 | + if (isset($this->_urls["refresh"])) |
|
92 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $this->_generateContent($table); |
96 | 96 | |
97 | - if($this->_hasCheckboxes && $table->hasPart("thead")){ |
|
97 | + if ($this->_hasCheckboxes && $table->hasPart("thead")) { |
|
98 | 98 | $table->getHeader()->getCell(0, 0)->addClass("no-sort"); |
99 | 99 | } |
100 | 100 | |
101 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
101 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
102 | 102 | $this->_generatePagination($table); |
103 | 103 | } |
104 | - if(isset($this->_toolbar)){ |
|
104 | + if (isset($this->_toolbar)) { |
|
105 | 105 | $this->_setToolbarPosition($table, $captions); |
106 | 106 | } |
107 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
107 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
108 | 108 | $this->_compileForm(); |
109 | 109 | $this->_generated=true; |
110 | 110 | } |
111 | - return parent::compile($js,$view); |
|
111 | + return parent::compile($js, $view); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
115 | 115 | |
116 | - protected function _generateContent($table){ |
|
116 | + protected function _generateContent($table) { |
|
117 | 117 | $objects=$this->_modelInstance; |
118 | - if(isset($this->_pagination)){ |
|
118 | + if (isset($this->_pagination)) { |
|
119 | 119 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
120 | 120 | } |
121 | 121 | InstanceViewer::setIndex(0); |
122 | 122 | $table->fromDatabaseObjects($objects, function($instance) use($table){ |
123 | 123 | $this->_instanceViewer->setInstance($instance); |
124 | 124 | InstanceViewer::$index++; |
125 | - $values= $this->_instanceViewer->getValues(); |
|
126 | - if($this->_hasCheckboxes){ |
|
127 | - $ck=new HtmlCheckbox("ck-".$this->identifier,""); |
|
125 | + $values=$this->_instanceViewer->getValues(); |
|
126 | + if ($this->_hasCheckboxes) { |
|
127 | + $ck=new HtmlCheckbox("ck-".$this->identifier, ""); |
|
128 | 128 | $field=$ck->getField(); |
129 | - $field->setProperty("value",$this->_instanceViewer->getIdentifier()); |
|
129 | + $field->setProperty("value", $this->_instanceViewer->getIdentifier()); |
|
130 | 130 | $field->setProperty("name", "selection[]"); |
131 | 131 | \array_unshift($values, $ck); |
132 | 132 | } |
@@ -137,37 +137,37 @@ discard block |
||
137 | 137 | }); |
138 | 138 | } |
139 | 139 | |
140 | - private function _generatePagination($table){ |
|
140 | + private function _generatePagination($table) { |
|
141 | 141 | $footer=$table->getFooter(); |
142 | 142 | $footer->mergeCol(); |
143 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
143 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
144 | 144 | $menu->floatRight(); |
145 | 145 | $menu->setActiveItem($this->_pagination->getPage()-1); |
146 | 146 | $footer->setValues($menu); |
147 | - if(isset($this->_urls["refresh"])) |
|
148 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
147 | + if (isset($this->_urls["refresh"])) |
|
148 | + $menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
149 | 149 | } |
150 | 150 | |
151 | - protected function _getFieldName($index){ |
|
151 | + protected function _getFieldName($index) { |
|
152 | 152 | return parent::_getFieldName($index)."[]"; |
153 | 153 | } |
154 | 154 | |
155 | - protected function _getFieldCaption($index){ |
|
155 | + protected function _getFieldCaption($index) { |
|
156 | 156 | return null; |
157 | 157 | } |
158 | 158 | |
159 | - protected function _setToolbarPosition($table,$captions=NULL){ |
|
160 | - switch ($this->_toolbarPosition){ |
|
159 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
160 | + switch ($this->_toolbarPosition) { |
|
161 | 161 | case PositionInTable::BEFORETABLE: |
162 | 162 | case PositionInTable::AFTERTABLE: |
163 | - if(isset($this->_compileParts)===false){ |
|
163 | + if (isset($this->_compileParts)===false) { |
|
164 | 164 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
165 | 165 | } |
166 | 166 | break; |
167 | 167 | case PositionInTable::HEADER: |
168 | 168 | case PositionInTable::FOOTER: |
169 | 169 | case PositionInTable::BODY: |
170 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
170 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
171 | 171 | break; |
172 | 172 | } |
173 | 173 | } |
@@ -179,23 +179,23 @@ discard block |
||
179 | 179 | * @param callable $callback function called after the field compilation |
180 | 180 | * @return \Ajax\semantic\widgets\datatable\DataTable |
181 | 181 | */ |
182 | - public function afterCompile($index,$callback){ |
|
183 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
182 | + public function afterCompile($index, $callback) { |
|
183 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
184 | 184 | return $this; |
185 | 185 | } |
186 | 186 | |
187 | - private function addToolbarRow($part,$table,$captions){ |
|
187 | + private function addToolbarRow($part, $table, $captions) { |
|
188 | 188 | $hasPart=$table->hasPart($part); |
189 | - if($hasPart){ |
|
189 | + if ($hasPart) { |
|
190 | 190 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
191 | - }else{ |
|
191 | + } else { |
|
192 | 192 | $row=$table->getPart($part)->getRow(0); |
193 | 193 | } |
194 | 194 | $row->mergeCol(); |
195 | 195 | $row->setValues([$this->_toolbar]); |
196 | 196 | } |
197 | 197 | |
198 | - public function getHtmlComponent(){ |
|
198 | + public function getHtmlComponent() { |
|
199 | 199 | return $this->content["table"]; |
200 | 200 | } |
201 | 201 | |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | * @return \Ajax\semantic\widgets\datatable\DataTable |
210 | 210 | */ |
211 | 211 | public function setUrls($urls) { |
212 | - if(\is_array($urls)){ |
|
213 | - $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
|
214 | - $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
|
215 | - $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
|
216 | - }else{ |
|
217 | - $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
|
212 | + if (\is_array($urls)) { |
|
213 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
214 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
215 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
216 | + } else { |
|
217 | + $this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls]; |
|
218 | 218 | } |
219 | 219 | return $this; |
220 | 220 | } |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | * @param number $total_rowcount |
228 | 228 | * @return DataTable |
229 | 229 | */ |
230 | - public function paginate($page=1,$items_per_page=10,$pages_visibles=4,$total_rowcount=null){ |
|
231 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount); |
|
230 | + public function paginate($page=1, $items_per_page=10, $pages_visibles=4, $total_rowcount=null) { |
|
231 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
232 | 232 | return $this; |
233 | 233 | } |
234 | 234 | |
@@ -238,20 +238,20 @@ discard block |
||
238 | 238 | * @param array $compileParts |
239 | 239 | * @return DataTable |
240 | 240 | */ |
241 | - public function refresh($compileParts=["tbody"]){ |
|
241 | + public function refresh($compileParts=["tbody"]) { |
|
242 | 242 | $this->_compileParts=$compileParts; |
243 | 243 | return $this; |
244 | 244 | } |
245 | 245 | |
246 | 246 | |
247 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
247 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
248 | 248 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
249 | 249 | } |
250 | 250 | |
251 | - public function getSearchField(){ |
|
252 | - if(isset($this->_searchField)===false){ |
|
253 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
254 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
251 | + public function getSearchField() { |
|
252 | + if (isset($this->_searchField)===false) { |
|
253 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
254 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
255 | 255 | } |
256 | 256 | return $this->_searchField; |
257 | 257 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | return $this; |
268 | 268 | } |
269 | 269 | |
270 | - public function asForm(){ |
|
270 | + public function asForm() { |
|
271 | 271 | return $this->getForm(); |
272 | 272 | } |
273 | 273 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | protected function getTargetSelector() { |
277 | 277 | $result=$this->_targetSelector; |
278 | - if(!isset($result)) |
|
278 | + if (!isset($result)) |
|
279 | 279 | $result="#".$this->identifier; |
280 | 280 | return $result; |
281 | 281 | } |
@@ -14,44 +14,44 @@ discard block |
||
14 | 14 | */ |
15 | 15 | abstract class HtmlCollection extends HtmlDoubleElement { |
16 | 16 | |
17 | - public function __construct($identifier,$tagName="div"){ |
|
18 | - parent::__construct($identifier,$tagName); |
|
17 | + public function __construct($identifier, $tagName="div") { |
|
18 | + parent::__construct($identifier, $tagName); |
|
19 | 19 | $this->content=array(); |
20 | 20 | } |
21 | 21 | |
22 | - public function addItems($items){ |
|
23 | - if(JArray::isAssociative($items)){ |
|
24 | - foreach ($items as $k=>$v){ |
|
25 | - $this->addItem([$k,$v]); |
|
22 | + public function addItems($items) { |
|
23 | + if (JArray::isAssociative($items)) { |
|
24 | + foreach ($items as $k=>$v) { |
|
25 | + $this->addItem([$k, $v]); |
|
26 | 26 | } |
27 | - }else{ |
|
28 | - foreach ($items as $item){ |
|
27 | + } else { |
|
28 | + foreach ($items as $item) { |
|
29 | 29 | $this->addItem($item); |
30 | 30 | } |
31 | 31 | } |
32 | 32 | return $this; |
33 | 33 | } |
34 | 34 | |
35 | - public function setItems($items){ |
|
35 | + public function setItems($items) { |
|
36 | 36 | $this->content=$items; |
37 | 37 | return $this; |
38 | 38 | } |
39 | 39 | |
40 | - public function getItems(){ |
|
40 | + public function getItems() { |
|
41 | 41 | return $this->content; |
42 | 42 | } |
43 | 43 | |
44 | - protected function getItemToAdd($item){ |
|
44 | + protected function getItemToAdd($item) { |
|
45 | 45 | $itemO=$item; |
46 | - if($this->createCondition($item)===true){ |
|
46 | + if ($this->createCondition($item)===true) { |
|
47 | 47 | $itemO=$this->createItem($item); |
48 | 48 | } |
49 | 49 | return $itemO; |
50 | 50 | } |
51 | 51 | |
52 | - protected function setItemIdentifier($item,$classname,$index){ |
|
53 | - if($item instanceof BaseWidget){ |
|
54 | - if($item->getIdentifier()===""){ |
|
52 | + protected function setItemIdentifier($item, $classname, $index) { |
|
53 | + if ($item instanceof BaseWidget) { |
|
54 | + if ($item->getIdentifier()==="") { |
|
55 | 55 | $item->setIdentifier($classname."-".$this->identifier."-".$index); |
56 | 56 | } |
57 | 57 | } |
@@ -62,15 +62,15 @@ discard block |
||
62 | 62 | * @param HtmlDoubleElement|string|array $item |
63 | 63 | * @return \Ajax\common\html\HtmlDoubleElement |
64 | 64 | */ |
65 | - public function addItem($item){ |
|
65 | + public function addItem($item) { |
|
66 | 66 | $itemO=$this->getItemToAdd($item); |
67 | 67 | $this->addContent($itemO); |
68 | 68 | return $itemO; |
69 | 69 | } |
70 | 70 | |
71 | - public function insertItem($item,$position=0){ |
|
71 | + public function insertItem($item, $position=0) { |
|
72 | 72 | $itemO=$this->getItemToAdd($item); |
73 | - \array_splice( $this->content, $position, 0, array($itemO)); |
|
73 | + \array_splice($this->content, $position, 0, array($itemO)); |
|
74 | 74 | return $itemO; |
75 | 75 | } |
76 | 76 | |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | return $this; |
94 | 94 | } |
95 | 95 | |
96 | - public function removeItem($index){ |
|
96 | + public function removeItem($index) { |
|
97 | 97 | return array_splice($this->content, $index, 1); |
98 | 98 | } |
99 | 99 | |
100 | - public function count(){ |
|
100 | + public function count() { |
|
101 | 101 | return \sizeof($this->content); |
102 | 102 | } |
103 | 103 | |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | return $this->addItem($function($object)); |
109 | 109 | } |
110 | 110 | |
111 | - public function apply($callBack){ |
|
112 | - foreach ($this->content as $item){ |
|
111 | + public function apply($callBack) { |
|
112 | + foreach ($this->content as $item) { |
|
113 | 113 | $callBack($item); |
114 | 114 | } |
115 | 115 | return $this; |
@@ -129,23 +129,23 @@ discard block |
||
129 | 129 | */ |
130 | 130 | abstract protected function createItem($value); |
131 | 131 | |
132 | - protected function createCondition($value){ |
|
132 | + protected function createCondition($value) { |
|
133 | 133 | return \is_object($value)===false; |
134 | 134 | } |
135 | 135 | |
136 | - protected function contentAs($tagName){ |
|
137 | - foreach ($this->content as $item){ |
|
136 | + protected function contentAs($tagName) { |
|
137 | + foreach ($this->content as $item) { |
|
138 | 138 | $item->setTagName($tagName); |
139 | 139 | } |
140 | 140 | return $this; |
141 | 141 | } |
142 | 142 | |
143 | - public function setProperties($properties){ |
|
143 | + public function setProperties($properties) { |
|
144 | 144 | $i=0; |
145 | - foreach ($properties as $k=>$v){ |
|
145 | + foreach ($properties as $k=>$v) { |
|
146 | 146 | $c=$this->content[$i++]; |
147 | - if(isset($c)) |
|
148 | - $c->setProperty($k,$v); |
|
147 | + if (isset($c)) |
|
148 | + $c->setProperty($k, $v); |
|
149 | 149 | else |
150 | 150 | return $this; |
151 | 151 | } |
@@ -158,17 +158,17 @@ discard block |
||
158 | 158 | * @param array $values |
159 | 159 | * @return HtmlCollection |
160 | 160 | */ |
161 | - public function setPropertyValues($property,$values){ |
|
161 | + public function setPropertyValues($property, $values) { |
|
162 | 162 | $i=0; |
163 | - if(\is_array($values)===false){ |
|
164 | - $values=\array_fill(0, $this->count(),$values); |
|
163 | + if (\is_array($values)===false) { |
|
164 | + $values=\array_fill(0, $this->count(), $values); |
|
165 | 165 | } |
166 | - foreach ($values as $value){ |
|
166 | + foreach ($values as $value) { |
|
167 | 167 | $c=$this->content[$i++]; |
168 | - if(isset($c)){ |
|
169 | - $c->setProperty($property,$value); |
|
168 | + if (isset($c)) { |
|
169 | + $c->setProperty($property, $value); |
|
170 | 170 | } |
171 | - else{ |
|
171 | + else { |
|
172 | 172 | return $this; |
173 | 173 | } |
174 | 174 | } |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
179 | 179 | $index=0; |
180 | 180 | $classname=\strtolower(JReflection::shortClassName($this)); |
181 | - foreach ($this->content as $item){ |
|
182 | - $this->setItemIdentifier($item,$classname,$index++); |
|
181 | + foreach ($this->content as $item) { |
|
182 | + $this->setItemIdentifier($item, $classname, $index++); |
|
183 | 183 | } |
184 | - return parent::compile($js,$view); |
|
184 | + return parent::compile($js, $view); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | \ No newline at end of file |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | private $pages_visibles; |
10 | 10 | private $row_count; |
11 | 11 | |
12 | - public function __construct($items_per_page=10,$pages_visibles=4,$page=1,$row_count=null){ |
|
12 | + public function __construct($items_per_page=10, $pages_visibles=4, $page=1, $row_count=null) { |
|
13 | 13 | $this->items_per_page=$items_per_page; |
14 | 14 | $this->page=$page; |
15 | 15 | $this->pages_visibles=$pages_visibles; |
@@ -17,29 +17,29 @@ discard block |
||
17 | 17 | $this->row_count=$row_count; |
18 | 18 | } |
19 | 19 | |
20 | - public function getObjects($objects){ |
|
20 | + public function getObjects($objects) { |
|
21 | 21 | $auto=(!isset($this->row_count)); |
22 | - $offset = ($this->page - 1) * $this->items_per_page; |
|
22 | + $offset=($this->page-1)*$this->items_per_page; |
|
23 | 23 | $os=$objects; |
24 | - if(!\is_array($os)){ |
|
24 | + if (!\is_array($os)) { |
|
25 | 25 | $os=[]; |
26 | - foreach ($objects as $o){ |
|
26 | + foreach ($objects as $o) { |
|
27 | 27 | $os[]=$o; |
28 | 28 | } |
29 | 29 | } |
30 | - $this->page_count = 0; |
|
31 | - $row_count=($auto)?\sizeof($os):$this->row_count; |
|
32 | - if (0 === $row_count) { |
|
30 | + $this->page_count=0; |
|
31 | + $row_count=($auto) ? \sizeof($os) : $this->row_count; |
|
32 | + if (0===$row_count) { |
|
33 | 33 | $this->visible=false; |
34 | 34 | } else { |
35 | 35 | $this->visible=true; |
36 | - $this->page_count = (int)ceil($row_count / $this->items_per_page); |
|
37 | - if($this->page > $this->page_count+1) { |
|
38 | - $this->page = 1; |
|
36 | + $this->page_count=(int)ceil($row_count/$this->items_per_page); |
|
37 | + if ($this->page>$this->page_count+1) { |
|
38 | + $this->page=1; |
|
39 | 39 | } |
40 | 40 | } |
41 | - if($auto) |
|
42 | - return array_slice($os, $offset,$this->items_per_page); |
|
41 | + if ($auto) |
|
42 | + return array_slice($os, $offset, $this->items_per_page); |
|
43 | 43 | return $os; |
44 | 44 | } |
45 | 45 | |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | return $this->page_count; |
75 | 75 | } |
76 | 76 | |
77 | - public function getPagesNumbers(){ |
|
78 | - $middle= (int)ceil(($this->pages_visibles-1)/ 2); |
|
77 | + public function getPagesNumbers() { |
|
78 | + $middle=(int)ceil(($this->pages_visibles-1)/2); |
|
79 | 79 | $first=$this->page-$middle; |
80 | - if($first<1){ |
|
80 | + if ($first<1) { |
|
81 | 81 | $first=1; |
82 | 82 | } |
83 | 83 | $last=$first+$this->pages_visibles-1; |
84 | - if($last>$this->page_count){ |
|
84 | + if ($last>$this->page_count) { |
|
85 | 85 | $last=$this->page_count; |
86 | 86 | } |
87 | 87 | return \range($first, $last); |
@@ -38,8 +38,9 @@ |
||
38 | 38 | $this->page = 1; |
39 | 39 | } |
40 | 40 | } |
41 | - if($auto) |
|
42 | - return array_slice($os, $offset,$this->items_per_page); |
|
41 | + if($auto) { |
|
42 | + return array_slice($os, $offset,$this->items_per_page); |
|
43 | + } |
|
43 | 44 | return $os; |
44 | 45 | } |
45 | 46 |
@@ -15,117 +15,117 @@ discard block |
||
15 | 15 | protected $_paramParts=array(); |
16 | 16 | |
17 | 17 | public function __construct($identifier, $header="", $content="", $actions=null) { |
18 | - parent::__construct($identifier, "div","ui modal"); |
|
19 | - if(isset($header)){ |
|
18 | + parent::__construct($identifier, "div", "ui modal"); |
|
19 | + if (isset($header)) { |
|
20 | 20 | $this->setHeader($header); |
21 | 21 | } |
22 | - if(isset($content)){ |
|
22 | + if (isset($content)) { |
|
23 | 23 | $this->setContent($content); |
24 | 24 | } |
25 | - if(isset($actions)){ |
|
25 | + if (isset($actions)) { |
|
26 | 26 | $this->setActions($actions); |
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function setHeader($value) { |
31 | - $this->content["header"]=new HtmlSemDoubleElement("header-" . $this->identifier, "a", "header", $value); |
|
31 | + $this->content["header"]=new HtmlSemDoubleElement("header-".$this->identifier, "a", "header", $value); |
|
32 | 32 | return $this; |
33 | 33 | } |
34 | 34 | |
35 | 35 | public function setContent($value) { |
36 | - $this->content["content"]=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", $value); |
|
36 | + $this->content["content"]=new HtmlSemDoubleElement("content-".$this->identifier, "div", "content", $value); |
|
37 | 37 | return $this; |
38 | 38 | } |
39 | 39 | |
40 | 40 | public function setActions($actions) { |
41 | - $this->content["actions"]=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "actions"); |
|
42 | - if(\is_array($actions)){ |
|
43 | - foreach ($actions as $action){ |
|
41 | + $this->content["actions"]=new HtmlSemDoubleElement("content-".$this->identifier, "div", "actions"); |
|
42 | + if (\is_array($actions)) { |
|
43 | + foreach ($actions as $action) { |
|
44 | 44 | $this->addAction($action); |
45 | 45 | } |
46 | 46 | } |
47 | - else{ |
|
47 | + else { |
|
48 | 48 | $this->addAction($actions); |
49 | 49 | } |
50 | 50 | return $this; |
51 | 51 | } |
52 | 52 | |
53 | - public function addAction($action){ |
|
54 | - if(!$action instanceof BaseHtml){ |
|
53 | + public function addAction($action) { |
|
54 | + if (!$action instanceof BaseHtml) { |
|
55 | 55 | $class=""; |
56 | - if(\array_search($action, ["Okay","Yes"])!==false){ |
|
56 | + if (\array_search($action, ["Okay", "Yes"])!==false) { |
|
57 | 57 | $class="approve"; |
58 | 58 | } |
59 | - if(\array_search($action, ["Close","Cancel","No"])!==false){ |
|
59 | + if (\array_search($action, ["Close", "Cancel", "No"])!==false) { |
|
60 | 60 | $class="cancel"; |
61 | 61 | } |
62 | - $action=new HtmlButton("action-".$this->identifier,$action); |
|
63 | - if($class!=="") |
|
62 | + $action=new HtmlButton("action-".$this->identifier, $action); |
|
63 | + if ($class!=="") |
|
64 | 64 | $action->addToProperty("class", $class); |
65 | 65 | } |
66 | 66 | return $this->addElementInPart($action, "actions"); |
67 | 67 | } |
68 | 68 | |
69 | - public function addContent($content,$before=false){ |
|
70 | - $this->content["content"]->addContent($content,$before); |
|
69 | + public function addContent($content, $before=false) { |
|
70 | + $this->content["content"]->addContent($content, $before); |
|
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | |
74 | - public function addImageContent($image,$description=NULL){ |
|
74 | + public function addImageContent($image, $description=NULL) { |
|
75 | 75 | $content=$this->content["content"]; |
76 | - if(isset($description)){ |
|
77 | - $description=new HtmlSemDoubleElement("description-".$this->identifier,"div","description",$description); |
|
78 | - $content->addContent($description,true); |
|
76 | + if (isset($description)) { |
|
77 | + $description=new HtmlSemDoubleElement("description-".$this->identifier, "div", "description", $description); |
|
78 | + $content->addContent($description, true); |
|
79 | 79 | } |
80 | - if($image!==""){ |
|
81 | - $img=new HtmlImage("image-".$this->identifier,$image,"","medium"); |
|
82 | - $content->addContent($img,true); |
|
83 | - $content->addToProperty("class","image"); |
|
80 | + if ($image!=="") { |
|
81 | + $img=new HtmlImage("image-".$this->identifier, $image, "", "medium"); |
|
82 | + $content->addContent($img, true); |
|
83 | + $content->addToProperty("class", "image"); |
|
84 | 84 | } |
85 | 85 | return $this; |
86 | 86 | } |
87 | 87 | |
88 | - public function addIconContent($icon,$description=NULL){ |
|
88 | + public function addIconContent($icon, $description=NULL) { |
|
89 | 89 | $content=$this->content["content"]; |
90 | - if(isset($description)){ |
|
91 | - $description=new HtmlSemDoubleElement("description-".$this->identifier,"div","description",$description); |
|
92 | - $content->addContent($description,true); |
|
90 | + if (isset($description)) { |
|
91 | + $description=new HtmlSemDoubleElement("description-".$this->identifier, "div", "description", $description); |
|
92 | + $content->addContent($description, true); |
|
93 | 93 | } |
94 | - if($icon!==""){ |
|
95 | - $img=new HtmlIcon("image-".$this->identifier,$icon); |
|
96 | - $content->addContent($img,true); |
|
97 | - $content->addToProperty("class","image"); |
|
94 | + if ($icon!=="") { |
|
95 | + $img=new HtmlIcon("image-".$this->identifier, $icon); |
|
96 | + $content->addContent($img, true); |
|
97 | + $content->addToProperty("class", "image"); |
|
98 | 98 | } |
99 | 99 | return $this; |
100 | 100 | } |
101 | 101 | |
102 | - private function addContentInPart($content,$uiClass,$part) { |
|
103 | - return $this->addElementInPart(new HtmlSemDoubleElement($part."-" . $this->identifier, "div", $uiClass, $content), $part); |
|
102 | + private function addContentInPart($content, $uiClass, $part) { |
|
103 | + return $this->addElementInPart(new HtmlSemDoubleElement($part."-".$this->identifier, "div", $uiClass, $content), $part); |
|
104 | 104 | } |
105 | 105 | |
106 | - private function addElementInPart($element,$part) { |
|
106 | + private function addElementInPart($element, $part) { |
|
107 | 107 | $this->content[$part]->addContent($element); |
108 | 108 | return $element; |
109 | 109 | } |
110 | 110 | |
111 | - public function showDimmer($value){ |
|
112 | - $value=$value?"show":"hide"; |
|
111 | + public function showDimmer($value) { |
|
112 | + $value=$value ? "show" : "hide"; |
|
113 | 113 | $this->_paramParts[]=["'".$value." dimmer'"]; |
114 | 114 | return $this; |
115 | 115 | } |
116 | 116 | |
117 | - public function setInverted(){ |
|
117 | + public function setInverted() { |
|
118 | 118 | $this->_params["inverted"]=true; |
119 | 119 | return $this; |
120 | 120 | } |
121 | 121 | |
122 | - public function setBasic(){ |
|
122 | + public function setBasic() { |
|
123 | 123 | return $this->addToProperty("class", "basic"); |
124 | 124 | } |
125 | 125 | |
126 | 126 | |
127 | - public function setTransition($value){ |
|
128 | - $this->_paramParts[]=["'setting'","'transition'","'".$value."'"]; |
|
127 | + public function setTransition($value) { |
|
128 | + $this->_paramParts[]=["'setting'", "'transition'", "'".$value."'"]; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | * @param string $viewName |
136 | 136 | * @param $params The parameters to pass to the view |
137 | 137 | */ |
138 | - public function renderView(JsUtils $js,$initialController,$viewName, $params=array()) { |
|
139 | - return $this->setContent($js->renderContent($initialController, $viewName,$params)); |
|
138 | + public function renderView(JsUtils $js, $initialController, $viewName, $params=array()) { |
|
139 | + return $this->setContent($js->renderContent($initialController, $viewName, $params)); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | * @param string $actionName the action name |
148 | 148 | * @param array $params |
149 | 149 | */ |
150 | - public function forward(JsUtils $js,$initialControllerInstance,$controllerName,$actionName,$params=NULL){ |
|
151 | - return $this->setContent($js->forward($initialControllerInstance, $controllerName, $actionName,$params)); |
|
150 | + public function forward(JsUtils $js, $initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
151 | + return $this->setContent($js->forward($initialControllerInstance, $controllerName, $actionName, $params)); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile() |
159 | 159 | */ |
160 | 160 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
161 | - $this->content=JArray::sortAssociative($this->content, ["header","content","actions" ]); |
|
161 | + $this->content=JArray::sortAssociative($this->content, ["header", "content", "actions"]); |
|
162 | 162 | return parent::compile($js, $view); |
163 | 163 | } |
164 | 164 | /* |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | * @see BaseHtml::run() |
167 | 167 | */ |
168 | 168 | public function run(JsUtils $js) { |
169 | - if(isset($this->_bsComponent)===false) |
|
170 | - $this->_bsComponent=$js->semantic()->modal("#".$this->identifier,$this->_params,$this->_paramParts); |
|
169 | + if (isset($this->_bsComponent)===false) |
|
170 | + $this->_bsComponent=$js->semantic()->modal("#".$this->identifier, $this->_params, $this->_paramParts); |
|
171 | 171 | $this->addEventsOnRun($js); |
172 | 172 | return $this->_bsComponent; |
173 | 173 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | use BaseTrait; |
23 | 23 | protected $_popup=NULL; |
24 | 24 | protected $_dimmer=NULL; |
25 | - protected $_params=array (); |
|
25 | + protected $_params=array(); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | public function __construct($identifier, $tagName="p", $baseClass="ui", $content=NULL) { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | public function addDimmer($params=array(), $content=NULL) { |
55 | - $dimmer=new HtmlDimmer("dimmer-" . $this->identifier, $content); |
|
55 | + $dimmer=new HtmlDimmer("dimmer-".$this->identifier, $content); |
|
56 | 56 | $dimmer->setParams($params); |
57 | 57 | $dimmer->setContainer($this); |
58 | 58 | $this->addContent($dimmer); |
@@ -61,20 +61,20 @@ discard block |
||
61 | 61 | |
62 | 62 | public function addLabel($label, $before=false, $icon=NULL) { |
63 | 63 | $labelO=$label; |
64 | - if (\is_object($label) === false) { |
|
65 | - $labelO=new HtmlLabel("label-" . $this->identifier, $label); |
|
64 | + if (\is_object($label)===false) { |
|
65 | + $labelO=new HtmlLabel("label-".$this->identifier, $label); |
|
66 | 66 | if (isset($icon)) |
67 | 67 | $labelO->addIcon($icon); |
68 | 68 | } else { |
69 | - $labelO->addToPropertyCtrl("class", "label", array ("label" )); |
|
69 | + $labelO->addToPropertyCtrl("class", "label", array("label")); |
|
70 | 70 | } |
71 | 71 | $this->addContent($labelO, $before); |
72 | 72 | return $labelO; |
73 | 73 | } |
74 | 74 | |
75 | - public function attachLabel($label,$side=Side::TOP,$direction=Direction::NONE,$icon=NULL){ |
|
76 | - $label=$this->addLabel($label,true,$icon); |
|
77 | - $label->setAttached($side,$direction); |
|
75 | + public function attachLabel($label, $side=Side::TOP, $direction=Direction::NONE, $icon=NULL) { |
|
76 | + $label=$this->addLabel($label, true, $icon); |
|
77 | + $label->setAttached($side, $direction); |
|
78 | 78 | return $this; |
79 | 79 | } |
80 | 80 | |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | |
91 | 91 | public function jsShowDimmer($show=true) { |
92 | 92 | $status="hide"; |
93 | - if ($show === true) |
|
93 | + if ($show===true) |
|
94 | 94 | $status="show"; |
95 | - return '$("#.' . $this->identifier . ').dimmer("' . $status . '");'; |
|
95 | + return '$("#.'.$this->identifier.').dimmer("'.$status.'");'; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | public function run(JsUtils $js) { |
105 | - $this->_bsComponent=$js->semantic()->generic("#" . $this->identifier); |
|
105 | + $this->_bsComponent=$js->semantic()->generic("#".$this->identifier); |
|
106 | 106 | parent::run($js); |
107 | 107 | $this->addEventsOnRun($js); |
108 | 108 | if (isset($this->_popup)) { |