@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Ajax\semantic\html\collections\table\traits; |
3 | 3 | |
4 | -trait TableTrait{ |
|
4 | +trait TableTrait { |
|
5 | 5 | /** |
6 | 6 | * @return HtmlTable |
7 | 7 | */ |
8 | 8 | abstract protected function getTable(); |
9 | 9 | |
10 | - protected function addToPropertyTable($property,$value){ |
|
10 | + protected function addToPropertyTable($property, $value) { |
|
11 | 11 | return $this->getTable()->addToProperty($property, $value); |
12 | 12 | } |
13 | 13 | |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | public function setBasic($very=false) { |
19 | 19 | $table=$this->getTable(); |
20 | 20 | if ($very) |
21 | - $table->addToPropertyCtrl("class", "very", array ("very" )); |
|
22 | - return $table->addToPropertyCtrl("class", "basic", array ("basic" )); |
|
21 | + $table->addToPropertyCtrl("class", "very", array("very")); |
|
22 | + return $table->addToPropertyCtrl("class", "basic", array("basic")); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function setCollapsing() { |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | class JArray { |
6 | 6 | |
7 | 7 | public static function isAssociative($array) { |
8 | - return (array_values($array) !== $array); |
|
8 | + return (array_values($array)!==$array); |
|
9 | 9 | // return (array_keys($array)!==range(0, count($array)-1)); |
10 | 10 | } |
11 | 11 | |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | return $array[$key]; |
15 | 15 | } |
16 | 16 | $values=array_values($array); |
17 | - if ($pos < sizeof($values)) |
|
17 | + if ($pos<sizeof($values)) |
|
18 | 18 | return $values[$pos]; |
19 | 19 | } |
20 | 20 | |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | $result=NULL; |
23 | 23 | if (array_key_exists($key, $array)) { |
24 | 24 | $result=$array[$key]; |
25 | - if ($condition($result) === true) |
|
25 | + if ($condition($result)===true) |
|
26 | 26 | return $result; |
27 | 27 | } |
28 | 28 | $values=array_values($array); |
29 | - foreach ( $values as $val ) { |
|
30 | - if ($condition($val) === true) |
|
29 | + foreach ($values as $val) { |
|
30 | + if ($condition($val)===true) |
|
31 | 31 | return $val; |
32 | 32 | } |
33 | 33 | return $result; |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | $result=""; |
45 | 45 | if (\is_array($glue)) { |
46 | 46 | $size=\sizeof($pieces); |
47 | - if ($size > 0) { |
|
48 | - for($i=0; $i < $size - 1; $i++) { |
|
49 | - $result.=$pieces[$i] . @$glue[$i]; |
|
47 | + if ($size>0) { |
|
48 | + for ($i=0; $i<$size-1; $i++) { |
|
49 | + $result.=$pieces[$i].@$glue[$i]; |
|
50 | 50 | } |
51 | - $result.=$pieces[$size - 1]; |
|
51 | + $result.=$pieces[$size-1]; |
|
52 | 52 | } |
53 | 53 | } else { |
54 | 54 | $result=\implode($glue, $pieces); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | public static function dimension($array) { |
60 | 60 | if (is_array(reset($array))) { |
61 | - $return=self::dimension(reset($array)) + 1; |
|
61 | + $return=self::dimension(reset($array))+1; |
|
62 | 62 | } else { |
63 | 63 | $return=1; |
64 | 64 | } |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | public static function sortAssociative($array, $sortedKeys=array()) { |
69 | - $newArray=array (); |
|
70 | - foreach ( $sortedKeys as $key ) { |
|
69 | + $newArray=array(); |
|
70 | + foreach ($sortedKeys as $key) { |
|
71 | 71 | if (\array_key_exists($key, $array)) { |
72 | 72 | $newArray[$key]=$array[$key]; |
73 | 73 | } |
@@ -75,27 +75,27 @@ discard block |
||
75 | 75 | return $newArray; |
76 | 76 | } |
77 | 77 | |
78 | - public static function modelArray($objects,$identifierFunction=NULL,$modelFunction=NULL){ |
|
78 | + public static function modelArray($objects, $identifierFunction=NULL, $modelFunction=NULL) { |
|
79 | 79 | $result=[]; |
80 | - if(isset($modelFunction)===false){ |
|
80 | + if (isset($modelFunction)===false) { |
|
81 | 81 | $modelFunction="__toString"; |
82 | 82 | } |
83 | - if(isset($identifierFunction)===false){ |
|
84 | - foreach ($objects as $object){ |
|
83 | + if (isset($identifierFunction)===false) { |
|
84 | + foreach ($objects as $object) { |
|
85 | 85 | $result[]=self::callFunction($object, $modelFunction); |
86 | 86 | } |
87 | - }else{ |
|
88 | - foreach ($objects as $object){ |
|
87 | + } else { |
|
88 | + foreach ($objects as $object) { |
|
89 | 89 | $result[self::callFunction($object, $identifierFunction)]=self::callFunction($object, $modelFunction); |
90 | 90 | } |
91 | 91 | } |
92 | 92 | return $result; |
93 | 93 | } |
94 | 94 | |
95 | - private static function callFunction($object,$callback){ |
|
96 | - if(\is_string($callback)) |
|
97 | - return \call_user_func(array($object, $callback),[]); |
|
98 | - else if (\is_callable($callback)){ |
|
95 | + private static function callFunction($object, $callback) { |
|
96 | + if (\is_string($callback)) |
|
97 | + return \call_user_func(array($object, $callback), []); |
|
98 | + else if (\is_callable($callback)) { |
|
99 | 99 | return $callback($object); |
100 | 100 | } |
101 | 101 | } |
@@ -7,21 +7,21 @@ |
||
7 | 7 | |
8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
9 | 9 | |
10 | - public function __construct($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false,$associative=true) { |
|
11 | - parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label); |
|
10 | + public function __construct($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false, $associative=true) { |
|
11 | + parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label); |
|
12 | 12 | } |
13 | 13 | |
14 | - public function setItems($items){ |
|
14 | + public function setItems($items) { |
|
15 | 15 | return $this->getField()->setItems($items); |
16 | 16 | } |
17 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
18 | - return $this->getField()->addItem($item,$value,$image); |
|
17 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
18 | + return $this->getField()->addItem($item, $value, $image); |
|
19 | 19 | } |
20 | - public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$associative=true){ |
|
21 | - return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative); |
|
20 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $associative=true) { |
|
21 | + return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative); |
|
22 | 22 | } |
23 | 23 | |
24 | - public function getDataField(){ |
|
24 | + public function getDataField() { |
|
25 | 25 | return $this->getField()->getInput(); |
26 | 26 | } |
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return HtmlModal |
87 | 87 | */ |
88 | 88 | public function htmlModal($identifier, $header="", $content="", $actions=array()) { |
89 | - return $this->addHtmlComponent(new HtmlModal($identifier, $header,$content,$actions)); |
|
89 | + return $this->addHtmlComponent(new HtmlModal($identifier, $header, $content, $actions)); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | * @param boolean $associative |
118 | 118 | * @return HtmlDropdown |
119 | 119 | */ |
120 | - public function htmlDropdown($identifier, $value="", $items=array(),$associative=true) { |
|
121 | - return $this->addHtmlComponent(new HtmlDropdown($identifier, $value, $items,$associative)); |
|
120 | + public function htmlDropdown($identifier, $value="", $items=array(), $associative=true) { |
|
121 | + return $this->addHtmlComponent(new HtmlDropdown($identifier, $value, $items, $associative)); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -14,60 +14,60 @@ |
||
14 | 14 | protected $params; |
15 | 15 | protected $semElement; |
16 | 16 | |
17 | - public function __construct($semElement,$title="",$content="",$variation=NULL,$params=array()){ |
|
17 | + public function __construct($semElement, $title="", $content="", $variation=NULL, $params=array()) { |
|
18 | 18 | $this->semElement=$semElement; |
19 | 19 | $this->title=$title; |
20 | 20 | $this->content=$content; |
21 | - $this->setAttributes($variation,$params); |
|
21 | + $this->setAttributes($variation, $params); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function setHtml($html) { |
25 | - $this->html= $html; |
|
25 | + $this->html=$html; |
|
26 | 26 | return $this; |
27 | 27 | } |
28 | 28 | |
29 | - public function setAttributes($variation=NULL,$params=array()){ |
|
29 | + public function setAttributes($variation=NULL, $params=array()) { |
|
30 | 30 | $this->variation=$variation; |
31 | 31 | $this->params=$params; |
32 | 32 | } |
33 | 33 | |
34 | - public function onShow($jsCode){ |
|
34 | + public function onShow($jsCode) { |
|
35 | 35 | $this->params["onShow"]=$jsCode; |
36 | 36 | } |
37 | 37 | |
38 | - public function compile(JsUtils $js=NULL){ |
|
39 | - if(JString::isNotNull($this->title)){ |
|
38 | + public function compile(JsUtils $js=NULL) { |
|
39 | + if (JString::isNotNull($this->title)) { |
|
40 | 40 | $this->semElement->addToProperty("data-title", $this->title); |
41 | 41 | } |
42 | - if(JString::isNotNull($this->content)){ |
|
42 | + if (JString::isNotNull($this->content)) { |
|
43 | 43 | $this->semElement->addToProperty("data-content", $this->content); |
44 | 44 | } |
45 | - if(JString::isNotNull($this->html)){ |
|
45 | + if (JString::isNotNull($this->html)) { |
|
46 | 46 | $html=$this->html; |
47 | - if(\is_array($html)){ |
|
47 | + if (\is_array($html)) { |
|
48 | 48 | \array_walk($html, function(&$item) use($js){ |
49 | - if($item instanceof HtmlSemDoubleElement){ |
|
49 | + if ($item instanceof HtmlSemDoubleElement) { |
|
50 | 50 | $comp=$item->compile($js); |
51 | - if(isset($js)){ |
|
51 | + if (isset($js)) { |
|
52 | 52 | $bs=$item->run($js); |
53 | - if(isset($bs)) |
|
53 | + if (isset($bs)) |
|
54 | 54 | $this->params['onShow']=$bs->getScript(); |
55 | 55 | } |
56 | 56 | $item=$comp; |
57 | 57 | } |
58 | 58 | }); |
59 | - $html=\implode("",$html); |
|
59 | + $html=\implode("", $html); |
|
60 | 60 | } |
61 | 61 | $html=\str_replace("\"", "'", $html); |
62 | 62 | $this->semElement->addToProperty("data-html", $html); |
63 | 63 | } |
64 | - if(JString::isNotNull($this->variation)){ |
|
64 | + if (JString::isNotNull($this->variation)) { |
|
65 | 65 | $this->semElement->addToProperty("data-variation", $this->variation); |
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | - public function run(JsUtils $js){ |
|
70 | - $js->semantic()->popup("#".$this->semElement->getIdentifier(),$this->params); |
|
69 | + public function run(JsUtils $js) { |
|
70 | + $js->semantic()->popup("#".$this->semElement->getIdentifier(), $this->params); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | } |
74 | 74 | \ No newline at end of file |
@@ -3,8 +3,8 @@ |
||
3 | 3 | namespace Ajax\service; |
4 | 4 | |
5 | 5 | class Javascript { |
6 | - public static function containsCode($expression){ |
|
7 | - return strrpos($expression, 'this')!==false||strrpos($expression, 'event')!==false||strrpos($expression, 'self')!==false; |
|
6 | + public static function containsCode($expression) { |
|
7 | + return strrpos($expression, 'this')!==false || strrpos($expression, 'event')!==false || strrpos($expression, 'self')!==false; |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | /** |
@@ -12,36 +12,36 @@ discard block |
||
12 | 12 | */ |
13 | 13 | abstract class HtmlCollection extends HtmlDoubleElement { |
14 | 14 | |
15 | - public function __construct($identifier,$tagName="div"){ |
|
16 | - parent::__construct($identifier,$tagName); |
|
15 | + public function __construct($identifier, $tagName="div") { |
|
16 | + parent::__construct($identifier, $tagName); |
|
17 | 17 | $this->content=array(); |
18 | 18 | } |
19 | 19 | |
20 | - public function addItems($items){ |
|
21 | - if(JArray::isAssociative($items)){ |
|
22 | - foreach ($items as $k=>$v){ |
|
23 | - $this->addItem([$k,$v]); |
|
20 | + public function addItems($items) { |
|
21 | + if (JArray::isAssociative($items)) { |
|
22 | + foreach ($items as $k=>$v) { |
|
23 | + $this->addItem([$k, $v]); |
|
24 | 24 | } |
25 | - }else{ |
|
26 | - foreach ($items as $item){ |
|
25 | + } else { |
|
26 | + foreach ($items as $item) { |
|
27 | 27 | $this->addItem($item); |
28 | 28 | } |
29 | 29 | } |
30 | 30 | return $this; |
31 | 31 | } |
32 | 32 | |
33 | - public function setItems($items){ |
|
33 | + public function setItems($items) { |
|
34 | 34 | $this->content=$items; |
35 | 35 | return $this; |
36 | 36 | } |
37 | 37 | |
38 | - public function getItems(){ |
|
38 | + public function getItems() { |
|
39 | 39 | return $this->content; |
40 | 40 | } |
41 | 41 | |
42 | - protected function getItemToAdd($item){ |
|
42 | + protected function getItemToAdd($item) { |
|
43 | 43 | $itemO=$item; |
44 | - if($this->createCondition($item)===true){ |
|
44 | + if ($this->createCondition($item)===true) { |
|
45 | 45 | $itemO=$this->createItem($item); |
46 | 46 | } |
47 | 47 | return $itemO; |
@@ -52,15 +52,15 @@ discard block |
||
52 | 52 | * @param HtmlDoubleElement|string|array $item |
53 | 53 | * @return \Ajax\common\html\HtmlDoubleElement |
54 | 54 | */ |
55 | - public function addItem($item){ |
|
55 | + public function addItem($item) { |
|
56 | 56 | $itemO=$this->getItemToAdd($item); |
57 | 57 | $this->addContent($itemO); |
58 | 58 | return $itemO; |
59 | 59 | } |
60 | 60 | |
61 | - public function insertItem($item,$position=0){ |
|
61 | + public function insertItem($item, $position=0) { |
|
62 | 62 | $itemO=$this->getItemToAdd($item); |
63 | - \array_splice( $this->content, $position, 0, array($itemO)); |
|
63 | + \array_splice($this->content, $position, 0, array($itemO)); |
|
64 | 64 | return $itemO; |
65 | 65 | } |
66 | 66 | |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | return $this; |
84 | 84 | } |
85 | 85 | |
86 | - public function removeItem($index){ |
|
86 | + public function removeItem($index) { |
|
87 | 87 | return array_splice($this->content, $index, 1); |
88 | 88 | } |
89 | 89 | |
90 | - public function count(){ |
|
90 | + public function count() { |
|
91 | 91 | return \sizeof($this->content); |
92 | 92 | } |
93 | 93 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | return $this->addItem($function($object)); |
99 | 99 | } |
100 | 100 | |
101 | - public function apply($callBack){ |
|
102 | - foreach ($this->content as $item){ |
|
101 | + public function apply($callBack) { |
|
102 | + foreach ($this->content as $item) { |
|
103 | 103 | $callBack($item); |
104 | 104 | } |
105 | 105 | return $this; |
@@ -119,40 +119,40 @@ discard block |
||
119 | 119 | */ |
120 | 120 | protected abstract function createItem($value); |
121 | 121 | |
122 | - protected function createCondition($value){ |
|
122 | + protected function createCondition($value) { |
|
123 | 123 | return \is_object($value)===false; |
124 | 124 | } |
125 | 125 | |
126 | - protected function contentAs($tagName){ |
|
127 | - foreach ($this->content as $item){ |
|
126 | + protected function contentAs($tagName) { |
|
127 | + foreach ($this->content as $item) { |
|
128 | 128 | $item->setTagName($tagName); |
129 | 129 | } |
130 | 130 | return $this; |
131 | 131 | } |
132 | 132 | |
133 | - public function setProperties($properties){ |
|
133 | + public function setProperties($properties) { |
|
134 | 134 | $i=0; |
135 | - foreach ($properties as $k=>$v){ |
|
135 | + foreach ($properties as $k=>$v) { |
|
136 | 136 | $c=$this->content[$i++]; |
137 | - if(isset($c)) |
|
138 | - $c->setProperty($k,$v); |
|
137 | + if (isset($c)) |
|
138 | + $c->setProperty($k, $v); |
|
139 | 139 | else |
140 | 140 | return $this; |
141 | 141 | } |
142 | 142 | return $this; |
143 | 143 | } |
144 | 144 | |
145 | - public function setPropertyValues($property,$values){ |
|
145 | + public function setPropertyValues($property, $values) { |
|
146 | 146 | $i=0; |
147 | - if(\is_array($values)===false){ |
|
148 | - $values=\array_fill(0, $this->count(),$values); |
|
147 | + if (\is_array($values)===false) { |
|
148 | + $values=\array_fill(0, $this->count(), $values); |
|
149 | 149 | } |
150 | - foreach ($values as $value){ |
|
150 | + foreach ($values as $value) { |
|
151 | 151 | $c=$this->content[$i++]; |
152 | - if(isset($c)){ |
|
153 | - $c->setProperty($property,$value); |
|
152 | + if (isset($c)) { |
|
153 | + $c->setProperty($property, $value); |
|
154 | 154 | } |
155 | - else{ |
|
155 | + else { |
|
156 | 156 | return $this; |
157 | 157 | } |
158 | 158 | } |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | protected $_toolbarPosition; |
35 | 35 | |
36 | 36 | |
37 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
37 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
38 | 38 | parent::__construct($identifier); |
39 | 39 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
40 | 40 | $this->setModel($model); |
41 | - if(isset($modelInstance)); |
|
41 | + if (isset($modelInstance)); |
|
42 | 42 | $this->show($modelInstance); |
43 | 43 | } |
44 | 44 | |
45 | - protected function _getFieldIdentifier($prefix){ |
|
45 | + protected function _getFieldIdentifier($prefix) { |
|
46 | 46 | return $this->identifier."-{$prefix}-".$this->_instanceViewer->getIdentifier(); |
47 | 47 | } |
48 | 48 | |
49 | - abstract protected function _setToolbarPosition($table,$captions=NULL); |
|
49 | + abstract protected function _setToolbarPosition($table, $captions=NULL); |
|
50 | 50 | |
51 | - public function show($modelInstance){ |
|
51 | + public function show($modelInstance) { |
|
52 | 52 | $this->_modelInstance=$modelInstance; |
53 | 53 | } |
54 | 54 | |
@@ -72,42 +72,42 @@ discard block |
||
72 | 72 | |
73 | 73 | public abstract function getHtmlComponent(); |
74 | 74 | |
75 | - public function setColor($color){ |
|
75 | + public function setColor($color) { |
|
76 | 76 | return $this->getHtmlComponent()->setColor($color); |
77 | 77 | } |
78 | 78 | |
79 | 79 | |
80 | - public function setCaptions($captions){ |
|
80 | + public function setCaptions($captions) { |
|
81 | 81 | $this->_instanceViewer->setCaptions($captions); |
82 | 82 | return $this; |
83 | 83 | } |
84 | 84 | |
85 | - public function setFields($fields){ |
|
85 | + public function setFields($fields) { |
|
86 | 86 | $this->_instanceViewer->setVisibleProperties($fields); |
87 | 87 | return $this; |
88 | 88 | } |
89 | 89 | |
90 | - public function addField($field){ |
|
90 | + public function addField($field) { |
|
91 | 91 | $this->_instanceViewer->addField($field); |
92 | 92 | return $this; |
93 | 93 | } |
94 | 94 | |
95 | - public function insertField($index,$field){ |
|
95 | + public function insertField($index, $field) { |
|
96 | 96 | $this->_instanceViewer->insertField($index, $field); |
97 | 97 | return $this; |
98 | 98 | } |
99 | 99 | |
100 | - public function insertInField($index,$field){ |
|
100 | + public function insertInField($index, $field) { |
|
101 | 101 | $this->_instanceViewer->insertInField($index, $field); |
102 | 102 | return $this; |
103 | 103 | } |
104 | 104 | |
105 | - public function setValueFunction($index,$callback){ |
|
105 | + public function setValueFunction($index, $callback) { |
|
106 | 106 | $this->_instanceViewer->setValueFunction($index, $callback); |
107 | 107 | return $this; |
108 | 108 | } |
109 | 109 | |
110 | - public function setIdentifierFunction($callback){ |
|
110 | + public function setIdentifierFunction($callback) { |
|
111 | 111 | $this->_instanceViewer->setIdentifierFunction($callback); |
112 | 112 | return $this; |
113 | 113 | } |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | /** |
116 | 116 | * @return \Ajax\semantic\html\collections\menus\HtmlMenu |
117 | 117 | */ |
118 | - public function getToolbar(){ |
|
119 | - if(isset($this->_toolbar)===false){ |
|
118 | + public function getToolbar() { |
|
119 | + if (isset($this->_toolbar)===false) { |
|
120 | 120 | $this->_toolbar=new HtmlMenu("toolbar-".$this->identifier); |
121 | 121 | //$this->_toolbar->setSecondary(); |
122 | 122 | } |
@@ -129,57 +129,57 @@ discard block |
||
129 | 129 | * @param callable $callback function to call on $element |
130 | 130 | * @return \Ajax\common\html\HtmlDoubleElement |
131 | 131 | */ |
132 | - public function addInToolbar($element,$callback=NULL){ |
|
132 | + public function addInToolbar($element, $callback=NULL) { |
|
133 | 133 | $tb=$this->getToolbar(); |
134 | - if(isset($callback)){ |
|
135 | - if(\is_callable($callback)){ |
|
134 | + if (isset($callback)) { |
|
135 | + if (\is_callable($callback)) { |
|
136 | 136 | $callback($element); |
137 | 137 | } |
138 | 138 | } |
139 | 139 | return $tb->addItem($element); |
140 | 140 | } |
141 | 141 | |
142 | - public function addItemInToolbar($caption,$icon=NULL,$callback=NULL){ |
|
143 | - $result=$this->addInToolbar($caption,$callback); |
|
144 | - if(isset($icon)) |
|
142 | + public function addItemInToolbar($caption, $icon=NULL, $callback=NULL) { |
|
143 | + $result=$this->addInToolbar($caption, $callback); |
|
144 | + if (isset($icon)) |
|
145 | 145 | $result->addIcon($icon); |
146 | 146 | return $result; |
147 | 147 | } |
148 | 148 | |
149 | - public function addItemsInToolbar(array $items,$callback=NULL){ |
|
150 | - if(JArray::isAssociative($items)){ |
|
151 | - foreach ($items as $icon=>$item){ |
|
152 | - $this->addItemInToolbar($item,$icon,$callback); |
|
149 | + public function addItemsInToolbar(array $items, $callback=NULL) { |
|
150 | + if (JArray::isAssociative($items)) { |
|
151 | + foreach ($items as $icon=>$item) { |
|
152 | + $this->addItemInToolbar($item, $icon, $callback); |
|
153 | 153 | } |
154 | - }else{ |
|
155 | - foreach ($items as $item){ |
|
156 | - $this->addItemInToolbar($item,null,$callback); |
|
154 | + } else { |
|
155 | + foreach ($items as $item) { |
|
156 | + $this->addItemInToolbar($item, null, $callback); |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | return $this; |
160 | 160 | } |
161 | 161 | |
162 | - public function addDropdownInToolbar($value,$items=NULL,$callback=NULL){ |
|
162 | + public function addDropdownInToolbar($value, $items=NULL, $callback=NULL) { |
|
163 | 163 | $dd=$value; |
164 | 164 | if (\is_string($value)) { |
165 | - $dd=new HtmlDropdown("dropdown-". $this->identifier."-".$value, $value, $items); |
|
165 | + $dd=new HtmlDropdown("dropdown-".$this->identifier."-".$value, $value, $items); |
|
166 | 166 | } |
167 | - return $this->addInToolbar($dd,$callback); |
|
167 | + return $this->addInToolbar($dd, $callback); |
|
168 | 168 | } |
169 | 169 | |
170 | - public function addButtonInToolbar($caption,$callback=NULL){ |
|
171 | - $bt=new HtmlButton("",$caption); |
|
172 | - return $this->addInToolbar($bt,$callback); |
|
170 | + public function addButtonInToolbar($caption, $callback=NULL) { |
|
171 | + $bt=new HtmlButton("", $caption); |
|
172 | + return $this->addInToolbar($bt, $callback); |
|
173 | 173 | } |
174 | 174 | |
175 | - public function addButtonsInToolbar(array $captions,$asIcon=false,$callback=NULL){ |
|
176 | - $bts=new HtmlButtonGroups("",$captions,$asIcon); |
|
177 | - return $this->addInToolbar($bts,$callback); |
|
175 | + public function addButtonsInToolbar(array $captions, $asIcon=false, $callback=NULL) { |
|
176 | + $bts=new HtmlButtonGroups("", $captions, $asIcon); |
|
177 | + return $this->addInToolbar($bts, $callback); |
|
178 | 178 | } |
179 | 179 | |
180 | - public function addLabelledIconButtonInToolbar($caption,$icon,$before=true,$labeled=false){ |
|
181 | - $bt=new HtmlButton("",$caption); |
|
182 | - $bt->addIcon($icon,$before,$labeled); |
|
180 | + public function addLabelledIconButtonInToolbar($caption, $icon, $before=true, $labeled=false) { |
|
181 | + $bt=new HtmlButton("", $caption); |
|
182 | + $bt->addIcon($icon, $before, $labeled); |
|
183 | 183 | return $this->addInToolbar($bt); |
184 | 184 | } |
185 | 185 |
@@ -6,27 +6,27 @@ discard block |
||
6 | 6 | use Symfony\Component\HttpFoundation\Request; |
7 | 7 | use Symfony\Component\HttpKernel\HttpKernelInterface; |
8 | 8 | use Ajax\service\JString; |
9 | -class JsUtils extends \Ajax\JsUtils{ |
|
10 | - public function getUrl($url){ |
|
9 | +class JsUtils extends \Ajax\JsUtils { |
|
10 | + public function getUrl($url) { |
|
11 | 11 | //$request = Request::createFromGlobals(); |
12 | 12 | $router=$this->getInjected(); |
13 | - if(isset($router)){ |
|
13 | + if (isset($router)) { |
|
14 | 14 | try { |
15 | 15 | $url=$router->generate($url); |
16 | - }catch (\Exception $e){ |
|
16 | + }catch (\Exception $e) { |
|
17 | 17 | return $router->getContext()->getBaseUrl(); |
18 | 18 | } |
19 | 19 | } |
20 | 20 | return $url; |
21 | 21 | } |
22 | - public function addViewElement($identifier,$content,&$view){ |
|
23 | - if(\array_key_exists("q", $view)===false){ |
|
22 | + public function addViewElement($identifier, $content, &$view) { |
|
23 | + if (\array_key_exists("q", $view)===false) { |
|
24 | 24 | $view["q"]=array(); |
25 | 25 | } |
26 | 26 | $view["q"][$identifier]=$content; |
27 | 27 | } |
28 | 28 | |
29 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
29 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
30 | 30 | $view[$view_var]=$output; |
31 | 31 | } |
32 | 32 | |
@@ -37,17 +37,17 @@ discard block |
||
37 | 37 | * @param array $params |
38 | 38 | * @see \Ajax\JsUtils::forward() |
39 | 39 | */ |
40 | - public function forward($initialControllerInstance,$controllerName,$actionName,$params=array()){ |
|
40 | + public function forward($initialControllerInstance, $controllerName, $actionName, $params=array()) { |
|
41 | 41 | $path=$params; |
42 | - $request = $initialControllerInstance->get('request_stack')->getCurrentRequest(); |
|
43 | - $path['_forwarded'] = $request->attributes; |
|
44 | - $path['_controller'] = $controllerName.":".$actionName; |
|
45 | - $subRequest = $request->duplicate([], null, $path); |
|
46 | - $response= $initialControllerInstance->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST); |
|
42 | + $request=$initialControllerInstance->get('request_stack')->getCurrentRequest(); |
|
43 | + $path['_forwarded']=$request->attributes; |
|
44 | + $path['_controller']=$controllerName.":".$actionName; |
|
45 | + $subRequest=$request->duplicate([], null, $path); |
|
46 | + $response=$initialControllerInstance->get('http_kernel')->handle($subRequest, HttpKernelInterface::SUB_REQUEST); |
|
47 | 47 | return $response->getContent(); |
48 | 48 | } |
49 | 49 | |
50 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
50 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
51 | 51 | if ($initialControllerInstance->has('templating')) { |
52 | 52 | return $initialControllerInstance->get('templating')->render($viewName, $params); |
53 | 53 | } |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | return $initialControllerInstance->get('twig')->render($viewName, $params); |
60 | 60 | } |
61 | 61 | |
62 | - public function fromDispatcher($dispatcher){ |
|
63 | - $request = $dispatcher->get('request_stack')->getCurrentRequest(); |
|
62 | + public function fromDispatcher($dispatcher) { |
|
63 | + $request=$dispatcher->get('request_stack')->getCurrentRequest(); |
|
64 | 64 | $uri=$request->getPathInfo(); |
65 | - if(JString::startswith($uri, "/")){ |
|
65 | + if (JString::startswith($uri, "/")) { |
|
66 | 66 | $uri=\substr($uri, 1); |
67 | 67 | } |
68 | 68 | return \explode("/", $uri); |