@@ -6,8 +6,9 @@ |
||
6 | 6 | |
7 | 7 | class JsUtils extends \Ajax\JsUtils{ |
8 | 8 | public function getUrl($url){ |
9 | - if($url==="") |
|
10 | - $url="/"; |
|
9 | + if($url==="") { |
|
10 | + $url="/"; |
|
11 | + } |
|
11 | 12 | return Url::toRoute($url); |
12 | 13 | } |
13 | 14 |
@@ -4,14 +4,14 @@ discard block |
||
4 | 4 | |
5 | 5 | use yii\helpers\Url; |
6 | 6 | |
7 | -class JsUtils extends \Ajax\JsUtils{ |
|
8 | - public function getUrl($url){ |
|
9 | - if($url==="") |
|
7 | +class JsUtils extends \Ajax\JsUtils { |
|
8 | + public function getUrl($url) { |
|
9 | + if ($url==="") |
|
10 | 10 | $url="/"; |
11 | 11 | return Url::toRoute($url); |
12 | 12 | } |
13 | 13 | |
14 | - public function addViewElement($identifier,$content,&$view){ |
|
14 | + public function addViewElement($identifier, $content, &$view) { |
|
15 | 15 | $params=$view->params; |
16 | 16 | if (\array_key_exists("q", $params)==false) { |
17 | 17 | $view->params["q"]=array(); |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | $view->params["q"][$identifier]=$content; |
20 | 20 | } |
21 | 21 | |
22 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
22 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
23 | 23 | $view->params[$view_var]=$output; |
24 | 24 | } |
25 | 25 | |
26 | - public function forward($initialControllerInstance,$controllerName,$actionName,$params=array()){ |
|
26 | + public function forward($initialControllerInstance, $controllerName, $actionName, $params=array()) { |
|
27 | 27 | \ob_start(); |
28 | 28 | $ctrInfo=\yii::$app->createController($controllerName."/".$actionName); |
29 | 29 | $ctrInfo[0]->{$ctrInfo[1]}($params); |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | return $result; |
33 | 33 | } |
34 | 34 | |
35 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
36 | - return \yii::$app->view->render($viewName,$params); |
|
35 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
36 | + return \yii::$app->view->render($viewName, $params); |
|
37 | 37 | } |
38 | 38 | |
39 | - public function fromDispatcher($dispatcher){ |
|
39 | + public function fromDispatcher($dispatcher) { |
|
40 | 40 | $uri=new \Ajax\php\yii\URI(); |
41 | 41 | return $uri->segment_array(); |
42 | 42 | } |
@@ -14,6 +14,9 @@ discard block |
||
14 | 14 | protected $_params=array(); |
15 | 15 | protected $_paramParts=array(); |
16 | 16 | |
17 | + /** |
|
18 | + * @param string $identifier |
|
19 | + */ |
|
17 | 20 | public function __construct($identifier, $header="", $content="", $actions=array()) { |
18 | 21 | parent::__construct($identifier, "div","ui modal"); |
19 | 22 | if(isset($header)){ |
@@ -27,6 +30,9 @@ discard block |
||
27 | 30 | } |
28 | 31 | } |
29 | 32 | |
33 | + /** |
|
34 | + * @param string $value |
|
35 | + */ |
|
30 | 36 | public function setHeader($value) { |
31 | 37 | $this->content["header"]=new HtmlSemDoubleElement("header-" . $this->identifier, "a", "header", $value); |
32 | 38 | return $this; |
@@ -103,6 +109,9 @@ discard block |
||
103 | 109 | return $this->addElementInPart(new HtmlSemDoubleElement($part."-" . $this->identifier, "div", $uiClass, $content), $part); |
104 | 110 | } |
105 | 111 | |
112 | + /** |
|
113 | + * @param BaseHtml $element |
|
114 | + */ |
|
106 | 115 | private function addElementInPart($element,$part) { |
107 | 116 | $this->content[$part]->addContent($element); |
108 | 117 | return $element; |
@@ -141,7 +150,6 @@ discard block |
||
141 | 150 | /** |
142 | 151 | * render the content of $controller::$action and set the response to the modal content |
143 | 152 | * @param JsUtils $js |
144 | - * @param string $title The panel title |
|
145 | 153 | * @param Controller $initialControllerInstance |
146 | 154 | * @param string $controllerName the controller name |
147 | 155 | * @param string $actionName the action name |
@@ -43,8 +43,7 @@ discard block |
||
43 | 43 | foreach ($actions as $action){ |
44 | 44 | $this->addAction($action); |
45 | 45 | } |
46 | - } |
|
47 | - else{ |
|
46 | + } else{ |
|
48 | 47 | $this->addAction($actions); |
49 | 48 | } |
50 | 49 | return $this; |
@@ -60,8 +59,9 @@ discard block |
||
60 | 59 | $class="cancel"; |
61 | 60 | } |
62 | 61 | $action=new HtmlButton("action-".$this->identifier,$action); |
63 | - if($class!=="") |
|
64 | - $action->addToProperty("class", $class); |
|
62 | + if($class!=="") { |
|
63 | + $action->addToProperty("class", $class); |
|
64 | + } |
|
65 | 65 | } |
66 | 66 | return $this->addElementInPart($action, "actions"); |
67 | 67 | } |
@@ -165,8 +165,9 @@ discard block |
||
165 | 165 | * @see BaseHtml::run() |
166 | 166 | */ |
167 | 167 | public function run(JsUtils $js) { |
168 | - if(isset($this->_bsComponent)===false) |
|
169 | - $this->_bsComponent=$js->semantic()->modal("#".$this->identifier,$this->_params,$this->_paramParts); |
|
168 | + if(isset($this->_bsComponent)===false) { |
|
169 | + $this->_bsComponent=$js->semantic()->modal("#".$this->identifier,$this->_params,$this->_paramParts); |
|
170 | + } |
|
170 | 171 | $this->addEventsOnRun($js); |
171 | 172 | return $this->_bsComponent; |
172 | 173 | } |
@@ -15,120 +15,120 @@ discard block |
||
15 | 15 | protected $_paramParts=array(); |
16 | 16 | |
17 | 17 | public function __construct($identifier, $header="", $content="", $actions=array()) { |
18 | - parent::__construct($identifier, "div","ui modal"); |
|
19 | - if(isset($header)){ |
|
18 | + parent::__construct($identifier, "div", "ui modal"); |
|
19 | + if (isset($header)) { |
|
20 | 20 | $this->setHeader($header); |
21 | 21 | } |
22 | - if(isset($content)){ |
|
22 | + if (isset($content)) { |
|
23 | 23 | $this->setContent($content); |
24 | 24 | } |
25 | - if(isset($actions)){ |
|
25 | + if (isset($actions)) { |
|
26 | 26 | $this->setActions($actions); |
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function setHeader($value) { |
31 | - $this->content["header"]=new HtmlSemDoubleElement("header-" . $this->identifier, "a", "header", $value); |
|
31 | + $this->content["header"]=new HtmlSemDoubleElement("header-".$this->identifier, "a", "header", $value); |
|
32 | 32 | return $this; |
33 | 33 | } |
34 | 34 | |
35 | 35 | public function setContent($value) { |
36 | - $this->content["content"]=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", $value); |
|
36 | + $this->content["content"]=new HtmlSemDoubleElement("content-".$this->identifier, "div", "content", $value); |
|
37 | 37 | return $this; |
38 | 38 | } |
39 | 39 | |
40 | 40 | public function setActions($actions) { |
41 | - $this->content["actions"]=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "actions"); |
|
42 | - if(\is_array($actions)){ |
|
43 | - foreach ($actions as $action){ |
|
41 | + $this->content["actions"]=new HtmlSemDoubleElement("content-".$this->identifier, "div", "actions"); |
|
42 | + if (\is_array($actions)) { |
|
43 | + foreach ($actions as $action) { |
|
44 | 44 | $this->addAction($action); |
45 | 45 | } |
46 | 46 | } |
47 | - else{ |
|
47 | + else { |
|
48 | 48 | $this->addAction($actions); |
49 | 49 | } |
50 | 50 | return $this; |
51 | 51 | } |
52 | 52 | |
53 | - public function addAction($action){ |
|
54 | - if(!$action instanceof BaseHtml){ |
|
53 | + public function addAction($action) { |
|
54 | + if (!$action instanceof BaseHtml) { |
|
55 | 55 | $class=""; |
56 | - if(\array_search($action, ["Okay","Yes"])!==false){ |
|
56 | + if (\array_search($action, ["Okay", "Yes"])!==false) { |
|
57 | 57 | $class="approve"; |
58 | 58 | } |
59 | - if(\array_search($action, ["Cancel","No"])!==false){ |
|
59 | + if (\array_search($action, ["Cancel", "No"])!==false) { |
|
60 | 60 | $class="cancel"; |
61 | 61 | } |
62 | - $action=new HtmlButton("action-".$this->identifier,$action); |
|
63 | - if($class!=="") |
|
62 | + $action=new HtmlButton("action-".$this->identifier, $action); |
|
63 | + if ($class!=="") |
|
64 | 64 | $action->addToProperty("class", $class); |
65 | 65 | } |
66 | 66 | return $this->addElementInPart($action, "actions"); |
67 | 67 | } |
68 | 68 | |
69 | - public function addContent($content,$before=false){ |
|
70 | - $this->content["content"]->addContent($content,$before); |
|
69 | + public function addContent($content, $before=false) { |
|
70 | + $this->content["content"]->addContent($content, $before); |
|
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | |
74 | - public function addImageContent($image,$description=NULL){ |
|
74 | + public function addImageContent($image, $description=NULL) { |
|
75 | 75 | $content=$this->content["content"]; |
76 | - if(isset($description)){ |
|
77 | - $description=new HtmlSemDoubleElement("description-".$this->identifier,"div","description",$description); |
|
78 | - $content->addContent($description,true); |
|
76 | + if (isset($description)) { |
|
77 | + $description=new HtmlSemDoubleElement("description-".$this->identifier, "div", "description", $description); |
|
78 | + $content->addContent($description, true); |
|
79 | 79 | } |
80 | - if($image!==""){ |
|
81 | - $img=new HtmlImage("image-".$this->identifier,$image,"","medium"); |
|
82 | - $content->addContent($img,true); |
|
83 | - $content->addToProperty("class","image"); |
|
80 | + if ($image!=="") { |
|
81 | + $img=new HtmlImage("image-".$this->identifier, $image, "", "medium"); |
|
82 | + $content->addContent($img, true); |
|
83 | + $content->addToProperty("class", "image"); |
|
84 | 84 | } |
85 | 85 | return $this; |
86 | 86 | } |
87 | 87 | |
88 | - public function addIconContent($icon,$description=NULL){ |
|
88 | + public function addIconContent($icon, $description=NULL) { |
|
89 | 89 | $content=$this->content["content"]; |
90 | - if(isset($description)){ |
|
91 | - $description=new HtmlSemDoubleElement("description-".$this->identifier,"div","description",$description); |
|
92 | - $content->addContent($description,true); |
|
90 | + if (isset($description)) { |
|
91 | + $description=new HtmlSemDoubleElement("description-".$this->identifier, "div", "description", $description); |
|
92 | + $content->addContent($description, true); |
|
93 | 93 | } |
94 | - if($icon!==""){ |
|
95 | - $img=new HtmlIcon("image-".$this->identifier,$icon); |
|
96 | - $content->addContent($img,true); |
|
97 | - $content->addToProperty("class","image"); |
|
94 | + if ($icon!=="") { |
|
95 | + $img=new HtmlIcon("image-".$this->identifier, $icon); |
|
96 | + $content->addContent($img, true); |
|
97 | + $content->addToProperty("class", "image"); |
|
98 | 98 | } |
99 | 99 | return $this; |
100 | 100 | } |
101 | 101 | |
102 | - private function addContentInPart($content,$uiClass,$part) { |
|
103 | - return $this->addElementInPart(new HtmlSemDoubleElement($part."-" . $this->identifier, "div", $uiClass, $content), $part); |
|
102 | + private function addContentInPart($content, $uiClass, $part) { |
|
103 | + return $this->addElementInPart(new HtmlSemDoubleElement($part."-".$this->identifier, "div", $uiClass, $content), $part); |
|
104 | 104 | } |
105 | 105 | |
106 | - private function addElementInPart($element,$part) { |
|
106 | + private function addElementInPart($element, $part) { |
|
107 | 107 | $this->content[$part]->addContent($element); |
108 | 108 | return $element; |
109 | 109 | } |
110 | 110 | |
111 | - public function showDimmer($value){ |
|
112 | - $value=$value?"show":"hide"; |
|
111 | + public function showDimmer($value) { |
|
112 | + $value=$value ? "show" : "hide"; |
|
113 | 113 | $this->_paramParts[]=["'".$value." dimmer'"]; |
114 | 114 | return $this; |
115 | 115 | } |
116 | 116 | |
117 | - public function setInverted(){ |
|
117 | + public function setInverted() { |
|
118 | 118 | $this->_params["inverted"]=true; |
119 | 119 | return $this; |
120 | 120 | } |
121 | 121 | |
122 | - public function setBasic(){ |
|
122 | + public function setBasic() { |
|
123 | 123 | return $this->addToProperty("class", "basic"); |
124 | 124 | } |
125 | 125 | |
126 | - public function setActive(){ |
|
126 | + public function setActive() { |
|
127 | 127 | return $this->addToProperty("class", "active"); |
128 | 128 | } |
129 | 129 | |
130 | - public function setTransition($value){ |
|
131 | - $this->_paramParts[]=["'setting'","'transition'","'".$value."'"]; |
|
130 | + public function setTransition($value) { |
|
131 | + $this->_paramParts[]=["'setting'", "'transition'", "'".$value."'"]; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | * @param string $viewName |
139 | 139 | * @param $params The parameters to pass to the view |
140 | 140 | */ |
141 | - public function renderView(JsUtils $js,$initialController,$viewName, $params=array()) { |
|
142 | - return $this->setContent($js->renderContent($initialController, $viewName,$params)); |
|
141 | + public function renderView(JsUtils $js, $initialController, $viewName, $params=array()) { |
|
142 | + return $this->setContent($js->renderContent($initialController, $viewName, $params)); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * @param string $controllerName the controller name |
151 | 151 | * @param string $actionName the action name |
152 | 152 | */ |
153 | - public function forward(JsUtils $js,$initialControllerInstance,$controllerName,$actionName,$params=NULL){ |
|
154 | - return $this->setContent($js->forward($initialControllerInstance, $controllerName, $actionName,$params)); |
|
153 | + public function forward(JsUtils $js, $initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
154 | + return $this->setContent($js->forward($initialControllerInstance, $controllerName, $actionName, $params)); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile() |
162 | 162 | */ |
163 | 163 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
164 | - $this->content=JArray::sortAssociative($this->content, ["header","content","actions" ]); |
|
164 | + $this->content=JArray::sortAssociative($this->content, ["header", "content", "actions"]); |
|
165 | 165 | return parent::compile($js, $view); |
166 | 166 | } |
167 | 167 | /* |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * @see BaseHtml::run() |
170 | 170 | */ |
171 | 171 | public function run(JsUtils $js) { |
172 | - if(isset($this->_bsComponent)===false) |
|
173 | - $this->_bsComponent=$js->semantic()->modal("#".$this->identifier,$this->_params,$this->_paramParts); |
|
172 | + if (isset($this->_bsComponent)===false) |
|
173 | + $this->_bsComponent=$js->semantic()->modal("#".$this->identifier, $this->_params, $this->_paramParts); |
|
174 | 174 | $this->addEventsOnRun($js); |
175 | 175 | return $this->_bsComponent; |
176 | 176 | } |
@@ -59,6 +59,9 @@ discard block |
||
59 | 59 | return $this->addComponent(new Accordion($this->js), $attachTo, $params); |
60 | 60 | } |
61 | 61 | |
62 | + /** |
|
63 | + * @param string $attachTo |
|
64 | + */ |
|
62 | 65 | public function sticky($attachTo=NULL, $params=NULL) { |
63 | 66 | return $this->addComponent(new Sticky($this->js), $attachTo, $params); |
64 | 67 | } |
@@ -67,22 +70,37 @@ discard block |
||
67 | 70 | return $this->addComponent(new Checkbox($this->js), $attachTo, $params); |
68 | 71 | } |
69 | 72 | |
73 | + /** |
|
74 | + * @param string $attachTo |
|
75 | + */ |
|
70 | 76 | public function rating($attachTo=NULL, $params=NULL) { |
71 | 77 | return $this->addComponent(new Rating($this->js), $attachTo, $params); |
72 | 78 | } |
73 | 79 | |
80 | + /** |
|
81 | + * @param string $attachTo |
|
82 | + */ |
|
74 | 83 | public function progress($attachTo=NULL, $params=NULL) { |
75 | 84 | return $this->addComponent(new Progress($this->js), $attachTo, $params); |
76 | 85 | } |
77 | 86 | |
87 | + /** |
|
88 | + * @param string $attachTo |
|
89 | + */ |
|
78 | 90 | public function search($attachTo=NULL, $params=NULL) { |
79 | 91 | return $this->addComponent(new Search($this->js), $attachTo, $params); |
80 | 92 | } |
81 | 93 | |
94 | + /** |
|
95 | + * @param string $attachTo |
|
96 | + */ |
|
82 | 97 | public function dimmer($attachTo=NULL, $params=NULL) { |
83 | 98 | return $this->addComponent(new Dimmer($this->js), $attachTo, $params); |
84 | 99 | } |
85 | 100 | |
101 | + /** |
|
102 | + * @param string $attachTo |
|
103 | + */ |
|
86 | 104 | public function modal($attachTo=NULL, $params=NULL,$paramsParts=NULL) { |
87 | 105 | $result= $this->addComponent(new Modal($this->js), $attachTo, $params); |
88 | 106 | $result->setParamParts($paramsParts); |
@@ -83,8 +83,8 @@ |
||
83 | 83 | return $this->addComponent(new Dimmer($this->js), $attachTo, $params); |
84 | 84 | } |
85 | 85 | |
86 | - public function modal($attachTo=NULL, $params=NULL,$paramsParts=NULL) { |
|
87 | - $result= $this->addComponent(new Modal($this->js), $attachTo, $params); |
|
86 | + public function modal($attachTo=NULL, $params=NULL, $paramsParts=NULL) { |
|
87 | + $result=$this->addComponent(new Modal($this->js), $attachTo, $params); |
|
88 | 88 | $result->setParamParts($paramsParts); |
89 | 89 | return $result; |
90 | 90 | } |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | $this->paramParts=array(); |
13 | 13 | } |
14 | 14 | |
15 | - protected function generateParamParts(){ |
|
15 | + protected function generateParamParts() { |
|
16 | 16 | $results=[]; |
17 | - foreach ($this->paramParts as $paramPart){ |
|
17 | + foreach ($this->paramParts as $paramPart) { |
|
18 | 18 | $results[]="{$this->uiName}(".\implode(",", $paramPart).")"; |
19 | 19 | } |
20 | 20 | return \implode(".", $results); |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | |
23 | 23 | public function getScript() { |
24 | 24 | $allParams=$this->params; |
25 | - $this->jquery_code_for_compile=array (); |
|
25 | + $this->jquery_code_for_compile=array(); |
|
26 | 26 | $paramParts=""; |
27 | - if(\sizeof($this->paramParts)>0){ |
|
27 | + if (\sizeof($this->paramParts)>0) { |
|
28 | 28 | $paramParts=".".$this->generateParamParts(); |
29 | 29 | } |
30 | 30 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).{$this->uiName}(".$this->getParamsAsJSON($allParams).")".$paramParts.";"; |
@@ -16,11 +16,11 @@ |
||
16 | 16 | return $this; |
17 | 17 | } |
18 | 18 | |
19 | - public function showDimmer(){ |
|
19 | + public function showDimmer() { |
|
20 | 20 | return $this->setBehavior("hide dimmer"); |
21 | 21 | } |
22 | 22 | |
23 | - public function setInverted(){ |
|
23 | + public function setInverted() { |
|
24 | 24 | $this->params["inverted"]=true; |
25 | 25 | } |
26 | 26 |
@@ -78,6 +78,6 @@ |
||
78 | 78 | * @return HtmlModal |
79 | 79 | */ |
80 | 80 | public function htmlModal($identifier, $header="", $content="", $actions=array()) { |
81 | - return $this->addHtmlComponent(new HtmlModal($identifier, $header,$content,$actions)); |
|
81 | + return $this->addHtmlComponent(new HtmlModal($identifier, $header, $content, $actions)); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | \ No newline at end of file |
@@ -30,8 +30,6 @@ |
||
30 | 30 | /** |
31 | 31 | * |
32 | 32 | * @param string $identifier |
33 | - * @param int $rowCount |
|
34 | - * @param int $colCount |
|
35 | 33 | * @return HtmlRating |
36 | 34 | */ |
37 | 35 | public function htmlRating($identifier, $value, $max, $icon="") { |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * JsUtils Class : Service to be injected |
23 | 23 | */ |
24 | -abstract class JsUtils{ |
|
25 | - use JsUtilsEventsTrait,JsUtilsActionsTrait,JsUtilsAjaxTrait; |
|
24 | +abstract class JsUtils { |
|
25 | + use JsUtilsEventsTrait, JsUtilsActionsTrait, JsUtilsAjaxTrait; |
|
26 | 26 | |
27 | 27 | protected $js; |
28 | 28 | protected $cdns; |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | protected $config; |
52 | 52 | |
53 | 53 | protected function _setDi($di) { |
54 | - if ($this->js!=null&&$di!=null) |
|
54 | + if ($this->js!=null && $di!=null) |
|
55 | 55 | $this->js->setDi($di); |
56 | 56 | } |
57 | 57 | |
58 | 58 | public abstract function getUrl($url); |
59 | - public abstract function addViewElement($identifier,$content,&$view); |
|
60 | - public abstract function createScriptVariable(&$view,$view_var, $output); |
|
59 | + public abstract function addViewElement($identifier, $content, &$view); |
|
60 | + public abstract function createScriptVariable(&$view, $view_var, $output); |
|
61 | 61 | /** |
62 | 62 | * render the content of $controller::$action and set the response to the modal content |
63 | 63 | * @param Controller $initialController |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | * @param string $action a Phalcon action |
66 | 66 | * @param array $params |
67 | 67 | */ |
68 | - public abstract function forward($initialController,$controller,$action,$params); |
|
68 | + public abstract function forward($initialController, $controller, $action, $params); |
|
69 | 69 | /** |
70 | 70 | * render the content of an existing view : $viewName and set the response to the modal content |
71 | 71 | * @param Controller $initialControllerInstance |
72 | 72 | * @param View $viewName |
73 | 73 | * @param $params The parameters to pass to the view |
74 | 74 | */ |
75 | - public abstract function renderContent($initialControllerInstance,$viewName, $params=NULL); |
|
75 | + public abstract function renderContent($initialControllerInstance, $viewName, $params=NULL); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * Collect url parts from the request dispatcher : controllerName, actionName, parameters |
@@ -163,28 +163,28 @@ discard block |
||
163 | 163 | return $this->config; |
164 | 164 | } |
165 | 165 | |
166 | - public function __construct($params=array(),$injected=NULL) { |
|
167 | - $defaults=array ( |
|
166 | + public function __construct($params=array(), $injected=NULL) { |
|
167 | + $defaults=array( |
|
168 | 168 | 'driver' => 'Jquery', |
169 | 169 | 'debug' => true |
170 | 170 | ); |
171 | - foreach ( $defaults as $key => $val ) { |
|
171 | + foreach ($defaults as $key => $val) { |
|
172 | 172 | if (isset($params[$key])===false || $params[$key]==="") { |
173 | 173 | $params[$key]=$defaults[$key]; |
174 | 174 | } |
175 | 175 | } |
176 | - $this->js=new Jquery($params,$this); |
|
176 | + $this->js=new Jquery($params, $this); |
|
177 | 177 | |
178 | - if(\array_key_exists("semantic", $params)){ |
|
178 | + if (\array_key_exists("semantic", $params)) { |
|
179 | 179 | $this->semantic(new Semantic()); |
180 | 180 | } |
181 | - $this->cdns=array (); |
|
181 | + $this->cdns=array(); |
|
182 | 182 | $this->params=$params; |
183 | 183 | $this->injected=$injected; |
184 | 184 | } |
185 | 185 | |
186 | - public function __set($property, $value){ |
|
187 | - switch ($property){ |
|
186 | + public function __set($property, $value) { |
|
187 | + switch ($property) { |
|
188 | 188 | case "bootstrap": |
189 | 189 | $this->bootstrap($value); |
190 | 190 | break; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | - public function getParam($key){ |
|
202 | + public function getParam($key) { |
|
203 | 203 | return $this->params[$key]; |
204 | 204 | } |
205 | 205 | |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function compile(&$view=NULL, $view_var='script_foot', $script_tags=TRUE) { |
239 | 239 | $bs=$this->_bootstrap; |
240 | - if (isset($bs)&&isset($view)) { |
|
240 | + if (isset($bs) && isset($view)) { |
|
241 | 241 | $bs->compileHtml($this, $view); |
242 | 242 | } |
243 | 243 | $sem=$this->_semantic; |
244 | - if (isset($sem)&&isset($view)) { |
|
244 | + if (isset($sem) && isset($view)) { |
|
245 | 245 | $sem->compileHtml($this, $view); |
246 | 246 | } |
247 | 247 | return $this->js->_compile($view, $view_var, $script_tags); |
@@ -308,27 +308,27 @@ discard block |
||
308 | 308 | $json_result=$result->result_array(); |
309 | 309 | } elseif (is_array($result)) { |
310 | 310 | $json_result=$result; |
311 | - } else { |
|
311 | + }else { |
|
312 | 312 | return $this->_prep_args($result); |
313 | 313 | } |
314 | - } else { |
|
314 | + }else { |
|
315 | 315 | return 'null'; |
316 | 316 | } |
317 | 317 | return $this->_create_json($json_result, $match_array_type); |
318 | 318 | } |
319 | 319 | |
320 | 320 | private function _create_json($json_result, $match_array_type) { |
321 | - $json=array (); |
|
321 | + $json=array(); |
|
322 | 322 | $_is_assoc=TRUE; |
323 | - if (!is_array($json_result)&&empty($json_result)) { |
|
323 | + if (!is_array($json_result) && empty($json_result)) { |
|
324 | 324 | show_error("Generate JSON Failed - Illegal key, value pair."); |
325 | 325 | } elseif ($match_array_type) { |
326 | 326 | $_is_assoc=$this->_is_associative_array($json_result); |
327 | 327 | } |
328 | - foreach ( $json_result as $k => $v ) { |
|
328 | + foreach ($json_result as $k => $v) { |
|
329 | 329 | if ($_is_assoc) { |
330 | 330 | $json[]=$this->_prep_args($k, TRUE).':'.$this->generate_json($v, $match_array_type); |
331 | - } else { |
|
331 | + }else { |
|
332 | 332 | $json[]=$this->generate_json($v, $match_array_type); |
333 | 333 | } |
334 | 334 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @return type |
344 | 344 | */ |
345 | 345 | public function _is_associative_array($arr) { |
346 | - foreach ( array_keys($arr) as $key => $val ) { |
|
346 | + foreach (array_keys($arr) as $key => $val) { |
|
347 | 347 | if ($key!==$val) { |
348 | 348 | return TRUE; |
349 | 349 | } |
@@ -362,11 +362,11 @@ discard block |
||
362 | 362 | return 'null'; |
363 | 363 | } elseif (is_bool($result)) { |
364 | 364 | return ($result===TRUE) ? 'true' : 'false'; |
365 | - } elseif (is_string($result)||$is_key) { |
|
366 | - return '"'.str_replace(array ( |
|
367 | - '\\',"\t","\n","\r",'"','/' |
|
368 | - ), array ( |
|
369 | - '\\\\','\\t','\\n',"\\r",'\"','\/' |
|
365 | + } elseif (is_string($result) || $is_key) { |
|
366 | + return '"'.str_replace(array( |
|
367 | + '\\', "\t", "\n", "\r", '"', '/' |
|
368 | + ), array( |
|
369 | + '\\\\', '\\t', '\\n', "\\r", '\"', '\/' |
|
370 | 370 | ), $result).'"'; |
371 | 371 | } elseif (is_scalar($result)) { |
372 | 372 | return $result; |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | |
380 | 380 | public function setCDNs($cdns) { |
381 | 381 | if (is_array($cdns)===false) { |
382 | - $cdns=array ( |
|
382 | + $cdns=array( |
|
383 | 383 | $cdns |
384 | 384 | ); |
385 | 385 | } |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | $hasJQueryUI=false; |
392 | 392 | $hasBootstrap=false; |
393 | 393 | $hasSemantic=false; |
394 | - $result=array (); |
|
395 | - foreach ( $this->cdns as $cdn ) { |
|
396 | - switch(get_class($cdn)) { |
|
394 | + $result=array(); |
|
395 | + foreach ($this->cdns as $cdn) { |
|
396 | + switch (get_class($cdn)) { |
|
397 | 397 | case "Ajax\lib\CDNJQuery": |
398 | 398 | $hasJQuery=true; |
399 | 399 | $result[0]=$cdn; |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | $result[1]=$cdn; |
404 | 404 | break; |
405 | 405 | case "Ajax\lib\CDNCoreCss": |
406 | - if($cdn->getFramework()==="Bootstrap") |
|
406 | + if ($cdn->getFramework()==="Bootstrap") |
|
407 | 407 | $hasBootstrap=true; |
408 | - elseif($cdn->getFramework()==="Semantic") |
|
408 | + elseif ($cdn->getFramework()==="Semantic") |
|
409 | 409 | $hasSemantic=true; |
410 | - if($hasSemantic || $hasBootstrap) |
|
410 | + if ($hasSemantic || $hasBootstrap) |
|
411 | 411 | $result[2]=$cdn; |
412 | 412 | break; |
413 | 413 | } |
@@ -415,14 +415,14 @@ discard block |
||
415 | 415 | if ($hasJQuery===false) { |
416 | 416 | $result[0]=new CDNJQuery("x"); |
417 | 417 | } |
418 | - if ($hasJQueryUI===false&&isset($this->_ui)) { |
|
418 | + if ($hasJQueryUI===false && isset($this->_ui)) { |
|
419 | 419 | $result[1]=new CDNGuiGen("x", $template); |
420 | 420 | } |
421 | - if ($hasBootstrap===false&&isset($this->_bootstrap)) { |
|
422 | - $result[2]=new CDNCoreCss("Bootstrap","x"); |
|
421 | + if ($hasBootstrap===false && isset($this->_bootstrap)) { |
|
422 | + $result[2]=new CDNCoreCss("Bootstrap", "x"); |
|
423 | 423 | } |
424 | - if ($hasSemantic===false&&isset($this->_semantic)) { |
|
425 | - $result[2]=new CDNCoreCss("Semantic","x"); |
|
424 | + if ($hasSemantic===false && isset($this->_semantic)) { |
|
425 | + $result[2]=new CDNCoreCss("Semantic", "x"); |
|
426 | 426 | } |
427 | 427 | ksort($result); |
428 | 428 | return implode("\n", $result); |
@@ -68,7 +68,7 @@ |
||
68 | 68 | public abstract function forward($initialController,$controller,$action,$params); |
69 | 69 | /** |
70 | 70 | * render the content of an existing view : $viewName and set the response to the modal content |
71 | - * @param Controller $initialControllerInstance |
|
71 | + * @param Controller $initialControllerInstance |
|
72 | 72 | * @param View $viewName |
73 | 73 | * @param $params The parameters to pass to the view |
74 | 74 | */ |
@@ -51,8 +51,9 @@ discard block |
||
51 | 51 | protected $config; |
52 | 52 | |
53 | 53 | protected function _setDi($di) { |
54 | - if ($this->js!=null&&$di!=null) |
|
55 | - $this->js->setDi($di); |
|
54 | + if ($this->js!=null&&$di!=null) { |
|
55 | + $this->js->setDi($di); |
|
56 | + } |
|
56 | 57 | } |
57 | 58 | |
58 | 59 | public abstract function getUrl($url); |
@@ -403,12 +404,14 @@ discard block |
||
403 | 404 | $result[1]=$cdn; |
404 | 405 | break; |
405 | 406 | case "Ajax\lib\CDNCoreCss": |
406 | - if($cdn->getFramework()==="Bootstrap") |
|
407 | - $hasBootstrap=true; |
|
408 | - elseif($cdn->getFramework()==="Semantic") |
|
409 | - $hasSemantic=true; |
|
410 | - if($hasSemantic || $hasBootstrap) |
|
411 | - $result[2]=$cdn; |
|
407 | + if($cdn->getFramework()==="Bootstrap") { |
|
408 | + $hasBootstrap=true; |
|
409 | + } elseif($cdn->getFramework()==="Semantic") { |
|
410 | + $hasSemantic=true; |
|
411 | + } |
|
412 | + if($hasSemantic || $hasBootstrap) { |
|
413 | + $result[2]=$cdn; |
|
414 | + } |
|
412 | 415 | break; |
413 | 416 | } |
414 | 417 | } |
@@ -4,24 +4,24 @@ discard block |
||
4 | 4 | |
5 | 5 | use Illuminate\Support\Facades\App; |
6 | 6 | |
7 | -class JsUtils extends \Ajax\JsUtils{ |
|
8 | - public function getUrl($url){ |
|
7 | +class JsUtils extends \Ajax\JsUtils { |
|
8 | + public function getUrl($url) { |
|
9 | 9 | return \url($url); |
10 | 10 | } |
11 | - public function addViewElement($identifier,$content,&$view){ |
|
11 | + public function addViewElement($identifier, $content, &$view) { |
|
12 | 12 | $controls=$view->__get("q"); |
13 | - if (isset($controls) === false) { |
|
14 | - $controls=array (); |
|
13 | + if (isset($controls)===false) { |
|
14 | + $controls=array(); |
|
15 | 15 | } |
16 | 16 | $controls[$identifier]=$content; |
17 | 17 | $view->__set("q", $controls); |
18 | 18 | } |
19 | 19 | |
20 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
21 | - $view->__set($view_var,$output); |
|
20 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
21 | + $view->__set($view_var, $output); |
|
22 | 22 | } |
23 | 23 | |
24 | - public function forward($initialControllerInstance,$controllerName,$actionName,$params=NULL){ |
|
24 | + public function forward($initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
25 | 25 | \ob_start(); |
26 | 26 | App::make($controllerName)->{$actionName}($params); |
27 | 27 | $result=\ob_get_contents(); |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | return $result; |
30 | 30 | } |
31 | 31 | |
32 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
33 | - return \view()->make($viewName,$params)->render(); |
|
32 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
33 | + return \view()->make($viewName, $params)->render(); |
|
34 | 34 | } |
35 | 35 | |
36 | - public function fromDispatcher($dispatcher){ |
|
36 | + public function fromDispatcher($dispatcher) { |
|
37 | 37 | return $dispatcher->segments(); |
38 | 38 | } |
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -48,15 +48,15 @@ |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
51 | - if ($initialControllerInstance->has('templating')) { |
|
52 | - return $initialControllerInstance->get('templating')->render($viewName, $params); |
|
53 | - } |
|
51 | + if ($initialControllerInstance->has('templating')) { |
|
52 | + return $initialControllerInstance->get('templating')->render($viewName, $params); |
|
53 | + } |
|
54 | 54 | |
55 | - if (!$initialControllerInstance->has('twig')) { |
|
56 | - throw new \LogicException('You can not use the "renderView" method if the Templating Component or the Twig Bundle are not available.'); |
|
57 | - } |
|
55 | + if (!$initialControllerInstance->has('twig')) { |
|
56 | + throw new \LogicException('You can not use the "renderView" method if the Templating Component or the Twig Bundle are not available.'); |
|
57 | + } |
|
58 | 58 | |
59 | - return $initialControllerInstance->get('twig')->render($viewName, $params); |
|
59 | + return $initialControllerInstance->get('twig')->render($viewName, $params); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | public function fromDispatcher($dispatcher){ |
@@ -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)===true){ |
|
13 | + if (isset($router)===true) { |
|
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); |
@@ -13,7 +13,7 @@ |
||
13 | 13 | if(isset($router)===true){ |
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 | } |