@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | * @property SimpleExtComponent $_bsComponent |
| 12 | 12 | * @property string identifier |
| 13 | 13 | */ |
| 14 | -trait BaseHtmlEventsTrait{ |
|
| 14 | +trait BaseHtmlEventsTrait { |
|
| 15 | 15 | |
| 16 | - protected $_events=array (); |
|
| 16 | + protected $_events=array(); |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * @param string $event |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | * @return \Ajax\common\html\BaseHtml |
| 24 | 24 | */ |
| 25 | 25 | public function addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
| 26 | - if ($stopPropagation === true) { |
|
| 27 | - $jsCode=Javascript::$stopPropagation . $jsCode; |
|
| 26 | + if ($stopPropagation===true) { |
|
| 27 | + $jsCode=Javascript::$stopPropagation.$jsCode; |
|
| 28 | 28 | } |
| 29 | - if ($preventDefault === true) { |
|
| 30 | - $jsCode=Javascript::$preventDefault . $jsCode; |
|
| 29 | + if ($preventDefault===true) { |
|
| 30 | + $jsCode=Javascript::$preventDefault.$jsCode; |
|
| 31 | 31 | } |
| 32 | 32 | return $this->_addEvent($event, $jsCode); |
| 33 | 33 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | if (\is_array($this->_events[$event])) { |
| 43 | 43 | $this->_events[$event][]=$jsCode; |
| 44 | 44 | } else { |
| 45 | - $this->_events[$event]=array ($this->_events[$event],$jsCode ); |
|
| 45 | + $this->_events[$event]=array($this->_events[$event], $jsCode); |
|
| 46 | 46 | } |
| 47 | 47 | } else { |
| 48 | 48 | $this->_events[$event]=$jsCode; |
@@ -69,10 +69,10 @@ discard block |
||
| 69 | 69 | return $this->onClick($jsCode); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - public function onCreate($jsCode){ |
|
| 73 | - if(isset($this->_events["_create"])){ |
|
| 72 | + public function onCreate($jsCode) { |
|
| 73 | + if (isset($this->_events["_create"])) { |
|
| 74 | 74 | $this->_events["_create"][]=$jsCode; |
| 75 | - }else{ |
|
| 75 | + } else { |
|
| 76 | 76 | $this->_events["_create"]=[$jsCode]; |
| 77 | 77 | } |
| 78 | 78 | return $this; |
@@ -81,15 +81,15 @@ discard block |
||
| 81 | 81 | public function addEventsOnRun(JsUtils $js=NULL) { |
| 82 | 82 | $this->_eventsOnCreate($js); |
| 83 | 83 | if (isset($this->_bsComponent)) { |
| 84 | - foreach ( $this->_events as $event => $jsCode ) { |
|
| 84 | + foreach ($this->_events as $event => $jsCode) { |
|
| 85 | 85 | $code=$jsCode; |
| 86 | 86 | if (\is_array($jsCode)) { |
| 87 | 87 | $code=""; |
| 88 | - foreach ( $jsCode as $jsC ) { |
|
| 88 | + foreach ($jsCode as $jsC) { |
|
| 89 | 89 | if ($jsC instanceof AjaxCall) { |
| 90 | - $code.="\n" . $jsC->compile($js); |
|
| 90 | + $code.="\n".$jsC->compile($js); |
|
| 91 | 91 | } else { |
| 92 | - $code.="\n" . $jsC; |
|
| 92 | + $code.="\n".$jsC; |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | } elseif ($jsCode instanceof AjaxCall) { |
@@ -97,18 +97,18 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | $this->_bsComponent->addEvent($event, $code); |
| 99 | 99 | } |
| 100 | - $this->_events=array (); |
|
| 100 | + $this->_events=array(); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - protected function _eventsOnCreate(JsUtils $js=NULL){ |
|
| 105 | - if(isset($this->_events["_create"])){ |
|
| 104 | + protected function _eventsOnCreate(JsUtils $js=NULL) { |
|
| 105 | + if (isset($this->_events["_create"])) { |
|
| 106 | 106 | $create=$this->_events["_create"]; |
| 107 | - if(\is_array($create)){ |
|
| 107 | + if (\is_array($create)) { |
|
| 108 | 108 | $create=\implode("", $create); |
| 109 | 109 | } |
| 110 | - if(isset($js) && $create!=="") |
|
| 111 | - $js->exec($create,true); |
|
| 110 | + if (isset($js) && $create!=="") |
|
| 111 | + $js->exec($create, true); |
|
| 112 | 112 | unset($this->_events["_create"]); |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @return BaseHtml |
| 123 | 123 | */ |
| 124 | 124 | public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) { |
| 125 | - $params=array ("url" => $url,"responseElement" => $responseElement ); |
|
| 125 | + $params=array("url" => $url, "responseElement" => $responseElement); |
|
| 126 | 126 | $params=array_merge($params, $parameters); |
| 127 | 127 | $this->_addEvent($event, new AjaxCall($operation, $params)); |
| 128 | 128 | return $this; |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | public function jsDoJquery($jqueryCall, $param="") { |
| 158 | - return "$('#" . $this->identifier . "')." . $jqueryCall . "(" . Javascript::prep_value($param) . ");"; |
|
| 158 | + return "$('#".$this->identifier."').".$jqueryCall."(".Javascript::prep_value($param).");"; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | public function executeOnRun($jsCode) { |
@@ -175,6 +175,6 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | public function jsToggle($value) { |
| 178 | - return $this->jsDoJquery("toggle",$value); |
|
| 178 | + return $this->jsDoJquery("toggle", $value); |
|
| 179 | 179 | } |
| 180 | 180 | } |
@@ -32,16 +32,16 @@ discard block |
||
| 32 | 32 | // } |
| 33 | 33 | $this->setWide($numCols); |
| 34 | 34 | } |
| 35 | - if($createCols) |
|
| 35 | + if ($createCols) |
|
| 36 | 36 | $this->setRowsCount($numRows, $numCols); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public function asSegment() { |
| 40 | - return $this->addToPropertyCtrl("class", "segment", array ("segment" )); |
|
| 40 | + return $this->addToPropertyCtrl("class", "segment", array("segment")); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public function asContainer() { |
| 44 | - return $this->addToPropertyCtrl("class", "container", array ("container" )); |
|
| 44 | + return $this->addToPropertyCtrl("class", "container", array("container")); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | * @param int $wide |
| 50 | 50 | */ |
| 51 | 51 | public function setWide($wide) { |
| 52 | - if(isset(Wide::getConstants()["W" . $wide])){ |
|
| 53 | - $wide=Wide::getConstants()["W" . $wide]; |
|
| 52 | + if (isset(Wide::getConstants()["W".$wide])) { |
|
| 53 | + $wide=Wide::getConstants()["W".$wide]; |
|
| 54 | 54 | $this->addToPropertyCtrl("class", $wide, Wide::getConstants()); |
| 55 | - return $this->addToPropertyCtrl("class", "column", array ("column" )); |
|
| 55 | + return $this->addToPropertyCtrl("class", "column", array("column")); |
|
| 56 | 56 | } |
| 57 | 57 | return $this; |
| 58 | 58 | } |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | * @return mixed |
| 73 | 73 | */ |
| 74 | 74 | public function addRow($colsCount=NULL) { |
| 75 | - $rowCount=$this->rowCount() + 1; |
|
| 75 | + $rowCount=$this->rowCount()+1; |
|
| 76 | 76 | $this->setRowsCount($rowCount, $colsCount, true); |
| 77 | - return $this->content[$rowCount - 1]; |
|
| 77 | + return $this->content[$rowCount-1]; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -83,10 +83,10 @@ discard block |
||
| 83 | 83 | * @return mixed|\Ajax\semantic\html\collections\HtmlGrid |
| 84 | 84 | */ |
| 85 | 85 | public function addCol($width=NULL) { |
| 86 | - $colCount=$this->colCount() + 1; |
|
| 86 | + $colCount=$this->colCount()+1; |
|
| 87 | 87 | $this->setColsCount($colCount, true, $width); |
| 88 | 88 | if ($this->hasOnlyCols($this->count())) |
| 89 | - return $this->content[$colCount - 1]; |
|
| 89 | + return $this->content[$colCount-1]; |
|
| 90 | 90 | return $this; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @return \Ajax\semantic\html\collections\HtmlGrid |
| 97 | 97 | */ |
| 98 | 98 | public function addCols($sizes=array()) { |
| 99 | - foreach ( $sizes as $size ) { |
|
| 99 | + foreach ($sizes as $size) { |
|
| 100 | 100 | $this->addCol($size); |
| 101 | 101 | } |
| 102 | 102 | return $this; |
@@ -110,19 +110,19 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function setRowsCount($rowsCount, $colsCount=NULL, $force=false) { |
| 112 | 112 | $count=$this->count(); |
| 113 | - if ($rowsCount < 2 && $force === false) { |
|
| 114 | - for($i=$count; $i < $colsCount; $i++) { |
|
| 115 | - $this->addItem(new HtmlGridCol("col-" . $this->identifier . "-" . $i)); |
|
| 113 | + if ($rowsCount<2 && $force===false) { |
|
| 114 | + for ($i=$count; $i<$colsCount; $i++) { |
|
| 115 | + $this->addItem(new HtmlGridCol("col-".$this->identifier."-".$i)); |
|
| 116 | 116 | } |
| 117 | 117 | } else { |
| 118 | 118 | if ($this->hasOnlyCols($count)) { |
| 119 | 119 | $tmpContent=$this->content; |
| 120 | 120 | $item=$this->addItem($colsCount); |
| 121 | 121 | $item->setContent($tmpContent); |
| 122 | - $this->content=array (); |
|
| 122 | + $this->content=array(); |
|
| 123 | 123 | $count=1; |
| 124 | 124 | } |
| 125 | - for($i=$count; $i < $rowsCount; $i++) { |
|
| 125 | + for ($i=$count; $i<$rowsCount; $i++) { |
|
| 126 | 126 | $this->addItem($colsCount); |
| 127 | 127 | } |
| 128 | 128 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | protected function hasOnlyCols($count) { |
| 133 | - return $count > 0 && $this->content[0] instanceof HtmlGridCol; |
|
| 133 | + return $count>0 && $this->content[0] instanceof HtmlGridCol; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | if (isset($width)===false) { |
| 145 | 145 | $this->setWide($numCols); |
| 146 | 146 | } |
| 147 | - if ($toCreate === true) { |
|
| 147 | + if ($toCreate===true) { |
|
| 148 | 148 | $count=$this->count(); |
| 149 | - if ($count == 0 || $this->hasOnlyCols($count)) { |
|
| 150 | - for($i=$count; $i < $numCols; $i++) { |
|
| 151 | - $this->addItem(new HtmlGridCol("col-" . $this->identifier . "-" . $i, $width)); |
|
| 149 | + if ($count==0 || $this->hasOnlyCols($count)) { |
|
| 150 | + for ($i=$count; $i<$numCols; $i++) { |
|
| 151 | + $this->addItem(new HtmlGridCol("col-".$this->identifier."-".$i, $width)); |
|
| 152 | 152 | } |
| 153 | 153 | } else { |
| 154 | - for($i=0; $i < $count; $i++) { |
|
| 154 | + for ($i=0; $i<$count; $i++) { |
|
| 155 | 155 | $this->getItem($i)->setColsCount($numCols); |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $count=$this->count(); |
| 188 | 188 | if ($this->hasOnlyCols($count)) |
| 189 | 189 | return $count; |
| 190 | - if ($count > 0) |
|
| 190 | + if ($count>0) |
|
| 191 | 191 | return $this->getItem(0)->count(); |
| 192 | 192 | return 0; |
| 193 | 193 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * @return \Ajax\semantic\html\collections\HtmlGridCol |
| 200 | 200 | */ |
| 201 | 201 | public function getCell($row, $col) { |
| 202 | - if ($row < 2 && $this->hasOnlyCols($this->count())) |
|
| 202 | + if ($row<2 && $this->hasOnlyCols($this->count())) |
|
| 203 | 203 | return $this->getItem($col); |
| 204 | 204 | $row=$this->getItem($row); |
| 205 | 205 | if (isset($row)) { |
@@ -214,8 +214,8 @@ discard block |
||
| 214 | 214 | * @return \Ajax\semantic\html\collections\HtmlGrid |
| 215 | 215 | */ |
| 216 | 216 | public function setDivided($vertically=false) { |
| 217 | - $value=($vertically === true) ? "vertically divided" : "divided"; |
|
| 218 | - return $this->addToPropertyCtrl("class", $value, array ("divided" )); |
|
| 217 | + $value=($vertically===true) ? "vertically divided" : "divided"; |
|
| 218 | + return $this->addToPropertyCtrl("class", $value, array("divided")); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -224,15 +224,15 @@ discard block |
||
| 224 | 224 | * @return \Ajax\semantic\html\collections\HtmlGrid |
| 225 | 225 | */ |
| 226 | 226 | public function setCelled($internally=false) { |
| 227 | - $value=($internally === true) ? "internally celled" : "celled"; |
|
| 228 | - return $this->addToPropertyCtrl("class", $value, array ("celled","internally celled" )); |
|
| 227 | + $value=($internally===true) ? "internally celled" : "celled"; |
|
| 228 | + return $this->addToPropertyCtrl("class", $value, array("celled", "internally celled")); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | 232 | * A grid can have its columns centered |
| 233 | 233 | */ |
| 234 | 234 | public function setCentered() { |
| 235 | - return $this->addToPropertyCtrl("class", "centered", array ("centered" )); |
|
| 235 | + return $this->addToPropertyCtrl("class", "centered", array("centered")); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | public function setPadded($value=NULL) { |
| 252 | 252 | if (isset($value)) |
| 253 | - $this->addToPropertyCtrl("class", $value, array ("vertically","horizontally" )); |
|
| 253 | + $this->addToPropertyCtrl("class", $value, array("vertically", "horizontally")); |
|
| 254 | 254 | return $this->addToProperty("class", "padded"); |
| 255 | 255 | } |
| 256 | 256 | |
@@ -260,12 +260,12 @@ discard block |
||
| 260 | 260 | * @return \Ajax\semantic\html\collections\HtmlGrid |
| 261 | 261 | */ |
| 262 | 262 | public function setRelaxed($very=false) { |
| 263 | - $value=($very === true) ? "very relaxed" : "relaxed"; |
|
| 264 | - return $this->addToPropertyCtrl("class", $value, array ("relaxed","very relaxed" )); |
|
| 263 | + $value=($very===true) ? "very relaxed" : "relaxed"; |
|
| 264 | + return $this->addToPropertyCtrl("class", $value, array("relaxed", "very relaxed")); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | public function setVerticalAlignment($value=VerticalAlignment::MIDDLE) { |
| 268 | - return $this->addToPropertyCtrl("class", $value . " aligned", VerticalAlignment::getConstantValues("aligned")); |
|
| 268 | + return $this->addToPropertyCtrl("class", $value." aligned", VerticalAlignment::getConstantValues("aligned")); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -275,9 +275,9 @@ discard block |
||
| 275 | 275 | * @see \Ajax\common\html\HtmlCollection::createItem() |
| 276 | 276 | */ |
| 277 | 277 | protected function createItem($value) { |
| 278 | - if ($this->_createCols === false) |
|
| 278 | + if ($this->_createCols===false) |
|
| 279 | 279 | $value=null; |
| 280 | - $item=new HtmlGridRow($this->identifier . "-row-" . ($this->count() + 1), $value, $this->_colSizing, $this->_implicitRows); |
|
| 280 | + $item=new HtmlGridRow($this->identifier."-row-".($this->count()+1), $value, $this->_colSizing, $this->_implicitRows); |
|
| 281 | 281 | return $item; |
| 282 | 282 | } |
| 283 | 283 | |
@@ -288,20 +288,20 @@ discard block |
||
| 288 | 288 | public function setValues($values, $force=true) { |
| 289 | 289 | $count=$this->count(); |
| 290 | 290 | $valuesSize=\sizeof($values); |
| 291 | - if ($this->_createCols === false || $force === true) { |
|
| 292 | - for($i=$count; $i < $valuesSize; $i++) { |
|
| 291 | + if ($this->_createCols===false || $force===true) { |
|
| 292 | + for ($i=$count; $i<$valuesSize; $i++) { |
|
| 293 | 293 | $colSize=\sizeof($values[$i]); |
| 294 | - $this->addItem(new HtmlGridRow($this->identifier . "-row-" . ($this->count() + 1), $colSize, $this->_colSizing, $this->_implicitRows)); |
|
| 294 | + $this->addItem(new HtmlGridRow($this->identifier."-row-".($this->count()+1), $colSize, $this->_colSizing, $this->_implicitRows)); |
|
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | - $count=\min(array ($this->count(),$valuesSize )); |
|
| 298 | - for($i=0; $i < $count; $i++) { |
|
| 299 | - $this->content[$i]->setValues($values[$i], $this->_createCols === false); |
|
| 297 | + $count=\min(array($this->count(), $valuesSize)); |
|
| 298 | + for ($i=0; $i<$count; $i++) { |
|
| 299 | + $this->content[$i]->setValues($values[$i], $this->_createCols===false); |
|
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - public function setColWidth($numCol,$width){ |
|
| 304 | - foreach ($this->content as $row){ |
|
| 303 | + public function setColWidth($numCol, $width) { |
|
| 304 | + foreach ($this->content as $row) { |
|
| 305 | 305 | $row->getCol($numCol)->setWidth($width); |
| 306 | 306 | } |
| 307 | 307 | return $this; |
@@ -7,22 +7,22 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // Get the input |
| 10 | -$source = file_get_contents($argv[1]); |
|
| 10 | +$source=file_get_contents($argv[1]); |
|
| 11 | 11 | |
| 12 | 12 | // make traits to classes |
| 13 | -$regexp = '#trait([\s]+[\S]+[\s]*){#'; |
|
| 14 | -$replace = 'class$1{'; |
|
| 15 | -$source = preg_replace($regexp, $replace, $source); |
|
| 13 | +$regexp='#trait([\s]+[\S]+[\s]*){#'; |
|
| 14 | +$replace='class$1{'; |
|
| 15 | +$source=preg_replace($regexp, $replace, $source); |
|
| 16 | 16 | |
| 17 | 17 | // use traits by extending them (classes that not extending a class) |
| 18 | -$regexp = '#class([\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
| 19 | -$replace = 'class$1 extends $3 $2 {'; |
|
| 20 | -$source = preg_replace($regexp, $replace, $source); |
|
| 18 | +$regexp='#class([\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
| 19 | +$replace='class$1 extends $3 $2 {'; |
|
| 20 | +$source=preg_replace($regexp, $replace, $source); |
|
| 21 | 21 | |
| 22 | 22 | // use traits by extending them (classes that already extending a class) |
| 23 | -$regexp = '#class([\s]+[\S]+[\s]+extends[\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
| 24 | -$replace = 'class$1, $3 $2{'; |
|
| 25 | -$source = preg_replace($regexp, $replace, $source); |
|
| 23 | +$regexp='#class([\s]+[\S]+[\s]+extends[\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
| 24 | +$replace='class$1, $3 $2{'; |
|
| 25 | +$source=preg_replace($regexp, $replace, $source); |
|
| 26 | 26 | |
| 27 | 27 | // Output |
| 28 | 28 | echo $source; |
@@ -14,44 +14,44 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | abstract class HtmlCollection extends HtmlDoubleElement { |
| 16 | 16 | |
| 17 | - public function __construct($identifier,$tagName="div"){ |
|
| 18 | - parent::__construct($identifier,$tagName); |
|
| 17 | + public function __construct($identifier, $tagName="div") { |
|
| 18 | + parent::__construct($identifier, $tagName); |
|
| 19 | 19 | $this->content=array(); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public function addItems($items){ |
|
| 23 | - if(JArray::isAssociative($items)){ |
|
| 24 | - foreach ($items as $k=>$v){ |
|
| 25 | - $this->addItem([$k,$v]); |
|
| 22 | + public function addItems($items) { |
|
| 23 | + if (JArray::isAssociative($items)) { |
|
| 24 | + foreach ($items as $k=>$v) { |
|
| 25 | + $this->addItem([$k, $v]); |
|
| 26 | 26 | } |
| 27 | - }else{ |
|
| 28 | - foreach ($items as $item){ |
|
| 27 | + } else { |
|
| 28 | + foreach ($items as $item) { |
|
| 29 | 29 | $this->addItem($item); |
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | return $this; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function setItems($items){ |
|
| 35 | + public function setItems($items) { |
|
| 36 | 36 | $this->content=$items; |
| 37 | 37 | return $this; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public function getItems(){ |
|
| 40 | + public function getItems() { |
|
| 41 | 41 | return $this->content; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - protected function getItemToAdd($item){ |
|
| 44 | + protected function getItemToAdd($item) { |
|
| 45 | 45 | $itemO=$item; |
| 46 | - if($this->createCondition($item)===true){ |
|
| 46 | + if ($this->createCondition($item)===true) { |
|
| 47 | 47 | $itemO=$this->createItem($item); |
| 48 | 48 | } |
| 49 | 49 | return $itemO; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - protected function setItemIdentifier($item,$classname,$index){ |
|
| 53 | - if($item instanceof BaseWidget){ |
|
| 54 | - if($item->getIdentifier()===""){ |
|
| 52 | + protected function setItemIdentifier($item, $classname, $index) { |
|
| 53 | + if ($item instanceof BaseWidget) { |
|
| 54 | + if ($item->getIdentifier()==="") { |
|
| 55 | 55 | $item->setIdentifier($classname."-".$this->identifier."-".$index); |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -62,15 +62,15 @@ discard block |
||
| 62 | 62 | * @param HtmlDoubleElement|string|array $item |
| 63 | 63 | * @return \Ajax\common\html\HtmlDoubleElement |
| 64 | 64 | */ |
| 65 | - public function addItem($item){ |
|
| 65 | + public function addItem($item) { |
|
| 66 | 66 | $itemO=$this->getItemToAdd($item); |
| 67 | 67 | $this->addContent($itemO); |
| 68 | 68 | return $itemO; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - public function insertItem($item,$position=0){ |
|
| 71 | + public function insertItem($item, $position=0) { |
|
| 72 | 72 | $itemO=$this->getItemToAdd($item); |
| 73 | - \array_splice( $this->content, $position, 0, array($itemO)); |
|
| 73 | + \array_splice($this->content, $position, 0, array($itemO)); |
|
| 74 | 74 | return $itemO; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | return $this; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - public function removeItem($index){ |
|
| 96 | + public function removeItem($index) { |
|
| 97 | 97 | return array_splice($this->content, $index, 1); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - public function count(){ |
|
| 100 | + public function count() { |
|
| 101 | 101 | return \sizeof($this->content); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | return $this->addItem($function($object)); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - public function apply($callBack){ |
|
| 112 | - foreach ($this->content as $item){ |
|
| 111 | + public function apply($callBack) { |
|
| 112 | + foreach ($this->content as $item) { |
|
| 113 | 113 | $callBack($item); |
| 114 | 114 | } |
| 115 | 115 | return $this; |
@@ -129,23 +129,23 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | abstract protected function createItem($value); |
| 131 | 131 | |
| 132 | - protected function createCondition($value){ |
|
| 132 | + protected function createCondition($value) { |
|
| 133 | 133 | return \is_object($value)===false; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - protected function contentAs($tagName){ |
|
| 137 | - foreach ($this->content as $item){ |
|
| 136 | + protected function contentAs($tagName) { |
|
| 137 | + foreach ($this->content as $item) { |
|
| 138 | 138 | $item->setTagName($tagName); |
| 139 | 139 | } |
| 140 | 140 | return $this; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - public function setProperties($properties){ |
|
| 143 | + public function setProperties($properties) { |
|
| 144 | 144 | $i=0; |
| 145 | - foreach ($properties as $k=>$v){ |
|
| 145 | + foreach ($properties as $k=>$v) { |
|
| 146 | 146 | $c=$this->content[$i++]; |
| 147 | - if(isset($c)) |
|
| 148 | - $c->setProperty($k,$v); |
|
| 147 | + if (isset($c)) |
|
| 148 | + $c->setProperty($k, $v); |
|
| 149 | 149 | else |
| 150 | 150 | return $this; |
| 151 | 151 | } |
@@ -158,17 +158,17 @@ discard block |
||
| 158 | 158 | * @param array $values |
| 159 | 159 | * @return \Ajax\common\html\HtmlCollection |
| 160 | 160 | */ |
| 161 | - public function setPropertyValues($property,$values){ |
|
| 161 | + public function setPropertyValues($property, $values) { |
|
| 162 | 162 | $i=0; |
| 163 | - if(\is_array($values)===false){ |
|
| 164 | - $values=\array_fill(0, $this->count(),$values); |
|
| 163 | + if (\is_array($values)===false) { |
|
| 164 | + $values=\array_fill(0, $this->count(), $values); |
|
| 165 | 165 | } |
| 166 | - foreach ($values as $value){ |
|
| 166 | + foreach ($values as $value) { |
|
| 167 | 167 | $c=$this->content[$i++]; |
| 168 | - if(isset($c)){ |
|
| 169 | - $c->setProperty($property,$value); |
|
| 168 | + if (isset($c)) { |
|
| 169 | + $c->setProperty($property, $value); |
|
| 170 | 170 | } |
| 171 | - else{ |
|
| 171 | + else { |
|
| 172 | 172 | return $this; |
| 173 | 173 | } |
| 174 | 174 | } |
@@ -178,9 +178,9 @@ discard block |
||
| 178 | 178 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 179 | 179 | $index=0; |
| 180 | 180 | $classname=\strtolower(JReflection::shortClassName($this)); |
| 181 | - foreach ($this->content as $item){ |
|
| 182 | - $this->setItemIdentifier($item,$classname,$index++); |
|
| 181 | + foreach ($this->content as $item) { |
|
| 182 | + $this->setItemIdentifier($item, $classname, $index++); |
|
| 183 | 183 | } |
| 184 | - return parent::compile($js,$view); |
|
| 184 | + return parent::compile($js, $view); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | \ No newline at end of file |
@@ -14,8 +14,8 @@ discard block |
||
| 14 | 14 | * @property string $identifier |
| 15 | 15 | */ |
| 16 | 16 | trait BaseTrait { |
| 17 | - protected $_variations=[ ]; |
|
| 18 | - protected $_states=[ ]; |
|
| 17 | + protected $_variations=[]; |
|
| 18 | + protected $_states=[]; |
|
| 19 | 19 | protected $_baseClass; |
| 20 | 20 | |
| 21 | 21 | abstract protected function setPropertyCtrl($name, $value, $typeCtrl); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | abstract public function setProperty($name, $value); |
| 30 | 30 | |
| 31 | - abstract public function addContent($content,$before=false); |
|
| 31 | + abstract public function addContent($content, $before=false); |
|
| 32 | 32 | |
| 33 | 33 | abstract public function onCreate($jsCode); |
| 34 | 34 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $this->setProperty("class", $this->_baseClass); |
| 50 | 50 | if (\is_string($variations)) |
| 51 | 51 | $variations=\explode(" ", $variations); |
| 52 | - foreach ( $variations as $variation ) { |
|
| 52 | + foreach ($variations as $variation) { |
|
| 53 | 53 | $this->addVariation($variation); |
| 54 | 54 | } |
| 55 | 55 | return $this; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | public function addVariations($variations=array()) { |
| 64 | 64 | if (\is_string($variations)) |
| 65 | 65 | $variations=\explode(" ", $variations); |
| 66 | - foreach ( $variations as $variation ) { |
|
| 66 | + foreach ($variations as $variation) { |
|
| 67 | 67 | $this->addVariation($variation); |
| 68 | 68 | } |
| 69 | 69 | return $this; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | public function addStates($states=array()) { |
| 73 | 73 | if (\is_string($states)) |
| 74 | 74 | $states=\explode(" ", $states); |
| 75 | - foreach ( $states as $state ) { |
|
| 75 | + foreach ($states as $state) { |
|
| 76 | 76 | $this->addState($state); |
| 77 | 77 | } |
| 78 | 78 | return $this; |
@@ -82,17 +82,17 @@ discard block |
||
| 82 | 82 | $this->setProperty("class", $this->_baseClass); |
| 83 | 83 | if (\is_string($states)) |
| 84 | 84 | $states=\explode(" ", $states); |
| 85 | - foreach ( $states as $state ) { |
|
| 85 | + foreach ($states as $state) { |
|
| 86 | 86 | $this->addState($state); |
| 87 | 87 | } |
| 88 | 88 | return $this; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | public function addIcon($icon, $before=true) { |
| 92 | - return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before); |
|
| 92 | + return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function addSticky($context="body"){ |
|
| 95 | + public function addSticky($context="body") { |
|
| 96 | 96 | $this->onCreate("$('#".$this->identifier."').sticky({ context: '".$context."'});"); |
| 97 | 97 | return $this; |
| 98 | 98 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @return HtmlSemDoubleElement |
| 114 | 114 | */ |
| 115 | 115 | public function setDisabled($disable=true) { |
| 116 | - if($disable) |
|
| 116 | + if ($disable) |
|
| 117 | 117 | $this->addToProperty("class", "disabled"); |
| 118 | 118 | return $this; |
| 119 | 119 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @return HtmlSemDoubleElement |
| 141 | 141 | */ |
| 142 | - public function asHeader(){ |
|
| 142 | + public function asHeader() { |
|
| 143 | 143 | return $this->addToProperty("class", "header"); |
| 144 | 144 | } |
| 145 | 145 | |
@@ -147,15 +147,15 @@ discard block |
||
| 147 | 147 | * show it is currently the active user selection |
| 148 | 148 | * @return HtmlSemDoubleElement |
| 149 | 149 | */ |
| 150 | - public function setActive($value=true){ |
|
| 151 | - if($value) |
|
| 150 | + public function setActive($value=true) { |
|
| 151 | + if ($value) |
|
| 152 | 152 | $this->addToProperty("class", "active"); |
| 153 | 153 | return $this; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - public function setAttached($value=true){ |
|
| 157 | - if($value) |
|
| 158 | - $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 156 | + public function setAttached($value=true) { |
|
| 157 | + if ($value) |
|
| 158 | + $this->addToPropertyCtrl("class", "attached", array("attached")); |
|
| 159 | 159 | return $this; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | public function setFloated($direction="right") { |
| 174 | - return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
|
| 174 | + return $this->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated")); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | public function floatRight() { |
@@ -186,14 +186,14 @@ discard block |
||
| 186 | 186 | return $this->_baseClass; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - protected function addBehavior(&$array,$key,$value,$before="",$after=""){ |
|
| 190 | - if(\is_string($value)){ |
|
| 191 | - if(isset($array[$key])){ |
|
| 189 | + protected function addBehavior(&$array, $key, $value, $before="", $after="") { |
|
| 190 | + if (\is_string($value)) { |
|
| 191 | + if (isset($array[$key])) { |
|
| 192 | 192 | $p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, ""); |
| 193 | 193 | $array[$key]=$before.$p.$value.$after; |
| 194 | - }else |
|
| 194 | + } else |
|
| 195 | 195 | $array[$key]=$before.$value.$after; |
| 196 | - }else |
|
| 196 | + } else |
|
| 197 | 197 | $array[$key]=$value; |
| 198 | 198 | return $this; |
| 199 | 199 | } |
@@ -19,16 +19,16 @@ discard block |
||
| 19 | 19 | abstract public function setClass($classNames); |
| 20 | 20 | abstract public function addIcon($icon, $before=true); |
| 21 | 21 | |
| 22 | - public function setContent($content){ |
|
| 23 | - if($content==="-"){ |
|
| 22 | + public function setContent($content) { |
|
| 23 | + if ($content==="-") { |
|
| 24 | 24 | $this->asDivider(); |
| 25 | - }elseif($content==="-search-"){ |
|
| 26 | - $values=\explode(",",$content,-1); |
|
| 27 | - $this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."),JArray::getDefaultValue($values, 1, "search")); |
|
| 28 | - }elseif(JString::startswith($content, "-")){ |
|
| 29 | - $content=\ltrim($content,"-"); |
|
| 25 | + }elseif ($content==="-search-") { |
|
| 26 | + $values=\explode(",", $content, -1); |
|
| 27 | + $this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."), JArray::getDefaultValue($values, 1, "search")); |
|
| 28 | + }elseif (JString::startswith($content, "-")) { |
|
| 29 | + $content=\ltrim($content, "-"); |
|
| 30 | 30 | $this->asHeader($content); |
| 31 | - }else |
|
| 31 | + } else |
|
| 32 | 32 | parent::setContent($content); |
| 33 | 33 | return $this; |
| 34 | 34 | } |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | * @param string $icon |
| 39 | 39 | * @return HtmlDropdownItem|HtmlMenuItem |
| 40 | 40 | */ |
| 41 | - public function asSearchInput($placeholder=NULL,$icon=NULL){ |
|
| 41 | + public function asSearchInput($placeholder=NULL, $icon=NULL) { |
|
| 42 | 42 | $this->setClass("ui icon search input"); |
| 43 | 43 | $input=new HtmlInput("search-".$this->identifier); |
| 44 | - if(isset($placeholder)) |
|
| 44 | + if (isset($placeholder)) |
|
| 45 | 45 | $input->setProperty("placeholder", $placeholder); |
| 46 | 46 | $this->content=$input; |
| 47 | - if(isset($icon)) |
|
| 47 | + if (isset($icon)) |
|
| 48 | 48 | $this->addIcon($icon); |
| 49 | 49 | return $this; |
| 50 | 50 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * @return HtmlDropdownItem|HtmlMenuItem |
| 54 | 54 | */ |
| 55 | - public function asDivider(){ |
|
| 55 | + public function asDivider() { |
|
| 56 | 56 | $this->content=NULL; |
| 57 | 57 | $this->tagName="div"; |
| 58 | 58 | $this->setClass("divider"); |
@@ -64,16 +64,16 @@ discard block |
||
| 64 | 64 | * @param string $icon |
| 65 | 65 | * @return HtmlDropdownItem|HtmlMenuItem |
| 66 | 66 | */ |
| 67 | - public function asHeader($caption=NULL,$icon=NULL){ |
|
| 67 | + public function asHeader($caption=NULL, $icon=NULL) { |
|
| 68 | 68 | $this->setClass("header"); |
| 69 | 69 | $this->tagName="div"; |
| 70 | 70 | $this->content=$caption; |
| 71 | - if(isset($icon)) |
|
| 72 | - $this->addIcon($icon,Direction::LEFT); |
|
| 71 | + if (isset($icon)) |
|
| 72 | + $this->addIcon($icon, Direction::LEFT); |
|
| 73 | 73 | return $this; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - public function setPosition($direction){ |
|
| 77 | - $this->addToProperty("class",$direction); |
|
| 76 | + public function setPosition($direction) { |
|
| 77 | + $this->addToProperty("class", $direction); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | \ No newline at end of file |