@@ -14,9 +14,9 @@ |
||
14 | 14 | |
15 | 15 | public function __construct(JsUtils $js) { |
16 | 16 | parent::__construct($js); |
17 | - $this->params = array( |
|
17 | + $this->params=array( |
|
18 | 18 | "value" => 50 |
19 | 19 | ); |
20 | - $this->uiName = "progressbar"; |
|
20 | + $this->uiName="progressbar"; |
|
21 | 21 | } |
22 | 22 | } |
@@ -14,15 +14,15 @@ discard block |
||
14 | 14 | class DialogButton extends BaseComponent { |
15 | 15 | |
16 | 16 | private function addFunction($jsCode) { |
17 | - if (! JString::startsWith($jsCode, "function")) |
|
18 | - $jsCode = "%function(){" . $jsCode . "}%"; |
|
17 | + if (!JString::startsWith($jsCode, "function")) |
|
18 | + $jsCode="%function(){".$jsCode."}%"; |
|
19 | 19 | return $jsCode; |
20 | 20 | } |
21 | 21 | |
22 | - public function __construct($caption, $jsCode, $event = "click") { |
|
22 | + public function __construct($caption, $jsCode, $event="click") { |
|
23 | 23 | parent::__construct(NULL); |
24 | - $this->params["text"] = $caption; |
|
25 | - $this->params[$event] = $this->addFunction($jsCode); |
|
24 | + $this->params["text"]=$caption; |
|
25 | + $this->params[$event]=$this->addFunction($jsCode); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function __toString() { |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | return json_encode($this->params, JSON_UNESCAPED_SLASHES); |
38 | 38 | } |
39 | 39 | |
40 | - public static function cancelButton($caption = "Annuler") { |
|
40 | + public static function cancelButton($caption="Annuler") { |
|
41 | 41 | return new DialogButton($caption, "$( this ).dialog( 'close' );"); |
42 | 42 | } |
43 | 43 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null) |
53 | 53 | * @return DialogButton |
54 | 54 | */ |
55 | - public static function submitButton(JsUtils $js, $url, $form, $responseElement, $caption = "Okay", $parameters = []) { |
|
56 | - return new DialogButton($caption, $js->postFormDeferred($url, $form, $responseElement, $parameters) . ";$( this ).dialog( 'close' );"); |
|
55 | + public static function submitButton(JsUtils $js, $url, $form, $responseElement, $caption="Okay", $parameters=[]) { |
|
56 | + return new DialogButton($caption, $js->postFormDeferred($url, $form, $responseElement, $parameters).";$( this ).dialog( 'close' );"); |
|
57 | 57 | } |
58 | 58 | } |
@@ -14,8 +14,9 @@ |
||
14 | 14 | class DialogButton extends BaseComponent { |
15 | 15 | |
16 | 16 | private function addFunction($jsCode) { |
17 | - if (! JString::startsWith($jsCode, "function")) |
|
18 | - $jsCode = "%function(){" . $jsCode . "}%"; |
|
17 | + if (! JString::startsWith($jsCode, "function")) { |
|
18 | + $jsCode = "%function(){" . $jsCode . "}%"; |
|
19 | + } |
|
19 | 20 | return $jsCode; |
20 | 21 | } |
21 | 22 |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | public function __construct(JsUtils $js) { |
16 | 16 | parent::__construct($js); |
17 | - $this->uiName = "buttonset"; |
|
17 | + $this->uiName="buttonset"; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class Position extends BaseComponent { |
13 | 13 | |
14 | - public function __construct($my = "left top", $at = "left bottom", $collision = "none", $within = "window") { |
|
14 | + public function __construct($my="left top", $at="left bottom", $collision="none", $within="window") { |
|
15 | 15 | $this->setParam("my", $my); |
16 | 16 | $this->setParam("at", $at); |
17 | 17 | $this->setParam("collision", $collision); |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | protected function setParamCtrl($key, $value, $typeCtrl) { |
85 | - if (! $typeCtrl($value)) { |
|
86 | - throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $key . " à la position"); |
|
85 | + if (!$typeCtrl($value)) { |
|
86 | + throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$key." à la position"); |
|
87 | 87 | } else |
88 | 88 | $this->setParam($key, $value); |
89 | 89 | } |
@@ -84,8 +84,9 @@ |
||
84 | 84 | protected function setParamCtrl($key, $value, $typeCtrl) { |
85 | 85 | if (! $typeCtrl($value)) { |
86 | 86 | throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $key . " à la position"); |
87 | - } else |
|
88 | - $this->setParam($key, $value); |
|
87 | + } else { |
|
88 | + $this->setParam($key, $value); |
|
89 | + } |
|
89 | 90 | } |
90 | 91 | |
91 | 92 | /* |
@@ -11,7 +11,7 @@ |
||
11 | 11 | */ |
12 | 12 | class Animation extends BaseComponent { |
13 | 13 | |
14 | - public function __construct($duration = 400, $easing = "swing", $queue = false) { |
|
14 | + public function __construct($duration=400, $easing="swing", $queue=false) { |
|
15 | 15 | $this->setDuration($duration); |
16 | 16 | $this->setEasing($easing); |
17 | 17 | $this->setQueue($queue); |
@@ -23,22 +23,22 @@ discard block |
||
23 | 23 | class HtmlSemDoubleElement extends HtmlDoubleElement { |
24 | 24 | use BaseTrait; |
25 | 25 | |
26 | - protected $_popup = NULL; |
|
26 | + protected $_popup=NULL; |
|
27 | 27 | |
28 | - protected $_dimmer = NULL; |
|
28 | + protected $_dimmer=NULL; |
|
29 | 29 | |
30 | - protected $_toast = NULL; |
|
30 | + protected $_toast=NULL; |
|
31 | 31 | |
32 | - protected $_sidebar = NULL; |
|
32 | + protected $_sidebar=NULL; |
|
33 | 33 | |
34 | - protected $_params = array(); |
|
34 | + protected $_params=array(); |
|
35 | 35 | |
36 | - public function __construct($identifier, $tagName = "p", $baseClass = "ui", $content = NULL) { |
|
36 | + public function __construct($identifier, $tagName="p", $baseClass="ui", $content=NULL) { |
|
37 | 37 | parent::__construct($identifier, $tagName); |
38 | - $this->_baseClass = $baseClass; |
|
38 | + $this->_baseClass=$baseClass; |
|
39 | 39 | $this->setClass($baseClass); |
40 | 40 | if (isset($content)) { |
41 | - $this->content = $content; |
|
41 | + $this->content=$content; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param string $variation |
49 | 49 | * @param string $popupEvent |
50 | 50 | */ |
51 | - public function setPopupAttributes($variation = NULL, $popupEvent = NULL) { |
|
51 | + public function setPopupAttributes($variation=NULL, $popupEvent=NULL) { |
|
52 | 52 | if (isset($this->_popup)) |
53 | 53 | $this->_popup->setAttributes($variation, $popupEvent); |
54 | 54 | } |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * @param array $params |
63 | 63 | * @return HtmlSemDoubleElement |
64 | 64 | */ |
65 | - public function addPopup($title = "", $content = "", $variation = NULL, $params = array()) { |
|
66 | - $this->_popup = new InternalPopup($this, $title, $content, $variation, $params); |
|
65 | + public function addPopup($title="", $content="", $variation=NULL, $params=array()) { |
|
66 | + $this->_popup=new InternalPopup($this, $title, $content, $variation, $params); |
|
67 | 67 | return $this; |
68 | 68 | } |
69 | 69 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * @param array $params |
76 | 76 | * @return HtmlSemDoubleElement |
77 | 77 | */ |
78 | - public function addPopupHtml($html = "", $variation = NULL, $params = array()) { |
|
79 | - $this->_popup = new InternalPopup($this); |
|
78 | + public function addPopupHtml($html="", $variation=NULL, $params=array()) { |
|
79 | + $this->_popup=new InternalPopup($this); |
|
80 | 80 | $this->_popup->setHtml($html); |
81 | 81 | $this->_popup->setAttributes($variation, $params); |
82 | 82 | return $this; |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | * @param mixed $content |
90 | 90 | * @return HtmlDimmer |
91 | 91 | */ |
92 | - public function addDimmer($params = array(), $content = NULL) { |
|
93 | - $dimmer = new HtmlDimmer("dimmer-" . $this->identifier, $content); |
|
92 | + public function addDimmer($params=array(), $content=NULL) { |
|
93 | + $dimmer=new HtmlDimmer("dimmer-".$this->identifier, $content); |
|
94 | 94 | $dimmer->setParams($params); |
95 | 95 | $dimmer->setContainer($this); |
96 | 96 | $this->addContent($dimmer); |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | * @param string $icon |
106 | 106 | * @return mixed|HtmlLabel |
107 | 107 | */ |
108 | - public function addLabel($label, $before = false, $icon = NULL) { |
|
109 | - $labelO = $label; |
|
110 | - if (\is_object($label) === false) { |
|
111 | - $labelO = new HtmlLabel("label-" . $this->identifier, $label); |
|
108 | + public function addLabel($label, $before=false, $icon=NULL) { |
|
109 | + $labelO=$label; |
|
110 | + if (\is_object($label)===false) { |
|
111 | + $labelO=new HtmlLabel("label-".$this->identifier, $label); |
|
112 | 112 | if (isset($icon)) |
113 | 113 | $labelO->addIcon($icon); |
114 | 114 | } else { |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * @param string $icon |
130 | 130 | * @return HtmlSemDoubleElement |
131 | 131 | */ |
132 | - public function attachLabel($label, $side = Side::TOP, $direction = Direction::NONE, $icon = NULL) { |
|
133 | - $label = $this->addLabel($label, true, $icon); |
|
132 | + public function attachLabel($label, $side=Side::TOP, $direction=Direction::NONE, $icon=NULL) { |
|
133 | + $label=$this->addLabel($label, true, $icon); |
|
134 | 134 | $label->setAttached($side, $direction); |
135 | 135 | return $this; |
136 | 136 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return HtmlSemDoubleElement |
142 | 142 | */ |
143 | - public function asLink($href = NULL, $target = NULL) { |
|
143 | + public function asLink($href=NULL, $target=NULL) { |
|
144 | 144 | if (isset($href)) |
145 | 145 | $this->setProperty("href", $href); |
146 | 146 | if (isset($target)) |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | * @param boolean $show |
155 | 155 | * @return string |
156 | 156 | */ |
157 | - public function jsShowDimmer($show = true) { |
|
158 | - $status = "hide"; |
|
159 | - if ($show === true) |
|
160 | - $status = "show"; |
|
161 | - return '$("#.' . $this->identifier . ').dimmer("' . $status . '");'; |
|
157 | + public function jsShowDimmer($show=true) { |
|
158 | + $status="hide"; |
|
159 | + if ($show===true) |
|
160 | + $status="show"; |
|
161 | + return '$("#.'.$this->identifier.').dimmer("'.$status.'");'; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * {@inheritdoc} |
167 | 167 | * @see BaseHtml::compile() |
168 | 168 | */ |
169 | - public function compile(JsUtils $js = NULL, &$view = NULL) { |
|
169 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
170 | 170 | if (isset($this->_popup)) { |
171 | 171 | $this->_popup->compile($js); |
172 | 172 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @see HtmlDoubleElement::run() |
180 | 180 | */ |
181 | 181 | public function run(JsUtils $js) { |
182 | - $this->_bsComponent = $js->semantic()->generic("#" . $this->identifier); |
|
182 | + $this->_bsComponent=$js->semantic()->generic("#".$this->identifier); |
|
183 | 183 | parent::run($js); |
184 | 184 | $this->addEventsOnRun($js); |
185 | 185 | if (isset($this->_popup)) { |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | * @param boolean $ordered |
198 | 198 | * @return \Ajax\common\html\html5\HtmlList |
199 | 199 | */ |
200 | - public function addList($items, $ordered = false) { |
|
201 | - $list = new HtmlList("list-" . $this->identifier, $items); |
|
200 | + public function addList($items, $ordered=false) { |
|
201 | + $list=new HtmlList("list-".$this->identifier, $items); |
|
202 | 202 | $list->setOrdered($ordered); |
203 | 203 | $list->setClass("ui list"); |
204 | 204 | $this->addContent($list); |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | * @param ?array $params |
211 | 211 | * @return \Ajax\semantic\components\Toast |
212 | 212 | */ |
213 | - public function asToast($params = NULL) { |
|
214 | - $this->_toast = new Toast(); |
|
215 | - $this->_toast->attach('#' . $this->_identifier); |
|
213 | + public function asToast($params=NULL) { |
|
214 | + $this->_toast=new Toast(); |
|
215 | + $this->_toast->attach('#'.$this->_identifier); |
|
216 | 216 | $this->setProperty('style', 'display:none;'); |
217 | 217 | if (isset($params)) { |
218 | 218 | $this->_toast->setParams($params); |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | * @param string $classes |
227 | 227 | * @return \Ajax\semantic\components\Sidebar |
228 | 228 | */ |
229 | - public function asSideBar($classes = '') { |
|
230 | - $this->_sidebar = new Sidebar(); |
|
229 | + public function asSideBar($classes='') { |
|
230 | + $this->_sidebar=new Sidebar(); |
|
231 | 231 | $this->addToProperty('class', 'sidebar'); |
232 | 232 | return $this->_sidebar; |
233 | 233 | } |
@@ -49,8 +49,9 @@ discard block |
||
49 | 49 | * @param string $popupEvent |
50 | 50 | */ |
51 | 51 | public function setPopupAttributes($variation = NULL, $popupEvent = NULL) { |
52 | - if (isset($this->_popup)) |
|
53 | - $this->_popup->setAttributes($variation, $popupEvent); |
|
52 | + if (isset($this->_popup)) { |
|
53 | + $this->_popup->setAttributes($variation, $popupEvent); |
|
54 | + } |
|
54 | 55 | } |
55 | 56 | |
56 | 57 | /** |
@@ -109,8 +110,9 @@ discard block |
||
109 | 110 | $labelO = $label; |
110 | 111 | if (\is_object($label) === false) { |
111 | 112 | $labelO = new HtmlLabel("label-" . $this->identifier, $label); |
112 | - if (isset($icon)) |
|
113 | - $labelO->addIcon($icon); |
|
113 | + if (isset($icon)) { |
|
114 | + $labelO->addIcon($icon); |
|
115 | + } |
|
114 | 116 | } else { |
115 | 117 | $labelO->addToPropertyCtrl("class", "label", array( |
116 | 118 | "label" |
@@ -141,10 +143,12 @@ discard block |
||
141 | 143 | * @return HtmlSemDoubleElement |
142 | 144 | */ |
143 | 145 | public function asLink($href = NULL, $target = NULL) { |
144 | - if (isset($href)) |
|
145 | - $this->setProperty("href", $href); |
|
146 | - if (isset($target)) |
|
147 | - $this->setProperty("target", $target); |
|
146 | + if (isset($href)) { |
|
147 | + $this->setProperty("href", $href); |
|
148 | + } |
|
149 | + if (isset($target)) { |
|
150 | + $this->setProperty("target", $target); |
|
151 | + } |
|
148 | 152 | return $this->setTagName("a"); |
149 | 153 | } |
150 | 154 | |
@@ -156,8 +160,9 @@ discard block |
||
156 | 160 | */ |
157 | 161 | public function jsShowDimmer($show = true) { |
158 | 162 | $status = "hide"; |
159 | - if ($show === true) |
|
160 | - $status = "show"; |
|
163 | + if ($show === true) { |
|
164 | + $status = "show"; |
|
165 | + } |
|
161 | 166 | return '$("#.' . $this->identifier . ').dimmer("' . $status . '");'; |
162 | 167 | } |
163 | 168 |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class Sidebar extends SimpleSemExtComponent { |
16 | 16 | |
17 | - public function __construct(JsUtils $js = NULL) { |
|
17 | + public function __construct(JsUtils $js=NULL) { |
|
18 | 18 | parent::__construct($js); |
19 | - $this->uiName = 'sidebar'; |
|
19 | + $this->uiName='sidebar'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function show() { |
@@ -46,32 +46,32 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | public function setContext($value) { |
49 | - $this->params['context'] = $value; |
|
49 | + $this->params['context']=$value; |
|
50 | 50 | return $this; |
51 | 51 | } |
52 | 52 | |
53 | - public function setExclusive($value = true) { |
|
54 | - $this->params['exclusive'] = true; |
|
53 | + public function setExclusive($value=true) { |
|
54 | + $this->params['exclusive']=true; |
|
55 | 55 | return $this; |
56 | 56 | } |
57 | 57 | |
58 | - public function setClosable($value = true) { |
|
59 | - $this->params['closable'] = $value; |
|
58 | + public function setClosable($value=true) { |
|
59 | + $this->params['closable']=$value; |
|
60 | 60 | return $this; |
61 | 61 | } |
62 | 62 | |
63 | - public function setDimPage($value = true) { |
|
64 | - $this->params['dimPage'] = $value; |
|
63 | + public function setDimPage($value=true) { |
|
64 | + $this->params['dimPage']=$value; |
|
65 | 65 | return $this; |
66 | 66 | } |
67 | 67 | |
68 | - public function setScrollLock($value = false) { |
|
69 | - $this->params['scrollLock'] = $value; |
|
68 | + public function setScrollLock($value=false) { |
|
69 | + $this->params['scrollLock']=$value; |
|
70 | 70 | return $this; |
71 | 71 | } |
72 | 72 | |
73 | - public function setReturnScroll($value = false) { |
|
74 | - $this->params['returnScroll'] = $value; |
|
73 | + public function setReturnScroll($value=false) { |
|
74 | + $this->params['returnScroll']=$value; |
|
75 | 75 | return $this; |
76 | 76 | } |
77 | 77 |
@@ -10,50 +10,50 @@ discard block |
||
10 | 10 | private $parameters; |
11 | 11 | |
12 | 12 | public function __construct($method, $parameters) { |
13 | - $this->method = $method; |
|
14 | - $this->parameters = $parameters; |
|
13 | + $this->method=$method; |
|
14 | + $this->parameters=$parameters; |
|
15 | 15 | } |
16 | 16 | |
17 | - public function compile(JsUtils $js = null) { |
|
18 | - if ($js === null) |
|
17 | + public function compile(JsUtils $js=null) { |
|
18 | + if ($js===null) |
|
19 | 19 | return; |
20 | - $params = "{}"; |
|
21 | - $stopPropagation = true; |
|
22 | - $preventDefault = true; |
|
23 | - $method = "get"; |
|
24 | - $this->parameters["immediatly"] = false; |
|
20 | + $params="{}"; |
|
21 | + $stopPropagation=true; |
|
22 | + $preventDefault=true; |
|
23 | + $method="get"; |
|
24 | + $this->parameters["immediatly"]=false; |
|
25 | 25 | extract($this->parameters); |
26 | - $result = $this->_eventPreparing($preventDefault, $stopPropagation); |
|
26 | + $result=$this->_eventPreparing($preventDefault, $stopPropagation); |
|
27 | 27 | switch ($this->method) { |
28 | 28 | case "get": |
29 | - $result .= $js->getDeferred($url, $responseElement, $this->parameters); |
|
29 | + $result.=$js->getDeferred($url, $responseElement, $this->parameters); |
|
30 | 30 | break; |
31 | 31 | case "post": |
32 | - $result .= $js->postDeferred($url, $params, $responseElement, $this->parameters); |
|
32 | + $result.=$js->postDeferred($url, $params, $responseElement, $this->parameters); |
|
33 | 33 | break; |
34 | 34 | case "postForm": |
35 | - $result .= $js->postFormDeferred($url, $form, $responseElement, $this->parameters); |
|
35 | + $result.=$js->postFormDeferred($url, $form, $responseElement, $this->parameters); |
|
36 | 36 | break; |
37 | 37 | case "json": |
38 | - $result .= $js->jsonDeferred($url, $method, $this->parameters); |
|
38 | + $result.=$js->jsonDeferred($url, $method, $this->parameters); |
|
39 | 39 | break; |
40 | 40 | case "jsonArray": |
41 | - $result .= $js->jsonArrayDeferred($modelSelector, $url, $method, $this->parameters); |
|
41 | + $result.=$js->jsonArrayDeferred($modelSelector, $url, $method, $this->parameters); |
|
42 | 42 | break; |
43 | 43 | default: |
44 | - $result .= $js->ajaxDeferred($this->method, $url, $responseElement, $this->parameters); |
|
44 | + $result.=$js->ajaxDeferred($this->method, $url, $responseElement, $this->parameters); |
|
45 | 45 | break; |
46 | 46 | } |
47 | 47 | return $result; |
48 | 48 | } |
49 | 49 | |
50 | 50 | protected function _eventPreparing($preventDefault, $stopPropagation) { |
51 | - $result = ""; |
|
52 | - if ($preventDefault === true) { |
|
53 | - $result .= Javascript::$preventDefault; |
|
51 | + $result=""; |
|
52 | + if ($preventDefault===true) { |
|
53 | + $result.=Javascript::$preventDefault; |
|
54 | 54 | } |
55 | - if ($stopPropagation === true) { |
|
56 | - $result .= Javascript::$stopPropagation; |
|
55 | + if ($stopPropagation===true) { |
|
56 | + $result.=Javascript::$stopPropagation; |
|
57 | 57 | } |
58 | 58 | return $result; |
59 | 59 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | public function setMethod($method) { |
66 | - $this->method = $method; |
|
66 | + $this->method=$method; |
|
67 | 67 | return $this; |
68 | 68 | } |
69 | 69 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | public function setParameters($parameters) { |
75 | - $this->parameters = $parameters; |
|
75 | + $this->parameters=$parameters; |
|
76 | 76 | return $this; |
77 | 77 | } |
78 | 78 | } |
@@ -15,8 +15,9 @@ |
||
15 | 15 | } |
16 | 16 | |
17 | 17 | public function compile(JsUtils $js = null) { |
18 | - if ($js === null) |
|
19 | - return; |
|
18 | + if ($js === null) { |
|
19 | + return; |
|
20 | + } |
|
20 | 21 | $params = "{}"; |
21 | 22 | $stopPropagation = true; |
22 | 23 | $preventDefault = true; |
@@ -126,8 +126,9 @@ discard block |
||
126 | 126 | public function fieldAsLabel($index, $icon = NULL, $attributes = NULL) { |
127 | 127 | return $this->_fieldAs(function ($id, $name, $value) use ($icon) { |
128 | 128 | $lbl = new HtmlLabel($id, $value); |
129 | - if (isset($icon)) |
|
130 | - $lbl->addIcon($icon); |
|
129 | + if (isset($icon)) { |
|
130 | + $lbl->addIcon($icon); |
|
131 | + } |
|
131 | 132 | return $lbl; |
132 | 133 | }, $index, $attributes, "label"); |
133 | 134 | } |
@@ -135,8 +136,9 @@ discard block |
||
135 | 136 | public function fieldAsHeader($index, $niveau = 1, $icon = NULL, $attributes = NULL) { |
136 | 137 | return $this->_fieldAs(function ($id, $name, $value) use ($niveau, $icon) { |
137 | 138 | $header = new HtmlHeader($id, $niveau, $value); |
138 | - if (isset($icon)) |
|
139 | - $header->asIcon($icon, $value); |
|
139 | + if (isset($icon)) { |
|
140 | + $header->asIcon($icon, $value); |
|
141 | + } |
|
140 | 142 | return $header; |
141 | 143 | }, $index, $attributes, "header"); |
142 | 144 | } |
@@ -145,8 +147,9 @@ discard block |
||
145 | 147 | $this->setValueFunction($index, function ($img) use ($size, $circular) { |
146 | 148 | $image = new HtmlImage($this->_getFieldIdentifier("image"), $img); |
147 | 149 | $image->setSize($size); |
148 | - if ($circular) |
|
149 | - $image->setCircular(); |
|
150 | + if ($circular) { |
|
151 | + $image->setCircular(); |
|
152 | + } |
|
150 | 153 | return $image; |
151 | 154 | }); |
152 | 155 | return $this; |
@@ -251,8 +254,9 @@ discard block |
||
251 | 254 | |
252 | 255 | public function fieldAsCheckbox($index, $attributes = NULL) { |
253 | 256 | return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
254 | - if ($caption === null || $caption === "") |
|
255 | - $caption = ""; |
|
257 | + if ($caption === null || $caption === "") { |
|
258 | + $caption = ""; |
|
259 | + } |
|
256 | 260 | $input = new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
257 | 261 | $input->setChecked(JString::isBooleanTrue($value)); |
258 | 262 | return $this->_prepareFormFields($input, $name, $attributes); |
@@ -292,9 +296,9 @@ discard block |
||
292 | 296 | $i = 0; |
293 | 297 | if (JArray::isAssociative($types)) { |
294 | 298 | foreach ($types as $type => $attributes) { |
295 | - if (\is_int($type)) |
|
296 | - $this->fieldAs($i ++, $attributes, []); |
|
297 | - else { |
|
299 | + if (\is_int($type)) { |
|
300 | + $this->fieldAs($i ++, $attributes, []); |
|
301 | + } else { |
|
298 | 302 | $type = preg_replace('/\d/', '', $type); |
299 | 303 | $this->fieldAs($i ++, $type, $attributes); |
300 | 304 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | trait FieldAsTrait { |
39 | 39 | |
40 | - abstract protected function _getFieldIdentifier($prefix, $name = ""); |
|
40 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
41 | 41 | |
42 | 42 | abstract public function setValueFunction($index, $callback); |
43 | 43 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | abstract protected function _getFieldCaption($index); |
47 | 47 | |
48 | - abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement = NULL, $parameters = NULL); |
|
48 | + abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
49 | 49 | |
50 | 50 | private $_speProperties; |
51 | 51 | |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * @param HtmlFormField $element |
55 | 55 | * @param array $attributes |
56 | 56 | */ |
57 | - protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance = null) { |
|
57 | + protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance=null) { |
|
58 | 58 | if (isset($attributes["jsCallback"])) { |
59 | - $callback = $attributes["jsCallback"]; |
|
59 | + $callback=$attributes["jsCallback"]; |
|
60 | 60 | if (\is_callable($callback)) { |
61 | 61 | $callback($element, $instance, $index, InstanceViewer::$index); |
62 | 62 | } |
@@ -67,15 +67,15 @@ discard block |
||
67 | 67 | $element->fromArray($attributes); |
68 | 68 | } |
69 | 69 | |
70 | - private function _getLabelField($caption, $icon = NULL) { |
|
71 | - $label = new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
70 | + private function _getLabelField($caption, $icon=NULL) { |
|
71 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
72 | 72 | return $label; |
73 | 73 | } |
74 | 74 | |
75 | 75 | protected function _addRules(HtmlFormField $element, &$attributes) { |
76 | 76 | if (isset($attributes["rules"])) { |
77 | - $this->_hasRules = true; |
|
78 | - $rules = $attributes["rules"]; |
|
77 | + $this->_hasRules=true; |
|
78 | + $rules=$attributes["rules"]; |
|
79 | 79 | if (\is_array($rules)) { |
80 | 80 | $element->addRules($rules); |
81 | 81 | } else { |
@@ -91,24 +91,24 @@ discard block |
||
91 | 91 | return $field; |
92 | 92 | } |
93 | 93 | |
94 | - protected function _fieldAs($elementCallback, &$index, $attributes = NULL, $prefix = null) { |
|
95 | - $this->setValueFunction($index, function ($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix) { |
|
96 | - $caption = $this->_getFieldCaption($index); |
|
97 | - $name = $this->_getFieldName($index); |
|
98 | - $id = $this->_getFieldIdentifier($prefix, $name); |
|
94 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
95 | + $this->setValueFunction($index, function($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix) { |
|
96 | + $caption=$this->_getFieldCaption($index); |
|
97 | + $name=$this->_getFieldName($index); |
|
98 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
99 | 99 | if (isset($attributes["name"])) { |
100 | - $name = $attributes["name"]; |
|
100 | + $name=$attributes["name"]; |
|
101 | 101 | unset($attributes["name"]); |
102 | 102 | } |
103 | - $element = $elementCallback($id, $name, $value, $caption); |
|
103 | + $element=$elementCallback($id, $name, $value, $caption); |
|
104 | 104 | if (isset($this->_speProperties[$index])) { |
105 | 105 | $attributes ??= []; |
106 | - $attributes += $this->_speProperties[$index]; |
|
106 | + $attributes+=$this->_speProperties[$index]; |
|
107 | 107 | } |
108 | 108 | if (\is_array($attributes)) { |
109 | 109 | $this->_applyAttributes($element, $attributes, $index, $instance); |
110 | 110 | } |
111 | - $element->setDisabled(! $this->_edition); |
|
111 | + $element->setDisabled(!$this->_edition); |
|
112 | 112 | return $element; |
113 | 113 | }); |
114 | 114 | return $this; |
@@ -124,48 +124,48 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function setPropertyValues($property, $indexValues) { |
126 | 126 | foreach ($indexValues as $index => $value) { |
127 | - $ind = $this->_getIndex($index); |
|
128 | - $this->_speProperties[$ind][$property] = $value; |
|
127 | + $ind=$this->_getIndex($index); |
|
128 | + $this->_speProperties[$ind][$property]=$value; |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | - public function fieldAsProgress($index, $label = NULL, $attributes = array()) { |
|
133 | - $this->setValueFunction($index, function ($value) use ($label, $attributes) { |
|
134 | - $pb = new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
132 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
133 | + $this->setValueFunction($index, function($value) use ($label, $attributes) { |
|
134 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
135 | 135 | return $pb; |
136 | 136 | }); |
137 | 137 | return $this; |
138 | 138 | } |
139 | 139 | |
140 | - public function fieldAsRating($index, $max = 5, $icon = "") { |
|
141 | - $this->setValueFunction($index, function ($value) use ($max, $icon) { |
|
142 | - $rating = new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
140 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
141 | + $this->setValueFunction($index, function($value) use ($max, $icon) { |
|
142 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
143 | 143 | return $rating; |
144 | 144 | }); |
145 | 145 | return $this; |
146 | 146 | } |
147 | 147 | |
148 | - public function fieldAsLabel($index, $icon = NULL, $attributes = NULL) { |
|
149 | - return $this->_fieldAs(function ($id, $name, $value) use ($icon) { |
|
150 | - $lbl = new HtmlLabel($id, $value); |
|
148 | + public function fieldAsLabel($index, $icon=NULL, $attributes=NULL) { |
|
149 | + return $this->_fieldAs(function($id, $name, $value) use ($icon) { |
|
150 | + $lbl=new HtmlLabel($id, $value); |
|
151 | 151 | if (isset($icon)) |
152 | 152 | $lbl->addIcon($icon); |
153 | 153 | return $lbl; |
154 | 154 | }, $index, $attributes, "label"); |
155 | 155 | } |
156 | 156 | |
157 | - public function fieldAsHeader($index, $niveau = 1, $icon = NULL, $attributes = NULL) { |
|
158 | - return $this->_fieldAs(function ($id, $name, $value) use ($niveau, $icon) { |
|
159 | - $header = new HtmlHeader($id, $niveau, $value); |
|
157 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
158 | + return $this->_fieldAs(function($id, $name, $value) use ($niveau, $icon) { |
|
159 | + $header=new HtmlHeader($id, $niveau, $value); |
|
160 | 160 | if (isset($icon)) |
161 | 161 | $header->asIcon($icon, $value); |
162 | 162 | return $header; |
163 | 163 | }, $index, $attributes, "header"); |
164 | 164 | } |
165 | 165 | |
166 | - public function fieldAsImage($index, $size = Size::MINI, $circular = false) { |
|
167 | - $this->setValueFunction($index, function ($img) use ($size, $circular) { |
|
168 | - $image = new HtmlImage($this->_getFieldIdentifier("image"), $img); |
|
166 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
167 | + $this->setValueFunction($index, function($img) use ($size, $circular) { |
|
168 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); |
|
169 | 169 | $image->setSize($size); |
170 | 170 | if ($circular) |
171 | 171 | $image->setCircular(); |
@@ -175,65 +175,65 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | public function fieldAsFlag($index) { |
178 | - $this->setValueFunction($index, function ($flag) { |
|
179 | - $flag = new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
178 | + $this->setValueFunction($index, function($flag) { |
|
179 | + $flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
180 | 180 | return $flag; |
181 | 181 | }); |
182 | 182 | return $this; |
183 | 183 | } |
184 | 184 | |
185 | 185 | public function fieldAsIcon($index) { |
186 | - $this->setValueFunction($index, function ($icon) { |
|
187 | - $icon = new HtmlIcon($this->_getFieldIdentifier("icon"), $icon); |
|
186 | + $this->setValueFunction($index, function($icon) { |
|
187 | + $icon=new HtmlIcon($this->_getFieldIdentifier("icon"), $icon); |
|
188 | 188 | return $icon; |
189 | 189 | }); |
190 | 190 | return $this; |
191 | 191 | } |
192 | 192 | |
193 | - public function fieldAsAvatar($index, $attributes = NULL) { |
|
194 | - return $this->_fieldAs(function ($id, $name, $value) { |
|
195 | - $img = new HtmlImage($id, $value); |
|
193 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
194 | + return $this->_fieldAs(function($id, $name, $value) { |
|
195 | + $img=new HtmlImage($id, $value); |
|
196 | 196 | $img->asAvatar(); |
197 | 197 | return $img; |
198 | 198 | }, $index, $attributes, "avatar"); |
199 | 199 | } |
200 | 200 | |
201 | - public function fieldAsRadio($index, $attributes = NULL) { |
|
202 | - return $this->_fieldAs(function ($id, $name, $value) use ($attributes) { |
|
203 | - $input = new HtmlFormRadio($id, $name, $value, $value); |
|
201 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
202 | + return $this->_fieldAs(function($id, $name, $value) use ($attributes) { |
|
203 | + $input=new HtmlFormRadio($id, $name, $value, $value); |
|
204 | 204 | return $this->_prepareFormFields($input, $name, $attributes); |
205 | 205 | }, $index, $attributes, "radio"); |
206 | 206 | } |
207 | 207 | |
208 | - public function fieldAsRadios($index, $elements = [], $attributes = NULL) { |
|
209 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($elements) { |
|
208 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
209 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements) { |
|
210 | 210 | return HtmlFormFields::radios($name, $elements, $caption, $value); |
211 | 211 | }, $index, $attributes, "radios"); |
212 | 212 | } |
213 | 213 | |
214 | - public function fieldAsList($index, $classNames = "", $attributes = NULL) { |
|
215 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($classNames) { |
|
216 | - $result = new HtmlList($name, $value); |
|
214 | + public function fieldAsList($index, $classNames="", $attributes=NULL) { |
|
215 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($classNames) { |
|
216 | + $result=new HtmlList($name, $value); |
|
217 | 217 | $result->addClass($classNames); |
218 | 218 | return $result; |
219 | 219 | }, $index, $attributes, "list"); |
220 | 220 | } |
221 | 221 | |
222 | - public function fieldAsInput($index, $attributes = NULL) { |
|
223 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
224 | - $input = new HtmlFormInput($id, $caption, "text", $value); |
|
222 | + public function fieldAsInput($index, $attributes=NULL) { |
|
223 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
224 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
225 | 225 | return $this->_prepareFormFields($input, $name, $attributes); |
226 | 226 | }, $index, $attributes, "input"); |
227 | 227 | } |
228 | 228 | |
229 | - public function fieldAsLabeledInput($index, $attributes = NULL) { |
|
230 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
231 | - $input = new HtmlFormInput($id, '', 'text', $value, $caption); |
|
232 | - $required = ''; |
|
229 | + public function fieldAsLabeledInput($index, $attributes=NULL) { |
|
230 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
231 | + $input=new HtmlFormInput($id, '', 'text', $value, $caption); |
|
232 | + $required=''; |
|
233 | 233 | if (isset($attributes['rules'])) { |
234 | - $rules = json_encode($attributes['rules']); |
|
235 | - if (strpos($rules, 'empty') !== false) { |
|
236 | - $required = 'required'; |
|
234 | + $rules=json_encode($attributes['rules']); |
|
235 | + if (strpos($rules, 'empty')!==false) { |
|
236 | + $required='required'; |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | $input->getField() |
@@ -244,80 +244,80 @@ discard block |
||
244 | 244 | }, $index, $attributes, 'input'); |
245 | 245 | } |
246 | 246 | |
247 | - public function fieldAsDataList($index, ?array $items = [], $attributes = NULL) { |
|
248 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes, $items) { |
|
249 | - $input = new HtmlFormInput($id, $caption, "text", $value); |
|
247 | + public function fieldAsDataList($index, ?array $items=[], $attributes=NULL) { |
|
248 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $items) { |
|
249 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
250 | 250 | $input->getField() |
251 | 251 | ->addDataList($items); |
252 | 252 | return $this->_prepareFormFields($input, $name, $attributes); |
253 | 253 | }, $index, $attributes, "input"); |
254 | 254 | } |
255 | 255 | |
256 | - public function fieldAsFile($index, $attributes = NULL) { |
|
256 | + public function fieldAsFile($index, $attributes=NULL) { |
|
257 | 257 | if (isset($this->_form)) { |
258 | 258 | $this->_form->setProperty('enctype', 'multipart/form-data'); |
259 | 259 | } |
260 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
261 | - $input = new HtmlFormInput($id, $caption); |
|
260 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
261 | + $input=new HtmlFormInput($id, $caption); |
|
262 | 262 | $input->asFile(); |
263 | 263 | return $this->_prepareFormFields($input, $name, $attributes); |
264 | 264 | }, $index, $attributes, "input"); |
265 | 265 | } |
266 | 266 | |
267 | - public function fieldAsTextarea($index, $attributes = NULL) { |
|
268 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
269 | - $textarea = new HtmlFormTextarea($id, $caption, $value); |
|
267 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
268 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
269 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
270 | 270 | return $this->_prepareFormFields($textarea, $name, $attributes); |
271 | 271 | }, $index, $attributes, "textarea"); |
272 | 272 | } |
273 | 273 | |
274 | - public function fieldAsElement($index, $tagName = "div", $baseClass = "", $attributes = NULL) { |
|
275 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass) { |
|
276 | - $div = new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
274 | + public function fieldAsElement($index, $tagName="div", $baseClass="", $attributes=NULL) { |
|
275 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass) { |
|
276 | + $div=new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
277 | 277 | $div->setContent(\htmlentities($value)); |
278 | - $textarea = new HtmlFormField("field-" . $id, $div, $caption); |
|
278 | + $textarea=new HtmlFormField("field-".$id, $div, $caption); |
|
279 | 279 | return $this->_prepareFormFields($textarea, $name, $attributes); |
280 | 280 | }, $index, $attributes, "element"); |
281 | 281 | } |
282 | 282 | |
283 | - public function fieldAsHidden($index, $attributes = NULL) { |
|
284 | - if (! \is_array($attributes)) { |
|
285 | - $attributes = []; |
|
283 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
284 | + if (!\is_array($attributes)) { |
|
285 | + $attributes=[]; |
|
286 | 286 | } |
287 | - $attributes["inputType"] = "hidden"; |
|
288 | - $attributes["style"] = "display:none;"; |
|
287 | + $attributes["inputType"]="hidden"; |
|
288 | + $attributes["style"]="display:none;"; |
|
289 | 289 | return $this->fieldAsInput($index, $attributes); |
290 | 290 | } |
291 | 291 | |
292 | - public function fieldAsCheckbox($index, $attributes = NULL) { |
|
293 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
294 | - if ($caption === null || $caption === "") |
|
295 | - $caption = ""; |
|
296 | - $input = new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
292 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
293 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
294 | + if ($caption===null || $caption==="") |
|
295 | + $caption=""; |
|
296 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
297 | 297 | $input->setChecked(JString::isBooleanTrue($value)); |
298 | 298 | return $this->_prepareFormFields($input, $name, $attributes); |
299 | 299 | }, $index, $attributes, "ck"); |
300 | 300 | } |
301 | 301 | |
302 | - public function fieldAsDropDown($index, $elements = [], $multiple = false, $attributes = NULL) { |
|
303 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($elements, $multiple, $attributes) { |
|
304 | - $dd = new HtmlFormDropdown($id, $elements, $caption, $value ?? ''); |
|
302 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
303 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements, $multiple, $attributes) { |
|
304 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value ?? ''); |
|
305 | 305 | $dd->asSelect($name, $multiple); |
306 | 306 | return $this->_prepareFormFields($dd, $name, $attributes); |
307 | 307 | }, $index, $attributes, "dd"); |
308 | 308 | } |
309 | 309 | |
310 | - public function fieldAsMessage($index, $attributes = NULL) { |
|
311 | - return $this->_fieldAs(function ($id, $name, $value, $caption) { |
|
312 | - $mess = new HtmlMessage("message-" . $id, $caption); |
|
310 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
311 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
312 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
313 | 313 | $mess->addHeader($value); |
314 | 314 | return $mess; |
315 | 315 | }, $index, $attributes, "message"); |
316 | 316 | } |
317 | 317 | |
318 | - public function fieldAsLink($index, $attributes = NULL) { |
|
319 | - return $this->_fieldAs(function ($id, $name, $value, $caption) { |
|
320 | - $lnk = new HtmlLink("message-" . $id, "#", $caption); |
|
318 | + public function fieldAsLink($index, $attributes=NULL) { |
|
319 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
320 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
321 | 321 | return $lnk; |
322 | 322 | }, $index, $attributes, "link"); |
323 | 323 | } |
@@ -329,28 +329,28 @@ discard block |
||
329 | 329 | * an array or associative array $type=>$attributes |
330 | 330 | */ |
331 | 331 | public function fieldsAs(array $types) { |
332 | - $i = 0; |
|
332 | + $i=0; |
|
333 | 333 | if (JArray::isAssociative($types)) { |
334 | 334 | foreach ($types as $type => $attributes) { |
335 | 335 | if (\is_int($type)) |
336 | - $this->fieldAs($i ++, $attributes, []); |
|
336 | + $this->fieldAs($i++, $attributes, []); |
|
337 | 337 | else { |
338 | - $type = preg_replace('/\d/', '', $type); |
|
339 | - $this->fieldAs($i ++, $type, $attributes); |
|
338 | + $type=preg_replace('/\d/', '', $type); |
|
339 | + $this->fieldAs($i++, $type, $attributes); |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | } else { |
343 | 343 | foreach ($types as $type) { |
344 | - $this->fieldAs($i ++, $type); |
|
344 | + $this->fieldAs($i++, $type); |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | } |
348 | 348 | |
349 | - public function fieldAs($index, $type, $attributes = NULL) { |
|
350 | - $method = "fieldAs" . \ucfirst($type); |
|
349 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
350 | + $method="fieldAs".\ucfirst($type); |
|
351 | 351 | if (\method_exists($this, $method)) { |
352 | - if (! \is_array($attributes)) { |
|
353 | - $attributes = [ |
|
352 | + if (!\is_array($attributes)) { |
|
353 | + $attributes=[ |
|
354 | 354 | $index |
355 | 355 | ]; |
356 | 356 | } else { |
@@ -363,39 +363,39 @@ discard block |
||
363 | 363 | } |
364 | 364 | } |
365 | 365 | |
366 | - public function fieldAsSubmit($index, $cssStyle = NULL, $url = NULL, $responseElement = NULL, $attributes = NULL) { |
|
367 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes) { |
|
368 | - $button = new HtmlButton($id, $caption, $cssStyle); |
|
366 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
367 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes) { |
|
368 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
369 | 369 | $this->_buttonAsSubmit($button, "click", $url, $responseElement, $attributes["ajax"] ?? []); |
370 | 370 | return $button; |
371 | 371 | }, $index, $attributes, "submit"); |
372 | 372 | } |
373 | 373 | |
374 | - public function fieldAsButton($index, $cssStyle = NULL, $attributes = NULL) { |
|
375 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($cssStyle) { |
|
376 | - $button = new HtmlButton($id, $value, $cssStyle); |
|
374 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
375 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle) { |
|
376 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
377 | 377 | return $button; |
378 | 378 | }, $index, $attributes, "button"); |
379 | 379 | } |
380 | 380 | |
381 | - public function fieldAsDataTable($index, $model, $instances = null, $fields = [], $attributes = NULL) { |
|
382 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($model, $instances, $fields, $index) { |
|
383 | - $dt = new DataTable($id, $model, $instances); |
|
381 | + public function fieldAsDataTable($index, $model, $instances=null, $fields=[], $attributes=NULL) { |
|
382 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($model, $instances, $fields, $index) { |
|
383 | + $dt=new DataTable($id, $model, $instances); |
|
384 | 384 | $dt->setNamePrefix($index); |
385 | 385 | $dt->setFields($fields); |
386 | 386 | $dt->setEdition(true); |
387 | - $dt->addDeleteButton(false, [], function ($bt) use ($index) { |
|
387 | + $dt->addDeleteButton(false, [], function($bt) use ($index) { |
|
388 | 388 | $bt->addClass('mini circular') |
389 | - ->wrap('<input value="" class="_status" type="hidden" name="' . $index . '._status[]">'); |
|
389 | + ->wrap('<input value="" class="_status" type="hidden" name="'.$index.'._status[]">'); |
|
390 | 390 | }); |
391 | - if ($caption != null) { |
|
391 | + if ($caption!=null) { |
|
392 | 392 | $dt->setFormCaption($caption); |
393 | 393 | } |
394 | - $dt->onPreCompile(function () use (&$dt) { |
|
394 | + $dt->onPreCompile(function() use (&$dt) { |
|
395 | 395 | $dt->getHtmlComponent() |
396 | 396 | ->colRightFromRight(0); |
397 | 397 | }); |
398 | - $dt->wrap('<input type="hidden" name="' . $index . '">'); |
|
398 | + $dt->wrap('<input type="hidden" name="'.$index.'">'); |
|
399 | 399 | return $dt; |
400 | 400 | }, $index, $attributes, "dataTable"); |
401 | 401 | } |