@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * @param string $placeholder |
| 27 | 27 | * @param string $icon |
| 28 | - * @return \Ajax\semantic\html\content\HtmlDropdownItem|\Ajax\semantic\html\content\HtmlMenuItem |
|
| 28 | + * @return MenuItemTrait |
|
| 29 | 29 | */ |
| 30 | 30 | public function asSearchInput($placeholder=NULL,$icon=NULL){ |
| 31 | 31 | $this->setClass("ui icon search input"); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * @return \Ajax\semantic\html\content\HtmlDropdownItem|\Ajax\semantic\html\content\HtmlMenuItem |
|
| 42 | + * @return MenuItemTrait |
|
| 43 | 43 | */ |
| 44 | 44 | public function asDivider(){ |
| 45 | 45 | $this->content=NULL; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | /** |
| 52 | 52 | * @param string $caption |
| 53 | 53 | * @param string $icon |
| 54 | - * @return \Ajax\semantic\html\content\HtmlDropdownItem|\Ajax\semantic\html\content\HtmlMenuItem |
|
| 54 | + * @return MenuItemTrait |
|
| 55 | 55 | */ |
| 56 | 56 | public function asHeader($caption=NULL,$icon=NULL){ |
| 57 | 57 | $this->setClass("header"); |
@@ -11,14 +11,15 @@ discard block |
||
| 11 | 11 | public function setContent($content){ |
| 12 | 12 | if($content==="-"){ |
| 13 | 13 | $this->asDivider(); |
| 14 | - }elseif($content==="-search-"){ |
|
| 14 | + } elseif($content==="-search-"){ |
|
| 15 | 15 | $values=\explode(",",$content,-1); |
| 16 | 16 | $this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."),JArray::getDefaultValue($values, 1, "search")); |
| 17 | - }elseif(JString::startswith($content, "-")){ |
|
| 17 | + } elseif(JString::startswith($content, "-")){ |
|
| 18 | 18 | $content=\ltrim($content,"-"); |
| 19 | 19 | $this->asHeader($content); |
| 20 | - }else |
|
| 21 | - parent::setContent($content); |
|
| 20 | + } else { |
|
| 21 | + parent::setContent($content); |
|
| 22 | + } |
|
| 22 | 23 | return $this; |
| 23 | 24 | } |
| 24 | 25 | |
@@ -30,11 +31,13 @@ discard block |
||
| 30 | 31 | public function asSearchInput($placeholder=NULL,$icon=NULL){ |
| 31 | 32 | $this->setClass("ui icon search input"); |
| 32 | 33 | $input=new HtmlInput("search-".$this->identifier); |
| 33 | - if(isset($placeholder)) |
|
| 34 | - $input->setProperty("placeholder", $placeholder); |
|
| 34 | + if(isset($placeholder)) { |
|
| 35 | + $input->setProperty("placeholder", $placeholder); |
|
| 36 | + } |
|
| 35 | 37 | $this->content=$input; |
| 36 | - if(isset($icon)) |
|
| 37 | - $this->addIcon($icon); |
|
| 38 | + if(isset($icon)) { |
|
| 39 | + $this->addIcon($icon); |
|
| 40 | + } |
|
| 38 | 41 | return $this; |
| 39 | 42 | } |
| 40 | 43 | |
@@ -57,8 +60,9 @@ discard block |
||
| 57 | 60 | $this->setClass("header"); |
| 58 | 61 | $this->tagName="div"; |
| 59 | 62 | $this->content=$caption; |
| 60 | - if(isset($icon)) |
|
| 61 | - $this->addIcon($icon,Direction::LEFT); |
|
| 63 | + if(isset($icon)) { |
|
| 64 | + $this->addIcon($icon,Direction::LEFT); |
|
| 65 | + } |
|
| 62 | 66 | return $this; |
| 63 | 67 | } |
| 64 | 68 | } |
| 65 | 69 | \ No newline at end of file |
@@ -12,6 +12,10 @@ discard block |
||
| 12 | 12 | protected $variation; |
| 13 | 13 | protected $params; |
| 14 | 14 | protected $semElement; |
| 15 | + |
|
| 16 | + /** |
|
| 17 | + * @param HtmlSemDoubleElement $semElement |
|
| 18 | + */ |
|
| 15 | 19 | public function __construct($semElement,$title="",$content="",$variation=NULL,$params=array()){ |
| 16 | 20 | $this->semElement=$semElement; |
| 17 | 21 | $this->title=$title; |
@@ -19,6 +23,9 @@ discard block |
||
| 19 | 23 | $this->setAttributes($variation,$params); |
| 20 | 24 | } |
| 21 | 25 | |
| 26 | + /** |
|
| 27 | + * @param string $html |
|
| 28 | + */ |
|
| 22 | 29 | public function setHtml($html) { |
| 23 | 30 | $this->html= $html; |
| 24 | 31 | return $this; |
@@ -47,8 +47,9 @@ |
||
| 47 | 47 | if($item instanceof HtmlSemDoubleElement){ |
| 48 | 48 | $comp=$item->compile($js); |
| 49 | 49 | $bs=$item->run($js); |
| 50 | - if(isset($bs)) |
|
| 51 | - $this->params['onShow']=$bs->getScript(); |
|
| 50 | + if(isset($bs)) { |
|
| 51 | + $this->params['onShow']=$bs->getScript(); |
|
| 52 | + } |
|
| 52 | 53 | $item=$comp; |
| 53 | 54 | } |
| 54 | 55 | }); |
@@ -22,6 +22,9 @@ discard block |
||
| 22 | 22 | protected $input; |
| 23 | 23 | protected $value; |
| 24 | 24 | |
| 25 | + /** |
|
| 26 | + * @param string $identifier |
|
| 27 | + */ |
|
| 25 | 28 | public function __construct($identifier, $value="", $items=array()) { |
| 26 | 29 | parent::__construct($identifier, "div"); |
| 27 | 30 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
@@ -49,7 +52,7 @@ discard block |
||
| 49 | 52 | /** |
| 50 | 53 | * Insert an item at a position |
| 51 | 54 | * @param mixed $item |
| 52 | - * @param number $position |
|
| 55 | + * @param integer $position |
|
| 53 | 56 | * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown |
| 54 | 57 | */ |
| 55 | 58 | public function insertItem($item,$position=0){ |
@@ -240,6 +243,9 @@ discard block |
||
| 240 | 243 | return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
| 241 | 244 | } |
| 242 | 245 | |
| 246 | + /** |
|
| 247 | + * @param string $value |
|
| 248 | + */ |
|
| 243 | 249 | public function setValue($value){ |
| 244 | 250 | $this->value=$value; |
| 245 | 251 | return $this; |
@@ -274,6 +280,9 @@ discard block |
||
| 274 | 280 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
| 275 | 281 | } |
| 276 | 282 | |
| 283 | + /** |
|
| 284 | + * @param string $action |
|
| 285 | + */ |
|
| 277 | 286 | public function setAction($action){ |
| 278 | 287 | $this->_params["action"]=$action; |
| 279 | 288 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | if(!$item instanceof HtmlDropdownItem){ |
| 73 | 73 | $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description); |
| 74 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
| 74 | + } elseif($itemO instanceof HtmlDropdownItem){ |
|
| 75 | 75 | $this->addToProperty("class", "vertical"); |
| 76 | 76 | } |
| 77 | 77 | return $itemO; |
@@ -85,8 +85,9 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public function addInput($name){ |
| 88 | - if(!isset($name)) |
|
| 89 | - $name="input-".$this->identifier; |
|
| 88 | + if(!isset($name)) { |
|
| 89 | + $name="input-".$this->identifier; |
|
| 90 | + } |
|
| 90 | 91 | $this->setAction("activate"); |
| 91 | 92 | $this->input=new HtmlInput($name,"hidden"); |
| 92 | 93 | } |
@@ -143,7 +144,7 @@ discard block |
||
| 143 | 144 | foreach ($items as $k=>$v){ |
| 144 | 145 | $this->addItem($v)->setData($k); |
| 145 | 146 | } |
| 146 | - }else{ |
|
| 147 | + } else{ |
|
| 147 | 148 | foreach ($items as $item){ |
| 148 | 149 | $this->addItem($item); |
| 149 | 150 | } |
@@ -167,7 +168,7 @@ discard block |
||
| 167 | 168 | if($dropdown===false){ |
| 168 | 169 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
| 169 | 170 | $dropdown="menu"; |
| 170 | - }else{ |
|
| 171 | + } else{ |
|
| 171 | 172 | $dropdown="dropdown"; |
| 172 | 173 | $this->mClass="menu"; |
| 173 | 174 | } |
@@ -187,20 +188,24 @@ discard block |
||
| 187 | 188 | } |
| 188 | 189 | |
| 189 | 190 | public function asButton($floating=false){ |
| 190 | - if($floating) |
|
| 191 | - $this->addToProperty("class", "floating"); |
|
| 191 | + if($floating) { |
|
| 192 | + $this->addToProperty("class", "floating"); |
|
| 193 | + } |
|
| 192 | 194 | $this->removePropertyValue("class", "selection"); |
| 193 | 195 | return $this->addToProperty("class", "button"); |
| 194 | 196 | } |
| 195 | 197 | |
| 196 | 198 | public function asSelect($name=NULL,$multiple=false,$selection=true){ |
| 197 | - if(isset($name)) |
|
| 198 | - $this->addInput($name); |
|
| 199 | - if($multiple) |
|
| 200 | - $this->addToProperty("class", "multiple"); |
|
| 199 | + if(isset($name)) { |
|
| 200 | + $this->addInput($name); |
|
| 201 | + } |
|
| 202 | + if($multiple) { |
|
| 203 | + $this->addToProperty("class", "multiple"); |
|
| 204 | + } |
|
| 201 | 205 | if ($selection){ |
| 202 | - if($this->propertyContains("class", "button")===false) |
|
| 203 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
| 206 | + if($this->propertyContains("class", "button")===false) { |
|
| 207 | + $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
| 208 | + } |
|
| 204 | 209 | } |
| 205 | 210 | return $this; |
| 206 | 211 | } |
@@ -211,8 +216,9 @@ discard block |
||
| 211 | 216 | } |
| 212 | 217 | |
| 213 | 218 | public function setSelect($name=NULL,$multiple=false){ |
| 214 | - if(!isset($name)) |
|
| 215 | - $name="select-".$this->identifier; |
|
| 219 | + if(!isset($name)) { |
|
| 220 | + $name="select-".$this->identifier; |
|
| 221 | + } |
|
| 216 | 222 | $this->input=null; |
| 217 | 223 | if($multiple){ |
| 218 | 224 | $this->setProperty("multiple", true); |
@@ -248,12 +254,13 @@ discard block |
||
| 248 | 254 | $value=$this->value; |
| 249 | 255 | if(isset($this->input) && isset($value)){ |
| 250 | 256 | $this->input->setProperty("value", $value); |
| 251 | - }else{ |
|
| 257 | + } else{ |
|
| 252 | 258 | $this->setProperty("value", $value); |
| 253 | 259 | } |
| 254 | 260 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
| 255 | - if(isset($textElement)) |
|
| 256 | - $textElement->setContent($value); |
|
| 261 | + if(isset($textElement)) { |
|
| 262 | + $textElement->setContent($value); |
|
| 263 | + } |
|
| 257 | 264 | return $this; |
| 258 | 265 | } |
| 259 | 266 | |
@@ -263,8 +270,9 @@ discard block |
||
| 263 | 270 | */ |
| 264 | 271 | public function run(JsUtils $js) { |
| 265 | 272 | if($this->propertyContains("class", "simple")===false){ |
| 266 | - if(isset($this->_bsComponent)===false) |
|
| 267 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
| 273 | + if(isset($this->_bsComponent)===false) { |
|
| 274 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
| 275 | + } |
|
| 268 | 276 | $this->addEventsOnRun($js); |
| 269 | 277 | return $this->_bsComponent; |
| 270 | 278 | } |
@@ -27,6 +27,9 @@ discard block |
||
| 27 | 27 | return $result; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | + /** |
|
| 31 | + * @param string $key |
|
| 32 | + */ |
|
| 30 | 33 | private function addElementInContent($key, $element) { |
| 31 | 34 | if (\array_key_exists($key, $this->content) === false) { |
| 32 | 35 | $this->content[$key]=array (); |
@@ -35,6 +38,9 @@ discard block |
||
| 35 | 38 | return $element; |
| 36 | 39 | } |
| 37 | 40 | |
| 41 | + /** |
|
| 42 | + * @param string $part |
|
| 43 | + */ |
|
| 38 | 44 | private function getPart($part, $index=NULL) { |
| 39 | 45 | if (\array_key_exists($part, $this->content)) { |
| 40 | 46 | if (isset($index)) |
@@ -59,6 +65,10 @@ discard block |
||
| 59 | 65 | return $this->addElementInContent("content", $image); |
| 60 | 66 | } |
| 61 | 67 | |
| 68 | + /** |
|
| 69 | + * @param HtmlImage $visibleContent |
|
| 70 | + * @param HtmlImage $hiddenContent |
|
| 71 | + */ |
|
| 62 | 72 | public function addReveal($visibleContent, $hiddenContent=NULL, $type=RevealType::FADE, $attributeType=NULL) { |
| 63 | 73 | $reveal=$visibleContent; |
| 64 | 74 | if (!$visibleContent instanceof HtmlReveal) { |
@@ -32,8 +32,9 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function setPopupAttributes($variation=NULL, $popupEvent=NULL) { |
| 35 | - if (isset($this->_popup)) |
|
| 36 | - $this->_popup->setAttributes($variation, $popupEvent); |
|
| 35 | + if (isset($this->_popup)) { |
|
| 36 | + $this->_popup->setAttributes($variation, $popupEvent); |
|
| 37 | + } |
|
| 37 | 38 | } |
| 38 | 39 | |
| 39 | 40 | public function addPopup($title="", $content="", $variation=NULL, $params=array()) { |
@@ -60,8 +61,9 @@ discard block |
||
| 60 | 61 | $labelO=$label; |
| 61 | 62 | if (\is_object($label) === false) { |
| 62 | 63 | $labelO=new HtmlLabel("label-" . $this->identifier, $label); |
| 63 | - if (isset($icon)) |
|
| 64 | - $labelO->addIcon($icon); |
|
| 64 | + if (isset($icon)) { |
|
| 65 | + $labelO->addIcon($icon); |
|
| 66 | + } |
|
| 65 | 67 | } else { |
| 66 | 68 | $labelO->addToPropertyCtrl("class", "label", array ("label" )); |
| 67 | 69 | } |
@@ -80,21 +82,24 @@ discard block |
||
| 80 | 82 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
| 81 | 83 | */ |
| 82 | 84 | public function asLink($href=NULL) { |
| 83 | - if (isset($href)) |
|
| 84 | - $this->setProperty("href", $href); |
|
| 85 | + if (isset($href)) { |
|
| 86 | + $this->setProperty("href", $href); |
|
| 87 | + } |
|
| 85 | 88 | return $this->setTagName("a"); |
| 86 | 89 | } |
| 87 | 90 | |
| 88 | 91 | public function jsShowDimmer($show=true) { |
| 89 | 92 | $status="hide"; |
| 90 | - if ($show === true) |
|
| 91 | - $status="show"; |
|
| 93 | + if ($show === true) { |
|
| 94 | + $status="show"; |
|
| 95 | + } |
|
| 92 | 96 | return '$("#.' . $this->identifier . ').dimmer("' . $status . '");'; |
| 93 | 97 | } |
| 94 | 98 | |
| 95 | 99 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 96 | - if (isset($this->_popup)) |
|
| 97 | - $this->_popup->compile($js); |
|
| 100 | + if (isset($this->_popup)) { |
|
| 101 | + $this->_popup->compile($js); |
|
| 102 | + } |
|
| 98 | 103 | return parent::compile($js, $view); |
| 99 | 104 | } |
| 100 | 105 | |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | private function afterInsert($item) { |
| 61 | - if (!$item instanceof HtmlMenu && $item->propertyContains("class", "header")===false) |
|
| 62 | - $item->addToPropertyCtrl("class", "item", array ("item" )); |
|
| 63 | - else { |
|
| 61 | + if (!$item instanceof HtmlMenu && $item->propertyContains("class", "header")===false) { |
|
| 62 | + $item->addToPropertyCtrl("class", "item", array ("item" )); |
|
| 63 | + } else { |
|
| 64 | 64 | $this->setSecondary(); |
| 65 | 65 | } |
| 66 | 66 | return $item; |
@@ -146,10 +146,11 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | public function setSecondary($value=true) { |
| 149 | - if($value) |
|
| 150 | - $this->addToProperty("class", "secondary"); |
|
| 151 | - else |
|
| 152 | - $this->removePropertyValue("class", "secondary"); |
|
| 149 | + if($value) { |
|
| 150 | + $this->addToProperty("class", "secondary"); |
|
| 151 | + } else { |
|
| 152 | + $this->removePropertyValue("class", "secondary"); |
|
| 153 | + } |
|
| 153 | 154 | } |
| 154 | 155 | |
| 155 | 156 | public function setVertical() { |
@@ -168,8 +169,9 @@ discard block |
||
| 168 | 169 | $this->apply(function (HtmlDoubleElement &$item) { |
| 169 | 170 | $item->setTagName("a"); |
| 170 | 171 | }); |
| 171 | - if ($vertical === true) |
|
| 172 | - $this->setVertical(); |
|
| 172 | + if ($vertical === true) { |
|
| 173 | + $this->setVertical(); |
|
| 174 | + } |
|
| 173 | 175 | return $this->addToProperty("class", "tabular"); |
| 174 | 176 | } |
| 175 | 177 | |
@@ -198,10 +200,11 @@ discard block |
||
| 198 | 200 | */ |
| 199 | 201 | public function fromDatabaseObject($object, $function) { |
| 200 | 202 | $return=$function($object); |
| 201 | - if (\is_array($return)) |
|
| 202 | - $this->addItems($return); |
|
| 203 | - else |
|
| 204 | - $this->addItem($return); |
|
| 203 | + if (\is_array($return)) { |
|
| 204 | + $this->addItems($return); |
|
| 205 | + } else { |
|
| 206 | + $this->addItem($return); |
|
| 207 | + } |
|
| 205 | 208 | } |
| 206 | 209 | |
| 207 | 210 | /** |
@@ -17,12 +17,15 @@ discard block |
||
| 17 | 17 | parent::__construct($identifier, "a"); |
| 18 | 18 | $this->setClass("item"); |
| 19 | 19 | $this->setContent($content); |
| 20 | - if($value!==NULL) |
|
| 21 | - $this->setData($value); |
|
| 22 | - if($image!==NULL) |
|
| 23 | - $this->asMiniAvatar($image); |
|
| 24 | - if($description!==NULL) |
|
| 25 | - $this->setDescription($description); |
|
| 20 | + if($value!==NULL) { |
|
| 21 | + $this->setData($value); |
|
| 22 | + } |
|
| 23 | + if($image!==NULL) { |
|
| 24 | + $this->asMiniAvatar($image); |
|
| 25 | + } |
|
| 26 | + if($description!==NULL) { |
|
| 27 | + $this->setDescription($description); |
|
| 28 | + } |
|
| 26 | 29 | } |
| 27 | 30 | |
| 28 | 31 | public function setDescription($description){ |
@@ -39,8 +42,9 @@ discard block |
||
| 39 | 42 | |
| 40 | 43 | public function asOption(){ |
| 41 | 44 | $this->tagName="option"; |
| 42 | - if($this->getProperty("data-value")!==null) |
|
| 43 | - $this->setProperty("value", $this->getProperty("data-value")); |
|
| 45 | + if($this->getProperty("data-value")!==null) { |
|
| 46 | + $this->setProperty("value", $this->getProperty("data-value")); |
|
| 47 | + } |
|
| 44 | 48 | } |
| 45 | 49 | |
| 46 | 50 | /** |