@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | if(isset($value)){ |
| 36 | 36 | if($value instanceof HtmlSemDoubleElement){ |
| 37 | 37 | $text=$value; |
| 38 | - }else{ |
|
| 38 | + } else{ |
|
| 39 | 39 | $text=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
| 40 | 40 | $text->setClass("text"); |
| 41 | 41 | $this->setValue($value); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | if(!$item instanceof HtmlDropdownItem){ |
| 114 | 114 | $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description); |
| 115 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
| 115 | + } elseif($itemO instanceof HtmlDropdownItem){ |
|
| 116 | 116 | $this->addToProperty("class", "vertical"); |
| 117 | 117 | } |
| 118 | 118 | return $itemO; |
@@ -126,8 +126,9 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | public function addInput($name){ |
| 129 | - if(!isset($name)) |
|
| 130 | - $name="input-".$this->identifier; |
|
| 129 | + if(!isset($name)) { |
|
| 130 | + $name="input-".$this->identifier; |
|
| 131 | + } |
|
| 131 | 132 | $this->setAction("activate"); |
| 132 | 133 | $this->input=new HtmlInput($name,"hidden"); |
| 133 | 134 | $this->input->setIdentifier("input-".$this->identifier); |
@@ -186,7 +187,7 @@ discard block |
||
| 186 | 187 | foreach ($items as $k=>$v){ |
| 187 | 188 | $this->addItem($v)->setData($k); |
| 188 | 189 | } |
| 189 | - }else{ |
|
| 190 | + } else{ |
|
| 190 | 191 | foreach ($items as $item){ |
| 191 | 192 | $this->addItem($item); |
| 192 | 193 | } |
@@ -208,8 +209,7 @@ discard block |
||
| 208 | 209 | $c=$this->items[$i++]; |
| 209 | 210 | if(isset($c)){ |
| 210 | 211 | $c->setProperty($property,$value); |
| 211 | - } |
|
| 212 | - else{ |
|
| 212 | + } else{ |
|
| 213 | 213 | return $this; |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | if($dropdown===false){ |
| 241 | 241 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
| 242 | 242 | $dropdown="menu"; |
| 243 | - }else{ |
|
| 243 | + } else{ |
|
| 244 | 244 | $dropdown="dropdown"; |
| 245 | 245 | $this->mClass="menu"; |
| 246 | 246 | } |
@@ -261,22 +261,25 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | public function asButton($floating=false){ |
| 263 | 263 | $this->removeArrow(); |
| 264 | - if($floating) |
|
| 265 | - $this->addToProperty("class", "floating"); |
|
| 264 | + if($floating) { |
|
| 265 | + $this->addToProperty("class", "floating"); |
|
| 266 | + } |
|
| 266 | 267 | $this->removePropertyValue("class", "selection"); |
| 267 | 268 | return $this->addToProperty("class", "button"); |
| 268 | 269 | } |
| 269 | 270 | |
| 270 | 271 | public function asSelect($name=NULL,$multiple=false,$selection=true){ |
| 271 | 272 | $this->_multiple=$multiple; |
| 272 | - if(isset($name)) |
|
| 273 | - $this->addInput($name); |
|
| 273 | + if(isset($name)) { |
|
| 274 | + $this->addInput($name); |
|
| 275 | + } |
|
| 274 | 276 | if($multiple){ |
| 275 | 277 | $this->addToProperty("class", "multiple"); |
| 276 | 278 | } |
| 277 | 279 | if ($selection){ |
| 278 | - if($this->propertyContains("class", "button")===false) |
|
| 279 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
| 280 | + if($this->propertyContains("class", "button")===false) { |
|
| 281 | + $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
| 282 | + } |
|
| 280 | 283 | } |
| 281 | 284 | return $this; |
| 282 | 285 | } |
@@ -288,8 +291,9 @@ discard block |
||
| 288 | 291 | |
| 289 | 292 | public function setSelect($name=NULL,$multiple=false){ |
| 290 | 293 | $this->_template='<%tagName% id="%identifier%" %properties%>%items%</%tagName%>'; |
| 291 | - if(!isset($name)) |
|
| 292 | - $name="select-".$this->identifier; |
|
| 294 | + if(!isset($name)) { |
|
| 295 | + $name="select-".$this->identifier; |
|
| 296 | + } |
|
| 293 | 297 | $this->input=null; |
| 294 | 298 | if($multiple){ |
| 295 | 299 | $this->setProperty("multiple", true); |
@@ -330,12 +334,13 @@ discard block |
||
| 330 | 334 | $value=$this->value; |
| 331 | 335 | if(isset($this->input) && isset($value)){ |
| 332 | 336 | $this->input->setProperty("value", $value); |
| 333 | - }else{ |
|
| 337 | + } else{ |
|
| 334 | 338 | $this->setProperty("value", $value); |
| 335 | 339 | } |
| 336 | 340 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
| 337 | - if(isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple) |
|
| 338 | - $textElement->setContent($value); |
|
| 341 | + if(isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple) { |
|
| 342 | + $textElement->setContent($value); |
|
| 343 | + } |
|
| 339 | 344 | return $this; |
| 340 | 345 | } |
| 341 | 346 | |
@@ -14,29 +14,29 @@ discard block |
||
| 14 | 14 | use Ajax\common\html\HtmlDoubleElement; |
| 15 | 15 | |
| 16 | 16 | class HtmlDropdown extends HtmlSemDoubleElement { |
| 17 | - use FieldTrait,LabeledIconTrait { |
|
| 17 | + use FieldTrait, LabeledIconTrait { |
|
| 18 | 18 | addIcon as addIconP; |
| 19 | 19 | } |
| 20 | 20 | protected $mClass="menu"; |
| 21 | 21 | protected $mTagName="div"; |
| 22 | - protected $items=array (); |
|
| 23 | - protected $_params=array("action"=>"nothing","on"=>"hover","showOnFocus"=>false); |
|
| 22 | + protected $items=array(); |
|
| 23 | + protected $_params=array("action"=>"nothing", "on"=>"hover", "showOnFocus"=>false); |
|
| 24 | 24 | protected $input; |
| 25 | 25 | protected $value; |
| 26 | 26 | protected $_associative; |
| 27 | 27 | protected $_multiple; |
| 28 | 28 | |
| 29 | - public function __construct($identifier, $value="", $items=array(),$associative=true) { |
|
| 29 | + public function __construct($identifier, $value="", $items=array(), $associative=true) { |
|
| 30 | 30 | parent::__construct($identifier, "div"); |
| 31 | 31 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
| 32 | 32 | $this->setProperty("class", "ui dropdown"); |
| 33 | 33 | $this->_multiple=false; |
| 34 | 34 | $content=[]; |
| 35 | - if(isset($value)){ |
|
| 36 | - if($value instanceof HtmlSemDoubleElement){ |
|
| 35 | + if (isset($value)) { |
|
| 36 | + if ($value instanceof HtmlSemDoubleElement) { |
|
| 37 | 37 | $text=$value; |
| 38 | - }else{ |
|
| 39 | - $text=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
| 38 | + } else { |
|
| 39 | + $text=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
| 40 | 40 | $text->setClass("text"); |
| 41 | 41 | $this->setValue($value); |
| 42 | 42 | } |
@@ -49,33 +49,33 @@ discard block |
||
| 49 | 49 | $this->addItems($items); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function getField(){ |
|
| 52 | + public function getField() { |
|
| 53 | 53 | return $this->input; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public function getDataField(){ |
|
| 56 | + public function getDataField() { |
|
| 57 | 57 | return $this->input; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function addItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
| 61 | - $itemO=$this->beforeAddItem($item,$value,$image,$description); |
|
| 60 | + public function addItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
| 61 | + $itemO=$this->beforeAddItem($item, $value, $image, $description); |
|
| 62 | 62 | $this->items[]=$itemO; |
| 63 | 63 | return $itemO; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
| 66 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
| 67 | 67 | $this->removeArrow(); |
| 68 | - $this->addIconP($icon,$before,$labeled); |
|
| 68 | + $this->addIconP($icon, $before, $labeled); |
|
| 69 | 69 | $elm=$this->getElementById("text-".$this->identifier, $this->content); |
| 70 | - if(isset($elm)){ |
|
| 70 | + if (isset($elm)) { |
|
| 71 | 71 | $elm->setWrapAfter(""); |
| 72 | 72 | } |
| 73 | 73 | return $this; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - public function addIcons($icons){ |
|
| 76 | + public function addIcons($icons) { |
|
| 77 | 77 | $count=$this->count(); |
| 78 | - for ($i=0;$i<\sizeof($icons) && $i<$count;$i++){ |
|
| 78 | + for ($i=0; $i<\sizeof($icons) && $i<$count; $i++) { |
|
| 79 | 79 | $this->getItem($i)->addIcon($icons[$i]); |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -86,33 +86,33 @@ discard block |
||
| 86 | 86 | * @param int $position |
| 87 | 87 | * @return HtmlDropdownItem |
| 88 | 88 | */ |
| 89 | - public function insertItem($item,$position=0){ |
|
| 89 | + public function insertItem($item, $position=0) { |
|
| 90 | 90 | $itemO=$this->beforeAddItem($item); |
| 91 | - $start = array_slice($this->items, 0, $position); |
|
| 92 | - $end = array_slice($this->items, $position); |
|
| 93 | - $start[] = $item; |
|
| 91 | + $start=array_slice($this->items, 0, $position); |
|
| 92 | + $end=array_slice($this->items, $position); |
|
| 93 | + $start[]=$item; |
|
| 94 | 94 | $this->items=array_merge($start, $end); |
| 95 | 95 | return $itemO; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - protected function removeArrow(){ |
|
| 99 | - if(\sizeof($this->content)>1){ |
|
| 98 | + protected function removeArrow() { |
|
| 99 | + if (\sizeof($this->content)>1) { |
|
| 100 | 100 | unset($this->content["arrow"]); |
| 101 | 101 | $this->content=\array_values($this->content); |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - protected function beforeAddItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
| 105 | + protected function beforeAddItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
| 106 | 106 | $itemO=$item; |
| 107 | - if(\is_array($item)){ |
|
| 107 | + if (\is_array($item)) { |
|
| 108 | 108 | $description=JArray::getValue($item, "description", 3); |
| 109 | 109 | $value=JArray::getValue($item, "value", 1); |
| 110 | 110 | $image=JArray::getValue($item, "image", 2); |
| 111 | 111 | $item=JArray::getValue($item, "item", 0); |
| 112 | 112 | } |
| 113 | - if(!$item instanceof HtmlDropdownItem){ |
|
| 114 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description); |
|
| 115 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
| 113 | + if (!$item instanceof HtmlDropdownItem) { |
|
| 114 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image, $description); |
|
| 115 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
| 116 | 116 | $this->addToProperty("class", "vertical"); |
| 117 | 117 | } |
| 118 | 118 | return $itemO; |
@@ -125,11 +125,11 @@ discard block |
||
| 125 | 125 | $this->addItem($function($object)); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - public function addInput($name){ |
|
| 129 | - if(!isset($name)) |
|
| 128 | + public function addInput($name) { |
|
| 129 | + if (!isset($name)) |
|
| 130 | 130 | $name="input-".$this->identifier; |
| 131 | 131 | $this->setAction("activate"); |
| 132 | - $this->input=new HtmlInput($name,"hidden"); |
|
| 132 | + $this->input=new HtmlInput($name, "hidden"); |
|
| 133 | 133 | $this->input->setIdentifier("input-".$this->identifier); |
| 134 | 134 | return $this->input; |
| 135 | 135 | } |
@@ -140,15 +140,15 @@ discard block |
||
| 140 | 140 | * @param string $icon |
| 141 | 141 | * @return HtmlDropdownItem |
| 142 | 142 | */ |
| 143 | - public function addSearchInputItem($placeHolder=NULL,$icon=NULL){ |
|
| 144 | - return $this->addItem(HtmlDropdownItem::searchInput($placeHolder,$icon)); |
|
| 143 | + public function addSearchInputItem($placeHolder=NULL, $icon=NULL) { |
|
| 144 | + return $this->addItem(HtmlDropdownItem::searchInput($placeHolder, $icon)); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
| 148 | 148 | * Adds a divider item |
| 149 | 149 | * @return HtmlDropdownItem |
| 150 | 150 | */ |
| 151 | - public function addDividerItem(){ |
|
| 151 | + public function addDividerItem() { |
|
| 152 | 152 | return $this->addItem(HtmlDropdownItem::divider()); |
| 153 | 153 | } |
| 154 | 154 | |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | * @param string $icon |
| 159 | 159 | * @return HtmlDropdownItem |
| 160 | 160 | */ |
| 161 | - public function addHeaderItem($caption=NULL,$icon=NULL){ |
|
| 162 | - return $this->addItem(HtmlDropdownItem::header($caption,$icon)); |
|
| 161 | + public function addHeaderItem($caption=NULL, $icon=NULL) { |
|
| 162 | + return $this->addItem(HtmlDropdownItem::header($caption, $icon)); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @param string $color |
| 169 | 169 | * @return HtmlDropdownItem |
| 170 | 170 | */ |
| 171 | - public function addCircularLabelItem($caption,$color){ |
|
| 171 | + public function addCircularLabelItem($caption, $color) { |
|
| 172 | 172 | return $this->addItem(HtmlDropdownItem::circular($caption, $color)); |
| 173 | 173 | } |
| 174 | 174 | |
@@ -177,17 +177,17 @@ discard block |
||
| 177 | 177 | * @param string $image |
| 178 | 178 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
| 179 | 179 | */ |
| 180 | - public function addMiniAvatarImageItem($caption,$image){ |
|
| 180 | + public function addMiniAvatarImageItem($caption, $image) { |
|
| 181 | 181 | return $this->addItem(HtmlDropdownItem::avatar($caption, $image)); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - public function addItems($items){ |
|
| 185 | - if(\is_array($items) && $this->_associative){ |
|
| 186 | - foreach ($items as $k=>$v){ |
|
| 184 | + public function addItems($items) { |
|
| 185 | + if (\is_array($items) && $this->_associative) { |
|
| 186 | + foreach ($items as $k=>$v) { |
|
| 187 | 187 | $this->addItem($v)->setData($k); |
| 188 | 188 | } |
| 189 | - }else{ |
|
| 190 | - foreach ($items as $item){ |
|
| 189 | + } else { |
|
| 190 | + foreach ($items as $item) { |
|
| 191 | 191 | $this->addItem($item); |
| 192 | 192 | } |
| 193 | 193 | } |
@@ -199,99 +199,99 @@ discard block |
||
| 199 | 199 | * @param array|mixed $values |
| 200 | 200 | * @return $this |
| 201 | 201 | */ |
| 202 | - public function setPropertyValues($property,$values){ |
|
| 202 | + public function setPropertyValues($property, $values) { |
|
| 203 | 203 | $i=0; |
| 204 | - if(\is_array($values)===false){ |
|
| 205 | - $values=\array_fill(0, $this->count(),$values); |
|
| 204 | + if (\is_array($values)===false) { |
|
| 205 | + $values=\array_fill(0, $this->count(), $values); |
|
| 206 | 206 | } |
| 207 | - foreach ($values as $value){ |
|
| 207 | + foreach ($values as $value) { |
|
| 208 | 208 | $c=$this->items[$i++]; |
| 209 | - if(isset($c)){ |
|
| 210 | - $c->setProperty($property,$value); |
|
| 209 | + if (isset($c)) { |
|
| 210 | + $c->setProperty($property, $value); |
|
| 211 | 211 | } |
| 212 | - else{ |
|
| 212 | + else { |
|
| 213 | 213 | return $this; |
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | return $this; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - public function each($callBack){ |
|
| 220 | - foreach ($this->items as $index=>$value){ |
|
| 221 | - $callBack($index,$value); |
|
| 219 | + public function each($callBack) { |
|
| 220 | + foreach ($this->items as $index=>$value) { |
|
| 221 | + $callBack($index, $value); |
|
| 222 | 222 | } |
| 223 | 223 | return $this; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - public function getItem($index){ |
|
| 226 | + public function getItem($index) { |
|
| 227 | 227 | return $this->items[$index]; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
| 231 | 231 | * @return int |
| 232 | 232 | */ |
| 233 | - public function count(){ |
|
| 233 | + public function count() { |
|
| 234 | 234 | return \sizeof($this->items); |
| 235 | 235 | } |
| 236 | 236 | /** |
| 237 | 237 | * @param boolean $dropdown |
| 238 | 238 | */ |
| 239 | - public function asDropdown($dropdown){ |
|
| 240 | - if($dropdown===false){ |
|
| 239 | + public function asDropdown($dropdown) { |
|
| 240 | + if ($dropdown===false) { |
|
| 241 | 241 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
| 242 | 242 | $dropdown="menu"; |
| 243 | - }else{ |
|
| 243 | + } else { |
|
| 244 | 244 | $dropdown="dropdown"; |
| 245 | 245 | $this->mClass="menu"; |
| 246 | 246 | } |
| 247 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
| 247 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - public function setVertical(){ |
|
| 251 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
| 250 | + public function setVertical() { |
|
| 251 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - public function setInline(){ |
|
| 255 | - return $this->addToPropertyCtrl("class", "inline",["inline"]); |
|
| 254 | + public function setInline() { |
|
| 255 | + return $this->addToPropertyCtrl("class", "inline", ["inline"]); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - public function setSimple(){ |
|
| 259 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
| 258 | + public function setSimple() { |
|
| 259 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - public function asButton($floating=false){ |
|
| 262 | + public function asButton($floating=false) { |
|
| 263 | 263 | $this->removeArrow(); |
| 264 | - if($floating) |
|
| 264 | + if ($floating) |
|
| 265 | 265 | $this->addToProperty("class", "floating"); |
| 266 | 266 | $this->removePropertyValue("class", "selection"); |
| 267 | 267 | return $this->addToProperty("class", "button"); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
| 270 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
| 271 | 271 | $this->_multiple=$multiple; |
| 272 | - if(isset($name)) |
|
| 272 | + if (isset($name)) |
|
| 273 | 273 | $this->addInput($name); |
| 274 | - if($multiple){ |
|
| 274 | + if ($multiple) { |
|
| 275 | 275 | $this->addToProperty("class", "multiple"); |
| 276 | 276 | } |
| 277 | - if ($selection){ |
|
| 278 | - if($this->propertyContains("class", "button")===false) |
|
| 279 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
| 277 | + if ($selection) { |
|
| 278 | + if ($this->propertyContains("class", "button")===false) |
|
| 279 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
| 280 | 280 | } |
| 281 | 281 | return $this; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - public function asSearch($name=NULL,$multiple=false,$selection=true){ |
|
| 285 | - $this->asSelect($name,$multiple,$selection); |
|
| 284 | + public function asSearch($name=NULL, $multiple=false, $selection=true) { |
|
| 285 | + $this->asSelect($name, $multiple, $selection); |
|
| 286 | 286 | return $this->addToProperty("class", "search"); |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - public function setSelect($name=NULL,$multiple=false){ |
|
| 289 | + public function setSelect($name=NULL, $multiple=false) { |
|
| 290 | 290 | $this->_template='<%tagName% id="%identifier%" %properties%>%items%</%tagName%>'; |
| 291 | - if(!isset($name)) |
|
| 291 | + if (!isset($name)) |
|
| 292 | 292 | $name="select-".$this->identifier; |
| 293 | 293 | $this->input=null; |
| 294 | - if($multiple){ |
|
| 294 | + if ($multiple) { |
|
| 295 | 295 | $this->setProperty("multiple", true); |
| 296 | 296 | $this->addToProperty("class", "multiple"); |
| 297 | 297 | } |
@@ -299,42 +299,42 @@ discard block |
||
| 299 | 299 | $this->tagName="select"; |
| 300 | 300 | $this->setProperty("name", $name); |
| 301 | 301 | $this->content=null; |
| 302 | - foreach ($this->items as $item){ |
|
| 302 | + foreach ($this->items as $item) { |
|
| 303 | 303 | $item->asOption(); |
| 304 | 304 | } |
| 305 | 305 | return $this; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - public function asSubmenu($pointing=NULL){ |
|
| 308 | + public function asSubmenu($pointing=NULL) { |
|
| 309 | 309 | $this->setClass("ui dropdown link item"); |
| 310 | - if(isset($pointing)){ |
|
| 310 | + if (isset($pointing)) { |
|
| 311 | 311 | $this->setPointing($pointing); |
| 312 | 312 | } |
| 313 | 313 | return $this; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - public function setPointing($value=Direction::NONE){ |
|
| 317 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
| 316 | + public function setPointing($value=Direction::NONE) { |
|
| 317 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - public function setValue($value){ |
|
| 320 | + public function setValue($value) { |
|
| 321 | 321 | $this->value=$value; |
| 322 | 322 | return $this; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - public function setDefaultText($text){ |
|
| 326 | - $this->content["text"]=new HtmlSemDoubleElement("","div","default text",$text); |
|
| 325 | + public function setDefaultText($text) { |
|
| 326 | + $this->content["text"]=new HtmlSemDoubleElement("", "div", "default text", $text); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - private function applyValue(){ |
|
| 329 | + private function applyValue() { |
|
| 330 | 330 | $value=$this->value; |
| 331 | - if(isset($this->input) && isset($value)){ |
|
| 331 | + if (isset($this->input) && isset($value)) { |
|
| 332 | 332 | $this->input->setProperty("value", $value); |
| 333 | - }else{ |
|
| 333 | + } else { |
|
| 334 | 334 | $this->setProperty("value", $value); |
| 335 | 335 | } |
| 336 | 336 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
| 337 | - if(isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple) |
|
| 337 | + if (isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple) |
|
| 338 | 338 | $textElement->setContent($value); |
| 339 | 339 | return $this; |
| 340 | 340 | } |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | * @see BaseHtml::run() |
| 345 | 345 | */ |
| 346 | 346 | public function run(JsUtils $js) { |
| 347 | - if($this->propertyContains("class", "simple")===false){ |
|
| 348 | - if(isset($this->_bsComponent)===false){ |
|
| 349 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
| 347 | + if ($this->propertyContains("class", "simple")===false) { |
|
| 348 | + if (isset($this->_bsComponent)===false) { |
|
| 349 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params); |
|
| 350 | 350 | $this->_bsComponent->setItemSelector(".item"); |
| 351 | 351 | } |
| 352 | 352 | $this->addEventsOnRun($js); |
@@ -354,50 +354,50 @@ discard block |
||
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - public function setCompact(){ |
|
| 357 | + public function setCompact() { |
|
| 358 | 358 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - public function setAction($action){ |
|
| 361 | + public function setAction($action) { |
|
| 362 | 362 | $this->_params["action"]=$action; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - public function setOn($on){ |
|
| 365 | + public function setOn($on) { |
|
| 366 | 366 | $this->_params["on"]=$on; |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - public function setShowOnFocus($value){ |
|
| 369 | + public function setShowOnFocus($value) { |
|
| 370 | 370 | $this->_params["showOnFocus"]=$value; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - public function setAllowAdditions($value){ |
|
| 373 | + public function setAllowAdditions($value) { |
|
| 374 | 374 | $this->_params["allowAdditions"]=$value; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - public function setFullTextSearch($value){ |
|
| 377 | + public function setFullTextSearch($value) { |
|
| 378 | 378 | $this->_params["fullTextSearch"]=$value; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 382 | 382 | $this->applyValue(); |
| 383 | - return parent::compile($js,$view); |
|
| 383 | + return parent::compile($js, $view); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | public function getInput() { |
| 387 | 387 | return $this->input; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - public function setIcon($icon="dropdown"){ |
|
| 390 | + public function setIcon($icon="dropdown") { |
|
| 391 | 391 | $this->content["arrow"]=new HtmlIcon($this->identifier."-icon", $icon); |
| 392 | 392 | return $this; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - public function jsAddItem($caption){ |
|
| 395 | + public function jsAddItem($caption) { |
|
| 396 | 396 | $js="var first=$('#{$this->identifier} .item').first();if(first!=undefined){var new =first.clone();first.parent().append(new);first.html('{$caption}};')"; |
| 397 | 397 | return $js; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - public function setClearable($value){ |
|
| 400 | + public function setClearable($value) { |
|
| 401 | 401 | $this->_params["clearable"]=$value; |
| 402 | 402 | } |
| 403 | 403 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | if (isset($label)) |
| 37 | 37 | $this->setLabel($label); |
| 38 | - foreach ( $fields as $field ) { |
|
| 38 | + foreach ($fields as $field) { |
|
| 39 | 39 | $this->addItem($field); |
| 40 | 40 | } |
| 41 | 41 | return $this; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | public function addItem($item) { |
| 59 | 59 | $item=parent::addItem($item); |
| 60 | - if($item instanceof HtmlFormField) |
|
| 60 | + if ($item instanceof HtmlFormField) |
|
| 61 | 61 | $item->setContainer($this); |
| 62 | 62 | return $item; |
| 63 | 63 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | /** |
| 66 | 66 | * @return HtmlFormField |
| 67 | 67 | */ |
| 68 | - public function getItem($index){ |
|
| 68 | + public function getItem($index) { |
|
| 69 | 69 | return parent::getItem($index); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -104,10 +104,10 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | |
| 107 | - public static function radios($identifier,$name, $items=array(), $label=NULL, $value=null, $type=NULL) { |
|
| 108 | - $fields=array (); |
|
| 107 | + public static function radios($identifier, $name, $items=array(), $label=NULL, $value=null, $type=NULL) { |
|
| 108 | + $fields=array(); |
|
| 109 | 109 | $i=0; |
| 110 | - foreach ( $items as $val => $caption ) { |
|
| 110 | + foreach ($items as $val => $caption) { |
|
| 111 | 111 | $itemO=new HtmlFormRadio($name."-".$i++, $name, $caption, $val, $type); |
| 112 | 112 | if ($val===$value) { |
| 113 | 113 | $itemO->getDataField()->setProperty("checked", ""); |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | return $radios; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - public static function checkeds($identifier,$name, $items=array(), $label=NULL, $values=array(), $type=NULL) { |
|
| 124 | - $fields=array (); |
|
| 123 | + public static function checkeds($identifier, $name, $items=array(), $label=NULL, $values=array(), $type=NULL) { |
|
| 124 | + $fields=array(); |
|
| 125 | 125 | $i=0; |
| 126 | - foreach ( $items as $val => $caption ) { |
|
| 126 | + foreach ($items as $val => $caption) { |
|
| 127 | 127 | $itemO=new HtmlFormCheckbox($name."-".$i++, $caption, $val, $type); |
| 128 | 128 | $itemO->setName($name); |
| 129 | 129 | if (\array_search($val, $values)!==false) { |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | return $this; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - public function run(JsUtils $js){ |
|
| 146 | - $result= parent::run($js); |
|
| 145 | + public function run(JsUtils $js) { |
|
| 146 | + $result=parent::run($js); |
|
| 147 | 147 | //return $result->setItemSelector("[data-value]"); |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -29,12 +29,14 @@ discard block |
||
| 29 | 29 | if (\is_string($end)) { |
| 30 | 30 | $label=$end; |
| 31 | 31 | \array_pop($fields); |
| 32 | - } else |
|
| 33 | - $label=NULL; |
|
| 32 | + } else { |
|
| 33 | + $label=NULL; |
|
| 34 | + } |
|
| 34 | 35 | } |
| 35 | 36 | } |
| 36 | - if (isset($label)) |
|
| 37 | - $this->setLabel($label); |
|
| 37 | + if (isset($label)) { |
|
| 38 | + $this->setLabel($label); |
|
| 39 | + } |
|
| 38 | 40 | foreach ( $fields as $field ) { |
| 39 | 41 | $this->addItem($field); |
| 40 | 42 | } |
@@ -57,8 +59,9 @@ discard block |
||
| 57 | 59 | |
| 58 | 60 | public function addItem($item) { |
| 59 | 61 | $item=parent::addItem($item); |
| 60 | - if($item instanceof HtmlFormField) |
|
| 61 | - $item->setContainer($this); |
|
| 62 | + if($item instanceof HtmlFormField) { |
|
| 63 | + $item->setContainer($this); |
|
| 64 | + } |
|
| 62 | 65 | return $item; |
| 63 | 66 | } |
| 64 | 67 | |
@@ -73,8 +76,9 @@ discard block |
||
| 73 | 76 | if ($this->_equalWidth) { |
| 74 | 77 | $count=$this->count(); |
| 75 | 78 | $this->addToProperty("class", Wide::getConstants()["W".$count]." fields"); |
| 76 | - } else |
|
| 77 | - $this->addToProperty("class", "fields"); |
|
| 79 | + } else { |
|
| 80 | + $this->addToProperty("class", "fields"); |
|
| 81 | + } |
|
| 78 | 82 | return parent::compile($js, $view); |
| 79 | 83 | } |
| 80 | 84 | |
@@ -115,8 +119,9 @@ discard block |
||
| 115 | 119 | $fields[]=$itemO; |
| 116 | 120 | } |
| 117 | 121 | $radios=new HtmlFormFields($identifier, $fields); |
| 118 | - if (isset($label)) |
|
| 119 | - $radios->setLabel($label)->setProperty("for", $name); |
|
| 122 | + if (isset($label)) { |
|
| 123 | + $radios->setLabel($label)->setProperty("for", $name); |
|
| 124 | + } |
|
| 120 | 125 | return $radios; |
| 121 | 126 | } |
| 122 | 127 | |
@@ -132,8 +137,9 @@ discard block |
||
| 132 | 137 | $fields[]=$itemO; |
| 133 | 138 | } |
| 134 | 139 | $radios=new HtmlFormFields($identifier, $fields); |
| 135 | - if (isset($label)) |
|
| 136 | - $radios->setLabel($label)->setProperty("for", $name); |
|
| 140 | + if (isset($label)) { |
|
| 141 | + $radios->setLabel($label)->setProperty("for", $name); |
|
| 142 | + } |
|
| 137 | 143 | return $radios; |
| 138 | 144 | } |
| 139 | 145 | |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | * @param string $type |
| 44 | 44 | * @return HtmlFormFields |
| 45 | 45 | */ |
| 46 | - public function htmlRadios($identifier, $items=[], $label=NULL,$value=NULL, $type=NULL) { |
|
| 47 | - return $this->addHtmlComponent(HtmlFormFields::radios($identifier,$items,$label,$value,$type)); |
|
| 46 | + public function htmlRadios($identifier, $items=[], $label=NULL, $value=NULL, $type=NULL) { |
|
| 47 | + return $this->addHtmlComponent(HtmlFormFields::radios($identifier, $items, $label, $value, $type)); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @return HtmlModal |
| 101 | 101 | */ |
| 102 | 102 | public function htmlModal($identifier, $header="", $content="", $actions=array()) { |
| 103 | - return $this->addHtmlComponent(new HtmlModal($identifier, $header,$content,$actions)); |
|
| 103 | + return $this->addHtmlComponent(new HtmlModal($identifier, $header, $content, $actions)); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | * @param boolean $associative |
| 132 | 132 | * @return HtmlDropdown |
| 133 | 133 | */ |
| 134 | - public function htmlDropdown($identifier, $value="", $items=array(),$associative=true) { |
|
| 135 | - return $this->addHtmlComponent(new HtmlDropdown($identifier, $value, $items,$associative)); |
|
| 134 | + public function htmlDropdown($identifier, $value="", $items=array(), $associative=true) { |
|
| 135 | + return $this->addHtmlComponent(new HtmlDropdown($identifier, $value, $items, $associative)); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @return mixed |
| 38 | 38 | */ |
| 39 | 39 | public function getLibraryId() { |
| 40 | - if( isset($this->_libraryId)){ |
|
| 40 | + if (isset($this->_libraryId)) { |
|
| 41 | 41 | return $this->_libraryId; |
| 42 | 42 | } |
| 43 | 43 | return $this->identifier; |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param mixed $_libraryId |
| 48 | 48 | */ |
| 49 | 49 | public function setLibraryId($_libraryId) { |
| 50 | - $this->_libraryId = $_libraryId; |
|
| 50 | + $this->_libraryId=$_libraryId; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | trait JsUtilsActionsTrait { |
| 13 | 13 | |
| 14 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
| 14 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
| 15 | 15 | /** |
| 16 | 16 | * show or hide with effect |
| 17 | 17 | * |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @param boolean $immediatly defers the execution if set to false |
| 23 | 23 | * @return string |
| 24 | 24 | */ |
| 25 | - protected function _showHideWithEffect($action,$element='this', $speed='', $callback='', $immediatly=false) { |
|
| 25 | + protected function _showHideWithEffect($action, $element='this', $speed='', $callback='', $immediatly=false) { |
|
| 26 | 26 | $element=Javascript::prep_element($element); |
| 27 | 27 | $speed=$this->_validate_speed($speed); |
| 28 | 28 | if ($callback!='') { |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | * @return string |
| 40 | 40 | */ |
| 41 | 41 | private function _validate_speed($speed) { |
| 42 | - if (in_array($speed, array ( |
|
| 43 | - 'slow','normal','fast' |
|
| 42 | + if (in_array($speed, array( |
|
| 43 | + 'slow', 'normal', 'fast' |
|
| 44 | 44 | ))) { |
| 45 | 45 | $speed='"'.$speed.'"'; |
| 46 | 46 | } elseif (preg_match("/[^0-9]/", $speed)) { |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param string $param |
| 58 | 58 | * @param boolean $immediatly delayed if false |
| 59 | 59 | */ |
| 60 | - public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) { |
|
| 60 | + public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) { |
|
| 61 | 61 | $element=Javascript::prep_element($element); |
| 62 | 62 | if (isset($param)) { |
| 63 | 63 | $param=Javascript::prep_value($param); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @param boolean $immediatly delayed if false |
| 78 | 78 | * @return string |
| 79 | 79 | */ |
| 80 | - public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) { |
|
| 80 | + public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) { |
|
| 81 | 81 | $to=Javascript::prep_element($to); |
| 82 | 82 | $element=Javascript::prep_element($element); |
| 83 | 83 | $str="$({$to}).{$jQueryCall}({$element});"; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @return string |
| 95 | 95 | */ |
| 96 | 96 | public function addClass($element='this', $class='', $immediatly=false) { |
| 97 | - return $this->_genericCallValue('addClass',$element, $class, $immediatly); |
|
| 97 | + return $this->_genericCallValue('addClass', $element, $class, $immediatly); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | * @param boolean $immediatly defers the execution if set to false |
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | - public function after($to, $element, $immediatly=false){ |
|
| 108 | - return $this->_genericCallElement('after',$to, $element, $immediatly); |
|
| 107 | + public function after($to, $element, $immediatly=false) { |
|
| 108 | + return $this->_genericCallElement('after', $to, $element, $immediatly); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | * @param boolean $immediatly defers the execution if set to false |
| 116 | 116 | * @return string |
| 117 | 117 | */ |
| 118 | - public function before($to, $element, $immediatly=false){ |
|
| 119 | - return $this->_genericCallElement('before',$to, $element, $immediatly); |
|
| 118 | + public function before($to, $element, $immediatly=false) { |
|
| 119 | + return $this->_genericCallElement('before', $to, $element, $immediatly); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | * @param string $value |
| 145 | 145 | * @param boolean $immediatly defers the execution if set to false |
| 146 | 146 | */ |
| 147 | - public function val($element='this',$value='',$immediatly=false){ |
|
| 148 | - return $this->_genericCallValue('val',$element,$value,$immediatly); |
|
| 147 | + public function val($element='this', $value='', $immediatly=false) { |
|
| 148 | + return $this->_genericCallValue('val', $element, $value, $immediatly); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @param boolean $immediatly defers the execution if set to false |
| 156 | 156 | */ |
| 157 | 157 | public function html($element='this', $value='', $immediatly=false) { |
| 158 | - return $this->_genericCallValue('html',$element, $value, $immediatly); |
|
| 158 | + return $this->_genericCallValue('html', $element, $value, $immediatly); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | $animations="\t\t\t"; |
| 176 | 176 | if (\is_array($params)) { |
| 177 | - foreach ( $params as $param => $value ) { |
|
| 177 | + foreach ($params as $param => $value) { |
|
| 178 | 178 | $animations.=$param.': \''.$value.'\', '; |
| 179 | 179 | } |
| 180 | 180 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @return string |
| 204 | 204 | */ |
| 205 | 205 | public function append($to, $element, $immediatly=false) { |
| 206 | - return $this->_genericCallElement('append',$to, $element, $immediatly); |
|
| 206 | + return $this->_genericCallElement('append', $to, $element, $immediatly); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @return string |
| 215 | 215 | */ |
| 216 | 216 | public function prepend($to, $element, $immediatly=false) { |
| 217 | - return $this->_genericCallElement('prepend',$to, $element, $immediatly); |
|
| 217 | + return $this->_genericCallElement('prepend', $to, $element, $immediatly); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * @return string |
| 228 | 228 | */ |
| 229 | 229 | public function fadeIn($element='this', $speed='', $callback='', $immediatly=false) { |
| 230 | - return $this->_showHideWithEffect("fadeIn",$element,$speed,$callback,$immediatly); |
|
| 230 | + return $this->_showHideWithEffect("fadeIn", $element, $speed, $callback, $immediatly); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * @return string |
| 241 | 241 | */ |
| 242 | 242 | public function fadeOut($element='this', $speed='', $callback='', $immediatly=false) { |
| 243 | - return $this->_showHideWithEffect("fadeOut",$element,$speed,$callback,$immediatly); |
|
| 243 | + return $this->_showHideWithEffect("fadeOut", $element, $speed, $callback, $immediatly); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * @return string |
| 254 | 254 | */ |
| 255 | 255 | public function slideUp($element='this', $speed='', $callback='', $immediatly=false) { |
| 256 | - return $this->_showHideWithEffect("slideUp",$element,$speed,$callback,$immediatly); |
|
| 256 | + return $this->_showHideWithEffect("slideUp", $element, $speed, $callback, $immediatly); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * @return string |
| 266 | 266 | */ |
| 267 | 267 | public function removeClass($element='this', $class='', $immediatly=false) { |
| 268 | - return $this->_genericCallValue('removeClass',$element, $class, $immediatly); |
|
| 268 | + return $this->_genericCallValue('removeClass', $element, $class, $immediatly); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * @return string |
| 279 | 279 | */ |
| 280 | 280 | public function slideDown($element='this', $speed='', $callback='', $immediatly=false) { |
| 281 | - return $this->_showHideWithEffect("slideDown",$element,$speed,$callback,$immediatly); |
|
| 281 | + return $this->_showHideWithEffect("slideDown", $element, $speed, $callback, $immediatly); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | * @return string |
| 292 | 292 | */ |
| 293 | 293 | public function slideToggle($element='this', $speed='', $callback='', $immediatly=false) { |
| 294 | - return $this->_showHideWithEffect("slideToggle",$element,$speed,$callback,$immediatly); |
|
| 294 | + return $this->_showHideWithEffect("slideToggle", $element, $speed, $callback, $immediatly); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | * @return string |
| 305 | 305 | */ |
| 306 | 306 | public function hide($element='this', $speed='', $callback='', $immediatly=false) { |
| 307 | - return $this->_showHideWithEffect("hide",$element,$speed,$callback,$immediatly); |
|
| 307 | + return $this->_showHideWithEffect("hide", $element, $speed, $callback, $immediatly); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | * @return string |
| 318 | 318 | */ |
| 319 | 319 | public function toggle($element='this', $speed='', $callback='', $immediatly=false) { |
| 320 | - return $this->_showHideWithEffect("toggle",$element,$speed,$callback,$immediatly); |
|
| 320 | + return $this->_showHideWithEffect("toggle", $element, $speed, $callback, $immediatly); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | * @return string |
| 330 | 330 | */ |
| 331 | 331 | public function toggleClass($element='this', $class='', $immediatly=false) { |
| 332 | - return $this->_genericCallValue('toggleClass',$element, $class, $immediatly); |
|
| 332 | + return $this->_genericCallValue('toggleClass', $element, $class, $immediatly); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | * @return string |
| 358 | 358 | */ |
| 359 | 359 | public function show($element='this', $speed='', $callback='', $immediatly=false) { |
| 360 | - return $this->_showHideWithEffect("show",$element,$speed,$callback,$immediatly); |
|
| 360 | + return $this->_showHideWithEffect("show", $element, $speed, $callback, $immediatly); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -369,8 +369,8 @@ discard block |
||
| 369 | 369 | */ |
| 370 | 370 | public function sortable($element, $options=array()) { |
| 371 | 371 | if (count($options)>0) { |
| 372 | - $sort_options=array (); |
|
| 373 | - foreach ( $options as $k => $v ) { |
|
| 372 | + $sort_options=array(); |
|
| 373 | + foreach ($options as $k => $v) { |
|
| 374 | 374 | $sort_options[]="\n\t\t".$k.': '.$v.""; |
| 375 | 375 | } |
| 376 | 376 | $sort_options=implode(",", $sort_options); |
@@ -467,8 +467,8 @@ discard block |
||
| 467 | 467 | * @param boolean $immediatly |
| 468 | 468 | * @return string |
| 469 | 469 | */ |
| 470 | - private function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="",$immediatly=true) { |
|
| 471 | - return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 470 | + private function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="", $immediatly=true) { |
|
| 471 | + return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | $preventDefault=false; |
| 487 | 487 | $immediatly=true; |
| 488 | 488 | extract($parameters); |
| 489 | - return $this->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback,$immediatly); |
|
| 489 | + return $this->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback, $immediatly); |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | /** |
@@ -527,11 +527,11 @@ discard block |
||
| 527 | 527 | $preventDefault=false; |
| 528 | 528 | $immediatly=true; |
| 529 | 529 | extract($parameters); |
| 530 | - $script=$this->_add_event($element, $this->exec($js), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 530 | + $script=$this->_add_event($element, $this->exec($js), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 531 | 531 | return $script; |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - public function setJsonToElement($json,$elementClass="_element",$immediatly=true){ |
|
| 534 | + public function setJsonToElement($json, $elementClass="_element", $immediatly=true) { |
|
| 535 | 535 | $retour="var data={$json};" |
| 536 | 536 | ."\n\tdata=($.isPlainObject(data))?data:JSON.parse(data);" |
| 537 | 537 | ."\n\tvar pk=data['pk'];var object=data['object'];" |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | ."\n\t});" |
| 543 | 543 | ."\n}};\n"; |
| 544 | 544 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 545 | - return $this->exec($retour,$immediatly); |
|
| 545 | + return $this->exec($retour, $immediatly); |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | /** |
@@ -550,10 +550,10 @@ discard block |
||
| 550 | 550 | * @param string $element The element selector |
| 551 | 551 | * @param array $parameters default : array("attr"=>"id","preventDefault"=>false,"stopPropagation"=>false,"immediatly"=>true) |
| 552 | 552 | */ |
| 553 | - public function setDraggable($element,$parameters=[]){ |
|
| 553 | + public function setDraggable($element, $parameters=[]) { |
|
| 554 | 554 | $attr="id"; |
| 555 | 555 | extract($parameters); |
| 556 | - $script=$this->_add_event($element, Javascript::draggable($attr), "dragstart",$parameters); |
|
| 556 | + $script=$this->_add_event($element, Javascript::draggable($attr), "dragstart", $parameters); |
|
| 557 | 557 | return $script; |
| 558 | 558 | } |
| 559 | 559 | |
@@ -563,13 +563,13 @@ discard block |
||
| 563 | 563 | * @param array $parameters default : array("attr"=>"id","stopPropagation"=>false,"immediatly"=>true,"jqueryDone"=>"append") |
| 564 | 564 | * @param string $jsCallback the js script to call when element is dropped |
| 565 | 565 | */ |
| 566 | - public function asDropZone($element,$jsCallback="",$parameters=[]){ |
|
| 566 | + public function asDropZone($element, $jsCallback="", $parameters=[]) { |
|
| 567 | 567 | $stopPropagation=false; |
| 568 | 568 | $immediatly=true; |
| 569 | 569 | $jqueryDone="append"; |
| 570 | - $script=$this->_add_event($element, '', "dragover",true,$stopPropagation,$immediatly); |
|
| 570 | + $script=$this->_add_event($element, '', "dragover", true, $stopPropagation, $immediatly); |
|
| 571 | 571 | extract($parameters); |
| 572 | - $script.=$this->_add_event($element, Javascript::dropZone($jqueryDone,$jsCallback), "drop",true,$stopPropagation,$immediatly); |
|
| 572 | + $script.=$this->_add_event($element, Javascript::dropZone($jqueryDone, $jsCallback), "drop", true, $stopPropagation, $immediatly); |
|
| 573 | 573 | return $script; |
| 574 | 574 | } |
| 575 | 575 | |
@@ -581,16 +581,16 @@ discard block |
||
| 581 | 581 | * @param boolean $immediatly delayed if false |
| 582 | 582 | * @return string |
| 583 | 583 | */ |
| 584 | - public function interval($jsCode,$time,$globalName=null,$immediatly=true){ |
|
| 585 | - if(!Javascript::isFunction($jsCode)){ |
|
| 584 | + public function interval($jsCode, $time, $globalName=null, $immediatly=true) { |
|
| 585 | + if (!Javascript::isFunction($jsCode)) { |
|
| 586 | 586 | $jsCode="function(){\n".$jsCode."\n}"; |
| 587 | 587 | } |
| 588 | - if(isset($globalName)){ |
|
| 588 | + if (isset($globalName)) { |
|
| 589 | 589 | $script="if(window.{$globalName}){clearInterval(window.{$globalName});}\nwindow.{$globalName}=setInterval({$jsCode},{$time});"; |
| 590 | - }else{ |
|
| 590 | + } else { |
|
| 591 | 591 | $script="setInterval({$jsCode},{$time});"; |
| 592 | 592 | } |
| 593 | - return $this->exec($script,$immediatly); |
|
| 593 | + return $this->exec($script, $immediatly); |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | /** |
@@ -599,8 +599,8 @@ discard block |
||
| 599 | 599 | * @param boolean $immediatly delayed if false |
| 600 | 600 | * @return string |
| 601 | 601 | */ |
| 602 | - public function clearInterval($globalName,$immediatly=true){ |
|
| 603 | - return $this->exec("if(window.{$globalName}){clearInterval(window.{$globalName});}",$immediatly); |
|
| 602 | + public function clearInterval($globalName, $immediatly=true) { |
|
| 603 | + return $this->exec("if(window.{$globalName}){clearInterval(window.{$globalName});}", $immediatly); |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | /** |
@@ -613,17 +613,17 @@ discard block |
||
| 613 | 613 | * @param boolean $immediatly delayed if false |
| 614 | 614 | * @return string |
| 615 | 615 | */ |
| 616 | - public function counter($counterSelector,$value=0,$limit=0,$globalName=null,$countDown=true,$immediatly=true){ |
|
| 616 | + public function counter($counterSelector, $value=0, $limit=0, $globalName=null, $countDown=true, $immediatly=true) { |
|
| 617 | 617 | $stop=""; |
| 618 | - if($countDown){ |
|
| 618 | + if ($countDown) { |
|
| 619 | 619 | $stop="if (--timer < ".$limit.") {clearInterval(interval);display.trigger({type:'counter-end',value: timer,limit:".$limit."});}"; |
| 620 | - }else{ |
|
| 621 | - if($limit!=0){ |
|
| 620 | + } else { |
|
| 621 | + if ($limit!=0) { |
|
| 622 | 622 | $stop="if (++timer > ".$limit.") {clearInterval(interval);display.trigger({type:'counter-end',value: timer,limit:".$limit."});}"; |
| 623 | 623 | } |
| 624 | 624 | } |
| 625 | 625 | $global=""; |
| 626 | - if(isset($globalName)){ |
|
| 626 | + if (isset($globalName)) { |
|
| 627 | 627 | $global="\nwindow.{$globalName}=interval;"; |
| 628 | 628 | } |
| 629 | 629 | $timer="var startTimer=function(duration, display) {var timer = duration, minutes, seconds; |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | ".$global." |
| 640 | 640 | }"; |
| 641 | 641 | $element='$("'.$counterSelector.'")'; |
| 642 | - return $this->exec($timer."\nstartTimer(".$value.",".$element.");",$immediatly); |
|
| 642 | + return $this->exec($timer."\nstartTimer(".$value.",".$element.");", $immediatly); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | /** |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | * @param boolean $countDown count down if true or elapse if false |
| 654 | 654 | * @return string |
| 655 | 655 | */ |
| 656 | - public function counterOn($element,$event,$counterSelector,$value=0,$limit=0,$globalName=null,$countDown=true){ |
|
| 657 | - return $this->execOn($event, $element, $this->counter($counterSelector,$value,$limit,$globalName,$countDown,false)); |
|
| 656 | + public function counterOn($element, $event, $counterSelector, $value=0, $limit=0, $globalName=null, $countDown=true) { |
|
| 657 | + return $this->execOn($event, $element, $this->counter($counterSelector, $value, $limit, $globalName, $countDown, false)); |
|
| 658 | 658 | } |
| 659 | 659 | } |
@@ -29,8 +29,9 @@ discard block |
||
| 29 | 29 | $callback=", function(){\n{$callback}\n}"; |
| 30 | 30 | } |
| 31 | 31 | $str="$({$element}).{$action}({$speed}{$callback});"; |
| 32 | - if ($immediatly) |
|
| 33 | - $this->jquery_code_for_compile[]=$str; |
|
| 32 | + if ($immediatly) { |
|
| 33 | + $this->jquery_code_for_compile[]=$str; |
|
| 34 | + } |
|
| 34 | 35 | return $str; |
| 35 | 36 | } |
| 36 | 37 | /** |
@@ -62,10 +63,12 @@ discard block |
||
| 62 | 63 | if (isset($param)) { |
| 63 | 64 | $param=Javascript::prep_value($param); |
| 64 | 65 | $str="$({$element}).{$jQueryCall}({$param});"; |
| 65 | - } else |
|
| 66 | - $str="$({$element}).{$jQueryCall}();"; |
|
| 67 | - if ($immediatly) |
|
| 68 | - $this->jquery_code_for_compile[]=$str; |
|
| 66 | + } else { |
|
| 67 | + $str="$({$element}).{$jQueryCall}();"; |
|
| 68 | + } |
|
| 69 | + if ($immediatly) { |
|
| 70 | + $this->jquery_code_for_compile[]=$str; |
|
| 71 | + } |
|
| 69 | 72 | return $str; |
| 70 | 73 | } |
| 71 | 74 | |
@@ -81,8 +84,9 @@ discard block |
||
| 81 | 84 | $to=Javascript::prep_element($to); |
| 82 | 85 | $element=Javascript::prep_element($element); |
| 83 | 86 | $str="$({$to}).{$jQueryCall}({$element});"; |
| 84 | - if ($immediatly) |
|
| 85 | - $this->jquery_code_for_compile[]=$str; |
|
| 87 | + if ($immediatly) { |
|
| 88 | + $this->jquery_code_for_compile[]=$str; |
|
| 89 | + } |
|
| 86 | 90 | return $str; |
| 87 | 91 | } |
| 88 | 92 | /** |
@@ -131,10 +135,12 @@ discard block |
||
| 131 | 135 | if (isset($value)) { |
| 132 | 136 | $value=Javascript::prep_value($value); |
| 133 | 137 | $str="$({$element}).attr(\"$attributeName\",{$value});"; |
| 134 | - } else |
|
| 135 | - $str="$({$element}).attr(\"$attributeName\");"; |
|
| 136 | - if ($immediatly) |
|
| 137 | - $this->jquery_code_for_compile[]=$str; |
|
| 138 | + } else { |
|
| 139 | + $str="$({$element}).attr(\"$attributeName\");"; |
|
| 140 | + } |
|
| 141 | + if ($immediatly) { |
|
| 142 | + $this->jquery_code_for_compile[]=$str; |
|
| 143 | + } |
|
| 138 | 144 | return $str; |
| 139 | 145 | } |
| 140 | 146 | |
@@ -190,8 +196,9 @@ discard block |
||
| 190 | 196 | |
| 191 | 197 | $str="$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");"; |
| 192 | 198 | |
| 193 | - if ($immediatly) |
|
| 194 | - $this->jquery_code_for_compile[]=$str; |
|
| 199 | + if ($immediatly) { |
|
| 200 | + $this->jquery_code_for_compile[]=$str; |
|
| 201 | + } |
|
| 195 | 202 | return $str; |
| 196 | 203 | } |
| 197 | 204 | |
@@ -342,8 +349,9 @@ discard block |
||
| 342 | 349 | $element=Javascript::prep_element($element); |
| 343 | 350 | $str="$({$element}).trigger(\"$event\");"; |
| 344 | 351 | |
| 345 | - if ($immediatly) |
|
| 346 | - $this->jquery_code_for_compile[]=$str; |
|
| 352 | + if ($immediatly) { |
|
| 353 | + $this->jquery_code_for_compile[]=$str; |
|
| 354 | + } |
|
| 347 | 355 | return $str; |
| 348 | 356 | } |
| 349 | 357 | |
@@ -405,8 +413,9 @@ discard block |
||
| 405 | 413 | $str.="else{".$jsCodeIfFalse."}"; |
| 406 | 414 | } |
| 407 | 415 | |
| 408 | - if ($immediatly) |
|
| 409 | - $this->jquery_code_for_compile[]=$str; |
|
| 416 | + if ($immediatly) { |
|
| 417 | + $this->jquery_code_for_compile[]=$str; |
|
| 418 | + } |
|
| 410 | 419 | return $str; |
| 411 | 420 | } |
| 412 | 421 | |
@@ -422,11 +431,13 @@ discard block |
||
| 422 | 431 | private function _doJQuery($element, $jqueryCall, $param="", $jsCallback="", $immediatly=false) { |
| 423 | 432 | $param=Javascript::prep_value($param); |
| 424 | 433 | $callback=""; |
| 425 | - if ($jsCallback!="") |
|
| 426 | - $callback=", function(event){\n{$jsCallback}\n}"; |
|
| 434 | + if ($jsCallback!="") { |
|
| 435 | + $callback=", function(event){\n{$jsCallback}\n}"; |
|
| 436 | + } |
|
| 427 | 437 | $script="$(".Javascript::prep_element($element).").".$jqueryCall."(".$param.$callback.");\n"; |
| 428 | - if ($immediatly) |
|
| 429 | - $this->jquery_code_for_compile[]=$script; |
|
| 438 | + if ($immediatly) { |
|
| 439 | + $this->jquery_code_for_compile[]=$script; |
|
| 440 | + } |
|
| 430 | 441 | return $script; |
| 431 | 442 | } |
| 432 | 443 | |
@@ -497,8 +508,9 @@ discard block |
||
| 497 | 508 | */ |
| 498 | 509 | public function exec($js, $immediatly=false) { |
| 499 | 510 | $script=$js."\n"; |
| 500 | - if ($immediatly) |
|
| 501 | - $this->jquery_code_for_compile[]=$script; |
|
| 511 | + if ($immediatly) { |
|
| 512 | + $this->jquery_code_for_compile[]=$script; |
|
| 513 | + } |
|
| 502 | 514 | return $script; |
| 503 | 515 | } |
| 504 | 516 | |
@@ -587,7 +599,7 @@ discard block |
||
| 587 | 599 | } |
| 588 | 600 | if(isset($globalName)){ |
| 589 | 601 | $script="if(window.{$globalName}){clearInterval(window.{$globalName});}\nwindow.{$globalName}=setInterval({$jsCode},{$time});"; |
| 590 | - }else{ |
|
| 602 | + } else{ |
|
| 591 | 603 | $script="setInterval({$jsCode},{$time});"; |
| 592 | 604 | } |
| 593 | 605 | return $this->exec($script,$immediatly); |
@@ -617,7 +629,7 @@ discard block |
||
| 617 | 629 | $stop=""; |
| 618 | 630 | if($countDown){ |
| 619 | 631 | $stop="if (--timer < ".$limit.") {clearInterval(interval);display.trigger({type:'counter-end',value: timer,limit:".$limit."});}"; |
| 620 | - }else{ |
|
| 632 | + } else{ |
|
| 621 | 633 | if($limit!=0){ |
| 622 | 634 | $stop="if (++timer > ".$limit.") {clearInterval(interval);display.trigger({type:'counter-end',value: timer,limit:".$limit."});}"; |
| 623 | 635 | } |
@@ -30,15 +30,15 @@ discard block |
||
| 30 | 30 | return $this->content; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function addContent($content,$before=false) { |
|
| 33 | + public function addContent($content, $before=false) { |
|
| 34 | 34 | if (!\is_array($this->content)) { |
| 35 | - if(isset($this->content)) |
|
| 36 | - $this->content=array ($this->content); |
|
| 35 | + if (isset($this->content)) |
|
| 36 | + $this->content=array($this->content); |
|
| 37 | 37 | else |
| 38 | 38 | $this->content=array(); |
| 39 | 39 | } |
| 40 | - if($before) |
|
| 41 | - array_unshift($this->content,$content); |
|
| 40 | + if ($before) |
|
| 41 | + array_unshift($this->content, $content); |
|
| 42 | 42 | else |
| 43 | 43 | $this->content []=$content; |
| 44 | 44 | return $this; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | if ($this->content instanceof HtmlDoubleElement) { |
| 54 | 54 | $this->content->run($js); |
| 55 | 55 | } else if (\is_array($this->content)) { |
| 56 | - foreach ( $this->content as $itemContent ) { |
|
| 56 | + foreach ($this->content as $itemContent) { |
|
| 57 | 57 | if ($itemContent instanceof HtmlDoubleElement) { |
| 58 | 58 | $itemContent->run($js); |
| 59 | 59 | } |
@@ -70,19 +70,19 @@ discard block |
||
| 70 | 70 | return $this; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function getContentInstances($class){ |
|
| 74 | - return $this->_getContentInstances($class,$this->content); |
|
| 73 | + public function getContentInstances($class) { |
|
| 74 | + return $this->_getContentInstances($class, $this->content); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - protected function _getContentInstances($class,$content){ |
|
| 77 | + protected function _getContentInstances($class, $content) { |
|
| 78 | 78 | $instances=[]; |
| 79 | - if($content instanceof $class){ |
|
| 79 | + if ($content instanceof $class) { |
|
| 80 | 80 | $instances[]=$content; |
| 81 | - }elseif($content instanceof HtmlDoubleElement){ |
|
| 82 | - $instances=\array_merge($instances,$content->getContentInstances($class)); |
|
| 83 | - }elseif (\is_array($content)){ |
|
| 84 | - foreach ($content as $element){ |
|
| 85 | - $instances=\array_merge($instances,$this->_getContentInstances($class, $element)); |
|
| 81 | + }elseif ($content instanceof HtmlDoubleElement) { |
|
| 82 | + $instances=\array_merge($instances, $content->getContentInstances($class)); |
|
| 83 | + }elseif (\is_array($content)) { |
|
| 84 | + foreach ($content as $element) { |
|
| 85 | + $instances=\array_merge($instances, $this->_getContentInstances($class, $element)); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | return $instances; |
@@ -92,36 +92,36 @@ discard block |
||
| 92 | 92 | * Transforms the element into a link |
| 93 | 93 | * @return HtmlDoubleElement |
| 94 | 94 | */ |
| 95 | - public function asLink($href=NULL,$target=NULL) { |
|
| 95 | + public function asLink($href=NULL, $target=NULL) { |
|
| 96 | 96 | if (isset($href)) |
| 97 | 97 | $this->setProperty("href", $href); |
| 98 | - if(isset($target)) |
|
| 98 | + if (isset($target)) |
|
| 99 | 99 | $this->setProperty("target", $target); |
| 100 | 100 | return $this->setTagName("a"); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - public function getTextContent(){ |
|
| 104 | - if(is_array($this->content)){ |
|
| 103 | + public function getTextContent() { |
|
| 104 | + if (is_array($this->content)) { |
|
| 105 | 105 | return strip_tags(implode("", $this->content)); |
| 106 | 106 | } |
| 107 | 107 | return strip_tags($this->content); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public function asEditable(HtmlFormField $field,$asForm=false,$setValueProperty="val()"){ |
|
| 110 | + public function asEditable(HtmlFormField $field, $asForm=false, $setValueProperty="val()") { |
|
| 111 | 111 | $idF=$field->getIdentifier(); |
| 112 | 112 | $idE=$idF; |
| 113 | - if($asForm){ |
|
| 113 | + if ($asForm) { |
|
| 114 | 114 | $frm=new HtmlForm("frm-".$field->getIdentifier()); |
| 115 | 115 | $frm->setProperty("onsubmit", "return false;"); |
| 116 | 116 | $fields=$frm->addFields(); |
| 117 | 117 | $idE=$frm->getIdentifier(); |
| 118 | 118 | $fields->addItem($field); |
| 119 | - $fields->addButtonIcon("bt-okay", "check","green mini","\$('#".$idE."').trigger('validate',{value: $('#'+idF+' input').val()});"); |
|
| 120 | - $fields->addButtonIcon("bt-cancel", "close","mini","\$('#".$idE."').trigger('endEdit');"); |
|
| 119 | + $fields->addButtonIcon("bt-okay", "check", "green mini", "\$('#".$idE."').trigger('validate',{value: $('#'+idF+' input').val()});"); |
|
| 120 | + $fields->addButtonIcon("bt-cancel", "close", "mini", "\$('#".$idE."').trigger('endEdit');"); |
|
| 121 | 121 | $this->_editableContent=$frm; |
| 122 | 122 | $keypress=""; |
| 123 | 123 | $focusOut=""; |
| 124 | - }else{ |
|
| 124 | + } else { |
|
| 125 | 125 | $focusOut="if(e.relatedTarget==null)elm.trigger('endEdit');"; |
| 126 | 126 | $this->_editableContent=$field; |
| 127 | 127 | $keypress="$('#".$idF."').keyup(function(e){if(e.which == 13) {\$('#".$idE."').trigger('validate',{value: $('#'+idF+' input').val()});}if(e.keyCode===27) {\$('#".$idE."').trigger('endEdit');}});"; |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | * {@inheritDoc} |
| 135 | 135 | * @see \Ajax\common\html\BaseHtml::compile_once() |
| 136 | 136 | */ |
| 137 | - protected function compile_once(\Ajax\JsUtils $js = NULL, &$view = NULL) { |
|
| 138 | - if(!$this->_compiled && isset($this->_editableContent)){ |
|
| 139 | - $this->wrap("",$this->_editableContent); |
|
| 137 | + protected function compile_once(\Ajax\JsUtils $js=NULL, &$view=NULL) { |
|
| 138 | + if (!$this->_compiled && isset($this->_editableContent)) { |
|
| 139 | + $this->wrap("", $this->_editableContent); |
|
| 140 | 140 | } |
| 141 | - parent::compile_once($js,$view); |
|
| 141 | + parent::compile_once($js, $view); |
|
| 142 | 142 | |
| 143 | 143 | } |
| 144 | 144 | |
@@ -32,15 +32,17 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public function addContent($content,$before=false) { |
| 34 | 34 | if (!\is_array($this->content)) { |
| 35 | - if(isset($this->content)) |
|
| 36 | - $this->content=array ($this->content); |
|
| 37 | - else |
|
| 38 | - $this->content=array(); |
|
| 35 | + if(isset($this->content)) { |
|
| 36 | + $this->content=array ($this->content); |
|
| 37 | + } else { |
|
| 38 | + $this->content=array(); |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | + if($before) { |
|
| 42 | + array_unshift($this->content,$content); |
|
| 43 | + } else { |
|
| 44 | + $this->content []=$content; |
|
| 39 | 45 | } |
| 40 | - if($before) |
|
| 41 | - array_unshift($this->content,$content); |
|
| 42 | - else |
|
| 43 | - $this->content []=$content; |
|
| 44 | 46 | return $this; |
| 45 | 47 | } |
| 46 | 48 | |
@@ -78,9 +80,9 @@ discard block |
||
| 78 | 80 | $instances=[]; |
| 79 | 81 | if($content instanceof $class){ |
| 80 | 82 | $instances[]=$content; |
| 81 | - }elseif($content instanceof HtmlDoubleElement){ |
|
| 83 | + } elseif($content instanceof HtmlDoubleElement){ |
|
| 82 | 84 | $instances=\array_merge($instances,$content->getContentInstances($class)); |
| 83 | - }elseif (\is_array($content)){ |
|
| 85 | + } elseif (\is_array($content)){ |
|
| 84 | 86 | foreach ($content as $element){ |
| 85 | 87 | $instances=\array_merge($instances,$this->_getContentInstances($class, $element)); |
| 86 | 88 | } |
@@ -93,10 +95,12 @@ discard block |
||
| 93 | 95 | * @return HtmlDoubleElement |
| 94 | 96 | */ |
| 95 | 97 | public function asLink($href=NULL,$target=NULL) { |
| 96 | - if (isset($href)) |
|
| 97 | - $this->setProperty("href", $href); |
|
| 98 | - if(isset($target)) |
|
| 99 | - $this->setProperty("target", $target); |
|
| 98 | + if (isset($href)) { |
|
| 99 | + $this->setProperty("href", $href); |
|
| 100 | + } |
|
| 101 | + if(isset($target)) { |
|
| 102 | + $this->setProperty("target", $target); |
|
| 103 | + } |
|
| 100 | 104 | return $this->setTagName("a"); |
| 101 | 105 | } |
| 102 | 106 | |
@@ -121,7 +125,7 @@ discard block |
||
| 121 | 125 | $this->_editableContent=$frm; |
| 122 | 126 | $keypress=""; |
| 123 | 127 | $focusOut=""; |
| 124 | - }else{ |
|
| 128 | + } else{ |
|
| 125 | 129 | $focusOut="if(e.relatedTarget==null)elm.trigger('endEdit');"; |
| 126 | 130 | $this->_editableContent=$field; |
| 127 | 131 | $keypress="$('#".$idF."').keyup(function(e){if(e.which == 13) {\$('#".$idE."').trigger('validate',{value: $('#'+idF+' input').val()});}if(e.keyCode===27) {\$('#".$idE."').trigger('endEdit');}});"; |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * @param string $hookKey |
| 10 | 10 | * @return boolean |
| 11 | 11 | */ |
| 12 | - public function hookExists($hookKey){ |
|
| 12 | + public function hookExists($hookKey) { |
|
| 13 | 13 | return isset($this->_hooks[$hookKey]); |
| 14 | 14 | } |
| 15 | 15 | |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | * @param string $hookKey |
| 18 | 18 | * @return callable|NULL |
| 19 | 19 | */ |
| 20 | - public function getHook($hookKey){ |
|
| 21 | - if(isset($this->_hooks[$hookKey])){ |
|
| 20 | + public function getHook($hookKey) { |
|
| 21 | + if (isset($this->_hooks[$hookKey])) { |
|
| 22 | 22 | return $this->_hooks[$hookKey]; |
| 23 | 23 | } |
| 24 | 24 | return null; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param String $hookKey |
| 30 | 30 | * @param callable $callable |
| 31 | 31 | */ |
| 32 | - public function addHook($hookKey,$callable){ |
|
| 32 | + public function addHook($hookKey, $callable) { |
|
| 33 | 33 | $this->_hooks[$hookKey]=$callable; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | * @param mixed|null $variable |
| 40 | 40 | * @return void|mixed |
| 41 | 41 | */ |
| 42 | - public function execHook($hookKey,...$variables){ |
|
| 43 | - if(($hook=$this->getHook($hookKey))!=null){ |
|
| 44 | - return call_user_func_array($hook,$variables); |
|
| 42 | + public function execHook($hookKey, ...$variables) { |
|
| 43 | + if (($hook=$this->getHook($hookKey))!=null) { |
|
| 44 | + return call_user_func_array($hook, $variables); |
|
| 45 | 45 | } |
| 46 | 46 | return; |
| 47 | 47 | } |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Ajax\common\html; |
| 4 | 4 | |
| 5 | -class HtmlContentOnly extends HtmlDoubleElement{ |
|
| 6 | - public function __construct($content,$identifier=""){ |
|
| 5 | +class HtmlContentOnly extends HtmlDoubleElement { |
|
| 6 | + public function __construct($content, $identifier="") { |
|
| 7 | 7 | parent::__construct($identifier); |
| 8 | 8 | $this->_template='%wrapContentBefore%%content%%wrapContentAfter%'; |
| 9 | 9 | $this->setContent($content); |
@@ -21,36 +21,36 @@ discard block |
||
| 21 | 21 | use BaseTrait; |
| 22 | 22 | |
| 23 | 23 | public function __construct($identifier, $modelInstance=NULL) { |
| 24 | - parent::__construct($identifier, null,$modelInstance); |
|
| 24 | + parent::__construct($identifier, null, $modelInstance); |
|
| 25 | 25 | $this->_form=new HtmlForm($identifier); |
| 26 | 26 | $this->_init(new FormInstanceViewer($identifier), "form", $this->_form, true); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
| 29 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
| 30 | 30 | return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier(); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 34 | - if(!$this->_generated){ |
|
| 33 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 34 | + if (!$this->_generated) { |
|
| 35 | 35 | $this->_instanceViewer->setInstance($this->_modelInstance); |
| 36 | 36 | |
| 37 | 37 | $form=$this->content["form"]; |
| 38 | 38 | $this->_generateContent($form); |
| 39 | 39 | |
| 40 | - if(isset($this->_toolbar)){ |
|
| 40 | + if (isset($this->_toolbar)) { |
|
| 41 | 41 | $this->_setToolbarPosition($form); |
| 42 | 42 | } |
| 43 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]); |
|
| 43 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]); |
|
| 44 | 44 | $this->_generated=true; |
| 45 | 45 | } |
| 46 | - return parent::compile($js,$view); |
|
| 46 | + return parent::compile($js, $view); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @param HtmlForm $form |
| 51 | 51 | */ |
| 52 | - protected function _generateContent($form){ |
|
| 53 | - $values= $this->_instanceViewer->getValues(); |
|
| 52 | + protected function _generateContent($form) { |
|
| 53 | + $values=$this->_instanceViewer->getValues(); |
|
| 54 | 54 | $count=$this->_instanceViewer->count(); |
| 55 | 55 | $separators=$this->_instanceViewer->getSeparators(); |
| 56 | 56 | $headers=$this->_instanceViewer->getHeaders(); |
@@ -58,41 +58,41 @@ discard block |
||
| 58 | 58 | \sort($separators); |
| 59 | 59 | $size=\sizeof($separators); |
| 60 | 60 | $nb=0; |
| 61 | - if($size===1){ |
|
| 61 | + if ($size===1) { |
|
| 62 | 62 | $i=-1; |
| 63 | - foreach ($values as $v){ |
|
| 64 | - $this->_generateFields($form, [$v], $headers, $i, $wrappers,$nb++); |
|
| 63 | + foreach ($values as $v) { |
|
| 64 | + $this->_generateFields($form, [$v], $headers, $i, $wrappers, $nb++); |
|
| 65 | 65 | $i++; |
| 66 | 66 | } |
| 67 | - }else{ |
|
| 67 | + } else { |
|
| 68 | 68 | $separators[]=$count; |
| 69 | - for($i=0;$i<$size;$i++){ |
|
| 70 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
| 71 | - $this->_generateFields($form, $fields, $headers, $separators[$i], $wrappers,$nb++); |
|
| 69 | + for ($i=0; $i<$size; $i++) { |
|
| 70 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
| 71 | + $this->_generateFields($form, $fields, $headers, $separators[$i], $wrappers, $nb++); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | - if($this->_hasRules && !$this->getForm()->hasValidationParams()){ |
|
| 74 | + if ($this->_hasRules && !$this->getForm()->hasValidationParams()) { |
|
| 75 | 75 | $this->setValidationParams(["inline"=>true]); |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - protected function _generateFields($form,$values,$headers,$sepFirst,$wrappers,$nb){ |
|
| 79 | + protected function _generateFields($form, $values, $headers, $sepFirst, $wrappers, $nb) { |
|
| 80 | 80 | $wrapper=null; |
| 81 | - if(isset($headers[$sepFirst+1])) |
|
| 82 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
| 83 | - if(isset($wrappers[$sepFirst+1])){ |
|
| 81 | + if (isset($headers[$sepFirst+1])) |
|
| 82 | + $form->addHeader($headers[$sepFirst+1], 4, true); |
|
| 83 | + if (isset($wrappers[$sepFirst+1])) { |
|
| 84 | 84 | $wrapper=$wrappers[$sepFirst+1]; |
| 85 | 85 | } |
| 86 | - if(\sizeof($values)===1){ |
|
| 86 | + if (\sizeof($values)===1) { |
|
| 87 | 87 | $added=$form->addField($values[0]); |
| 88 | - }elseif(\sizeof($values)>1){ |
|
| 88 | + }elseif (\sizeof($values)>1) { |
|
| 89 | 89 | $added=$form->addFields($values); |
| 90 | - }else |
|
| 90 | + } else |
|
| 91 | 91 | return; |
| 92 | - if(isset($wrapper)){ |
|
| 93 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
| 92 | + if (isset($wrapper)) { |
|
| 93 | + $added->wrap($wrapper[0], $wrapper[1]); |
|
| 94 | 94 | } |
| 95 | - $this->execHook("onGenerateFields",$added,$nb); |
|
| 95 | + $this->execHook("onGenerateFields", $added, $nb); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -100,18 +100,18 @@ discard block |
||
| 100 | 100 | * the generated field is the first parameter |
| 101 | 101 | * @param callable $callback the fonction to call when a field is generated |
| 102 | 102 | */ |
| 103 | - public function onGenerateField($callback){ |
|
| 104 | - $this->addHook("onGenerateFields",$callback); |
|
| 103 | + public function onGenerateField($callback) { |
|
| 104 | + $this->addHook("onGenerateFields", $callback); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * @return HtmlForm |
| 109 | 109 | */ |
| 110 | - public function getForm(){ |
|
| 110 | + public function getForm() { |
|
| 111 | 111 | return $this->content["form"]; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - public function addSeparatorAfter($fieldNum){ |
|
| 114 | + public function addSeparatorAfter($fieldNum) { |
|
| 115 | 115 | $fieldNum=$this->_getIndex($fieldNum); |
| 116 | 116 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
| 117 | 117 | return $this; |
@@ -126,12 +126,12 @@ discard block |
||
| 126 | 126 | return $this; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
| 130 | - return $this->_fieldAs(function($id,$name,$value) use ($cssStyle){ |
|
| 131 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 129 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 130 | + return $this->_fieldAs(function($id, $name, $value) use ($cssStyle){ |
|
| 131 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 132 | 132 | $button->setProperty("type", "reset"); |
| 133 | 133 | return $button; |
| 134 | - }, $index,$attributes); |
|
| 134 | + }, $index, $attributes); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -150,19 +150,19 @@ discard block |
||
| 150 | 150 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - public function addDividerBefore($index,$title){ |
|
| 153 | + public function addDividerBefore($index, $title) { |
|
| 154 | 154 | $index=$this->_getIndex($index); |
| 155 | 155 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
| 156 | 156 | return $this; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - public function addWrapper($index,$contentBefore,$contentAfter=null){ |
|
| 159 | + public function addWrapper($index, $contentBefore, $contentAfter=null) { |
|
| 160 | 160 | $index=$this->_getIndex($index); |
| 161 | - $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
|
| 161 | + $this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter); |
|
| 162 | 162 | return $this; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - public function run(JsUtils $js){ |
|
| 165 | + public function run(JsUtils $js) { |
|
| 166 | 166 | parent::run($js); |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $this->_generateFields($form, [$v], $headers, $i, $wrappers,$nb++); |
| 65 | 65 | $i++; |
| 66 | 66 | } |
| 67 | - }else{ |
|
| 67 | + } else{ |
|
| 68 | 68 | $separators[]=$count; |
| 69 | 69 | for($i=0;$i<$size;$i++){ |
| 70 | 70 | $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
@@ -78,17 +78,19 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | protected function _generateFields($form,$values,$headers,$sepFirst,$wrappers,$nb){ |
| 80 | 80 | $wrapper=null; |
| 81 | - if(isset($headers[$sepFirst+1])) |
|
| 82 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
| 81 | + if(isset($headers[$sepFirst+1])) { |
|
| 82 | + $form->addHeader($headers[$sepFirst+1],4,true); |
|
| 83 | + } |
|
| 83 | 84 | if(isset($wrappers[$sepFirst+1])){ |
| 84 | 85 | $wrapper=$wrappers[$sepFirst+1]; |
| 85 | 86 | } |
| 86 | 87 | if(\sizeof($values)===1){ |
| 87 | 88 | $added=$form->addField($values[0]); |
| 88 | - }elseif(\sizeof($values)>1){ |
|
| 89 | + } elseif(\sizeof($values)>1){ |
|
| 89 | 90 | $added=$form->addFields($values); |
| 90 | - }else |
|
| 91 | - return; |
|
| 91 | + } else { |
|
| 92 | + return; |
|
| 93 | + } |
|
| 92 | 94 | if(isset($wrapper)){ |
| 93 | 95 | $added->wrap($wrapper[0],$wrapper[1]); |
| 94 | 96 | } |