@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | class HtmlDropdown extends HtmlSemDoubleElement { |
| 14 | 14 | protected $mClass="menu"; |
| 15 | 15 | protected $mTagName="div"; |
| 16 | - protected $items=array (); |
|
| 16 | + protected $items=array(); |
|
| 17 | 17 | protected $params=array("action"=>"select"); |
| 18 | 18 | protected $input; |
| 19 | 19 | |
@@ -21,40 +21,40 @@ discard block |
||
| 21 | 21 | parent::__construct($identifier, "div"); |
| 22 | 22 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
| 23 | 23 | $this->setProperty("class", "ui dropdown"); |
| 24 | - $content=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
| 24 | + $content=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
| 25 | 25 | $content->setClass("text"); |
| 26 | 26 | $content->setContent($value); |
| 27 | - $content->wrap("",new HtmlIcon("", "dropdown")); |
|
| 27 | + $content->wrap("", new HtmlIcon("", "dropdown")); |
|
| 28 | 28 | $this->content=array($content); |
| 29 | 29 | $this->tagName="div"; |
| 30 | 30 | $this->addItems($items); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
| 33 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
| 34 | 34 | $itemO=$item; |
| 35 | - if(\is_object($item)===false){ |
|
| 36 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image); |
|
| 37 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
| 35 | + if (\is_object($item)===false) { |
|
| 36 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image); |
|
| 37 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
| 38 | 38 | $this->addToProperty("class", "vertical"); |
| 39 | 39 | } |
| 40 | 40 | $this->items[]=$itemO; |
| 41 | 41 | return $itemO; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function addInput($name){ |
|
| 45 | - if(!isset($name)) |
|
| 44 | + public function addInput($name) { |
|
| 45 | + if (!isset($name)) |
|
| 46 | 46 | $name="input-".$this->identifier; |
| 47 | 47 | $this->setAction("activate"); |
| 48 | - $this->input=new HtmlInput($name,"hidden"); |
|
| 48 | + $this->input=new HtmlInput($name, "hidden"); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function addItems($items){ |
|
| 52 | - if(JArray::isAssociative($items)){ |
|
| 53 | - foreach ($items as $k=>$v){ |
|
| 51 | + public function addItems($items) { |
|
| 52 | + if (JArray::isAssociative($items)) { |
|
| 53 | + foreach ($items as $k=>$v) { |
|
| 54 | 54 | $this->addItem($v)->setData($k); |
| 55 | 55 | } |
| 56 | - }else{ |
|
| 57 | - foreach ($items as $item){ |
|
| 56 | + }else { |
|
| 57 | + foreach ($items as $item) { |
|
| 58 | 58 | $this->addItem($item); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -63,51 +63,51 @@ discard block |
||
| 63 | 63 | /** |
| 64 | 64 | * @param boolean $dropdown |
| 65 | 65 | */ |
| 66 | - public function asDropdown($dropdown){ |
|
| 67 | - if($dropdown===false){ |
|
| 66 | + public function asDropdown($dropdown) { |
|
| 67 | + if ($dropdown===false) { |
|
| 68 | 68 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
| 69 | 69 | $dropdown="menu"; |
| 70 | - }else{ |
|
| 70 | + }else { |
|
| 71 | 71 | $dropdown="dropdown"; |
| 72 | 72 | $this->mClass="menu"; |
| 73 | 73 | } |
| 74 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
| 74 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - public function setVertical(){ |
|
| 78 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
| 77 | + public function setVertical() { |
|
| 78 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public function setSimple(){ |
|
| 82 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
| 81 | + public function setSimple() { |
|
| 82 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - public function asButton($floating=false){ |
|
| 86 | - if($floating) |
|
| 85 | + public function asButton($floating=false) { |
|
| 86 | + if ($floating) |
|
| 87 | 87 | $this->addToProperty("class", "floating"); |
| 88 | 88 | return $this->addToProperty("class", "button"); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
| 92 | - if(isset($name)) |
|
| 91 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
| 92 | + if (isset($name)) |
|
| 93 | 93 | $this->addInput($name); |
| 94 | - if($multiple) |
|
| 94 | + if ($multiple) |
|
| 95 | 95 | $this->addToProperty("class", "multiple"); |
| 96 | 96 | if ($selection) |
| 97 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
| 97 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
| 98 | 98 | return $this; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - public function asSearch($name=NULL,$multiple=false,$selection=false){ |
|
| 102 | - $this->asSelect($name,$multiple,$selection); |
|
| 101 | + public function asSearch($name=NULL, $multiple=false, $selection=false) { |
|
| 102 | + $this->asSelect($name, $multiple, $selection); |
|
| 103 | 103 | return $this->addToProperty("class", "search"); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - public function setSelect($name=NULL,$multiple=false){ |
|
| 107 | - if(!isset($name)) |
|
| 106 | + public function setSelect($name=NULL, $multiple=false) { |
|
| 107 | + if (!isset($name)) |
|
| 108 | 108 | $name="select-".$this->identifier; |
| 109 | 109 | $this->input=null; |
| 110 | - if($multiple){ |
|
| 110 | + if ($multiple) { |
|
| 111 | 111 | $this->setProperty("multiple", true); |
| 112 | 112 | $this->addToProperty("class", "multiple"); |
| 113 | 113 | } |
@@ -115,32 +115,32 @@ discard block |
||
| 115 | 115 | $this->tagName="select"; |
| 116 | 116 | $this->setProperty("name", $name); |
| 117 | 117 | $this->content=null; |
| 118 | - foreach ($this->items as $item){ |
|
| 118 | + foreach ($this->items as $item) { |
|
| 119 | 119 | $item->asOption(); |
| 120 | 120 | } |
| 121 | 121 | return $this; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - public function asSubmenu($pointing=NULL){ |
|
| 124 | + public function asSubmenu($pointing=NULL) { |
|
| 125 | 125 | $this->setClass("ui dropdown link item"); |
| 126 | - if(isset($pointing)){ |
|
| 126 | + if (isset($pointing)) { |
|
| 127 | 127 | $this->setPointing($pointing); |
| 128 | 128 | } |
| 129 | 129 | return $this; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - public function setPointing($value=Direction::NONE){ |
|
| 133 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
| 132 | + public function setPointing($value=Direction::NONE) { |
|
| 133 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - public function setValue($value){ |
|
| 137 | - if(isset($this->input)){ |
|
| 136 | + public function setValue($value) { |
|
| 137 | + if (isset($this->input)) { |
|
| 138 | 138 | $this->input->setProperty("value", $value); |
| 139 | - }else{ |
|
| 139 | + }else { |
|
| 140 | 140 | $this->setProperty("value", $value); |
| 141 | 141 | } |
| 142 | 142 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
| 143 | - if(isset($textElement)) |
|
| 143 | + if (isset($textElement)) |
|
| 144 | 144 | $textElement->setContent($value); |
| 145 | 145 | return $this; |
| 146 | 146 | } |
@@ -150,15 +150,15 @@ discard block |
||
| 150 | 150 | * @see BaseHtml::run() |
| 151 | 151 | */ |
| 152 | 152 | public function run(JsUtils $js) { |
| 153 | - if($this->propertyContains("class", "simple")===false){ |
|
| 154 | - if(isset($this->_bsComponent)===false) |
|
| 155 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->params); |
|
| 153 | + if ($this->propertyContains("class", "simple")===false) { |
|
| 154 | + if (isset($this->_bsComponent)===false) |
|
| 155 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->params); |
|
| 156 | 156 | $this->addEventsOnRun($js); |
| 157 | 157 | return $this->_bsComponent; |
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - public function setAction($action){ |
|
| 161 | + public function setAction($action) { |
|
| 162 | 162 | $this->params["action"]=$action; |
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | \ No newline at end of file |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $itemO=$item; |
| 35 | 35 | if(\is_object($item)===false){ |
| 36 | 36 | $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image); |
| 37 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
| 37 | + } elseif($itemO instanceof HtmlDropdownItem){ |
|
| 38 | 38 | $this->addToProperty("class", "vertical"); |
| 39 | 39 | } |
| 40 | 40 | $this->items[]=$itemO; |
@@ -42,8 +42,9 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function addInput($name){ |
| 45 | - if(!isset($name)) |
|
| 46 | - $name="input-".$this->identifier; |
|
| 45 | + if(!isset($name)) { |
|
| 46 | + $name="input-".$this->identifier; |
|
| 47 | + } |
|
| 47 | 48 | $this->setAction("activate"); |
| 48 | 49 | $this->input=new HtmlInput($name,"hidden"); |
| 49 | 50 | } |
@@ -53,7 +54,7 @@ discard block |
||
| 53 | 54 | foreach ($items as $k=>$v){ |
| 54 | 55 | $this->addItem($v)->setData($k); |
| 55 | 56 | } |
| 56 | - }else{ |
|
| 57 | + } else{ |
|
| 57 | 58 | foreach ($items as $item){ |
| 58 | 59 | $this->addItem($item); |
| 59 | 60 | } |
@@ -67,7 +68,7 @@ discard block |
||
| 67 | 68 | if($dropdown===false){ |
| 68 | 69 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
| 69 | 70 | $dropdown="menu"; |
| 70 | - }else{ |
|
| 71 | + } else{ |
|
| 71 | 72 | $dropdown="dropdown"; |
| 72 | 73 | $this->mClass="menu"; |
| 73 | 74 | } |
@@ -83,18 +84,22 @@ discard block |
||
| 83 | 84 | } |
| 84 | 85 | |
| 85 | 86 | public function asButton($floating=false){ |
| 86 | - if($floating) |
|
| 87 | - $this->addToProperty("class", "floating"); |
|
| 87 | + if($floating) { |
|
| 88 | + $this->addToProperty("class", "floating"); |
|
| 89 | + } |
|
| 88 | 90 | return $this->addToProperty("class", "button"); |
| 89 | 91 | } |
| 90 | 92 | |
| 91 | 93 | public function asSelect($name=NULL,$multiple=false,$selection=true){ |
| 92 | - if(isset($name)) |
|
| 93 | - $this->addInput($name); |
|
| 94 | - if($multiple) |
|
| 95 | - $this->addToProperty("class", "multiple"); |
|
| 96 | - if ($selection) |
|
| 97 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
| 94 | + if(isset($name)) { |
|
| 95 | + $this->addInput($name); |
|
| 96 | + } |
|
| 97 | + if($multiple) { |
|
| 98 | + $this->addToProperty("class", "multiple"); |
|
| 99 | + } |
|
| 100 | + if ($selection) { |
|
| 101 | + $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
| 102 | + } |
|
| 98 | 103 | return $this; |
| 99 | 104 | } |
| 100 | 105 | |
@@ -104,8 +109,9 @@ discard block |
||
| 104 | 109 | } |
| 105 | 110 | |
| 106 | 111 | public function setSelect($name=NULL,$multiple=false){ |
| 107 | - if(!isset($name)) |
|
| 108 | - $name="select-".$this->identifier; |
|
| 112 | + if(!isset($name)) { |
|
| 113 | + $name="select-".$this->identifier; |
|
| 114 | + } |
|
| 109 | 115 | $this->input=null; |
| 110 | 116 | if($multiple){ |
| 111 | 117 | $this->setProperty("multiple", true); |
@@ -136,12 +142,13 @@ discard block |
||
| 136 | 142 | public function setValue($value){ |
| 137 | 143 | if(isset($this->input)){ |
| 138 | 144 | $this->input->setProperty("value", $value); |
| 139 | - }else{ |
|
| 145 | + } else{ |
|
| 140 | 146 | $this->setProperty("value", $value); |
| 141 | 147 | } |
| 142 | 148 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
| 143 | - if(isset($textElement)) |
|
| 144 | - $textElement->setContent($value); |
|
| 149 | + if(isset($textElement)) { |
|
| 150 | + $textElement->setContent($value); |
|
| 151 | + } |
|
| 145 | 152 | return $this; |
| 146 | 153 | } |
| 147 | 154 | |
@@ -151,8 +158,9 @@ discard block |
||
| 151 | 158 | */ |
| 152 | 159 | public function run(JsUtils $js) { |
| 153 | 160 | if($this->propertyContains("class", "simple")===false){ |
| 154 | - if(isset($this->_bsComponent)===false) |
|
| 155 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->params); |
|
| 161 | + if(isset($this->_bsComponent)===false) { |
|
| 162 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->params); |
|
| 163 | + } |
|
| 156 | 164 | $this->addEventsOnRun($js); |
| 157 | 165 | return $this->_bsComponent; |
| 158 | 166 | } |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | * @param string $type one of text,item |
| 28 | 28 | * @return \Ajax\semantic\html\collections\HtmlMenu |
| 29 | 29 | */ |
| 30 | - public function setType($type=""){ |
|
| 31 | - return $this->addToPropertyCtrl("class", $type, array("","item","text")); |
|
| 30 | + public function setType($type="") { |
|
| 31 | + return $this->addToPropertyCtrl("class", $type, array("", "item", "text")); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function setActiveItem($index){ |
|
| 34 | + public function setActiveItem($index) { |
|
| 35 | 35 | $item=$this->getItem($index); |
| 36 | - if($item!==null){ |
|
| 36 | + if ($item!==null) { |
|
| 37 | 37 | $item->addToProperty("class", "active"); |
| 38 | 38 | } |
| 39 | 39 | return $this; |
@@ -43,16 +43,16 @@ discard block |
||
| 43 | 43 | * {@inheritDoc} |
| 44 | 44 | * @see \Ajax\common\html\html5\HtmlCollection::addItem() |
| 45 | 45 | */ |
| 46 | - public function addItem($item){ |
|
| 47 | - if($item instanceof \Ajax\semantic\html\elements\HtmlInput){ |
|
| 48 | - $itemO=new HtmlSemDoubleElement("item-".$this->identifier,"div"); |
|
| 46 | + public function addItem($item) { |
|
| 47 | + if ($item instanceof \Ajax\semantic\html\elements\HtmlInput) { |
|
| 48 | + $itemO=new HtmlSemDoubleElement("item-".$this->identifier, "div"); |
|
| 49 | 49 | $itemO->setContent($item); |
| 50 | 50 | $item=$itemO; |
| 51 | 51 | } |
| 52 | 52 | $item=parent::addItem($item); |
| 53 | - if(!$item instanceof HtmlMenu) |
|
| 54 | - $item->addToPropertyCtrl("class", "item",array("item")); |
|
| 55 | - else{ |
|
| 53 | + if (!$item instanceof HtmlMenu) |
|
| 54 | + $item->addToPropertyCtrl("class", "item", array("item")); |
|
| 55 | + else { |
|
| 56 | 56 | $this->setSecondary(); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -61,51 +61,51 @@ discard block |
||
| 61 | 61 | * @see \Ajax\common\html\html5\HtmlCollection::createItem() |
| 62 | 62 | */ |
| 63 | 63 | protected function createItem($value) { |
| 64 | - $itemO=new HtmlLink("item-".\sizeof($this->content),"",$value); |
|
| 64 | + $itemO=new HtmlLink("item-".\sizeof($this->content), "", $value); |
|
| 65 | 65 | return $itemO->setClass("item"); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public function setInverted(){ |
|
| 68 | + public function setInverted() { |
|
| 69 | 69 | return $this->addToProperty("class", "inverted"); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - public function setSecondary(){ |
|
| 72 | + public function setSecondary() { |
|
| 73 | 73 | return $this->addToProperty("class", "secondary"); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - public function setVertical(){ |
|
| 76 | + public function setVertical() { |
|
| 77 | 77 | return $this->addToProperty("class", "vertical"); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function setPosition($value="right"){ |
|
| 81 | - return $this->addToPropertyCtrl("class", $value,array("right","left")); |
|
| 80 | + public function setPosition($value="right") { |
|
| 81 | + return $this->addToPropertyCtrl("class", $value, array("right", "left")); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - public function setPointing($value=Direction::NONE){ |
|
| 85 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
| 84 | + public function setPointing($value=Direction::NONE) { |
|
| 85 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function asTab($vertical=false){ |
|
| 89 | - $this->apply(function(HtmlDoubleElement &$item){$item->setTagName("a");}); |
|
| 90 | - if($vertical===true) |
|
| 88 | + public function asTab($vertical=false) { |
|
| 89 | + $this->apply(function(HtmlDoubleElement & $item) {$item->setTagName("a"); }); |
|
| 90 | + if ($vertical===true) |
|
| 91 | 91 | $this->setVertical(); |
| 92 | 92 | return $this->addToProperty("class", "tabular"); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function asPagination(){ |
|
| 96 | - $this->apply(function(HtmlDoubleElement &$item){$item->setTagName("a");}); |
|
| 95 | + public function asPagination() { |
|
| 96 | + $this->apply(function(HtmlDoubleElement & $item) {$item->setTagName("a"); }); |
|
| 97 | 97 | return $this->addToProperty("class", "pagination"); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - public function setFixed(){ |
|
| 100 | + public function setFixed() { |
|
| 101 | 101 | return $this->addToProperty("class", "fixed"); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - public function setFluid(){ |
|
| 104 | + public function setFluid() { |
|
| 105 | 105 | return $this->addToProperty("class", "fluid"); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public function setCompact(){ |
|
| 108 | + public function setCompact() { |
|
| 109 | 109 | return $this->addToProperty("class", "compact"); |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | \ No newline at end of file |