@@ -22,7 +22,7 @@ |
||
22 | 22 | */ |
23 | 23 | public function confirm($question, $yesScript, $noScript) |
24 | 24 | { |
25 | - if(!$noScript) |
|
25 | + if (!$noScript) |
|
26 | 26 | { |
27 | 27 | return 'if(confirm(' . $question . ')){' . $yesScript . ';}'; |
28 | 28 | } |
@@ -25,8 +25,7 @@ |
||
25 | 25 | if(!$noScript) |
26 | 26 | { |
27 | 27 | return 'if(confirm(' . $question . ')){' . $yesScript . ';}'; |
28 | - } |
|
29 | - else |
|
28 | + } else |
|
30 | 29 | { |
31 | 30 | return 'if(confirm(' . $question . ')){' . $yesScript . ';}else{' . $noScript . ';}'; |
32 | 31 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | private function getJsLibUri() |
77 | 77 | { |
78 | - if(!$this->hasOption('js.lib.uri')) |
|
78 | + if (!$this->hasOption('js.lib.uri')) |
|
79 | 79 | { |
80 | 80 | // return 'https://cdn.jsdelivr.net/jaxon/1.2.0/'; |
81 | 81 | return 'https://cdn.jsdelivr.net/gh/jaxon-php/[email protected]/dist/'; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | // The jsDelivr CDN only hosts minified files |
99 | 99 | // if(($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri) |
100 | 100 | // Starting from version 2.0.0 of the js lib, the jsDelivr CDN also hosts non minified files. |
101 | - if(($this->getOption('js.app.minify'))) |
|
101 | + if (($this->getOption('js.app.minify'))) |
|
102 | 102 | { |
103 | 103 | return '.min.js'; |
104 | 104 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | // Check config options |
116 | 116 | // - The js.app.extern option must be set to true |
117 | 117 | // - The js.app.uri and js.app.dir options must be set to non null values |
118 | - if(!$this->getOption('js.app.extern') || |
|
118 | + if (!$this->getOption('js.app.extern') || |
|
119 | 119 | !$this->getOption('js.app.uri') || |
120 | 120 | !$this->getOption('js.app.dir')) |
121 | 121 | { |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | // Check dir access |
125 | 125 | // - The js.app.dir must be writable |
126 | 126 | $sJsAppDir = $this->getOption('js.app.dir'); |
127 | - if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
127 | + if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir)) |
|
128 | 128 | { |
129 | 129 | return false; |
130 | 130 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | private function setTemplateCacheDir() |
140 | 140 | { |
141 | - if($this->hasOption('core.template.cache_dir')) |
|
141 | + if ($this->hasOption('core.template.cache_dir')) |
|
142 | 142 | { |
143 | 143 | $this->setCacheDir($this->getOption('core.template.cache_dir')); |
144 | 144 | } |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | private function generateHash() |
153 | 153 | { |
154 | 154 | $sHash = jaxon()->getVersion(); |
155 | - foreach($this->xPluginManager->getRequestPlugins() as $xPlugin) |
|
155 | + foreach ($this->xPluginManager->getRequestPlugins() as $xPlugin) |
|
156 | 156 | { |
157 | 157 | $sHash .= $xPlugin->generateHash(); |
158 | 158 | } |
159 | - foreach($this->xPluginManager->getResponsePlugins() as $xPlugin) |
|
159 | + foreach ($this->xPluginManager->getResponsePlugins() as $xPlugin) |
|
160 | 160 | { |
161 | 161 | $sHash .= $xPlugin->generateHash(); |
162 | 162 | } |
@@ -170,49 +170,49 @@ discard block |
||
170 | 170 | */ |
171 | 171 | private function makePluginsCode() |
172 | 172 | { |
173 | - if($this->sCssCode === null || $this->sJsCode === null || $this->sJsReady === null) |
|
173 | + if ($this->sCssCode === null || $this->sJsCode === null || $this->sJsReady === null) |
|
174 | 174 | { |
175 | 175 | $this->sCssCode = ''; |
176 | 176 | $this->sJsCode = ''; |
177 | 177 | $this->sJsReady = ''; |
178 | - foreach($this->xPluginManager->getResponsePlugins() as $xPlugin) |
|
178 | + foreach ($this->xPluginManager->getResponsePlugins() as $xPlugin) |
|
179 | 179 | { |
180 | - if(($str = trim($xPlugin->getCss()))) |
|
180 | + if (($str = trim($xPlugin->getCss()))) |
|
181 | 181 | { |
182 | 182 | $this->sCssCode .= rtrim($str, " \n") . "\n"; |
183 | 183 | } |
184 | - if(($str = trim($xPlugin->getJs()))) |
|
184 | + if (($str = trim($xPlugin->getJs()))) |
|
185 | 185 | { |
186 | 186 | $this->sJsCode .= rtrim($str, " \n") . "\n"; |
187 | 187 | } |
188 | - if(($str = trim($xPlugin->getScript()))) |
|
188 | + if (($str = trim($xPlugin->getScript()))) |
|
189 | 189 | { |
190 | 190 | $this->sJsReady .= "\n" . trim($str, " \n"); |
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | 194 | $this->sJsReady = $this->render('jaxon::plugins/ready.js', ['sPluginScript' => $this->sJsReady]); |
195 | - foreach($this->xPluginManager->getRequestPlugins() as $xPlugin) |
|
195 | + foreach ($this->xPluginManager->getRequestPlugins() as $xPlugin) |
|
196 | 196 | { |
197 | - if(($str = trim($xPlugin->getScript()))) |
|
197 | + if (($str = trim($xPlugin->getScript()))) |
|
198 | 198 | { |
199 | 199 | $this->sJsReady .= "\n" . trim($str, " \n"); |
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | - foreach($this->xPluginManager->getPackages() as $sClass) |
|
203 | + foreach ($this->xPluginManager->getPackages() as $sClass) |
|
204 | 204 | { |
205 | 205 | $xPackage = jaxon()->di()->get($sClass); |
206 | - if(($str = trim($xPackage->css()))) |
|
206 | + if (($str = trim($xPackage->css()))) |
|
207 | 207 | { |
208 | 208 | $this->sCssCode .= rtrim($str, " \n") . "\n"; |
209 | 209 | } |
210 | - if(($str = trim($xPackage->js()))) |
|
210 | + if (($str = trim($xPackage->js()))) |
|
211 | 211 | { |
212 | 212 | $this->sJsCode .= rtrim($str, " \n") . "\n"; |
213 | 213 | } |
214 | 214 | $xPackage = jaxon()->di()->get($sClass); |
215 | - if(($str = trim($xPackage->ready()))) |
|
215 | + if (($str = trim($xPackage->ready()))) |
|
216 | 216 | { |
217 | 217 | $this->sJsReady .= "\n" . trim($str, " \n"); |
218 | 218 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | // Add component files to the javascript file array; |
238 | 238 | $aJsFiles = array($sJsCoreUrl); |
239 | - if($this->getOption('core.debug.on')) |
|
239 | + if ($this->getOption('core.debug.on')) |
|
240 | 240 | { |
241 | 241 | $aJsFiles[] = $sJsDebugUrl; |
242 | 242 | $aJsFiles[] = $sJsLanguageUrl; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | $this->setTemplateCacheDir(); |
332 | 332 | $this->makePluginsCode(); |
333 | 333 | |
334 | - if($this->canExportJavascript()) |
|
334 | + if ($this->canExportJavascript()) |
|
335 | 335 | { |
336 | 336 | $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/'; |
337 | 337 | $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/'; |
@@ -340,13 +340,13 @@ discard block |
||
340 | 340 | $sHash = $this->generateHash(); |
341 | 341 | $sOutFile = $sHash . '.js'; |
342 | 342 | $sMinFile = $sHash . '.min.js'; |
343 | - if(!is_file($sJsAppDir . $sOutFile)) |
|
343 | + if (!is_file($sJsAppDir . $sOutFile)) |
|
344 | 344 | { |
345 | 345 | file_put_contents($sJsAppDir . $sOutFile, $this->_getScript()); |
346 | 346 | } |
347 | - if(($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
347 | + if (($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile)) |
|
348 | 348 | { |
349 | - if(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
349 | + if (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile))) |
|
350 | 350 | { |
351 | 351 | $sOutFile = $sMinFile; |
352 | 352 | } |
@@ -357,8 +357,7 @@ |
||
357 | 357 | 'sJsOptions' => $this->getOption('js.app.options'), |
358 | 358 | 'sUrl' => $sJsAppURI . $sOutFile, |
359 | 359 | )); |
360 | - } |
|
361 | - else |
|
360 | + } else |
|
362 | 361 | { |
363 | 362 | // The plugins scripts are wrapped with javascript tags |
364 | 363 | $sScript = $this->render('jaxon::plugins/wrapper.js', array( |
@@ -60,19 +60,19 @@ discard block |
||
60 | 60 | { |
61 | 61 | $this->xRepository = $xRepository; |
62 | 62 | |
63 | - if(!empty($_GET['jxncls'])) |
|
63 | + if (!empty($_GET['jxncls'])) |
|
64 | 64 | { |
65 | 65 | $this->sRequestedClass = $_GET['jxncls']; |
66 | 66 | } |
67 | - if(!empty($_GET['jxnmthd'])) |
|
67 | + if (!empty($_GET['jxnmthd'])) |
|
68 | 68 | { |
69 | 69 | $this->sRequestedMethod = $_GET['jxnmthd']; |
70 | 70 | } |
71 | - if(!empty($_POST['jxncls'])) |
|
71 | + if (!empty($_POST['jxncls'])) |
|
72 | 72 | { |
73 | 73 | $this->sRequestedClass = $_POST['jxncls']; |
74 | 74 | } |
75 | - if(!empty($_POST['jxnmthd'])) |
|
75 | + if (!empty($_POST['jxnmthd'])) |
|
76 | 76 | { |
77 | 77 | $this->sRequestedMethod = $_POST['jxnmthd']; |
78 | 78 | } |
@@ -99,20 +99,20 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function register($sType, $sClassName, $aOptions) |
101 | 101 | { |
102 | - if($sType != $this->getName()) |
|
102 | + if ($sType != $this->getName()) |
|
103 | 103 | { |
104 | 104 | return false; |
105 | 105 | } |
106 | 106 | |
107 | - if(!is_string($sClassName)) |
|
107 | + if (!is_string($sClassName)) |
|
108 | 108 | { |
109 | 109 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
110 | 110 | } |
111 | - if(is_string($aOptions)) |
|
111 | + if (is_string($aOptions)) |
|
112 | 112 | { |
113 | 113 | $aOptions = ['include' => $aOptions]; |
114 | 114 | } |
115 | - if(!is_array($aOptions)) |
|
115 | + if (!is_array($aOptions)) |
|
116 | 116 | { |
117 | 117 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
118 | 118 | } |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | public function canProcessRequest() |
151 | 151 | { |
152 | 152 | // Check the validity of the class name |
153 | - if($this->sRequestedClass !== null && !$this->validateClass($this->sRequestedClass)) |
|
153 | + if ($this->sRequestedClass !== null && !$this->validateClass($this->sRequestedClass)) |
|
154 | 154 | { |
155 | 155 | $this->sRequestedClass = null; |
156 | 156 | $this->sRequestedMethod = null; |
157 | 157 | } |
158 | 158 | // Check the validity of the method name |
159 | - if($this->sRequestedMethod !== null && !$this->validateMethod($this->sRequestedMethod)) |
|
159 | + if ($this->sRequestedMethod !== null && !$this->validateMethod($this->sRequestedMethod)) |
|
160 | 160 | { |
161 | 161 | $this->sRequestedClass = null; |
162 | 162 | $this->sRequestedMethod = null; |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function processRequest() |
173 | 173 | { |
174 | - if(!$this->canProcessRequest()) |
|
174 | + if (!$this->canProcessRequest()) |
|
175 | 175 | { |
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | |
179 | 179 | // Find the requested method |
180 | 180 | $xCallableObject = $this->xRepository->getCallableObject($this->sRequestedClass); |
181 | - if(!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
181 | + if (!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
182 | 182 | { |
183 | 183 | // Unable to find the requested object or method |
184 | 184 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid', |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $jaxon = jaxon(); |
190 | 190 | $aArgs = $jaxon->getRequestHandler()->processArguments(); |
191 | 191 | $xResponse = $xCallableObject->call($this->sRequestedMethod, $aArgs); |
192 | - if(($xResponse)) |
|
192 | + if (($xResponse)) |
|
193 | 193 | { |
194 | 194 | $jaxon->getResponseManager()->append($xResponse); |
195 | 195 | } |