@@ -10,50 +10,50 @@ |
||
10 | 10 | * @param string $identifier |
11 | 11 | * @param object $modelInstance |
12 | 12 | */ |
13 | - public function __construct($identifier,$modelInstance=null,$fieldsOrder=[],$fieldsDefinition=[],$fields=[],$captions=[],$separators=[]) { |
|
14 | - parent::__construct($identifier,$modelInstance,$fieldsOrder,$fieldsDefinition,$fields,$captions,$separators); |
|
13 | + public function __construct($identifier, $modelInstance=null, $fieldsOrder=[], $fieldsDefinition=[], $fields=[], $captions=[], $separators=[]) { |
|
14 | + parent::__construct($identifier, $modelInstance, $fieldsOrder, $fieldsDefinition, $fields, $captions, $separators); |
|
15 | 15 | } |
16 | 16 | |
17 | - protected function getDefaultModelInstance(){ |
|
17 | + protected function getDefaultModelInstance() { |
|
18 | 18 | return new UserModel(); |
19 | 19 | } |
20 | 20 | |
21 | - public static function regular($identifier,$modelInstance=null){ |
|
22 | - return new FormLogin($identifier,$modelInstance, |
|
23 | - ["message","login","password","remember","forget","submit","error"], |
|
24 | - ["message"=>[["icon"=>"sign in"]],"input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"checkbox","link","submit"=>["green fluid"],"message2"=>[["error"=>true]]], |
|
25 | - ["Connection","login","password","remember","forget","submit","error"], |
|
26 | - ["Please enter login and password to connect","Login","Password","Remember me.","Forgot your password?","Connection"], |
|
27 | - [0,2,4,5,6]); |
|
21 | + public static function regular($identifier, $modelInstance=null) { |
|
22 | + return new FormLogin($identifier, $modelInstance, |
|
23 | + ["message", "login", "password", "remember", "forget", "submit", "error"], |
|
24 | + ["message"=>[["icon"=>"sign in"]], "input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "checkbox", "link", "submit"=>["green fluid"], "message2"=>[["error"=>true]]], |
|
25 | + ["Connection", "login", "password", "remember", "forget", "submit", "error"], |
|
26 | + ["Please enter login and password to connect", "Login", "Password", "Remember me.", "Forgot your password?", "Connection"], |
|
27 | + [0, 2, 4, 5, 6]); |
|
28 | 28 | } |
29 | 29 | |
30 | - public static function smallInline($identifier,$modelInstance=null){ |
|
31 | - $result=new FormLogin($identifier,$modelInstance, |
|
32 | - ["login","password","submit"], |
|
33 | - ["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]], |
|
34 | - ["login","password","submit"], |
|
35 | - ["","","Connection"], |
|
30 | + public static function smallInline($identifier, $modelInstance=null) { |
|
31 | + $result=new FormLogin($identifier, $modelInstance, |
|
32 | + ["login", "password", "submit"], |
|
33 | + ["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]], |
|
34 | + ["login", "password", "submit"], |
|
35 | + ["", "", "Connection"], |
|
36 | 36 | [2]); |
37 | 37 | $result->addDividerBefore(0, "Connection"); |
38 | 38 | return $result; |
39 | 39 | } |
40 | 40 | |
41 | - public static function small($identifier,$modelInstance=null){ |
|
42 | - $result=new FormLogin($identifier,$modelInstance, |
|
43 | - ["login","password","submit"], |
|
44 | - ["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]], |
|
45 | - ["login","password","submit"], |
|
46 | - ["Login","Password","Connection"], |
|
47 | - [1,2]); |
|
41 | + public static function small($identifier, $modelInstance=null) { |
|
42 | + $result=new FormLogin($identifier, $modelInstance, |
|
43 | + ["login", "password", "submit"], |
|
44 | + ["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]], |
|
45 | + ["login", "password", "submit"], |
|
46 | + ["Login", "Password", "Connection"], |
|
47 | + [1, 2]); |
|
48 | 48 | $result->addDividerBefore(0, "Connection"); |
49 | 49 | return $result; |
50 | 50 | } |
51 | 51 | |
52 | - public static function attachedSegment($identifier,$modelInstance=null){ |
|
53 | - $result=self::regular($identifier,$modelInstance); |
|
54 | - $result->fieldAsMessage("message",["icon"=>"sign in","attached"=>true]); |
|
55 | - $result->addWrapper("message",null,"<div class='ui attached segment'>"); |
|
56 | - $result->addWrapper("error", null,"</div>"); |
|
52 | + public static function attachedSegment($identifier, $modelInstance=null) { |
|
53 | + $result=self::regular($identifier, $modelInstance); |
|
54 | + $result->fieldAsMessage("message", ["icon"=>"sign in", "attached"=>true]); |
|
55 | + $result->addWrapper("message", null, "<div class='ui attached segment'>"); |
|
56 | + $result->addWrapper("error", null, "</div>"); |
|
57 | 57 | return $result; |
58 | 58 | } |
59 | 59 | } |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | $this->params["fields"]=[]; |
21 | 21 | } |
22 | 22 | |
23 | - public function addField($identifier){ |
|
23 | + public function addField($identifier) { |
|
24 | 24 | $this->params["fields"][$identifier]=new FieldValidation($identifier); |
25 | 25 | } |
26 | 26 | |
27 | - public function setInline($value){ |
|
27 | + public function setInline($value) { |
|
28 | 28 | return $this->setParam("inline", true); |
29 | 29 | } |
30 | 30 | |
31 | - public function setOn($value){ |
|
31 | + public function setOn($value) { |
|
32 | 32 | return $this->setParam("on", $value); |
33 | 33 | } |
34 | 34 | |
@@ -40,33 +40,33 @@ discard block |
||
40 | 40 | * @param mixed $value |
41 | 41 | * @param string|NULL $prompt |
42 | 42 | */ |
43 | - public function addFieldRule($identifier,$type,$prompt=NULL,$value=NULL){ |
|
44 | - if(isset($this->params["fields"][$identifier])===false){ |
|
43 | + public function addFieldRule($identifier, $type, $prompt=NULL, $value=NULL) { |
|
44 | + if (isset($this->params["fields"][$identifier])===false) { |
|
45 | 45 | $this->addField($identifier); |
46 | 46 | } |
47 | - $this->params["fields"][$identifier]->addRule($type,$prompt,$value); |
|
47 | + $this->params["fields"][$identifier]->addRule($type, $prompt, $value); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | 51 | * @param FieldValidation $fieldValidation |
52 | 52 | */ |
53 | - public function addFieldValidation($fieldValidation){ |
|
53 | + public function addFieldValidation($fieldValidation) { |
|
54 | 54 | $this->params["fields"][$fieldValidation->getIdentifier()]=$fieldValidation; |
55 | 55 | } |
56 | 56 | |
57 | - public function setJs(JsUtils $js){ |
|
57 | + public function setJs(JsUtils $js) { |
|
58 | 58 | $this->js=$js; |
59 | 59 | } |
60 | 60 | |
61 | 61 | public function getScript() { |
62 | 62 | $allParams=$this->params; |
63 | - $this->jquery_code_for_compile=array (); |
|
63 | + $this->jquery_code_for_compile=array(); |
|
64 | 64 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).");"; |
65 | 65 | $this->compileEvents(); |
66 | 66 | return $this->compileJQueryCode(); |
67 | 67 | } |
68 | 68 | |
69 | - public function onValid($jsCode){ |
|
69 | + public function onValid($jsCode) { |
|
70 | 70 | $this->addComponentEvent("onValid", $jsCode); |
71 | 71 | } |
72 | 72 | } |
@@ -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,11 +26,11 @@ 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 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | public function fromArray($array) { |
70 | - foreach ( $array as $key => $value ) { |
|
70 | + foreach ($array as $key => $value) { |
|
71 | 71 | $this->{$key}=$value; |
72 | 72 | } |
73 | 73 | return $this; |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | |
80 | 80 | public function JsonSerialize() { |
81 | 81 | $vars=get_object_vars($this); |
82 | - $result=array (); |
|
83 | - foreach ( $vars as $k => $v ) { |
|
82 | + $result=array(); |
|
83 | + foreach ($vars as $k => $v) { |
|
84 | 84 | if (isset($v)) |
85 | 85 | $result[$k]=$v; |
86 | 86 | } |
@@ -89,6 +89,6 @@ discard block |
||
89 | 89 | |
90 | 90 | public function search($query, $field="title") { |
91 | 91 | $value=$this->$field; |
92 | - return \stripos($value, $query) !== false; |
|
92 | + return \stripos($value, $query)!==false; |
|
93 | 93 | } |
94 | 94 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @version 1.001 |
6 | 6 | * Generates a JSON Rule for the validation of a field |
7 | 7 | */ |
8 | -class Rule implements \JsonSerializable{ |
|
8 | +class Rule implements \JsonSerializable { |
|
9 | 9 | /** |
10 | 10 | * @var string |
11 | 11 | */ |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | private $value; |
22 | 22 | |
23 | - public function __construct($type,$prompt=NULL,$value=NULL){ |
|
23 | + public function __construct($type, $prompt=NULL, $value=NULL) { |
|
24 | 24 | $this->type=$type; |
25 | 25 | $this->prompt=$prompt; |
26 | 26 | $this->value=$value; |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | public function jsonSerialize() { |
57 | - $result= ["type"=>$this->type]; |
|
58 | - if(isset($this->prompt)) |
|
57 | + $result=["type"=>$this->type]; |
|
58 | + if (isset($this->prompt)) |
|
59 | 59 | $result["prompt"]=$this->prompt; |
60 | - if(isset($this->value)) |
|
60 | + if (isset($this->value)) |
|
61 | 61 | $result["value"]=$this->value; |
62 | 62 | return $result; |
63 | 63 | } |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @param string $prompt |
69 | 69 | * @return \Ajax\semantic\components\validation\Rule |
70 | 70 | */ |
71 | - public static function match($name,$prompt=NULL){ |
|
72 | - return new Rule("match[".$name."]",$prompt); |
|
71 | + public static function match($name, $prompt=NULL) { |
|
72 | + return new Rule("match[".$name."]", $prompt); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * @param string $prompt |
79 | 79 | * @return \Ajax\semantic\components\validation\Rule |
80 | 80 | */ |
81 | - public static function different($name,$prompt=NULL){ |
|
82 | - return new Rule("different[".$name."]",$prompt); |
|
81 | + public static function different($name, $prompt=NULL) { |
|
82 | + return new Rule("different[".$name."]", $prompt); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -89,78 +89,78 @@ discard block |
||
89 | 89 | * @param string $prompt |
90 | 90 | * @return \Ajax\semantic\components\validation\Rule |
91 | 91 | */ |
92 | - public static function integer($min=NULL,$max=NULL,$prompt=NULL){ |
|
93 | - if(\is_int($min) && \is_int($max)) |
|
94 | - return new Rule("integer[{$min}..{$max}]",$prompt); |
|
95 | - return new Rule("integer",$prompt); |
|
92 | + public static function integer($min=NULL, $max=NULL, $prompt=NULL) { |
|
93 | + if (\is_int($min) && \is_int($max)) |
|
94 | + return new Rule("integer[{$min}..{$max}]", $prompt); |
|
95 | + return new Rule("integer", $prompt); |
|
96 | 96 | } |
97 | 97 | |
98 | - public static function decimal($prompt=NULL){ |
|
99 | - return new Rule("decimal",$prompt); |
|
98 | + public static function decimal($prompt=NULL) { |
|
99 | + return new Rule("decimal", $prompt); |
|
100 | 100 | } |
101 | 101 | |
102 | - public static function number($prompt=NULL){ |
|
103 | - return new Rule("number",$prompt); |
|
102 | + public static function number($prompt=NULL) { |
|
103 | + return new Rule("number", $prompt); |
|
104 | 104 | } |
105 | 105 | |
106 | - public static function is($value,$prompt=NULL){ |
|
107 | - return new Rule("is[".$value."]",$prompt); |
|
106 | + public static function is($value, $prompt=NULL) { |
|
107 | + return new Rule("is[".$value."]", $prompt); |
|
108 | 108 | } |
109 | 109 | |
110 | - public static function isExactly($value,$prompt=NULL){ |
|
111 | - return new Rule("isExactly[".$value."]",$prompt); |
|
110 | + public static function isExactly($value, $prompt=NULL) { |
|
111 | + return new Rule("isExactly[".$value."]", $prompt); |
|
112 | 112 | } |
113 | 113 | |
114 | - public static function not($value,$prompt=NULL){ |
|
115 | - return new Rule("not[".$value."]",$prompt); |
|
114 | + public static function not($value, $prompt=NULL) { |
|
115 | + return new Rule("not[".$value."]", $prompt); |
|
116 | 116 | } |
117 | 117 | |
118 | - public static function notExactly($value,$prompt=NULL){ |
|
119 | - return new Rule("notExactly[".$value."]",$prompt); |
|
118 | + public static function notExactly($value, $prompt=NULL) { |
|
119 | + return new Rule("notExactly[".$value."]", $prompt); |
|
120 | 120 | } |
121 | 121 | |
122 | - public static function contains($value,$prompt=NULL){ |
|
123 | - return new Rule("contains[".$value."]",$prompt); |
|
122 | + public static function contains($value, $prompt=NULL) { |
|
123 | + return new Rule("contains[".$value."]", $prompt); |
|
124 | 124 | } |
125 | 125 | |
126 | - public static function containsExactly($value,$prompt=NULL){ |
|
127 | - return new Rule("containsExactly[".$value."]",$prompt); |
|
126 | + public static function containsExactly($value, $prompt=NULL) { |
|
127 | + return new Rule("containsExactly[".$value."]", $prompt); |
|
128 | 128 | } |
129 | 129 | |
130 | - public static function doesntContain($value,$prompt=NULL){ |
|
131 | - return new Rule("doesntContain[".$value."]",$prompt); |
|
130 | + public static function doesntContain($value, $prompt=NULL) { |
|
131 | + return new Rule("doesntContain[".$value."]", $prompt); |
|
132 | 132 | } |
133 | 133 | |
134 | - public static function doesntContainExactly($value,$prompt=NULL){ |
|
135 | - return new Rule("doesntContainExactly[".$value."]",$prompt); |
|
134 | + public static function doesntContainExactly($value, $prompt=NULL) { |
|
135 | + return new Rule("doesntContainExactly[".$value."]", $prompt); |
|
136 | 136 | } |
137 | 137 | |
138 | - public static function minCount($value,$prompt=NULL){ |
|
139 | - return new Rule("minCount[".$value."]",$prompt); |
|
138 | + public static function minCount($value, $prompt=NULL) { |
|
139 | + return new Rule("minCount[".$value."]", $prompt); |
|
140 | 140 | } |
141 | 141 | |
142 | - public static function maxCount($value,$prompt=NULL){ |
|
143 | - return new Rule("maxCount[".$value."]",$prompt); |
|
142 | + public static function maxCount($value, $prompt=NULL) { |
|
143 | + return new Rule("maxCount[".$value."]", $prompt); |
|
144 | 144 | } |
145 | 145 | |
146 | - public static function exactCount($value,$prompt=NULL){ |
|
147 | - return new Rule("exactCount[".$value."]",$prompt); |
|
146 | + public static function exactCount($value, $prompt=NULL) { |
|
147 | + return new Rule("exactCount[".$value."]", $prompt); |
|
148 | 148 | } |
149 | 149 | |
150 | - public static function email($prompt=NULL){ |
|
151 | - return new Rule("email",$prompt); |
|
150 | + public static function email($prompt=NULL) { |
|
151 | + return new Rule("email", $prompt); |
|
152 | 152 | } |
153 | 153 | |
154 | - public static function url($prompt=NULL){ |
|
155 | - return new Rule("url",$prompt); |
|
154 | + public static function url($prompt=NULL) { |
|
155 | + return new Rule("url", $prompt); |
|
156 | 156 | } |
157 | 157 | |
158 | - public static function regExp($value,$prompt=NULL){ |
|
159 | - return new Rule("regExp",$prompt,$value); |
|
158 | + public static function regExp($value, $prompt=NULL) { |
|
159 | + return new Rule("regExp", $prompt, $value); |
|
160 | 160 | } |
161 | 161 | |
162 | - public static function custom($name,$jsFunction){ |
|
163 | - return "$.fn.form.settings.rules.".$name." =".$jsFunction ; |
|
162 | + public static function custom($name, $jsFunction) { |
|
163 | + return "$.fn.form.settings.rules.".$name." =".$jsFunction; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | } |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | * @param array $instances |
18 | 18 | * @return DataTable |
19 | 19 | */ |
20 | - public function dataTable($identifier,$model, $instances){ |
|
21 | - return $this->addHtmlComponent(new DataTable($identifier,$model,$instances)); |
|
20 | + public function dataTable($identifier, $model, $instances) { |
|
21 | + return $this->addHtmlComponent(new DataTable($identifier, $model, $instances)); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | * @param array $instances |
28 | 28 | * @return JsonDataTable |
29 | 29 | */ |
30 | - public function jsonDataTable($identifier,$model, $instances){ |
|
31 | - return $this->addHtmlComponent(new JsonDataTable($identifier,$model,$instances)); |
|
30 | + public function jsonDataTable($identifier, $model, $instances) { |
|
31 | + return $this->addHtmlComponent(new JsonDataTable($identifier, $model, $instances)); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | * @param object $instance |
37 | 37 | * @return DataElement |
38 | 38 | */ |
39 | - public function dataElement($identifier, $instance){ |
|
40 | - return $this->addHtmlComponent(new DataElement($identifier,$instance)); |
|
39 | + public function dataElement($identifier, $instance) { |
|
40 | + return $this->addHtmlComponent(new DataElement($identifier, $instance)); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -45,19 +45,19 @@ discard block |
||
45 | 45 | * @param object $instance |
46 | 46 | * @return DataForm |
47 | 47 | */ |
48 | - public function dataForm($identifier, $instance){ |
|
49 | - return $this->addHtmlComponent(new DataForm($identifier,$instance)); |
|
48 | + public function dataForm($identifier, $instance) { |
|
49 | + return $this->addHtmlComponent(new DataForm($identifier, $instance)); |
|
50 | 50 | } |
51 | 51 | |
52 | - public function defaultLogin($identifier,$instance=null){ |
|
53 | - return $this->addHtmlComponent(FormLogin::regular($identifier,$instance)); |
|
52 | + public function defaultLogin($identifier, $instance=null) { |
|
53 | + return $this->addHtmlComponent(FormLogin::regular($identifier, $instance)); |
|
54 | 54 | } |
55 | 55 | |
56 | - public function smallLogin($identifier,$instance=null){ |
|
57 | - return $this->addHtmlComponent(FormLogin::small($identifier,$instance)); |
|
56 | + public function smallLogin($identifier, $instance=null) { |
|
57 | + return $this->addHtmlComponent(FormLogin::small($identifier, $instance)); |
|
58 | 58 | } |
59 | 59 | |
60 | - public function segmentedLogin($identifier,$instance=null){ |
|
61 | - return $this->addHtmlComponent(FormLogin::attachedSegment($identifier,$instance)); |
|
60 | + public function segmentedLogin($identifier, $instance=null) { |
|
61 | + return $this->addHtmlComponent(FormLogin::attachedSegment($identifier, $instance)); |
|
62 | 62 | } |
63 | 63 | } |
@@ -25,8 +25,9 @@ discard block |
||
25 | 25 | |
26 | 26 | private static function containsElement($input) { |
27 | 27 | foreach ( $input as $v ) { |
28 | - if (\is_object($v) || \is_array($v)) |
|
29 | - return true; |
|
28 | + if (\is_object($v) || \is_array($v)) { |
|
29 | + return true; |
|
30 | + } |
|
30 | 31 | } |
31 | 32 | return false; |
32 | 33 | } |
@@ -44,12 +45,13 @@ discard block |
||
44 | 45 | |
45 | 46 | public static function wrapObjects($input, $js=NULL, $separator=' ', $valueQuote='"') { |
46 | 47 | return implode($separator, array_map(function ($v) use($js, $separator, $valueQuote) { |
47 | - if (is_object($v)) |
|
48 | - return $v->compile($js); |
|
49 | - elseif (\is_array($v)) { |
|
48 | + if (is_object($v)) { |
|
49 | + return $v->compile($js); |
|
50 | + } elseif (\is_array($v)) { |
|
50 | 51 | return self::wrap($v, $js, $separator, $valueQuote); |
51 | - } else |
|
52 | - return $v; |
|
52 | + } else { |
|
53 | + return $v; |
|
54 | + } |
|
53 | 55 | }, $input)); |
54 | 56 | } |
55 | 57 | } |
@@ -14,44 +14,44 @@ discard block |
||
14 | 14 | */ |
15 | 15 | abstract class HtmlCollection extends HtmlDoubleElement { |
16 | 16 | |
17 | - public function __construct($identifier,$tagName="div"){ |
|
18 | - parent::__construct($identifier,$tagName); |
|
17 | + public function __construct($identifier, $tagName="div") { |
|
18 | + parent::__construct($identifier, $tagName); |
|
19 | 19 | $this->content=array(); |
20 | 20 | } |
21 | 21 | |
22 | - public function addItems($items){ |
|
23 | - if(JArray::isAssociative($items)){ |
|
24 | - foreach ($items as $k=>$v){ |
|
25 | - $this->addItem([$k,$v]); |
|
22 | + public function addItems($items) { |
|
23 | + if (JArray::isAssociative($items)) { |
|
24 | + foreach ($items as $k=>$v) { |
|
25 | + $this->addItem([$k, $v]); |
|
26 | 26 | } |
27 | - }else{ |
|
28 | - foreach ($items as $item){ |
|
27 | + } else { |
|
28 | + foreach ($items as $item) { |
|
29 | 29 | $this->addItem($item); |
30 | 30 | } |
31 | 31 | } |
32 | 32 | return $this; |
33 | 33 | } |
34 | 34 | |
35 | - public function setItems($items){ |
|
35 | + public function setItems($items) { |
|
36 | 36 | $this->content=$items; |
37 | 37 | return $this; |
38 | 38 | } |
39 | 39 | |
40 | - public function getItems(){ |
|
40 | + public function getItems() { |
|
41 | 41 | return $this->content; |
42 | 42 | } |
43 | 43 | |
44 | - protected function getItemToAdd($item){ |
|
44 | + protected function getItemToAdd($item) { |
|
45 | 45 | $itemO=$item; |
46 | - if($this->createCondition($item)===true){ |
|
46 | + if ($this->createCondition($item)===true) { |
|
47 | 47 | $itemO=$this->createItem($item); |
48 | 48 | } |
49 | 49 | return $itemO; |
50 | 50 | } |
51 | 51 | |
52 | - protected function setItemIdentifier($item,$classname,$index){ |
|
53 | - if($item instanceof BaseWidget){ |
|
54 | - if($item->getIdentifier()===""){ |
|
52 | + protected function setItemIdentifier($item, $classname, $index) { |
|
53 | + if ($item instanceof BaseWidget) { |
|
54 | + if ($item->getIdentifier()==="") { |
|
55 | 55 | $item->setIdentifier($classname."-".$this->identifier."-".$index); |
56 | 56 | } |
57 | 57 | } |
@@ -62,15 +62,15 @@ discard block |
||
62 | 62 | * @param HtmlDoubleElement|string|array $item |
63 | 63 | * @return \Ajax\common\html\HtmlDoubleElement |
64 | 64 | */ |
65 | - public function addItem($item){ |
|
65 | + public function addItem($item) { |
|
66 | 66 | $itemO=$this->getItemToAdd($item); |
67 | 67 | $this->addContent($itemO); |
68 | 68 | return $itemO; |
69 | 69 | } |
70 | 70 | |
71 | - public function insertItem($item,$position=0){ |
|
71 | + public function insertItem($item, $position=0) { |
|
72 | 72 | $itemO=$this->getItemToAdd($item); |
73 | - \array_splice( $this->content, $position, 0, array($itemO)); |
|
73 | + \array_splice($this->content, $position, 0, array($itemO)); |
|
74 | 74 | return $itemO; |
75 | 75 | } |
76 | 76 | |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | return $this; |
94 | 94 | } |
95 | 95 | |
96 | - public function removeItem($index){ |
|
96 | + public function removeItem($index) { |
|
97 | 97 | return array_splice($this->content, $index, 1); |
98 | 98 | } |
99 | 99 | |
100 | - public function count(){ |
|
100 | + public function count() { |
|
101 | 101 | return \sizeof($this->content); |
102 | 102 | } |
103 | 103 | |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | return $this->addItem($function($object)); |
109 | 109 | } |
110 | 110 | |
111 | - public function apply($callBack){ |
|
112 | - foreach ($this->content as $item){ |
|
111 | + public function apply($callBack) { |
|
112 | + foreach ($this->content as $item) { |
|
113 | 113 | $callBack($item); |
114 | 114 | } |
115 | 115 | return $this; |
@@ -129,23 +129,23 @@ discard block |
||
129 | 129 | */ |
130 | 130 | abstract protected function createItem($value); |
131 | 131 | |
132 | - protected function createCondition($value){ |
|
132 | + protected function createCondition($value) { |
|
133 | 133 | return \is_object($value)===false; |
134 | 134 | } |
135 | 135 | |
136 | - protected function contentAs($tagName){ |
|
137 | - foreach ($this->content as $item){ |
|
136 | + protected function contentAs($tagName) { |
|
137 | + foreach ($this->content as $item) { |
|
138 | 138 | $item->setTagName($tagName); |
139 | 139 | } |
140 | 140 | return $this; |
141 | 141 | } |
142 | 142 | |
143 | - public function setProperties($properties){ |
|
143 | + public function setProperties($properties) { |
|
144 | 144 | $i=0; |
145 | - foreach ($properties as $k=>$v){ |
|
145 | + foreach ($properties as $k=>$v) { |
|
146 | 146 | $c=$this->content[$i++]; |
147 | - if(isset($c)) |
|
148 | - $c->setProperty($k,$v); |
|
147 | + if (isset($c)) |
|
148 | + $c->setProperty($k, $v); |
|
149 | 149 | else |
150 | 150 | return $this; |
151 | 151 | } |
@@ -158,17 +158,17 @@ discard block |
||
158 | 158 | * @param array $values |
159 | 159 | * @return HtmlCollection |
160 | 160 | */ |
161 | - public function setPropertyValues($property,$values){ |
|
161 | + public function setPropertyValues($property, $values) { |
|
162 | 162 | $i=0; |
163 | - if(\is_array($values)===false){ |
|
164 | - $values=\array_fill(0, $this->count(),$values); |
|
163 | + if (\is_array($values)===false) { |
|
164 | + $values=\array_fill(0, $this->count(), $values); |
|
165 | 165 | } |
166 | - foreach ($values as $value){ |
|
166 | + foreach ($values as $value) { |
|
167 | 167 | $c=$this->content[$i++]; |
168 | - if(isset($c)){ |
|
169 | - $c->setProperty($property,$value); |
|
168 | + if (isset($c)) { |
|
169 | + $c->setProperty($property, $value); |
|
170 | 170 | } |
171 | - else{ |
|
171 | + else { |
|
172 | 172 | return $this; |
173 | 173 | } |
174 | 174 | } |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
179 | 179 | $index=0; |
180 | 180 | $classname=\strtolower(JReflection::shortClassName($this)); |
181 | - foreach ($this->content as $item){ |
|
182 | - $this->setItemIdentifier($item,$classname,$index++); |
|
181 | + foreach ($this->content as $item) { |
|
182 | + $this->setItemIdentifier($item, $classname, $index++); |
|
183 | 183 | } |
184 | - return parent::compile($js,$view); |
|
184 | + return parent::compile($js, $view); |
|
185 | 185 | } |
186 | 186 | |
187 | - public function getItemById($identifier){ |
|
187 | + public function getItemById($identifier) { |
|
188 | 188 | return $this->getElementById($identifier, $this->content); |
189 | 189 | } |
190 | 190 | } |
@@ -7,27 +7,27 @@ |
||
7 | 7 | |
8 | 8 | class HtmlTextarea extends HtmlDoubleElement { |
9 | 9 | |
10 | - public function __construct($identifier,$value=NULL,$placeholder=NULL,$rows=NULL) { |
|
10 | + public function __construct($identifier, $value=NULL, $placeholder=NULL, $rows=NULL) { |
|
11 | 11 | parent::__construct($identifier, "textarea"); |
12 | 12 | $this->setProperty("name", $identifier); |
13 | 13 | $this->setValue($value); |
14 | 14 | $this->setPlaceholder($placeholder); |
15 | - if(isset($rows)) |
|
15 | + if (isset($rows)) |
|
16 | 16 | $this->setRows($rows); |
17 | 17 | } |
18 | 18 | public function setValue($value) { |
19 | - if(isset($value)) |
|
19 | + if (isset($value)) |
|
20 | 20 | $this->setContent($value); |
21 | 21 | return $this; |
22 | 22 | } |
23 | 23 | |
24 | - public function setPlaceholder($value){ |
|
25 | - if(JString::isNotNull($value)) |
|
24 | + public function setPlaceholder($value) { |
|
25 | + if (JString::isNotNull($value)) |
|
26 | 26 | $this->setProperty("placeholder", $value); |
27 | 27 | return $this; |
28 | 28 | } |
29 | 29 | |
30 | - public function setRows($count){ |
|
30 | + public function setRows($count) { |
|
31 | 31 | $this->setProperty("rows", $count); |
32 | 32 | } |
33 | 33 | } |