@@ -24,6 +24,10 @@ discard block |
||
24 | 24 | trait FieldAsTrait{ |
25 | 25 | |
26 | 26 | abstract protected function _getFieldIdentifier($prefix); |
27 | + |
|
28 | + /** |
|
29 | + * @param \Closure $callback |
|
30 | + */ |
|
27 | 31 | abstract public function setValueFunction($index,$callback); |
28 | 32 | |
29 | 33 | /** |
@@ -49,6 +53,10 @@ discard block |
||
49 | 53 | |
50 | 54 | protected function _addRules($element,&$attributes){} |
51 | 55 | |
56 | + /** |
|
57 | + * @param \Closure $elementCallback |
|
58 | + * @param string $prefix |
|
59 | + */ |
|
52 | 60 | protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){ |
53 | 61 | $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){ |
54 | 62 | $name=$this->_instanceViewer->getCaption($index)."[]"; |
@@ -56,8 +56,9 @@ discard block |
||
56 | 56 | $name=$attributes["name"]; |
57 | 57 | } |
58 | 58 | $element=$elementCallback($this->_getFieldIdentifier($prefix),$name,$value,""); |
59 | - if(\is_array($attributes)) |
|
60 | - $this->_applyAttributes($element, $attributes,$index); |
|
59 | + if(\is_array($attributes)) { |
|
60 | + $this->_applyAttributes($element, $attributes,$index); |
|
61 | + } |
|
61 | 62 | $element->setDisabled(!$this->_edition); |
62 | 63 | return $element; |
63 | 64 | }); |
@@ -92,8 +93,9 @@ discard block |
||
92 | 93 | public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
93 | 94 | return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
94 | 95 | $header=new HtmlHeader($id,$niveau,$value); |
95 | - if(isset($icon)) |
|
96 | - $header->asIcon($icon, $value); |
|
96 | + if(isset($icon)) { |
|
97 | + $header->asIcon($icon, $value); |
|
98 | + } |
|
97 | 99 | return $header; |
98 | 100 | }, $index,$attributes,"header"); |
99 | 101 | } |
@@ -101,7 +103,9 @@ discard block |
||
101 | 103 | |
102 | 104 | public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
103 | 105 | $this->setValueFunction($index,function($img) use($size,$circular){ |
104 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
106 | + $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular) { |
|
107 | + $image->setCircular(); |
|
108 | + } |
|
105 | 109 | return $image; |
106 | 110 | }); |
107 | 111 | return $this; |
@@ -18,43 +18,43 @@ discard block |
||
18 | 18 | * @property boolean $_edition |
19 | 19 | * @property mixed _modelInstance |
20 | 20 | */ |
21 | -trait FieldAsTrait{ |
|
21 | +trait FieldAsTrait { |
|
22 | 22 | |
23 | 23 | abstract protected function _getFieldIdentifier($prefix); |
24 | - abstract public function setValueFunction($index,$callback); |
|
24 | + abstract public function setValueFunction($index, $callback); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @param HtmlFormField $element |
28 | 28 | * @param array $attributes |
29 | 29 | */ |
30 | - protected function _applyAttributes($element,&$attributes,$index){ |
|
30 | + protected function _applyAttributes($element, &$attributes, $index) { |
|
31 | 31 | $this->_addRules($element, $attributes); |
32 | - if(isset($attributes["callback"])){ |
|
32 | + if (isset($attributes["callback"])) { |
|
33 | 33 | $callback=$attributes["callback"]; |
34 | - if(\is_callable($callback)){ |
|
35 | - $callback($element,$this->_modelInstance,$index); |
|
34 | + if (\is_callable($callback)) { |
|
35 | + $callback($element, $this->_modelInstance, $index); |
|
36 | 36 | unset($attributes["callback"]); |
37 | 37 | } |
38 | 38 | } |
39 | 39 | $element->fromArray($attributes); |
40 | 40 | } |
41 | 41 | |
42 | - private function _getLabelField($caption,$icon=NULL){ |
|
43 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
42 | + private function _getLabelField($caption, $icon=NULL) { |
|
43 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
44 | 44 | return $label; |
45 | 45 | } |
46 | 46 | |
47 | - protected function _addRules($element,&$attributes){} |
|
47 | + protected function _addRules($element, &$attributes) {} |
|
48 | 48 | |
49 | - protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){ |
|
50 | - $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){ |
|
49 | + protected function _fieldAs($elementCallback, $index, $attributes=NULL, $prefix=null) { |
|
50 | + $this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback, $prefix){ |
|
51 | 51 | $name=$this->_instanceViewer->getCaption($index)."[]"; |
52 | - if(isset($attributes["name"])){ |
|
52 | + if (isset($attributes["name"])) { |
|
53 | 53 | $name=$attributes["name"]; |
54 | 54 | } |
55 | - $element=$elementCallback($this->_getFieldIdentifier($prefix),$name,$value,""); |
|
56 | - if(\is_array($attributes)) |
|
57 | - $this->_applyAttributes($element, $attributes,$index); |
|
55 | + $element=$elementCallback($this->_getFieldIdentifier($prefix), $name, $value, ""); |
|
56 | + if (\is_array($attributes)) |
|
57 | + $this->_applyAttributes($element, $attributes, $index); |
|
58 | 58 | $element->setDisabled(!$this->_edition); |
59 | 59 | return $element; |
60 | 60 | }); |
@@ -62,94 +62,94 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
66 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
67 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
65 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
66 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
67 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
68 | 68 | return $pb; |
69 | 69 | }); |
70 | 70 | return $this; |
71 | 71 | } |
72 | 72 | |
73 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
74 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
75 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
73 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
74 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
75 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
76 | 76 | return $rating; |
77 | 77 | }); |
78 | 78 | return $this; |
79 | 79 | } |
80 | 80 | |
81 | - public function fieldAsLabel($index,$icon=NULL){ |
|
82 | - $this->setValueFunction($index,function($caption) use($icon){ |
|
83 | - $lbl=$this->_getLabelField($caption,$icon); |
|
81 | + public function fieldAsLabel($index, $icon=NULL) { |
|
82 | + $this->setValueFunction($index, function($caption) use($icon){ |
|
83 | + $lbl=$this->_getLabelField($caption, $icon); |
|
84 | 84 | return $lbl; |
85 | 85 | }); |
86 | 86 | return $this; |
87 | 87 | } |
88 | 88 | |
89 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
90 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
91 | - $header=new HtmlHeader($id,$niveau,$value); |
|
92 | - if(isset($icon)) |
|
89 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
90 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
91 | + $header=new HtmlHeader($id, $niveau, $value); |
|
92 | + if (isset($icon)) |
|
93 | 93 | $header->asIcon($icon, $value); |
94 | 94 | return $header; |
95 | - }, $index,$attributes,"header"); |
|
95 | + }, $index, $attributes, "header"); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
99 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
100 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
101 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
99 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
100 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
101 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
102 | 102 | return $image; |
103 | 103 | }); |
104 | 104 | return $this; |
105 | 105 | } |
106 | 106 | |
107 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
108 | - return $this->_fieldAs(function($id,$name,$value){ |
|
109 | - $img=new HtmlImage($id,$value); |
|
107 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
108 | + return $this->_fieldAs(function($id, $name, $value) { |
|
109 | + $img=new HtmlImage($id, $value); |
|
110 | 110 | $img->asAvatar(); |
111 | 111 | return $img; |
112 | - }, $index,$attributes,"avatar"); |
|
112 | + }, $index, $attributes, "avatar"); |
|
113 | 113 | } |
114 | 114 | |
115 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
116 | - return $this->_fieldAs(function($id,$name,$value){ |
|
117 | - $input= new HtmlRadio($id,$name,$value,$value); |
|
115 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
116 | + return $this->_fieldAs(function($id, $name, $value) { |
|
117 | + $input=new HtmlRadio($id, $name, $value, $value); |
|
118 | 118 | return $input; |
119 | - }, $index,$attributes,"radio"); |
|
119 | + }, $index, $attributes, "radio"); |
|
120 | 120 | } |
121 | 121 | |
122 | - public function fieldAsInput($index,$attributes=NULL){ |
|
123 | - return $this->_fieldAs(function($id,$name,$value){ |
|
124 | - $input= new HtmlFormInput($id,"","text",$value); |
|
122 | + public function fieldAsInput($index, $attributes=NULL) { |
|
123 | + return $this->_fieldAs(function($id, $name, $value) { |
|
124 | + $input=new HtmlFormInput($id, "", "text", $value); |
|
125 | 125 | $input->setName($name); |
126 | 126 | return $input; |
127 | - }, $index,$attributes,"input"); |
|
127 | + }, $index, $attributes, "input"); |
|
128 | 128 | } |
129 | 129 | |
130 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
131 | - if(!\is_array($attributes)){ |
|
130 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
131 | + if (!\is_array($attributes)) { |
|
132 | 132 | $attributes=[]; |
133 | 133 | } |
134 | 134 | $attributes["imputType"]="hidden"; |
135 | - return $this->fieldAsInput($index,$attributes); |
|
135 | + return $this->fieldAsInput($index, $attributes); |
|
136 | 136 | } |
137 | 137 | |
138 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
139 | - return $this->_fieldAs(function($id,$name,$value){ |
|
140 | - $input=new HtmlFormCheckbox($id,NULL,$this->_instanceViewer->getIdentifier()); |
|
138 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
139 | + return $this->_fieldAs(function($id, $name, $value) { |
|
140 | + $input=new HtmlFormCheckbox($id, NULL, $this->_instanceViewer->getIdentifier()); |
|
141 | 141 | $input->setChecked(JString::isBooleanTrue($value)); |
142 | 142 | $input->getField()->setProperty("name", $name); |
143 | 143 | return $input; |
144 | - }, $index,$attributes,"ck"); |
|
144 | + }, $index, $attributes, "ck"); |
|
145 | 145 | } |
146 | 146 | |
147 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
148 | - return $this->_fieldAs(function($id,$name,$value) use($elements,$multiple){ |
|
147 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
148 | + return $this->_fieldAs(function($id, $name, $value) use($elements, $multiple){ |
|
149 | 149 | //$dd=new HtmlDropdown($id,$value,$elements); |
150 | - $dd=new HtmlFormDropdown($id,$elements,NULL,$value); |
|
151 | - $dd->asSelect($name,$multiple); |
|
150 | + $dd=new HtmlFormDropdown($id, $elements, NULL, $value); |
|
151 | + $dd->asSelect($name, $multiple); |
|
152 | 152 | return $dd; |
153 | - }, $index,$attributes,"dd"); |
|
153 | + }, $index, $attributes, "dd"); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | \ No newline at end of file |
@@ -20,6 +20,9 @@ |
||
20 | 20 | class DataForm extends Widget { |
21 | 21 | use FormFieldAsTrait,FormTrait; |
22 | 22 | |
23 | + /** |
|
24 | + * @param string $identifier |
|
25 | + */ |
|
23 | 26 | public function __construct($identifier, $modelInstance=NULL) { |
24 | 27 | parent::__construct($identifier, null,$modelInstance); |
25 | 28 | $this->_init(new FormInstanceViewer($identifier), "form", new HtmlForm($identifier), true); |
@@ -18,46 +18,46 @@ discard block |
||
18 | 18 | * @property FormInstanceViewer $_instanceViewer |
19 | 19 | */ |
20 | 20 | class DataForm extends Widget { |
21 | - use FormFieldAsTrait,FormTrait; |
|
21 | + use FormFieldAsTrait, FormTrait; |
|
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->_init(new FormInstanceViewer($identifier), "form", new HtmlForm($identifier), true); |
26 | 26 | } |
27 | 27 | |
28 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
28 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
29 | 29 | $this->_instanceViewer->setInstance($this->_modelInstance); |
30 | 30 | |
31 | 31 | $form=$this->content["form"]; |
32 | 32 | $this->_generateContent($form); |
33 | 33 | |
34 | - if(isset($this->_toolbar)){ |
|
34 | + if (isset($this->_toolbar)) { |
|
35 | 35 | $this->_setToolbarPosition($form); |
36 | 36 | } |
37 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]); |
|
38 | - return parent::compile($js,$view); |
|
37 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]); |
|
38 | + return parent::compile($js, $view); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @param HtmlForm $form |
43 | 43 | */ |
44 | - protected function _generateContent($form){ |
|
45 | - $values= $this->_instanceViewer->getValues(); |
|
44 | + protected function _generateContent($form) { |
|
45 | + $values=$this->_instanceViewer->getValues(); |
|
46 | 46 | $count=$this->_instanceViewer->count(); |
47 | 47 | |
48 | 48 | $separators=$this->_instanceViewer->getSeparators(); |
49 | 49 | $size=\sizeof($separators); |
50 | - if($size===1){ |
|
51 | - foreach ($values as $v){ |
|
50 | + if ($size===1) { |
|
51 | + foreach ($values as $v) { |
|
52 | 52 | $form->addField($v); |
53 | 53 | } |
54 | - }else{ |
|
54 | + } else { |
|
55 | 55 | $separators[]=$count; |
56 | - for($i=0;$i<$size;$i++){ |
|
57 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
58 | - if(\sizeof($fields)===1){ |
|
56 | + for ($i=0; $i<$size; $i++) { |
|
57 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
58 | + if (\sizeof($fields)===1) { |
|
59 | 59 | $form->addField($fields[0]); |
60 | - }else |
|
60 | + } else |
|
61 | 61 | $form->addFields($fields); |
62 | 62 | } |
63 | 63 | } |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | /** |
67 | 67 | * @return HtmlForm |
68 | 68 | */ |
69 | - protected function getForm(){ |
|
69 | + protected function getForm() { |
|
70 | 70 | return $this->content["form"]; |
71 | 71 | } |
72 | 72 | |
73 | - public function addSeparatorAfter($fieldNum){ |
|
73 | + public function addSeparatorAfter($fieldNum) { |
|
74 | 74 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
75 | 75 | return $this; |
76 | 76 | } |
@@ -84,26 +84,26 @@ discard block |
||
84 | 84 | return $this; |
85 | 85 | } |
86 | 86 | |
87 | - public function addSubmitInToolbar($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){ |
|
88 | - $button=new HtmlButton($identifier,$value,$cssStyle); |
|
89 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement); |
|
87 | + public function addSubmitInToolbar($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL) { |
|
88 | + $button=new HtmlButton($identifier, $value, $cssStyle); |
|
89 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement); |
|
90 | 90 | return $this->addInToolbar($button); |
91 | 91 | } |
92 | 92 | |
93 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
94 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle){ |
|
95 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
96 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement); |
|
93 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
94 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle){ |
|
95 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
96 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement); |
|
97 | 97 | return $button; |
98 | - }, $index,$attributes); |
|
98 | + }, $index, $attributes); |
|
99 | 99 | } |
100 | 100 | |
101 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
102 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
103 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
101 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
102 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
103 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
104 | 104 | $button->setProperty("type", "reset"); |
105 | 105 | return $button; |
106 | - }, $index,$attributes); |
|
106 | + }, $index, $attributes); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -51,14 +51,15 @@ |
||
51 | 51 | foreach ($values as $v){ |
52 | 52 | $form->addField($v); |
53 | 53 | } |
54 | - }else{ |
|
54 | + } else{ |
|
55 | 55 | $separators[]=$count; |
56 | 56 | for($i=0;$i<$size;$i++){ |
57 | 57 | $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
58 | 58 | if(\sizeof($fields)===1){ |
59 | 59 | $form->addField($fields[0]); |
60 | - }else |
|
61 | - $form->addFields($fields); |
|
60 | + } else { |
|
61 | + $form->addFields($fields); |
|
62 | + } |
|
62 | 63 | } |
63 | 64 | } |
64 | 65 | } |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | protected $attr; |
20 | 20 | |
21 | 21 | |
22 | - public function __construct($identifier,$tagName){ |
|
23 | - parent::__construct($identifier,$tagName); |
|
22 | + public function __construct($identifier, $tagName) { |
|
23 | + parent::__construct($identifier, $tagName); |
|
24 | 24 | $this->root=""; |
25 | 25 | $this->attr="data-ajax"; |
26 | 26 | } |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | * @param string $targetSelector the target of the get |
32 | 32 | * @return HtmlNavElement |
33 | 33 | */ |
34 | - public function autoGetOnClick($targetSelector){ |
|
35 | - return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
|
34 | + public function autoGetOnClick($targetSelector) { |
|
35 | + return $this->getOnClick($this->root, $targetSelector, array("attr"=>$this->attr)); |
|
36 | 36 | } |
37 | 37 | |
38 | - public function contentAsString(){ |
|
38 | + public function contentAsString() { |
|
39 | 39 | return implode("", $this->content); |
40 | 40 | } |
41 | 41 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | * Generate the jquery script to set the elements to the HtmlNavElement |
44 | 44 | * @param JsUtils $jsUtils |
45 | 45 | */ |
46 | - public function jsSetContent(JsUtils $jsUtils){ |
|
47 | - $jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true); |
|
46 | + public function jsSetContent(JsUtils $jsUtils) { |
|
47 | + $jsUtils->html("#".$this->identifier, str_replace("\"", "'", $this->contentAsString()), true); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function getRoot() { |
51 | 51 | return $this->root; |
52 | 52 | } |
53 | 53 | public function setRoot($root) { |
54 | - $this->root = $root; |
|
54 | + $this->root=$root; |
|
55 | 55 | return $this; |
56 | 56 | } |
57 | 57 | public function getAttr() { |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | * @return HtmlNavElement |
65 | 65 | */ |
66 | 66 | public function setAttr($attr) { |
67 | - $this->attr = $attr; |
|
67 | + $this->attr=$attr; |
|
68 | 68 | return $this; |
69 | 69 | } |
70 | 70 | |
71 | 71 | public function __call($method, $args) { |
72 | - if(isset($this->$method) && is_callable($this->$method)) { |
|
72 | + if (isset($this->$method) && is_callable($this->$method)) { |
|
73 | 73 | return call_user_func_array( |
74 | 74 | $this->$method, |
75 | 75 | $args |
@@ -77,6 +77,6 @@ discard block |
||
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | - abstract public function fromDispatcher(JsUtils $js,$dispatcher,$startIndex=0); |
|
80 | + abstract public function fromDispatcher(JsUtils $js, $dispatcher, $startIndex=0); |
|
81 | 81 | |
82 | 82 | } |
83 | 83 | \ No newline at end of file |
@@ -21,8 +21,9 @@ discard block |
||
21 | 21 | $this->widgetIdentifier=$identifier; |
22 | 22 | $this->values=[]; |
23 | 23 | $this->afterCompile=[]; |
24 | - if(isset($instance)) |
|
25 | - $this->setInstance($instance); |
|
24 | + if(isset($instance)) { |
|
25 | + $this->setInstance($instance); |
|
26 | + } |
|
26 | 27 | $this->setCaptions($captions); |
27 | 28 | $this->captionCallback=NULL; |
28 | 29 | $this->defaultValueFunction=function($name,$value){return $value;}; |
@@ -40,8 +41,9 @@ discard block |
||
40 | 41 | |
41 | 42 | public function getIdentifier(){ |
42 | 43 | $value=self::$index; |
43 | - if(isset($this->values["identifier"])) |
|
44 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
44 | + if(isset($this->values["identifier"])) { |
|
45 | + $value=$this->values["identifier"](self::$index,$this->instance); |
|
46 | + } |
|
45 | 47 | return $value; |
46 | 48 | } |
47 | 49 | |
@@ -65,19 +67,19 @@ discard block |
||
65 | 67 | $value=$property->getValue($this->instance); |
66 | 68 | if(isset($this->values[$index])){ |
67 | 69 | $value= $this->values[$index]($value,$this->instance,$index); |
68 | - }else{ |
|
70 | + } else{ |
|
69 | 71 | $value=$this->_getDefaultValue($property->getName(),$value, $index); |
70 | 72 | } |
71 | - }else{ |
|
72 | - if(\is_callable($property)) |
|
73 | - $value=$property($this->instance); |
|
74 | - elseif(\is_array($property)){ |
|
73 | + } else{ |
|
74 | + if(\is_callable($property)) { |
|
75 | + $value=$property($this->instance); |
|
76 | + } elseif(\is_array($property)){ |
|
75 | 77 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
76 | 78 | $value=\implode("", $values); |
77 | - }else{ |
|
79 | + } else{ |
|
78 | 80 | if(isset($this->values[$index])){ |
79 | 81 | $value= $this->values[$index]($property,$this->instance,$index); |
80 | - }else{ |
|
82 | + } else{ |
|
81 | 83 | $value=$property; |
82 | 84 | } |
83 | 85 | } |
@@ -100,10 +102,10 @@ discard block |
||
100 | 102 | if(isset($vb[$index])){ |
101 | 103 | if(\is_array($vb[$index])){ |
102 | 104 | $this->visibleProperties[$index][]=$field; |
103 | - }else{ |
|
105 | + } else{ |
|
104 | 106 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
105 | 107 | } |
106 | - }else{ |
|
108 | + } else{ |
|
107 | 109 | return $this->insertField($index, $field); |
108 | 110 | } |
109 | 111 | return $this; |
@@ -139,7 +141,7 @@ discard block |
||
139 | 141 | $this->reflect=new \ReflectionClass($instance); |
140 | 142 | if(\sizeof($this->visibleProperties)===0){ |
141 | 143 | $this->properties=$this->getDefaultProperties(); |
142 | - }else{ |
|
144 | + } else{ |
|
143 | 145 | foreach ($this->visibleProperties as $property){ |
144 | 146 | $this->setInstanceProperty($property); |
145 | 147 | } |
@@ -150,22 +152,23 @@ discard block |
||
150 | 152 | private function setInstanceProperty($property){ |
151 | 153 | if(\is_callable($property)){ |
152 | 154 | $this->properties[]=$property; |
153 | - }elseif(\is_string($property)){ |
|
155 | + } elseif(\is_string($property)){ |
|
154 | 156 | try{ |
155 | 157 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
156 | 158 | $rProperty=$this->reflect->getProperty($property); |
157 | 159 | $this->properties[]=$rProperty; |
158 | - }catch(\Exception $e){ |
|
160 | + } catch(\Exception $e){ |
|
159 | 161 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
160 | 162 | $this->properties[]=$property; |
161 | 163 | } |
162 | - }elseif(\is_int($property)){ |
|
164 | + } elseif(\is_int($property)){ |
|
163 | 165 | $props=$this->getDefaultProperties(); |
164 | - if(isset($props[$property])) |
|
165 | - $this->properties[]=$props[$property]; |
|
166 | - else |
|
167 | - $this->properties[]=$property; |
|
168 | - }else{ |
|
166 | + if(isset($props[$property])) { |
|
167 | + $this->properties[]=$props[$property]; |
|
168 | + } else { |
|
169 | + $this->properties[]=$property; |
|
170 | + } |
|
171 | + } else{ |
|
169 | 172 | $this->properties[]=$property; |
170 | 173 | } |
171 | 174 | } |
@@ -209,12 +212,13 @@ discard block |
||
209 | 212 | if(isset($this->captions[$index])){ |
210 | 213 | return $this->captions[$index]; |
211 | 214 | } |
212 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
213 | - return $this->properties[$index]->getName(); |
|
214 | - elseif(\is_callable($this->properties[$index])) |
|
215 | - return ""; |
|
216 | - else |
|
217 | - return $this->properties[$index]; |
|
215 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
216 | + return $this->properties[$index]->getName(); |
|
217 | + } elseif(\is_callable($this->properties[$index])) { |
|
218 | + return ""; |
|
219 | + } else { |
|
220 | + return $this->properties[$index]; |
|
221 | + } |
|
218 | 222 | } |
219 | 223 | |
220 | 224 | public function getCaptions(){ |
@@ -223,7 +227,7 @@ discard block |
||
223 | 227 | for($i=\sizeof($captions);$i<$this->count();$i++){ |
224 | 228 | $captions[]=""; |
225 | 229 | } |
226 | - }else{ |
|
230 | + } else{ |
|
227 | 231 | $captions=[]; |
228 | 232 | $index=0; |
229 | 233 | $count=$this->count(); |
@@ -239,8 +243,9 @@ discard block |
||
239 | 243 | } |
240 | 244 | |
241 | 245 | public function setCaption($index,$caption){ |
242 | - if(isset($this->captions)===false) |
|
243 | - $this->captions=[]; |
|
246 | + if(isset($this->captions)===false) { |
|
247 | + $this->captions=[]; |
|
248 | + } |
|
244 | 249 | $this->captions[$index]=$caption; |
245 | 250 | return $this; |
246 | 251 | } |
@@ -17,165 +17,165 @@ discard block |
||
17 | 17 | |
18 | 18 | public static $index=0; |
19 | 19 | |
20 | - public function __construct($identifier,$instance=NULL,$captions=NULL){ |
|
20 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
21 | 21 | $this->widgetIdentifier=$identifier; |
22 | 22 | $this->values=[]; |
23 | 23 | $this->afterCompile=[]; |
24 | - if(isset($instance)) |
|
24 | + if (isset($instance)) |
|
25 | 25 | $this->setInstance($instance); |
26 | 26 | $this->setCaptions($captions); |
27 | 27 | $this->captionCallback=NULL; |
28 | - $this->defaultValueFunction=function($name,$value){return $value;}; |
|
28 | + $this->defaultValueFunction=function($name, $value) {return $value; }; |
|
29 | 29 | } |
30 | 30 | |
31 | - public function getValues(){ |
|
31 | + public function getValues() { |
|
32 | 32 | $values=[]; |
33 | 33 | $index=0; |
34 | 34 | $count=$this->count(); |
35 | - while($index<$count){ |
|
35 | + while ($index<$count) { |
|
36 | 36 | $values[]=$this->getValue($index++); |
37 | 37 | } |
38 | 38 | return $values; |
39 | 39 | } |
40 | 40 | |
41 | - public function getIdentifier(){ |
|
41 | + public function getIdentifier() { |
|
42 | 42 | $value=self::$index; |
43 | - if(isset($this->values["identifier"])) |
|
44 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
43 | + if (isset($this->values["identifier"])) |
|
44 | + $value=$this->values["identifier"](self::$index, $this->instance); |
|
45 | 45 | return $value; |
46 | 46 | } |
47 | 47 | |
48 | - public function getValue($index){ |
|
48 | + public function getValue($index) { |
|
49 | 49 | $property=$this->properties[$index]; |
50 | 50 | return $this->_getValue($property, $index); |
51 | 51 | } |
52 | 52 | |
53 | - protected function _beforeAddProperty($index,&$field){ |
|
53 | + protected function _beforeAddProperty($index, &$field) { |
|
54 | 54 | |
55 | 55 | } |
56 | 56 | |
57 | - protected function _getDefaultValue($name,$value,$index){ |
|
57 | + protected function _getDefaultValue($name, $value, $index) { |
|
58 | 58 | $func=$this->defaultValueFunction; |
59 | - return $func($name,$value,$index,$this->instance); |
|
59 | + return $func($name, $value, $index, $this->instance); |
|
60 | 60 | } |
61 | 61 | |
62 | - protected function _getValue($property,$index){ |
|
63 | - if($property instanceof \ReflectionProperty){ |
|
62 | + protected function _getValue($property, $index) { |
|
63 | + if ($property instanceof \ReflectionProperty) { |
|
64 | 64 | $property->setAccessible(true); |
65 | 65 | $value=$property->getValue($this->instance); |
66 | - if(isset($this->values[$index])){ |
|
67 | - $value= $this->values[$index]($value,$this->instance,$index); |
|
68 | - }else{ |
|
69 | - $value=$this->_getDefaultValue($property->getName(),$value, $index); |
|
66 | + if (isset($this->values[$index])) { |
|
67 | + $value=$this->values[$index]($value, $this->instance, $index); |
|
68 | + } else { |
|
69 | + $value=$this->_getDefaultValue($property->getName(), $value, $index); |
|
70 | 70 | } |
71 | - }else{ |
|
72 | - if(\is_callable($property)) |
|
71 | + } else { |
|
72 | + if (\is_callable($property)) |
|
73 | 73 | $value=$property($this->instance); |
74 | - elseif(\is_array($property)){ |
|
75 | - $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
|
74 | + elseif (\is_array($property)) { |
|
75 | + $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property); |
|
76 | 76 | $value=\implode("", $values); |
77 | - }else{ |
|
78 | - if(isset($this->values[$index])){ |
|
79 | - $value= $this->values[$index]($property,$this->instance,$index); |
|
80 | - }else{ |
|
77 | + } else { |
|
78 | + if (isset($this->values[$index])) { |
|
79 | + $value=$this->values[$index]($property, $this->instance, $index); |
|
80 | + } else { |
|
81 | 81 | $value=$property; |
82 | 82 | } |
83 | 83 | } |
84 | 84 | } |
85 | - if(isset($this->afterCompile[$index])){ |
|
86 | - if(\is_callable($this->afterCompile[$index])){ |
|
87 | - $this->afterCompile[$index]($value,$this->instance,$index); |
|
85 | + if (isset($this->afterCompile[$index])) { |
|
86 | + if (\is_callable($this->afterCompile[$index])) { |
|
87 | + $this->afterCompile[$index]($value, $this->instance, $index); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | return $value; |
91 | 91 | } |
92 | 92 | |
93 | - public function insertField($index,$field){ |
|
94 | - array_splice( $this->visibleProperties, $index, 0, $field ); |
|
93 | + public function insertField($index, $field) { |
|
94 | + array_splice($this->visibleProperties, $index, 0, $field); |
|
95 | 95 | return $this; |
96 | 96 | } |
97 | 97 | |
98 | - public function insertInField($index,$field){ |
|
98 | + public function insertInField($index, $field) { |
|
99 | 99 | $vb=$this->visibleProperties; |
100 | - if(isset($vb[$index])){ |
|
101 | - if(\is_array($vb[$index])){ |
|
100 | + if (isset($vb[$index])) { |
|
101 | + if (\is_array($vb[$index])) { |
|
102 | 102 | $this->visibleProperties[$index][]=$field; |
103 | - }else{ |
|
104 | - $this->visibleProperties[$index]=[$vb[$index],$field]; |
|
103 | + } else { |
|
104 | + $this->visibleProperties[$index]=[$vb[$index], $field]; |
|
105 | 105 | } |
106 | - }else{ |
|
106 | + } else { |
|
107 | 107 | return $this->insertField($index, $field); |
108 | 108 | } |
109 | 109 | return $this; |
110 | 110 | } |
111 | 111 | |
112 | - public function addField($field){ |
|
112 | + public function addField($field) { |
|
113 | 113 | $this->visibleProperties[]=$field; |
114 | 114 | return $this; |
115 | 115 | } |
116 | 116 | |
117 | - public function count(){ |
|
117 | + public function count() { |
|
118 | 118 | return \sizeof($this->properties); |
119 | 119 | } |
120 | 120 | |
121 | - public function visiblePropertiesCount(){ |
|
121 | + public function visiblePropertiesCount() { |
|
122 | 122 | return \sizeof($this->visibleProperties); |
123 | 123 | } |
124 | 124 | |
125 | - public function getProperty($index){ |
|
125 | + public function getProperty($index) { |
|
126 | 126 | return $this->properties[$index]; |
127 | 127 | } |
128 | 128 | |
129 | - protected function showableProperty(\ReflectionProperty $rProperty){ |
|
130 | - return JString::startswith($rProperty->getName(),"_")===false; |
|
129 | + protected function showableProperty(\ReflectionProperty $rProperty) { |
|
130 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | public function setInstance($instance) { |
134 | - if(\is_string($instance)){ |
|
134 | + if (\is_string($instance)) { |
|
135 | 135 | $instance=new $instance(); |
136 | 136 | } |
137 | 137 | $this->instance=$instance; |
138 | 138 | $this->properties=[]; |
139 | 139 | $this->reflect=new \ReflectionClass($instance); |
140 | - if(\sizeof($this->visibleProperties)===0){ |
|
140 | + if (\sizeof($this->visibleProperties)===0) { |
|
141 | 141 | $this->properties=$this->getDefaultProperties(); |
142 | - }else{ |
|
143 | - foreach ($this->visibleProperties as $property){ |
|
142 | + } else { |
|
143 | + foreach ($this->visibleProperties as $property) { |
|
144 | 144 | $this->setInstanceProperty($property); |
145 | 145 | } |
146 | 146 | } |
147 | 147 | return $this; |
148 | 148 | } |
149 | 149 | |
150 | - private function setInstanceProperty($property){ |
|
151 | - if(\is_callable($property)){ |
|
150 | + private function setInstanceProperty($property) { |
|
151 | + if (\is_callable($property)) { |
|
152 | 152 | $this->properties[]=$property; |
153 | - }elseif(\is_string($property)){ |
|
154 | - try{ |
|
153 | + }elseif (\is_string($property)) { |
|
154 | + try { |
|
155 | 155 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
156 | 156 | $rProperty=$this->reflect->getProperty($property); |
157 | 157 | $this->properties[]=$rProperty; |
158 | - }catch(\Exception $e){ |
|
158 | + }catch (\Exception $e) { |
|
159 | 159 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
160 | 160 | $this->properties[]=$property; |
161 | 161 | } |
162 | - }elseif(\is_int($property)){ |
|
162 | + }elseif (\is_int($property)) { |
|
163 | 163 | $props=$this->getDefaultProperties(); |
164 | - if(isset($props[$property])) |
|
164 | + if (isset($props[$property])) |
|
165 | 165 | $this->properties[]=$props[$property]; |
166 | 166 | else |
167 | 167 | $this->properties[]=$property; |
168 | - }else{ |
|
168 | + } else { |
|
169 | 169 | $this->properties[]=$property; |
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | - protected function getDefaultProperties(){ |
|
173 | + protected function getDefaultProperties() { |
|
174 | 174 | $result=[]; |
175 | 175 | $properties=$this->reflect->getProperties(); |
176 | - foreach ($properties as $property){ |
|
176 | + foreach ($properties as $property) { |
|
177 | 177 | $showable=$this->showableProperty($property); |
178 | - if($showable!==false){ |
|
178 | + if ($showable!==false) { |
|
179 | 179 | $result[]=$property; |
180 | 180 | } |
181 | 181 | } |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | return $this; |
188 | 188 | } |
189 | 189 | |
190 | - public function setValueFunction($index,$callback){ |
|
190 | + public function setValueFunction($index, $callback) { |
|
191 | 191 | $this->values[$index]=$callback; |
192 | 192 | return $this; |
193 | 193 | } |
194 | 194 | |
195 | - public function setIdentifierFunction($callback){ |
|
195 | + public function setIdentifierFunction($callback) { |
|
196 | 196 | $this->values["identifier"]=$callback; |
197 | 197 | return $this; |
198 | 198 | } |
@@ -205,41 +205,41 @@ discard block |
||
205 | 205 | return $this->properties; |
206 | 206 | } |
207 | 207 | |
208 | - public function getCaption($index){ |
|
209 | - if(isset($this->captions[$index])){ |
|
208 | + public function getCaption($index) { |
|
209 | + if (isset($this->captions[$index])) { |
|
210 | 210 | return $this->captions[$index]; |
211 | 211 | } |
212 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
212 | + if ($this->properties[$index] instanceof \ReflectionProperty) |
|
213 | 213 | return $this->properties[$index]->getName(); |
214 | - elseif(\is_callable($this->properties[$index])) |
|
214 | + elseif (\is_callable($this->properties[$index])) |
|
215 | 215 | return ""; |
216 | 216 | else |
217 | 217 | return $this->properties[$index]; |
218 | 218 | } |
219 | 219 | |
220 | - public function getCaptions(){ |
|
221 | - if(isset($this->captions)){ |
|
222 | - $captions= $this->captions; |
|
223 | - for($i=\sizeof($captions);$i<$this->count();$i++){ |
|
220 | + public function getCaptions() { |
|
221 | + if (isset($this->captions)) { |
|
222 | + $captions=$this->captions; |
|
223 | + for ($i=\sizeof($captions); $i<$this->count(); $i++) { |
|
224 | 224 | $captions[]=""; |
225 | 225 | } |
226 | - }else{ |
|
226 | + } else { |
|
227 | 227 | $captions=[]; |
228 | 228 | $index=0; |
229 | 229 | $count=$this->count(); |
230 | - while($index<$count){ |
|
230 | + while ($index<$count) { |
|
231 | 231 | $captions[]=$this->getCaption($index++); |
232 | 232 | } |
233 | 233 | } |
234 | - if(isset($this->captionCallback) && \is_callable($this->captionCallback)){ |
|
234 | + if (isset($this->captionCallback) && \is_callable($this->captionCallback)) { |
|
235 | 235 | $callback=$this->captionCallback; |
236 | - $callback($captions,$this->instance); |
|
236 | + $callback($captions, $this->instance); |
|
237 | 237 | } |
238 | 238 | return $captions; |
239 | 239 | } |
240 | 240 | |
241 | - public function setCaption($index,$caption){ |
|
242 | - if(isset($this->captions)===false) |
|
241 | + public function setCaption($index, $caption) { |
|
242 | + if (isset($this->captions)===false) |
|
243 | 243 | $this->captions=[]; |
244 | 244 | $this->captions[$index]=$caption; |
245 | 245 | return $this; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @param callable $callback function called after the field compilation |
258 | 258 | * @return \Ajax\semantic\widgets\datatable\InstanceViewer |
259 | 259 | */ |
260 | - public function afterCompile($index,$callback){ |
|
260 | + public function afterCompile($index, $callback) { |
|
261 | 261 | $this->afterCompile[$index]=$callback; |
262 | 262 | return $this; |
263 | 263 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param string $tagName |
159 | 159 | * @return HtmlLabel |
160 | 160 | */ |
161 | - public function htmlLabel($identifier, $content="", $icon=NULL,$tagName="div") { |
|
162 | - return $this->addHtmlComponent(new HtmlLabel($identifier, $content,$icon, $tagName)); |
|
161 | + public function htmlLabel($identifier, $content="", $icon=NULL, $tagName="div") { |
|
162 | + return $this->addHtmlComponent(new HtmlLabel($identifier, $content, $icon, $tagName)); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * @param array $attributes |
169 | 169 | * @return HtmlLabelGroups |
170 | 170 | */ |
171 | - public function htmlLabelGroups($identifier,$labels=array(),$attributes=array()){ |
|
172 | - return $this->addHtmlComponent(new HtmlLabelGroups($identifier,$labels,$attributes)); |
|
171 | + public function htmlLabelGroups($identifier, $labels=array(), $attributes=array()) { |
|
172 | + return $this->addHtmlComponent(new HtmlLabelGroups($identifier, $labels, $attributes)); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | abstract public function addToProperty($name, $value, $separator=" "); |
18 | 18 | abstract public function addLabel($caption, $style="label-default", $leftSeparator=" "); |
19 | - abstract public function addContent($content,$before=false); |
|
19 | + abstract public function addContent($content, $before=false); |
|
20 | 20 | abstract public function getField(); |
21 | 21 | abstract public function getDataField(); |
22 | 22 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | public function addLoading() { |
28 | - if ($this->_hasIcon === false) { |
|
28 | + if ($this->_hasIcon===false) { |
|
29 | 29 | throw new \Exception("Input must have an icon for showing a loader, use addIcon before"); |
30 | 30 | } |
31 | 31 | return $this->addToProperty("class", State::LOADING); |
@@ -33,56 +33,56 @@ discard block |
||
33 | 33 | |
34 | 34 | public function labeled($label, $direction=Direction::LEFT, $icon=NULL) { |
35 | 35 | $field=$this->getField(); |
36 | - $labelO=$field->addLabel($label,$direction===Direction::LEFT,$icon); |
|
37 | - $field->addToProperty("class", $direction . " labeled"); |
|
36 | + $labelO=$field->addLabel($label, $direction===Direction::LEFT, $icon); |
|
37 | + $field->addToProperty("class", $direction." labeled"); |
|
38 | 38 | return $labelO; |
39 | 39 | } |
40 | 40 | |
41 | 41 | public function labeledToCorner($icon, $direction=Direction::LEFT) { |
42 | - return $this->labeled("", $direction . " corner", $icon)->toCorner($direction); |
|
42 | + return $this->labeled("", $direction." corner", $icon)->toCorner($direction); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public function addAction($action, $direction=Direction::RIGHT, $icon=NULL, $labeled=false) { |
46 | 46 | $field=$this->getField(); |
47 | 47 | $actionO=$action; |
48 | - if (\is_object($action) === false) { |
|
49 | - $actionO=new HtmlButton("action-" . $this->identifier, $action); |
|
48 | + if (\is_object($action)===false) { |
|
49 | + $actionO=new HtmlButton("action-".$this->identifier, $action); |
|
50 | 50 | if (isset($icon)) |
51 | 51 | $actionO->addIcon($icon, true, $labeled); |
52 | 52 | } |
53 | - $field->addToProperty("class", $direction . " action"); |
|
54 | - $field->addContent($actionO, \strstr($direction, Direction::LEFT) !== false); |
|
53 | + $field->addToProperty("class", $direction." action"); |
|
54 | + $field->addContent($actionO, \strstr($direction, Direction::LEFT)!==false); |
|
55 | 55 | return $actionO; |
56 | 56 | } |
57 | 57 | |
58 | - public function addDropdown($label="", $items=array(),$direction=Direction::RIGHT){ |
|
59 | - $labelO=new HtmlDropdown("dd-".$this->identifier,$label,$items); |
|
60 | - $labelO->asSelect("select-".$this->identifier,false,true); |
|
61 | - return $this->labeled($labelO,$direction); |
|
58 | + public function addDropdown($label="", $items=array(), $direction=Direction::RIGHT) { |
|
59 | + $labelO=new HtmlDropdown("dd-".$this->identifier, $label, $items); |
|
60 | + $labelO->asSelect("select-".$this->identifier, false, true); |
|
61 | + return $this->labeled($labelO, $direction); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | public function setTransparent() { |
65 | 65 | return $this->getField()->addToProperty("class", "transparent"); |
66 | 66 | } |
67 | 67 | |
68 | - public function setReadonly(){ |
|
68 | + public function setReadonly() { |
|
69 | 69 | $this->getDataField()->setProperty("readonly", ""); |
70 | 70 | return $this; |
71 | 71 | } |
72 | 72 | |
73 | - public function setName($name){ |
|
74 | - $this->getDataField()->setProperty("name",$name); |
|
73 | + public function setName($name) { |
|
74 | + $this->getDataField()->setProperty("name", $name); |
|
75 | 75 | return $this; |
76 | 76 | } |
77 | 77 | |
78 | - public function setFluid(){ |
|
79 | - $this->getField()->addToProperty("class","fluid"); |
|
78 | + public function setFluid() { |
|
79 | + $this->getField()->addToProperty("class", "fluid"); |
|
80 | 80 | return $this; |
81 | 81 | } |
82 | 82 | |
83 | 83 | public function setDisabled($disable=true) { |
84 | 84 | $field=$this->getField(); |
85 | - if($disable) |
|
85 | + if ($disable) |
|
86 | 86 | $field->addToProperty("class", "disabled"); |
87 | 87 | return $this; |
88 | 88 | } |
@@ -47,8 +47,9 @@ discard block |
||
47 | 47 | $actionO=$action; |
48 | 48 | if (\is_object($action) === false) { |
49 | 49 | $actionO=new HtmlButton("action-" . $this->identifier, $action); |
50 | - if (isset($icon)) |
|
51 | - $actionO->addIcon($icon, true, $labeled); |
|
50 | + if (isset($icon)) { |
|
51 | + $actionO->addIcon($icon, true, $labeled); |
|
52 | + } |
|
52 | 53 | } |
53 | 54 | $field->addToProperty("class", $direction . " action"); |
54 | 55 | $field->addContent($actionO, \strstr($direction, Direction::LEFT) !== false); |
@@ -82,8 +83,9 @@ discard block |
||
82 | 83 | |
83 | 84 | public function setDisabled($disable=true) { |
84 | 85 | $field=$this->getField(); |
85 | - if($disable) |
|
86 | - $field->addToProperty("class", "disabled"); |
|
86 | + if($disable) { |
|
87 | + $field->addToProperty("class", "disabled"); |
|
88 | + } |
|
87 | 89 | return $this; |
88 | 90 | } |
89 | 91 | } |
90 | 92 | \ No newline at end of file |
@@ -38,18 +38,18 @@ discard block |
||
38 | 38 | return $this->getHtmlCk()->attachEvents($events); |
39 | 39 | } |
40 | 40 | |
41 | - public function getField(){ |
|
41 | + public function getField() { |
|
42 | 42 | //TODO check getField() ? |
43 | 43 | return $this->content["field"]; |
44 | 44 | } |
45 | 45 | |
46 | - public function getHtmlCk(){ |
|
46 | + public function getHtmlCk() { |
|
47 | 47 | return $this->content["field"]; |
48 | 48 | } |
49 | 49 | |
50 | - public function getDataField(){ |
|
51 | - $field= $this->getField(); |
|
52 | - if($field instanceof AbstractCheckbox) |
|
50 | + public function getDataField() { |
|
51 | + $field=$this->getField(); |
|
52 | + if ($field instanceof AbstractCheckbox) |
|
53 | 53 | $field=$field->getField(); |
54 | 54 | return $field; |
55 | 55 | } |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | * @param boolean $value |
60 | 60 | * @return HtmlFormField |
61 | 61 | */ |
62 | - public function setChecked($value=true){ |
|
63 | - if($value===true){ |
|
62 | + public function setChecked($value=true) { |
|
63 | + if ($value===true) { |
|
64 | 64 | $this->getDataField()->setProperty("checked", "checked"); |
65 | - }else{ |
|
65 | + } else { |
|
66 | 66 | $this->getDataField()->removeProperty("checked"); |
67 | 67 | } |
68 | 68 | return $this; |
@@ -49,8 +49,9 @@ discard block |
||
49 | 49 | |
50 | 50 | public function getDataField(){ |
51 | 51 | $field= $this->getField(); |
52 | - if($field instanceof AbstractCheckbox) |
|
53 | - $field=$field->getField(); |
|
52 | + if($field instanceof AbstractCheckbox) { |
|
53 | + $field=$field->getField(); |
|
54 | + } |
|
54 | 55 | return $field; |
55 | 56 | } |
56 | 57 | |
@@ -62,7 +63,7 @@ discard block |
||
62 | 63 | public function setChecked($value=true){ |
63 | 64 | if($value===true){ |
64 | 65 | $this->getDataField()->setProperty("checked", "checked"); |
65 | - }else{ |
|
66 | + } else{ |
|
66 | 67 | $this->getDataField()->removeProperty("checked"); |
67 | 68 | } |
68 | 69 | return $this; |
@@ -14,34 +14,34 @@ discard block |
||
14 | 14 | use FieldTrait; |
15 | 15 | protected $_container; |
16 | 16 | protected $_validation; |
17 | - public function __construct($identifier, $field,$label=NULL) { |
|
18 | - parent::__construct($identifier, "div","field"); |
|
17 | + public function __construct($identifier, $field, $label=NULL) { |
|
18 | + parent::__construct($identifier, "div", "field"); |
|
19 | 19 | $this->content=array(); |
20 | - $this->_states=[State::ERROR,State::DISABLED]; |
|
21 | - if(isset($label)) |
|
20 | + $this->_states=[State::ERROR, State::DISABLED]; |
|
21 | + if (isset($label)) |
|
22 | 22 | $this->setLabel($label); |
23 | 23 | $this->setField($field); |
24 | 24 | $this->_validation=NULL; |
25 | 25 | } |
26 | 26 | |
27 | - public function addPointingLabel($label,$pointing=Direction::NONE){ |
|
28 | - $labelO=new HtmlLabel("",$label); |
|
27 | + public function addPointingLabel($label, $pointing=Direction::NONE) { |
|
28 | + $labelO=new HtmlLabel("", $label); |
|
29 | 29 | $labelO->setPointing($pointing); |
30 | - $this->addContent($labelO,$pointing==="below" || $pointing==="right"); |
|
30 | + $this->addContent($labelO, $pointing==="below" || $pointing==="right"); |
|
31 | 31 | return $labelO; |
32 | 32 | } |
33 | 33 | |
34 | - public function setLabel($label){ |
|
34 | + public function setLabel($label) { |
|
35 | 35 | $labelO=$label; |
36 | - if(\is_string($label)){ |
|
37 | - $labelO=new HtmlSemDoubleElement("","label",""); |
|
36 | + if (\is_string($label)) { |
|
37 | + $labelO=new HtmlSemDoubleElement("", "label", ""); |
|
38 | 38 | $labelO->setContent($label); |
39 | - $labelO->setProperty("for", \str_replace("field-", "",$this->identifier)); |
|
39 | + $labelO->setProperty("for", \str_replace("field-", "", $this->identifier)); |
|
40 | 40 | } |
41 | 41 | $this->content["label"]=$labelO; |
42 | 42 | } |
43 | 43 | |
44 | - public function setField($field){ |
|
44 | + public function setField($field) { |
|
45 | 45 | $this->content["field"]=$field; |
46 | 46 | } |
47 | 47 | |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | * Returns the label or null |
50 | 50 | * @return mixed |
51 | 51 | */ |
52 | - public function getLabel(){ |
|
53 | - if(\array_key_exists("label", $this->content)) |
|
52 | + public function getLabel() { |
|
53 | + if (\array_key_exists("label", $this->content)) |
|
54 | 54 | return $this->content["label"]; |
55 | 55 | } |
56 | 56 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * Return the field |
59 | 59 | * @return mixed |
60 | 60 | */ |
61 | - public function getField(){ |
|
61 | + public function getField() { |
|
62 | 62 | return $this->content["field"]; |
63 | 63 | } |
64 | 64 | |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | * Return the field with data |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | - public function getDataField(){ |
|
69 | + public function getDataField() { |
|
70 | 70 | return $this->content["field"]; |
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
74 | 74 | * puts the label before or behind |
75 | 75 | */ |
76 | - public function swapLabel(){ |
|
76 | + public function swapLabel() { |
|
77 | 77 | $label=$this->getLabel(); |
78 | 78 | unset($this->content["label"]); |
79 | 79 | $this->content["label"]=$label; |
@@ -84,31 +84,31 @@ discard block |
||
84 | 84 | * @param int $width |
85 | 85 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
86 | 86 | */ |
87 | - public function setWidth($width){ |
|
88 | - if(\is_int($width)){ |
|
87 | + public function setWidth($width) { |
|
88 | + if (\is_int($width)) { |
|
89 | 89 | $width=Wide::getConstants()["W".$width]; |
90 | 90 | } |
91 | 91 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
92 | - if(isset($this->_container)){ |
|
92 | + if (isset($this->_container)) { |
|
93 | 93 | $this->_container->setEqualWidth(false); |
94 | 94 | } |
95 | - return $this->addToPropertyCtrl("class", "wide",array("wide")); |
|
95 | + return $this->addToPropertyCtrl("class", "wide", array("wide")); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Field displays an error state |
100 | 100 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
101 | 101 | */ |
102 | - public function setError(){ |
|
102 | + public function setError() { |
|
103 | 103 | return $this->addToProperty("class", "error"); |
104 | 104 | } |
105 | 105 | |
106 | - public function setInline(){ |
|
106 | + public function setInline() { |
|
107 | 107 | return $this->addToProperty("class", "inline"); |
108 | 108 | } |
109 | 109 | |
110 | - public function jsState($state){ |
|
111 | - return $this->jsDoJquery("addClass",$state); |
|
110 | + public function jsState($state) { |
|
111 | + return $this->jsDoJquery("addClass", $state); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | public function setContainer($_container) { |
@@ -116,34 +116,34 @@ discard block |
||
116 | 116 | return $this; |
117 | 117 | } |
118 | 118 | |
119 | - public function setReadonly(){ |
|
119 | + public function setReadonly() { |
|
120 | 120 | $this->getField()->setProperty("readonly", ""); |
121 | 121 | } |
122 | 122 | |
123 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
123 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
124 | 124 | $field=$this->getDataField(); |
125 | - if(isset($field)){ |
|
126 | - if(!isset($this->_validation)){ |
|
125 | + if (isset($field)) { |
|
126 | + if (!isset($this->_validation)) { |
|
127 | 127 | $this->_validation=new FieldValidation($field->getIdentifier()); |
128 | 128 | } |
129 | - if($type==="empty"){ |
|
130 | - $this->addToProperty("class","required"); |
|
129 | + if ($type==="empty") { |
|
130 | + $this->addToProperty("class", "required"); |
|
131 | 131 | } |
132 | - $this->_validation->addRule($type,$prompt,$value); |
|
132 | + $this->_validation->addRule($type, $prompt, $value); |
|
133 | 133 | } |
134 | 134 | return $this; |
135 | 135 | } |
136 | 136 | |
137 | - public function addRules(array $rules){ |
|
138 | - foreach ($rules as $rule){ |
|
137 | + public function addRules(array $rules) { |
|
138 | + foreach ($rules as $rule) { |
|
139 | 139 | $this->addRule($rule); |
140 | 140 | } |
141 | 141 | return $this; |
142 | 142 | } |
143 | 143 | |
144 | - public function addIcon($icon,$direction=Direction::LEFT){ |
|
144 | + public function addIcon($icon, $direction=Direction::LEFT) { |
|
145 | 145 | $field=$this->getField(); |
146 | - return $field->addIcon($icon,$direction); |
|
146 | + return $field->addIcon($icon, $direction); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | public function getValidation() { |
@@ -18,8 +18,9 @@ discard block |
||
18 | 18 | parent::__construct($identifier, "div","field"); |
19 | 19 | $this->content=array(); |
20 | 20 | $this->_states=[State::ERROR,State::DISABLED]; |
21 | - if(isset($label)) |
|
22 | - $this->setLabel($label); |
|
21 | + if(isset($label)) { |
|
22 | + $this->setLabel($label); |
|
23 | + } |
|
23 | 24 | $this->setField($field); |
24 | 25 | $this->_validation=NULL; |
25 | 26 | } |
@@ -50,8 +51,9 @@ discard block |
||
50 | 51 | * @return mixed |
51 | 52 | */ |
52 | 53 | public function getLabel(){ |
53 | - if(\array_key_exists("label", $this->content)) |
|
54 | - return $this->content["label"]; |
|
54 | + if(\array_key_exists("label", $this->content)) { |
|
55 | + return $this->content["label"]; |
|
56 | + } |
|
55 | 57 | } |
56 | 58 | |
57 | 59 | /** |
@@ -7,25 +7,25 @@ |
||
7 | 7 | |
8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
9 | 9 | |
10 | - public function __construct($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false,$associative=true) { |
|
11 | - parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label); |
|
10 | + public function __construct($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false, $associative=true) { |
|
11 | + parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->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,$associative=true){ |
|
21 | - return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative); |
|
20 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $associative=true) { |
|
21 | + return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative); |
|
22 | 22 | } |
23 | 23 | |
24 | - public function getDataField(){ |
|
24 | + public function getDataField() { |
|
25 | 25 | return $this->getField()->getInput(); |
26 | 26 | } |
27 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
28 | - $this->getField()->asSelect($name,$multiple,$selection); |
|
27 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
28 | + $this->getField()->asSelect($name, $multiple, $selection); |
|
29 | 29 | return $this; |
30 | 30 | } |
31 | 31 | } |
32 | 32 | \ No newline at end of file |