@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | public function render($template, array $vars = array(), $cookies = array(), $domain = null) |
36 | 36 | { |
37 | 37 | $vars['__menu__'] = $this->getMenu(); |
38 | - $domain = (null ===$domain) ? $this->getDomain() : $domain; |
|
39 | - return $this->tpl->render($domain . $template, $vars, $cookies); |
|
38 | + $domain = (null === $domain) ? $this->getDomain() : $domain; |
|
39 | + return $this->tpl->render($domain.$template, $vars, $cookies); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | $vars['__menu__'] = $this->getMenu(); |
69 | 69 | $domain = $domain ?: $this->getDomain(); |
70 | - return $this->tpl->dump($domain . $template, $vars); |
|
70 | + return $this->tpl->dump($domain.$template, $vars); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | ///////////////////////////////////////////////////////////// |
97 | 97 | // Date in the past sets the value to already have been expired. |
98 | 98 | header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); |
99 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
99 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
100 | 100 | header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
101 | 101 | header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
102 | 102 | header("Pragma: no-cache"); |
103 | 103 | header("Expires: 0"); |
104 | 104 | header('Content-Transfer-Encoding: none'); |
105 | - header("Content-type: " . $content); |
|
106 | - header("Content-length: " . strlen($data)); |
|
107 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
105 | + header("Content-type: ".$content); |
|
106 | + header("Content-length: ".strlen($data)); |
|
107 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
108 | 108 | echo $data; |
109 | 109 | ob_flush(); |
110 | 110 | ob_end_clean(); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @package PSFS\controller |
16 | 16 | * @domain ROOT |
17 | 17 | */ |
18 | -abstract class Admin extends AuthAdminController{ |
|
18 | +abstract class Admin extends AuthAdminController { |
|
19 | 19 | |
20 | 20 | const DOMAIN = 'ROOT'; |
21 | 21 | |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | * @throws \PSFS\base\exception\FormException |
46 | 46 | */ |
47 | 47 | public static function staticAdminLogon($route = null) { |
48 | - if(file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
49 | - if('login' !== Config::getInstance()->get('admin_login')) { |
|
48 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
49 | + if ('login' !== Config::getInstance()->get('admin_login')) { |
|
50 | 50 | return AdminServices::getInstance()->setAdminHeaders(); |
51 | - } else { |
|
51 | + }else { |
|
52 | 52 | $form = new LoginForm(); |
53 | 53 | $form->setData(array("route" => $route)); |
54 | 54 | $form->build(); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | 'form' => $form, |
59 | 59 | )); |
60 | 60 | } |
61 | - } else { |
|
61 | + }else { |
|
62 | 62 | return UserController::showAdminManager(); |
63 | 63 | } |
64 | 64 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Método que revisa las traducciones directorio a directorio |
29 | - * @param $path |
|
29 | + * @param string $path |
|
30 | 30 | * @param $locale |
31 | 31 | * @return array |
32 | 32 | */ |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param string $module |
103 | 103 | * @param boolean $mod_path |
104 | 104 | * @param boolean $isModule |
105 | - * @return boolean |
|
105 | + * @return boolean|null |
|
106 | 106 | */ |
107 | 107 | private function createModulePathTree($module, $mod_path, $isModule = false) |
108 | 108 | { |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | * Method that copy resources recursively |
475 | 475 | * @param string $dest |
476 | 476 | * @param boolean $force |
477 | - * @param $filename_path |
|
477 | + * @param string $filename_path |
|
478 | 478 | * @param boolean $debug |
479 | 479 | */ |
480 | 480 | public static function copyResources($dest, $force, $filename_path, $debug) |
@@ -32,24 +32,24 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function findTranslations($path, $locale) |
34 | 34 | { |
35 | - $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
36 | - $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
35 | + $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
36 | + $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
37 | 37 | |
38 | 38 | $translations = array(); |
39 | 39 | if (file_exists($path)) { |
40 | 40 | $d = dir($path); |
41 | 41 | while (false !== ($dir = $d->read())) { |
42 | 42 | Config::createDir($locale_path); |
43 | - if (!file_exists($locale_path . 'translations.po')) { |
|
44 | - file_put_contents($locale_path . 'translations.po', ''); |
|
43 | + if (!file_exists($locale_path.'translations.po')) { |
|
44 | + file_put_contents($locale_path.'translations.po', ''); |
|
45 | 45 | } |
46 | - $inspect_path = realpath($path . DIRECTORY_SEPARATOR . $dir); |
|
47 | - $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext " . |
|
48 | - $inspect_path . DIRECTORY_SEPARATOR . |
|
46 | + $inspect_path = realpath($path.DIRECTORY_SEPARATOR.$dir); |
|
47 | + $cmd_php = "export PATH=\$PATH:/opt/local/bin; xgettext ". |
|
48 | + $inspect_path.DIRECTORY_SEPARATOR. |
|
49 | 49 | "*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$locale_path}translations.po"; |
50 | - if (is_dir($path . DIRECTORY_SEPARATOR . $dir) && preg_match('/^\./', $dir) == 0) { |
|
51 | - $res = _('Revisando directorio: ') . $inspect_path; |
|
52 | - $res .= _('Comando ejecutado: ') . $cmd_php; |
|
50 | + if (is_dir($path.DIRECTORY_SEPARATOR.$dir) && preg_match('/^\./', $dir) == 0) { |
|
51 | + $res = _('Revisando directorio: ').$inspect_path; |
|
52 | + $res .= _('Comando ejecutado: ').$cmd_php; |
|
53 | 53 | $res .= shell_exec($cmd_php); |
54 | 54 | usleep(10); |
55 | 55 | $translations[] = $res; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function createStructureModule($module, $force = false, $type = "", $isModule = false) |
72 | 72 | { |
73 | - $mod_path = CORE_DIR . DIRECTORY_SEPARATOR; |
|
73 | + $mod_path = CORE_DIR.DIRECTORY_SEPARATOR; |
|
74 | 74 | $module = ucfirst($module); |
75 | 75 | $this->createModulePath($module, $mod_path, $isModule); |
76 | 76 | $this->createModulePathTree($module, $mod_path, $isModule); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | Config::createDir($mod_path); |
94 | 94 | // Create module path |
95 | 95 | if (false === $isModule) { |
96 | - Config::createDir($mod_path . $module); |
|
96 | + Config::createDir($mod_path.$module); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
@@ -111,20 +111,20 @@ discard block |
||
111 | 111 | $paths = [ |
112 | 112 | "Api", "Api/base", "Config", "Controller", "Form", "Models", "Public", "Templates", "Services", "Test" |
113 | 113 | ]; |
114 | - $module_path = $isModule ? $mod_path : $mod_path . $module; |
|
114 | + $module_path = $isModule ? $mod_path : $mod_path.$module; |
|
115 | 115 | foreach ($paths as $path) { |
116 | - Config::createDir($module_path . DIRECTORY_SEPARATOR . $path); |
|
116 | + Config::createDir($module_path.DIRECTORY_SEPARATOR.$path); |
|
117 | 117 | } |
118 | 118 | //Creamos las carpetas de los assets |
119 | 119 | $htmlPaths = array("css", "js", "img", "media", "font"); |
120 | 120 | foreach ($htmlPaths as $path) { |
121 | - Config::createDir($module_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . $path); |
|
121 | + Config::createDir($module_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR.$path); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | if ($isModule) { |
125 | 125 | return $this->writeTemplateToFile(json_encode([ |
126 | - "module" => "\\" . preg_replace('/(\\\|\/)/', '\\\\', $module), |
|
127 | - ], JSON_PRETTY_PRINT), $mod_path . DIRECTORY_SEPARATOR . "module.json", true); |
|
126 | + "module" => "\\".preg_replace('/(\\\|\/)/', '\\\\', $module), |
|
127 | + ], JSON_PRETTY_PRINT), $mod_path.DIRECTORY_SEPARATOR."module.json", true); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | private function createModuleBaseFiles($module, $mod_path, $force = false, $controllerType = '', $isModule = false) |
140 | 140 | { |
141 | - $module_path = $isModule ? $mod_path : $mod_path . $module; |
|
141 | + $module_path = $isModule ? $mod_path : $mod_path.$module; |
|
142 | 142 | $this->generateControllerTemplate($module, $module_path, $force, $controllerType); |
143 | 143 | $this->generateServiceTemplate($module, $module_path, $force); |
144 | 144 | $this->genereateAutoloaderTemplate($module, $module_path, $force, $isModule); |
@@ -157,24 +157,24 @@ discard block |
||
157 | 157 | */ |
158 | 158 | private function createModuleModels($module, $path, $isModule = false) |
159 | 159 | { |
160 | - $module_path = $isModule ? $path : $path . $module; |
|
161 | - $module_path = str_replace(CORE_DIR . DIRECTORY_SEPARATOR, '', $module_path); |
|
160 | + $module_path = $isModule ? $path : $path.$module; |
|
161 | + $module_path = str_replace(CORE_DIR.DIRECTORY_SEPARATOR, '', $module_path); |
|
162 | 162 | //Generamos las clases de propel y la configuración |
163 | - $exec = "export PATH=\$PATH:/opt/local/bin; " . BASE_DIR . DIRECTORY_SEPARATOR . |
|
164 | - "vendor" . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "propel "; |
|
165 | - $schemaOpt = " --schema-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path . |
|
166 | - DIRECTORY_SEPARATOR . "Config"; |
|
167 | - $opt = " --config-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . $module_path . DIRECTORY_SEPARATOR . |
|
168 | - "Config --output-dir=" . CORE_DIR . " --verbose"; |
|
169 | - $this->log->infoLog("[GENERATOR] Ejecutamos propel:\n" . $exec . "build" . $opt . $schemaOpt); |
|
170 | - $ret = shell_exec($exec . "build" . $opt . $schemaOpt); |
|
163 | + $exec = "export PATH=\$PATH:/opt/local/bin; ".BASE_DIR.DIRECTORY_SEPARATOR. |
|
164 | + "vendor".DIRECTORY_SEPARATOR."bin".DIRECTORY_SEPARATOR."propel "; |
|
165 | + $schemaOpt = " --schema-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path. |
|
166 | + DIRECTORY_SEPARATOR."Config"; |
|
167 | + $opt = " --config-dir=".CORE_DIR.DIRECTORY_SEPARATOR.$module_path.DIRECTORY_SEPARATOR. |
|
168 | + "Config --output-dir=".CORE_DIR." --verbose"; |
|
169 | + $this->log->infoLog("[GENERATOR] Ejecutamos propel:\n".$exec."build".$opt.$schemaOpt); |
|
170 | + $ret = shell_exec($exec."build".$opt.$schemaOpt); |
|
171 | 171 | |
172 | 172 | $this->log->infoLog("[GENERATOR] Generamos clases invocando a propel:\n $ret"); |
173 | - $ret = shell_exec($exec . "sql:build" . $opt . " --output-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . |
|
174 | - $module_path . DIRECTORY_SEPARATOR . "Config" . $schemaOpt); |
|
173 | + $ret = shell_exec($exec."sql:build".$opt." --output-dir=".CORE_DIR.DIRECTORY_SEPARATOR. |
|
174 | + $module_path.DIRECTORY_SEPARATOR."Config".$schemaOpt); |
|
175 | 175 | $this->log->infoLog("[GENERATOR] Generamos sql invocando a propel:\n $ret"); |
176 | - $ret = shell_exec($exec . "config:convert" . $opt . " --output-dir=" . CORE_DIR . DIRECTORY_SEPARATOR . |
|
177 | - $module_path . DIRECTORY_SEPARATOR . "Config"); |
|
176 | + $ret = shell_exec($exec."config:convert".$opt." --output-dir=".CORE_DIR.DIRECTORY_SEPARATOR. |
|
177 | + $module_path.DIRECTORY_SEPARATOR."Config"); |
|
178 | 178 | $this->log->infoLog("[GENERATOR] Generamos configuración invocando a propel:\n $ret"); |
179 | 179 | } |
180 | 180 | |
@@ -195,32 +195,32 @@ discard block |
||
195 | 195 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
196 | 196 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
197 | 197 | "class" => $class, |
198 | - "controllerType" => $class . "Base", |
|
198 | + "controllerType" => $class."Base", |
|
199 | 199 | "is_base" => false |
200 | 200 | )); |
201 | - $controller = $this->writeTemplateToFile($controllerBody, $mod_path . DIRECTORY_SEPARATOR . "Controller" . |
|
202 | - DIRECTORY_SEPARATOR . "{$class}Controller.php", $force); |
|
201 | + $controller = $this->writeTemplateToFile($controllerBody, $mod_path.DIRECTORY_SEPARATOR."Controller". |
|
202 | + DIRECTORY_SEPARATOR."{$class}Controller.php", $force); |
|
203 | 203 | |
204 | 204 | $controllerBody = $this->tpl->dump("generator/controller.template.twig", array( |
205 | 205 | "module" => $module, |
206 | 206 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
207 | 207 | "url" => preg_replace('/(\\\|\/)/', '/', $module), |
208 | - "class" => $class . "Base", |
|
208 | + "class" => $class."Base", |
|
209 | 209 | "service" => $class, |
210 | 210 | "controllerType" => $controllerType, |
211 | 211 | "is_base" => true, |
212 | 212 | "domain" => $class, |
213 | 213 | )); |
214 | - $controllerBase = $this->writeTemplateToFile($controllerBody, $mod_path . DIRECTORY_SEPARATOR . "Controller" . |
|
215 | - DIRECTORY_SEPARATOR . "base" . DIRECTORY_SEPARATOR . "{$class}BaseController.php", true); |
|
214 | + $controllerBase = $this->writeTemplateToFile($controllerBody, $mod_path.DIRECTORY_SEPARATOR."Controller". |
|
215 | + DIRECTORY_SEPARATOR."base".DIRECTORY_SEPARATOR."{$class}BaseController.php", true); |
|
216 | 216 | |
217 | 217 | $testTemplate = $this->tpl->dump("generator/testCase.template.twig", array( |
218 | 218 | "module" => $module, |
219 | 219 | "namespace" => preg_replace('/(\\\|\/)/', '\\', $module), |
220 | 220 | "class" => $class, |
221 | 221 | )); |
222 | - $test = $this->writeTemplateToFile($testTemplate, $mod_path . DIRECTORY_SEPARATOR . "Test" . |
|
223 | - DIRECTORY_SEPARATOR . "{$class}Test.php", true); |
|
222 | + $test = $this->writeTemplateToFile($testTemplate, $mod_path.DIRECTORY_SEPARATOR."Test". |
|
223 | + DIRECTORY_SEPARATOR."{$class}Test.php", true); |
|
224 | 224 | return ($controller && $controllerBase && $test); |
225 | 225 | } |
226 | 226 | |
@@ -235,11 +235,9 @@ discard block |
||
235 | 235 | { |
236 | 236 | $created = true; |
237 | 237 | $modelPath = $isModule ? |
238 | - $mod_path . DIRECTORY_SEPARATOR . 'Models' : |
|
239 | - $mod_path . $module . DIRECTORY_SEPARATOR . 'Models'; |
|
238 | + $mod_path.DIRECTORY_SEPARATOR.'Models' : $mod_path.$module.DIRECTORY_SEPARATOR.'Models'; |
|
240 | 239 | $api_path = $isModule ? |
241 | - $mod_path . DIRECTORY_SEPARATOR . 'Api' : |
|
242 | - $mod_path . $module . DIRECTORY_SEPARATOR . 'Api'; |
|
240 | + $mod_path.DIRECTORY_SEPARATOR.'Api' : $mod_path.$module.DIRECTORY_SEPARATOR.'Api'; |
|
243 | 241 | if (file_exists($modelPath)) { |
244 | 242 | $dir = dir($modelPath); |
245 | 243 | while ($file = $dir->read()) { |
@@ -267,7 +265,7 @@ discard block |
||
267 | 265 | //Generamos el fichero de configuración |
268 | 266 | $this->log->infoLog("Generamos fichero vacío de configuración"); |
269 | 267 | return $this->writeTemplateToFile("<?php\n\t", |
270 | - $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "config.php", |
|
268 | + $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."config.php", |
|
271 | 269 | $force); |
272 | 270 | } |
273 | 271 | |
@@ -282,10 +280,10 @@ discard block |
||
282 | 280 | //Generamos el fichero de configuración |
283 | 281 | $this->log->infoLog("Generamos ficheros para assets base"); |
284 | 282 | $css = $this->writeTemplateToFile("/* CSS3 STYLES */\n\n", |
285 | - $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . "styles.css", |
|
283 | + $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."css".DIRECTORY_SEPARATOR."styles.css", |
|
286 | 284 | $force); |
287 | 285 | $js = $this->writeTemplateToFile("/* APP MODULE JS */\n\n(function() {\n\t'use strict';\n})();", |
288 | - $mod_path . DIRECTORY_SEPARATOR . "Public" . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . "app.js", |
|
286 | + $mod_path.DIRECTORY_SEPARATOR."Public".DIRECTORY_SEPARATOR."js".DIRECTORY_SEPARATOR."app.js", |
|
289 | 287 | $force); |
290 | 288 | return ($css && $js); |
291 | 289 | } |
@@ -307,7 +305,7 @@ discard block |
||
307 | 305 | "class" => $class, |
308 | 306 | )); |
309 | 307 | return $this->writeTemplateToFile($controller, |
310 | - $mod_path . DIRECTORY_SEPARATOR . "Services" . DIRECTORY_SEPARATOR . "{$class}Service.php", |
|
308 | + $mod_path.DIRECTORY_SEPARATOR."Services".DIRECTORY_SEPARATOR."{$class}Service.php", |
|
311 | 309 | $force); |
312 | 310 | } |
313 | 311 | |
@@ -328,14 +326,14 @@ discard block |
||
328 | 326 | "regex" => preg_replace('/(\\\|\/)/m', '\\\\\\\\\\\\', $module), |
329 | 327 | "is_module" => $isModule, |
330 | 328 | )); |
331 | - $autoload = $this->writeTemplateToFile($autoloader, $mod_path . DIRECTORY_SEPARATOR . "autoload.php", $force); |
|
329 | + $autoload = $this->writeTemplateToFile($autoloader, $mod_path.DIRECTORY_SEPARATOR."autoload.php", $force); |
|
332 | 330 | |
333 | 331 | $this->log->infoLog("Generamos el phpunit"); |
334 | 332 | $phpUnitTemplate = $this->tpl->dump("generator/phpunit.template.twig", array( |
335 | 333 | "module" => $module, |
336 | 334 | "is_module" => $isModule, |
337 | 335 | )); |
338 | - $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path . DIRECTORY_SEPARATOR . "phpunit.xml.dist", $force); |
|
336 | + $phpunit = $this->writeTemplateToFile($phpUnitTemplate, $mod_path.DIRECTORY_SEPARATOR."phpunit.xml.dist", $force); |
|
339 | 337 | return $autoload && $phpunit; |
340 | 338 | } |
341 | 339 | |
@@ -356,7 +354,7 @@ discard block |
||
356 | 354 | "db" => $this->config->get("db_name"), |
357 | 355 | )); |
358 | 356 | return $this->writeTemplateToFile($schema, |
359 | - $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "schema.xml", |
|
357 | + $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."schema.xml", |
|
360 | 358 | $force); |
361 | 359 | } |
362 | 360 | |
@@ -379,7 +377,7 @@ discard block |
||
379 | 377 | "namespace" => preg_replace('/(\\\|\/)/', '', $module), |
380 | 378 | )); |
381 | 379 | return $this->writeTemplateToFile($build_properties, |
382 | - $mod_path . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . "propel.yml", |
|
380 | + $mod_path.DIRECTORY_SEPARATOR."Config".DIRECTORY_SEPARATOR."propel.yml", |
|
383 | 381 | $force); |
384 | 382 | } |
385 | 383 | |
@@ -397,7 +395,7 @@ discard block |
||
397 | 395 | "module" => $module, |
398 | 396 | )); |
399 | 397 | return $this->writeTemplateToFile($index, |
400 | - $mod_path . DIRECTORY_SEPARATOR . "Templates" . DIRECTORY_SEPARATOR . "index.html.twig", |
|
398 | + $mod_path.DIRECTORY_SEPARATOR."Templates".DIRECTORY_SEPARATOR."index.html.twig", |
|
401 | 399 | $force); |
402 | 400 | } |
403 | 401 | |
@@ -415,11 +413,11 @@ discard block |
||
415 | 413 | try { |
416 | 414 | $this->cache->storeData($filename, $fileContent, Cache::TEXT, true); |
417 | 415 | $created = true; |
418 | - } catch (\Exception $e) { |
|
416 | + }catch (\Exception $e) { |
|
419 | 417 | $this->log->errorLog($e->getMessage()); |
420 | 418 | } |
421 | - } else { |
|
422 | - $this->log->errorLog($filename . _(' not exists or cant write')); |
|
419 | + }else { |
|
420 | + $this->log->errorLog($filename._(' not exists or cant write')); |
|
423 | 421 | } |
424 | 422 | return $created; |
425 | 423 | } |
@@ -444,7 +442,7 @@ discard block |
||
444 | 442 | )); |
445 | 443 | |
446 | 444 | return $this->writeTemplateToFile($controller, |
447 | - $mod_path . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . "{$api}BaseApi.php", true); |
|
445 | + $mod_path.DIRECTORY_SEPARATOR.'base'.DIRECTORY_SEPARATOR."{$api}BaseApi.php", true); |
|
448 | 446 | } |
449 | 447 | |
450 | 448 | /** |
@@ -467,7 +465,7 @@ discard block |
||
467 | 465 | "class" => $class, |
468 | 466 | )); |
469 | 467 | |
470 | - return $this->writeTemplateToFile($controller, $mod_path . DIRECTORY_SEPARATOR . "{$api}.php", $force); |
|
468 | + return $this->writeTemplateToFile($controller, $mod_path.DIRECTORY_SEPARATOR."{$api}.php", $force); |
|
471 | 469 | } |
472 | 470 | |
473 | 471 | /** |
@@ -481,12 +479,12 @@ discard block |
||
481 | 479 | { |
482 | 480 | if (file_exists($filename_path)) { |
483 | 481 | $destfolder = basename($filename_path); |
484 | - if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) { |
|
482 | + if (!file_exists(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) || $debug || $force) { |
|
485 | 483 | if (is_dir($filename_path)) { |
486 | - self::copyr($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder); |
|
487 | - } else { |
|
488 | - if (@copy($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) { |
|
489 | - throw new ConfigException("Can't copy " . $filename_path . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder); |
|
484 | + self::copyr($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
|
485 | + }else { |
|
486 | + if (@copy($filename_path, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) { |
|
487 | + throw new ConfigException("Can't copy ".$filename_path." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
|
490 | 488 | } |
491 | 489 | } |
492 | 490 | } |
@@ -505,10 +503,10 @@ discard block |
||
505 | 503 | Config::createDir($dst); |
506 | 504 | while (false !== ($file = readdir($dir))) { |
507 | 505 | if (($file != '.') && ($file != '..')) { |
508 | - if (is_dir($src . '/' . $file)) { |
|
509 | - self::copyr($src . '/' . $file, $dst . '/' . $file); |
|
510 | - } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) { |
|
511 | - throw new ConfigException("Can't copy " . $src . " to " . $dst); |
|
506 | + if (is_dir($src.'/'.$file)) { |
|
507 | + self::copyr($src.'/'.$file, $dst.'/'.$file); |
|
508 | + } elseif (@copy($src.'/'.$file, $dst.'/'.$file) === false) { |
|
509 | + throw new ConfigException("Can't copy ".$src." to ".$dst); |
|
512 | 510 | } |
513 | 511 | } |
514 | 512 | } |
@@ -7,6 +7,14 @@ |
||
7 | 7 | * @package PSFS\base\types\interfaces |
8 | 8 | */ |
9 | 9 | interface ControllerInterface { |
10 | + |
|
11 | + /** |
|
12 | + * @return string|null |
|
13 | + */ |
|
10 | 14 | public function render($template, array $vars = [], $cookies = []); |
15 | + |
|
16 | + /** |
|
17 | + * @return void |
|
18 | + */ |
|
11 | 19 | public function response($response, $type = 'text/html'); |
12 | 20 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | use PSFS\base\Singleton; |
17 | 17 | use PSFS\controller\ConfigController; |
18 | 18 | |
19 | -require_once __DIR__ . DIRECTORY_SEPARATOR . "bootstrap.php"; |
|
19 | +require_once __DIR__.DIRECTORY_SEPARATOR."bootstrap.php"; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Class Dispatcher |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | private function setLocale() |
78 | 78 | { |
79 | 79 | $this->locale = $this->config->get("default_language"); |
80 | - Logger::log('Set locale to project [' . $this->locale . ']'); |
|
80 | + Logger::log('Set locale to project ['.$this->locale.']'); |
|
81 | 81 | // Load translations |
82 | - putenv("LC_ALL=" . $this->locale); |
|
82 | + putenv("LC_ALL=".$this->locale); |
|
83 | 83 | setlocale(LC_ALL, $this->locale); |
84 | 84 | // Load the locale path |
85 | - $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
86 | - Logger::log('Set locale dir ' . $locale_path); |
|
85 | + $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
86 | + Logger::log('Set locale dir '.$locale_path); |
|
87 | 87 | Config::createDir($locale_path); |
88 | 88 | bindtextdomain('translations', $locale_path); |
89 | 89 | textdomain('translations'); |
@@ -104,18 +104,18 @@ discard block |
||
104 | 104 | if (!$this->parser->isFile()) { |
105 | 105 | return $this->router->execute($this->actualUri); |
106 | 106 | } |
107 | - } else { |
|
107 | + }else { |
|
108 | 108 | return ConfigController::getInstance()->config(); |
109 | 109 | } |
110 | - } catch (ConfigException $c) { |
|
110 | + }catch (ConfigException $c) { |
|
111 | 111 | return $this->dumpException($c); |
112 | - } catch (SecurityException $s) { |
|
112 | + }catch (SecurityException $s) { |
|
113 | 113 | return $this->security->notAuthorized($this->actualUri); |
114 | - } catch (UserAuthException $u) { |
|
114 | + }catch (UserAuthException $u) { |
|
115 | 115 | $this->redirectToHome(); |
116 | - } catch (RouterException $r) { |
|
116 | + }catch (RouterException $r) { |
|
117 | 117 | return $this->router->httpNotFound($r); |
118 | - } catch (\Exception $e) { |
|
118 | + }catch (\Exception $e) { |
|
119 | 119 | return $this->dumpException($e); |
120 | 120 | } |
121 | 121 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $use /= 1024; |
163 | 163 | break; |
164 | 164 | case "MBytes": |
165 | - $use /= (1024 * 1024); |
|
165 | + $use /= (1024*1024); |
|
166 | 166 | break; |
167 | 167 | case "Bytes": |
168 | 168 | default: |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | if ($this->config->getDebugMode() && $this->config->get('errors.strict', false)) { |
189 | 189 | Logger::log('Added handlers for errors'); |
190 | 190 | //Warning & Notice handler |
191 | - set_error_handler(function ($errno, $errstr, $errfile, $errline) { |
|
191 | + set_error_handler(function($errno, $errstr, $errfile, $errline) { |
|
192 | 192 | Logger::log($errstr, LOG_CRIT, ['file' => $errfile, 'line' => $errline]); |
193 | 193 | throw new \Exception($errstr, 500); |
194 | 194 | }); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | Logger::log('Initializing stats (mem + ts)'); |
204 | 204 | if (null !== $_SERVER && array_key_exists('REQUEST_TIME_FLOAT', $_SERVER)) { |
205 | 205 | $this->ts = (float)$_SERVER['REQUEST_TIME_FLOAT']; |
206 | - } else { |
|
206 | + }else { |
|
207 | 207 | $this->ts = $this->parser->getTs(); |
208 | 208 | } |
209 | 209 | $this->mem = memory_get_usage(); |
@@ -22,7 +22,7 @@ |
||
22 | 22 | if (!Config::getInstance()->checkTryToSaveConfig() |
23 | 23 | && (preg_match('/^\/(admin|setup\-admin)/i', $route) || NULL !== Config::getInstance()->get('restricted')) |
24 | 24 | ) { |
25 | - if(!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
25 | + if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
26 | 26 | //Si no hay fichero de usuarios redirigimos directamente al gestor |
27 | 27 | return UserController::showAdminManager(); |
28 | 28 | } |
@@ -1,7 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace PSFS\base\types; |
3 | 3 | |
4 | - use Propel\Runtime\ActiveQuery\Criteria; |
|
5 | 4 | use Propel\Runtime\ActiveQuery\ModelCriteria; |
6 | 5 | use Propel\Runtime\ActiveRecord\ActiveRecordInterface; |
7 | 6 | use Propel\Runtime\Connection\ConnectionInterface; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param ModelCriteria $query |
182 | 182 | */ |
183 | - private function addOrders(ModelCriteria &$query) |
|
183 | + private function addOrders(ModelCriteria & $query) |
|
184 | 184 | { |
185 | 185 | $orderAdded = FALSE; |
186 | 186 | $tableMap = $this->getTableMap(); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $orderAdded = TRUE; |
190 | 190 | if ($direction === Order::ASC) { |
191 | 191 | $query->addAscendingOrderByColumn($column->getPhpName()); |
192 | - } else { |
|
192 | + }else { |
|
193 | 193 | $query->addDescendingOrderByColumn($column->getPhpName()); |
194 | 194 | } |
195 | 195 | } |
@@ -205,10 +205,10 @@ discard block |
||
205 | 205 | private function addPkToList() { |
206 | 206 | $tableMap = $this->getTableMap(); |
207 | 207 | $pks = $tableMap->getPrimaryKeys(); |
208 | - if(count($pks) == 1) { |
|
208 | + if (count($pks) == 1) { |
|
209 | 209 | $pks = array_keys($pks); |
210 | 210 | $this->extraColumns[$pks[0]] = self::API_MODEL_KEY_FIELD; |
211 | - } else { |
|
211 | + }else { |
|
212 | 212 | throw new ApiException(_('El modelo de la API no está debidamente mapeado, no hay Primary Key o es compuesta')); |
213 | 213 | } |
214 | 214 | } |
@@ -217,19 +217,19 @@ discard block |
||
217 | 217 | * Method that add a new field with the Label of the row |
218 | 218 | */ |
219 | 219 | private function addDefaultListField() { |
220 | - if(!in_array(self::API_LIST_NAME_FIELD, $this->extraColumns)) { |
|
220 | + if (!in_array(self::API_LIST_NAME_FIELD, $this->extraColumns)) { |
|
221 | 221 | $tableMap = $this->getTableMap(); |
222 | 222 | $column = null; |
223 | - if($tableMap->hasColumn('NAME')) { |
|
223 | + if ($tableMap->hasColumn('NAME')) { |
|
224 | 224 | $column = $tableMap->getColumn('NAME'); |
225 | - } elseif($tableMap->hasColumn('TITLE')) { |
|
225 | + } elseif ($tableMap->hasColumn('TITLE')) { |
|
226 | 226 | $column = $tableMap->getColumn('TITLE'); |
227 | - } elseif($tableMap->hasColumn('LABEL')) { |
|
227 | + } elseif ($tableMap->hasColumn('LABEL')) { |
|
228 | 228 | $column = $tableMap->getColumn('LABEL'); |
229 | 229 | } |
230 | - if(null !== $column) { |
|
230 | + if (null !== $column) { |
|
231 | 231 | $this->extraColumns[$column->getFullyQualifiedName()] = self::API_LIST_NAME_FIELD; |
232 | - } else { |
|
232 | + }else { |
|
233 | 233 | $this->addClassListName($tableMap); |
234 | 234 | } |
235 | 235 | } |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @param ModelCriteria $query |
243 | 243 | */ |
244 | - private function addExtraColumns(ModelCriteria &$query) |
|
244 | + private function addExtraColumns(ModelCriteria & $query) |
|
245 | 245 | { |
246 | - if(self::API_ACTION_LIST === $this->action) { |
|
246 | + if (self::API_ACTION_LIST === $this->action) { |
|
247 | 247 | $this->addDefaultListField(); |
248 | 248 | $this->addPkToList(); |
249 | 249 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @param ModelCriteria $query |
261 | 261 | */ |
262 | - protected function joinTables(ModelCriteria &$query) |
|
262 | + protected function joinTables(ModelCriteria & $query) |
|
263 | 263 | { |
264 | 264 | //TODO for specific implementations |
265 | 265 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | */ |
270 | 270 | protected function parseExtraColumns() { |
271 | 271 | $columns = []; |
272 | - foreach($this->extraColumns as $key => $columnName) { |
|
272 | + foreach ($this->extraColumns as $key => $columnName) { |
|
273 | 273 | $columns[$columnName] = strtolower($columnName); |
274 | 274 | } |
275 | 275 | return $columns; |
@@ -280,14 +280,14 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @param ModelCriteria $query |
282 | 282 | */ |
283 | - private function addFilters(ModelCriteria &$query) |
|
283 | + private function addFilters(ModelCriteria & $query) |
|
284 | 284 | { |
285 | 285 | if (count($this->query) > 0) { |
286 | 286 | $tableMap = $this->getTableMap(); |
287 | 287 | foreach ($this->query as $field => $value) { |
288 | - if(self::API_COMBO_FIELD === $field) { |
|
288 | + if (self::API_COMBO_FIELD === $field) { |
|
289 | 289 | ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value); |
290 | - } else { |
|
290 | + }else { |
|
291 | 291 | ApiHelper::addModelField($tableMap, $query, $field, $value); |
292 | 292 | } |
293 | 293 | } |
@@ -297,20 +297,20 @@ discard block |
||
297 | 297 | /** |
298 | 298 | * @param ModelCriteria $query |
299 | 299 | */ |
300 | - private function checkReturnFields(ModelCriteria &$query) { |
|
300 | + private function checkReturnFields(ModelCriteria & $query) { |
|
301 | 301 | $returnFields = $this->getRequest()->getQuery('__fields'); |
302 | - if(null !== $returnFields) { |
|
302 | + if (null !== $returnFields) { |
|
303 | 303 | $fields = explode(',', $returnFields); |
304 | 304 | $select = []; |
305 | 305 | $tablemap = $this->getTableMap(); |
306 | 306 | foreach ($fields as $field) { |
307 | - if(in_array($field, $this->extraColumns)) { |
|
307 | + if (in_array($field, $this->extraColumns)) { |
|
308 | 308 | $select[] = $field; |
309 | - } elseif($tablemap->hasColumnByPhpName($field)) { |
|
309 | + } elseif ($tablemap->hasColumnByPhpName($field)) { |
|
310 | 310 | $select[] = $field; |
311 | 311 | } |
312 | 312 | } |
313 | - if(count($select) > 0) { |
|
313 | + if (count($select) > 0) { |
|
314 | 314 | $query->select($select); |
315 | 315 | } |
316 | 316 | } |
@@ -332,10 +332,10 @@ discard block |
||
332 | 332 | list($page, $limit) = $this->extractPagination(); |
333 | 333 | if ($limit == -1) { |
334 | 334 | $this->list = $query->find($this->con); |
335 | - } else { |
|
335 | + }else { |
|
336 | 336 | $this->list = $query->paginate($page, $limit, $this->con); |
337 | 337 | } |
338 | - } catch (\Exception $e) { |
|
338 | + }catch (\Exception $e) { |
|
339 | 339 | Logger::log($e->getMessage(), LOG_ERR); |
340 | 340 | } |
341 | 341 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $this->joinTables($query); |
353 | 353 | $this->addExtraColumns($query); |
354 | 354 | $this->model = $query->findPk($pk); |
355 | - } catch (\Exception $e) { |
|
355 | + }catch (\Exception $e) { |
|
356 | 356 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
357 | 357 | } |
358 | 358 | } |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | $saved = TRUE; |
444 | 444 | $model = $this->model->toArray(); |
445 | 445 | } |
446 | - } catch (\Exception $e) { |
|
447 | - $model = _('Ha ocurrido un error intentando guardar el elemento: ') . $e->getMessage(); |
|
446 | + }catch (\Exception $e) { |
|
447 | + $model = _('Ha ocurrido un error intentando guardar el elemento: ').$e->getMessage(); |
|
448 | 448 | Logger::log($e->getMessage(), LOG_ERR); |
449 | 449 | } |
450 | 450 | |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | $this->model->delete($this->con); |
475 | 475 | $deleted = TRUE; |
476 | 476 | } |
477 | - } catch (\Exception $e) { |
|
477 | + }catch (\Exception $e) { |
|
478 | 478 | $message = _('Ha ocurrido un error intentando eliminar el elemento, por favor verifica que no tenga otros elementos relacionados'); |
479 | 479 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
480 | 480 | } |
@@ -509,14 +509,14 @@ discard block |
||
509 | 509 | $updated = TRUE; |
510 | 510 | $status = 200; |
511 | 511 | $model = $this->model->toArray(); |
512 | - } else { |
|
512 | + }else { |
|
513 | 513 | $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
514 | 514 | } |
515 | - } catch(\Exception $e) { |
|
515 | + }catch (\Exception $e) { |
|
516 | 516 | $model = $e->getMessage(); |
517 | 517 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
518 | 518 | } |
519 | - } else { |
|
519 | + }else { |
|
520 | 520 | $model = _('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
521 | 521 | } |
522 | 522 | |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | */ |
529 | 529 | private function extractQuery() |
530 | 530 | { |
531 | - $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query"); |
|
531 | + $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query"); |
|
532 | 532 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
533 | 533 | $query = $queryReflector->getMethod('create')->invoke($this->con); |
534 | 534 | |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | if (null !== $this->con && $this->con->inTransaction()) { |
573 | 573 | if ($status === 200) { |
574 | 574 | $this->con->commit(); |
575 | - } else { |
|
575 | + }else { |
|
576 | 576 | $this->con->rollBack(); |
577 | 577 | } |
578 | 578 | } |
@@ -624,8 +624,8 @@ discard block |
||
624 | 624 | "domain" => $this->getDomain(), |
625 | 625 | "listLabel" => self::API_LIST_NAME_FIELD, |
626 | 626 | 'modelId' => self::API_MODEL_KEY_FIELD, |
627 | - 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $this->getDomain() . '-' . $this->getApi()), TRUE)), |
|
628 | - "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain() . '-' . 'api-' . $this->getApi() . "-pk"), TRUE)), |
|
627 | + 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-'.$this->getDomain().'-'.$this->getApi()), TRUE)), |
|
628 | + "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain().'-'.'api-'.$this->getApi()."-pk"), TRUE)), |
|
629 | 629 | ), [], ''); |
630 | 630 | } |
631 | 631 | |
@@ -659,12 +659,12 @@ discard block |
||
659 | 659 | $pages = 0; |
660 | 660 | try { |
661 | 661 | $this->paginate(); |
662 | - if(null !== $this->list) { |
|
662 | + if (null !== $this->list) { |
|
663 | 663 | $return = $this->list->toArray(); |
664 | 664 | $total = $this->list->getNbResults(); |
665 | 665 | $pages = $this->list->getLastPage(); |
666 | 666 | } |
667 | - } catch (\Exception $e) { |
|
667 | + }catch (\Exception $e) { |
|
668 | 668 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
669 | 669 | } |
670 | 670 | |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | $return = array(); |
684 | 684 | if (NULL === $model && method_exists($model, 'toArray')) { |
685 | 685 | $code = 404; |
686 | - } else { |
|
686 | + }else { |
|
687 | 687 | $return = $model->toArray(); |
688 | 688 | } |
689 | 689 | |
@@ -698,10 +698,10 @@ discard block |
||
698 | 698 | $pks = ''; |
699 | 699 | $sep = ''; |
700 | 700 | foreach ($tableMap->getPrimaryKeys() as $pk) { |
701 | - $pks .= $sep . $pk->getFullyQualifiedName(); |
|
701 | + $pks .= $sep.$pk->getFullyQualifiedName(); |
|
702 | 702 | $sep = ', "|", '; |
703 | 703 | } |
704 | - $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = self::API_LIST_NAME_FIELD; |
|
704 | + $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = self::API_LIST_NAME_FIELD; |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | /** |
@@ -192,7 +192,7 @@ |
||
192 | 192 | |
193 | 193 | /** |
194 | 194 | * @param ColumnMap $column |
195 | - * @param ModelCriteria $quwuery |
|
195 | + * @param ModelCriteria $query |
|
196 | 196 | * @param mixed $value |
197 | 197 | */ |
198 | 198 | private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null) { |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | } elseif ($mappedColumn->isNumeric()) { |
39 | 39 | $fDto = self::generateNumericField($field, $required); |
40 | 40 | } elseif ($mappedColumn->isText()) { |
41 | - if($mappedColumn->getSize() > 100) { |
|
41 | + if ($mappedColumn->getSize() > 100) { |
|
42 | 42 | $fDto = self::createField($field, Field::TEXTAREA_TYPE, $required); |
43 | - } else { |
|
43 | + }else { |
|
44 | 44 | $fDto = self::generateStringField($field, $required); |
45 | 45 | } |
46 | 46 | } elseif ($mappedColumn->getType() === PropelTypes::BOOLEAN) { |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | $fDto = self::generatePasswordField($field, $required); |
50 | 50 | } elseif (in_array($mappedColumn->getType(), [PropelTypes::TIMESTAMP, PropelTypes::DATE, PropelTypes::BU_DATE, PropelTypes::BU_TIMESTAMP])) { |
51 | 51 | $fDto = self::createField($field, $mappedColumn->getType() == PropelTypes::TIMESTAMP ? Field::TEXT_TYPE : Field::DATE, $required); |
52 | - } elseif(in_array($mappedColumn->getType(), [PropelTypes::ENUM, PropelTypes::SET])) { |
|
52 | + } elseif (in_array($mappedColumn->getType(), [PropelTypes::ENUM, PropelTypes::SET])) { |
|
53 | 53 | $fDto = self::generateEnumField($field, $required); |
54 | - foreach($mappedColumn->getValueSet() as $value) { |
|
54 | + foreach ($mappedColumn->getValueSet() as $value) { |
|
55 | 55 | $fDto->data[] = [ |
56 | 56 | $field => $value, |
57 | 57 | "Label" => _($value), |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | - if(null !== $fDto) { |
|
62 | + if (null !== $fDto) { |
|
63 | 63 | $fDto->size = $mappedColumn->getSize(); |
64 | 64 | $form->addField($fDto); |
65 | 65 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $fDto->entity = $relatedModel; |
84 | 84 | $relatedField = $foreignTable->getColumn($mappedColumn->getRelatedColumnName()); |
85 | 85 | $fDto->relatedField = $relatedField->getPhpName(); |
86 | - $fDto->url = Router::getInstance()->getRoute('api-' . $relatedModel); |
|
86 | + $fDto->url = Router::getInstance()->getRoute('api-'.$relatedModel); |
|
87 | 87 | return $fDto; |
88 | 88 | } |
89 | 89 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | public static function checkFieldExists(TableMap $tableMap, $field) { |
189 | 189 | try { |
190 | 190 | $column = $tableMap->getColumnByPhpName($field); |
191 | - } catch(\Exception $e) { |
|
191 | + }catch (\Exception $e) { |
|
192 | 192 | Logger::log($e->getMessage(), LOG_ERR); |
193 | 193 | $column = null; |
194 | 194 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @param ModelCriteria $quwuery |
201 | 201 | * @param mixed $value |
202 | 202 | */ |
203 | - private static function addQueryFilter(ColumnMap $column, ModelCriteria &$query, $value = null) { |
|
203 | + private static function addQueryFilter(ColumnMap $column, ModelCriteria & $query, $value = null) { |
|
204 | 204 | $tableField = $column->getPhpName(); |
205 | 205 | if (preg_match('/^<=/', $value)) { |
206 | 206 | $query->filterBy($tableField, substr($value, 2, strlen($value)), Criteria::LESS_EQUAL); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $text = preg_replace('/(\'|\")/', '', $value); |
215 | 215 | $text = preg_replace('/\ /', '%', $text); |
216 | 216 | $query->filterBy($tableField, '%'.$text.'%', Criteria::LIKE); |
217 | - } else { |
|
217 | + }else { |
|
218 | 218 | $query->filterBy($tableField, $value, Criteria::EQUAL); |
219 | 219 | } |
220 | 220 | } |
@@ -225,23 +225,23 @@ discard block |
||
225 | 225 | * @param array $extraColumns |
226 | 226 | * @param mixed $value |
227 | 227 | */ |
228 | - public static function composerComboField(TableMap $tableMap, ModelCriteria &$query, array $extraColumns = [], $value = null) { |
|
228 | + public static function composerComboField(TableMap $tableMap, ModelCriteria & $query, array $extraColumns = [], $value = null) { |
|
229 | 229 | $exp = 'CONCAT('; |
230 | 230 | $sep = ''; |
231 | - foreach($tableMap->getColumns() as $column) { |
|
232 | - if($column->isText()) { |
|
233 | - $exp .= $sep . 'IFNULL(' . $column->getFullyQualifiedName() . ',"")'; |
|
231 | + foreach ($tableMap->getColumns() as $column) { |
|
232 | + if ($column->isText()) { |
|
233 | + $exp .= $sep.'IFNULL('.$column->getFullyQualifiedName().',"")'; |
|
234 | 234 | $sep = ', " ", '; |
235 | 235 | } |
236 | 236 | } |
237 | - foreach($extraColumns as $extra => $name) { |
|
238 | - $exp .= $sep . $extra; |
|
237 | + foreach ($extraColumns as $extra => $name) { |
|
238 | + $exp .= $sep.$extra; |
|
239 | 239 | $sep = ', " ", '; |
240 | 240 | } |
241 | 241 | $exp .= ")"; |
242 | 242 | $text = preg_replace('/(\'|\")/', '', $value); |
243 | 243 | $text = preg_replace('/\ /', '%', $text); |
244 | - $query->where($exp . Criteria::LIKE . '"%' . $text . '%"'); |
|
244 | + $query->where($exp.Criteria::LIKE.'"%'.$text.'%"'); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @param string $field |
252 | 252 | * @param mixed $value |
253 | 253 | */ |
254 | - public static function addModelField(TableMap $tableMap, ModelCriteria &$query, $field, $value = null) { |
|
254 | + public static function addModelField(TableMap $tableMap, ModelCriteria & $query, $field, $value = null) { |
|
255 | 255 | if ($column = self::checkFieldExists($tableMap, $field)) { |
256 | 256 | self::addQueryFilter($column, $query, $value); |
257 | 257 | } |
@@ -4,17 +4,17 @@ |
||
4 | 4 | |
5 | 5 | if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__); |
6 | 6 | if (preg_match('/vendor/', SOURCE_DIR)) { |
7 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
8 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
9 | -} else { |
|
10 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
11 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
7 | + if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'); |
|
8 | + if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src'); |
|
9 | +}else { |
|
10 | + if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'); |
|
11 | + if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules'); |
|
12 | 12 | } |
13 | -if (!defined('VENDOR_DIR')) define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor'); |
|
14 | -if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
15 | -if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
16 | -if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
17 | -if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
13 | +if (!defined('VENDOR_DIR')) define('VENDOR_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'vendor'); |
|
14 | +if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
15 | +if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache'); |
|
16 | +if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config'); |
|
17 | +if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html'); |
|
18 | 18 | |
19 | 19 | //Cargamos en memoria la función de desarrollo PRE |
20 | 20 | if (!function_exists('pre')) { |
@@ -1,20 +1,42 @@ |
||
1 | 1 | <?php |
2 | -if (defined('PSFS_BOOTSTRAP_LOADED')) return; |
|
2 | +if (defined('PSFS_BOOTSTRAP_LOADED')) { |
|
3 | + return; |
|
4 | +} |
|
3 | 5 | use Symfony\Component\Finder\Finder; |
4 | 6 | |
5 | -if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__); |
|
7 | +if (!defined('SOURCE_DIR')) { |
|
8 | + define('SOURCE_DIR', __DIR__); |
|
9 | +} |
|
6 | 10 | if (preg_match('/vendor/', SOURCE_DIR)) { |
7 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
8 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
9 | -} else { |
|
10 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
11 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
12 | -} |
|
13 | -if (!defined('VENDOR_DIR')) define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor'); |
|
14 | -if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
15 | -if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
16 | -if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
17 | -if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
11 | + if (!defined('BASE_DIR')) { |
|
12 | + define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
13 | + } |
|
14 | + if (!defined('CORE_DIR')) { |
|
15 | + define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
16 | + } |
|
17 | + } else { |
|
18 | + if (!defined('BASE_DIR')) { |
|
19 | + define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
20 | + } |
|
21 | + if (!defined('CORE_DIR')) { |
|
22 | + define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
23 | + } |
|
24 | + } |
|
25 | +if (!defined('VENDOR_DIR')) { |
|
26 | + define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor'); |
|
27 | +} |
|
28 | +if (!defined('LOG_DIR')) { |
|
29 | + define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
30 | +} |
|
31 | +if (!defined('CACHE_DIR')) { |
|
32 | + define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
33 | +} |
|
34 | +if (!defined('CONFIG_DIR')) { |
|
35 | + define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
36 | +} |
|
37 | +if (!defined('WEB_DIR')) { |
|
38 | + define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
39 | +} |
|
18 | 40 | |
19 | 41 | //Cargamos en memoria la función de desarrollo PRE |
20 | 42 | if (!function_exists('pre')) { |