@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | * @param string $action one of "select","auto","activate","combo","nothing","hide" |
18 | 18 | * @return \Ajax\semantic\components\Dropdown |
19 | 19 | */ |
20 | - public function setAction($action){ |
|
21 | - return $this->setParamCtrl("action", $action,array("select","auto","activate","combo","nothing","hide")); |
|
20 | + public function setAction($action) { |
|
21 | + return $this->setParamCtrl("action", $action, array("select", "auto", "activate", "combo", "nothing", "hide")); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | * @param string $event Event used to trigger dropdown (Hover, Click, Custom Event) |
27 | 27 | * @return \Ajax\semantic\components\Dropdown |
28 | 28 | */ |
29 | - public function setOn($event){ |
|
29 | + public function setOn($event) { |
|
30 | 30 | return $this->setParam("on", $event); |
31 | 31 | } |
32 | 32 | |
33 | - public function setFullTextSearch($value){ |
|
33 | + public function setFullTextSearch($value) { |
|
34 | 34 | return $this->setParam("fullTextSearch", $value); |
35 | 35 | } |
36 | 36 | |
37 | - public function setShowOnFocus($value){ |
|
37 | + public function setShowOnFocus($value) { |
|
38 | 38 | return $this->setParam("showOnFocus", $value); |
39 | 39 | } |
40 | 40 | } |
@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | trait JsUtilsEventsTrait { |
12 | 12 | |
13 | 13 | |
14 | - protected $jquery_events=array ( |
|
15 | - "bind","blur","change","click","dblclick","delegate","die","error","focus","focusin","focusout","hover","keydown","keypress","keyup","live","load","mousedown","mousseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","off","on","one","ready","resize","scroll","select","submit","toggle","trigger","triggerHandler","undind","undelegate","unload" |
|
14 | + protected $jquery_events=array( |
|
15 | + "bind", "blur", "change", "click", "dblclick", "delegate", "die", "error", "focus", "focusin", "focusout", "hover", "keydown", "keypress", "keyup", "live", "load", "mousedown", "mousseenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "off", "on", "one", "ready", "resize", "scroll", "select", "submit", "toggle", "trigger", "triggerHandler", "undind", "undelegate", "unload" |
|
16 | 16 | ); |
17 | 17 | |
18 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
18 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Outputs a javascript library blur event |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * @param boolean $stopPropagation |
38 | 38 | * @return string |
39 | 39 | */ |
40 | - public function change($element='this', $js='',$preventDefault=false,$stopPropagation=false) { |
|
41 | - return $this->_add_event($element, $js, 'change',$preventDefault,$stopPropagation); |
|
40 | + public function change($element='this', $js='', $preventDefault=false, $stopPropagation=false) { |
|
41 | + return $this->_add_event($element, $js, 'change', $preventDefault, $stopPropagation); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | * @param boolean $stopPropagation |
52 | 52 | * @return string |
53 | 53 | */ |
54 | - public function click($element='this', $js='', $ret_false=TRUE,$preventDefault=false,$stopPropagation=false) { |
|
54 | + public function click($element='this', $js='', $ret_false=TRUE, $preventDefault=false, $stopPropagation=false) { |
|
55 | 55 | if (!is_array($js)) { |
56 | - $js=array ( |
|
56 | + $js=array( |
|
57 | 57 | $js |
58 | 58 | ); |
59 | 59 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $js[]="return false;"; |
63 | 63 | } |
64 | 64 | |
65 | - return $this->_add_event($element, $js, 'click',$preventDefault,$stopPropagation); |
|
65 | + return $this->_add_event($element, $js, 'click', $preventDefault, $stopPropagation); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @version 1.001 |
9 | 9 | * Generates a JSON Rule for the validation of a field |
10 | 10 | */ |
11 | -class Rule implements \JsonSerializable{ |
|
11 | +class Rule implements \JsonSerializable { |
|
12 | 12 | /** |
13 | 13 | * @var string |
14 | 14 | */ |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | private $value; |
25 | 25 | |
26 | - public function __construct($type,$prompt=NULL,$value=NULL){ |
|
26 | + public function __construct($type, $prompt=NULL, $value=NULL) { |
|
27 | 27 | $this->type=$type; |
28 | 28 | $this->prompt=$prompt; |
29 | 29 | $this->value=$value; |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | public function jsonSerialize() { |
60 | - $result= ["type"=>$this->type]; |
|
61 | - if(isset($this->prompt)) |
|
60 | + $result=["type"=>$this->type]; |
|
61 | + if (isset($this->prompt)) |
|
62 | 62 | $result["prompt"]=$this->prompt; |
63 | - if(isset($this->value)) |
|
63 | + if (isset($this->value)) |
|
64 | 64 | $result["value"]=$this->value; |
65 | 65 | return $result; |
66 | 66 | } |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * @param string $prompt |
72 | 72 | * @return \Ajax\semantic\components\validation\Rule |
73 | 73 | */ |
74 | - public static function match($name,$prompt=NULL){ |
|
75 | - return new Rule("match[".$name."]",$prompt); |
|
74 | + public static function match($name, $prompt=NULL) { |
|
75 | + return new Rule("match[".$name."]", $prompt); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | * @param string $prompt |
82 | 82 | * @return \Ajax\semantic\components\validation\Rule |
83 | 83 | */ |
84 | - public static function different($name,$prompt=NULL){ |
|
85 | - return new Rule("different[".$name."]",$prompt); |
|
84 | + public static function different($name, $prompt=NULL) { |
|
85 | + return new Rule("different[".$name."]", $prompt); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -92,82 +92,82 @@ discard block |
||
92 | 92 | * @param string $prompt |
93 | 93 | * @return \Ajax\semantic\components\validation\Rule |
94 | 94 | */ |
95 | - public static function integer($min=NULL,$max=NULL,$prompt=NULL){ |
|
96 | - if(\is_int($min) && \is_int($max)) |
|
97 | - return new Rule("integer[{$min}..{$max}]",$prompt); |
|
98 | - return new Rule("integer",$prompt); |
|
95 | + public static function integer($min=NULL, $max=NULL, $prompt=NULL) { |
|
96 | + if (\is_int($min) && \is_int($max)) |
|
97 | + return new Rule("integer[{$min}..{$max}]", $prompt); |
|
98 | + return new Rule("integer", $prompt); |
|
99 | 99 | } |
100 | 100 | |
101 | - public static function decimal($prompt=NULL){ |
|
102 | - return new Rule("decimal",$prompt); |
|
101 | + public static function decimal($prompt=NULL) { |
|
102 | + return new Rule("decimal", $prompt); |
|
103 | 103 | } |
104 | 104 | |
105 | - public static function number($prompt=NULL){ |
|
106 | - return new Rule("number",$prompt); |
|
105 | + public static function number($prompt=NULL) { |
|
106 | + return new Rule("number", $prompt); |
|
107 | 107 | } |
108 | 108 | |
109 | - public static function is($value,$prompt=NULL){ |
|
110 | - return new Rule("is[".$value."]",$prompt); |
|
109 | + public static function is($value, $prompt=NULL) { |
|
110 | + return new Rule("is[".$value."]", $prompt); |
|
111 | 111 | } |
112 | 112 | |
113 | - public static function isExactly($value,$prompt=NULL){ |
|
114 | - return new Rule("isExactly[".$value."]",$prompt); |
|
113 | + public static function isExactly($value, $prompt=NULL) { |
|
114 | + return new Rule("isExactly[".$value."]", $prompt); |
|
115 | 115 | } |
116 | 116 | |
117 | - public static function not($value,$prompt=NULL){ |
|
118 | - return new Rule("not[".$value."]",$prompt); |
|
117 | + public static function not($value, $prompt=NULL) { |
|
118 | + return new Rule("not[".$value."]", $prompt); |
|
119 | 119 | } |
120 | 120 | |
121 | - public static function notExactly($value,$prompt=NULL){ |
|
122 | - return new Rule("notExactly[".$value."]",$prompt); |
|
121 | + public static function notExactly($value, $prompt=NULL) { |
|
122 | + return new Rule("notExactly[".$value."]", $prompt); |
|
123 | 123 | } |
124 | 124 | |
125 | - public static function contains($value,$prompt=NULL){ |
|
126 | - return new Rule("contains[".$value."]",$prompt); |
|
125 | + public static function contains($value, $prompt=NULL) { |
|
126 | + return new Rule("contains[".$value."]", $prompt); |
|
127 | 127 | } |
128 | 128 | |
129 | - public static function containsExactly($value,$prompt=NULL){ |
|
130 | - return new Rule("containsExactly[".$value."]",$prompt); |
|
129 | + public static function containsExactly($value, $prompt=NULL) { |
|
130 | + return new Rule("containsExactly[".$value."]", $prompt); |
|
131 | 131 | } |
132 | 132 | |
133 | - public static function doesntContain($value,$prompt=NULL){ |
|
134 | - return new Rule("doesntContain[".$value."]",$prompt); |
|
133 | + public static function doesntContain($value, $prompt=NULL) { |
|
134 | + return new Rule("doesntContain[".$value."]", $prompt); |
|
135 | 135 | } |
136 | 136 | |
137 | - public static function doesntContainExactly($value,$prompt=NULL){ |
|
138 | - return new Rule("doesntContainExactly[".$value."]",$prompt); |
|
137 | + public static function doesntContainExactly($value, $prompt=NULL) { |
|
138 | + return new Rule("doesntContainExactly[".$value."]", $prompt); |
|
139 | 139 | } |
140 | 140 | |
141 | - public static function minCount($value,$prompt=NULL){ |
|
142 | - return new Rule("minCount[".$value."]",$prompt); |
|
141 | + public static function minCount($value, $prompt=NULL) { |
|
142 | + return new Rule("minCount[".$value."]", $prompt); |
|
143 | 143 | } |
144 | 144 | |
145 | - public static function maxCount($value,$prompt=NULL){ |
|
146 | - return new Rule("maxCount[".$value."]",$prompt); |
|
145 | + public static function maxCount($value, $prompt=NULL) { |
|
146 | + return new Rule("maxCount[".$value."]", $prompt); |
|
147 | 147 | } |
148 | 148 | |
149 | - public static function exactCount($value,$prompt=NULL){ |
|
150 | - return new Rule("exactCount[".$value."]",$prompt); |
|
149 | + public static function exactCount($value, $prompt=NULL) { |
|
150 | + return new Rule("exactCount[".$value."]", $prompt); |
|
151 | 151 | } |
152 | 152 | |
153 | - public static function email($prompt=NULL){ |
|
154 | - return new Rule("email",$prompt); |
|
153 | + public static function email($prompt=NULL) { |
|
154 | + return new Rule("email", $prompt); |
|
155 | 155 | } |
156 | 156 | |
157 | - public static function url($prompt=NULL){ |
|
158 | - return new Rule("url",$prompt); |
|
157 | + public static function url($prompt=NULL) { |
|
158 | + return new Rule("url", $prompt); |
|
159 | 159 | } |
160 | 160 | |
161 | - public static function regExp($value,$prompt=NULL){ |
|
162 | - return new Rule("regExp",$prompt,$value); |
|
161 | + public static function regExp($value, $prompt=NULL) { |
|
162 | + return new Rule("regExp", $prompt, $value); |
|
163 | 163 | } |
164 | 164 | |
165 | - public static function custom($name,$jsFunction){ |
|
166 | - return "$.fn.form.settings.rules.".$name." =".$jsFunction ; |
|
165 | + public static function custom($name, $jsFunction) { |
|
166 | + return "$.fn.form.settings.rules.".$name." =".$jsFunction; |
|
167 | 167 | } |
168 | 168 | |
169 | - public static function ajax(JsUtils $js,$name,$url,$params,$jsCallback,$method="post",$parameters=[]){ |
|
170 | - $parameters=\array_merge(["async"=>false,"url"=>$url,"params"=>$params,"hasLoader"=>false,"jsCallback"=>$jsCallback,"dataType"=>"json","stopPropagation"=>false,"preventDefault"=>false,"responseElement"=>null],$parameters); |
|
169 | + public static function ajax(JsUtils $js, $name, $url, $params, $jsCallback, $method="post", $parameters=[]) { |
|
170 | + $parameters=\array_merge(["async"=>false, "url"=>$url, "params"=>$params, "hasLoader"=>false, "jsCallback"=>$jsCallback, "dataType"=>"json", "stopPropagation"=>false, "preventDefault"=>false, "responseElement"=>null], $parameters); |
|
171 | 171 | $ajax=new AjaxCall($method, $parameters); |
172 | 172 | return self::custom($name, "function(value){var result=true;".$ajax->compile($js)."return result;}"); |
173 | 173 | } |
@@ -2,10 +2,10 @@ discard block |
||
2 | 2 | namespace Ajax\common\traits; |
3 | 3 | use Ajax\common\BaseGui; |
4 | 4 | |
5 | -trait JsUtilsInternalTrait{ |
|
5 | +trait JsUtilsInternalTrait { |
|
6 | 6 | |
7 | - protected $jquery_code_for_compile=array (); |
|
8 | - protected $jquery_code_for_compile_at_last=array (); |
|
7 | + protected $jquery_code_for_compile=array(); |
|
8 | + protected $jquery_code_for_compile_at_last=array(); |
|
9 | 9 | |
10 | 10 | protected function _addToCompile($jsScript) { |
11 | 11 | $this->jquery_code_for_compile[]=$jsScript; |
@@ -15,28 +15,28 @@ discard block |
||
15 | 15 | * @param BaseGui $library |
16 | 16 | * @param mixed $view |
17 | 17 | */ |
18 | - protected function _compileLibrary(BaseGui $library=NULL, &$view=NULL){ |
|
19 | - if(isset($view)) |
|
18 | + protected function _compileLibrary(BaseGui $library=NULL, &$view=NULL) { |
|
19 | + if (isset($view)) |
|
20 | 20 | $library->compileHtml($this, $view); |
21 | 21 | if ($library->isAutoCompile()) { |
22 | 22 | $library->compile(true); |
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
26 | - protected function defer($script){ |
|
26 | + protected function defer($script) { |
|
27 | 27 | $result="window.defer=function (method) {if (window.jQuery) method(); else setTimeout(function() { defer(method) }, 50);};"; |
28 | 28 | $result.="window.defer(function(){".$script."})"; |
29 | 29 | return $result; |
30 | 30 | } |
31 | 31 | |
32 | - protected function ready($script){ |
|
32 | + protected function ready($script) { |
|
33 | 33 | $result='$(document).ready(function() {'."\n"; |
34 | 34 | $result.=$script.'})'; |
35 | 35 | return $result; |
36 | 36 | } |
37 | 37 | |
38 | 38 | protected function minify($input) { |
39 | - if(trim($input) === "") return $input; |
|
39 | + if (trim($input)==="") return $input; |
|
40 | 40 | return preg_replace( |
41 | 41 | array( |
42 | 42 | // Remove comment(s) |
@@ -14,27 +14,27 @@ discard block |
||
14 | 14 | * @author jc |
15 | 15 | * |
16 | 16 | */ |
17 | -trait FormTrait{ |
|
17 | +trait FormTrait { |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @return HtmlForm |
21 | 21 | */ |
22 | 22 | abstract protected function getForm(); |
23 | 23 | |
24 | - protected function addCompoValidation(Form $compo,HtmlFormField $field){ |
|
24 | + protected function addCompoValidation(Form $compo, HtmlFormField $field) { |
|
25 | 25 | $validation=$field->getValidation(); |
26 | - if(isset($validation)){ |
|
26 | + if (isset($validation)) { |
|
27 | 27 | $validation->setIdentifier($field->getDataField()->getIdentifier()); |
28 | 28 | $compo->addFieldValidation($validation); |
29 | 29 | } |
30 | 30 | return $compo; |
31 | 31 | } |
32 | 32 | |
33 | - protected function _runValidationParams(Form &$compo,JsUtils $js=NULL){ |
|
33 | + protected function _runValidationParams(Form &$compo, JsUtils $js=NULL) { |
|
34 | 34 | $form=$this->getForm(); |
35 | 35 | $params=$form->getValidationParams(); |
36 | - if(isset($params["_ajaxSubmit"])){ |
|
37 | - $compilation=$this->_compileAjaxSubmit($params["_ajaxSubmit"],$js); |
|
36 | + if (isset($params["_ajaxSubmit"])) { |
|
37 | + $compilation=$this->_compileAjaxSubmit($params["_ajaxSubmit"], $js); |
|
38 | 38 | $this->onSuccess($compilation); |
39 | 39 | $form->removeValidationParam("_ajaxSubmit"); |
40 | 40 | } |
@@ -43,16 +43,16 @@ discard block |
||
43 | 43 | $form->addEventsOnRun($js); |
44 | 44 | } |
45 | 45 | |
46 | - protected function _compileAjaxSubmit($ajaxSubmit,JsUtils $js=null){ |
|
46 | + protected function _compileAjaxSubmit($ajaxSubmit, JsUtils $js=null) { |
|
47 | 47 | $compilation=""; |
48 | - if(\is_array($ajaxSubmit)){ |
|
49 | - foreach ($ajaxSubmit as $ajaxSubmitItem){ |
|
48 | + if (\is_array($ajaxSubmit)) { |
|
49 | + foreach ($ajaxSubmit as $ajaxSubmitItem) { |
|
50 | 50 | $compilation.=$ajaxSubmitItem->compile($js); |
51 | 51 | } |
52 | - }elseif($ajaxSubmit instanceof AjaxCall){ |
|
52 | + }elseif ($ajaxSubmit instanceof AjaxCall) { |
|
53 | 53 | $compilation=$ajaxSubmit->compile($js); |
54 | 54 | } |
55 | - $compilation=str_ireplace("\"","%quote%", $compilation); |
|
55 | + $compilation=str_ireplace("\"", "%quote%", $compilation); |
|
56 | 56 | return $compilation; |
57 | 57 | } |
58 | 58 | |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | return $this; |
66 | 66 | } |
67 | 67 | |
68 | - public function setAttached($value=true){ |
|
68 | + public function setAttached($value=true) { |
|
69 | 69 | $form=$this->getForm(); |
70 | - if($value) |
|
71 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
70 | + if ($value) |
|
71 | + $form->addToPropertyCtrl("class", "attached", array("attached")); |
|
72 | 72 | return $form; |
73 | 73 | } |
74 | 74 | |
75 | - public function addErrorMessage(){ |
|
75 | + public function addErrorMessage() { |
|
76 | 76 | return $this->getForm()->addContent((new HtmlMessage(""))->setError()); |
77 | 77 | } |
78 | 78 | |
@@ -88,47 +88,47 @@ discard block |
||
88 | 88 | * @param array $parameters |
89 | 89 | * @return HtmlForm |
90 | 90 | */ |
91 | - public function submitOn($event,$identifierOrElement,$url,$responseElement,$parameters=NULL){ |
|
91 | + public function submitOn($event, $identifierOrElement, $url, $responseElement, $parameters=NULL) { |
|
92 | 92 | $form=$this->getForm(); |
93 | - if($identifierOrElement instanceof BaseHtml) |
|
93 | + if ($identifierOrElement instanceof BaseHtml) |
|
94 | 94 | $elem=$identifierOrElement; |
95 | 95 | else |
96 | 96 | $elem=$form->getElementById($identifierOrElement, $form->getContent()); |
97 | - if(isset($elem)){ |
|
98 | - $this->_buttonAsSubmit($elem, $event,$url,$responseElement,$parameters); |
|
97 | + if (isset($elem)) { |
|
98 | + $this->_buttonAsSubmit($elem, $event, $url, $responseElement, $parameters); |
|
99 | 99 | } |
100 | 100 | return $form; |
101 | 101 | } |
102 | 102 | |
103 | - public function submitOnClick($identifier,$url,$responseElement,$parameters=NULL){ |
|
104 | - return $this->submitOn("click", $identifier, $url, $responseElement,$parameters); |
|
103 | + public function submitOnClick($identifier, $url, $responseElement, $parameters=NULL) { |
|
104 | + return $this->submitOn("click", $identifier, $url, $responseElement, $parameters); |
|
105 | 105 | } |
106 | 106 | |
107 | - public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
108 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
109 | - return $this->_buttonAsSubmit($bt, "click",$url,$responseElement,$parameters); |
|
107 | + public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
108 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
109 | + return $this->_buttonAsSubmit($bt, "click", $url, $responseElement, $parameters); |
|
110 | 110 | } |
111 | 111 | |
112 | - protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL){ |
|
112 | + protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement=NULL, $parameters=NULL) { |
|
113 | 113 | $form=$this->getForm(); |
114 | - if(isset($url) && isset($responseElement)){ |
|
115 | - $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true); |
|
116 | - $this->setSubmitParams($url,$responseElement,$parameters); |
|
114 | + if (isset($url) && isset($responseElement)) { |
|
115 | + $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');", true, true); |
|
116 | + $this->setSubmitParams($url, $responseElement, $parameters); |
|
117 | 117 | } |
118 | 118 | return $button; |
119 | 119 | } |
120 | 120 | |
121 | - public function setSubmitParams($url,$responseElement=NULL,$parameters=NULL){ |
|
121 | + public function setSubmitParams($url, $responseElement=NULL, $parameters=NULL) { |
|
122 | 122 | $form=$this->getForm(); |
123 | - $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true]; |
|
124 | - if(\is_array($parameters)) |
|
125 | - $params=\array_merge($params,$parameters); |
|
123 | + $params=["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url, "stopPropagation"=>true]; |
|
124 | + if (\is_array($parameters)) |
|
125 | + $params=\array_merge($params, $parameters); |
|
126 | 126 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
127 | 127 | return $this; |
128 | 128 | } |
129 | 129 | |
130 | - public function addReset($identifier,$value,$cssStyle=NULL){ |
|
131 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
130 | + public function addReset($identifier, $value, $cssStyle=NULL) { |
|
131 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
132 | 132 | $bt->setProperty("type", "reset"); |
133 | 133 | return $bt; |
134 | 134 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @param string $jsCode |
139 | 139 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
140 | 140 | */ |
141 | - public function onValid($jsCode){ |
|
141 | + public function onValid($jsCode) { |
|
142 | 142 | $form=$this->getForm(); |
143 | 143 | $form->addValidationParam("onValid", "%function(){".$jsCode."}%"); |
144 | 144 | return $form; |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | * @param string $jsCode can use event and fields parameters |
150 | 150 | * @return HtmlForm |
151 | 151 | */ |
152 | - public function onSuccess($jsCode){ |
|
152 | + public function onSuccess($jsCode) { |
|
153 | 153 | $form=$this->getForm(); |
154 | - $form->addValidationParam("onSuccess", $jsCode,"%function(event,fields){","}%"); |
|
154 | + $form->addValidationParam("onSuccess", $jsCode, "%function(event,fields){", "}%"); |
|
155 | 155 | return $form; |
156 | 156 | } |
157 | 157 | } |
@@ -12,34 +12,34 @@ discard block |
||
12 | 12 | use Ajax\semantic\html\base\traits\MenuItemTrait; |
13 | 13 | |
14 | 14 | class HtmlDropdownItem extends HtmlSemDoubleElement { |
15 | - use IconTrait,MenuItemTrait; |
|
16 | - public function __construct($identifier, $content="",$value=NULL,$image=NULL,$description=NULL) { |
|
15 | + use IconTrait, MenuItemTrait; |
|
16 | + public function __construct($identifier, $content="", $value=NULL, $image=NULL, $description=NULL) { |
|
17 | 17 | parent::__construct($identifier, "a"); |
18 | 18 | $this->setClass("item"); |
19 | 19 | $this->setContent($content); |
20 | - if($value!==NULL) |
|
20 | + if ($value!==NULL) |
|
21 | 21 | $this->setData($value); |
22 | - if($image!==NULL) |
|
22 | + if ($image!==NULL) |
|
23 | 23 | $this->asMiniAvatar($image); |
24 | - if($description!==NULL) |
|
24 | + if ($description!==NULL) |
|
25 | 25 | $this->setDescription($description); |
26 | 26 | } |
27 | 27 | |
28 | - public function setDescription($description){ |
|
29 | - $descO=new HtmlDoubleElement("desc-".$this->identifier,"span"); |
|
28 | + public function setDescription($description) { |
|
29 | + $descO=new HtmlDoubleElement("desc-".$this->identifier, "span"); |
|
30 | 30 | $descO->setClass("description"); |
31 | 31 | $descO->setContent($description); |
32 | - return $this->addContent($descO,true); |
|
32 | + return $this->addContent($descO, true); |
|
33 | 33 | } |
34 | 34 | |
35 | - public function setData($value){ |
|
35 | + public function setData($value) { |
|
36 | 36 | $this->setProperty("data-value", $value); |
37 | 37 | return $this; |
38 | 38 | } |
39 | 39 | |
40 | - public function asOption(){ |
|
40 | + public function asOption() { |
|
41 | 41 | $this->tagName="option"; |
42 | - if($this->getProperty("data-value")!==null) |
|
42 | + if ($this->getProperty("data-value")!==null) |
|
43 | 43 | $this->setProperty("value", $this->getProperty("data-value")); |
44 | 44 | } |
45 | 45 | |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @param string $image the image src |
48 | 48 | * @return HtmlImg |
49 | 49 | */ |
50 | - public function asMiniAvatar($image){ |
|
50 | + public function asMiniAvatar($image) { |
|
51 | 51 | $this->tagName="div"; |
52 | - $img=new HtmlImg("image-".$this->identifier,$image); |
|
52 | + $img=new HtmlImg("image-".$this->identifier, $image); |
|
53 | 53 | $img->setClass("ui mini avatar image"); |
54 | - $this->addContent($img,true); |
|
54 | + $this->addContent($img, true); |
|
55 | 55 | return $this; |
56 | 56 | } |
57 | 57 | |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | * @param string $icon |
61 | 61 | * @return HtmlDropdownItem |
62 | 62 | */ |
63 | - public function asIcon($caption,$icon){ |
|
63 | + public function asIcon($caption, $icon) { |
|
64 | 64 | $this->setContent($caption); |
65 | - $this->addContent(new HtmlIcon("", $icon),true); |
|
65 | + $this->addContent(new HtmlIcon("", $icon), true); |
|
66 | 66 | return $this; |
67 | 67 | } |
68 | 68 | |
@@ -71,23 +71,23 @@ discard block |
||
71 | 71 | * @param string $color |
72 | 72 | * @return HtmlDropdownItem |
73 | 73 | */ |
74 | - public function asCircularLabel($caption,$color){ |
|
74 | + public function asCircularLabel($caption, $color) { |
|
75 | 75 | $this->setContent($caption); |
76 | 76 | $lbl=new HtmlLabel(""); |
77 | 77 | $lbl->setCircular()->setColor($color)->setEmpty(); |
78 | - $this->addContent($lbl,true); |
|
78 | + $this->addContent($lbl, true); |
|
79 | 79 | return $this; |
80 | 80 | } |
81 | 81 | |
82 | 82 | |
83 | 83 | |
84 | 84 | public function addMenuItem($items) { |
85 | - $menu=new HtmlMenu("menu-" . $this->identifier, $items); |
|
85 | + $menu=new HtmlMenu("menu-".$this->identifier, $items); |
|
86 | 86 | $content=$this->content; |
87 | 87 | $this->setTagName("div"); |
88 | 88 | $this->setProperty("class", "item"); |
89 | 89 | $icon=new HtmlIcon("", "dropdown"); |
90 | - $this->content=[$icon,new HtmlSemDoubleElement("","span","text",$content),$menu]; |
|
90 | + $this->content=[$icon, new HtmlSemDoubleElement("", "span", "text", $content), $menu]; |
|
91 | 91 | return $menu; |
92 | 92 | } |
93 | 93 | |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | * @param string $icon |
97 | 97 | * @return HtmlDropdownItem |
98 | 98 | */ |
99 | - public static function searchInput($placeholder=NULL,$icon=NULL){ |
|
100 | - return (new HtmlDropdownItem(""))->asSearchInput($placeholder,$icon); |
|
99 | + public static function searchInput($placeholder=NULL, $icon=NULL) { |
|
100 | + return (new HtmlDropdownItem(""))->asSearchInput($placeholder, $icon); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
104 | 104 | * @return HtmlDropdownItem |
105 | 105 | */ |
106 | - public static function divider(){ |
|
106 | + public static function divider() { |
|
107 | 107 | return (new HtmlDropdownItem(""))->asDivider(); |
108 | 108 | } |
109 | 109 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * @param string $icon |
113 | 113 | * @return HtmlDropdownItem |
114 | 114 | */ |
115 | - public static function header($caption=NULL,$icon=NULL){ |
|
116 | - return (new HtmlDropdownItem(""))->asHeader($caption,$icon); |
|
115 | + public static function header($caption=NULL, $icon=NULL) { |
|
116 | + return (new HtmlDropdownItem(""))->asHeader($caption, $icon); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * @param string $color |
122 | 122 | * @return HtmlDropdownItem |
123 | 123 | */ |
124 | - public static function circular($caption,$color){ |
|
125 | - return (new HtmlDropdownItem(""))->asCircularLabel($caption,$color); |
|
124 | + public static function circular($caption, $color) { |
|
125 | + return (new HtmlDropdownItem(""))->asCircularLabel($caption, $color); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | * @param string $icon |
131 | 131 | * @return HtmlDropdownItem |
132 | 132 | */ |
133 | - public static function icon($caption,$icon){ |
|
134 | - return (new HtmlDropdownItem(""))->asIcon($caption,$icon); |
|
133 | + public static function icon($caption, $icon) { |
|
134 | + return (new HtmlDropdownItem(""))->asIcon($caption, $icon); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @param string $image |
140 | 140 | * @return HtmlDropdownItem |
141 | 141 | */ |
142 | - public static function avatar($caption,$image){ |
|
143 | - return (new HtmlDropdownItem("",$caption))->asMiniAvatar($image); |
|
142 | + public static function avatar($caption, $image) { |
|
143 | + return (new HtmlDropdownItem("", $caption))->asMiniAvatar($image); |
|
144 | 144 | } |
145 | 145 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | class JArray { |
6 | 6 | |
7 | 7 | public static function isAssociative($array) { |
8 | - return (array_values($array) !== $array); |
|
8 | + return (array_values($array)!==$array); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | public static function getValue($array, $key, $pos) { |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | return $array[$key]; |
14 | 14 | } |
15 | 15 | $values=array_values($array); |
16 | - if ($pos < sizeof($values)) |
|
16 | + if ($pos<sizeof($values)) |
|
17 | 17 | return $values[$pos]; |
18 | 18 | } |
19 | 19 | |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | $result=NULL; |
22 | 22 | if (array_key_exists($key, $array)) { |
23 | 23 | $result=$array[$key]; |
24 | - if ($condition($result) === true) |
|
24 | + if ($condition($result)===true) |
|
25 | 25 | return $result; |
26 | 26 | } |
27 | 27 | $values=array_values($array); |
28 | - foreach ( $values as $val ) { |
|
29 | - if ($condition($val) === true) |
|
28 | + foreach ($values as $val) { |
|
29 | + if ($condition($val)===true) |
|
30 | 30 | return $val; |
31 | 31 | } |
32 | 32 | return $result; |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | $result=""; |
44 | 44 | if (\is_array($glue)) { |
45 | 45 | $size=\sizeof($pieces); |
46 | - if ($size > 0) { |
|
47 | - for($i=0; $i < $size - 1; $i++) { |
|
48 | - $result.=$pieces[$i] . @$glue[$i]; |
|
46 | + if ($size>0) { |
|
47 | + for ($i=0; $i<$size-1; $i++) { |
|
48 | + $result.=$pieces[$i].@$glue[$i]; |
|
49 | 49 | } |
50 | - $result.=$pieces[$size - 1]; |
|
50 | + $result.=$pieces[$size-1]; |
|
51 | 51 | } |
52 | 52 | } else { |
53 | 53 | $result=\implode($glue, $pieces); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | public static function dimension($array) { |
59 | 59 | if (\is_array(reset($array))) { |
60 | - $return=self::dimension(reset($array)) + 1; |
|
60 | + $return=self::dimension(reset($array))+1; |
|
61 | 61 | } else { |
62 | 62 | $return=1; |
63 | 63 | } |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | public static function sortAssociative($array, $sortedKeys=array()) { |
68 | - $newArray=array (); |
|
69 | - foreach ( $sortedKeys as $key ) { |
|
68 | + $newArray=array(); |
|
69 | + foreach ($sortedKeys as $key) { |
|
70 | 70 | if (\array_key_exists($key, $array)) { |
71 | 71 | $newArray[$key]=$array[$key]; |
72 | 72 | } |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | |
77 | 77 | public static function moveElementTo(&$array, $from, $to) { |
78 | 78 | $result=false; |
79 | - if(isset($array)){ |
|
80 | - if(isset($array[$from])){ |
|
81 | - $out = array_splice($array, $from, 1); |
|
79 | + if (isset($array)) { |
|
80 | + if (isset($array[$from])) { |
|
81 | + $out=array_splice($array, $from, 1); |
|
82 | 82 | array_splice($array, $to, 0, $out); |
83 | 83 | $result=true; |
84 | 84 | } |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | return $result; |
87 | 87 | } |
88 | 88 | |
89 | - public static function swapElements(&$array,$index1,$index2){ |
|
89 | + public static function swapElements(&$array, $index1, $index2) { |
|
90 | 90 | $result=false; |
91 | - if(isset($array)){ |
|
92 | - if(isset($array[$index1])&& isset($array[$index2])){ |
|
91 | + if (isset($array)) { |
|
92 | + if (isset($array[$index1]) && isset($array[$index2])) { |
|
93 | 93 | $tmp=$array[$index1]; |
94 | 94 | $array[$index1]=$array[$index2]; |
95 | 95 | $array[$index2]=$tmp; |
@@ -100,33 +100,33 @@ discard block |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | |
103 | - public static function modelArray($objects,$identifierFunction=NULL,$modelFunction=NULL){ |
|
103 | + public static function modelArray($objects, $identifierFunction=NULL, $modelFunction=NULL) { |
|
104 | 104 | $result=[]; |
105 | - if(isset($modelFunction)===false){ |
|
105 | + if (isset($modelFunction)===false) { |
|
106 | 106 | $modelFunction="__toString"; |
107 | 107 | } |
108 | - if(isset($identifierFunction)===false){ |
|
109 | - foreach ($objects as $object){ |
|
108 | + if (isset($identifierFunction)===false) { |
|
109 | + foreach ($objects as $object) { |
|
110 | 110 | $result[]=self::callFunction($object, $modelFunction); |
111 | 111 | } |
112 | - }else{ |
|
113 | - foreach ($objects as $object){ |
|
112 | + } else { |
|
113 | + foreach ($objects as $object) { |
|
114 | 114 | $result[self::callFunction($object, $identifierFunction)]=self::callFunction($object, $modelFunction); |
115 | 115 | } |
116 | 116 | } |
117 | 117 | return $result; |
118 | 118 | } |
119 | 119 | |
120 | - private static function callFunction($object,$callback){ |
|
121 | - if(\is_string($callback)) |
|
122 | - return \call_user_func(array($object, $callback),[]); |
|
123 | - else if (\is_callable($callback)){ |
|
120 | + private static function callFunction($object, $callback) { |
|
121 | + if (\is_string($callback)) |
|
122 | + return \call_user_func(array($object, $callback), []); |
|
123 | + else if (\is_callable($callback)) { |
|
124 | 124 | return $callback($object); |
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | - public static function count($array){ |
|
129 | - if(\is_array($array)){ |
|
128 | + public static function count($array) { |
|
129 | + if (\is_array($array)) { |
|
130 | 130 | return \sizeof($array); |
131 | 131 | } |
132 | 132 | return 0; |
@@ -15,29 +15,29 @@ discard block |
||
15 | 15 | use Ajax\common\html\HtmlDoubleElement; |
16 | 16 | |
17 | 17 | class HtmlDropdown extends HtmlSemDoubleElement { |
18 | - use FieldTrait,LabeledIconTrait { |
|
18 | + use FieldTrait, LabeledIconTrait { |
|
19 | 19 | addIcon as addIconP; |
20 | 20 | } |
21 | 21 | protected $mClass="menu"; |
22 | 22 | protected $mTagName="div"; |
23 | - protected $items=array (); |
|
24 | - protected $_params=array("action"=>"nothing","on"=>"hover","showOnFocus"=>false); |
|
23 | + protected $items=array(); |
|
24 | + protected $_params=array("action"=>"nothing", "on"=>"hover", "showOnFocus"=>false); |
|
25 | 25 | protected $input; |
26 | 26 | protected $value; |
27 | 27 | protected $_associative; |
28 | 28 | protected $_multiple; |
29 | 29 | |
30 | - public function __construct($identifier, $value="", $items=array(),$associative=true) { |
|
30 | + public function __construct($identifier, $value="", $items=array(), $associative=true) { |
|
31 | 31 | parent::__construct($identifier, "div"); |
32 | 32 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdown.php'; |
33 | 33 | $this->setProperty("class", "ui dropdown"); |
34 | 34 | $this->_multiple=false; |
35 | 35 | $content=[]; |
36 | - if(isset($value)){ |
|
37 | - if($value instanceof HtmlSemDoubleElement){ |
|
36 | + if (isset($value)) { |
|
37 | + if ($value instanceof HtmlSemDoubleElement) { |
|
38 | 38 | $text=$value; |
39 | - }else{ |
|
40 | - $text=new HtmlSemDoubleElement("text-".$this->identifier,"div"); |
|
39 | + } else { |
|
40 | + $text=new HtmlSemDoubleElement("text-".$this->identifier, "div"); |
|
41 | 41 | $text->setClass("text"); |
42 | 42 | $this->setValue($value); |
43 | 43 | } |
@@ -50,29 +50,29 @@ discard block |
||
50 | 50 | $this->addItems($items); |
51 | 51 | } |
52 | 52 | |
53 | - public function getField(){ |
|
53 | + public function getField() { |
|
54 | 54 | return $this->input; |
55 | 55 | } |
56 | 56 | |
57 | - public function getDataField(){ |
|
57 | + public function getDataField() { |
|
58 | 58 | return $this->input; |
59 | 59 | } |
60 | 60 | |
61 | - public function addItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
62 | - $itemO=$this->beforeAddItem($item,$value,$image,$description); |
|
61 | + public function addItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
62 | + $itemO=$this->beforeAddItem($item, $value, $image, $description); |
|
63 | 63 | $this->items[]=$itemO; |
64 | 64 | return $itemO; |
65 | 65 | } |
66 | 66 | |
67 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
67 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
68 | 68 | $this->removeArrow(); |
69 | - $this->addIconP($icon,$before,$labeled); |
|
69 | + $this->addIconP($icon, $before, $labeled); |
|
70 | 70 | return $this->getElementById("text-".$this->identifier, $this->content)->setWrapAfter(""); |
71 | 71 | } |
72 | 72 | |
73 | - public function addIcons($icons){ |
|
73 | + public function addIcons($icons) { |
|
74 | 74 | $count=$this->count(); |
75 | - for ($i=0;$i<\sizeof($icons) && $i<$count;$i++){ |
|
75 | + for ($i=0; $i<\sizeof($icons) && $i<$count; $i++) { |
|
76 | 76 | $this->getItem($i)->addIcon($icons[$i]); |
77 | 77 | } |
78 | 78 | } |
@@ -83,33 +83,33 @@ discard block |
||
83 | 83 | * @param int $position |
84 | 84 | * @return HtmlDropdownItem |
85 | 85 | */ |
86 | - public function insertItem($item,$position=0){ |
|
86 | + public function insertItem($item, $position=0) { |
|
87 | 87 | $itemO=$this->beforeAddItem($item); |
88 | - $start = array_slice($this->items, 0, $position); |
|
89 | - $end = array_slice($this->items, $position); |
|
90 | - $start[] = $item; |
|
88 | + $start=array_slice($this->items, 0, $position); |
|
89 | + $end=array_slice($this->items, $position); |
|
90 | + $start[]=$item; |
|
91 | 91 | $this->items=array_merge($start, $end); |
92 | 92 | return $itemO; |
93 | 93 | } |
94 | 94 | |
95 | - protected function removeArrow(){ |
|
96 | - if(\sizeof($this->content)>1){ |
|
95 | + protected function removeArrow() { |
|
96 | + if (\sizeof($this->content)>1) { |
|
97 | 97 | unset($this->content["arrow"]); |
98 | 98 | $this->content=\array_values($this->content); |
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - protected function beforeAddItem($item,$value=NULL,$image=NULL,$description=NULL){ |
|
102 | + protected function beforeAddItem($item, $value=NULL, $image=NULL, $description=NULL) { |
|
103 | 103 | $itemO=$item; |
104 | - if(\is_array($item)){ |
|
104 | + if (\is_array($item)) { |
|
105 | 105 | $description=JArray::getValue($item, "description", 3); |
106 | 106 | $value=JArray::getValue($item, "value", 1); |
107 | 107 | $image=JArray::getValue($item, "image", 2); |
108 | 108 | $item=JArray::getValue($item, "item", 0); |
109 | 109 | } |
110 | - if(!$item instanceof HtmlDropdownItem){ |
|
111 | - $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items),$item,$value,$image,$description); |
|
112 | - }elseif($itemO instanceof HtmlDropdownItem){ |
|
110 | + if (!$item instanceof HtmlDropdownItem) { |
|
111 | + $itemO=new HtmlDropdownItem("dd-item-".$this->identifier."-".\sizeof($this->items), $item, $value, $image, $description); |
|
112 | + }elseif ($itemO instanceof HtmlDropdownItem) { |
|
113 | 113 | $this->addToProperty("class", "vertical"); |
114 | 114 | } |
115 | 115 | return $itemO; |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | $this->addItem($function($object)); |
123 | 123 | } |
124 | 124 | |
125 | - public function addInput($name){ |
|
126 | - if(!isset($name)) |
|
125 | + public function addInput($name) { |
|
126 | + if (!isset($name)) |
|
127 | 127 | $name="input-".$this->identifier; |
128 | 128 | $this->setAction("activate"); |
129 | - $this->input=new HtmlInput($name,"hidden"); |
|
129 | + $this->input=new HtmlInput($name, "hidden"); |
|
130 | 130 | $this->input->setIdentifier("input-".$this->identifier); |
131 | 131 | return $this->input; |
132 | 132 | } |
@@ -137,15 +137,15 @@ discard block |
||
137 | 137 | * @param string $icon |
138 | 138 | * @return HtmlDropdownItem |
139 | 139 | */ |
140 | - public function addSearchInputItem($placeHolder=NULL,$icon=NULL){ |
|
141 | - return $this->addItem(HtmlDropdownItem::searchInput($placeHolder,$icon)); |
|
140 | + public function addSearchInputItem($placeHolder=NULL, $icon=NULL) { |
|
141 | + return $this->addItem(HtmlDropdownItem::searchInput($placeHolder, $icon)); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Adds a divider item |
146 | 146 | * @return HtmlDropdownItem |
147 | 147 | */ |
148 | - public function addDividerItem(){ |
|
148 | + public function addDividerItem() { |
|
149 | 149 | return $this->addItem(HtmlDropdownItem::divider()); |
150 | 150 | } |
151 | 151 | |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | * @param string $icon |
156 | 156 | * @return HtmlDropdownItem |
157 | 157 | */ |
158 | - public function addHeaderItem($caption=NULL,$icon=NULL){ |
|
159 | - return $this->addItem(HtmlDropdownItem::header($caption,$icon)); |
|
158 | + public function addHeaderItem($caption=NULL, $icon=NULL) { |
|
159 | + return $this->addItem(HtmlDropdownItem::header($caption, $icon)); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param string $color |
166 | 166 | * @return HtmlDropdownItem |
167 | 167 | */ |
168 | - public function addCircularLabelItem($caption,$color){ |
|
168 | + public function addCircularLabelItem($caption, $color) { |
|
169 | 169 | return $this->addItem(HtmlDropdownItem::circular($caption, $color)); |
170 | 170 | } |
171 | 171 | |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | * @param string $image |
175 | 175 | * @return \Ajax\semantic\html\content\HtmlDropdownItem |
176 | 176 | */ |
177 | - public function addMiniAvatarImageItem($caption,$image){ |
|
177 | + public function addMiniAvatarImageItem($caption, $image) { |
|
178 | 178 | return $this->addItem(HtmlDropdownItem::avatar($caption, $image)); |
179 | 179 | } |
180 | 180 | |
181 | - public function addItems($items){ |
|
182 | - if(\is_array($items) && $this->_associative){ |
|
183 | - foreach ($items as $k=>$v){ |
|
181 | + public function addItems($items) { |
|
182 | + if (\is_array($items) && $this->_associative) { |
|
183 | + foreach ($items as $k=>$v) { |
|
184 | 184 | $this->addItem($v)->setData($k); |
185 | 185 | } |
186 | - }else{ |
|
187 | - foreach ($items as $item){ |
|
186 | + } else { |
|
187 | + foreach ($items as $item) { |
|
188 | 188 | $this->addItem($item); |
189 | 189 | } |
190 | 190 | } |
@@ -196,98 +196,98 @@ discard block |
||
196 | 196 | * @param array $values |
197 | 197 | * @return HtmlCollection |
198 | 198 | */ |
199 | - public function setPropertyValues($property,$values){ |
|
199 | + public function setPropertyValues($property, $values) { |
|
200 | 200 | $i=0; |
201 | - if(\is_array($values)===false){ |
|
202 | - $values=\array_fill(0, $this->count(),$values); |
|
201 | + if (\is_array($values)===false) { |
|
202 | + $values=\array_fill(0, $this->count(), $values); |
|
203 | 203 | } |
204 | - foreach ($values as $value){ |
|
204 | + foreach ($values as $value) { |
|
205 | 205 | $c=$this->items[$i++]; |
206 | - if(isset($c)){ |
|
207 | - $c->setProperty($property,$value); |
|
206 | + if (isset($c)) { |
|
207 | + $c->setProperty($property, $value); |
|
208 | 208 | } |
209 | - else{ |
|
209 | + else { |
|
210 | 210 | return $this; |
211 | 211 | } |
212 | 212 | } |
213 | 213 | return $this; |
214 | 214 | } |
215 | 215 | |
216 | - public function each($callBack){ |
|
217 | - foreach ($this->items as $index=>$value){ |
|
218 | - $callBack($index,$value); |
|
216 | + public function each($callBack) { |
|
217 | + foreach ($this->items as $index=>$value) { |
|
218 | + $callBack($index, $value); |
|
219 | 219 | } |
220 | 220 | return $this; |
221 | 221 | } |
222 | 222 | |
223 | - public function getItem($index){ |
|
223 | + public function getItem($index) { |
|
224 | 224 | return $this->items[$index]; |
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
228 | 228 | * @return int |
229 | 229 | */ |
230 | - public function count(){ |
|
230 | + public function count() { |
|
231 | 231 | return \sizeof($this->items); |
232 | 232 | } |
233 | 233 | /** |
234 | 234 | * @param boolean $dropdown |
235 | 235 | */ |
236 | - public function asDropdown($dropdown){ |
|
237 | - if($dropdown===false){ |
|
236 | + public function asDropdown($dropdown) { |
|
237 | + if ($dropdown===false) { |
|
238 | 238 | $this->_template=include dirname(__FILE__).'/../templates/tplDropdownMenu.php'; |
239 | 239 | $dropdown="menu"; |
240 | - }else{ |
|
240 | + } else { |
|
241 | 241 | $dropdown="dropdown"; |
242 | 242 | $this->mClass="menu"; |
243 | 243 | } |
244 | - return $this->addToPropertyCtrl("class", $dropdown,array("menu","dropdown")); |
|
244 | + return $this->addToPropertyCtrl("class", $dropdown, array("menu", "dropdown")); |
|
245 | 245 | } |
246 | 246 | |
247 | - public function setVertical(){ |
|
248 | - return $this->addToPropertyCtrl("class", "vertical",array("vertical")); |
|
247 | + public function setVertical() { |
|
248 | + return $this->addToPropertyCtrl("class", "vertical", array("vertical")); |
|
249 | 249 | } |
250 | 250 | |
251 | - public function setInline(){ |
|
252 | - return $this->addToPropertyCtrl("class", "inline",["inline"]); |
|
251 | + public function setInline() { |
|
252 | + return $this->addToPropertyCtrl("class", "inline", ["inline"]); |
|
253 | 253 | } |
254 | 254 | |
255 | - public function setSimple(){ |
|
256 | - return $this->addToPropertyCtrl("class", "simple",array("simple")); |
|
255 | + public function setSimple() { |
|
256 | + return $this->addToPropertyCtrl("class", "simple", array("simple")); |
|
257 | 257 | } |
258 | 258 | |
259 | - public function asButton($floating=false){ |
|
259 | + public function asButton($floating=false) { |
|
260 | 260 | $this->removeArrow(); |
261 | - if($floating) |
|
261 | + if ($floating) |
|
262 | 262 | $this->addToProperty("class", "floating"); |
263 | 263 | $this->removePropertyValue("class", "selection"); |
264 | 264 | return $this->addToProperty("class", "button"); |
265 | 265 | } |
266 | 266 | |
267 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
267 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
268 | 268 | $this->_multiple=$multiple; |
269 | - if(isset($name)) |
|
269 | + if (isset($name)) |
|
270 | 270 | $this->addInput($name); |
271 | - if($multiple){ |
|
271 | + if ($multiple) { |
|
272 | 272 | $this->addToProperty("class", "multiple"); |
273 | 273 | } |
274 | - if ($selection){ |
|
275 | - if($this->propertyContains("class", "button")===false) |
|
276 | - $this->addToPropertyCtrl("class", "selection",array("selection")); |
|
274 | + if ($selection) { |
|
275 | + if ($this->propertyContains("class", "button")===false) |
|
276 | + $this->addToPropertyCtrl("class", "selection", array("selection")); |
|
277 | 277 | } |
278 | 278 | return $this; |
279 | 279 | } |
280 | 280 | |
281 | - public function asSearch($name=NULL,$multiple=false,$selection=true){ |
|
282 | - $this->asSelect($name,$multiple,$selection); |
|
281 | + public function asSearch($name=NULL, $multiple=false, $selection=true) { |
|
282 | + $this->asSelect($name, $multiple, $selection); |
|
283 | 283 | return $this->addToProperty("class", "search"); |
284 | 284 | } |
285 | 285 | |
286 | - public function setSelect($name=NULL,$multiple=false){ |
|
287 | - if(!isset($name)) |
|
286 | + public function setSelect($name=NULL, $multiple=false) { |
|
287 | + if (!isset($name)) |
|
288 | 288 | $name="select-".$this->identifier; |
289 | 289 | $this->input=null; |
290 | - if($multiple){ |
|
290 | + if ($multiple) { |
|
291 | 291 | $this->setProperty("multiple", true); |
292 | 292 | $this->addToProperty("class", "multiple"); |
293 | 293 | } |
@@ -295,37 +295,37 @@ discard block |
||
295 | 295 | $this->tagName="select"; |
296 | 296 | $this->setProperty("name", $name); |
297 | 297 | $this->content=null; |
298 | - foreach ($this->items as $item){ |
|
298 | + foreach ($this->items as $item) { |
|
299 | 299 | $item->asOption(); |
300 | 300 | } |
301 | 301 | return $this; |
302 | 302 | } |
303 | 303 | |
304 | - public function asSubmenu($pointing=NULL){ |
|
304 | + public function asSubmenu($pointing=NULL) { |
|
305 | 305 | $this->setClass("ui dropdown link item"); |
306 | - if(isset($pointing)){ |
|
306 | + if (isset($pointing)) { |
|
307 | 307 | $this->setPointing($pointing); |
308 | 308 | } |
309 | 309 | return $this; |
310 | 310 | } |
311 | 311 | |
312 | - public function setPointing($value=Direction::NONE){ |
|
313 | - return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing")); |
|
312 | + public function setPointing($value=Direction::NONE) { |
|
313 | + return $this->addToPropertyCtrl("class", $value." pointing", Direction::getConstantValues("pointing")); |
|
314 | 314 | } |
315 | 315 | |
316 | - public function setValue($value){ |
|
316 | + public function setValue($value) { |
|
317 | 317 | $this->value=$value; |
318 | 318 | return $this; |
319 | 319 | } |
320 | - private function applyValue(){ |
|
320 | + private function applyValue() { |
|
321 | 321 | $value=$this->value; |
322 | - if(isset($this->input) && isset($value)){ |
|
322 | + if (isset($this->input) && isset($value)) { |
|
323 | 323 | $this->input->setProperty("value", $value); |
324 | - }else{ |
|
324 | + } else { |
|
325 | 325 | $this->setProperty("value", $value); |
326 | 326 | } |
327 | 327 | $textElement=$this->getElementById("text-".$this->identifier, $this->content); |
328 | - if(isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple) |
|
328 | + if (isset($textElement) && ($textElement instanceof HtmlDoubleElement) && !$this->_multiple) |
|
329 | 329 | $textElement->setContent($value); |
330 | 330 | return $this; |
331 | 331 | } |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | * @see BaseHtml::run() |
336 | 336 | */ |
337 | 337 | public function run(JsUtils $js) { |
338 | - if($this->propertyContains("class", "simple")===false){ |
|
339 | - if(isset($this->_bsComponent)===false){ |
|
340 | - $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier,$this->_params); |
|
338 | + if ($this->propertyContains("class", "simple")===false) { |
|
339 | + if (isset($this->_bsComponent)===false) { |
|
340 | + $this->_bsComponent=$js->semantic()->dropdown("#".$this->identifier, $this->_params); |
|
341 | 341 | $this->_bsComponent->setItemSelector(".item"); |
342 | 342 | } |
343 | 343 | $this->addEventsOnRun($js); |
@@ -345,41 +345,41 @@ discard block |
||
345 | 345 | } |
346 | 346 | } |
347 | 347 | |
348 | - public function setCompact(){ |
|
348 | + public function setCompact() { |
|
349 | 349 | return $this->addToPropertyCtrl("class", "compact", array("compact")); |
350 | 350 | } |
351 | 351 | |
352 | - public function setAction($action){ |
|
352 | + public function setAction($action) { |
|
353 | 353 | $this->_params["action"]=$action; |
354 | 354 | } |
355 | 355 | |
356 | - public function setOn($on){ |
|
356 | + public function setOn($on) { |
|
357 | 357 | $this->_params["on"]=$on; |
358 | 358 | } |
359 | 359 | |
360 | - public function setShowOnFocus($value){ |
|
360 | + public function setShowOnFocus($value) { |
|
361 | 361 | $this->_params["showOnFocus"]=$value; |
362 | 362 | } |
363 | 363 | |
364 | - public function setFullTextSearch($value){ |
|
364 | + public function setFullTextSearch($value) { |
|
365 | 365 | $this->_params["fullTextSearch"]=$value; |
366 | 366 | } |
367 | 367 | |
368 | 368 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
369 | 369 | $this->applyValue(); |
370 | - return parent::compile($js,$view); |
|
370 | + return parent::compile($js, $view); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | public function getInput() { |
374 | 374 | return $this->input; |
375 | 375 | } |
376 | 376 | |
377 | - public function setIcon($icon="dropdown"){ |
|
377 | + public function setIcon($icon="dropdown") { |
|
378 | 378 | $this->content["arrow"]=new HtmlIcon($this->identifier."-icon", $icon); |
379 | 379 | return $this; |
380 | 380 | } |
381 | 381 | |
382 | - public function jsAddItem($caption){ |
|
382 | + public function jsAddItem($caption) { |
|
383 | 383 | $js="var first=$('#{$this->identifier} .item').first();if(first!=undefined){var new =first.clone();first.parent().append(new);first.html('{$caption}};')"; |
384 | 384 | return $js; |
385 | 385 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | use Ajax\JsUtils; |
13 | 13 | |
14 | 14 | class HtmlTD extends HtmlSemDoubleElement { |
15 | - use TextAlignmentTrait,TableElementTrait; |
|
15 | + use TextAlignmentTrait, TableElementTrait; |
|
16 | 16 | private $_container; |
17 | 17 | private $_row; |
18 | 18 | private $_col; |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function __construct($identifier, $content=NULL, $tagName="td") { |
30 | 30 | parent::__construct($identifier, $tagName, "", $content); |
31 | - $this->_variations=[ Variation::COLLAPSING ]; |
|
32 | - $this->_states=[ State::ACTIVE,State::POSITIVE,State::NEGATIVE,State::WARNING,State::ERROR,State::DISABLED ]; |
|
31 | + $this->_variations=[Variation::COLLAPSING]; |
|
32 | + $this->_states=[State::ACTIVE, State::POSITIVE, State::NEGATIVE, State::WARNING, State::ERROR, State::DISABLED]; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function setContainer($container, $row, $col) { |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | public function setRowspan($rowspan) { |
52 | - $to=min($this->_container->count(), $this->_row + $rowspan - 1); |
|
53 | - for($i=$to; $i > $this->_row; $i--) { |
|
52 | + $to=min($this->_container->count(), $this->_row+$rowspan-1); |
|
53 | + for ($i=$to; $i>$this->_row; $i--) { |
|
54 | 54 | $this->_container->toDelete($i, $this->_col); |
55 | 55 | } |
56 | 56 | $this->setProperty("rowspan", $rowspan); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | public function mergeRow() { |
61 | - if(!$this->_rowMerged){ |
|
61 | + if (!$this->_rowMerged) { |
|
62 | 62 | $this->_rowMerged=true; |
63 | 63 | return $this->setRowspan($this->_container->count()); |
64 | 64 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | public function mergeCol() { |
69 | - if(!$this->_colMerged){ |
|
69 | + if (!$this->_colMerged) { |
|
70 | 70 | $this->_colMerged=true; |
71 | 71 | return $this->setColspan($this->_container->getRow($this->_row)->count()); |
72 | 72 | } |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | public function setColspan($colspan) { |
77 | - $to=min($this->_container->getRow($this->_row)->count(), $this->_col + $colspan - 1); |
|
78 | - for($i=$to; $i > $this->_col; $i--) { |
|
79 | - $this->_container->delete($this->_row, $this->_col + 1); |
|
77 | + $to=min($this->_container->getRow($this->_row)->count(), $this->_col+$colspan-1); |
|
78 | + for ($i=$to; $i>$this->_col; $i--) { |
|
79 | + $this->_container->delete($this->_row, $this->_col+1); |
|
80 | 80 | } |
81 | 81 | $this->setProperty("colspan", $colspan); |
82 | 82 | return $this->_container; |
@@ -115,21 +115,21 @@ discard block |
||
115 | 115 | return $this->addToProperty("class", "selectable"); |
116 | 116 | } |
117 | 117 | |
118 | - public function setWidth($width){ |
|
118 | + public function setWidth($width) { |
|
119 | 119 | if (\is_int($width)) { |
120 | - $width=Wide::getConstants()["W" . $width]; |
|
120 | + $width=Wide::getConstants()["W".$width]; |
|
121 | 121 | } |
122 | 122 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
123 | - return $this->addToPropertyCtrl("class", "wide", array ("wide" )); |
|
123 | + return $this->addToPropertyCtrl("class", "wide", array("wide")); |
|
124 | 124 | } |
125 | 125 | |
126 | - public function toDelete(){ |
|
126 | + public function toDelete() { |
|
127 | 127 | $this->_deleted=true; |
128 | 128 | return $this; |
129 | 129 | } |
130 | 130 | |
131 | 131 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
132 | - if(!$this->_deleted) |
|
132 | + if (!$this->_deleted) |
|
133 | 133 | return parent::compile(); |
134 | 134 | } |
135 | 135 | } |