@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | |
17 | 17 | private $ajaxCall; |
18 | 18 | |
19 | - public function __construct($type, $url, $params, $jsCallback = null, $method = 'post', $parameters = [], $prompt = NULL, $value = NULL) { |
|
19 | + public function __construct($type, $url, $params, $jsCallback=null, $method='post', $parameters=[], $prompt=NULL, $value=NULL) { |
|
20 | 20 | parent::__construct($type, $prompt, $value); |
21 | - $parameters = \array_merge([ |
|
21 | + $parameters=\array_merge([ |
|
22 | 22 | 'async' => false, |
23 | 23 | 'url' => $url, |
24 | 24 | 'params' => $params, |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | 'preventDefault' => false, |
30 | 30 | 'responseElement' => null |
31 | 31 | ], $parameters); |
32 | - $this->ajaxCall = new AjaxCall($method, $parameters); |
|
32 | + $this->ajaxCall=new AjaxCall($method, $parameters); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function compile(JsUtils $js) { |
36 | - $js->exec(Rule::custom($this->getType(), "function(value,ruleValue){var result=true;" . $this->ajaxCall->compile($js) . "return result;}"), true); |
|
36 | + $js->exec(Rule::custom($this->getType(), "function(value,ruleValue){var result=true;".$this->ajaxCall->compile($js)."return result;}"), true); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | \ No newline at end of file |
@@ -15,9 +15,9 @@ |
||
15 | 15 | |
16 | 16 | protected $jsFunction; |
17 | 17 | |
18 | - public function __construct($type, $jsFunction, $prompt = NULL, $value = NULL) { |
|
18 | + public function __construct($type, $jsFunction, $prompt=NULL, $value=NULL) { |
|
19 | 19 | parent::__construct($type, $prompt, $value); |
20 | - $this->jsFunction = $jsFunction; |
|
20 | + $this->jsFunction=$jsFunction; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function compile(JsUtils $js) { |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @version 1.001 |
9 | 9 | * Generates a JSON field validator |
10 | 10 | */ |
11 | -class FieldValidation implements \JsonSerializable{ |
|
11 | +class FieldValidation implements \JsonSerializable { |
|
12 | 12 | /** |
13 | 13 | * @var string |
14 | 14 | */ |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | protected $optional; |
33 | 33 | |
34 | - public function __construct($identifier){ |
|
34 | + public function __construct($identifier) { |
|
35 | 35 | $this->identifier=$identifier; |
36 | 36 | $this->rules=[]; |
37 | 37 | } |
@@ -55,31 +55,31 @@ discard block |
||
55 | 55 | * @param string $value |
56 | 56 | * @return Rule |
57 | 57 | */ |
58 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
59 | - if($type instanceof Rule) { |
|
60 | - $rule = $type; |
|
61 | - if($type instanceof CustomRule){ |
|
58 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
59 | + if ($type instanceof Rule) { |
|
60 | + $rule=$type; |
|
61 | + if ($type instanceof CustomRule) { |
|
62 | 62 | $this->customRules[]=$type; |
63 | 63 | $this->hasCustomRules=true; |
64 | 64 | } |
65 | - }elseif(\is_array($type)){ |
|
65 | + }elseif (\is_array($type)) { |
|
66 | 66 | $value=JArray::getValue($type, "value", 2); |
67 | 67 | $prompt=JArray::getValue($type, "prompt", 1); |
68 | 68 | $type=JArray::getValue($type, "type", 0); |
69 | - $rule=new Rule($type,$prompt,$value); |
|
70 | - }else { |
|
71 | - $rule = new Rule($type, $prompt, $value); |
|
69 | + $rule=new Rule($type, $prompt, $value); |
|
70 | + } else { |
|
71 | + $rule=new Rule($type, $prompt, $value); |
|
72 | 72 | } |
73 | 73 | $this->rules[]=$rule; |
74 | 74 | return $rule; |
75 | 75 | } |
76 | 76 | |
77 | - public function jsonSerialize(){ |
|
78 | - $result=["identifier"=>$this->identifier,"rules"=>$this->rules]; |
|
79 | - if($this->optional){ |
|
77 | + public function jsonSerialize() { |
|
78 | + $result=["identifier"=>$this->identifier, "rules"=>$this->rules]; |
|
79 | + if ($this->optional) { |
|
80 | 80 | $result["optional"]=true; |
81 | 81 | } |
82 | - if(isset($this->depends)){ |
|
82 | + if (isset($this->depends)) { |
|
83 | 83 | $result["depends"]=$this->depends; |
84 | 84 | } |
85 | 85 | return $result; |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | return $this; |
96 | 96 | } |
97 | 97 | |
98 | - public function compile(JsUtils $js){ |
|
99 | - if($this->hasCustomRules) { |
|
98 | + public function compile(JsUtils $js) { |
|
99 | + if ($this->hasCustomRules) { |
|
100 | 100 | foreach ($this->customRules as $rule) { |
101 | 101 | $rule->compile($js); |
102 | 102 | } |
@@ -62,12 +62,12 @@ |
||
62 | 62 | $this->customRules[]=$type; |
63 | 63 | $this->hasCustomRules=true; |
64 | 64 | } |
65 | - }elseif(\is_array($type)){ |
|
65 | + } elseif(\is_array($type)){ |
|
66 | 66 | $value=JArray::getValue($type, "value", 2); |
67 | 67 | $prompt=JArray::getValue($type, "prompt", 1); |
68 | 68 | $type=JArray::getValue($type, "type", 0); |
69 | 69 | $rule=new Rule($type,$prompt,$value); |
70 | - }else { |
|
70 | + } else { |
|
71 | 71 | $rule = new Rule($type, $prompt, $value); |
72 | 72 | } |
73 | 73 | $this->rules[]=$rule; |
@@ -16,34 +16,34 @@ discard block |
||
16 | 16 | use FieldTrait; |
17 | 17 | protected $_container; |
18 | 18 | protected $_validation; |
19 | - public function __construct($identifier, $field,$label=NULL) { |
|
20 | - parent::__construct($identifier, "div","field"); |
|
19 | + public function __construct($identifier, $field, $label=NULL) { |
|
20 | + parent::__construct($identifier, "div", "field"); |
|
21 | 21 | $this->content=array(); |
22 | - $this->_states=[State::ERROR,State::DISABLED]; |
|
23 | - if(isset($label) && $label!=="") |
|
22 | + $this->_states=[State::ERROR, State::DISABLED]; |
|
23 | + if (isset($label) && $label!=="") |
|
24 | 24 | $this->setLabel($label); |
25 | 25 | $this->setField($field); |
26 | 26 | $this->_validation=NULL; |
27 | 27 | } |
28 | 28 | |
29 | - public function addPointingLabel($label,$pointing=Direction::NONE){ |
|
30 | - $labelO=new HtmlLabel("",$label); |
|
29 | + public function addPointingLabel($label, $pointing=Direction::NONE) { |
|
30 | + $labelO=new HtmlLabel("", $label); |
|
31 | 31 | $labelO->setPointing($pointing); |
32 | - $this->addContent($labelO,$pointing==="below" || $pointing==="right"); |
|
32 | + $this->addContent($labelO, $pointing==="below" || $pointing==="right"); |
|
33 | 33 | return $labelO; |
34 | 34 | } |
35 | 35 | |
36 | - public function setLabel($label){ |
|
36 | + public function setLabel($label) { |
|
37 | 37 | $labelO=$label; |
38 | - if(\is_string($label)){ |
|
39 | - $labelO=new HtmlSemDoubleElement("","label",""); |
|
38 | + if (\is_string($label)) { |
|
39 | + $labelO=new HtmlSemDoubleElement("", "label", ""); |
|
40 | 40 | $labelO->setContent($label); |
41 | - $labelO->setProperty("for", \str_replace("field-", "",$this->identifier)); |
|
41 | + $labelO->setProperty("for", \str_replace("field-", "", $this->identifier)); |
|
42 | 42 | } |
43 | 43 | $this->content["label"]=$labelO; |
44 | 44 | } |
45 | 45 | |
46 | - public function setField($field){ |
|
46 | + public function setField($field) { |
|
47 | 47 | $this->content["field"]=$field; |
48 | 48 | } |
49 | 49 | |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * Returns the label or null |
52 | 52 | * @return mixed |
53 | 53 | */ |
54 | - public function getLabel(){ |
|
55 | - if(\array_key_exists("label", $this->content)) |
|
54 | + public function getLabel() { |
|
55 | + if (\array_key_exists("label", $this->content)) |
|
56 | 56 | return $this->content["label"]; |
57 | 57 | } |
58 | 58 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * Return the field |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | - public function getField(){ |
|
63 | + public function getField() { |
|
64 | 64 | return $this->content["field"]; |
65 | 65 | } |
66 | 66 | |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | * Return the field with data |
69 | 69 | * @return mixed |
70 | 70 | */ |
71 | - public function getDataField(){ |
|
71 | + public function getDataField() { |
|
72 | 72 | return $this->content["field"]; |
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
76 | 76 | * puts the label before or behind |
77 | 77 | */ |
78 | - public function swapLabel(){ |
|
78 | + public function swapLabel() { |
|
79 | 79 | $label=$this->getLabel(); |
80 | 80 | unset($this->content["label"]); |
81 | 81 | $this->content["label"]=$label; |
@@ -86,31 +86,31 @@ discard block |
||
86 | 86 | * @param int $width |
87 | 87 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
88 | 88 | */ |
89 | - public function setWidth($width){ |
|
90 | - if(\is_int($width)){ |
|
89 | + public function setWidth($width) { |
|
90 | + if (\is_int($width)) { |
|
91 | 91 | $width=Wide::getConstants()["W".$width]; |
92 | 92 | } |
93 | 93 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
94 | - if(isset($this->_container)){ |
|
94 | + if (isset($this->_container)) { |
|
95 | 95 | $this->_container->setEqualWidth(false); |
96 | 96 | } |
97 | - return $this->addToPropertyCtrl("class", "wide",array("wide")); |
|
97 | + return $this->addToPropertyCtrl("class", "wide", array("wide")); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Field displays an error state |
102 | 102 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
103 | 103 | */ |
104 | - public function setError(){ |
|
104 | + public function setError() { |
|
105 | 105 | return $this->addToProperty("class", "error"); |
106 | 106 | } |
107 | 107 | |
108 | - public function setInline(){ |
|
108 | + public function setInline() { |
|
109 | 109 | return $this->addToProperty("class", "inline"); |
110 | 110 | } |
111 | 111 | |
112 | - public function jsState($state){ |
|
113 | - return $this->jsDoJquery("addClass",$state); |
|
112 | + public function jsState($state) { |
|
113 | + return $this->jsDoJquery("addClass", $state); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | public function setContainer($_container) { |
@@ -118,49 +118,49 @@ discard block |
||
118 | 118 | return $this; |
119 | 119 | } |
120 | 120 | |
121 | - public function setReadonly(){ |
|
121 | + public function setReadonly() { |
|
122 | 122 | $this->getDataField()->setProperty("readonly", ""); |
123 | 123 | } |
124 | 124 | |
125 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
125 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
126 | 126 | $field=$this->getDataField(); |
127 | - if(isset($field)){ |
|
128 | - if(!isset($this->_validation)){ |
|
127 | + if (isset($field)) { |
|
128 | + if (!isset($this->_validation)) { |
|
129 | 129 | $this->_validation=new FieldValidation($field->getIdentifier()); |
130 | 130 | } |
131 | - if($type==="empty"){ |
|
132 | - $this->addToProperty("class","required"); |
|
131 | + if ($type==="empty") { |
|
132 | + $this->addToProperty("class", "required"); |
|
133 | 133 | } |
134 | - $this->_validation->addRule($type,$prompt,$value); |
|
134 | + $this->_validation->addRule($type, $prompt, $value); |
|
135 | 135 | } |
136 | 136 | return $this; |
137 | 137 | } |
138 | 138 | |
139 | - public function setOptional($optional=true){ |
|
139 | + public function setOptional($optional=true) { |
|
140 | 140 | $field=$this->getDataField(); |
141 | - if(isset($field)){ |
|
142 | - if(!isset($this->_validation)){ |
|
141 | + if (isset($field)) { |
|
142 | + if (!isset($this->_validation)) { |
|
143 | 143 | $this->_validation=new FieldValidation($field->getIdentifier()); |
144 | 144 | } |
145 | 145 | $this->_validation->setOptional($optional); |
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | - public function addRules(array $rules){ |
|
150 | - foreach ($rules as $rule){ |
|
149 | + public function addRules(array $rules) { |
|
150 | + foreach ($rules as $rule) { |
|
151 | 151 | $this->addRule($rule); |
152 | 152 | } |
153 | 153 | return $this; |
154 | 154 | } |
155 | 155 | |
156 | - public function setRules(array $rules){ |
|
156 | + public function setRules(array $rules) { |
|
157 | 157 | $this->_validation=null; |
158 | 158 | return $this->addRules($rules); |
159 | 159 | } |
160 | 160 | |
161 | - public function addIcon($icon,$direction=Direction::LEFT){ |
|
161 | + public function addIcon($icon, $direction=Direction::LEFT) { |
|
162 | 162 | $field=$this->getField(); |
163 | - return $field->addIcon($icon,$direction); |
|
163 | + return $field->addIcon($icon, $direction); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | public function getValidation() { |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | } |
173 | 173 | |
174 | 174 | public function run(JsUtils $js) { |
175 | - if(isset($this->_validation)){ |
|
175 | + if (isset($this->_validation)) { |
|
176 | 176 | $this->_validation->compile($js); |
177 | 177 | } |
178 | 178 | return parent::run($js); |