@@ -69,6 +69,9 @@ discard block |
||
| 69 | 69 | return $tr; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | + /** |
|
| 73 | + * @param integer $value |
|
| 74 | + */ |
|
| 72 | 75 | public function newRow($value) { |
| 73 | 76 | return $this->createItem($value); |
| 74 | 77 | } |
@@ -102,7 +105,7 @@ discard block |
||
| 102 | 105 | /** |
| 103 | 106 | * |
| 104 | 107 | * @param int $index |
| 105 | - * @return \Ajax\semantic\html\content\HtmlTR |
|
| 108 | + * @return \Ajax\common\html\HtmlDoubleElement |
|
| 106 | 109 | */ |
| 107 | 110 | public function getRow($index) { |
| 108 | 111 | return $this->getItem($index); |
@@ -146,6 +149,9 @@ discard block |
||
| 146 | 149 | return $this; |
| 147 | 150 | } |
| 148 | 151 | |
| 152 | + /** |
|
| 153 | + * @param integer $colIndex |
|
| 154 | + */ |
|
| 149 | 155 | public function setColValues($colIndex, $values=array()) { |
| 150 | 156 | $count=$this->count(); |
| 151 | 157 | if (\is_array($values) === false) { |
@@ -166,6 +172,9 @@ discard block |
||
| 166 | 172 | return $this; |
| 167 | 173 | } |
| 168 | 174 | |
| 175 | + /** |
|
| 176 | + * @param integer $rowIndex |
|
| 177 | + */ |
|
| 169 | 178 | public function setRowValues($rowIndex, $values=array()) { |
| 170 | 179 | $count=$this->count(); |
| 171 | 180 | if (\is_array($values) === false) { |
@@ -175,6 +184,9 @@ discard block |
||
| 175 | 184 | return $this; |
| 176 | 185 | } |
| 177 | 186 | |
| 187 | + /** |
|
| 188 | + * @param string $function |
|
| 189 | + */ |
|
| 178 | 190 | private function colAlign($colIndex, $function) { |
| 179 | 191 | $count=$this->count(); |
| 180 | 192 | for($i=0; $i < $count; $i++) { |
@@ -33,6 +33,10 @@ discard block |
||
| 33 | 33 | parent::run($js); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | + /** |
|
| 37 | + * @param string $identifier |
|
| 38 | + * @param string $model |
|
| 39 | + */ |
|
| 36 | 40 | public function __construct($identifier,$model,$modelInstance=NULL) { |
| 37 | 41 | parent::__construct($identifier, $model,$modelInstance); |
| 38 | 42 | $this->_instanceViewer=new InstanceViewer(); |
@@ -112,6 +116,9 @@ discard block |
||
| 112 | 116 | return parent::compile($js,$view); |
| 113 | 117 | } |
| 114 | 118 | |
| 119 | + /** |
|
| 120 | + * @param string $part |
|
| 121 | + */ |
|
| 115 | 122 | private function addToolbarRow($part,$table,$captions){ |
| 116 | 123 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 117 | 124 | $row->mergeCol(); |
@@ -137,16 +144,26 @@ discard block |
||
| 137 | 144 | return $this; |
| 138 | 145 | } |
| 139 | 146 | |
| 147 | + /** |
|
| 148 | + * @param \Closure $field |
|
| 149 | + */ |
|
| 140 | 150 | public function addField($field){ |
| 141 | 151 | $this->_instanceViewer->addField($field); |
| 142 | 152 | return $this; |
| 143 | 153 | } |
| 144 | 154 | |
| 155 | + /** |
|
| 156 | + * @param integer $index |
|
| 157 | + * @param \Closure $field |
|
| 158 | + */ |
|
| 145 | 159 | public function insertField($index,$field){ |
| 146 | 160 | $this->_instanceViewer->insertField($index, $field); |
| 147 | 161 | return $this; |
| 148 | 162 | } |
| 149 | 163 | |
| 164 | + /** |
|
| 165 | + * @param \Closure $field |
|
| 166 | + */ |
|
| 150 | 167 | public function insertInField($index,$field){ |
| 151 | 168 | $this->_instanceViewer->insertInField($index, $field); |
| 152 | 169 | return $this; |
@@ -195,16 +212,16 @@ discard block |
||
| 195 | 212 | /** |
| 196 | 213 | * @param string $caption |
| 197 | 214 | * @param callable $callback |
| 198 | - * @return callable |
|
| 215 | + * @return \Closure |
|
| 199 | 216 | */ |
| 200 | 217 | private function getFieldButtonCallable($caption,$callback=null){ |
| 201 | 218 | return $this->getCallable($this->getFieldButton($caption),$callback); |
| 202 | 219 | } |
| 203 | 220 | |
| 204 | 221 | /** |
| 205 | - * @param mixed $object |
|
| 222 | + * @param HtmlButton $object |
|
| 206 | 223 | * @param callable $callback |
| 207 | - * @return callable |
|
| 224 | + * @return \Closure |
|
| 208 | 225 | */ |
| 209 | 226 | private function getCallable($object,$callback=null){ |
| 210 | 227 | $result=function($instance) use($object,$callback){ |
@@ -263,12 +280,20 @@ discard block |
||
| 263 | 280 | return $this; |
| 264 | 281 | } |
| 265 | 282 | |
| 283 | + /** |
|
| 284 | + * @param string $icon |
|
| 285 | + * @param string $class |
|
| 286 | + */ |
|
| 266 | 287 | private function addDefaultButton($icon,$class=null,$callback=null){ |
| 267 | 288 | $bt=$this->getDefaultButton($icon,$class); |
| 268 | 289 | $this->addField($this->getCallable($bt,$callback)); |
| 269 | 290 | return $this; |
| 270 | 291 | } |
| 271 | 292 | |
| 293 | + /** |
|
| 294 | + * @param string $icon |
|
| 295 | + * @param string $class |
|
| 296 | + */ |
|
| 272 | 297 | private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){ |
| 273 | 298 | $bt=$this->getDefaultButton($icon,$class); |
| 274 | 299 | $this->insertInField($index,$this->getCallable($bt,$callback)); |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | protected $_compileParts; |
| 24 | 24 | protected $_toolbarPosition; |
| 25 | 25 | |
| 26 | - public function run(JsUtils $js){ |
|
| 27 | - if($this->_hasCheckboxes && isset($js)){ |
|
| 26 | + public function run(JsUtils $js) { |
|
| 27 | + if ($this->_hasCheckboxes && isset($js)) { |
|
| 28 | 28 | $js->execOn("change", "#".$this->identifier." [name='selection[]']", " |
| 29 | 29 | var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true; |
| 30 | 30 | \$checkbox.each(function() {if($(this).prop('checked')){allUnchecked = false;}else{allChecked = false;}}); |
@@ -33,18 +33,18 @@ discard block |
||
| 33 | 33 | parent::run($js); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 37 | - parent::__construct($identifier, $model,$modelInstance); |
|
| 36 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 37 | + parent::__construct($identifier, $model, $modelInstance); |
|
| 38 | 38 | $this->_instanceViewer=new InstanceViewer(); |
| 39 | - $this->content=["table"=>new HtmlTable($identifier, 0,0)]; |
|
| 39 | + $this->content=["table"=>new HtmlTable($identifier, 0, 0)]; |
|
| 40 | 40 | $this->_toolbarPosition=PositionInTable::BEFORETABLE; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 44 | - if(isset($this->_toolbar) && isset($this->_compileParts)===false){ |
|
| 45 | - if($this->_toolbarPosition===PositionInTable::BEFORETABLE){ |
|
| 43 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 44 | + if (isset($this->_toolbar) && isset($this->_compileParts)===false) { |
|
| 45 | + if ($this->_toolbarPosition===PositionInTable::BEFORETABLE) { |
|
| 46 | 46 | $this->content["before"]=$this->_toolbar; |
| 47 | - }elseif($this->_toolbarPosition===PositionInTable::BEFORETABLE){ |
|
| 47 | + }elseif ($this->_toolbarPosition===PositionInTable::BEFORETABLE) { |
|
| 48 | 48 | $this->content["after"]=$this->_toolbar; |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | $table=$this->content["table"]; |
| 56 | 56 | //$table=new HtmlTable($identifier, 0, 0); |
| 57 | - if($this->_hasCheckboxes){ |
|
| 58 | - $ck=new HtmlCheckbox("main-ck-".$this->identifier,""); |
|
| 57 | + if ($this->_hasCheckboxes) { |
|
| 58 | + $ck=new HtmlCheckbox("main-ck-".$this->identifier, ""); |
|
| 59 | 59 | $ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);"); |
| 60 | 60 | $ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);"); |
| 61 | 61 | \array_unshift($captions, $ck); |
@@ -63,56 +63,56 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | $table->setRowCount(0, \sizeof($captions)); |
| 65 | 65 | $table->setHeaderValues($captions); |
| 66 | - if(isset($this->_compileParts)) |
|
| 66 | + if (isset($this->_compileParts)) |
|
| 67 | 67 | $table->setCompileParts($this->_compileParts); |
| 68 | - if(isset($this->_searchField)){ |
|
| 69 | - if(isset($js)) |
|
| 70 | - $this->_searchField->postOn("change", $this->_searchUrl,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
|
| 68 | + if (isset($this->_searchField)) { |
|
| 69 | + if (isset($js)) |
|
| 70 | + $this->_searchField->postOn("change", $this->_searchUrl, "{'s':$(this).val()}", "-#".$this->identifier." tbody", ["preventDefault"=>false]); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $objects=$this->_modelInstance; |
| 74 | - if(isset($this->_pagination)){ |
|
| 74 | + if (isset($this->_pagination)) { |
|
| 75 | 75 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
| 76 | 76 | } |
| 77 | 77 | InstanceViewer::setIndex(0); |
| 78 | - $table->fromDatabaseObjects($objects, function($instance){ |
|
| 78 | + $table->fromDatabaseObjects($objects, function($instance) { |
|
| 79 | 79 | $this->_instanceViewer->setInstance($instance); |
| 80 | - $result= $this->_instanceViewer->getValues(); |
|
| 81 | - if($this->_hasCheckboxes){ |
|
| 82 | - $ck=new HtmlCheckbox("ck-".$this->identifier,""); |
|
| 80 | + $result=$this->_instanceViewer->getValues(); |
|
| 81 | + if ($this->_hasCheckboxes) { |
|
| 82 | + $ck=new HtmlCheckbox("ck-".$this->identifier, ""); |
|
| 83 | 83 | $field=$ck->getField(); |
| 84 | - $field->setProperty("value",$this->_instanceViewer->getCkValue()); |
|
| 84 | + $field->setProperty("value", $this->_instanceViewer->getCkValue()); |
|
| 85 | 85 | $field->setProperty("name", "selection[]"); |
| 86 | 86 | \array_unshift($result, $ck); |
| 87 | 87 | } |
| 88 | 88 | return $result; |
| 89 | 89 | }); |
| 90 | - if($this->_hasCheckboxes){ |
|
| 91 | - if($table->hasPart("thead")) |
|
| 92 | - $table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort"); |
|
| 90 | + if ($this->_hasCheckboxes) { |
|
| 91 | + if ($table->hasPart("thead")) |
|
| 92 | + $table->getHeader()->getCell(0, 0)->addToProperty("class", "no-sort"); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
| 95 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
| 96 | 96 | $footer=$table->getFooter(); |
| 97 | 97 | $footer->mergeCol(); |
| 98 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
| 98 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
| 99 | 99 | $menu->floatRight(); |
| 100 | 100 | $menu->setActiveItem($this->_pagination->getPage()-1); |
| 101 | 101 | $footer->setValues($menu); |
| 102 | - $menu->postOnClick($this->_searchUrl,"{'p':$(this).attr('data-page')}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
|
| 102 | + $menu->postOnClick($this->_searchUrl, "{'p':$(this).attr('data-page')}", "-#".$this->identifier." tbody", ["preventDefault"=>false]); |
|
| 103 | 103 | } |
| 104 | - if(isset($this->_toolbar)){ |
|
| 105 | - if($this->_toolbarPosition===PositionInTable::FOOTER) |
|
| 106 | - $this->addToolbarRow("tfoot",$table, $captions); |
|
| 107 | - elseif($this->_toolbarPosition===PositionInTable::HEADER){ |
|
| 108 | - $this->addToolbarRow("thead",$table, $captions); |
|
| 104 | + if (isset($this->_toolbar)) { |
|
| 105 | + if ($this->_toolbarPosition===PositionInTable::FOOTER) |
|
| 106 | + $this->addToolbarRow("tfoot", $table, $captions); |
|
| 107 | + elseif ($this->_toolbarPosition===PositionInTable::HEADER) { |
|
| 108 | + $this->addToolbarRow("thead", $table, $captions); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | - $this->content=JArray::sortAssociative($this->content, ["before","table","after"]); |
|
| 112 | - return parent::compile($js,$view); |
|
| 111 | + $this->content=JArray::sortAssociative($this->content, ["before", "table", "after"]); |
|
| 112 | + return parent::compile($js, $view); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - private function addToolbarRow($part,$table,$captions){ |
|
| 115 | + private function addToolbarRow($part, $table, $captions) { |
|
| 116 | 116 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 117 | 117 | $row->mergeCol(); |
| 118 | 118 | $row->setValues([$this->_toolbar]); |
@@ -127,42 +127,42 @@ discard block |
||
| 127 | 127 | return $this; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public function setCaptions($captions){ |
|
| 130 | + public function setCaptions($captions) { |
|
| 131 | 131 | $this->_instanceViewer->setCaptions($captions); |
| 132 | 132 | return $this; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - public function setFields($fields){ |
|
| 135 | + public function setFields($fields) { |
|
| 136 | 136 | $this->_instanceViewer->setVisibleProperties($fields); |
| 137 | 137 | return $this; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - public function addField($field){ |
|
| 140 | + public function addField($field) { |
|
| 141 | 141 | $this->_instanceViewer->addField($field); |
| 142 | 142 | return $this; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - public function insertField($index,$field){ |
|
| 145 | + public function insertField($index, $field) { |
|
| 146 | 146 | $this->_instanceViewer->insertField($index, $field); |
| 147 | 147 | return $this; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - public function insertInField($index,$field){ |
|
| 150 | + public function insertInField($index, $field) { |
|
| 151 | 151 | $this->_instanceViewer->insertInField($index, $field); |
| 152 | 152 | return $this; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - public function setValueFunction($index,$callback){ |
|
| 155 | + public function setValueFunction($index, $callback) { |
|
| 156 | 156 | $this->_instanceViewer->setValueFunction($index, $callback); |
| 157 | 157 | return $this; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function setCkValueFunction($callback){ |
|
| 160 | + public function setCkValueFunction($callback) { |
|
| 161 | 161 | $this->_instanceViewer->setCkValueFunction($callback); |
| 162 | 162 | return $this; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - public function getHtmlComponent(){ |
|
| 165 | + public function getHtmlComponent() { |
|
| 166 | 166 | return $this->content["table"]; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -175,8 +175,8 @@ discard block |
||
| 175 | 175 | return $this; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - public function paginate($items_per_page=10,$page=1){ |
|
| 179 | - $this->_pagination=new Pagination($items_per_page,4,$page); |
|
| 178 | + public function paginate($items_per_page=10, $page=1) { |
|
| 179 | + $this->_pagination=new Pagination($items_per_page, 4, $page); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | public function getHasCheckboxes() { |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | return $this; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - public function refresh($compileParts=["tbody"]){ |
|
| 191 | + public function refresh($compileParts=["tbody"]) { |
|
| 192 | 192 | $this->_compileParts=$compileParts; |
| 193 | 193 | return $this; |
| 194 | 194 | } |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | * @param callable $callback |
| 198 | 198 | * @return callable |
| 199 | 199 | */ |
| 200 | - private function getFieldButtonCallable($caption,$callback=null){ |
|
| 201 | - return $this->getCallable($this->getFieldButton($caption),$callback); |
|
| 200 | + private function getFieldButtonCallable($caption, $callback=null) { |
|
| 201 | + return $this->getCallable($this->getFieldButton($caption), $callback); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -206,11 +206,11 @@ discard block |
||
| 206 | 206 | * @param callable $callback |
| 207 | 207 | * @return callable |
| 208 | 208 | */ |
| 209 | - private function getCallable($object,$callback=null){ |
|
| 210 | - $result=function($instance) use($object,$callback){ |
|
| 211 | - if(isset($callback)){ |
|
| 212 | - if(\is_callable($callback)){ |
|
| 213 | - $callback($object,$instance); |
|
| 209 | + private function getCallable($object, $callback=null) { |
|
| 210 | + $result=function($instance) use($object, $callback){ |
|
| 211 | + if (isset($callback)) { |
|
| 212 | + if (\is_callable($callback)) { |
|
| 213 | + $callback($object, $instance); |
|
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | return $object; |
@@ -222,9 +222,9 @@ discard block |
||
| 222 | 222 | * @param string $caption |
| 223 | 223 | * @return HtmlButton |
| 224 | 224 | */ |
| 225 | - private function getFieldButton($caption){ |
|
| 226 | - $bt=new HtmlButton("",$caption); |
|
| 227 | - $bt->setProperty("data-ajax",$this->_instanceViewer->getCkValue()); |
|
| 225 | + private function getFieldButton($caption) { |
|
| 226 | + $bt=new HtmlButton("", $caption); |
|
| 227 | + $bt->setProperty("data-ajax", $this->_instanceViewer->getCkValue()); |
|
| 228 | 228 | return $bt; |
| 229 | 229 | } |
| 230 | 230 | |
@@ -234,8 +234,8 @@ discard block |
||
| 234 | 234 | * @param callable $callback |
| 235 | 235 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 236 | 236 | */ |
| 237 | - public function addFieldButton($caption,$callback=null){ |
|
| 238 | - $this->addField($this->getFieldButtonCallable($caption,$callback)); |
|
| 237 | + public function addFieldButton($caption, $callback=null) { |
|
| 238 | + $this->addField($this->getFieldButtonCallable($caption, $callback)); |
|
| 239 | 239 | return $this; |
| 240 | 240 | } |
| 241 | 241 | |
@@ -246,8 +246,8 @@ discard block |
||
| 246 | 246 | * @param callable $callback |
| 247 | 247 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 248 | 248 | */ |
| 249 | - public function insertFieldButton($index,$caption,$callback=null){ |
|
| 250 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$callback)); |
|
| 249 | + public function insertFieldButton($index, $caption, $callback=null) { |
|
| 250 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $callback)); |
|
| 251 | 251 | return $this; |
| 252 | 252 | } |
| 253 | 253 | |
@@ -258,48 +258,48 @@ discard block |
||
| 258 | 258 | * @param callable $callback |
| 259 | 259 | * @return \Ajax\semantic\widgets\datatable\DataTable |
| 260 | 260 | */ |
| 261 | - public function insertInFieldButton($index,$caption,$callback=null){ |
|
| 262 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$callback)); |
|
| 261 | + public function insertInFieldButton($index, $caption, $callback=null) { |
|
| 262 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $callback)); |
|
| 263 | 263 | return $this; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - private function addDefaultButton($icon,$class=null,$callback=null){ |
|
| 267 | - $bt=$this->getDefaultButton($icon,$class); |
|
| 268 | - $this->addField($this->getCallable($bt,$callback)); |
|
| 266 | + private function addDefaultButton($icon, $class=null, $callback=null) { |
|
| 267 | + $bt=$this->getDefaultButton($icon, $class); |
|
| 268 | + $this->addField($this->getCallable($bt, $callback)); |
|
| 269 | 269 | return $this; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){ |
|
| 273 | - $bt=$this->getDefaultButton($icon,$class); |
|
| 274 | - $this->insertInField($index,$this->getCallable($bt,$callback)); |
|
| 272 | + private function insertDefaultButtonIn($index, $icon, $class=null, $callback=null) { |
|
| 273 | + $bt=$this->getDefaultButton($icon, $class); |
|
| 274 | + $this->insertInField($index, $this->getCallable($bt, $callback)); |
|
| 275 | 275 | return $this; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - private function getDefaultButton($icon,$class=null){ |
|
| 278 | + private function getDefaultButton($icon, $class=null) { |
|
| 279 | 279 | $bt=$this->getFieldButton(""); |
| 280 | 280 | $bt->asIcon($icon); |
| 281 | - if(isset($class)) |
|
| 281 | + if (isset($class)) |
|
| 282 | 282 | $bt->addToProperty("class", $class); |
| 283 | 283 | return $bt; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - public function addDeleteButton($callback=null){ |
|
| 287 | - return $this->addDefaultButton("remove","delete red basic",$callback); |
|
| 286 | + public function addDeleteButton($callback=null) { |
|
| 287 | + return $this->addDefaultButton("remove", "delete red basic", $callback); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - public function addEditButton($callback=null){ |
|
| 291 | - return $this->addDefaultButton("edit","edit basic",$callback); |
|
| 290 | + public function addEditButton($callback=null) { |
|
| 291 | + return $this->addDefaultButton("edit", "edit basic", $callback); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - public function insertDeleteButtonIn($index,$callback=null){ |
|
| 295 | - return $this->insertDefaultButtonIn($index,"remove","delete red basic",$callback); |
|
| 294 | + public function insertDeleteButtonIn($index, $callback=null) { |
|
| 295 | + return $this->insertDefaultButtonIn($index, "remove", "delete red basic", $callback); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - public function insertEditButtonIn($index,$callback=null){ |
|
| 299 | - return $this->insertDefaultButtonIn($index,"edit","edit basic",$callback); |
|
| 298 | + public function insertEditButtonIn($index, $callback=null) { |
|
| 299 | + return $this->insertDefaultButtonIn($index, "edit", "edit basic", $callback); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - public function setSelectable(){ |
|
| 302 | + public function setSelectable() { |
|
| 303 | 303 | $this->content["table"]->setSelectable(); |
| 304 | 304 | return $this; |
| 305 | 305 | } |
@@ -307,8 +307,8 @@ discard block |
||
| 307 | 307 | /** |
| 308 | 308 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
| 309 | 309 | */ |
| 310 | - public function getToolbar(){ |
|
| 311 | - if(isset($this->_toolbar)===false){ |
|
| 310 | + public function getToolbar() { |
|
| 311 | + if (isset($this->_toolbar)===false) { |
|
| 312 | 312 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
| 313 | 313 | $this->_toolbar->setSecondary(); |
| 314 | 314 | } |
@@ -319,37 +319,37 @@ discard block |
||
| 319 | 319 | * @param unknown $element |
| 320 | 320 | * @return \Ajax\common\html\HtmlDoubleElement |
| 321 | 321 | */ |
| 322 | - public function addInToolbar($element){ |
|
| 322 | + public function addInToolbar($element) { |
|
| 323 | 323 | $tb=$this->getToolbar(); |
| 324 | 324 | return $tb->addItem($element); |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - public function addItemInToolbar($caption,$icon=NULL){ |
|
| 327 | + public function addItemInToolbar($caption, $icon=NULL) { |
|
| 328 | 328 | $result=$this->addInToolbar($caption); |
| 329 | 329 | $result->addIcon($icon); |
| 330 | 330 | return $result; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - public function addButtonInToolbar($caption){ |
|
| 334 | - $bt=new HtmlButton("",$caption); |
|
| 333 | + public function addButtonInToolbar($caption) { |
|
| 334 | + $bt=new HtmlButton("", $caption); |
|
| 335 | 335 | return $this->addInToolbar($bt); |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
| 339 | - $bt=new HtmlButton("",$caption); |
|
| 340 | - $bt->addIcon($icon,$before,$labeled); |
|
| 338 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
| 339 | + $bt=new HtmlButton("", $caption); |
|
| 340 | + $bt->addIcon($icon, $before, $labeled); |
|
| 341 | 341 | return $this->addInToolbar($bt); |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | |
| 345 | - public function addSearchInToolbar(){ |
|
| 345 | + public function addSearchInToolbar() { |
|
| 346 | 346 | return $this->addInToolbar($this->getSearchField())->setPosition("right"); |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - public function getSearchField(){ |
|
| 350 | - if(isset($this->_searchField)===false){ |
|
| 351 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
| 352 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
| 349 | + public function getSearchField() { |
|
| 350 | + if (isset($this->_searchField)===false) { |
|
| 351 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
| 352 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
| 353 | 353 | } |
| 354 | 354 | return $this->_searchField; |
| 355 | 355 | } |
@@ -10,15 +10,15 @@ discard block |
||
| 10 | 10 | protected $_modelInstance; |
| 11 | 11 | protected $_instanceViewer; |
| 12 | 12 | |
| 13 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 13 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 14 | 14 | parent::__construct($identifier); |
| 15 | 15 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
| 16 | 16 | $this->setModel($model); |
| 17 | - if(isset($modelInstance)); |
|
| 17 | + if (isset($modelInstance)); |
|
| 18 | 18 | $this->show($modelInstance); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function show($modelInstance){ |
|
| 21 | + public function show($modelInstance) { |
|
| 22 | 22 | $this->_modelInstance=$modelInstance; |
| 23 | 23 | } |
| 24 | 24 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public abstract function getHtmlComponent(); |
| 44 | 44 | |
| 45 | - public function setColor($color){ |
|
| 45 | + public function setColor($color) { |
|
| 46 | 46 | return $this->getHtmlComponent()->setColor($color); |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | \ No newline at end of file |
@@ -17,18 +17,18 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public function __construct(JsUtils $js) { |
| 19 | 19 | parent::__construct($js); |
| 20 | - $this->events=array (); |
|
| 20 | + $this->events=array(); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | protected function compileEvents() { |
| 24 | - foreach ( $this->events as $event => $jsCode ) { |
|
| 25 | - if($event=="execute"){ |
|
| 24 | + foreach ($this->events as $event => $jsCode) { |
|
| 25 | + if ($event=="execute") { |
|
| 26 | 26 | $this->jquery_code_for_compile []=$jsCode; |
| 27 | - }else if($event=="beforeExecute"){ |
|
| 27 | + } else if ($event=="beforeExecute") { |
|
| 28 | 28 | \array_unshift($this->jquery_code_for_compile, $jsCode); |
| 29 | - }else{ |
|
| 29 | + } else { |
|
| 30 | 30 | $selector=$this->attachTo; |
| 31 | - if(isset($this->itemSelector)){ |
|
| 31 | + if (isset($this->itemSelector)) { |
|
| 32 | 32 | $selector.=" ".$this->itemSelector; |
| 33 | 33 | } |
| 34 | 34 | $this->jquery_code_for_compile []="$( \"".$selector."\" ).on(\"".$event."\" , function( event, data ) {".$jsCode."});"; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | $result=implode("\n", $this->jquery_code_for_compile); |
| 41 | 41 | $result=str_ireplace("\"%", "", $result); |
| 42 | 42 | $result=str_ireplace("%\"", "", $result); |
| 43 | - $result=str_replace(array ( |
|
| 43 | + $result=str_replace(array( |
|
| 44 | 44 | "\\n", |
| 45 | 45 | "\\r", |
| 46 | 46 | "\\t" |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | public function getScript() { |
| 52 | 52 | $allParams=$this->params; |
| 53 | - $this->jquery_code_for_compile=array (); |
|
| 53 | + $this->jquery_code_for_compile=array(); |
|
| 54 | 54 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).");"; |
| 55 | 55 | $this->compileEvents(); |
| 56 | 56 | return $this->compileJQueryCode(); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
| 16 | 16 | |
| 17 | 17 | public abstract function _prep_value($value); |
| 18 | - public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
| 18 | + public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
| 19 | 19 | protected function addLoading(&$retour, $responseElement) { |
| 20 | 20 | $loading_notifier='<div class="ajax-loader">'; |
| 21 | 21 | if ($this->ajaxLoader=='') { |
@@ -28,20 +28,20 @@ discard block |
||
| 28 | 28 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 32 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
| 31 | + public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 32 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
| 33 | 33 | } |
| 34 | - public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 35 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
| 34 | + public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 35 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 39 | - if(JString::isNull($params)){$params="{}";} |
|
| 38 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 39 | + if (JString::isNull($params)) {$params="{}"; } |
|
| 40 | 40 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 41 | 41 | $retour=$this->_getAjaxUrl($url, $attr); |
| 42 | 42 | $responseElement=$this->_getResponseElement($responseElement); |
| 43 | 43 | $retour.="var self=this;\n"; |
| 44 | - if($hasLoader===true){ |
|
| 44 | + if ($hasLoader===true) { |
|
| 45 | 45 | $this->addLoading($retour, $responseElement); |
| 46 | 46 | } |
| 47 | 47 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
@@ -51,30 +51,30 @@ discard block |
||
| 51 | 51 | return $retour; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - protected function _getAjaxUrl($url,$attr){ |
|
| 54 | + protected function _getAjaxUrl($url, $attr) { |
|
| 55 | 55 | $url=$this->_correctAjaxUrl($url); |
| 56 | 56 | $retour="url='".$url."';\n"; |
| 57 | 57 | $slash="/"; |
| 58 | - if(JString::endswith($url, "/")===true) |
|
| 58 | + if (JString::endswith($url, "/")===true) |
|
| 59 | 59 | $slash=""; |
| 60 | - if(JString::isNotNull($attr)){ |
|
| 60 | + if (JString::isNotNull($attr)) { |
|
| 61 | 61 | if ($attr==="value") |
| 62 | 62 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
| 63 | 63 | elseif ($attr==="html") |
| 64 | 64 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
| 65 | - elseif($attr!=null && $attr!=="") |
|
| 65 | + elseif ($attr!=null && $attr!=="") |
|
| 66 | 66 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
| 67 | 67 | } |
| 68 | 68 | return $retour; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - protected function _getOnAjaxDone($responseElement,$jsCallback){ |
|
| 71 | + protected function _getOnAjaxDone($responseElement, $jsCallback) { |
|
| 72 | 72 | $retour=""; |
| 73 | 73 | if ($responseElement!=="") { |
| 74 | - if(JString::startswith($responseElement, "\"-")===true){ |
|
| 74 | + if (JString::startswith($responseElement, "\"-")===true) { |
|
| 75 | 75 | $responseElement=\str_replace("\"-", "\"", $responseElement); |
| 76 | 76 | $retour="\t$({$responseElement}).replaceWith( data );\n"; |
| 77 | - }else{ |
|
| 77 | + } else { |
|
| 78 | 78 | $retour="\t$({$responseElement}).html( data );\n"; |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | return $retour; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - protected function _getResponseElement($responseElement){ |
|
| 85 | + protected function _getResponseElement($responseElement) { |
|
| 86 | 86 | if ($responseElement!=="") { |
| 87 | 87 | $responseElement=$this->_prep_value($responseElement); |
| 88 | 88 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | protected function _correctAjaxUrl($url) { |
| 93 | 93 | if ($url!=="/" && JString::endsWith($url, "/")===true) |
| 94 | 94 | $url=substr($url, 0, strlen($url)-1); |
| 95 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
| 95 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
| 96 | 96 | $url=$this->jsUtils->getUrl($url); |
| 97 | 97 | } |
| 98 | 98 | return $url; |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param string $jsCallback javascript code to execute after the request |
| 107 | 107 | * @param boolean $immediatly |
| 108 | 108 | */ |
| 109 | - public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
| 109 | + public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
| 110 | 110 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 111 | 111 | $retour=$this->_getAjaxUrl($url, $attr); |
| 112 | 112 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @param string $url the request address |
| 128 | 128 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
| 129 | 129 | */ |
| 130 | - public function _jsonOn($event,$element, $url,$parameters=array()) { |
|
| 130 | + public function _jsonOn($event, $element, $url, $parameters=array()) { |
|
| 131 | 131 | $preventDefault=true; |
| 132 | 132 | $stopPropagation=true; |
| 133 | 133 | $jsCallback=null; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $params="{}"; |
| 138 | 138 | $immediatly=true; |
| 139 | 139 | extract($parameters); |
| 140 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 140 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -149,19 +149,19 @@ discard block |
||
| 149 | 149 | * @param string $context jquery DOM element, array container. |
| 150 | 150 | * @param boolean $immediatly |
| 151 | 151 | */ |
| 152 | - public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$immediatly=false) { |
|
| 152 | + public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $immediatly=false) { |
|
| 153 | 153 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 154 | 154 | $retour=$this->_getAjaxUrl($url, $attr); |
| 155 | - if($context===null){ |
|
| 155 | + if ($context===null) { |
|
| 156 | 156 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
| 157 | - $newElm = "$('#'+newId)"; |
|
| 158 | - }else{ |
|
| 157 | + $newElm="$('#'+newId)"; |
|
| 158 | + } else { |
|
| 159 | 159 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
| 160 | - $newElm = $context.".find('#'+newId)"; |
|
| 160 | + $newElm=$context.".find('#'+newId)"; |
|
| 161 | 161 | } |
| 162 | 162 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
| 163 | 163 | $retour.="\tdata=$.parseJSON(data);$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone();newElm.attr('id',newId);\n"; |
| 164 | - $retour.= $appendTo; |
|
| 164 | + $retour.=$appendTo; |
|
| 165 | 165 | $retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('[['+key+']]')>-1){\n"."\t\t\t\tcontent=$(html.split('[['+key+']]').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n"; |
| 166 | 166 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 167 | 167 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -176,26 +176,26 @@ discard block |
||
| 176 | 176 | * @param string $url the request address |
| 177 | 177 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null) |
| 178 | 178 | */ |
| 179 | - public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) { |
|
| 179 | + public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
| 180 | 180 | $preventDefault=true; |
| 181 | 181 | $stopPropagation=true; |
| 182 | 182 | $jsCallback=null; |
| 183 | 183 | $attr="id"; |
| 184 | 184 | $method="get"; |
| 185 | - $context = null; |
|
| 185 | + $context=null; |
|
| 186 | 186 | $params="{}"; |
| 187 | 187 | $immediatly=true; |
| 188 | 188 | extract($parameters); |
| 189 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 189 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 192 | + public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 193 | 193 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 194 | 194 | $retour=$this->_getAjaxUrl($url, $attr); |
| 195 | 195 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
| 196 | 196 | $responseElement=$this->_getResponseElement($responseElement); |
| 197 | 197 | $retour.="var self=this;\n"; |
| 198 | - if($hasLoader===true){ |
|
| 198 | + if ($hasLoader===true) { |
|
| 199 | 199 | $this->addLoading($retour, $responseElement); |
| 200 | 200 | } |
| 201 | 201 | $retour.="$.post(url,params).done(function( data ) {\n"; |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | * @param string $responseElement |
| 223 | 223 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 224 | 224 | */ |
| 225 | - public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 225 | + public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 226 | 226 | $preventDefault=true; |
| 227 | 227 | $stopPropagation=true; |
| 228 | 228 | $jsCallback=null; |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | $hasLoader=true; |
| 231 | 231 | $immediatly=true; |
| 232 | 232 | extract($parameters); |
| 233 | - return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 233 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @param string $responseElement |
| 244 | 244 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 245 | 245 | */ |
| 246 | - public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 246 | + public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 247 | 247 | $preventDefault=true; |
| 248 | 248 | $stopPropagation=true; |
| 249 | 249 | $jsCallback=null; |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | $hasLoader=true; |
| 252 | 252 | $immediatly=true; |
| 253 | 253 | extract($parameters); |
| 254 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 254 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | * @param string $responseElement |
| 265 | 265 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true) |
| 266 | 266 | */ |
| 267 | - public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 267 | + public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 268 | 268 | $preventDefault=true; |
| 269 | 269 | $stopPropagation=true; |
| 270 | 270 | $validation=false; |
@@ -273,6 +273,6 @@ discard block |
||
| 273 | 273 | $hasLoader=true; |
| 274 | 274 | $immediatly=true; |
| 275 | 275 | extract($parameters); |
| 276 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 276 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | \ No newline at end of file |
@@ -8,34 +8,34 @@ discard block |
||
| 8 | 8 | private $page_count; |
| 9 | 9 | private $pages_visibles; |
| 10 | 10 | |
| 11 | - public function __construct($items_per_page=10,$pages_visibles=4,$page=1){ |
|
| 11 | + public function __construct($items_per_page=10, $pages_visibles=4, $page=1) { |
|
| 12 | 12 | $this->items_per_page=$items_per_page; |
| 13 | 13 | $this->page=$page; |
| 14 | 14 | $this->pages_visibles=$pages_visibles; |
| 15 | 15 | $this->visible=true; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public function getObjects($objects){ |
|
| 19 | - $offset = ($this->page - 1) * $this->items_per_page; |
|
| 18 | + public function getObjects($objects) { |
|
| 19 | + $offset=($this->page-1)*$this->items_per_page; |
|
| 20 | 20 | $os=$objects; |
| 21 | - if(\is_array($os)===false){ |
|
| 21 | + if (\is_array($os)===false) { |
|
| 22 | 22 | $os=[]; |
| 23 | - foreach ($objects as $o){ |
|
| 23 | + foreach ($objects as $o) { |
|
| 24 | 24 | $os[]=$o; |
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | - $this->page_count = 0; |
|
| 27 | + $this->page_count=0; |
|
| 28 | 28 | $row_count=\sizeof($os); |
| 29 | - if (0 === $row_count) { |
|
| 29 | + if (0===$row_count) { |
|
| 30 | 30 | $this->visible=false; |
| 31 | 31 | } else { |
| 32 | 32 | $this->visible=true; |
| 33 | - $this->page_count = (int)ceil($row_count / $this->items_per_page); |
|
| 34 | - if($this->page > $this->page_count+1) { |
|
| 35 | - $this->page = 1; |
|
| 33 | + $this->page_count=(int)ceil($row_count/$this->items_per_page); |
|
| 34 | + if ($this->page>$this->page_count+1) { |
|
| 35 | + $this->page=1; |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | - return array_slice($os, $offset,$this->items_per_page); |
|
| 38 | + return array_slice($os, $offset, $this->items_per_page); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function getItemsPerPage() { |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | return $this->page_count; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - public function getPagesNumbers(){ |
|
| 73 | - $middle= (int)ceil(($this->pages_visibles-1)/ 2); |
|
| 72 | + public function getPagesNumbers() { |
|
| 73 | + $middle=(int)ceil(($this->pages_visibles-1)/2); |
|
| 74 | 74 | $first=$this->page-$middle; |
| 75 | - if($first<1){ |
|
| 75 | + if ($first<1) { |
|
| 76 | 76 | $first=1; |
| 77 | 77 | } |
| 78 | 78 | $last=$first+$this->pages_visibles-1; |
| 79 | - if($last>$this->page_count){ |
|
| 79 | + if ($last>$this->page_count) { |
|
| 80 | 80 | $last=$this->page_count; |
| 81 | 81 | } |
| 82 | 82 | return \range($first, $last); |
@@ -11,21 +11,21 @@ discard block |
||
| 11 | 11 | private $values; |
| 12 | 12 | private static $index=0; |
| 13 | 13 | |
| 14 | - public function __construct($instance=NULL,$captions=NULL){ |
|
| 14 | + public function __construct($instance=NULL, $captions=NULL) { |
|
| 15 | 15 | $this->values=[]; |
| 16 | - if(isset($instance)) |
|
| 16 | + if (isset($instance)) |
|
| 17 | 17 | $this->setInstance($instance); |
| 18 | 18 | $this->setCaptions($captions); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function getCaption($index){ |
|
| 21 | + public function getCaption($index) { |
|
| 22 | 22 | return $this->properties[$index]->getName(); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function getCaptions(){ |
|
| 26 | - if(isset($this->captions)){ |
|
| 27 | - $result= $this->captions; |
|
| 28 | - for($i=\sizeof($result);$i<$this->count();$i++){ |
|
| 25 | + public function getCaptions() { |
|
| 26 | + if (isset($this->captions)) { |
|
| 27 | + $result=$this->captions; |
|
| 28 | + for ($i=\sizeof($result); $i<$this->count(); $i++) { |
|
| 29 | 29 | $result[]=""; |
| 30 | 30 | } |
| 31 | 31 | return $result; |
@@ -33,113 +33,113 @@ discard block |
||
| 33 | 33 | $captions=[]; |
| 34 | 34 | $index=0; |
| 35 | 35 | $count=$this->count(); |
| 36 | - while($index<$count){ |
|
| 36 | + while ($index<$count) { |
|
| 37 | 37 | $captions[]=$this->getCaption($index++); |
| 38 | 38 | } |
| 39 | 39 | return $captions; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function getValues(){ |
|
| 42 | + public function getValues() { |
|
| 43 | 43 | $values=[]; |
| 44 | 44 | $index=0; |
| 45 | 45 | $count=$this->count(); |
| 46 | - while($index<$count){ |
|
| 46 | + while ($index<$count) { |
|
| 47 | 47 | $values[]=$this->getValue($index++); |
| 48 | 48 | } |
| 49 | 49 | return $values; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function getCkValue(){ |
|
| 52 | + public function getCkValue() { |
|
| 53 | 53 | $value=self::$index; |
| 54 | - if(isset($this->values["ck"])) |
|
| 55 | - $value=$this->values["ck"](self::$index,$this->instance); |
|
| 54 | + if (isset($this->values["ck"])) |
|
| 55 | + $value=$this->values["ck"](self::$index, $this->instance); |
|
| 56 | 56 | self::$index++; |
| 57 | 57 | return $value; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function getValue($index){ |
|
| 60 | + public function getValue($index) { |
|
| 61 | 61 | $property=$this->properties[$index]; |
| 62 | 62 | return $this->_getValue($property, $index); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - private function _getValue($property,$index){ |
|
| 66 | - if($property instanceof \ReflectionProperty){ |
|
| 65 | + private function _getValue($property, $index) { |
|
| 66 | + if ($property instanceof \ReflectionProperty) { |
|
| 67 | 67 | $property->setAccessible(true); |
| 68 | 68 | $value=$property->getValue($this->instance); |
| 69 | - if(isset($this->values[$index])){ |
|
| 70 | - $value= $this->values[$index]($value); |
|
| 69 | + if (isset($this->values[$index])) { |
|
| 70 | + $value=$this->values[$index]($value); |
|
| 71 | 71 | } |
| 72 | - }else{ |
|
| 73 | - if(\is_callable($property)) |
|
| 72 | + } else { |
|
| 73 | + if (\is_callable($property)) |
|
| 74 | 74 | $value=$property($this->instance); |
| 75 | - elseif(\is_array($property)){ |
|
| 76 | - $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
|
| 75 | + elseif (\is_array($property)) { |
|
| 76 | + $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property); |
|
| 77 | 77 | $value=\implode("", $values); |
| 78 | - }else |
|
| 78 | + } else |
|
| 79 | 79 | $value=$property; |
| 80 | 80 | } |
| 81 | 81 | return $value; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - public function insertField($index,$field){ |
|
| 85 | - array_splice( $this->visibleProperties, $index, 0, $field ); |
|
| 84 | + public function insertField($index, $field) { |
|
| 85 | + array_splice($this->visibleProperties, $index, 0, $field); |
|
| 86 | 86 | return $this; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - public function insertInField($index,$field){ |
|
| 89 | + public function insertInField($index, $field) { |
|
| 90 | 90 | $vb=$this->visibleProperties; |
| 91 | - if(isset($vb[$index])){ |
|
| 92 | - if(\is_array($vb[$index])){ |
|
| 91 | + if (isset($vb[$index])) { |
|
| 92 | + if (\is_array($vb[$index])) { |
|
| 93 | 93 | $this->visibleProperties[$index][]=$field; |
| 94 | - }else{ |
|
| 95 | - $this->visibleProperties[$index]=[$vb[$index],$field]; |
|
| 94 | + } else { |
|
| 95 | + $this->visibleProperties[$index]=[$vb[$index], $field]; |
|
| 96 | 96 | } |
| 97 | - }else{ |
|
| 97 | + } else { |
|
| 98 | 98 | return $this->insertField($index, $field); |
| 99 | 99 | } |
| 100 | 100 | return $this; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - public function addField($field){ |
|
| 103 | + public function addField($field) { |
|
| 104 | 104 | $this->visibleProperties[]=$field; |
| 105 | 105 | return $this; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public function count(){ |
|
| 108 | + public function count() { |
|
| 109 | 109 | return \sizeof($this->properties); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - private function showableProperty(\ReflectionProperty $rProperty){ |
|
| 113 | - return JString::startswith($rProperty->getName(),"_")===false; |
|
| 112 | + private function showableProperty(\ReflectionProperty $rProperty) { |
|
| 113 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | public function setInstance($instance) { |
| 117 | - if(\is_string($instance)){ |
|
| 117 | + if (\is_string($instance)) { |
|
| 118 | 118 | $instance=new $instance(); |
| 119 | 119 | } |
| 120 | 120 | $this->instance=$instance; |
| 121 | 121 | $this->properties=[]; |
| 122 | 122 | $this->reflect=new \ReflectionClass($instance); |
| 123 | - if(\sizeof($this->visibleProperties)===0){ |
|
| 123 | + if (\sizeof($this->visibleProperties)===0) { |
|
| 124 | 124 | $this->properties=$this->getDefaultProperties(); |
| 125 | - }else{ |
|
| 126 | - foreach ($this->visibleProperties as $property){ |
|
| 127 | - if(\is_callable($property)){ |
|
| 125 | + } else { |
|
| 126 | + foreach ($this->visibleProperties as $property) { |
|
| 127 | + if (\is_callable($property)) { |
|
| 128 | 128 | $this->properties[]=$property; |
| 129 | - }elseif(\is_string($property)){ |
|
| 130 | - try{ |
|
| 129 | + }elseif (\is_string($property)) { |
|
| 130 | + try { |
|
| 131 | 131 | $rProperty=$this->reflect->getProperty($property); |
| 132 | 132 | $this->properties[]=$rProperty; |
| 133 | - }catch(\Exception $e){ |
|
| 133 | + }catch (\Exception $e) { |
|
| 134 | 134 | $this->properties[]=$property; |
| 135 | 135 | } |
| 136 | - }elseif(\is_int($property)){ |
|
| 136 | + }elseif (\is_int($property)) { |
|
| 137 | 137 | $props=$this->getDefaultProperties(); |
| 138 | - if(isset($props[$property])) |
|
| 138 | + if (isset($props[$property])) |
|
| 139 | 139 | $this->properties[]=$props[$property]; |
| 140 | 140 | else |
| 141 | 141 | $this->properties[]=$property; |
| 142 | - }else{ |
|
| 142 | + } else { |
|
| 143 | 143 | $this->properties[]=$property; |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -147,12 +147,12 @@ discard block |
||
| 147 | 147 | return $this; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - private function getDefaultProperties(){ |
|
| 150 | + private function getDefaultProperties() { |
|
| 151 | 151 | $result=[]; |
| 152 | 152 | $properties=$this->reflect->getProperties(); |
| 153 | - foreach ($properties as $property){ |
|
| 153 | + foreach ($properties as $property) { |
|
| 154 | 154 | $showable=$this->showableProperty($property); |
| 155 | - if($showable!==false){ |
|
| 155 | + if ($showable!==false) { |
|
| 156 | 156 | $result[]=$property; |
| 157 | 157 | } |
| 158 | 158 | } |
@@ -169,12 +169,12 @@ discard block |
||
| 169 | 169 | return $this; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - public function setValueFunction($index,$callback){ |
|
| 172 | + public function setValueFunction($index, $callback) { |
|
| 173 | 173 | $this->values[$index]=$callback; |
| 174 | 174 | return $this; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - public function setCkValueFunction($callback){ |
|
| 177 | + public function setCkValueFunction($callback) { |
|
| 178 | 178 | $this->values["ck"]=$callback; |
| 179 | 179 | return $this; |
| 180 | 180 | } |
@@ -3,5 +3,5 @@ |
||
| 3 | 3 | use Ajax\common\BaseEnum; |
| 4 | 4 | |
| 5 | 5 | abstract class PositionInTable extends BaseEnum { |
| 6 | - const BEFORETABLE="beforeTable",AFTERTABLE="afterTable",HEADER="header",FOOTER="footer"; |
|
| 6 | + const BEFORETABLE="beforeTable", AFTERTABLE="afterTable", HEADER="header", FOOTER="footer"; |
|
| 7 | 7 | } |
| 8 | 8 | \ No newline at end of file |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | * @param array $instances |
| 14 | 14 | * @return DataTable |
| 15 | 15 | */ |
| 16 | - public function dataTable($identifier,$model, $instances){ |
|
| 17 | - return $this->addHtmlComponent(new DataTable($identifier,$model,$instances)); |
|
| 16 | + public function dataTable($identifier, $model, $instances) { |
|
| 17 | + return $this->addHtmlComponent(new DataTable($identifier, $model, $instances)); |
|
| 18 | 18 | } |
| 19 | 19 | } |
| 20 | 20 | \ No newline at end of file |