@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | * @param boolean $autoActive sets the last element's class to <b>active</b> if true |
43 | 43 | * @param function $hrefFunction the function who generates the href elements. default : function($e){return $e->getContent()} |
44 | 44 | */ |
45 | - public function __construct($identifier,$elements=array(),$autoActive=true,$startIndex=0,$hrefFunction=NULL){ |
|
46 | - parent::__construct($identifier,"ol"); |
|
45 | + public function __construct($identifier, $elements=array(), $autoActive=true, $startIndex=0, $hrefFunction=NULL) { |
|
46 | + parent::__construct($identifier, "ol"); |
|
47 | 47 | $this->startIndex=$startIndex; |
48 | 48 | $this->setProperty("class", "breadcrumb"); |
49 | 49 | $this->content=array(); |
50 | 50 | $this->autoActive=$autoActive; |
51 | 51 | $this->absolutePaths; |
52 | - $this->_hrefFunction=function (HtmlDoubleElement $e){return $e->getContent();}; |
|
53 | - if(isset($hrefFunction)){ |
|
52 | + $this->_hrefFunction=function(HtmlDoubleElement $e) {return $e->getContent(); }; |
|
53 | + if (isset($hrefFunction)) { |
|
54 | 54 | $this->_hrefFunction=$hrefFunction; |
55 | 55 | } |
56 | 56 | $this->addElements($elements); |
@@ -61,43 +61,43 @@ discard block |
||
61 | 61 | * @param string $href |
62 | 62 | * @return \Ajax\bootstrap\html\HtmlLink |
63 | 63 | */ |
64 | - public function addElement($element,$href="",$glyph=NULL){ |
|
64 | + public function addElement($element, $href="", $glyph=NULL) { |
|
65 | 65 | $size=sizeof($this->content); |
66 | - if(\is_array($element)){ |
|
66 | + if (\is_array($element)) { |
|
67 | 67 | $elm=new HtmlLink("lnk-".$this->identifier."-".$size); |
68 | 68 | $elm->fromArray($element); |
69 | - }else if($element instanceof HtmlLink){ |
|
69 | + } else if ($element instanceof HtmlLink) { |
|
70 | 70 | $elm=$element; |
71 | - }else{ |
|
72 | - $elm=new HtmlLink("lnk-".$this->identifier."-".$size,$href,$element); |
|
73 | - if(isset($glyph)){ |
|
71 | + } else { |
|
72 | + $elm=new HtmlLink("lnk-".$this->identifier."-".$size, $href, $element); |
|
73 | + if (isset($glyph)) { |
|
74 | 74 | $elm->wrapContentWithGlyph($glyph); |
75 | 75 | } |
76 | 76 | } |
77 | - $elm->wrap("<li>","</li>"); |
|
77 | + $elm->wrap("<li>", "</li>"); |
|
78 | 78 | $this->content[]=$elm; |
79 | 79 | $elm->setProperty($this->attr, $this->getHref($size)); |
80 | 80 | return $elm; |
81 | 81 | } |
82 | 82 | |
83 | - public function setActive($index=null){ |
|
84 | - if(!isset($index)){ |
|
83 | + public function setActive($index=null) { |
|
84 | + if (!isset($index)) { |
|
85 | 85 | $index=sizeof($this->content)-1; |
86 | 86 | } |
87 | - $li=new HtmlBsDoubleElement("","li"); |
|
87 | + $li=new HtmlBsDoubleElement("", "li"); |
|
88 | 88 | $li->setClass("active"); |
89 | 89 | $li->setContent($this->content[$index]->getContent()); |
90 | 90 | $this->content[$index]=$li; |
91 | 91 | } |
92 | 92 | |
93 | - public function addElements($elements){ |
|
94 | - foreach ( $elements as $element ) { |
|
93 | + public function addElements($elements) { |
|
94 | + foreach ($elements as $element) { |
|
95 | 95 | $this->addElement($element); |
96 | 96 | } |
97 | 97 | return $this; |
98 | 98 | } |
99 | 99 | |
100 | - public function fromArray($array){ |
|
100 | + public function fromArray($array) { |
|
101 | 101 | $array=parent::fromArray($array); |
102 | 102 | $this->addElements($array); |
103 | 103 | return $array; |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | * @param string $separator |
110 | 110 | * @return string |
111 | 111 | */ |
112 | - public function getHref($index=null,$separator="/"){ |
|
113 | - if(!isset($index)){ |
|
112 | + public function getHref($index=null, $separator="/") { |
|
113 | + if (!isset($index)) { |
|
114 | 114 | $index=sizeof($this->content); |
115 | 115 | } |
116 | - if($this->absolutePaths===true){ |
|
116 | + if ($this->absolutePaths===true) { |
|
117 | 117 | return $this->_hrefFunction($this->content[$index]); |
118 | - }else{ |
|
119 | - return $this->root.implode($separator, array_slice(array_map(function($e){return $this->_hrefFunction($e);}, $this->content),$this->startIndex,$index+1)); |
|
118 | + } else { |
|
119 | + return $this->root.implode($separator, array_slice(array_map(function($e) {return $this->_hrefFunction($e); }, $this->content), $this->startIndex, $index+1)); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @see \Ajax\bootstrap\html\BaseHtml::compile() |
126 | 126 | */ |
127 | 127 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
128 | - if($this->autoActive){ |
|
128 | + if ($this->autoActive) { |
|
129 | 129 | $this->setActive(); |
130 | 130 | } |
131 | 131 | return parent::compile($js, $view); |
@@ -143,19 +143,19 @@ discard block |
||
143 | 143 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
144 | 144 | */ |
145 | 145 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
146 | - foreach ($this->content as $element){ |
|
147 | - $element->on($event,$jsCode,$stopPropagation,$preventDefault); |
|
146 | + foreach ($this->content as $element) { |
|
147 | + $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
|
148 | 148 | } |
149 | 149 | return $this; |
150 | 150 | } |
151 | 151 | |
152 | 152 | public function setAutoActive($autoActive) { |
153 | - $this->autoActive = $autoActive; |
|
153 | + $this->autoActive=$autoActive; |
|
154 | 154 | return $this; |
155 | 155 | } |
156 | 156 | |
157 | 157 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
158 | - foreach ($this->content as $element){ |
|
158 | + foreach ($this->content as $element) { |
|
159 | 159 | $element->_ajaxOn($operation, $event, $url, $responseElement, $parameters); |
160 | 160 | } |
161 | 161 | return $this; |
@@ -167,18 +167,18 @@ discard block |
||
167 | 167 | * @param string $targetSelector the target of the get |
168 | 168 | * @return HtmlBreadcrumbs |
169 | 169 | */ |
170 | - public function autoGetOnClick($targetSelector){ |
|
171 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
170 | + public function autoGetOnClick($targetSelector) { |
|
171 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
172 | 172 | } |
173 | 173 | |
174 | - public function contentAsString(){ |
|
175 | - if($this->autoActive){ |
|
174 | + public function contentAsString() { |
|
175 | + if ($this->autoActive) { |
|
176 | 176 | $this->setActive(); |
177 | 177 | } |
178 | 178 | return parent::contentAsString(); |
179 | 179 | } |
180 | 180 | |
181 | - public function getElement($index){ |
|
181 | + public function getElement($index) { |
|
182 | 182 | return $this->content[$index]; |
183 | 183 | } |
184 | 184 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param mixed $glyph |
188 | 188 | * @param int $index |
189 | 189 | */ |
190 | - public function addGlyph($glyph,$index=0){ |
|
190 | + public function addGlyph($glyph, $index=0) { |
|
191 | 191 | $elm=$this->getElement($index); |
192 | 192 | return $elm->wrapContentWithGlyph($glyph); |
193 | 193 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param Dispatcher $dispatcher the request dispatcher |
199 | 199 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
200 | 200 | */ |
201 | - public function fromDispatcher(JsUtils $js,$dispatcher,$startIndex=0){ |
|
201 | + public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0) { |
|
202 | 202 | $this->startIndex=$startIndex; |
203 | 203 | return $this->addElements($js->fromDispatcher($dispatcher)); |
204 | 204 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
211 | 211 | */ |
212 | 212 | public function setHrefFunction($_hrefFunction) { |
213 | - $this->_hrefFunction = $_hrefFunction; |
|
213 | + $this->_hrefFunction=$_hrefFunction; |
|
214 | 214 | return $this; |
215 | 215 | } |
216 | 216 |
@@ -50,7 +50,7 @@ |
||
50 | 50 | * @return $this |
51 | 51 | */ |
52 | 52 | public function setSource($source) { |
53 | - $source=str_ireplace(array ( |
|
53 | + $source=str_ireplace(array( |
|
54 | 54 | "\"", |
55 | 55 | "'" |
56 | 56 | ), "%quote%", $source); |
@@ -16,11 +16,11 @@ |
||
16 | 16 | return $this; |
17 | 17 | } |
18 | 18 | |
19 | - public function showDimmer(){ |
|
19 | + public function showDimmer() { |
|
20 | 20 | return $this->setBehavior("hide dimmer"); |
21 | 21 | } |
22 | 22 | |
23 | - public function setInverted(){ |
|
23 | + public function setInverted() { |
|
24 | 24 | $this->params["inverted"]=true; |
25 | 25 | } |
26 | 26 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | */ |
26 | 26 | class DataTable extends Widget { |
27 | - use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait,BaseTrait; |
|
27 | + use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait, BaseTrait; |
|
28 | 28 | protected $_searchField; |
29 | 29 | protected $_urls; |
30 | 30 | protected $_pagination; |
@@ -42,35 +42,35 @@ discard block |
||
42 | 42 | protected $_colWidths; |
43 | 43 | |
44 | 44 | |
45 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
46 | - parent::__construct($identifier, $model,$modelInstance); |
|
47 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
|
45 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
46 | + parent::__construct($identifier, $model, $modelInstance); |
|
47 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
|
48 | 48 | $this->_urls=[]; |
49 | - $this->_emptyMessage=new HtmlMessage("","nothing to display"); |
|
49 | + $this->_emptyMessage=new HtmlMessage("", "nothing to display"); |
|
50 | 50 | $this->_emptyMessage->setIcon("info circle"); |
51 | 51 | } |
52 | 52 | |
53 | - public function run(JsUtils $js){ |
|
54 | - if($this->_hasCheckboxes && isset($js)){ |
|
53 | + public function run(JsUtils $js) { |
|
54 | + if ($this->_hasCheckboxes && isset($js)) { |
|
55 | 55 | $this->_runCheckboxes($js); |
56 | 56 | } |
57 | - if($this->_visibleHover){ |
|
58 | - $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
59 | - $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
57 | + if ($this->_visibleHover) { |
|
58 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
59 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
60 | 60 | } |
61 | - if(\is_array($this->_deleteBehavior)) |
|
62 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
63 | - if(\is_array($this->_editBehavior)) |
|
64 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
61 | + if (\is_array($this->_deleteBehavior)) |
|
62 | + $this->_generateBehavior("delete", $this->_deleteBehavior, $js); |
|
63 | + if (\is_array($this->_editBehavior)) |
|
64 | + $this->_generateBehavior("edit", $this->_editBehavior, $js); |
|
65 | 65 | return parent::run($js); |
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | - protected function _generateBehavior($op,$params,JsUtils $js){ |
|
71 | - if(isset($this->_urls[$op])){ |
|
72 | - $params=\array_merge($params,["attr"=>"data-ajax"]); |
|
73 | - $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector(),$params); |
|
70 | + protected function _generateBehavior($op, $params, JsUtils $js) { |
|
71 | + if (isset($this->_urls[$op])) { |
|
72 | + $params=\array_merge($params, ["attr"=>"data-ajax"]); |
|
73 | + $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector(), $params); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -83,156 +83,156 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | |
86 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
87 | - if(!$this->_generated){ |
|
86 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
87 | + if (!$this->_generated) { |
|
88 | 88 | $this->_instanceViewer->setInstance($this->_model); |
89 | 89 | $captions=$this->_instanceViewer->getCaptions(); |
90 | 90 | $table=$this->content["table"]; |
91 | - if($this->_hasCheckboxes){ |
|
91 | + if ($this->_hasCheckboxes) { |
|
92 | 92 | $this->_generateMainCheckbox($captions); |
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 | 100 | $this->_generateContent($table); |
101 | 101 | |
102 | - $this->compileExtraElements($table, $captions,$js); |
|
102 | + $this->compileExtraElements($table, $captions, $js); |
|
103 | 103 | |
104 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
104 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
105 | 105 | $this->_compileForm(); |
106 | 106 | $this->_applyStyleAttributes($table); |
107 | 107 | $this->_generated=true; |
108 | 108 | } |
109 | - return parent::compile($js,$view); |
|
109 | + return parent::compile($js, $view); |
|
110 | 110 | } |
111 | 111 | |
112 | - protected function compileExtraElements($table,$captions,JsUtils $js=NULL){ |
|
113 | - if(isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])){ |
|
114 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
112 | + protected function compileExtraElements($table, $captions, JsUtils $js=NULL) { |
|
113 | + if (isset($this->_searchField) && isset($js) && isset($this->_urls["refresh"])) { |
|
114 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
115 | 115 | } |
116 | - if($this->_hasCheckboxes && $table->hasPart("thead")){ |
|
116 | + if ($this->_hasCheckboxes && $table->hasPart("thead")) { |
|
117 | 117 | $table->getHeader()->getCell(0, 0)->addClass("no-sort"); |
118 | 118 | } |
119 | 119 | |
120 | - if(isset($this->_toolbar)){ |
|
120 | + if (isset($this->_toolbar)) { |
|
121 | 121 | $this->_setToolbarPosition($table, $captions); |
122 | 122 | } |
123 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
124 | - $this->_generatePagination($table,$js); |
|
123 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
124 | + $this->_generatePagination($table, $js); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | - protected function _applyStyleAttributes($table){ |
|
129 | - if(isset($this->_hiddenColumns)) |
|
128 | + protected function _applyStyleAttributes($table) { |
|
129 | + if (isset($this->_hiddenColumns)) |
|
130 | 130 | $this->_hideColumns(); |
131 | - if(isset($this->_colWidths)){ |
|
132 | - foreach ($this->_colWidths as $colIndex=>$width){ |
|
133 | - $table->setColWidth($colIndex,$width); |
|
131 | + if (isset($this->_colWidths)) { |
|
132 | + foreach ($this->_colWidths as $colIndex=>$width) { |
|
133 | + $table->setColWidth($colIndex, $width); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | - protected function _hideColumns(){ |
|
139 | - foreach ($this->_hiddenColumns as $colIndex){ |
|
138 | + protected function _hideColumns() { |
|
139 | + foreach ($this->_hiddenColumns as $colIndex) { |
|
140 | 140 | $this->_self->hideColumn($colIndex); |
141 | 141 | } |
142 | 142 | return $this; |
143 | 143 | } |
144 | 144 | |
145 | - protected function _generateHeader(HtmlTable $table,$captions){ |
|
145 | + protected function _generateHeader(HtmlTable $table, $captions) { |
|
146 | 146 | $table->setHeaderValues($captions); |
147 | - if(isset($this->_sortable)){ |
|
147 | + if (isset($this->_sortable)) { |
|
148 | 148 | $table->setSortable($this->_sortable); |
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | 152 | |
153 | 153 | |
154 | - protected function _generateContent($table){ |
|
154 | + protected function _generateContent($table) { |
|
155 | 155 | $objects=$this->_modelInstance; |
156 | - if(isset($this->_pagination)){ |
|
156 | + if (isset($this->_pagination)) { |
|
157 | 157 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
158 | 158 | } |
159 | 159 | InstanceViewer::setIndex(0); |
160 | 160 | $table->fromDatabaseObjects($objects, function($instance) use($table){ |
161 | 161 | return $this->_generateRow($instance, $table); |
162 | 162 | }); |
163 | - if($table->getRowCount()==0){ |
|
163 | + if ($table->getRowCount()==0) { |
|
164 | 164 | $result=$table->addRow(); |
165 | 165 | $result->mergeRow(); |
166 | 166 | $result->setValues([$this->_emptyMessage]); |
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | - protected function _generateRow($instance,&$table,$checkedClass=null){ |
|
170 | + protected function _generateRow($instance, &$table, $checkedClass=null) { |
|
171 | 171 | $this->_instanceViewer->setInstance($instance); |
172 | 172 | InstanceViewer::$index++; |
173 | - $values= $this->_instanceViewer->getValues(); |
|
173 | + $values=$this->_instanceViewer->getValues(); |
|
174 | 174 | $id=$this->_instanceViewer->getIdentifier(); |
175 | - if($this->_hasCheckboxes){ |
|
176 | - $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,""); |
|
175 | + if ($this->_hasCheckboxes) { |
|
176 | + $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, ""); |
|
177 | 177 | $ck->setOnChange("event.stopPropagation();"); |
178 | 178 | $field=$ck->getField(); |
179 | - $field->setProperty("value",$id); |
|
179 | + $field->setProperty("value", $id); |
|
180 | 180 | $field->setProperty("name", "selection[]"); |
181 | - if(isset($checkedClass)) |
|
181 | + if (isset($checkedClass)) |
|
182 | 182 | $field->setClass($checkedClass); |
183 | 183 | \array_unshift($values, $ck); |
184 | 184 | } |
185 | 185 | $result=$table->newRow(); |
186 | 186 | $result->setIdentifier($this->identifier."-tr-".$id); |
187 | - $result->setProperty("data-ajax",$id); |
|
187 | + $result->setProperty("data-ajax", $id); |
|
188 | 188 | $result->setValues($values); |
189 | - $result->addToProperty("class",$this->_rowClass); |
|
189 | + $result->addToProperty("class", $this->_rowClass); |
|
190 | 190 | return $result; |
191 | 191 | } |
192 | 192 | |
193 | - protected function _generatePagination($table,$js=NULL){ |
|
194 | - if(isset($this->_toolbar)){ |
|
195 | - if($this->_toolbarPosition==PositionInTable::FOOTER) |
|
193 | + protected function _generatePagination($table, $js=NULL) { |
|
194 | + if (isset($this->_toolbar)) { |
|
195 | + if ($this->_toolbarPosition==PositionInTable::FOOTER) |
|
196 | 196 | $this->_toolbar->setFloated("left"); |
197 | 197 | } |
198 | 198 | $footer=$table->getFooter(); |
199 | 199 | $footer->mergeCol(); |
200 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
200 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
201 | 201 | $menu->floatRight(); |
202 | 202 | $menu->setActiveItem($this->_pagination->getPage()-1); |
203 | 203 | $footer->addValues($menu); |
204 | - $this->_associatePaginationBehavior($menu,$js); |
|
204 | + $this->_associatePaginationBehavior($menu, $js); |
|
205 | 205 | } |
206 | 206 | |
207 | - protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){ |
|
208 | - if(isset($this->_urls["refresh"])){ |
|
209 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
207 | + protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) { |
|
208 | + if (isset($this->_urls["refresh"])) { |
|
209 | + $menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
213 | - protected function _getFieldName($index){ |
|
213 | + protected function _getFieldName($index) { |
|
214 | 214 | $fieldName=parent::_getFieldName($index); |
215 | - if(\is_object($fieldName)) |
|
215 | + if (\is_object($fieldName)) |
|
216 | 216 | $fieldName="field-".$index; |
217 | 217 | return $fieldName."[]"; |
218 | 218 | } |
219 | 219 | |
220 | - protected function _getFieldCaption($index){ |
|
220 | + protected function _getFieldCaption($index) { |
|
221 | 221 | return null; |
222 | 222 | } |
223 | 223 | |
224 | - protected function _setToolbarPosition($table,$captions=NULL){ |
|
225 | - switch ($this->_toolbarPosition){ |
|
224 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
225 | + switch ($this->_toolbarPosition) { |
|
226 | 226 | case PositionInTable::BEFORETABLE: |
227 | 227 | case PositionInTable::AFTERTABLE: |
228 | - if(isset($this->_compileParts)===false){ |
|
228 | + if (isset($this->_compileParts)===false) { |
|
229 | 229 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
230 | 230 | } |
231 | 231 | break; |
232 | 232 | case PositionInTable::HEADER: |
233 | 233 | case PositionInTable::FOOTER: |
234 | 234 | case PositionInTable::BODY: |
235 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
235 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
236 | 236 | break; |
237 | 237 | } |
238 | 238 | } |
@@ -244,16 +244,16 @@ discard block |
||
244 | 244 | * @param callable $callback function called after the field compilation |
245 | 245 | * @return DataTable |
246 | 246 | */ |
247 | - public function afterCompile($index,$callback){ |
|
248 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
247 | + public function afterCompile($index, $callback) { |
|
248 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
249 | 249 | return $this; |
250 | 250 | } |
251 | 251 | |
252 | - private function addToolbarRow($part,$table,$captions){ |
|
252 | + private function addToolbarRow($part, $table, $captions) { |
|
253 | 253 | $hasPart=$table->hasPart($part); |
254 | - if($hasPart){ |
|
254 | + if ($hasPart) { |
|
255 | 255 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
256 | - }else{ |
|
256 | + } else { |
|
257 | 257 | $row=$table->getPart($part)->getRow(0); |
258 | 258 | } |
259 | 259 | $row->mergeCol(); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * @see Widget::getHtmlComponent() |
266 | 266 | * @return HtmlTable |
267 | 267 | */ |
268 | - public function getHtmlComponent(){ |
|
268 | + public function getHtmlComponent() { |
|
269 | 269 | return $this->content["table"]; |
270 | 270 | } |
271 | 271 | |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | * @return DataTable |
280 | 280 | */ |
281 | 281 | public function setUrls($urls) { |
282 | - if(\is_array($urls)){ |
|
283 | - $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
|
284 | - $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
|
285 | - $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
|
286 | - }else{ |
|
287 | - $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
|
282 | + if (\is_array($urls)) { |
|
283 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
284 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
285 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
286 | + } else { |
|
287 | + $this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls]; |
|
288 | 288 | } |
289 | 289 | return $this; |
290 | 290 | } |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | * @param number $pages_visibles The number of visible pages in the Pagination component |
298 | 298 | * @return DataTable |
299 | 299 | */ |
300 | - public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){ |
|
301 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount); |
|
300 | + public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) { |
|
301 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
302 | 302 | return $this; |
303 | 303 | } |
304 | 304 | |
@@ -309,8 +309,8 @@ discard block |
||
309 | 309 | * @param number $pages_visibles The number of visible pages in the Pagination component |
310 | 310 | * @return DataTable |
311 | 311 | */ |
312 | - public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){ |
|
313 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page); |
|
312 | + public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) { |
|
313 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page); |
|
314 | 314 | return $this; |
315 | 315 | } |
316 | 316 | |
@@ -320,20 +320,20 @@ discard block |
||
320 | 320 | * @param array $compileParts |
321 | 321 | * @return DataTable |
322 | 322 | */ |
323 | - public function refresh($compileParts=["tbody"]){ |
|
323 | + public function refresh($compileParts=["tbody"]) { |
|
324 | 324 | $this->_compileParts=$compileParts; |
325 | 325 | return $this; |
326 | 326 | } |
327 | 327 | |
328 | 328 | |
329 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
329 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
330 | 330 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
331 | 331 | } |
332 | 332 | |
333 | - public function getSearchField(){ |
|
334 | - if(isset($this->_searchField)===false){ |
|
335 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
336 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
333 | + public function getSearchField() { |
|
334 | + if (isset($this->_searchField)===false) { |
|
335 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
336 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
337 | 337 | } |
338 | 338 | return $this->_searchField; |
339 | 339 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | return $this; |
350 | 350 | } |
351 | 351 | |
352 | - public function asForm(){ |
|
352 | + public function asForm() { |
|
353 | 353 | return $this->getForm(); |
354 | 354 | } |
355 | 355 | |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | |
358 | 358 | protected function getTargetSelector() { |
359 | 359 | $result=$this->_targetSelector; |
360 | - if(!isset($result)) |
|
360 | + if (!isset($result)) |
|
361 | 361 | $result="#".$this->identifier; |
362 | 362 | return $result; |
363 | 363 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | } |
374 | 374 | |
375 | 375 | public function getRefreshSelector() { |
376 | - if(isset($this->_refreshSelector)) |
|
376 | + if (isset($this->_refreshSelector)) |
|
377 | 377 | return $this->_refreshSelector; |
378 | 378 | return "#".$this->identifier." tbody"; |
379 | 379 | } |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | * {@inheritDoc} |
392 | 392 | * @see \Ajax\common\Widget::show() |
393 | 393 | */ |
394 | - public function show($modelInstance){ |
|
395 | - if(\is_array($modelInstance)){ |
|
396 | - if(\is_array(array_values($modelInstance)[0])) |
|
394 | + public function show($modelInstance) { |
|
395 | + if (\is_array($modelInstance)) { |
|
396 | + if (\is_array(array_values($modelInstance)[0])) |
|
397 | 397 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
398 | 398 | } |
399 | 399 | $this->_modelInstance=$modelInstance; |
@@ -428,24 +428,24 @@ discard block |
||
428 | 428 | return $this; |
429 | 429 | } |
430 | 430 | |
431 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
432 | - $this->_self->setActiveRowSelector($class,$event,$multiple); |
|
431 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
432 | + $this->_self->setActiveRowSelector($class, $event, $multiple); |
|
433 | 433 | return $this; |
434 | 434 | } |
435 | 435 | |
436 | - public function hideColumn($colIndex){ |
|
437 | - if(!\is_array($this->_hiddenColumns)) |
|
436 | + public function hideColumn($colIndex) { |
|
437 | + if (!\is_array($this->_hiddenColumns)) |
|
438 | 438 | $this->_hiddenColumns=[]; |
439 | 439 | $this->_hiddenColumns[]=$colIndex; |
440 | 440 | return $this; |
441 | 441 | } |
442 | 442 | |
443 | - public function setColWidth($colIndex,$width){ |
|
443 | + public function setColWidth($colIndex, $width) { |
|
444 | 444 | $this->_colWidths[$colIndex]=$width; |
445 | 445 | return $this; |
446 | 446 | } |
447 | 447 | public function setColWidths($_colWidths) { |
448 | - $this->_colWidths = $_colWidths; |
|
448 | + $this->_colWidths=$_colWidths; |
|
449 | 449 | return $this; |
450 | 450 | } |
451 | 451 | } |
@@ -13,19 +13,19 @@ discard block |
||
13 | 13 | * @property boolean $_visibleHover |
14 | 14 | * @property InstanceViewer $_instanceViewer |
15 | 15 | */ |
16 | -trait DataTableFieldAsTrait{ |
|
16 | +trait DataTableFieldAsTrait { |
|
17 | 17 | abstract public function addField($field); |
18 | - abstract public function insertField($index,$field); |
|
19 | - abstract public function insertInField($index,$field); |
|
20 | - abstract public function fieldAs($index,$type,$attributes=NULL); |
|
18 | + abstract public function insertField($index, $field); |
|
19 | + abstract public function insertInField($index, $field); |
|
20 | + abstract public function fieldAs($index, $type, $attributes=NULL); |
|
21 | 21 | /** |
22 | 22 | * @param string $caption |
23 | 23 | * @param callable $callback |
24 | 24 | * @param boolean $visibleHover |
25 | 25 | * @return callable |
26 | 26 | */ |
27 | - private function getFieldButtonCallable($caption,$visibleHover=true,$callback=null){ |
|
28 | - return $this->getCallable("getFieldButton",[$caption,$visibleHover],$callback); |
|
27 | + private function getFieldButtonCallable($caption, $visibleHover=true, $callback=null) { |
|
28 | + return $this->getCallable("getFieldButton", [$caption, $visibleHover], $callback); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | * @param callable $callback |
35 | 35 | * @return callable |
36 | 36 | */ |
37 | - private function getCallable($thisCallback,$parameters,$callback=null){ |
|
38 | - $result=function($instance) use($thisCallback,$parameters,$callback){ |
|
39 | - $object=call_user_func_array(array($this,$thisCallback), $parameters); |
|
40 | - if(isset($callback)){ |
|
41 | - if(\is_callable($callback)){ |
|
42 | - $callback($object,$instance); |
|
37 | + private function getCallable($thisCallback, $parameters, $callback=null) { |
|
38 | + $result=function($instance) use($thisCallback, $parameters, $callback){ |
|
39 | + $object=call_user_func_array(array($this, $thisCallback), $parameters); |
|
40 | + if (isset($callback)) { |
|
41 | + if (\is_callable($callback)) { |
|
42 | + $callback($object, $instance); |
|
43 | 43 | } |
44 | 44 | } |
45 | - if($object instanceof HtmlSemDoubleElement){ |
|
46 | - $object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier()); |
|
47 | - if($object->propertyContains("class","visibleover")){ |
|
45 | + if ($object instanceof HtmlSemDoubleElement) { |
|
46 | + $object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier()); |
|
47 | + if ($object->propertyContains("class", "visibleover")) { |
|
48 | 48 | $this->_visibleHover=true; |
49 | - $object->setProperty("style","visibility:hidden;"); |
|
49 | + $object->setProperty("style", "visibility:hidden;"); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | return $object; |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | * @param string $caption |
59 | 59 | * @return HtmlButton |
60 | 60 | */ |
61 | - private function getFieldButton($caption,$visibleHover=true){ |
|
62 | - $bt= new HtmlButton("",$caption); |
|
63 | - if($visibleHover) |
|
61 | + private function getFieldButton($caption, $visibleHover=true) { |
|
62 | + $bt=new HtmlButton("", $caption); |
|
63 | + if ($visibleHover) |
|
64 | 64 | $this->_visibleOver($bt); |
65 | 65 | return $bt; |
66 | 66 | } |
@@ -74,19 +74,19 @@ discard block |
||
74 | 74 | * @param array $attributes associative array (<b>ajax</b> key is for ajax post) |
75 | 75 | * @return \Ajax\semantic\widgets\datatable\DataTable |
76 | 76 | */ |
77 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
78 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$index,$attributes){ |
|
79 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
80 | - $button->postOnClick($url,"$(event.target).closest('tr').find(':input').serialize()",$responseElement,$attributes["ajax"]); |
|
81 | - if(!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
77 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
78 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $index, $attributes){ |
|
79 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
80 | + $button->postOnClick($url, "$(event.target).closest('tr').find(':input').serialize()", $responseElement, $attributes["ajax"]); |
|
81 | + if (!isset($attributes["visibleHover"]) || $attributes["visibleHover"]) |
|
82 | 82 | $this->_visibleOver($button); |
83 | 83 | return $button; |
84 | - }, $index,$attributes); |
|
84 | + }, $index, $attributes); |
|
85 | 85 | } |
86 | 86 | |
87 | - protected function _visibleOver(BaseHtml $element){ |
|
87 | + protected function _visibleOver(BaseHtml $element) { |
|
88 | 88 | $this->_visibleHover=true; |
89 | - return $element->addToProperty("class", "visibleover")->setProperty("style","visibility:hidden;"); |
|
89 | + return $element->addToProperty("class", "visibleover")->setProperty("style", "visibility:hidden;"); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | * @param boolean $visibleHover |
97 | 97 | * @return \Ajax\semantic\widgets\datatable\DataTable |
98 | 98 | */ |
99 | - public function addFieldButton($caption,$visibleHover=true,$callback=null){ |
|
100 | - $this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback)); |
|
99 | + public function addFieldButton($caption, $visibleHover=true, $callback=null) { |
|
100 | + $this->addField($this->getCallable("getFieldButton", [$caption, $visibleHover], $callback)); |
|
101 | 101 | return $this; |
102 | 102 | } |
103 | 103 | |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * @param callable $callback |
109 | 109 | * @return \Ajax\semantic\widgets\datatable\DataTable |
110 | 110 | */ |
111 | - public function insertFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
112 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
111 | + public function insertFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
112 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
113 | 113 | return $this; |
114 | 114 | } |
115 | 115 | |
@@ -120,25 +120,25 @@ discard block |
||
120 | 120 | * @param callable $callback |
121 | 121 | * @return \Ajax\semantic\widgets\datatable\DataTable |
122 | 122 | */ |
123 | - public function insertInFieldButton($index,$caption,$visibleHover=true,$callback=null){ |
|
124 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$visibleHover,$callback)); |
|
123 | + public function insertInFieldButton($index, $caption, $visibleHover=true, $callback=null) { |
|
124 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $visibleHover, $callback)); |
|
125 | 125 | return $this; |
126 | 126 | } |
127 | 127 | |
128 | - private function addDefaultButton($icon,$class=null,$visibleHover=true,$callback=null){ |
|
129 | - $this->addField($this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
|
128 | + private function addDefaultButton($icon, $class=null, $visibleHover=true, $callback=null) { |
|
129 | + $this->addField($this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback)); |
|
130 | 130 | return $this; |
131 | 131 | } |
132 | 132 | |
133 | - private function insertDefaultButtonIn($index,$icon,$class=null,$visibleHover=true,$callback=null){ |
|
134 | - $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class,$visibleHover],$callback)); |
|
133 | + private function insertDefaultButtonIn($index, $icon, $class=null, $visibleHover=true, $callback=null) { |
|
134 | + $this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class, $visibleHover], $callback)); |
|
135 | 135 | return $this; |
136 | 136 | } |
137 | 137 | |
138 | - private function getDefaultButton($icon,$class=null,$visibleHover=true){ |
|
139 | - $bt=$this->getFieldButton("",$visibleHover); |
|
138 | + private function getDefaultButton($icon, $class=null, $visibleHover=true) { |
|
139 | + $bt=$this->getFieldButton("", $visibleHover); |
|
140 | 140 | $bt->asIcon($icon); |
141 | - if(isset($class)) |
|
141 | + if (isset($class)) |
|
142 | 142 | $bt->addClass($class); |
143 | 143 | return $bt; |
144 | 144 | } |
@@ -149,30 +149,30 @@ discard block |
||
149 | 149 | * @param callable $callback |
150 | 150 | * @return DataTable |
151 | 151 | */ |
152 | - public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
152 | + public function addDeleteButton($visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
153 | 153 | $this->_deleteBehavior=$deleteBehavior; |
154 | - return $this->addDefaultButton("remove","_delete red basic",$visibleHover,$callback); |
|
154 | + return $this->addDefaultButton("remove", "_delete red basic", $visibleHover, $callback); |
|
155 | 155 | } |
156 | 156 | |
157 | - public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){ |
|
157 | + public function addEditButton($visibleHover=true, $editBehavior=[], $callback=null) { |
|
158 | 158 | $this->_editBehavior=$editBehavior; |
159 | - return $this->addDefaultButton("edit","_edit basic",$visibleHover,$callback); |
|
159 | + return $this->addDefaultButton("edit", "_edit basic", $visibleHover, $callback); |
|
160 | 160 | } |
161 | 161 | |
162 | - public function addEditDeleteButtons($visibleHover=true,$behavior=[],$callbackEdit=null,$callbackDelete=null){ |
|
163 | - $this->addEditButton($visibleHover,$behavior,$callbackEdit); |
|
162 | + public function addEditDeleteButtons($visibleHover=true, $behavior=[], $callbackEdit=null, $callbackDelete=null) { |
|
163 | + $this->addEditButton($visibleHover, $behavior, $callbackEdit); |
|
164 | 164 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
165 | - $this->insertDeleteButtonIn($index,$visibleHover,$behavior,$callbackDelete); |
|
165 | + $this->insertDeleteButtonIn($index, $visibleHover, $behavior, $callbackDelete); |
|
166 | 166 | return $this; |
167 | 167 | } |
168 | 168 | |
169 | - public function insertDeleteButtonIn($index,$visibleHover=true,$deleteBehavior=[],$callback=null){ |
|
169 | + public function insertDeleteButtonIn($index, $visibleHover=true, $deleteBehavior=[], $callback=null) { |
|
170 | 170 | $this->_deleteBehavior=$deleteBehavior; |
171 | - return $this->insertDefaultButtonIn($index,"remove","_delete red basic",$visibleHover,$callback); |
|
171 | + return $this->insertDefaultButtonIn($index, "remove", "_delete red basic", $visibleHover, $callback); |
|
172 | 172 | } |
173 | 173 | |
174 | - public function insertEditButtonIn($index,$visibleHover=true,$editBehavior=[],$callback=null){ |
|
174 | + public function insertEditButtonIn($index, $visibleHover=true, $editBehavior=[], $callback=null) { |
|
175 | 175 | $this->_editBehavior=$editBehavior; |
176 | - return $this->insertDefaultButtonIn($index,"edit","_edit basic",$visibleHover,$callback); |
|
176 | + return $this->insertDefaultButtonIn($index, "edit", "_edit basic", $visibleHover, $callback); |
|
177 | 177 | } |
178 | 178 | } |
@@ -28,23 +28,23 @@ discard block |
||
28 | 28 | * @property boolean $_edition |
29 | 29 | * @property mixed _modelInstance |
30 | 30 | */ |
31 | -trait FieldAsTrait{ |
|
31 | +trait FieldAsTrait { |
|
32 | 32 | |
33 | - abstract protected function _getFieldIdentifier($prefix,$name=""); |
|
34 | - abstract public function setValueFunction($index,$callback); |
|
33 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
34 | + abstract public function setValueFunction($index, $callback); |
|
35 | 35 | abstract protected function _getFieldName($index); |
36 | 36 | abstract protected function _getFieldCaption($index); |
37 | - abstract protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
|
37 | + abstract protected function _buttonAsSubmit(BaseHtml&$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @param HtmlFormField $element |
41 | 41 | * @param array $attributes |
42 | 42 | */ |
43 | - protected function _applyAttributes(BaseHtml $element,&$attributes,$index){ |
|
44 | - if(isset($attributes["jsCallback"])){ |
|
43 | + protected function _applyAttributes(BaseHtml $element, &$attributes, $index) { |
|
44 | + if (isset($attributes["jsCallback"])) { |
|
45 | 45 | $callback=$attributes["jsCallback"]; |
46 | - if(\is_callable($callback)){ |
|
47 | - $callback($element,$this->_modelInstance,$index); |
|
46 | + if (\is_callable($callback)) { |
|
47 | + $callback($element, $this->_modelInstance, $index); |
|
48 | 48 | unset($attributes["jsCallback"]); |
49 | 49 | } |
50 | 50 | } |
@@ -54,43 +54,43 @@ discard block |
||
54 | 54 | $element->fromArray($attributes); |
55 | 55 | } |
56 | 56 | |
57 | - private function _getLabelField($caption,$icon=NULL){ |
|
58 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
57 | + private function _getLabelField($caption, $icon=NULL) { |
|
58 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
59 | 59 | return $label; |
60 | 60 | } |
61 | 61 | |
62 | 62 | |
63 | - protected function _addRules(HtmlFormField $element,&$attributes){ |
|
64 | - if(isset($attributes["rules"])){ |
|
63 | + protected function _addRules(HtmlFormField $element, &$attributes) { |
|
64 | + if (isset($attributes["rules"])) { |
|
65 | 65 | $rules=$attributes["rules"]; |
66 | - if(\is_array($rules)){ |
|
66 | + if (\is_array($rules)) { |
|
67 | 67 | $element->addRules($rules); |
68 | 68 | } |
69 | - else{ |
|
69 | + else { |
|
70 | 70 | $element->addRule($rules); |
71 | 71 | } |
72 | 72 | unset($attributes["rules"]); |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - protected function _prepareFormFields(HtmlFormField &$field,$name,&$attributes){ |
|
76 | + protected function _prepareFormFields(HtmlFormField&$field, $name, &$attributes) { |
|
77 | 77 | $field->setName($name); |
78 | 78 | $this->_addRules($field, $attributes); |
79 | 79 | return $field; |
80 | 80 | } |
81 | 81 | |
82 | - protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){ |
|
83 | - $this->setValueFunction($index,function($value,$instance,$index) use (&$attributes,$elementCallback,$prefix){ |
|
82 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
83 | + $this->setValueFunction($index, function($value, $instance, $index) use (&$attributes, $elementCallback, $prefix){ |
|
84 | 84 | $caption=$this->_getFieldCaption($index); |
85 | 85 | $name=$this->_getFieldName($index); |
86 | - $id=$this->_getFieldIdentifier($prefix,$name); |
|
87 | - if(isset($attributes["name"])){ |
|
86 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
87 | + if (isset($attributes["name"])) { |
|
88 | 88 | $name=$attributes["name"]; |
89 | 89 | unset($attributes["name"]); |
90 | 90 | } |
91 | - $element=$elementCallback($id,$name,$value,$caption); |
|
92 | - if(\is_array($attributes)){ |
|
93 | - $this->_applyAttributes($element, $attributes,$index); |
|
91 | + $element=$elementCallback($id, $name, $value, $caption); |
|
92 | + if (\is_array($attributes)) { |
|
93 | + $this->_applyAttributes($element, $attributes, $index); |
|
94 | 94 | } |
95 | 95 | $element->setDisabled(!$this->_edition); |
96 | 96 | return $element; |
@@ -99,178 +99,178 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
103 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
104 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
102 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
103 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
104 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
105 | 105 | return $pb; |
106 | 106 | }); |
107 | 107 | return $this; |
108 | 108 | } |
109 | 109 | |
110 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
111 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
112 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
110 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
111 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
112 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
113 | 113 | return $rating; |
114 | 114 | }); |
115 | 115 | return $this; |
116 | 116 | } |
117 | 117 | |
118 | - public function fieldAsLabel($index,$icon=NULL,$attributes=NULL){ |
|
119 | - return $this->_fieldAs(function($id,$name,$value) use($icon){ |
|
120 | - $lbl=new HtmlLabel($id,$value); |
|
121 | - if(isset($icon)) |
|
118 | + public function fieldAsLabel($index, $icon=NULL, $attributes=NULL) { |
|
119 | + return $this->_fieldAs(function($id, $name, $value) use($icon){ |
|
120 | + $lbl=new HtmlLabel($id, $value); |
|
121 | + if (isset($icon)) |
|
122 | 122 | $lbl->addIcon($icon); |
123 | 123 | return $lbl; |
124 | - }, $index,$attributes,"label"); |
|
124 | + }, $index, $attributes, "label"); |
|
125 | 125 | } |
126 | 126 | |
127 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
128 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
129 | - $header=new HtmlHeader($id,$niveau,$value); |
|
130 | - if(isset($icon)) |
|
127 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
128 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
129 | + $header=new HtmlHeader($id, $niveau, $value); |
|
130 | + if (isset($icon)) |
|
131 | 131 | $header->asIcon($icon, $value); |
132 | 132 | return $header; |
133 | - }, $index,$attributes,"header"); |
|
133 | + }, $index, $attributes, "header"); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
137 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
138 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
139 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
137 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
138 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
139 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
140 | 140 | return $image; |
141 | 141 | }); |
142 | 142 | return $this; |
143 | 143 | } |
144 | 144 | |
145 | - public function fieldAsFlag($index){ |
|
146 | - $this->setValueFunction($index,function($flag){ |
|
147 | - $flag=new HtmlFlag($this->_getFieldIdentifier("flag"),$flag); |
|
145 | + public function fieldAsFlag($index) { |
|
146 | + $this->setValueFunction($index, function($flag) { |
|
147 | + $flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
148 | 148 | return $flag; |
149 | 149 | }); |
150 | 150 | return $this; |
151 | 151 | } |
152 | 152 | |
153 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
154 | - return $this->_fieldAs(function($id,$name,$value){ |
|
155 | - $img=new HtmlImage($id,$value); |
|
153 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
154 | + return $this->_fieldAs(function($id, $name, $value) { |
|
155 | + $img=new HtmlImage($id, $value); |
|
156 | 156 | $img->asAvatar(); |
157 | 157 | return $img; |
158 | - }, $index,$attributes,"avatar"); |
|
158 | + }, $index, $attributes, "avatar"); |
|
159 | 159 | } |
160 | 160 | |
161 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
162 | - return $this->_fieldAs(function($id,$name,$value) use($attributes){ |
|
163 | - $input= new HtmlRadio($id,$name,$value,$value); |
|
161 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
162 | + return $this->_fieldAs(function($id, $name, $value) use($attributes){ |
|
163 | + $input=new HtmlRadio($id, $name, $value, $value); |
|
164 | 164 | return $this->_prepareFormFields($input, $name, $attributes); |
165 | - }, $index,$attributes,"radio"); |
|
165 | + }, $index, $attributes, "radio"); |
|
166 | 166 | } |
167 | 167 | |
168 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
169 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){ |
|
170 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
171 | - }, $index,$attributes,"radios"); |
|
168 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
169 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){ |
|
170 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
171 | + }, $index, $attributes, "radios"); |
|
172 | 172 | } |
173 | 173 | |
174 | - public function fieldAsInput($index,$attributes=NULL){ |
|
175 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
176 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
174 | + public function fieldAsInput($index, $attributes=NULL) { |
|
175 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
176 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
177 | 177 | return $this->_prepareFormFields($input, $name, $attributes); |
178 | - }, $index,$attributes,"input"); |
|
178 | + }, $index, $attributes, "input"); |
|
179 | 179 | } |
180 | 180 | |
181 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
182 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
183 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
181 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
182 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
183 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
184 | 184 | return $this->_prepareFormFields($textarea, $name, $attributes); |
185 | - }, $index,$attributes,"textarea"); |
|
185 | + }, $index, $attributes, "textarea"); |
|
186 | 186 | } |
187 | 187 | |
188 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
189 | - if(!\is_array($attributes)){ |
|
188 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
189 | + if (!\is_array($attributes)) { |
|
190 | 190 | $attributes=[]; |
191 | 191 | } |
192 | 192 | $attributes["inputType"]="hidden"; |
193 | - return $this->fieldAsInput($index,$attributes); |
|
193 | + return $this->fieldAsInput($index, $attributes); |
|
194 | 194 | } |
195 | 195 | |
196 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
197 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($attributes){ |
|
198 | - if($caption===null || $caption==="") |
|
196 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
197 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($attributes){ |
|
198 | + if ($caption===null || $caption==="") |
|
199 | 199 | $caption=""; |
200 | - $input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier()); |
|
200 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
201 | 201 | $input->setChecked(JString::isBooleanTrue($value)); |
202 | 202 | return $this->_prepareFormFields($input, $name, $attributes); |
203 | - }, $index,$attributes,"ck"); |
|
203 | + }, $index, $attributes, "ck"); |
|
204 | 204 | } |
205 | 205 | |
206 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
207 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple,$attributes){ |
|
208 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value); |
|
209 | - $dd->asSelect($name,$multiple); |
|
206 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
207 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple, $attributes){ |
|
208 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value); |
|
209 | + $dd->asSelect($name, $multiple); |
|
210 | 210 | return $this->_prepareFormFields($dd, $name, $attributes); |
211 | - }, $index,$attributes,"dd"); |
|
211 | + }, $index, $attributes, "dd"); |
|
212 | 212 | } |
213 | 213 | |
214 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
215 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
216 | - $mess= new HtmlMessage("message-".$id,$caption); |
|
214 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
215 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
216 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
217 | 217 | $mess->addHeader($value); |
218 | 218 | return $mess; |
219 | - }, $index,$attributes,"message"); |
|
219 | + }, $index, $attributes, "message"); |
|
220 | 220 | } |
221 | 221 | |
222 | - public function fieldAsLink($index,$attributes=NULL){ |
|
223 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
224 | - $lnk= new HtmlLink("message-".$id,"#",$caption); |
|
222 | + public function fieldAsLink($index, $attributes=NULL) { |
|
223 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
224 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
225 | 225 | return $lnk; |
226 | - }, $index,$attributes,"link"); |
|
226 | + }, $index, $attributes, "link"); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /**Change fields type |
230 | 230 | * @param array $types an array or associative array $type=>$attributes |
231 | 231 | */ |
232 | - public function fieldsAs(array $types){ |
|
232 | + public function fieldsAs(array $types) { |
|
233 | 233 | $i=0; |
234 | - if(JArray::isAssociative($types)){ |
|
235 | - foreach ($types as $type=>$attributes){ |
|
236 | - if(\is_int($type)) |
|
237 | - $this->fieldAs($i++,$attributes,[]); |
|
238 | - else{ |
|
239 | - $type=preg_replace('/\d/', '', $type ); |
|
240 | - $this->fieldAs($i++,$type,$attributes); |
|
234 | + if (JArray::isAssociative($types)) { |
|
235 | + foreach ($types as $type=>$attributes) { |
|
236 | + if (\is_int($type)) |
|
237 | + $this->fieldAs($i++, $attributes, []); |
|
238 | + else { |
|
239 | + $type=preg_replace('/\d/', '', $type); |
|
240 | + $this->fieldAs($i++, $type, $attributes); |
|
241 | 241 | } |
242 | 242 | } |
243 | - }else{ |
|
244 | - foreach ($types as $type){ |
|
245 | - $this->fieldAs($i++,$type); |
|
243 | + } else { |
|
244 | + foreach ($types as $type) { |
|
245 | + $this->fieldAs($i++, $type); |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
250 | - public function fieldAs($index,$type,$attributes=NULL){ |
|
250 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
251 | 251 | $method="fieldAs".\ucfirst($type); |
252 | - if(\method_exists($this, $method)){ |
|
253 | - if(!\is_array($attributes)){ |
|
252 | + if (\method_exists($this, $method)) { |
|
253 | + if (!\is_array($attributes)) { |
|
254 | 254 | $attributes=[$index]; |
255 | - }else{ |
|
255 | + } else { |
|
256 | 256 | \array_unshift($attributes, $index); |
257 | 257 | } |
258 | - \call_user_func_array([$this,$method], $attributes); |
|
258 | + \call_user_func_array([$this, $method], $attributes); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
263 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
|
264 | - $button=new HtmlButton($id,$caption,$cssStyle); |
|
265 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]); |
|
262 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
263 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){ |
|
264 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
265 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]); |
|
266 | 266 | return $button; |
267 | - }, $index,$attributes,"submit"); |
|
267 | + }, $index, $attributes, "submit"); |
|
268 | 268 | } |
269 | 269 | |
270 | - public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){ |
|
271 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
272 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
270 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
271 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
272 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
273 | 273 | return $button; |
274 | - }, $index,$attributes,"button"); |
|
274 | + }, $index, $attributes, "button"); |
|
275 | 275 | } |
276 | 276 | } |
@@ -20,19 +20,19 @@ discard block |
||
20 | 20 | |
21 | 21 | public function __construct($identifier) { |
22 | 22 | parent::__construct($identifier, "tr", ""); |
23 | - $this->_states=[ State::ACTIVE,State::POSITIVE,State::NEGATIVE,State::WARNING,State::ERROR,State::DISABLED ]; |
|
23 | + $this->_states=[State::ACTIVE, State::POSITIVE, State::NEGATIVE, State::WARNING, State::ERROR, State::DISABLED]; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function setColCount($colCount) { |
27 | 27 | $count=$this->count(); |
28 | - for($i=$count; $i < $colCount; $i++) { |
|
28 | + for ($i=$count; $i<$colCount; $i++) { |
|
29 | 29 | $item=$this->addItem(NULL); |
30 | 30 | $item->setTagName($this->_tdTagName); |
31 | 31 | } |
32 | 32 | return $this; |
33 | 33 | } |
34 | 34 | |
35 | - public function getColCount(){ |
|
35 | + public function getColCount() { |
|
36 | 36 | return $this->count(); |
37 | 37 | } |
38 | 38 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param mixed $values |
69 | 69 | */ |
70 | 70 | public function setValues($values=array()) { |
71 | - return $this->_addOrSetValues($values, function(HtmlTD &$cell,$value){$cell->setValue($value);}); |
|
71 | + return $this->_addOrSetValues($values, function(HtmlTD&$cell, $value) {$cell->setValue($value); }); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,27 +76,27 @@ discard block |
||
76 | 76 | * @param mixed $values |
77 | 77 | */ |
78 | 78 | public function addValues($values=array()) { |
79 | - return $this->_addOrSetValues($values, function(HtmlTD &$cell,$value){$cell->addValue($value);}); |
|
79 | + return $this->_addOrSetValues($values, function(HtmlTD&$cell, $value) {$cell->addValue($value); }); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Sets or adds values to the row cols |
84 | 84 | * @param mixed $values |
85 | 85 | */ |
86 | - protected function _addOrSetValues($values,$callback) { |
|
86 | + protected function _addOrSetValues($values, $callback) { |
|
87 | 87 | $count=$this->count(); |
88 | 88 | if (!\is_array($values)) { |
89 | 89 | $values=\array_fill(0, $count, $values); |
90 | 90 | } else { |
91 | - if (JArray::isAssociative($values) === true) { |
|
91 | + if (JArray::isAssociative($values)===true) { |
|
92 | 92 | $values=\array_values($values); |
93 | 93 | } |
94 | 94 | } |
95 | 95 | $count=\min(\sizeof($values), $count); |
96 | 96 | |
97 | - for($i=0; $i < $count; $i++) { |
|
97 | + for ($i=0; $i<$count; $i++) { |
|
98 | 98 | $cell=$this->content[$i]; |
99 | - $callback($cell,$values[$i]); |
|
99 | + $callback($cell, $values[$i]); |
|
100 | 100 | } |
101 | 101 | return $this; |
102 | 102 | } |
@@ -122,20 +122,20 @@ discard block |
||
122 | 122 | public function getColPosition($colIndex) { |
123 | 123 | $pos=0; |
124 | 124 | $rows=$this->_container->getContent(); |
125 | - for($i=0; $i < $this->_row; $i++) { |
|
125 | + for ($i=0; $i<$this->_row; $i++) { |
|
126 | 126 | $max=\min($colIndex, $rows[$i]->count()); |
127 | - for($j=0; $j < $max; $j++) { |
|
127 | + for ($j=0; $j<$max; $j++) { |
|
128 | 128 | $rowspan=$rows[$i]->getItem($j)->getRowspan(); |
129 | - if ($rowspan + $i > $this->_row) |
|
129 | + if ($rowspan+$i>$this->_row) |
|
130 | 130 | $pos++; |
131 | 131 | } |
132 | 132 | } |
133 | - if ($pos > $colIndex) |
|
133 | + if ($pos>$colIndex) |
|
134 | 134 | return NULL; |
135 | 135 | $count=$this->count(); |
136 | - for($i=0; $i < $count; $i++) { |
|
136 | + for ($i=0; $i<$count; $i++) { |
|
137 | 137 | $pos+=$this->content[$i]->getColspan(); |
138 | - if ($pos >= $colIndex + 1) |
|
138 | + if ($pos>=$colIndex+1) |
|
139 | 139 | return $i; |
140 | 140 | } |
141 | 141 | return null; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | public function conditionalCellFormat($callback, $format) { |
145 | 145 | $cells=$this->content; |
146 | - foreach ( $cells as $cell ) { |
|
146 | + foreach ($cells as $cell) { |
|
147 | 147 | $cell->conditionalCellFormat($callback, $format); |
148 | 148 | } |
149 | 149 | return $this; |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | |
159 | 159 | public function containsStr($needle) { |
160 | 160 | $cells=$this->content; |
161 | - foreach ( $cells as $cell ) { |
|
162 | - if (\strpos($cell->getContent(), $needle) !== false) |
|
161 | + foreach ($cells as $cell) { |
|
162 | + if (\strpos($cell->getContent(), $needle)!==false) |
|
163 | 163 | return true; |
164 | 164 | } |
165 | 165 | return false; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | public function applyCells($callback) { |
174 | 174 | $cells=$this->content; |
175 | - foreach ( $cells as $cell ) { |
|
175 | + foreach ($cells as $cell) { |
|
176 | 176 | $cell->apply($callback); |
177 | 177 | } |
178 | 178 | return $this; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * |
12 | 12 | */ |
13 | 13 | class HtmlTableContent extends HtmlSemCollection { |
14 | - protected $_tdTagNames=[ "thead" => "th","tbody" => "td","tfoot" => "th" ]; |
|
14 | + protected $_tdTagNames=["thead" => "th", "tbody" => "td", "tfoot" => "th"]; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function setRowCount($rowCount, $colCount) { |
36 | 36 | $count=$this->count(); |
37 | - for($i=$count; $i < $rowCount; $i++) { |
|
37 | + for ($i=$count; $i<$rowCount; $i++) { |
|
38 | 38 | $this->addItem($colCount); |
39 | 39 | } |
40 | 40 | return $this; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $tr=new HtmlTR("", $value); |
57 | 57 | $tr->setContainer($this, $count); |
58 | 58 | $tr->setTdTagName($this->_tdTagNames[$this->tagName]); |
59 | - if (isset($value) === true) { |
|
59 | + if (isset($value)===true) { |
|
60 | 60 | $tr->setColCount($value); |
61 | 61 | } |
62 | 62 | return $tr; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function setCellValue($row, $col, $value="") { |
116 | 116 | $cell=$this->getCell($row, $col); |
117 | - if (isset($cell) === true) { |
|
117 | + if (isset($cell)===true) { |
|
118 | 118 | $cell->setValue($value); |
119 | 119 | } |
120 | 120 | return $this; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param mixed $values |
126 | 126 | */ |
127 | 127 | public function setValues($values=array()) { |
128 | - return $this->_addOrSetValues($values, function(HtmlTR $row,$_values){$row->setValues($_values);}); |
|
128 | + return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) {$row->setValues($_values); }); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param mixed $values |
134 | 134 | */ |
135 | 135 | public function addValues($values=array()) { |
136 | - return $this->_addOrSetValues($values, function(HtmlTR $row,$_values){$row->addValues($_values);}); |
|
136 | + return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) {$row->addValues($_values); }); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -141,21 +141,21 @@ discard block |
||
141 | 141 | * @param mixed $values |
142 | 142 | * @param callable $callback |
143 | 143 | */ |
144 | - protected function _addOrSetValues($values,$callback) { |
|
144 | + protected function _addOrSetValues($values, $callback) { |
|
145 | 145 | $count=$this->count(); |
146 | 146 | $isArray=true; |
147 | 147 | if (!\is_array($values)) { |
148 | 148 | $values=\array_fill(0, $count, $values); |
149 | 149 | $isArray=false; |
150 | 150 | } |
151 | - if (JArray::dimension($values) == 1 && $isArray) |
|
152 | - $values=[ $values ]; |
|
151 | + if (JArray::dimension($values)==1 && $isArray) |
|
152 | + $values=[$values]; |
|
153 | 153 | |
154 | 154 | $count=\min(\sizeof($values), $count); |
155 | 155 | |
156 | - for($i=0; $i < $count; $i++) { |
|
156 | + for ($i=0; $i<$count; $i++) { |
|
157 | 157 | $row=$this->content[$i]; |
158 | - $callback($row,$values[$i]); |
|
158 | + $callback($row, $values[$i]); |
|
159 | 159 | } |
160 | 160 | return $this; |
161 | 161 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $values=\array_fill(0, $count, $values); |
167 | 167 | } |
168 | 168 | $count=\min(\sizeof($values), $count); |
169 | - for($i=0; $i < $count; $i++) { |
|
169 | + for ($i=0; $i<$count; $i++) { |
|
170 | 170 | $this->getCell($i, $colIndex)->setValue($values[$i]); |
171 | 171 | } |
172 | 172 | return $this; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | public function addColVariations($colIndex, $variations=array()) { |
176 | 176 | $count=$this->count(); |
177 | - for($i=0; $i < $count; $i++) { |
|
177 | + for ($i=0; $i<$count; $i++) { |
|
178 | 178 | $this->getCell($i, $colIndex)->addVariations($variations); |
179 | 179 | } |
180 | 180 | return $this; |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | |
192 | 192 | private function colAlign($colIndex, $function) { |
193 | 193 | $count=$this->count(); |
194 | - for($i=0; $i < $count; $i++) { |
|
194 | + for ($i=0; $i<$count; $i++) { |
|
195 | 195 | $index=$this->content[$i]->getColPosition($colIndex); |
196 | - if ($index !== NULL) |
|
196 | + if ($index!==NULL) |
|
197 | 197 | $this->getCell($i, $index)->$function(); |
198 | 198 | } |
199 | 199 | return $this; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function getColCount() { |
227 | 227 | $result=0; |
228 | - if ($this->count() > 0) |
|
228 | + if ($this->count()>0) |
|
229 | 229 | $result=$this->getItem(0)->count(); |
230 | 230 | return $result; |
231 | 231 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | public function delete($rowIndex, $colIndex=NULL) { |
240 | 240 | if (isset($colIndex)) { |
241 | 241 | $row=$this->getItem($rowIndex); |
242 | - if (isset($row) === true) { |
|
242 | + if (isset($row)===true) { |
|
243 | 243 | $row->delete($colIndex); |
244 | 244 | } |
245 | 245 | } else { |
@@ -272,17 +272,17 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function conditionalCellFormat($callback, $format) { |
274 | 274 | $rows=$this->content; |
275 | - foreach ( $rows as $row ) { |
|
275 | + foreach ($rows as $row) { |
|
276 | 276 | $row->conditionalCellFormat($callback, $format); |
277 | 277 | } |
278 | 278 | return $this; |
279 | 279 | } |
280 | 280 | |
281 | - public function conditionalColFormat($colIndex,$callback,$format){ |
|
281 | + public function conditionalColFormat($colIndex, $callback, $format) { |
|
282 | 282 | $rows=$this->content; |
283 | - foreach ( $rows as $row ) { |
|
283 | + foreach ($rows as $row) { |
|
284 | 284 | $cell=$row->getItem($colIndex); |
285 | - $cell->conditionnalCellFormat($callback,$format); |
|
285 | + $cell->conditionnalCellFormat($callback, $format); |
|
286 | 286 | } |
287 | 287 | return $this; |
288 | 288 | } |
@@ -294,17 +294,17 @@ discard block |
||
294 | 294 | */ |
295 | 295 | public function conditionalRowFormat($callback, $format) { |
296 | 296 | $rows=$this->content; |
297 | - foreach ( $rows as $row ) { |
|
297 | + foreach ($rows as $row) { |
|
298 | 298 | $row->conditionalRowFormat($callback, $format); |
299 | 299 | } |
300 | 300 | return $this; |
301 | 301 | } |
302 | 302 | |
303 | - public function hideColumn($colIndex){ |
|
303 | + public function hideColumn($colIndex) { |
|
304 | 304 | $rows=$this->content; |
305 | - foreach ( $rows as $row ) { |
|
305 | + foreach ($rows as $row) { |
|
306 | 306 | $cell=$row->getItem($colIndex); |
307 | - $cell->addToProperty("style","display:none;"); |
|
307 | + $cell->addToProperty("style", "display:none;"); |
|
308 | 308 | } |
309 | 309 | return $this; |
310 | 310 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function applyCells($callback) { |
317 | 317 | $rows=$this->content; |
318 | - foreach ( $rows as $row ) { |
|
318 | + foreach ($rows as $row) { |
|
319 | 319 | $row->applyCells($callback); |
320 | 320 | } |
321 | 321 | return $this; |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | */ |
328 | 328 | public function applyRows($callback) { |
329 | 329 | $rows=$this->content; |
330 | - foreach ( $rows as $row ) { |
|
330 | + foreach ($rows as $row) { |
|
331 | 331 | $row->apply($callback); |
332 | 332 | } |
333 | 333 | return $this; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $this->startIndex=$startIndex; |
53 | 53 | $this->autoActive=$autoActive; |
54 | 54 | $this->_contentSeparator="<div class='divider'> / </div>"; |
55 | - $this->_hrefFunction=function (HtmlSemDoubleElement $e) { |
|
55 | + $this->_hrefFunction=function(HtmlSemDoubleElement $e) { |
|
56 | 56 | return $e->getContent(); |
57 | 57 | }; |
58 | 58 | if (isset($hrefFunction)) { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return HtmlBreadcrumbs |
69 | 69 | */ |
70 | 70 | public function autoGetOnClick($targetSelector) { |
71 | - return $this->getOnClick($this->root, $targetSelector, array ("attr" => $this->attr )); |
|
71 | + return $this->getOnClick($this->root, $targetSelector, array("attr" => $this->attr)); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | public function contentAsString() { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function setActive($index=null) { |
85 | 85 | if (!isset($index)) { |
86 | - $index=sizeof($this->content) - 1; |
|
86 | + $index=sizeof($this->content)-1; |
|
87 | 87 | } |
88 | 88 | $activeItem=$this->content[$index]; |
89 | 89 | $activeItem->addToProperty("class", "active"); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param Dispatcher $dispatcher the request dispatcher |
97 | 97 | * @return \Ajax\bootstrap\html\HtmlBreadcrumbs |
98 | 98 | */ |
99 | - public function fromDispatcher(JsUtils $js,$dispatcher, $startIndex=0) { |
|
99 | + public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0) { |
|
100 | 100 | return $this->addItems($js->fromDispatcher($dispatcher)); |
101 | 101 | } |
102 | 102 | |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | if (!isset($index)) { |
111 | 111 | $index=sizeof($this->content); |
112 | 112 | } |
113 | - if ($this->absolutePaths === true) { |
|
113 | + if ($this->absolutePaths===true) { |
|
114 | 114 | return $this->_hrefFunction($this->content[$index]); |
115 | 115 | } else { |
116 | - return $this->root . implode($separator, array_slice(array_map(function ($e) { |
|
116 | + return $this->root.implode($separator, array_slice(array_map(function($e) { |
|
117 | 117 | return $this->_hrefFunction($e); |
118 | - }, $this->content), $this->startIndex, $index + 1)); |
|
118 | + }, $this->content), $this->startIndex, $index+1)); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | $this->setActive(); |
150 | 150 | } |
151 | 151 | $count=$this->count(); |
152 | - for($i=1; $i < $count; $i++) { |
|
153 | - $this->content[$i]->wrap($this->getContentDivider($i - 1)); |
|
152 | + for ($i=1; $i<$count; $i++) { |
|
153 | + $this->content[$i]->wrap($this->getContentDivider($i-1)); |
|
154 | 154 | } |
155 | 155 | return parent::compile($js, $view); |
156 | 156 | } |
@@ -160,15 +160,15 @@ discard block |
||
160 | 160 | * @see \Ajax\bootstrap\html\base\BaseHtml::on() |
161 | 161 | */ |
162 | 162 | public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
163 | - foreach ( $this->content as $element ) { |
|
163 | + foreach ($this->content as $element) { |
|
164 | 164 | $element->on($event, $jsCode, $stopPropagation, $preventDefault); |
165 | 165 | } |
166 | 166 | return $this; |
167 | 167 | } |
168 | 168 | |
169 | 169 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
170 | - foreach ( $this->content as $element ) { |
|
171 | - if ($element->getProperty($this->attr) != NULL){ |
|
170 | + foreach ($this->content as $element) { |
|
171 | + if ($element->getProperty($this->attr)!=NULL) { |
|
172 | 172 | $element->_ajaxOn($operation, $event, $url, $responseElement, $parameters); |
173 | 173 | } |
174 | 174 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | protected function createItem($value) { |
185 | 185 | $count=$this->count(); |
186 | - $itemO=new HtmlSemDoubleElement("item-" . $this->identifier . "-" . $count, "a", "section"); |
|
186 | + $itemO=new HtmlSemDoubleElement("item-".$this->identifier."-".$count, "a", "section"); |
|
187 | 187 | if (\is_array($value)) |
188 | 188 | $itemO->fromArray($value); |
189 | 189 | else { |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | public function addIconAt($icon, $index) { |
196 | 196 | $item=$this->getItem($index); |
197 | 197 | if (isset($item)) { |
198 | - $icon=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
198 | + $icon=new HtmlIcon("icon-".$this->identifier, $icon); |
|
199 | 199 | $item->wrapContent($icon); |
200 | 200 | } |
201 | 201 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | public function addItem($item) { |
204 | 204 | $count=$this->count(); |
205 | 205 | $itemO=parent::addItem($item); |
206 | - $this->addToPropertyCtrl("class", "section", array ("section" )); |
|
206 | + $this->addToPropertyCtrl("class", "section", array("section")); |
|
207 | 207 | $itemO->setProperty($this->attr, $this->getHref($count)); |
208 | 208 | return $itemO; |
209 | 209 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | public function setAbsolutePaths($absolutePaths) { |
220 | 220 | $this->absolutePaths=$absolutePaths; |
221 | 221 | $size=\sizeof($this->content); |
222 | - for($i=0;$i<$size;$i++){ |
|
222 | + for ($i=0; $i<$size; $i++) { |
|
223 | 223 | $this->content[$i]->setProperty($this->attr, $this->getHref($i)); |
224 | 224 | } |
225 | 225 | return $this; |