@@ -128,12 +128,20 @@ |
||
128 | 128 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
129 | 129 | } |
130 | 130 | |
131 | + /** |
|
132 | + * @param integer $index |
|
133 | + * @param string $title |
|
134 | + */ |
|
131 | 135 | public function addDividerBefore($index,$title){ |
132 | 136 | $index=$this->_getIndex($index); |
133 | 137 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
134 | 138 | return $this; |
135 | 139 | } |
136 | 140 | |
141 | + /** |
|
142 | + * @param string $index |
|
143 | + * @param string $contentAfter |
|
144 | + */ |
|
137 | 145 | public function addWrapper($index,$contentBefore,$contentAfter=null){ |
138 | 146 | $index=$this->_getIndex($index); |
139 | 147 | $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
@@ -19,64 +19,64 @@ discard block |
||
19 | 19 | class DataForm extends Widget { |
20 | 20 | |
21 | 21 | public function __construct($identifier, $modelInstance=NULL) { |
22 | - parent::__construct($identifier, null,$modelInstance); |
|
22 | + parent::__construct($identifier, null, $modelInstance); |
|
23 | 23 | $this->_form=new HtmlForm($identifier); |
24 | 24 | $this->_init(new FormInstanceViewer($identifier), "form", $this->_form, true); |
25 | 25 | } |
26 | 26 | |
27 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
27 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
28 | 28 | return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier(); |
29 | 29 | } |
30 | 30 | |
31 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
32 | - if(!$this->_generated){ |
|
31 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
32 | + if (!$this->_generated) { |
|
33 | 33 | $this->_instanceViewer->setInstance($this->_modelInstance); |
34 | 34 | |
35 | 35 | $form=$this->content["form"]; |
36 | 36 | $this->_generateContent($form); |
37 | 37 | |
38 | - if(isset($this->_toolbar)){ |
|
38 | + if (isset($this->_toolbar)) { |
|
39 | 39 | $this->_setToolbarPosition($form); |
40 | 40 | } |
41 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]); |
|
41 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]); |
|
42 | 42 | $this->_generated=true; |
43 | 43 | } |
44 | - return parent::compile($js,$view); |
|
44 | + return parent::compile($js, $view); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * @param HtmlForm $form |
49 | 49 | */ |
50 | - protected function _generateContent($form){ |
|
51 | - $values= $this->_instanceViewer->getValues(); |
|
50 | + protected function _generateContent($form) { |
|
51 | + $values=$this->_instanceViewer->getValues(); |
|
52 | 52 | $count=$this->_instanceViewer->count(); |
53 | 53 | $separators=$this->_instanceViewer->getSeparators(); |
54 | 54 | $headers=$this->_instanceViewer->getHeaders(); |
55 | 55 | $wrappers=$this->_instanceViewer->getWrappers(); |
56 | 56 | \sort($separators); |
57 | 57 | $size=\sizeof($separators); |
58 | - if($size===1){ |
|
59 | - foreach ($values as $v){ |
|
58 | + if ($size===1) { |
|
59 | + foreach ($values as $v) { |
|
60 | 60 | $form->addField($v); |
61 | 61 | } |
62 | - }else{ |
|
62 | + } else { |
|
63 | 63 | $separators[]=$count; |
64 | - for($i=0;$i<$size;$i++){ |
|
64 | + for ($i=0; $i<$size; $i++) { |
|
65 | 65 | $wrapper=null; |
66 | - $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
|
67 | - if(isset($headers[$separators[$i]+1])) |
|
68 | - $form->addHeader($headers[$separators[$i]+1],4,true); |
|
69 | - if(isset($wrappers[$separators[$i]+1])){ |
|
66 | + $fields=\array_slice($values, $separators[$i]+1, $separators[$i+1]-$separators[$i]); |
|
67 | + if (isset($headers[$separators[$i]+1])) |
|
68 | + $form->addHeader($headers[$separators[$i]+1], 4, true); |
|
69 | + if (isset($wrappers[$separators[$i]+1])) { |
|
70 | 70 | $wrapper=$wrappers[$separators[$i]+1]; |
71 | 71 | } |
72 | 72 | //TODO check why $fields is empty |
73 | - if(\sizeof($fields)===1){ |
|
73 | + if (\sizeof($fields)===1) { |
|
74 | 74 | $added=$form->addField($fields[0]); |
75 | - }elseif(\sizeof($fields)>1){ |
|
75 | + }elseif (\sizeof($fields)>1) { |
|
76 | 76 | $added=$form->addFields($fields); |
77 | 77 | } |
78 | - if(isset($wrapper)) |
|
79 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
78 | + if (isset($wrapper)) |
|
79 | + $added->wrap($wrapper[0], $wrapper[1]); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | * {@inheritDoc} |
86 | 86 | * @see \Ajax\common\Widget::getForm() |
87 | 87 | */ |
88 | - public function getForm(){ |
|
88 | + public function getForm() { |
|
89 | 89 | return $this->content["form"]; |
90 | 90 | } |
91 | 91 | |
92 | - public function addSeparatorAfter($fieldNum){ |
|
92 | + public function addSeparatorAfter($fieldNum) { |
|
93 | 93 | $fieldNum=$this->_getIndex($fieldNum); |
94 | 94 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
95 | 95 | return $this; |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | return $this; |
105 | 105 | } |
106 | 106 | |
107 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
108 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
109 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
107 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
108 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
109 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
110 | 110 | $button->setProperty("type", "reset"); |
111 | 111 | return $button; |
112 | - }, $index,$attributes); |
|
112 | + }, $index, $attributes); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -128,19 +128,19 @@ discard block |
||
128 | 128 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
129 | 129 | } |
130 | 130 | |
131 | - public function addDividerBefore($index,$title){ |
|
131 | + public function addDividerBefore($index, $title) { |
|
132 | 132 | $index=$this->_getIndex($index); |
133 | 133 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
134 | 134 | return $this; |
135 | 135 | } |
136 | 136 | |
137 | - public function addWrapper($index,$contentBefore,$contentAfter=null){ |
|
137 | + public function addWrapper($index, $contentBefore, $contentAfter=null) { |
|
138 | 138 | $index=$this->_getIndex($index); |
139 | - $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
|
139 | + $this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter); |
|
140 | 140 | return $this; |
141 | 141 | } |
142 | 142 | |
143 | - public function run(JsUtils $js){ |
|
143 | + public function run(JsUtils $js) { |
|
144 | 144 | return parent::run($js); |
145 | 145 | } |
146 | 146 | } |
147 | 147 | \ No newline at end of file |
@@ -59,24 +59,26 @@ |
||
59 | 59 | foreach ($values as $v){ |
60 | 60 | $form->addField($v); |
61 | 61 | } |
62 | - }else{ |
|
62 | + } else{ |
|
63 | 63 | $separators[]=$count; |
64 | 64 | for($i=0;$i<$size;$i++){ |
65 | 65 | $wrapper=null; |
66 | 66 | $fields=\array_slice($values, $separators[$i]+1,$separators[$i+1]-$separators[$i]); |
67 | - if(isset($headers[$separators[$i]+1])) |
|
68 | - $form->addHeader($headers[$separators[$i]+1],4,true); |
|
67 | + if(isset($headers[$separators[$i]+1])) { |
|
68 | + $form->addHeader($headers[$separators[$i]+1],4,true); |
|
69 | + } |
|
69 | 70 | if(isset($wrappers[$separators[$i]+1])){ |
70 | 71 | $wrapper=$wrappers[$separators[$i]+1]; |
71 | 72 | } |
72 | 73 | //TODO check why $fields is empty |
73 | 74 | if(\sizeof($fields)===1){ |
74 | 75 | $added=$form->addField($fields[0]); |
75 | - }elseif(\sizeof($fields)>1){ |
|
76 | + } elseif(\sizeof($fields)>1){ |
|
76 | 77 | $added=$form->addFields($fields); |
77 | 78 | } |
78 | - if(isset($wrapper)) |
|
79 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
79 | + if(isset($wrapper)) { |
|
80 | + $added->wrap($wrapper[0],$wrapper[1]); |
|
81 | + } |
|
80 | 82 | } |
81 | 83 | } |
82 | 84 | } |
@@ -11,58 +11,58 @@ discard block |
||
11 | 11 | protected $headers; |
12 | 12 | protected $wrappers; |
13 | 13 | |
14 | - public function __construct($identifier,$instance=NULL, $captions=NULL) { |
|
15 | - parent::__construct($identifier,$instance=NULL, $captions=NULL); |
|
14 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
15 | + parent::__construct($identifier, $instance=NULL, $captions=NULL); |
|
16 | 16 | $this->separators=[-1]; |
17 | 17 | $this->headers=[]; |
18 | 18 | $this->wrappers=[]; |
19 | - $this->defaultValueFunction=function($name,$value,$index){ |
|
19 | + $this->defaultValueFunction=function($name, $value, $index) { |
|
20 | 20 | $caption=$this->getCaption($index); |
21 | - $input=new HtmlFormInput($this->widgetIdentifier."-".$name,$caption,"text",$value); |
|
21 | + $input=new HtmlFormInput($this->widgetIdentifier."-".$name, $caption, "text", $value); |
|
22 | 22 | $input->setName($name); |
23 | 23 | return $input; |
24 | 24 | }; |
25 | 25 | } |
26 | 26 | |
27 | - protected function _beforeAddProperty($index,&$field){ |
|
28 | - if(JString::endswith($field, "\n")===true){ |
|
27 | + protected function _beforeAddProperty($index, &$field) { |
|
28 | + if (JString::endswith($field, "\n")===true) { |
|
29 | 29 | $this->addSeparatorAfter($index); |
30 | 30 | } |
31 | - if($index>1 && JString::startswith($field, "\n")===true){ |
|
31 | + if ($index>1 && JString::startswith($field, "\n")===true) { |
|
32 | 32 | $this->addSeparatorAfter($index-1); |
33 | 33 | } |
34 | 34 | $field=\str_replace("\n", "", $field); |
35 | - if(($header=$this->hasHeader($field))!==false){ |
|
35 | + if (($header=$this->hasHeader($field))!==false) { |
|
36 | 36 | $this->addHeaderDividerBefore($index, $header); |
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | - protected function hasHeader(&$field){ |
|
41 | - $matches=[];$result=false; |
|
42 | - if(\preg_match('/\{(.*?)\}/s', $field, $matches)===1){ |
|
40 | + protected function hasHeader(&$field) { |
|
41 | + $matches=[]; $result=false; |
|
42 | + if (\preg_match('/\{(.*?)\}/s', $field, $matches)===1) { |
|
43 | 43 | $result=$matches[1]; |
44 | - $field=\str_replace("{".$result."}","", $field); |
|
44 | + $field=\str_replace("{".$result."}", "", $field); |
|
45 | 45 | } |
46 | 46 | return $result; |
47 | 47 | } |
48 | 48 | |
49 | 49 | |
50 | 50 | |
51 | - public function addSeparatorAfter($fieldNum){ |
|
52 | - if(\array_search($fieldNum, $this->separators)===false) |
|
51 | + public function addSeparatorAfter($fieldNum) { |
|
52 | + if (\array_search($fieldNum, $this->separators)===false) |
|
53 | 53 | $this->separators[]=$fieldNum; |
54 | 54 | return $this; |
55 | 55 | } |
56 | 56 | |
57 | - public function addHeaderDividerBefore($fieldNum,$header){ |
|
57 | + public function addHeaderDividerBefore($fieldNum, $header) { |
|
58 | 58 | $this->headers[$fieldNum]=$header; |
59 | - if($fieldNum>0) |
|
59 | + if ($fieldNum>0) |
|
60 | 60 | $this->addSeparatorAfter($fieldNum-1); |
61 | 61 | return $this; |
62 | 62 | } |
63 | 63 | |
64 | - public function addWrapper($fieldNum,$contentBefore,$contentAfter=null){ |
|
65 | - $this->wrappers[$fieldNum]=[$contentBefore,$contentAfter]; |
|
64 | + public function addWrapper($fieldNum, $contentBefore, $contentAfter=null) { |
|
65 | + $this->wrappers[$fieldNum]=[$contentBefore, $contentAfter]; |
|
66 | 66 | return $this; |
67 | 67 | } |
68 | 68 | |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | return $this->separators; |
71 | 71 | } |
72 | 72 | |
73 | - public function removeSeparator($index){ |
|
74 | - \array_splice($this->separators,$index,1); |
|
73 | + public function removeSeparator($index) { |
|
74 | + \array_splice($this->separators, $index, 1); |
|
75 | 75 | } |
76 | 76 | |
77 | - public function removeField($index){ |
|
77 | + public function removeField($index) { |
|
78 | 78 | parent::removeField($index); |
79 | 79 | $pos=\array_search($index, $this->separators); |
80 | - if($pos!==false){ |
|
81 | - for($i=$pos+1;$i<\sizeof($this->separators);$i++){ |
|
80 | + if ($pos!==false) { |
|
81 | + for ($i=$pos+1; $i<\sizeof($this->separators); $i++) { |
|
82 | 82 | $this->separators[$i]--; |
83 | 83 | } |
84 | 84 | \array_splice($this->separators, $pos, 1); |
@@ -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 | } |
60 | 60 | \ No newline at end of file |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | * @param array $instances |
17 | 17 | * @return DataTable |
18 | 18 | */ |
19 | - public function dataTable($identifier,$model, $instances){ |
|
20 | - return $this->addHtmlComponent(new DataTable($identifier,$model,$instances)); |
|
19 | + public function dataTable($identifier, $model, $instances) { |
|
20 | + return $this->addHtmlComponent(new DataTable($identifier, $model, $instances)); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | * @param object $instance |
26 | 26 | * @return DataElement |
27 | 27 | */ |
28 | - public function dataElement($identifier, $instance){ |
|
29 | - return $this->addHtmlComponent(new DataElement($identifier,$instance)); |
|
28 | + public function dataElement($identifier, $instance) { |
|
29 | + return $this->addHtmlComponent(new DataElement($identifier, $instance)); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | * @param object $instance |
35 | 35 | * @return DataForm |
36 | 36 | */ |
37 | - public function dataForm($identifier, $instance){ |
|
38 | - return $this->addHtmlComponent(new DataForm($identifier,$instance)); |
|
37 | + public function dataForm($identifier, $instance) { |
|
38 | + return $this->addHtmlComponent(new DataForm($identifier, $instance)); |
|
39 | 39 | } |
40 | 40 | |
41 | - public function defaultLogin($identifier,$instance=null){ |
|
42 | - return $this->addHtmlComponent(FormLogin::regular($identifier,$instance)); |
|
41 | + public function defaultLogin($identifier, $instance=null) { |
|
42 | + return $this->addHtmlComponent(FormLogin::regular($identifier, $instance)); |
|
43 | 43 | } |
44 | 44 | |
45 | - public function smallLogin($identifier,$instance=null){ |
|
46 | - return $this->addHtmlComponent(FormLogin::small($identifier,$instance)); |
|
45 | + public function smallLogin($identifier, $instance=null) { |
|
46 | + return $this->addHtmlComponent(FormLogin::small($identifier, $instance)); |
|
47 | 47 | } |
48 | 48 | |
49 | - public function segmentedLogin($identifier,$instance=null){ |
|
50 | - return $this->addHtmlComponent(FormLogin::attachedSegment($identifier,$instance)); |
|
49 | + public function segmentedLogin($identifier, $instance=null) { |
|
50 | + return $this->addHtmlComponent(FormLogin::attachedSegment($identifier, $instance)); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | \ No newline at end of file |