@@ -16,18 +16,39 @@ discard block |
||
16 | 16 | protected $_states=[ ]; |
17 | 17 | protected $_baseClass; |
18 | 18 | |
19 | + /** |
|
20 | + * @param string $name |
|
21 | + */ |
|
19 | 22 | abstract protected function setPropertyCtrl($name, $value, $typeCtrl); |
20 | 23 | |
24 | + /** |
|
25 | + * @param string $name |
|
26 | + */ |
|
21 | 27 | abstract protected function addToPropertyCtrl($name, $value, $typeCtrl); |
22 | 28 | |
29 | + /** |
|
30 | + * @param string $name |
|
31 | + */ |
|
23 | 32 | abstract protected function addToPropertyCtrlCheck($name, $value, $typeCtrl); |
24 | 33 | |
34 | + /** |
|
35 | + * @param string $name |
|
36 | + */ |
|
25 | 37 | abstract public function addToProperty($name, $value, $separator=" "); |
26 | 38 | |
39 | + /** |
|
40 | + * @param string $name |
|
41 | + */ |
|
27 | 42 | abstract public function setProperty($name, $value); |
28 | 43 | |
44 | + /** |
|
45 | + * @param HtmlIcon $content |
|
46 | + */ |
|
29 | 47 | abstract public function addContent($content,$before=false); |
30 | 48 | |
49 | + /** |
|
50 | + * @param string $jsCode |
|
51 | + */ |
|
31 | 52 | abstract public function onCreate($jsCode); |
32 | 53 | |
33 | 54 | public function addVariation($variation) { |
@@ -108,7 +129,7 @@ discard block |
||
108 | 129 | /** |
109 | 130 | * show it is currently unable to be interacted with |
110 | 131 | * @param boolean $disable |
111 | - * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
|
132 | + * @return BaseTrait |
|
112 | 133 | */ |
113 | 134 | public function setDisabled($disable=true) { |
114 | 135 | if($disable) |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | * @property string $identifier |
13 | 13 | */ |
14 | 14 | trait BaseTrait { |
15 | - protected $_variations=[ ]; |
|
16 | - protected $_states=[ ]; |
|
15 | + protected $_variations=[]; |
|
16 | + protected $_states=[]; |
|
17 | 17 | protected $_baseClass; |
18 | 18 | |
19 | 19 | abstract protected function setPropertyCtrl($name, $value, $typeCtrl); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | abstract public function setProperty($name, $value); |
28 | 28 | |
29 | - abstract public function addContent($content,$before=false); |
|
29 | + abstract public function addContent($content, $before=false); |
|
30 | 30 | |
31 | 31 | abstract public function onCreate($jsCode); |
32 | 32 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $this->setProperty("class", $this->_baseClass); |
48 | 48 | if (\is_string($variations)) |
49 | 49 | $variations=\explode(" ", $variations); |
50 | - foreach ( $variations as $variation ) { |
|
50 | + foreach ($variations as $variation) { |
|
51 | 51 | $this->addVariation($variation); |
52 | 52 | } |
53 | 53 | return $this; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | public function addVariations($variations=array()) { |
62 | 62 | if (\is_string($variations)) |
63 | 63 | $variations=\explode(" ", $variations); |
64 | - foreach ( $variations as $variation ) { |
|
64 | + foreach ($variations as $variation) { |
|
65 | 65 | $this->addVariation($variation); |
66 | 66 | } |
67 | 67 | return $this; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | public function addStates($states=array()) { |
71 | 71 | if (\is_string($states)) |
72 | 72 | $states=\explode(" ", $states); |
73 | - foreach ( $states as $state ) { |
|
73 | + foreach ($states as $state) { |
|
74 | 74 | $this->addState($state); |
75 | 75 | } |
76 | 76 | return $this; |
@@ -80,17 +80,17 @@ discard block |
||
80 | 80 | $this->setProperty("class", $this->_baseClass); |
81 | 81 | if (\is_string($states)) |
82 | 82 | $states=\explode(" ", $states); |
83 | - foreach ( $states as $state ) { |
|
83 | + foreach ($states as $state) { |
|
84 | 84 | $this->addState($state); |
85 | 85 | } |
86 | 86 | return $this; |
87 | 87 | } |
88 | 88 | |
89 | 89 | public function addIcon($icon, $before=true) { |
90 | - return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before); |
|
90 | + return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before); |
|
91 | 91 | } |
92 | 92 | |
93 | - public function addSticky($context="body"){ |
|
93 | + public function addSticky($context="body") { |
|
94 | 94 | $this->onCreate("$('#".$this->identifier."').sticky({ context: '".$context."'});"); |
95 | 95 | return $this; |
96 | 96 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
112 | 112 | */ |
113 | 113 | public function setDisabled($disable=true) { |
114 | - if($disable) |
|
114 | + if ($disable) |
|
115 | 115 | $this->addToProperty("class", "disabled"); |
116 | 116 | return $this; |
117 | 117 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
139 | 139 | */ |
140 | - public function asHeader(){ |
|
140 | + public function asHeader() { |
|
141 | 141 | return $this->addToProperty("class", "header"); |
142 | 142 | } |
143 | 143 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * show it is currently the active user selection |
146 | 146 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
147 | 147 | */ |
148 | - public function setActive($value=true){ |
|
148 | + public function setActive($value=true) { |
|
149 | 149 | return $this->addToProperty("class", "active"); |
150 | 150 | } |
151 | 151 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | public function setFloated($direction="right") { |
164 | - return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
|
164 | + return $this->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated")); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | public function floatRight() { |
@@ -45,8 +45,9 @@ discard block |
||
45 | 45 | |
46 | 46 | public function setVariations($variations) { |
47 | 47 | $this->setProperty("class", $this->_baseClass); |
48 | - if (\is_string($variations)) |
|
49 | - $variations=\explode(" ", $variations); |
|
48 | + if (\is_string($variations)) { |
|
49 | + $variations=\explode(" ", $variations); |
|
50 | + } |
|
50 | 51 | foreach ( $variations as $variation ) { |
51 | 52 | $this->addVariation($variation); |
52 | 53 | } |
@@ -59,8 +60,9 @@ discard block |
||
59 | 60 | } |
60 | 61 | |
61 | 62 | public function addVariations($variations=array()) { |
62 | - if (\is_string($variations)) |
|
63 | - $variations=\explode(" ", $variations); |
|
63 | + if (\is_string($variations)) { |
|
64 | + $variations=\explode(" ", $variations); |
|
65 | + } |
|
64 | 66 | foreach ( $variations as $variation ) { |
65 | 67 | $this->addVariation($variation); |
66 | 68 | } |
@@ -68,8 +70,9 @@ discard block |
||
68 | 70 | } |
69 | 71 | |
70 | 72 | public function addStates($states=array()) { |
71 | - if (\is_string($states)) |
|
72 | - $states=\explode(" ", $states); |
|
73 | + if (\is_string($states)) { |
|
74 | + $states=\explode(" ", $states); |
|
75 | + } |
|
73 | 76 | foreach ( $states as $state ) { |
74 | 77 | $this->addState($state); |
75 | 78 | } |
@@ -78,8 +81,9 @@ discard block |
||
78 | 81 | |
79 | 82 | public function setStates($states) { |
80 | 83 | $this->setProperty("class", $this->_baseClass); |
81 | - if (\is_string($states)) |
|
82 | - $states=\explode(" ", $states); |
|
84 | + if (\is_string($states)) { |
|
85 | + $states=\explode(" ", $states); |
|
86 | + } |
|
83 | 87 | foreach ( $states as $state ) { |
84 | 88 | $this->addState($state); |
85 | 89 | } |
@@ -111,8 +115,9 @@ discard block |
||
111 | 115 | * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
112 | 116 | */ |
113 | 117 | public function setDisabled($disable=true) { |
114 | - if($disable) |
|
115 | - $this->addToProperty("class", "disabled"); |
|
118 | + if($disable) { |
|
119 | + $this->addToProperty("class", "disabled"); |
|
120 | + } |
|
116 | 121 | return $this; |
117 | 122 | } |
118 | 123 |
@@ -36,28 +36,28 @@ discard block |
||
36 | 36 | protected $_edition; |
37 | 37 | |
38 | 38 | |
39 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
39 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
40 | 40 | parent::__construct($identifier); |
41 | 41 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
42 | 42 | $this->setModel($model); |
43 | - if(isset($modelInstance)); |
|
43 | + if (isset($modelInstance)); |
|
44 | 44 | $this->show($modelInstance); |
45 | 45 | } |
46 | 46 | |
47 | - protected function _init($instanceViewer,$contentKey,$content,$edition){ |
|
47 | + protected function _init($instanceViewer, $contentKey, $content, $edition) { |
|
48 | 48 | $this->_instanceViewer=$instanceViewer; |
49 | 49 | $this->content=[$contentKey=>$content]; |
50 | 50 | $this->_toolbarPosition=PositionInTable::BEFORETABLE; |
51 | 51 | $this->_edition=$edition; |
52 | 52 | } |
53 | 53 | |
54 | - protected function _getFieldIdentifier($prefix){ |
|
54 | + protected function _getFieldIdentifier($prefix) { |
|
55 | 55 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
56 | 56 | } |
57 | 57 | |
58 | - abstract protected function _setToolbarPosition($table,$captions=NULL); |
|
58 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
59 | 59 | |
60 | - public function show($modelInstance){ |
|
60 | + public function show($modelInstance) { |
|
61 | 61 | $this->_modelInstance=$modelInstance; |
62 | 62 | } |
63 | 63 | |
@@ -81,42 +81,42 @@ discard block |
||
81 | 81 | |
82 | 82 | abstract public function getHtmlComponent(); |
83 | 83 | |
84 | - public function setColor($color){ |
|
84 | + public function setColor($color) { |
|
85 | 85 | return $this->getHtmlComponent()->setColor($color); |
86 | 86 | } |
87 | 87 | |
88 | 88 | |
89 | - public function setCaptions($captions){ |
|
89 | + public function setCaptions($captions) { |
|
90 | 90 | $this->_instanceViewer->setCaptions($captions); |
91 | 91 | return $this; |
92 | 92 | } |
93 | 93 | |
94 | - public function setFields($fields){ |
|
94 | + public function setFields($fields) { |
|
95 | 95 | $this->_instanceViewer->setVisibleProperties($fields); |
96 | 96 | return $this; |
97 | 97 | } |
98 | 98 | |
99 | - public function addField($field){ |
|
99 | + public function addField($field) { |
|
100 | 100 | $this->_instanceViewer->addField($field); |
101 | 101 | return $this; |
102 | 102 | } |
103 | 103 | |
104 | - public function insertField($index,$field){ |
|
104 | + public function insertField($index, $field) { |
|
105 | 105 | $this->_instanceViewer->insertField($index, $field); |
106 | 106 | return $this; |
107 | 107 | } |
108 | 108 | |
109 | - public function insertInField($index,$field){ |
|
109 | + public function insertInField($index, $field) { |
|
110 | 110 | $this->_instanceViewer->insertInField($index, $field); |
111 | 111 | return $this; |
112 | 112 | } |
113 | 113 | |
114 | - public function setValueFunction($index,$callback){ |
|
114 | + public function setValueFunction($index, $callback) { |
|
115 | 115 | $this->_instanceViewer->setValueFunction($index, $callback); |
116 | 116 | return $this; |
117 | 117 | } |
118 | 118 | |
119 | - public function setIdentifierFunction($callback){ |
|
119 | + public function setIdentifierFunction($callback) { |
|
120 | 120 | $this->_instanceViewer->setIdentifierFunction($callback); |
121 | 121 | return $this; |
122 | 122 | } |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | /** |
125 | 125 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
126 | 126 | */ |
127 | - public function getToolbar(){ |
|
128 | - if(isset($this->_toolbar)===false){ |
|
127 | + public function getToolbar() { |
|
128 | + if (isset($this->_toolbar)===false) { |
|
129 | 129 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
130 | 130 | //$this->_toolbar->setSecondary(); |
131 | 131 | } |
@@ -138,57 +138,57 @@ discard block |
||
138 | 138 | * @param callable $callback function to call on $element |
139 | 139 | * @return \Ajax\common\html\HtmlDoubleElement |
140 | 140 | */ |
141 | - public function addInToolbar($element,$callback=NULL){ |
|
141 | + public function addInToolbar($element, $callback=NULL) { |
|
142 | 142 | $tb=$this->getToolbar(); |
143 | - if(isset($callback)){ |
|
144 | - if(\is_callable($callback)){ |
|
143 | + if (isset($callback)) { |
|
144 | + if (\is_callable($callback)) { |
|
145 | 145 | $callback($element); |
146 | 146 | } |
147 | 147 | } |
148 | 148 | return $tb->addItem($element); |
149 | 149 | } |
150 | 150 | |
151 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
152 | - $result=$this->addInToolbar($caption,$callback); |
|
153 | - if(isset($icon)) |
|
151 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
152 | + $result=$this->addInToolbar($caption, $callback); |
|
153 | + if (isset($icon)) |
|
154 | 154 | $result->addIcon($icon); |
155 | 155 | return $result; |
156 | 156 | } |
157 | 157 | |
158 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
159 | - if(JArray::isAssociative($items)){ |
|
160 | - foreach ($items as $icon=>$item){ |
|
161 | - $this->addItemInToolbar($item,$icon,$callback); |
|
158 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
159 | + if (JArray::isAssociative($items)) { |
|
160 | + foreach ($items as $icon=>$item) { |
|
161 | + $this->addItemInToolbar($item, $icon, $callback); |
|
162 | 162 | } |
163 | - }else{ |
|
164 | - foreach ($items as $item){ |
|
165 | - $this->addItemInToolbar($item,null,$callback); |
|
163 | + } else { |
|
164 | + foreach ($items as $item) { |
|
165 | + $this->addItemInToolbar($item, null, $callback); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | return $this; |
169 | 169 | } |
170 | 170 | |
171 | - public function addDropdownInToolbar($value,$items=NULL,$callback=NULL){ |
|
171 | + public function addDropdownInToolbar($value, $items=NULL, $callback=NULL) { |
|
172 | 172 | $dd=$value; |
173 | 173 | if (\is_string($value)) { |
174 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
174 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
175 | 175 | } |
176 | - return $this->addInToolbar($dd,$callback); |
|
176 | + return $this->addInToolbar($dd, $callback); |
|
177 | 177 | } |
178 | 178 | |
179 | - public function addButtonInToolbar($caption,$callback=NULL){ |
|
180 | - $bt=new HtmlButton("",$caption); |
|
181 | - return $this->addInToolbar($bt,$callback); |
|
179 | + public function addButtonInToolbar($caption, $callback=NULL) { |
|
180 | + $bt=new HtmlButton("", $caption); |
|
181 | + return $this->addInToolbar($bt, $callback); |
|
182 | 182 | } |
183 | 183 | |
184 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
185 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
186 | - return $this->addInToolbar($bts,$callback); |
|
184 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
185 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
186 | + return $this->addInToolbar($bts, $callback); |
|
187 | 187 | } |
188 | 188 | |
189 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
190 | - $bt=new HtmlButton("",$caption); |
|
191 | - $bt->addIcon($icon,$before,$labeled); |
|
189 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
190 | + $bt=new HtmlButton("", $caption); |
|
191 | + $bt->addIcon($icon, $before, $labeled); |
|
192 | 192 | return $this->addInToolbar($bt); |
193 | 193 | } |
194 | 194 |
@@ -25,7 +25,7 @@ |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | public function setDisabled($disable=true) { |
28 | - if($disable) |
|
28 | + if ($disable) |
|
29 | 29 | $this->addState(State::DISABLED); |
30 | 30 | return $this; |
31 | 31 | } |
@@ -25,8 +25,9 @@ |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | public function setDisabled($disable=true) { |
28 | - if($disable) |
|
29 | - $this->addState(State::DISABLED); |
|
28 | + if($disable) { |
|
29 | + $this->addState(State::DISABLED); |
|
30 | + } |
|
30 | 31 | return $this; |
31 | 32 | } |
32 | 33 | } |
33 | 34 | \ No newline at end of file |
@@ -19,33 +19,33 @@ |
||
19 | 19 | class DataElement extends Widget { |
20 | 20 | |
21 | 21 | public function __construct($identifier, $modelInstance=NULL) { |
22 | - parent::__construct($identifier, null,$modelInstance); |
|
23 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,2), false); |
|
22 | + parent::__construct($identifier, null, $modelInstance); |
|
23 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 2), false); |
|
24 | 24 | $this->content["table"]->setDefinition(); |
25 | 25 | } |
26 | 26 | |
27 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
27 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
28 | 28 | $this->_instanceViewer->setInstance($this->_modelInstance); |
29 | 29 | |
30 | 30 | $table=$this->content["table"]; |
31 | 31 | $this->_generateContent($table); |
32 | 32 | |
33 | - if(isset($this->_toolbar)){ |
|
33 | + if (isset($this->_toolbar)) { |
|
34 | 34 | $this->_setToolbarPosition($table); |
35 | 35 | } |
36 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
37 | - return parent::compile($js,$view); |
|
36 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
37 | + return parent::compile($js, $view); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @param HtmlTable $table |
42 | 42 | */ |
43 | - protected function _generateContent($table){ |
|
43 | + protected function _generateContent($table) { |
|
44 | 44 | $captions=$this->_instanceViewer->getCaptions(); |
45 | - $values= $this->_instanceViewer->getValues(); |
|
45 | + $values=$this->_instanceViewer->getValues(); |
|
46 | 46 | $count=$this->_instanceViewer->count(); |
47 | - for($i=0;$i<$count;$i++){ |
|
48 | - $table->addRow([$captions[$i],$values[$i]]); |
|
47 | + for ($i=0; $i<$count; $i++) { |
|
48 | + $table->addRow([$captions[$i], $values[$i]]); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | protected $_hasCheckboxes; |
31 | 31 | protected $_compileParts; |
32 | 32 | |
33 | - public function run(JsUtils $js){ |
|
34 | - if($this->_hasCheckboxes && isset($js)){ |
|
33 | + public function run(JsUtils $js) { |
|
34 | + if ($this->_hasCheckboxes && isset($js)) { |
|
35 | 35 | $js->execOn("change", "#".$this->identifier." [name='selection[]']", " |
36 | 36 | var \$parentCheckbox=\$('#ck-main-ck-{$this->identifier}'),\$checkbox=\$('#{$this->identifier} [name=\"selection[]\"]'),allChecked=true,allUnchecked=true; |
37 | 37 | \$checkbox.each(function() {if($(this).prop('checked')){allUnchecked = false;}else{allChecked = false;}}); |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | parent::run($js); |
41 | 41 | } |
42 | 42 | |
43 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
44 | - parent::__construct($identifier, $model,$modelInstance); |
|
45 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
|
43 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
44 | + parent::__construct($identifier, $model, $modelInstance); |
|
45 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -54,61 +54,61 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
57 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
58 | 58 | $this->_instanceViewer->setInstance($this->_model); |
59 | 59 | $captions=$this->_instanceViewer->getCaptions(); |
60 | 60 | |
61 | 61 | $table=$this->content["table"]; |
62 | 62 | |
63 | - if($this->_hasCheckboxes){ |
|
63 | + if ($this->_hasCheckboxes) { |
|
64 | 64 | $this->_generateMainCheckbox($captions); |
65 | 65 | } |
66 | 66 | |
67 | 67 | $table->setRowCount(0, \sizeof($captions)); |
68 | 68 | $table->setHeaderValues($captions); |
69 | - if(isset($this->_compileParts)) |
|
69 | + if (isset($this->_compileParts)) |
|
70 | 70 | $table->setCompileParts($this->_compileParts); |
71 | - if(isset($this->_searchField) && isset($js)){ |
|
72 | - $this->_searchField->postOn("change", $this->_urls,"{'s':$(this).val()}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
|
71 | + if (isset($this->_searchField) && isset($js)) { |
|
72 | + $this->_searchField->postOn("change", $this->_urls, "{'s':$(this).val()}", "-#".$this->identifier." tbody", ["preventDefault"=>false]); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | $this->_generateContent($table); |
76 | 76 | |
77 | - if($this->_hasCheckboxes && $table->hasPart("thead")){ |
|
78 | - $table->getHeader()->getCell(0, 0)->addToProperty("class","no-sort"); |
|
77 | + if ($this->_hasCheckboxes && $table->hasPart("thead")) { |
|
78 | + $table->getHeader()->getCell(0, 0)->addToProperty("class", "no-sort"); |
|
79 | 79 | } |
80 | 80 | |
81 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
81 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
82 | 82 | $this->_generatePagination($table); |
83 | 83 | } |
84 | - if(isset($this->_toolbar)){ |
|
84 | + if (isset($this->_toolbar)) { |
|
85 | 85 | $this->_setToolbarPosition($table, $captions); |
86 | 86 | } |
87 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
88 | - return parent::compile($js,$view); |
|
87 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
88 | + return parent::compile($js, $view); |
|
89 | 89 | } |
90 | 90 | |
91 | - private function _generateMainCheckbox(&$captions){ |
|
92 | - $ck=new HtmlCheckbox("main-ck-".$this->identifier,""); |
|
91 | + private function _generateMainCheckbox(&$captions) { |
|
92 | + $ck=new HtmlCheckbox("main-ck-".$this->identifier, ""); |
|
93 | 93 | $ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);"); |
94 | 94 | $ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);"); |
95 | 95 | \array_unshift($captions, $ck); |
96 | 96 | } |
97 | 97 | |
98 | - protected function _generateContent($table){ |
|
98 | + protected function _generateContent($table) { |
|
99 | 99 | $objects=$this->_modelInstance; |
100 | - if(isset($this->_pagination)){ |
|
100 | + if (isset($this->_pagination)) { |
|
101 | 101 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
102 | 102 | } |
103 | 103 | InstanceViewer::setIndex(0); |
104 | - $table->fromDatabaseObjects($objects, function($instance){ |
|
104 | + $table->fromDatabaseObjects($objects, function($instance) { |
|
105 | 105 | $this->_instanceViewer->setInstance($instance); |
106 | 106 | InstanceViewer::$index++; |
107 | - $result= $this->_instanceViewer->getValues(); |
|
108 | - if($this->_hasCheckboxes){ |
|
109 | - $ck=new HtmlCheckbox("ck-".$this->identifier,""); |
|
107 | + $result=$this->_instanceViewer->getValues(); |
|
108 | + if ($this->_hasCheckboxes) { |
|
109 | + $ck=new HtmlCheckbox("ck-".$this->identifier, ""); |
|
110 | 110 | $field=$ck->getField(); |
111 | - $field->setProperty("value",$this->_instanceViewer->getIdentifier()); |
|
111 | + $field->setProperty("value", $this->_instanceViewer->getIdentifier()); |
|
112 | 112 | $field->setProperty("name", "selection[]"); |
113 | 113 | \array_unshift($result, $ck); |
114 | 114 | } |
@@ -116,25 +116,25 @@ discard block |
||
116 | 116 | }); |
117 | 117 | } |
118 | 118 | |
119 | - private function _generatePagination($table){ |
|
119 | + private function _generatePagination($table) { |
|
120 | 120 | $footer=$table->getFooter(); |
121 | 121 | $footer->mergeCol(); |
122 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
122 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
123 | 123 | $menu->floatRight(); |
124 | 124 | $menu->setActiveItem($this->_pagination->getPage()-1); |
125 | 125 | $footer->setValues($menu); |
126 | - $menu->postOnClick($this->_urls,"{'p':$(this).attr('data-page')}","-#".$this->identifier." tbody",["preventDefault"=>false]); |
|
126 | + $menu->postOnClick($this->_urls, "{'p':$(this).attr('data-page')}", "-#".$this->identifier." tbody", ["preventDefault"=>false]); |
|
127 | 127 | } |
128 | 128 | |
129 | - protected function _setToolbarPosition($table,$captions=NULL){ |
|
130 | - switch ($this->_toolbarPosition){ |
|
129 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
130 | + switch ($this->_toolbarPosition) { |
|
131 | 131 | case PositionInTable::BEFORETABLE:case PositionInTable::AFTERTABLE: |
132 | - if(isset($this->_compileParts)===false){ |
|
132 | + if (isset($this->_compileParts)===false) { |
|
133 | 133 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
134 | 134 | } |
135 | 135 | break; |
136 | 136 | case PositionInTable::HEADER:case PositionInTable::FOOTER: case PositionInTable::BODY: |
137 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
137 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
138 | 138 | break; |
139 | 139 | } |
140 | 140 | } |
@@ -146,18 +146,18 @@ discard block |
||
146 | 146 | * @param callable $callback function called after the field compilation |
147 | 147 | * @return \Ajax\semantic\widgets\datatable\DataTable |
148 | 148 | */ |
149 | - public function afterCompile($index,$callback){ |
|
150 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
149 | + public function afterCompile($index, $callback) { |
|
150 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
151 | 151 | return $this; |
152 | 152 | } |
153 | 153 | |
154 | - private function addToolbarRow($part,$table,$captions){ |
|
154 | + private function addToolbarRow($part, $table, $captions) { |
|
155 | 155 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
156 | 156 | $row->mergeCol(); |
157 | 157 | $row->setValues([$this->_toolbar]); |
158 | 158 | } |
159 | 159 | |
160 | - public function getHtmlComponent(){ |
|
160 | + public function getHtmlComponent() { |
|
161 | 161 | return $this->content["table"]; |
162 | 162 | } |
163 | 163 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | return $this; |
171 | 171 | } |
172 | 172 | |
173 | - public function paginate($items_per_page=10,$page=1){ |
|
174 | - $this->_pagination=new Pagination($items_per_page,4,$page); |
|
173 | + public function paginate($items_per_page=10, $page=1) { |
|
174 | + $this->_pagination=new Pagination($items_per_page, 4, $page); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | public function getHasCheckboxes() { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | return $this; |
184 | 184 | } |
185 | 185 | |
186 | - public function refresh($compileParts=["tbody"]){ |
|
186 | + public function refresh($compileParts=["tbody"]) { |
|
187 | 187 | $this->_compileParts=$compileParts; |
188 | 188 | return $this; |
189 | 189 | } |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | * @param callable $callback |
193 | 193 | * @return callable |
194 | 194 | */ |
195 | - private function getFieldButtonCallable($caption,$callback=null){ |
|
196 | - return $this->getCallable("getFieldButton",[$caption],$callback); |
|
195 | + private function getFieldButtonCallable($caption, $callback=null) { |
|
196 | + return $this->getCallable("getFieldButton", [$caption], $callback); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -201,16 +201,16 @@ discard block |
||
201 | 201 | * @param callable $callback |
202 | 202 | * @return callable |
203 | 203 | */ |
204 | - private function getCallable($thisCallback,$parameters,$callback=null){ |
|
205 | - $result=function($instance) use($thisCallback,$parameters,$callback){ |
|
206 | - $object=call_user_func_array(array($this,$thisCallback), $parameters); |
|
207 | - if(isset($callback)){ |
|
208 | - if(\is_callable($callback)){ |
|
209 | - $callback($object,$instance); |
|
204 | + private function getCallable($thisCallback, $parameters, $callback=null) { |
|
205 | + $result=function($instance) use($thisCallback, $parameters, $callback){ |
|
206 | + $object=call_user_func_array(array($this, $thisCallback), $parameters); |
|
207 | + if (isset($callback)) { |
|
208 | + if (\is_callable($callback)) { |
|
209 | + $callback($object, $instance); |
|
210 | 210 | } |
211 | 211 | } |
212 | - if($object instanceof HtmlSemDoubleElement){ |
|
213 | - $object->setProperty("data-ajax",$this->_instanceViewer->getIdentifier()); |
|
212 | + if ($object instanceof HtmlSemDoubleElement) { |
|
213 | + $object->setProperty("data-ajax", $this->_instanceViewer->getIdentifier()); |
|
214 | 214 | } |
215 | 215 | return $object; |
216 | 216 | }; |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * @param string $caption |
222 | 222 | * @return HtmlButton |
223 | 223 | */ |
224 | - private function getFieldButton($caption){ |
|
225 | - return new HtmlButton("",$caption); |
|
224 | + private function getFieldButton($caption) { |
|
225 | + return new HtmlButton("", $caption); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * @param callable $callback |
232 | 232 | * @return \Ajax\semantic\widgets\datatable\DataTable |
233 | 233 | */ |
234 | - public function addFieldButton($caption,$callback=null){ |
|
235 | - $this->addField($this->getCallable("getFieldButton",[$caption],$callback)); |
|
234 | + public function addFieldButton($caption, $callback=null) { |
|
235 | + $this->addField($this->getCallable("getFieldButton", [$caption], $callback)); |
|
236 | 236 | return $this; |
237 | 237 | } |
238 | 238 | |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | * @param callable $callback |
244 | 244 | * @return \Ajax\semantic\widgets\datatable\DataTable |
245 | 245 | */ |
246 | - public function insertFieldButton($index,$caption,$callback=null){ |
|
247 | - $this->insertField($index, $this->getFieldButtonCallable($caption,$callback)); |
|
246 | + public function insertFieldButton($index, $caption, $callback=null) { |
|
247 | + $this->insertField($index, $this->getFieldButtonCallable($caption, $callback)); |
|
248 | 248 | return $this; |
249 | 249 | } |
250 | 250 | |
@@ -255,60 +255,60 @@ discard block |
||
255 | 255 | * @param callable $callback |
256 | 256 | * @return \Ajax\semantic\widgets\datatable\DataTable |
257 | 257 | */ |
258 | - public function insertInFieldButton($index,$caption,$callback=null){ |
|
259 | - $this->insertInField($index, $this->getFieldButtonCallable($caption,$callback)); |
|
258 | + public function insertInFieldButton($index, $caption, $callback=null) { |
|
259 | + $this->insertInField($index, $this->getFieldButtonCallable($caption, $callback)); |
|
260 | 260 | return $this; |
261 | 261 | } |
262 | 262 | |
263 | - private function addDefaultButton($icon,$class=null,$callback=null){ |
|
264 | - $this->addField($this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
|
263 | + private function addDefaultButton($icon, $class=null, $callback=null) { |
|
264 | + $this->addField($this->getCallable("getDefaultButton", [$icon, $class], $callback)); |
|
265 | 265 | return $this; |
266 | 266 | } |
267 | 267 | |
268 | - private function insertDefaultButtonIn($index,$icon,$class=null,$callback=null){ |
|
269 | - $this->insertInField($index,$this->getCallable("getDefaultButton",[$icon,$class],$callback)); |
|
268 | + private function insertDefaultButtonIn($index, $icon, $class=null, $callback=null) { |
|
269 | + $this->insertInField($index, $this->getCallable("getDefaultButton", [$icon, $class], $callback)); |
|
270 | 270 | return $this; |
271 | 271 | } |
272 | 272 | |
273 | - private function getDefaultButton($icon,$class=null){ |
|
273 | + private function getDefaultButton($icon, $class=null) { |
|
274 | 274 | $bt=$this->getFieldButton(""); |
275 | 275 | $bt->asIcon($icon); |
276 | - if(isset($class)) |
|
276 | + if (isset($class)) |
|
277 | 277 | $bt->addToProperty("class", $class); |
278 | 278 | return $bt; |
279 | 279 | } |
280 | 280 | |
281 | - public function addDeleteButton($callback=null){ |
|
282 | - return $this->addDefaultButton("remove","delete red basic",$callback); |
|
281 | + public function addDeleteButton($callback=null) { |
|
282 | + return $this->addDefaultButton("remove", "delete red basic", $callback); |
|
283 | 283 | } |
284 | 284 | |
285 | - public function addEditButton($callback=null){ |
|
286 | - return $this->addDefaultButton("edit","edit basic",$callback); |
|
285 | + public function addEditButton($callback=null) { |
|
286 | + return $this->addDefaultButton("edit", "edit basic", $callback); |
|
287 | 287 | } |
288 | 288 | |
289 | - public function addEditDeleteButtons($callbackEdit=null,$callbackDelete=null){ |
|
289 | + public function addEditDeleteButtons($callbackEdit=null, $callbackDelete=null) { |
|
290 | 290 | $this->addEditButton($callbackEdit); |
291 | 291 | $index=$this->_instanceViewer->visiblePropertiesCount()-1; |
292 | - $this->insertDeleteButtonIn($index,$callbackDelete); |
|
292 | + $this->insertDeleteButtonIn($index, $callbackDelete); |
|
293 | 293 | return $this; |
294 | 294 | } |
295 | 295 | |
296 | - public function insertDeleteButtonIn($index,$callback=null){ |
|
297 | - return $this->insertDefaultButtonIn($index,"remove","delete red basic",$callback); |
|
296 | + public function insertDeleteButtonIn($index, $callback=null) { |
|
297 | + return $this->insertDefaultButtonIn($index, "remove", "delete red basic", $callback); |
|
298 | 298 | } |
299 | 299 | |
300 | - public function insertEditButtonIn($index,$callback=null){ |
|
301 | - return $this->insertDefaultButtonIn($index,"edit","edit basic",$callback); |
|
300 | + public function insertEditButtonIn($index, $callback=null) { |
|
301 | + return $this->insertDefaultButtonIn($index, "edit", "edit basic", $callback); |
|
302 | 302 | } |
303 | 303 | |
304 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
304 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
305 | 305 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
306 | 306 | } |
307 | 307 | |
308 | - public function getSearchField(){ |
|
309 | - if(isset($this->_searchField)===false){ |
|
310 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
311 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
308 | + public function getSearchField() { |
|
309 | + if (isset($this->_searchField)===false) { |
|
310 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
311 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
312 | 312 | } |
313 | 313 | return $this->_searchField; |
314 | 314 | } |