@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use Phalcon\Mvc\View; |
8 | 8 | use Phalcon\Mvc\Controller; |
9 | 9 | |
10 | -class JsUtils extends \Ajax\JsUtils implements InjectionAwareInterface{ |
|
10 | +class JsUtils extends \Ajax\JsUtils implements InjectionAwareInterface { |
|
11 | 11 | protected $_di; |
12 | 12 | public function setDi(DiInterface $di) { |
13 | 13 | $this->_di=$di; |
@@ -18,50 +18,50 @@ discard block |
||
18 | 18 | return $this->_di; |
19 | 19 | } |
20 | 20 | |
21 | - public function getUrl($url){ |
|
21 | + public function getUrl($url) { |
|
22 | 22 | return $this->_di->get("url")->get($url); |
23 | 23 | } |
24 | 24 | |
25 | - public function addViewElement($identifier,$content,&$view){ |
|
25 | + public function addViewElement($identifier, $content, &$view) { |
|
26 | 26 | $controls=$view->getVar("q"); |
27 | - if (isset($controls) === false) { |
|
28 | - $controls=array (); |
|
27 | + if (isset($controls)===false) { |
|
28 | + $controls=array(); |
|
29 | 29 | } |
30 | 30 | $controls[$identifier]=$content; |
31 | 31 | $view->setVar("q", $controls); |
32 | 32 | } |
33 | 33 | |
34 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
35 | - $view->setVar($view_var,$output); |
|
34 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
35 | + $view->setVar($view_var, $output); |
|
36 | 36 | } |
37 | 37 | |
38 | - public function forward($initialController,$controller,$action,$params=array()){ |
|
39 | - $dispatcher = $initialController->dispatcher; |
|
38 | + public function forward($initialController, $controller, $action, $params=array()) { |
|
39 | + $dispatcher=$initialController->dispatcher; |
|
40 | 40 | $dispatcher->setControllerName($controller); |
41 | 41 | $dispatcher->setActionName($action); |
42 | 42 | $dispatcher->dispatch(); |
43 | - $template=$initialController->view->getRender($dispatcher->getControllerName(), $dispatcher->getActionName(),$dispatcher->getParams(), function ($view) { |
|
43 | + $template=$initialController->view->getRender($dispatcher->getControllerName(), $dispatcher->getActionName(), $dispatcher->getParams(), function($view) { |
|
44 | 44 | $view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
45 | 45 | }); |
46 | 46 | return $template; |
47 | 47 | } |
48 | 48 | |
49 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
50 | - list($controller,$action)=\explode("@", $viewName); |
|
51 | - $template=$initialControllerInstance->view->getRender($controller, $action, $params, function ($view) { |
|
49 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
50 | + list($controller, $action)=\explode("@", $viewName); |
|
51 | + $template=$initialControllerInstance->view->getRender($controller, $action, $params, function($view) { |
|
52 | 52 | $view->setRenderLevel(View::LEVEL_ACTION_VIEW); |
53 | 53 | }); |
54 | 54 | return $template; |
55 | 55 | } |
56 | 56 | |
57 | - public function fromDispatcher($dispatcher){ |
|
57 | + public function fromDispatcher($dispatcher) { |
|
58 | 58 | $params=$dispatcher->getParams(); |
59 | 59 | $action=$dispatcher->getActionName(); |
60 | 60 | $items=array($dispatcher->getControllerName()); |
61 | - if(\sizeof($params)>0 || \strtolower($action)!="index" ){ |
|
61 | + if (\sizeof($params)>0 || \strtolower($action)!="index") { |
|
62 | 62 | $items[]=$action; |
63 | - foreach ($params as $p){ |
|
64 | - if(\is_object($p)===false) |
|
63 | + foreach ($params as $p) { |
|
64 | + if (\is_object($p)===false) |
|
65 | 65 | $items[]=$p; |
66 | 66 | } |
67 | 67 | } |
@@ -61,8 +61,9 @@ |
||
61 | 61 | if(\sizeof($params)>0 || \strtolower($action)!="index" ){ |
62 | 62 | $items[]=$action; |
63 | 63 | foreach ($params as $p){ |
64 | - if(\is_object($p)===false) |
|
65 | - $items[]=$p; |
|
64 | + if(\is_object($p)===false) { |
|
65 | + $items[]=$p; |
|
66 | + } |
|
66 | 67 | } |
67 | 68 | } |
68 | 69 | return $items; |
@@ -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 | } |
@@ -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 |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | -return array ( |
|
3 | - "JQuery" => array ( |
|
4 | - "MaxCDN" => array ( |
|
2 | +return array( |
|
3 | + "JQuery" => array( |
|
4 | + "MaxCDN" => array( |
|
5 | 5 | "url" => "http://code.jquery.com/jquery-%version%.min.js", |
6 | - "versions" => array ( |
|
6 | + "versions" => array( |
|
7 | 7 | "2.2.3", |
8 | 8 | "2.2.1", |
9 | 9 | "2.1.4", |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | "1.11.2" |
12 | 12 | ) |
13 | 13 | ), |
14 | - "Google" => array ( |
|
14 | + "Google" => array( |
|
15 | 15 | "url" => "https://ajax.googleapis.com/ajax/libs/jquery/%version%/jquery.min.js", |
16 | - "versions" => array ( |
|
16 | + "versions" => array( |
|
17 | 17 | "2.2.2", |
18 | 18 | "2.2.1", |
19 | 19 | "2.2.0", |
@@ -25,17 +25,17 @@ discard block |
||
25 | 25 | ) |
26 | 26 | ) |
27 | 27 | ), |
28 | - "JQueryUI" => array ( |
|
29 | - "MaxCDN" => array ( |
|
28 | + "JQueryUI" => array( |
|
29 | + "MaxCDN" => array( |
|
30 | 30 | "core" => "http://code.jquery.com/ui/%version%/jquery-ui.min.js", |
31 | 31 | "css" => "http://code.jquery.com/ui/%version%/themes/%theme%/jquery-ui.css", |
32 | - "versions" => array ( |
|
32 | + "versions" => array( |
|
33 | 33 | "1.11.4", |
34 | 34 | "1.11.3", |
35 | 35 | "1.11.2", |
36 | 36 | "1.10.4" |
37 | 37 | ), |
38 | - "themes" => array ( |
|
38 | + "themes" => array( |
|
39 | 39 | "black-tie", |
40 | 40 | "blitzer", |
41 | 41 | "cupertino", |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | "vader" |
63 | 63 | ) |
64 | 64 | ), |
65 | - "Google" => array ( |
|
65 | + "Google" => array( |
|
66 | 66 | "core" => "https://ajax.googleapis.com/ajax/libs/jqueryui/%version%/jquery-ui.min.js", |
67 | 67 | "css" => "https://ajax.googleapis.com/ajax/libs/jqueryui/%version%/themes/%theme%/jquery-ui.css", |
68 | - "versions" => array ( |
|
68 | + "versions" => array( |
|
69 | 69 | "1.11.4", |
70 | 70 | "1.11.3", |
71 | 71 | "1.11.2", |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | "1.10.4", |
75 | 75 | "1.10.0" |
76 | 76 | ), |
77 | - "themes" => array ( |
|
77 | + "themes" => array( |
|
78 | 78 | "black-tie", |
79 | 79 | "blitzer", |
80 | 80 | "cupertino", |
@@ -102,25 +102,25 @@ discard block |
||
102 | 102 | ) |
103 | 103 | ) |
104 | 104 | ), |
105 | - "Bootstrap" => array ( |
|
106 | - "MaxCDN" => array ( |
|
105 | + "Bootstrap" => array( |
|
106 | + "MaxCDN" => array( |
|
107 | 107 | "core" => "http://maxcdn.bootstrapcdn.com/bootstrap/%version%/js/bootstrap.min.js", |
108 | 108 | "css" => "http://maxcdn.bootstrapcdn.com/bootstrap/%version%/css/bootstrap.min.css", |
109 | - "versions" => array ( |
|
109 | + "versions" => array( |
|
110 | 110 | "3.3.6", |
111 | 111 | "3.3.5" |
112 | 112 | ), |
113 | - "themes" => array () |
|
113 | + "themes" => array() |
|
114 | 114 | ) |
115 | 115 | ), |
116 | - "Semantic" => array ( |
|
117 | - "cdnjs" => array ( |
|
116 | + "Semantic" => array( |
|
117 | + "cdnjs" => array( |
|
118 | 118 | "core" => "https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/%version%/semantic.min.js", |
119 | 119 | "css" => "https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/%version%/semantic.min.css", |
120 | - "versions" => array ( |
|
120 | + "versions" => array( |
|
121 | 121 | "2.1.8" |
122 | 122 | ), |
123 | - "themes" => array () |
|
123 | + "themes" => array() |
|
124 | 124 | ) |
125 | 125 | ) |
126 | 126 | ); |
127 | 127 | \ No newline at end of file |
@@ -9,7 +9,7 @@ |
||
9 | 9 | protected $localCss; |
10 | 10 | protected $framework; |
11 | 11 | |
12 | - public function __construct($framework,$version, $provider="MaxCDN") { |
|
12 | + public function __construct($framework, $version, $provider="MaxCDN") { |
|
13 | 13 | parent::__construct($version, $provider); |
14 | 14 | $this->framework=$framework; |
15 | 15 | $this->data=$this->data [$framework]; |
@@ -60,10 +60,10 @@ |
||
60 | 60 | |
61 | 61 | protected function replaceVersionAndTheme($url, $version, $theme) { |
62 | 62 | if (isset($theme)) |
63 | - return str_ireplace(array ( |
|
63 | + return str_ireplace(array( |
|
64 | 64 | "%theme%", |
65 | 65 | "%version%" |
66 | - ), array ( |
|
66 | + ), array( |
|
67 | 67 | $theme, |
68 | 68 | $version |
69 | 69 | ), $url); |
@@ -33,11 +33,13 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | protected function getUrlOrCss($element, $key) { |
36 | - if (isset($element)) |
|
37 | - return $element; |
|
36 | + if (isset($element)) { |
|
37 | + return $element; |
|
38 | + } |
|
38 | 39 | $version=$this->version; |
39 | - if (array_search($version, $this->getVersions())===false) |
|
40 | - $version=$this->getLastVersion(); |
|
40 | + if (array_search($version, $this->getVersions())===false) { |
|
41 | + $version=$this->getLastVersion(); |
|
42 | + } |
|
41 | 43 | return $this->replaceVersion($this->data [$this->provider] [$key], $version); |
42 | 44 | } |
43 | 45 | |
@@ -59,16 +61,17 @@ discard block |
||
59 | 61 | } |
60 | 62 | |
61 | 63 | protected function replaceVersionAndTheme($url, $version, $theme) { |
62 | - if (isset($theme)) |
|
63 | - return str_ireplace(array ( |
|
64 | + if (isset($theme)) { |
|
65 | + return str_ireplace(array ( |
|
64 | 66 | "%theme%", |
65 | 67 | "%version%" |
66 | 68 | ), array ( |
67 | 69 | $theme, |
68 | 70 | $version |
69 | 71 | ), $url); |
70 | - else |
|
71 | - return $this->replaceVersion($url, $version); |
|
72 | + } else { |
|
73 | + return $this->replaceVersion($url, $version); |
|
74 | + } |
|
72 | 75 | } |
73 | 76 | |
74 | 77 | public function getProviders() { |
@@ -76,10 +79,11 @@ discard block |
||
76 | 79 | } |
77 | 80 | |
78 | 81 | public function getVersions($provider=NULL) { |
79 | - if (isset($provider)) |
|
80 | - return $this->data [$provider] ["versions"]; |
|
81 | - else |
|
82 | - return $this->data [$this->provider] ["versions"]; |
|
82 | + if (isset($provider)) { |
|
83 | + return $this->data [$provider] ["versions"]; |
|
84 | + } else { |
|
85 | + return $this->data [$this->provider] ["versions"]; |
|
86 | + } |
|
83 | 87 | } |
84 | 88 | |
85 | 89 | public function getLastVersion($provider=NULL) { |
@@ -14,10 +14,11 @@ discard block |
||
14 | 14 | $this->data=$this->data ["JQueryUI"]; |
15 | 15 | if (is_int($theme)) { |
16 | 16 | $themes=$this->getThemes(); |
17 | - if (sizeof($themes)>$theme-1) |
|
18 | - $this->theme=$themes [$theme-1]; |
|
19 | - else |
|
20 | - throw new \Exception("CDNGuiGen : Le numéro de thème demandé n'existe pas"); |
|
17 | + if (sizeof($themes)>$theme-1) { |
|
18 | + $this->theme=$themes [$theme-1]; |
|
19 | + } else { |
|
20 | + throw new \Exception("CDNGuiGen : Le numéro de thème demandé n'existe pas"); |
|
21 | + } |
|
21 | 22 | } |
22 | 23 | $this->theme=$theme; |
23 | 24 | $this->cssUrl=null; |
@@ -28,16 +29,18 @@ discard block |
||
28 | 29 | } |
29 | 30 | |
30 | 31 | public function getThemes($provider=NULL) { |
31 | - if (isset($provider)) |
|
32 | - return $this->data [$provider] ["themes"]; |
|
33 | - else |
|
34 | - return $this->data [$this->provider] ["themes"]; |
|
32 | + if (isset($provider)) { |
|
33 | + return $this->data [$provider] ["themes"]; |
|
34 | + } else { |
|
35 | + return $this->data [$this->provider] ["themes"]; |
|
36 | + } |
|
35 | 37 | } |
36 | 38 | |
37 | 39 | public function getFirstTheme($provider=NULL) { |
38 | 40 | $themes=$this->getThemes($provider); |
39 | - if (sizeof($themes)>0) |
|
40 | - return $themes [0]; |
|
41 | + if (sizeof($themes)>0) { |
|
42 | + return $themes [0]; |
|
43 | + } |
|
41 | 44 | return ""; |
42 | 45 | } |
43 | 46 | |
@@ -46,14 +49,17 @@ discard block |
||
46 | 49 | } |
47 | 50 | |
48 | 51 | public function getCss() { |
49 | - if (isset($this->cssUrl)) |
|
50 | - return $this->cssUrl; |
|
52 | + if (isset($this->cssUrl)) { |
|
53 | + return $this->cssUrl; |
|
54 | + } |
|
51 | 55 | $version=$this->version; |
52 | - if (array_search($version, $this->getVersions())===false) |
|
53 | - $version=$this->getLastVersion(); |
|
56 | + if (array_search($version, $this->getVersions())===false) { |
|
57 | + $version=$this->getLastVersion(); |
|
58 | + } |
|
54 | 59 | $theme=$this->theme; |
55 | - if (array_search($theme, $this->getThemes())===false) |
|
56 | - $theme=$this->getFirstTheme(); |
|
60 | + if (array_search($theme, $this->getThemes())===false) { |
|
61 | + $theme=$this->getFirstTheme(); |
|
62 | + } |
|
57 | 63 | return $this->replaceVersionAndTheme($this->data [$this->provider] ["css"], $version, $theme); |
58 | 64 | } |
59 | 65 |
@@ -9,7 +9,7 @@ |
||
9 | 9 | * @see \Ajax\common\SimpleComponent::compileEvents() |
10 | 10 | */ |
11 | 11 | protected function compileEvents() { |
12 | - foreach ( $this->events as $event => $jsCode ) { |
|
12 | + foreach ($this->events as $event => $jsCode) { |
|
13 | 13 | if ($event==="buttonClick") { |
14 | 14 | $this->jquery_code_for_compile []="$( \"#split-".preg_replace('/[^a-zA-Z0-9\-.]/s', '', $this->attachTo)."\" ).on(\"click\" , function( event, data ) {".$jsCode."});"; |
15 | 15 | } else { |