@@ -20,6 +20,9 @@ |
||
20 | 20 | protected $_tabsType="tabs"; |
21 | 21 | protected $stacked=""; |
22 | 22 | |
23 | + /** |
|
24 | + * @param string $identifier |
|
25 | + */ |
|
23 | 26 | public function __construct($identifier, $tagName="ul") { |
24 | 27 | parent::__construct($identifier, $tagName); |
25 | 28 | $this->_template="<%tagName% %properties%>%tabs%</%tagName%>%content%"; |
@@ -12,22 +12,22 @@ |
||
12 | 12 | use FieldsTrait; |
13 | 13 | protected $_equalWidth; |
14 | 14 | |
15 | - public function __construct($identifier, $fields=array(),$equalWidth=true) { |
|
15 | + public function __construct($identifier, $fields=array(), $equalWidth=true) { |
|
16 | 16 | parent::__construct($identifier, "div"); |
17 | 17 | $this->_equalWidth=$equalWidth; |
18 | 18 | $this->addItems($fields); |
19 | 19 | } |
20 | 20 | |
21 | - public function compile(JsUtils $js=NULL,View $view=NULL){ |
|
22 | - if($this->_equalWidth){ |
|
21 | + public function compile(JsUtils $js=NULL, View $view=NULL) { |
|
22 | + if ($this->_equalWidth) { |
|
23 | 23 | $count=$this->count(); |
24 | - $this->setClass( Wide::getConstants()["W".$count]." fields"); |
|
24 | + $this->setClass(Wide::getConstants()["W".$count]." fields"); |
|
25 | 25 | }else |
26 | 26 | $this->setClass("fields"); |
27 | - return parent::compile($js,$view); |
|
27 | + return parent::compile($js, $view); |
|
28 | 28 | } |
29 | 29 | |
30 | - public function setWidth($index,$width){ |
|
30 | + public function setWidth($index, $width) { |
|
31 | 31 | $this->_equalWidth=false; |
32 | 32 | return $this->getItem($index)->setWidth($width); |
33 | 33 | } |
@@ -22,8 +22,9 @@ |
||
22 | 22 | if($this->_equalWidth){ |
23 | 23 | $count=$this->count(); |
24 | 24 | $this->setClass( Wide::getConstants()["W".$count]." fields"); |
25 | - }else |
|
26 | - $this->setClass("fields"); |
|
25 | + } else { |
|
26 | + $this->setClass("fields"); |
|
27 | + } |
|
27 | 28 | return parent::compile($js,$view); |
28 | 29 | } |
29 | 30 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | |
8 | 8 | class HtmlInput extends HtmlSingleElement { |
9 | 9 | |
10 | - public function __construct($identifier,$type="text",$value=NULL,$placeholder=NULL) { |
|
10 | + public function __construct($identifier, $type="text", $value=NULL, $placeholder=NULL) { |
|
11 | 11 | parent::__construct($identifier, "input"); |
12 | 12 | $this->setProperty("name", $identifier); |
13 | 13 | $this->setValue($value); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | } |
17 | 17 | |
18 | 18 | public function setValue($value) { |
19 | - if(isset($value)) |
|
19 | + if (isset($value)) |
|
20 | 20 | $this->setProperty("value", $value); |
21 | 21 | return $this; |
22 | 22 | } |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | return $this->setProperty("type", $value); |
26 | 26 | } |
27 | 27 | |
28 | - public function setPlaceholder($value){ |
|
29 | - if(JString::isNotNull($value)) |
|
28 | + public function setPlaceholder($value) { |
|
29 | + if (JString::isNotNull($value)) |
|
30 | 30 | $this->setProperty("placeholder", $value); |
31 | 31 | return $this; |
32 | 32 | } |
@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | } |
17 | 17 | |
18 | 18 | public function setValue($value) { |
19 | - if(isset($value)) |
|
20 | - $this->setProperty("value", $value); |
|
19 | + if(isset($value)) { |
|
20 | + $this->setProperty("value", $value); |
|
21 | + } |
|
21 | 22 | return $this; |
22 | 23 | } |
23 | 24 | |
@@ -26,8 +27,9 @@ discard block |
||
26 | 27 | } |
27 | 28 | |
28 | 29 | public function setPlaceholder($value){ |
29 | - if(JString::isNotNull($value)) |
|
30 | - $this->setProperty("placeholder", $value); |
|
30 | + if(JString::isNotNull($value)) { |
|
31 | + $this->setProperty("placeholder", $value); |
|
32 | + } |
|
31 | 33 | return $this; |
32 | 34 | } |
33 | 35 | } |
34 | 36 | \ No newline at end of file |
@@ -7,17 +7,17 @@ |
||
7 | 7 | |
8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
9 | 9 | |
10 | - public function __construct($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false) { |
|
11 | - parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items))->asSelect($identifier,$multiple), $label); |
|
10 | + public function __construct($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false) { |
|
11 | + parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items))->asSelect($identifier, $multiple), $label); |
|
12 | 12 | } |
13 | 13 | |
14 | - public function setItems($items){ |
|
14 | + public function setItems($items) { |
|
15 | 15 | return $this->getField()->setItems($items); |
16 | 16 | } |
17 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
18 | - return $this->getField()->addItem($item,$value,$image); |
|
17 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
18 | + return $this->getField()->addItem($item, $value, $image); |
|
19 | 19 | } |
20 | - public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value=NULL){ |
|
21 | - return new HtmlFormDropdown($identifier,$items,$label,$value,true); |
|
20 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value=NULL) { |
|
21 | + return new HtmlFormDropdown($identifier, $items, $label, $value, true); |
|
22 | 22 | } |
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -10,52 +10,52 @@ |
||
10 | 10 | * @author jc |
11 | 11 | * @version 1.001 |
12 | 12 | */ |
13 | -class HtmlForm extends HtmlSemCollection{ |
|
13 | +class HtmlForm extends HtmlSemCollection { |
|
14 | 14 | |
15 | 15 | use FieldsTrait; |
16 | 16 | |
17 | 17 | protected $_fields; |
18 | 18 | |
19 | - public function __construct( $identifier, $elements=array()){ |
|
20 | - parent::__construct( $identifier, "form", "ui form"); |
|
19 | + public function __construct($identifier, $elements=array()) { |
|
20 | + parent::__construct($identifier, "form", "ui form"); |
|
21 | 21 | $this->setProperty("name", $this->identifier); |
22 | 22 | $this->_fields=array(); |
23 | 23 | $this->addItems($elements); |
24 | 24 | } |
25 | 25 | |
26 | - public function addHeader($title,$niveau=1,$dividing=true){ |
|
27 | - $header=new HtmlHeader("",$niveau,$title); |
|
28 | - if($dividing) |
|
26 | + public function addHeader($title, $niveau=1, $dividing=true) { |
|
27 | + $header=new HtmlHeader("", $niveau, $title); |
|
28 | + if ($dividing) |
|
29 | 29 | $header->setDividing(); |
30 | 30 | return $this->addItem($header); |
31 | 31 | } |
32 | 32 | |
33 | - public function addFields($fields,$label=NULL){ |
|
34 | - if(\is_array($fields)===false){ |
|
35 | - $fields = \func_get_args(); |
|
33 | + public function addFields($fields, $label=NULL) { |
|
34 | + if (\is_array($fields)===false) { |
|
35 | + $fields=\func_get_args(); |
|
36 | 36 | $end=\end($fields); |
37 | - if(\is_string($end)){ |
|
37 | + if (\is_string($end)) { |
|
38 | 38 | $label=$end; |
39 | 39 | \array_pop($fields); |
40 | 40 | } |
41 | 41 | } |
42 | - $this->_fields=\array_merge($this->_fields,$fields); |
|
43 | - $field=new HtmlFormField("", new HtmlFormFields("fields-".$this->identifier."-".$this->count(),$fields),$label); |
|
42 | + $this->_fields=\array_merge($this->_fields, $fields); |
|
43 | + $field=new HtmlFormField("", new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields), $label); |
|
44 | 44 | return $this->addItem($field); |
45 | 45 | } |
46 | 46 | |
47 | - public function addItem($item){ |
|
47 | + public function addItem($item) { |
|
48 | 48 | $item=parent::addItem($item); |
49 | - if(\is_subclass_of($item, HtmlFormField::class)===true){ |
|
49 | + if (\is_subclass_of($item, HtmlFormField::class)===true) { |
|
50 | 50 | $this->_fields[]=$item; |
51 | 51 | } |
52 | 52 | return $item; |
53 | 53 | } |
54 | 54 | |
55 | - public function getField($index){ |
|
56 | - if(\is_string($index)){ |
|
55 | + public function getField($index) { |
|
56 | + if (\is_string($index)) { |
|
57 | 57 | $field=$this->getElementById($index, $this->_fields); |
58 | - }else{ |
|
58 | + }else { |
|
59 | 59 | $field=$this->_fields[$index]; |
60 | 60 | } |
61 | 61 | return $field; |
@@ -25,8 +25,9 @@ discard block |
||
25 | 25 | |
26 | 26 | public function addHeader($title,$niveau=1,$dividing=true){ |
27 | 27 | $header=new HtmlHeader("",$niveau,$title); |
28 | - if($dividing) |
|
29 | - $header->setDividing(); |
|
28 | + if($dividing) { |
|
29 | + $header->setDividing(); |
|
30 | + } |
|
30 | 31 | return $this->addItem($header); |
31 | 32 | } |
32 | 33 | |
@@ -55,7 +56,7 @@ discard block |
||
55 | 56 | public function getField($index){ |
56 | 57 | if(\is_string($index)){ |
57 | 58 | $field=$this->getElementById($index, $this->_fields); |
58 | - }else{ |
|
59 | + } else{ |
|
59 | 60 | $field=$this->_fields[$index]; |
60 | 61 | } |
61 | 62 | return $field; |
@@ -7,17 +7,17 @@ |
||
7 | 7 | |
8 | 8 | class HtmlFormInput extends HtmlFormField { |
9 | 9 | |
10 | - public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
|
11 | - if(!isset($placeholder)) |
|
10 | + public function __construct($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
11 | + if (!isset($placeholder)) |
|
12 | 12 | $placeholder=$label; |
13 | - parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
|
13 | + parent::__construct("field-".$identifier, new HtmlInput($identifier, $type, $value, $placeholder), $label); |
|
14 | 14 | } |
15 | 15 | |
16 | - public function setPlaceholder($value){ |
|
16 | + public function setPlaceholder($value) { |
|
17 | 17 | return $this->getField()->setPlaceholder($value); |
18 | 18 | } |
19 | 19 | |
20 | - public function setValue($value){ |
|
20 | + public function setValue($value) { |
|
21 | 21 | return $this->getField()->setValue($value); |
22 | 22 | } |
23 | 23 | } |
24 | 24 | \ No newline at end of file |
@@ -8,8 +8,9 @@ |
||
8 | 8 | class HtmlFormInput extends HtmlFormField { |
9 | 9 | |
10 | 10 | public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
11 | - if(!isset($placeholder)) |
|
12 | - $placeholder=$label; |
|
11 | + if(!isset($placeholder)) { |
|
12 | + $placeholder=$label; |
|
13 | + } |
|
13 | 14 | parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
14 | 15 | } |
15 | 16 |
@@ -4,9 +4,9 @@ |
||
4 | 4 | |
5 | 5 | use Ajax\service\JArray; |
6 | 6 | trait FieldsTrait { |
7 | - protected function createItem($value){ |
|
8 | - if(\is_array($value)){ |
|
9 | - $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null))); |
|
7 | + protected function createItem($value) { |
|
8 | + if (\is_array($value)) { |
|
9 | + $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id", ""), JArray::getDefaultValue($value, "label", null), JArray::getDefaultValue($value, "type", "text"), JArray::getDefaultValue($value, "value", ""), JArray::getDefaultValue($value, "placeholder", JArray::getDefaultValue($value, "label", null))); |
|
10 | 10 | return $itemO; |
11 | 11 | }else |
12 | 12 | return new HtmlFormInput($value); |
@@ -8,7 +8,8 @@ |
||
8 | 8 | if(\is_array($value)){ |
9 | 9 | $itemO=new HtmlFormInput(JArray::getDefaultValue($value, "id",""),JArray::getDefaultValue($value, "label",null),JArray::getDefaultValue($value, "type", "text"),JArray::getDefaultValue($value, "value",""),JArray::getDefaultValue($value, "placeholder",JArray::getDefaultValue($value, "label",null))); |
10 | 10 | return $itemO; |
11 | - }else |
|
12 | - return new HtmlFormInput($value); |
|
11 | + } else { |
|
12 | + return new HtmlFormInput($value); |
|
13 | + } |
|
13 | 14 | } |
14 | 15 | } |
15 | 16 | \ No newline at end of file |
@@ -6,25 +6,25 @@ discard block |
||
6 | 6 | use Ajax\semantic\html\base\constants\Wide; |
7 | 7 | |
8 | 8 | class HtmlFormField extends HtmlSemDoubleElement { |
9 | - public function __construct($identifier, $field,$label=NULL) { |
|
10 | - parent::__construct($identifier, "div","field"); |
|
9 | + public function __construct($identifier, $field, $label=NULL) { |
|
10 | + parent::__construct($identifier, "div", "field"); |
|
11 | 11 | $this->content=array(); |
12 | - if(isset($label)) |
|
12 | + if (isset($label)) |
|
13 | 13 | $this->setLabel($label); |
14 | 14 | $this->setField($field); |
15 | 15 | } |
16 | 16 | |
17 | - public function setLabel($label){ |
|
17 | + public function setLabel($label) { |
|
18 | 18 | $labelO=$label; |
19 | - if(\is_string($label)){ |
|
20 | - $labelO=new HtmlSemDoubleElement("","label"); |
|
19 | + if (\is_string($label)) { |
|
20 | + $labelO=new HtmlSemDoubleElement("", "label"); |
|
21 | 21 | $labelO->setContent($label); |
22 | - $labelO->setProperty("for", \str_replace("field-", "",$this->identifier)); |
|
22 | + $labelO->setProperty("for", \str_replace("field-", "", $this->identifier)); |
|
23 | 23 | } |
24 | 24 | $this->content["label"]=$labelO; |
25 | 25 | } |
26 | 26 | |
27 | - public function setField($field){ |
|
27 | + public function setField($field) { |
|
28 | 28 | $this->content["field"]=$field; |
29 | 29 | } |
30 | 30 | |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | * Returns the label or null |
33 | 33 | * @return mixed |
34 | 34 | */ |
35 | - public function getLabel(){ |
|
36 | - if(\array_key_exists("label", $this->content)) |
|
35 | + public function getLabel() { |
|
36 | + if (\array_key_exists("label", $this->content)) |
|
37 | 37 | return $this->content["label"]; |
38 | 38 | } |
39 | 39 | |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | * Return the field |
42 | 42 | * @return mixed |
43 | 43 | */ |
44 | - public function getField(){ |
|
44 | + public function getField() { |
|
45 | 45 | return $this->content["field"]; |
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * puts the label before or behind |
50 | 50 | */ |
51 | - public function swapLabel(){ |
|
51 | + public function swapLabel() { |
|
52 | 52 | $label=$this->getLabel(); |
53 | 53 | unset($this->content["label"]); |
54 | 54 | $this->content["label"]=$label; |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | * @param int $width |
60 | 60 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
61 | 61 | */ |
62 | - public function setWidth($width){ |
|
63 | - if(\is_int($width)){ |
|
62 | + public function setWidth($width) { |
|
63 | + if (\is_int($width)) { |
|
64 | 64 | $width=Wide::getConstants()["W".$width]; |
65 | 65 | } |
66 | 66 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
67 | - return $this->addToPropertyCtrl("class", "wide",array("wide")); |
|
67 | + return $this->addToPropertyCtrl("class", "wide", array("wide")); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | \ No newline at end of file |
@@ -12,21 +12,21 @@ |
||
12 | 12 | */ |
13 | 13 | class HtmlFormCheckbox extends HtmlFormInput { |
14 | 14 | |
15 | - public function __construct($identifier, $label=NULL,$value=NULL,$type=NULL) { |
|
15 | + public function __construct($identifier, $label=NULL, $value=NULL, $type=NULL) { |
|
16 | 16 | parent::__construct($identifier, $label, "checkbox", $value=NULL); |
17 | - if(isset($label)){ |
|
17 | + if (isset($label)) { |
|
18 | 18 | $this->swapLabel(); |
19 | 19 | $label=$this->getLabel(); |
20 | 20 | $label->setClass="hidden"; |
21 | - $label->setProperty("tabindex",0); |
|
21 | + $label->setProperty("tabindex", 0); |
|
22 | 22 | } |
23 | 23 | $this->setClass("ui checkbox"); |
24 | - if(isset($type)) |
|
24 | + if (isset($type)) |
|
25 | 25 | $this->setType($type); |
26 | - $this->wrap("<div class='field'>","</div>"); |
|
26 | + $this->wrap("<div class='field'>", "</div>"); |
|
27 | 27 | } |
28 | 28 | |
29 | - public function setType($checkboxType){ |
|
29 | + public function setType($checkboxType) { |
|
30 | 30 | return $this->addToPropertyCtrl("class", $checkboxType, CheckboxType::getConstants()); |
31 | 31 | } |
32 | 32 | } |
33 | 33 | \ No newline at end of file |
@@ -21,8 +21,9 @@ |
||
21 | 21 | $label->setProperty("tabindex",0); |
22 | 22 | } |
23 | 23 | $this->setClass("ui checkbox"); |
24 | - if(isset($type)) |
|
25 | - $this->setType($type); |
|
24 | + if(isset($type)) { |
|
25 | + $this->setType($type); |
|
26 | + } |
|
26 | 27 | $this->wrap("<div class='field'>","</div>"); |
27 | 28 | } |
28 | 29 |
@@ -8,11 +8,11 @@ discard block |
||
8 | 8 | |
9 | 9 | class HtmlHeader extends HtmlSemDoubleElement { |
10 | 10 | protected $image; |
11 | - public function __construct($identifier, $niveau=1,$content=NULL,$type="page") { |
|
12 | - parent::__construct($identifier, "div","ui header"); |
|
11 | + public function __construct($identifier, $niveau=1, $content=NULL, $type="page") { |
|
12 | + parent::__construct($identifier, "div", "ui header"); |
|
13 | 13 | $this->_template="<%tagName% %properties%>%image%%content%</%tagName%>"; |
14 | - if(isset($type)){ |
|
15 | - if($type=="page"){ |
|
14 | + if (isset($type)) { |
|
15 | + if ($type=="page") { |
|
16 | 16 | $this->asPageHeader($niveau); |
17 | 17 | }else |
18 | 18 | $this->asContentHeader($niveau); |
@@ -20,39 +20,39 @@ discard block |
||
20 | 20 | $this->content=$content; |
21 | 21 | } |
22 | 22 | |
23 | - public function asPageHeader($niveau){ |
|
23 | + public function asPageHeader($niveau) { |
|
24 | 24 | $this->tagName="h".$niveau; |
25 | 25 | } |
26 | 26 | |
27 | - public function asContentHeader($niveau){ |
|
27 | + public function asContentHeader($niveau) { |
|
28 | 28 | $this->tagName="div"; |
29 | - if(\is_int($niveau)){ |
|
29 | + if (\is_int($niveau)) { |
|
30 | 30 | $niveau=Size::getConstantValues()[$niveau]; |
31 | 31 | } |
32 | 32 | $this->setSize($niveau); |
33 | 33 | } |
34 | 34 | |
35 | - public function asIcon($icon,$title,$subHeader=NULL){ |
|
35 | + public function asIcon($icon, $title, $subHeader=NULL) { |
|
36 | 36 | $this->addToProperty("class", "icon"); |
37 | 37 | $this->image=new HtmlIcon("icon-".$this->identifier, $icon); |
38 | - return $this->asTitle($title,$subHeader); |
|
38 | + return $this->asTitle($title, $subHeader); |
|
39 | 39 | } |
40 | 40 | |
41 | - public function asImage($src,$title,$subHeader=NULL){ |
|
42 | - $this->image=new HtmlImage("img-".$this->identifier, $src,$title); |
|
43 | - return $this->asTitle($title,$subHeader); |
|
41 | + public function asImage($src, $title, $subHeader=NULL) { |
|
42 | + $this->image=new HtmlImage("img-".$this->identifier, $src, $title); |
|
43 | + return $this->asTitle($title, $subHeader); |
|
44 | 44 | } |
45 | 45 | |
46 | - public function asTitle($title,$subHeader=NULL){ |
|
47 | - if(!\is_object($title)){ |
|
48 | - $this->content=new HtmlDoubleElement("content-".$this->identifier,"div"); |
|
46 | + public function asTitle($title, $subHeader=NULL) { |
|
47 | + if (!\is_object($title)) { |
|
48 | + $this->content=new HtmlDoubleElement("content-".$this->identifier, "div"); |
|
49 | 49 | $this->content->setContent($title); |
50 | - }else{ |
|
50 | + }else { |
|
51 | 51 | $this->content=$title; |
52 | 52 | } |
53 | 53 | $this->content->setClass("content"); |
54 | - if(isset($subHeader)){ |
|
55 | - $sub=new HtmlDoubleElement("subheader-".$this->identifier,"div"); |
|
54 | + if (isset($subHeader)) { |
|
55 | + $sub=new HtmlDoubleElement("subheader-".$this->identifier, "div"); |
|
56 | 56 | $sub->setClass("sub header"); |
57 | 57 | $sub->setContent($subHeader); |
58 | 58 | $this->content->addContent($sub); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | return $this->image; |
65 | 65 | } |
66 | 66 | |
67 | - public function setDividing(){ |
|
67 | + public function setDividing() { |
|
68 | 68 | $this->addToProperty("class", "dividing"); |
69 | 69 | } |
70 | 70 |