@@ -13,28 +13,28 @@ discard block |
||
13 | 13 | * @author jc |
14 | 14 | * |
15 | 15 | */ |
16 | -trait FormTrait{ |
|
16 | +trait FormTrait { |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @return HtmlForm |
20 | 20 | */ |
21 | 21 | abstract protected function getForm(); |
22 | 22 | |
23 | - protected function addCompoValidation($compo,$field){ |
|
23 | + protected function addCompoValidation($compo, $field) { |
|
24 | 24 | $validation=$field->getValidation(); |
25 | - if(isset($validation)){ |
|
25 | + if (isset($validation)) { |
|
26 | 26 | $validation->setIdentifier($field->getDataField()->getIdentifier()); |
27 | 27 | $compo->addFieldValidation($validation); |
28 | 28 | } |
29 | 29 | return $compo; |
30 | 30 | } |
31 | 31 | |
32 | - protected function _runValidationParams(&$compo,JsUtils $js=NULL){ |
|
32 | + protected function _runValidationParams(&$compo, JsUtils $js=NULL) { |
|
33 | 33 | $form=$this->getForm(); |
34 | 34 | $params=$form->getValidationParams(); |
35 | - if(isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall){ |
|
35 | + if (isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall) { |
|
36 | 36 | $compilation=$params["_ajaxSubmit"]->compile($js); |
37 | - $compilation=str_ireplace("\"","%quote%", $compilation); |
|
37 | + $compilation=str_ireplace("\"", "%quote%", $compilation); |
|
38 | 38 | $this->onSuccess($compilation); |
39 | 39 | $form->removeValidationParam("_ajaxSubmit"); |
40 | 40 | } |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | return $this; |
53 | 53 | } |
54 | 54 | |
55 | - public function setAttached($value=true){ |
|
55 | + public function setAttached($value=true) { |
|
56 | 56 | $form=$this->getForm(); |
57 | - if($value) |
|
58 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
57 | + if ($value) |
|
58 | + $form->addToPropertyCtrl("class", "attached", array("attached")); |
|
59 | 59 | return $form; |
60 | 60 | } |
61 | 61 | |
62 | - public function addErrorMessage(){ |
|
62 | + public function addErrorMessage() { |
|
63 | 63 | return $this->getForm()->addContent((new HtmlMessage(""))->setError()); |
64 | 64 | } |
65 | 65 | |
@@ -75,41 +75,41 @@ discard block |
||
75 | 75 | * @param array $parameters |
76 | 76 | * @return HtmlForm |
77 | 77 | */ |
78 | - public function submitOn($event,$identifierOrElement,$url,$responseElement,$parameters=NULL){ |
|
78 | + public function submitOn($event, $identifierOrElement, $url, $responseElement, $parameters=NULL) { |
|
79 | 79 | $form=$this->getForm(); |
80 | - if($identifierOrElement instanceof BaseHtml) |
|
80 | + if ($identifierOrElement instanceof BaseHtml) |
|
81 | 81 | $elem=$identifierOrElement; |
82 | 82 | else |
83 | 83 | $elem=$form->getElementById($identifierOrElement, $form->getContent()); |
84 | - if(isset($elem)){ |
|
85 | - $this->_buttonAsSubmit($elem, $event,$url,$responseElement,$parameters); |
|
84 | + if (isset($elem)) { |
|
85 | + $this->_buttonAsSubmit($elem, $event, $url, $responseElement, $parameters); |
|
86 | 86 | } |
87 | 87 | return $form; |
88 | 88 | } |
89 | 89 | |
90 | - public function submitOnClick($identifier,$url,$responseElement,$parameters=NULL){ |
|
91 | - return $this->submitOn("click", $identifier, $url, $responseElement,$parameters); |
|
90 | + public function submitOnClick($identifier, $url, $responseElement, $parameters=NULL) { |
|
91 | + return $this->submitOn("click", $identifier, $url, $responseElement, $parameters); |
|
92 | 92 | } |
93 | 93 | |
94 | - public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){ |
|
95 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
96 | - return $this->_buttonAsSubmit($bt, "click",$url,$responseElement,$parameters); |
|
94 | + public function addSubmit($identifier, $value, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $parameters=NULL) { |
|
95 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
96 | + return $this->_buttonAsSubmit($bt, "click", $url, $responseElement, $parameters); |
|
97 | 97 | } |
98 | 98 | |
99 | - protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL){ |
|
99 | + protected function _buttonAsSubmit(BaseHtml&$button, $event, $url, $responseElement=NULL, $parameters=NULL) { |
|
100 | 100 | $form=$this->getForm(); |
101 | - if(isset($url) && isset($responseElement)){ |
|
102 | - $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true); |
|
103 | - $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true]; |
|
104 | - if(\is_array($parameters)) |
|
105 | - $params=\array_merge($params,$parameters); |
|
101 | + if (isset($url) && isset($responseElement)) { |
|
102 | + $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');", true, true); |
|
103 | + $params=["form"=>$form->getIdentifier(), "responseElement"=>$responseElement, "url"=>$url, "stopPropagation"=>true]; |
|
104 | + if (\is_array($parameters)) |
|
105 | + $params=\array_merge($params, $parameters); |
|
106 | 106 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
107 | 107 | } |
108 | 108 | return $button; |
109 | 109 | } |
110 | 110 | |
111 | - public function addReset($identifier,$value,$cssStyle=NULL){ |
|
112 | - $bt=$this->getForm()->addButton($identifier, $value,$cssStyle); |
|
111 | + public function addReset($identifier, $value, $cssStyle=NULL) { |
|
112 | + $bt=$this->getForm()->addButton($identifier, $value, $cssStyle); |
|
113 | 113 | $bt->setProperty("type", "reset"); |
114 | 114 | return $bt; |
115 | 115 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param string $jsCode |
120 | 120 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
121 | 121 | */ |
122 | - public function onValid($jsCode){ |
|
122 | + public function onValid($jsCode) { |
|
123 | 123 | $form=$this->getForm(); |
124 | 124 | $form->addValidationParam("onValid", "%function(){".$jsCode."}%"); |
125 | 125 | return $form; |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | * @param string $jsCode can use event and fields parameters |
131 | 131 | * @return HtmlForm |
132 | 132 | */ |
133 | - public function onSuccess($jsCode){ |
|
133 | + public function onSuccess($jsCode) { |
|
134 | 134 | $form=$this->getForm(); |
135 | - $form->addValidationParam("onSuccess", $jsCode,"%function(event,fields){","}%"); |
|
135 | + $form->addValidationParam("onSuccess", $jsCode, "%function(event,fields){", "}%"); |
|
136 | 136 | return $form; |
137 | 137 | } |
138 | 138 | } |
139 | 139 | \ No newline at end of file |
@@ -54,8 +54,9 @@ discard block |
||
54 | 54 | |
55 | 55 | public function setAttached($value=true){ |
56 | 56 | $form=$this->getForm(); |
57 | - if($value) |
|
58 | - $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
57 | + if($value) { |
|
58 | + $form->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
59 | + } |
|
59 | 60 | return $form; |
60 | 61 | } |
61 | 62 | |
@@ -77,10 +78,11 @@ discard block |
||
77 | 78 | */ |
78 | 79 | public function submitOn($event,$identifierOrElement,$url,$responseElement,$parameters=NULL){ |
79 | 80 | $form=$this->getForm(); |
80 | - if($identifierOrElement instanceof BaseHtml) |
|
81 | - $elem=$identifierOrElement; |
|
82 | - else |
|
83 | - $elem=$form->getElementById($identifierOrElement, $form->getContent()); |
|
81 | + if($identifierOrElement instanceof BaseHtml) { |
|
82 | + $elem=$identifierOrElement; |
|
83 | + } else { |
|
84 | + $elem=$form->getElementById($identifierOrElement, $form->getContent()); |
|
85 | + } |
|
84 | 86 | if(isset($elem)){ |
85 | 87 | $this->_buttonAsSubmit($elem, $event,$url,$responseElement,$parameters); |
86 | 88 | } |
@@ -101,8 +103,9 @@ discard block |
||
101 | 103 | if(isset($url) && isset($responseElement)){ |
102 | 104 | $button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true); |
103 | 105 | $params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true]; |
104 | - if(\is_array($parameters)) |
|
105 | - $params=\array_merge($params,$parameters); |
|
106 | + if(\is_array($parameters)) { |
|
107 | + $params=\array_merge($params,$parameters); |
|
108 | + } |
|
106 | 109 | $form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params)); |
107 | 110 | } |
108 | 111 | return $button; |
@@ -7,50 +7,50 @@ |
||
7 | 7 | |
8 | 8 | class HtmlSticky extends HtmlSemDoubleElement { |
9 | 9 | |
10 | - public function __construct($identifier,$context=NULL,$content=NULL) { |
|
10 | + public function __construct($identifier, $context=NULL, $content=NULL) { |
|
11 | 11 | parent::__construct($identifier, "div", "ui sticky", $content); |
12 | - if(isset($content)) |
|
12 | + if (isset($content)) |
|
13 | 13 | $this->setContext($context); |
14 | 14 | } |
15 | 15 | |
16 | - public function setContext($context){ |
|
16 | + public function setContext($context) { |
|
17 | 17 | $this->_params["context"]=$context; |
18 | 18 | return $this; |
19 | 19 | } |
20 | 20 | |
21 | - public function setFixed($value=NULL){ |
|
21 | + public function setFixed($value=NULL) { |
|
22 | 22 | $fixed="fixed"; |
23 | - if(isset($value)) |
|
23 | + if (isset($value)) |
|
24 | 24 | $fixed.=" ".$value; |
25 | - return $this->addToProperty("class",$fixed); |
|
25 | + return $this->addToProperty("class", $fixed); |
|
26 | 26 | } |
27 | 27 | |
28 | - public function setBound($value=NULL){ |
|
28 | + public function setBound($value=NULL) { |
|
29 | 29 | $bound="bound"; |
30 | - if(isset($value)) |
|
30 | + if (isset($value)) |
|
31 | 31 | $bound.=" ".$value; |
32 | - return $this->addToProperty("class",$bound); |
|
32 | + return $this->addToProperty("class", $bound); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * {@inheritDoc} |
37 | 37 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run() |
38 | 38 | */ |
39 | - public function run(JsUtils $js){ |
|
39 | + public function run(JsUtils $js) { |
|
40 | 40 | parent::run($js); |
41 | - return $js->semantic()->sticky("#".$this->identifier,$this->_params); |
|
41 | + return $js->semantic()->sticky("#".$this->identifier, $this->_params); |
|
42 | 42 | } |
43 | 43 | |
44 | - public function setOffset($offset=0){ |
|
44 | + public function setOffset($offset=0) { |
|
45 | 45 | $this->_params["offset"]=$offset; |
46 | 46 | return $this; |
47 | 47 | } |
48 | 48 | |
49 | 49 | |
50 | 50 | |
51 | - public function setDebug($verbose=NULL){ |
|
51 | + public function setDebug($verbose=NULL) { |
|
52 | 52 | $this->_params["debug"]=true; |
53 | - if(isset($verbose)) |
|
53 | + if (isset($verbose)) |
|
54 | 54 | $this->_params["verbose"]=true; |
55 | 55 | return $this; |
56 | 56 | } |
@@ -9,8 +9,9 @@ discard block |
||
9 | 9 | |
10 | 10 | public function __construct($identifier,$context=NULL,$content=NULL) { |
11 | 11 | parent::__construct($identifier, "div", "ui sticky", $content); |
12 | - if(isset($content)) |
|
13 | - $this->setContext($context); |
|
12 | + if(isset($content)) { |
|
13 | + $this->setContext($context); |
|
14 | + } |
|
14 | 15 | } |
15 | 16 | |
16 | 17 | public function setContext($context){ |
@@ -20,15 +21,17 @@ discard block |
||
20 | 21 | |
21 | 22 | public function setFixed($value=NULL){ |
22 | 23 | $fixed="fixed"; |
23 | - if(isset($value)) |
|
24 | - $fixed.=" ".$value; |
|
24 | + if(isset($value)) { |
|
25 | + $fixed.=" ".$value; |
|
26 | + } |
|
25 | 27 | return $this->addToProperty("class",$fixed); |
26 | 28 | } |
27 | 29 | |
28 | 30 | public function setBound($value=NULL){ |
29 | 31 | $bound="bound"; |
30 | - if(isset($value)) |
|
31 | - $bound.=" ".$value; |
|
32 | + if(isset($value)) { |
|
33 | + $bound.=" ".$value; |
|
34 | + } |
|
32 | 35 | return $this->addToProperty("class",$bound); |
33 | 36 | } |
34 | 37 | |
@@ -50,8 +53,9 @@ discard block |
||
50 | 53 | |
51 | 54 | public function setDebug($verbose=NULL){ |
52 | 55 | $this->_params["debug"]=true; |
53 | - if(isset($verbose)) |
|
54 | - $this->_params["verbose"]=true; |
|
56 | + if(isset($verbose)) { |
|
57 | + $this->_params["verbose"]=true; |
|
58 | + } |
|
55 | 59 | return $this; |
56 | 60 | } |
57 | 61 | } |
58 | 62 | \ No newline at end of file |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | $this->setLabel($label); |
20 | 20 | } |
21 | 21 | |
22 | - public function setChecked($value=true){ |
|
23 | - if($value===true){ |
|
22 | + public function setChecked($value=true) { |
|
23 | + if ($value===true) { |
|
24 | 24 | $this->getField()->setProperty("checked", "checked"); |
25 | - }else{ |
|
25 | + } else { |
|
26 | 26 | $this->getField()->removeProperty("checked"); |
27 | 27 | } |
28 | 28 | return $this; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @return \Ajax\semantic\html\collections\form\AbstractHtmlFormRadioCheckbox |
85 | 85 | */ |
86 | 86 | public function attachEvent($selector, $action=NULL) { |
87 | - if (isset($action)||\is_numeric($action)===true) { |
|
87 | + if (isset($action) || \is_numeric($action)===true) { |
|
88 | 88 | $js='$("#%identifier%").checkbox("attach events", "'.$selector.'", "'.$action.'");'; |
89 | 89 | } else { |
90 | 90 | $js='$("#%identifier%").checkbox("attach events", "'.$selector.'");'; |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function attachEvents($events=array()) { |
102 | 102 | if (\is_array($events)) { |
103 | - foreach ( $events as $action => $selector ) { |
|
103 | + foreach ($events as $action => $selector) { |
|
104 | 104 | $this->attachEvent($selector, $action); |
105 | 105 | } |
106 | 106 | } |
@@ -111,24 +111,24 @@ discard block |
||
111 | 111 | return $this->addToProperty("class", "fitted"); |
112 | 112 | } |
113 | 113 | |
114 | - public function setOnChecked($jsCode){ |
|
114 | + public function setOnChecked($jsCode) { |
|
115 | 115 | $this->_params["onChecked"]=$jsCode; |
116 | 116 | return $this; |
117 | 117 | } |
118 | 118 | |
119 | - public function setOnUnchecked($jsCode){ |
|
119 | + public function setOnUnchecked($jsCode) { |
|
120 | 120 | $this->_params["onUnchecked"]=$jsCode; |
121 | 121 | return $this; |
122 | 122 | } |
123 | 123 | |
124 | - public function setOnChange($jsCode){ |
|
124 | + public function setOnChange($jsCode) { |
|
125 | 125 | $this->_params["onChange"]=$jsCode; |
126 | 126 | return $this; |
127 | 127 | } |
128 | 128 | |
129 | 129 | public function run(JsUtils $js) { |
130 | - if(!isset($this->_bsComponent)) |
|
131 | - $this->_bsComponent=$js->semantic()->checkbox("#" . $this->identifier, $this->_params); |
|
130 | + if (!isset($this->_bsComponent)) |
|
131 | + $this->_bsComponent=$js->semantic()->checkbox("#".$this->identifier, $this->_params); |
|
132 | 132 | return parent::run($js); |
133 | 133 | } |
134 | 134 | } |
135 | 135 | \ No newline at end of file |
@@ -15,14 +15,15 @@ discard block |
||
15 | 15 | $field=new \Ajax\common\html\html5\HtmlInput($identifier, $inputType, $value); |
16 | 16 | $field->setProperty("name", $name); |
17 | 17 | $this->setField($field); |
18 | - if (isset($label)) |
|
19 | - $this->setLabel($label); |
|
18 | + if (isset($label)) { |
|
19 | + $this->setLabel($label); |
|
20 | + } |
|
20 | 21 | } |
21 | 22 | |
22 | 23 | public function setChecked($value=true){ |
23 | 24 | if($value===true){ |
24 | 25 | $this->getField()->setProperty("checked", "checked"); |
25 | - }else{ |
|
26 | + } else{ |
|
26 | 27 | $this->getField()->removeProperty("checked"); |
27 | 28 | } |
28 | 29 | return $this; |
@@ -51,8 +52,9 @@ discard block |
||
51 | 52 | * @return mixed |
52 | 53 | */ |
53 | 54 | public function getLabel() { |
54 | - if (\array_key_exists("label", $this->content)) |
|
55 | - return $this->content["label"]; |
|
55 | + if (\array_key_exists("label", $this->content)) { |
|
56 | + return $this->content["label"]; |
|
57 | + } |
|
56 | 58 | } |
57 | 59 | |
58 | 60 | /** |
@@ -127,8 +129,9 @@ discard block |
||
127 | 129 | } |
128 | 130 | |
129 | 131 | public function run(JsUtils $js) { |
130 | - if(!isset($this->_bsComponent)) |
|
131 | - $this->_bsComponent=$js->semantic()->checkbox("#" . $this->identifier, $this->_params); |
|
132 | + if(!isset($this->_bsComponent)) { |
|
133 | + $this->_bsComponent=$js->semantic()->checkbox("#" . $this->identifier, $this->_params); |
|
134 | + } |
|
132 | 135 | return parent::run($js); |
133 | 136 | } |
134 | 137 | } |
135 | 138 | \ No newline at end of file |
@@ -249,6 +249,9 @@ discard block |
||
249 | 249 | return $this; |
250 | 250 | } |
251 | 251 | |
252 | + /** |
|
253 | + * @param integer $index |
|
254 | + */ |
|
252 | 255 | public static function setIndex($index) { |
253 | 256 | self::$index=$index; |
254 | 257 | } |
@@ -307,7 +310,7 @@ discard block |
||
307 | 310 | * The $callback function can take the following arguments : $field=>the compiled field, $instance : the active instance of the object, $index: the field position |
308 | 311 | * @param int $index postion of the compiled field |
309 | 312 | * @param callable $callback function called after the field compilation |
310 | - * @return \Ajax\semantic\widgets\datatable\InstanceViewer |
|
313 | + * @return InstanceViewer |
|
311 | 314 | */ |
312 | 315 | public function afterCompile($index,$callback){ |
313 | 316 | $this->afterCompile[$index]=$callback; |
@@ -19,215 +19,215 @@ discard block |
||
19 | 19 | |
20 | 20 | public static $index=0; |
21 | 21 | |
22 | - public function __construct($identifier,$instance=NULL,$captions=NULL){ |
|
22 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
23 | 23 | $this->widgetIdentifier=$identifier; |
24 | 24 | $this->values=[]; |
25 | 25 | $this->afterCompile=[]; |
26 | - if(isset($instance)) |
|
26 | + if (isset($instance)) |
|
27 | 27 | $this->setInstance($instance); |
28 | 28 | $this->setCaptions($captions); |
29 | 29 | $this->captionCallback=NULL; |
30 | - $this->defaultValueFunction=function($name,$value){return $value;}; |
|
30 | + $this->defaultValueFunction=function($name, $value) {return $value; }; |
|
31 | 31 | } |
32 | 32 | |
33 | - public function moveFieldTo($from,$to){ |
|
34 | - if(JArray::moveElementTo($this->visibleProperties, $from, $to)){ |
|
33 | + public function moveFieldTo($from, $to) { |
|
34 | + if (JArray::moveElementTo($this->visibleProperties, $from, $to)) { |
|
35 | 35 | return JArray::moveElementTo($this->values, $from, $to); |
36 | 36 | } |
37 | 37 | return false; |
38 | 38 | } |
39 | 39 | |
40 | - public function swapFields($index1,$index2){ |
|
41 | - if(JArray::swapElements($this->visibleProperties, $index1, $index2)){ |
|
40 | + public function swapFields($index1, $index2) { |
|
41 | + if (JArray::swapElements($this->visibleProperties, $index1, $index2)) { |
|
42 | 42 | return JArray::swapElements($this->values, $index1, $index2); |
43 | 43 | } |
44 | 44 | return false; |
45 | 45 | } |
46 | 46 | |
47 | - public function removeField($index){ |
|
48 | - \array_splice($this->visibleProperties,$index,1); |
|
49 | - \array_splice($this->values,$index,1); |
|
50 | - \array_splice($this->captions,$index,1); |
|
47 | + public function removeField($index) { |
|
48 | + \array_splice($this->visibleProperties, $index, 1); |
|
49 | + \array_splice($this->values, $index, 1); |
|
50 | + \array_splice($this->captions, $index, 1); |
|
51 | 51 | return $this; |
52 | 52 | } |
53 | 53 | |
54 | - public function getValues(){ |
|
54 | + public function getValues() { |
|
55 | 55 | $values=[]; |
56 | 56 | $index=0; |
57 | 57 | $count=$this->count(); |
58 | - while($index<$count){ |
|
58 | + while ($index<$count) { |
|
59 | 59 | $values[]=$this->getValue($index++); |
60 | 60 | } |
61 | 61 | return $values; |
62 | 62 | } |
63 | 63 | |
64 | - public function getIdentifier($index=NULL){ |
|
65 | - if(!isset($index)) |
|
64 | + public function getIdentifier($index=NULL) { |
|
65 | + if (!isset($index)) |
|
66 | 66 | $index=self::$index; |
67 | 67 | $value=$index; |
68 | - if(isset($this->values["identifier"])){ |
|
69 | - if(\is_string($this->values["identifier"])) |
|
68 | + if (isset($this->values["identifier"])) { |
|
69 | + if (\is_string($this->values["identifier"])) |
|
70 | 70 | $value=JReflection::callMethod($this->instance, $this->values["identifier"], []); |
71 | 71 | else |
72 | - $value=$this->values["identifier"]($index,$this->instance); |
|
72 | + $value=$this->values["identifier"]($index, $this->instance); |
|
73 | 73 | } |
74 | 74 | return $value; |
75 | 75 | } |
76 | 76 | |
77 | - public function getValue($index){ |
|
77 | + public function getValue($index) { |
|
78 | 78 | $property=$this->properties[$index]; |
79 | 79 | return $this->_getValue($property, $index); |
80 | 80 | } |
81 | 81 | |
82 | - protected function _beforeAddProperty($index,&$field){ |
|
82 | + protected function _beforeAddProperty($index, &$field) { |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | |
86 | - protected function _getDefaultValue($name,$value,$index){ |
|
86 | + protected function _getDefaultValue($name, $value, $index) { |
|
87 | 87 | $func=$this->defaultValueFunction; |
88 | - return $func($name,$value,$index,$this->instance); |
|
88 | + return $func($name, $value, $index, $this->instance); |
|
89 | 89 | } |
90 | 90 | |
91 | - protected function _getPropertyValue(\ReflectionProperty $property,$index){ |
|
91 | + protected function _getPropertyValue(\ReflectionProperty $property, $index) { |
|
92 | 92 | $property->setAccessible(true); |
93 | 93 | return $property->getValue($this->instance); |
94 | 94 | } |
95 | 95 | |
96 | - protected function _getValue($property,$index){ |
|
96 | + protected function _getValue($property, $index) { |
|
97 | 97 | $value=null; |
98 | 98 | $propertyName=$property; |
99 | - if($property instanceof \ReflectionProperty){ |
|
99 | + if ($property instanceof \ReflectionProperty) { |
|
100 | 100 | $value=$this->_getPropertyValue($property, $index); |
101 | 101 | $propertyName=$property->getName(); |
102 | - }elseif(\is_callable($property)) |
|
102 | + }elseif (\is_callable($property)) |
|
103 | 103 | $value=$property($this->instance); |
104 | - elseif(\is_array($property)){ |
|
105 | - $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
|
104 | + elseif (\is_array($property)) { |
|
105 | + $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property); |
|
106 | 106 | $value=\implode("", $values); |
107 | - }elseif(\is_string($property)){ |
|
107 | + }elseif (\is_string($property)) { |
|
108 | 108 | $value=$property; |
109 | - if(isset($this->instance->{$property})){ |
|
109 | + if (isset($this->instance->{$property})) { |
|
110 | 110 | $value=$this->instance->{$property}; |
111 | - }elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){ |
|
111 | + }elseif (\method_exists($this->instance, $getter=JReflection::getterName($property))) { |
|
112 | 112 | $value=JReflection::callMethod($this->instance, $getter, []); |
113 | 113 | } |
114 | 114 | } |
115 | 115 | return $this->_postGetValue($index, $propertyName, $value); |
116 | 116 | } |
117 | 117 | |
118 | - protected function _postGetValue($index,$propertyName,$value){ |
|
119 | - if(isset($this->values[$index])){ |
|
120 | - $value= $this->values[$index]($value,$this->instance,$index); |
|
121 | - }else{ |
|
122 | - $value=$this->_getDefaultValue($propertyName,$value, $index); |
|
118 | + protected function _postGetValue($index, $propertyName, $value) { |
|
119 | + if (isset($this->values[$index])) { |
|
120 | + $value=$this->values[$index]($value, $this->instance, $index); |
|
121 | + } else { |
|
122 | + $value=$this->_getDefaultValue($propertyName, $value, $index); |
|
123 | 123 | } |
124 | - if(isset($this->afterCompile[$index])){ |
|
125 | - if(\is_callable($this->afterCompile[$index])){ |
|
126 | - $this->afterCompile[$index]($value,$this->instance,$index); |
|
124 | + if (isset($this->afterCompile[$index])) { |
|
125 | + if (\is_callable($this->afterCompile[$index])) { |
|
126 | + $this->afterCompile[$index]($value, $this->instance, $index); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | return $value; |
130 | 130 | } |
131 | 131 | |
132 | - public function insertField($index,$field){ |
|
133 | - array_splice( $this->visibleProperties, $index, 0, $field ); |
|
132 | + public function insertField($index, $field) { |
|
133 | + array_splice($this->visibleProperties, $index, 0, $field); |
|
134 | 134 | return $this; |
135 | 135 | } |
136 | 136 | |
137 | - public function insertInField($index,$field){ |
|
137 | + public function insertInField($index, $field) { |
|
138 | 138 | $vb=$this->visibleProperties; |
139 | - if(isset($vb[$index])){ |
|
140 | - if(\is_array($vb[$index])){ |
|
139 | + if (isset($vb[$index])) { |
|
140 | + if (\is_array($vb[$index])) { |
|
141 | 141 | $this->visibleProperties[$index][]=$field; |
142 | - }else{ |
|
143 | - $this->visibleProperties[$index]=[$vb[$index],$field]; |
|
142 | + } else { |
|
143 | + $this->visibleProperties[$index]=[$vb[$index], $field]; |
|
144 | 144 | } |
145 | - }else{ |
|
145 | + } else { |
|
146 | 146 | return $this->insertField($index, $field); |
147 | 147 | } |
148 | 148 | return $this; |
149 | 149 | } |
150 | 150 | |
151 | - public function addField($field){ |
|
151 | + public function addField($field) { |
|
152 | 152 | $this->visibleProperties[]=$field; |
153 | 153 | return $this; |
154 | 154 | } |
155 | 155 | |
156 | - public function count(){ |
|
156 | + public function count() { |
|
157 | 157 | return \sizeof($this->properties); |
158 | 158 | } |
159 | 159 | |
160 | - public function visiblePropertiesCount(){ |
|
160 | + public function visiblePropertiesCount() { |
|
161 | 161 | return \sizeof($this->visibleProperties); |
162 | 162 | } |
163 | 163 | |
164 | - public function getProperty($index){ |
|
164 | + public function getProperty($index) { |
|
165 | 165 | return $this->properties[$index]; |
166 | 166 | } |
167 | 167 | |
168 | - public function getFieldName($index){ |
|
168 | + public function getFieldName($index) { |
|
169 | 169 | $property=$this->getProperty($index); |
170 | - if($property instanceof \ReflectionProperty){ |
|
170 | + if ($property instanceof \ReflectionProperty) { |
|
171 | 171 | $result=$property->getName(); |
172 | - }elseif(\is_callable($property)){ |
|
172 | + }elseif (\is_callable($property)) { |
|
173 | 173 | $result=$this->visibleProperties[$index]; |
174 | - }else{ |
|
174 | + } else { |
|
175 | 175 | $result=$property; |
176 | 176 | } |
177 | 177 | return $result; |
178 | 178 | } |
179 | 179 | |
180 | 180 | |
181 | - protected function showableProperty(\ReflectionProperty $rProperty){ |
|
182 | - return JString::startswith($rProperty->getName(),"_")===false; |
|
181 | + protected function showableProperty(\ReflectionProperty $rProperty) { |
|
182 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | public function setInstance($instance) { |
186 | - if(\is_string($instance)){ |
|
186 | + if (\is_string($instance)) { |
|
187 | 187 | $instance=new $instance(); |
188 | 188 | } |
189 | 189 | $this->instance=$instance; |
190 | 190 | $this->properties=[]; |
191 | 191 | $this->reflect=new \ReflectionClass($instance); |
192 | - if(\sizeof($this->visibleProperties)===0){ |
|
192 | + if (\sizeof($this->visibleProperties)===0) { |
|
193 | 193 | $this->properties=$this->getDefaultProperties(); |
194 | - }else{ |
|
195 | - foreach ($this->visibleProperties as $property){ |
|
194 | + } else { |
|
195 | + foreach ($this->visibleProperties as $property) { |
|
196 | 196 | $this->setInstanceProperty($property); |
197 | 197 | } |
198 | 198 | } |
199 | 199 | return $this; |
200 | 200 | } |
201 | 201 | |
202 | - private function setInstanceProperty($property){ |
|
203 | - if(\is_callable($property)){ |
|
202 | + private function setInstanceProperty($property) { |
|
203 | + if (\is_callable($property)) { |
|
204 | 204 | $this->properties[]=$property; |
205 | - }elseif(\is_string($property)){ |
|
206 | - try{ |
|
205 | + }elseif (\is_string($property)) { |
|
206 | + try { |
|
207 | 207 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
208 | 208 | $rProperty=$this->reflect->getProperty($property); |
209 | 209 | $this->properties[]=$rProperty; |
210 | - }catch(\Exception $e){ |
|
210 | + }catch (\Exception $e) { |
|
211 | 211 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
212 | 212 | $this->properties[]=$property; |
213 | 213 | } |
214 | - }elseif(\is_int($property)){ |
|
214 | + }elseif (\is_int($property)) { |
|
215 | 215 | $props=$this->getDefaultProperties(); |
216 | - if(isset($props[$property])) |
|
216 | + if (isset($props[$property])) |
|
217 | 217 | $this->properties[]=$props[$property]; |
218 | 218 | else |
219 | 219 | $this->properties[]=$property; |
220 | - }else{ |
|
220 | + } else { |
|
221 | 221 | $this->properties[]=$property; |
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
225 | - protected function getDefaultProperties(){ |
|
225 | + protected function getDefaultProperties() { |
|
226 | 226 | $result=[]; |
227 | 227 | $properties=$this->reflect->getProperties(); |
228 | - foreach ($properties as $property){ |
|
228 | + foreach ($properties as $property) { |
|
229 | 229 | $showable=$this->showableProperty($property); |
230 | - if($showable!==false){ |
|
230 | + if ($showable!==false) { |
|
231 | 231 | $result[]=$property; |
232 | 232 | } |
233 | 233 | } |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | return $this; |
240 | 240 | } |
241 | 241 | |
242 | - public function setValueFunction($index,$callback){ |
|
242 | + public function setValueFunction($index, $callback) { |
|
243 | 243 | $this->values[$index]=$callback; |
244 | 244 | return $this; |
245 | 245 | } |
246 | 246 | |
247 | - public function setIdentifierFunction($callback){ |
|
247 | + public function setIdentifierFunction($callback) { |
|
248 | 248 | $this->values["identifier"]=$callback; |
249 | 249 | return $this; |
250 | 250 | } |
@@ -257,41 +257,41 @@ discard block |
||
257 | 257 | return $this->properties; |
258 | 258 | } |
259 | 259 | |
260 | - public function getCaption($index){ |
|
261 | - if(isset($this->captions[$index])){ |
|
260 | + public function getCaption($index) { |
|
261 | + if (isset($this->captions[$index])) { |
|
262 | 262 | return $this->captions[$index]; |
263 | 263 | } |
264 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
264 | + if ($this->properties[$index] instanceof \ReflectionProperty) |
|
265 | 265 | return $this->properties[$index]->getName(); |
266 | - elseif(\is_callable($this->properties[$index])) |
|
266 | + elseif (\is_callable($this->properties[$index])) |
|
267 | 267 | return ""; |
268 | 268 | else |
269 | 269 | return $this->properties[$index]; |
270 | 270 | } |
271 | 271 | |
272 | - public function getCaptions(){ |
|
273 | - if(isset($this->captions)){ |
|
274 | - $captions= \array_values($this->captions); |
|
275 | - for($i=\sizeof($captions);$i<$this->count();$i++){ |
|
272 | + public function getCaptions() { |
|
273 | + if (isset($this->captions)) { |
|
274 | + $captions=\array_values($this->captions); |
|
275 | + for ($i=\sizeof($captions); $i<$this->count(); $i++) { |
|
276 | 276 | $captions[]=""; |
277 | 277 | } |
278 | - }else{ |
|
278 | + } else { |
|
279 | 279 | $captions=[]; |
280 | 280 | $index=0; |
281 | 281 | $count=$this->count(); |
282 | - while($index<$count){ |
|
282 | + while ($index<$count) { |
|
283 | 283 | $captions[]=$this->getCaption($index++); |
284 | 284 | } |
285 | 285 | } |
286 | - if(isset($this->captionCallback) && \is_callable($this->captionCallback)){ |
|
286 | + if (isset($this->captionCallback) && \is_callable($this->captionCallback)) { |
|
287 | 287 | $callback=$this->captionCallback; |
288 | - $callback($captions,$this->instance); |
|
288 | + $callback($captions, $this->instance); |
|
289 | 289 | } |
290 | 290 | return $captions; |
291 | 291 | } |
292 | 292 | |
293 | - public function setCaption($index,$caption){ |
|
294 | - if(isset($this->captions)===false) |
|
293 | + public function setCaption($index, $caption) { |
|
294 | + if (isset($this->captions)===false) |
|
295 | 295 | $this->captions=[]; |
296 | 296 | $this->captions[$index]=$caption; |
297 | 297 | return $this; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @param callable $callback function called after the field compilation |
310 | 310 | * @return \Ajax\semantic\widgets\datatable\InstanceViewer |
311 | 311 | */ |
312 | - public function afterCompile($index,$callback){ |
|
312 | + public function afterCompile($index, $callback) { |
|
313 | 313 | $this->afterCompile[$index]=$callback; |
314 | 314 | return $this; |
315 | 315 | } |
@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | $this->widgetIdentifier=$identifier; |
24 | 24 | $this->values=[]; |
25 | 25 | $this->afterCompile=[]; |
26 | - if(isset($instance)) |
|
27 | - $this->setInstance($instance); |
|
26 | + if(isset($instance)) { |
|
27 | + $this->setInstance($instance); |
|
28 | + } |
|
28 | 29 | $this->setCaptions($captions); |
29 | 30 | $this->captionCallback=NULL; |
30 | 31 | $this->defaultValueFunction=function($name,$value){return $value;}; |
@@ -62,14 +63,16 @@ discard block |
||
62 | 63 | } |
63 | 64 | |
64 | 65 | public function getIdentifier($index=NULL){ |
65 | - if(!isset($index)) |
|
66 | - $index=self::$index; |
|
66 | + if(!isset($index)) { |
|
67 | + $index=self::$index; |
|
68 | + } |
|
67 | 69 | $value=$index; |
68 | 70 | if(isset($this->values["identifier"])){ |
69 | - if(\is_string($this->values["identifier"])) |
|
70 | - $value=JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
71 | - else |
|
72 | - $value=$this->values["identifier"]($index,$this->instance); |
|
71 | + if(\is_string($this->values["identifier"])) { |
|
72 | + $value=JReflection::callMethod($this->instance, $this->values["identifier"], []); |
|
73 | + } else { |
|
74 | + $value=$this->values["identifier"]($index,$this->instance); |
|
75 | + } |
|
73 | 76 | } |
74 | 77 | return $value; |
75 | 78 | } |
@@ -99,16 +102,16 @@ discard block |
||
99 | 102 | if($property instanceof \ReflectionProperty){ |
100 | 103 | $value=$this->_getPropertyValue($property, $index); |
101 | 104 | $propertyName=$property->getName(); |
102 | - }elseif(\is_callable($property)) |
|
103 | - $value=$property($this->instance); |
|
104 | - elseif(\is_array($property)){ |
|
105 | + } elseif(\is_callable($property)) { |
|
106 | + $value=$property($this->instance); |
|
107 | + } elseif(\is_array($property)){ |
|
105 | 108 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
106 | 109 | $value=\implode("", $values); |
107 | - }elseif(\is_string($property)){ |
|
110 | + } elseif(\is_string($property)){ |
|
108 | 111 | $value=$property; |
109 | 112 | if(isset($this->instance->{$property})){ |
110 | 113 | $value=$this->instance->{$property}; |
111 | - }elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){ |
|
114 | + } elseif(\method_exists($this->instance, $getter=JReflection::getterName($property))){ |
|
112 | 115 | $value=JReflection::callMethod($this->instance, $getter, []); |
113 | 116 | } |
114 | 117 | } |
@@ -118,7 +121,7 @@ discard block |
||
118 | 121 | protected function _postGetValue($index,$propertyName,$value){ |
119 | 122 | if(isset($this->values[$index])){ |
120 | 123 | $value= $this->values[$index]($value,$this->instance,$index); |
121 | - }else{ |
|
124 | + } else{ |
|
122 | 125 | $value=$this->_getDefaultValue($propertyName,$value, $index); |
123 | 126 | } |
124 | 127 | if(isset($this->afterCompile[$index])){ |
@@ -139,10 +142,10 @@ discard block |
||
139 | 142 | if(isset($vb[$index])){ |
140 | 143 | if(\is_array($vb[$index])){ |
141 | 144 | $this->visibleProperties[$index][]=$field; |
142 | - }else{ |
|
145 | + } else{ |
|
143 | 146 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
144 | 147 | } |
145 | - }else{ |
|
148 | + } else{ |
|
146 | 149 | return $this->insertField($index, $field); |
147 | 150 | } |
148 | 151 | return $this; |
@@ -169,9 +172,9 @@ discard block |
||
169 | 172 | $property=$this->getProperty($index); |
170 | 173 | if($property instanceof \ReflectionProperty){ |
171 | 174 | $result=$property->getName(); |
172 | - }elseif(\is_callable($property)){ |
|
175 | + } elseif(\is_callable($property)){ |
|
173 | 176 | $result=$this->visibleProperties[$index]; |
174 | - }else{ |
|
177 | + } else{ |
|
175 | 178 | $result=$property; |
176 | 179 | } |
177 | 180 | return $result; |
@@ -191,7 +194,7 @@ discard block |
||
191 | 194 | $this->reflect=new \ReflectionClass($instance); |
192 | 195 | if(\sizeof($this->visibleProperties)===0){ |
193 | 196 | $this->properties=$this->getDefaultProperties(); |
194 | - }else{ |
|
197 | + } else{ |
|
195 | 198 | foreach ($this->visibleProperties as $property){ |
196 | 199 | $this->setInstanceProperty($property); |
197 | 200 | } |
@@ -202,22 +205,23 @@ discard block |
||
202 | 205 | private function setInstanceProperty($property){ |
203 | 206 | if(\is_callable($property)){ |
204 | 207 | $this->properties[]=$property; |
205 | - }elseif(\is_string($property)){ |
|
208 | + } elseif(\is_string($property)){ |
|
206 | 209 | try{ |
207 | 210 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
208 | 211 | $rProperty=$this->reflect->getProperty($property); |
209 | 212 | $this->properties[]=$rProperty; |
210 | - }catch(\Exception $e){ |
|
213 | + } catch(\Exception $e){ |
|
211 | 214 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
212 | 215 | $this->properties[]=$property; |
213 | 216 | } |
214 | - }elseif(\is_int($property)){ |
|
217 | + } elseif(\is_int($property)){ |
|
215 | 218 | $props=$this->getDefaultProperties(); |
216 | - if(isset($props[$property])) |
|
217 | - $this->properties[]=$props[$property]; |
|
218 | - else |
|
219 | - $this->properties[]=$property; |
|
220 | - }else{ |
|
219 | + if(isset($props[$property])) { |
|
220 | + $this->properties[]=$props[$property]; |
|
221 | + } else { |
|
222 | + $this->properties[]=$property; |
|
223 | + } |
|
224 | + } else{ |
|
221 | 225 | $this->properties[]=$property; |
222 | 226 | } |
223 | 227 | } |
@@ -261,12 +265,13 @@ discard block |
||
261 | 265 | if(isset($this->captions[$index])){ |
262 | 266 | return $this->captions[$index]; |
263 | 267 | } |
264 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
265 | - return $this->properties[$index]->getName(); |
|
266 | - elseif(\is_callable($this->properties[$index])) |
|
267 | - return ""; |
|
268 | - else |
|
269 | - return $this->properties[$index]; |
|
268 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
269 | + return $this->properties[$index]->getName(); |
|
270 | + } elseif(\is_callable($this->properties[$index])) { |
|
271 | + return ""; |
|
272 | + } else { |
|
273 | + return $this->properties[$index]; |
|
274 | + } |
|
270 | 275 | } |
271 | 276 | |
272 | 277 | public function getCaptions(){ |
@@ -275,7 +280,7 @@ discard block |
||
275 | 280 | for($i=\sizeof($captions);$i<$this->count();$i++){ |
276 | 281 | $captions[]=""; |
277 | 282 | } |
278 | - }else{ |
|
283 | + } else{ |
|
279 | 284 | $captions=[]; |
280 | 285 | $index=0; |
281 | 286 | $count=$this->count(); |
@@ -291,8 +296,9 @@ discard block |
||
291 | 296 | } |
292 | 297 | |
293 | 298 | public function setCaption($index,$caption){ |
294 | - if(isset($this->captions)===false) |
|
295 | - $this->captions=[]; |
|
299 | + if(isset($this->captions)===false) { |
|
300 | + $this->captions=[]; |
|
301 | + } |
|
296 | 302 | $this->captions[$index]=$caption; |
297 | 303 | return $this; |
298 | 304 | } |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | |
28 | 28 | public function __construct($identifier, $rowCount, $colCount) { |
29 | 29 | parent::__construct($identifier, "table", "ui table"); |
30 | - $this->content=array (); |
|
30 | + $this->content=array(); |
|
31 | 31 | $this->setRowCount($rowCount, $colCount); |
32 | - $this->_variations=[ Variation::CELLED,Variation::PADDED,Variation::COMPACT ]; |
|
33 | - $this->_compileParts=["thead","tbody","tfoot"]; |
|
32 | + $this->_variations=[Variation::CELLED, Variation::PADDED, Variation::COMPACT]; |
|
33 | + $this->_compileParts=["thead", "tbody", "tfoot"]; |
|
34 | 34 | $this->_afterCompileEvents=[]; |
35 | 35 | } |
36 | 36 | |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | * @return HtmlTableContent |
49 | 49 | */ |
50 | 50 | public function getPart($key) { |
51 | - if (\array_key_exists($key, $this->content) === false) { |
|
51 | + if (\array_key_exists($key, $this->content)===false) { |
|
52 | 52 | $this->content[$key]=new HtmlTableContent("", $key); |
53 | - if ($key !== "tbody") { |
|
53 | + if ($key!=="tbody") { |
|
54 | 54 | $this->content[$key]->setRowCount(1, $this->_colCount); |
55 | 55 | } |
56 | 56 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return boolean |
96 | 96 | */ |
97 | 97 | public function hasPart($key) { |
98 | - return \array_key_exists($key, $this->content) === true; |
|
98 | + return \array_key_exists($key, $this->content)===true; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | private function colAlign($colIndex, $function) { |
232 | 232 | if (\is_array($colIndex)) { |
233 | - foreach ( $colIndex as $cIndex ) { |
|
233 | + foreach ($colIndex as $cIndex) { |
|
234 | 234 | $this->colAlign($cIndex, $function); |
235 | 235 | } |
236 | 236 | } else { |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @see HtmlSemDoubleElement::compile() |
292 | 292 | */ |
293 | 293 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
294 | - if(\sizeof($this->_compileParts)<3){ |
|
294 | + if (\sizeof($this->_compileParts)<3) { |
|
295 | 295 | $this->_template="%content%"; |
296 | 296 | $this->refresh(); |
297 | 297 | } |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | |
302 | 302 | protected function compile_once(JsUtils $js=NULL, &$view=NULL) { |
303 | 303 | if ($this->propertyContains("class", "sortable")) { |
304 | - $this->addEvent("execute", "$('#" . $this->identifier . "').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
304 | + $this->addEvent("execute", "$('#".$this->identifier."').tablesort().data('tablesort').sort($('th.default-sort'));"); |
|
305 | 305 | } |
306 | - if(isset($this->_activeRowSelector)){ |
|
306 | + if (isset($this->_activeRowSelector)) { |
|
307 | 307 | $this->_activeRowSelector->compile(); |
308 | 308 | } |
309 | 309 | } |
@@ -317,13 +317,13 @@ discard block |
||
317 | 317 | public function fromDatabaseObject($object, $function) { |
318 | 318 | $result=$function($object); |
319 | 319 | if (\is_array($result)) { |
320 | - $result= $this->addRow($function($object)); |
|
320 | + $result=$this->addRow($function($object)); |
|
321 | 321 | } else { |
322 | - $result= $this->getBody()->_addRow($result); |
|
322 | + $result=$this->getBody()->_addRow($result); |
|
323 | 323 | } |
324 | - if(isset($this->_afterCompileEvents["onNewRow"])){ |
|
325 | - if(\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
326 | - $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
324 | + if (isset($this->_afterCompileEvents["onNewRow"])) { |
|
325 | + if (\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
326 | + $this->_afterCompileEvents["onNewRow"]($result, $object); |
|
327 | 327 | } |
328 | 328 | return $result; |
329 | 329 | } |
@@ -338,14 +338,14 @@ discard block |
||
338 | 338 | return $this; |
339 | 339 | } |
340 | 340 | |
341 | - public function refresh(){ |
|
341 | + public function refresh() { |
|
342 | 342 | $this->_footer=$this->getFooter(); |
343 | 343 | $this->addEvent("execute", '$("#'.$this->identifier.' tfoot").replaceWith("'.\addslashes($this->_footer).'");'); |
344 | 344 | } |
345 | 345 | |
346 | - public function run(JsUtils $js){ |
|
347 | - $result= parent::run($js); |
|
348 | - if(isset($this->_footer)) |
|
346 | + public function run(JsUtils $js) { |
|
347 | + $result=parent::run($js); |
|
348 | + if (isset($this->_footer)) |
|
349 | 349 | $this->_footer->run($js); |
350 | 350 | return $result; |
351 | 351 | } |
@@ -368,27 +368,27 @@ discard block |
||
368 | 368 | * @param boolean $multiple |
369 | 369 | * @return HtmlTable |
370 | 370 | */ |
371 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
372 | - $this->_activeRowSelector=new ActiveRow($this,$class,$event,$multiple); |
|
371 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
372 | + $this->_activeRowSelector=new ActiveRow($this, $class, $event, $multiple); |
|
373 | 373 | return $this; |
374 | 374 | } |
375 | 375 | |
376 | - public function hideColumn($colIndex){ |
|
377 | - if($this->hasPart("thead")){ |
|
376 | + public function hideColumn($colIndex) { |
|
377 | + if ($this->hasPart("thead")) { |
|
378 | 378 | $this->getHeader()->hideColumn($colIndex); |
379 | 379 | } |
380 | 380 | $this->getBody()->hideColumn($colIndex); |
381 | - if($this->hasPart("tfoot")){ |
|
381 | + if ($this->hasPart("tfoot")) { |
|
382 | 382 | $this->getFooter()->hideColumn($colIndex); |
383 | 383 | } |
384 | 384 | return $this; |
385 | 385 | } |
386 | 386 | |
387 | - public function setColWidth($colIndex,$width){ |
|
388 | - if($this->hasPart("thead")){ |
|
387 | + public function setColWidth($colIndex, $width) { |
|
388 | + if ($this->hasPart("thead")) { |
|
389 | 389 | $this->getHeader()->getCell(0, $colIndex)->setWidth($width); |
390 | - }else{ |
|
391 | - if($this->getBody()->count()>0) |
|
390 | + } else { |
|
391 | + if ($this->getBody()->count()>0) |
|
392 | 392 | $this->getBody()->getCell(0, $colIndex)->setWidth($width); |
393 | 393 | } |
394 | 394 | return $this; |
@@ -322,8 +322,9 @@ discard block |
||
322 | 322 | $result= $this->getBody()->_addRow($result); |
323 | 323 | } |
324 | 324 | if(isset($this->_afterCompileEvents["onNewRow"])){ |
325 | - if(\is_callable($this->_afterCompileEvents["onNewRow"])) |
|
326 | - $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
325 | + if(\is_callable($this->_afterCompileEvents["onNewRow"])) { |
|
326 | + $this->_afterCompileEvents["onNewRow"]($result,$object); |
|
327 | + } |
|
327 | 328 | } |
328 | 329 | return $result; |
329 | 330 | } |
@@ -345,8 +346,9 @@ discard block |
||
345 | 346 | |
346 | 347 | public function run(JsUtils $js){ |
347 | 348 | $result= parent::run($js); |
348 | - if(isset($this->_footer)) |
|
349 | - $this->_footer->run($js); |
|
349 | + if(isset($this->_footer)) { |
|
350 | + $this->_footer->run($js); |
|
351 | + } |
|
350 | 352 | return $result; |
351 | 353 | } |
352 | 354 | |
@@ -387,9 +389,10 @@ discard block |
||
387 | 389 | public function setColWidth($colIndex,$width){ |
388 | 390 | if($this->hasPart("thead")){ |
389 | 391 | $this->getHeader()->getCell(0, $colIndex)->setWidth($width); |
390 | - }else{ |
|
391 | - if($this->getBody()->count()>0) |
|
392 | - $this->getBody()->getCell(0, $colIndex)->setWidth($width); |
|
392 | + } else{ |
|
393 | + if($this->getBody()->count()>0) { |
|
394 | + $this->getBody()->getCell(0, $colIndex)->setWidth($width); |
|
395 | + } |
|
393 | 396 | } |
394 | 397 | return $this; |
395 | 398 | } |