@@ -2,15 +2,11 @@ |
||
| 2 | 2 | namespace PSFS\base\types; |
| 3 | 3 | |
| 4 | 4 | use PSFS\base\config\Config; |
| 5 | -use PSFS\base\exception\RouterException; |
|
| 6 | -use PSFS\base\Request; |
|
| 7 | -use PSFS\base\Router; |
|
| 8 | 5 | use PSFS\base\Singleton; |
| 9 | 6 | use PSFS\base\types\helpers\GeneratorHelper; |
| 10 | 7 | use PSFS\base\types\helpers\Inspector; |
| 11 | 8 | use PSFS\base\types\interfaces\ControllerInterface; |
| 12 | 9 | use PSFS\base\types\traits\JsonTrait; |
| 13 | -use PSFS\base\types\traits\OutputTrait; |
|
| 14 | 10 | use PSFS\base\types\traits\RouteTrait; |
| 15 | 11 | |
| 16 | 12 | /** |
@@ -41,11 +41,11 @@ discard block |
||
| 41 | 41 | public function render($template, array $vars = array(), $cookies = array(), $domain = null) |
| 42 | 42 | { |
| 43 | 43 | $vars['__menu__'] = $this->getMenu(); |
| 44 | - if(Config::getParam('profiling.enable')) { |
|
| 44 | + if (Config::getParam('profiling.enable')) { |
|
| 45 | 45 | $vars['__profiling__'] = Inspector::getStats(); |
| 46 | 46 | } |
| 47 | 47 | $domain = (null === $domain) ? $this->getDomain() : $domain; |
| 48 | - return $this->tpl->render($domain . $template, $vars, $cookies); |
|
| 48 | + return $this->tpl->render($domain.$template, $vars, $cookies); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $vars['__menu__'] = $this->getMenu(); |
| 78 | 78 | $domain = $domain ?: $this->getDomain(); |
| 79 | - return $this->tpl->dump($domain . $template, $vars); |
|
| 79 | + return $this->tpl->dump($domain.$template, $vars); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -14,6 +14,9 @@ |
||
| 14 | 14 | ]; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | + /** |
|
| 18 | + * @param string $name |
|
| 19 | + */ |
|
| 17 | 20 | public static function stats($name = null) { |
| 18 | 21 | self::$profiling[] = self::collect($name); |
| 19 | 22 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | protected static function calculateStats(array $stats, $ts, $mem = 0, $files = 0) { |
| 29 | 29 | return [ |
| 30 | 30 | 'ts' => round($stats['ts'] - $ts, 4), |
| 31 | - 'mem' => round(($stats['mem'] - $mem) / 1024 / 1024, 4), |
|
| 31 | + 'mem' => round(($stats['mem'] - $mem)/1024/1024, 4), |
|
| 32 | 32 | 'files' => $stats['files'] - $files, |
| 33 | 33 | 'name' => $stats['name'], |
| 34 | 34 | ]; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $ts = defined('PSFS_START_TS') ? PSFS_START_TS : 0; |
| 43 | 43 | $mem = defined('PSFS_START_MEM') ? PSFS_START_MEM : 0; |
| 44 | 44 | $files = 0; |
| 45 | - foreach(self::$profiling as $key => &$value) { |
|
| 45 | + foreach (self::$profiling as $key => &$value) { |
|
| 46 | 46 | $value = self::calculateStats($value, $ts, $mem, $files); |
| 47 | 47 | } |
| 48 | 48 | self::$profiling[] = self::calculateStats(self::collect('Profiling collect ends'), $ts, $mem, $files); |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | * @param mixed $response |
| 19 | 19 | * @param int $statusCode |
| 20 | 20 | * |
| 21 | - * @return mixed JSON |
|
| 21 | + * @return string|null JSON |
|
| 22 | 22 | */ |
| 23 | 23 | public function json($response, $statusCode = 200) |
| 24 | 24 | { |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function json($response, $statusCode = 200) |
| 25 | 25 | { |
| 26 | - if(Config::getParam('profiling.enable')) { |
|
| 27 | - if(is_array($response)) { |
|
| 26 | + if (Config::getParam('profiling.enable')) { |
|
| 27 | + if (is_array($response)) { |
|
| 28 | 28 | $response['profiling'] = Inspector::getStats(); |
| 29 | - } elseif($response instanceof JsonResponse) { |
|
| 29 | + } elseif ($response instanceof JsonResponse) { |
|
| 30 | 30 | $response = ProfilingJsonResponse::createFromPrevious($response, Inspector::getStats()); |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -34,13 +34,13 @@ discard block |
||
| 34 | 34 | $this->decodeJsonReponse($response); |
| 35 | 35 | |
| 36 | 36 | $mask = JSON_UNESCAPED_UNICODE | JSON_BIGINT_AS_STRING; |
| 37 | - if(Config::getParam('output.json.strict_numbers')) { |
|
| 37 | + if (Config::getParam('output.json.strict_numbers')) { |
|
| 38 | 38 | $mask = JSON_UNESCAPED_UNICODE | JSON_BIGINT_AS_STRING | JSON_NUMERIC_CHECK; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $data = json_encode($response, $mask); |
| 42 | - if(Config::getParam('angular.protection', false)) { |
|
| 43 | - $data = ")]}',\n" . $data; |
|
| 42 | + if (Config::getParam('angular.protection', false)) { |
|
| 43 | + $data = ")]}',\n".$data; |
|
| 44 | 44 | } |
| 45 | 45 | $this->setStatus($statusCode); |
| 46 | 46 | ResponseHelper::setDebugHeaders([]); |
@@ -3,17 +3,17 @@ |
||
| 3 | 3 | |
| 4 | 4 | if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__); |
| 5 | 5 | if (preg_match('/vendor/', SOURCE_DIR)) { |
| 6 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
| 7 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
| 8 | -} else { |
|
| 9 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
| 10 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
| 6 | + if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'); |
|
| 7 | + if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src'); |
|
| 8 | +}else { |
|
| 9 | + if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'); |
|
| 10 | + if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules'); |
|
| 11 | 11 | } |
| 12 | -if (!defined('VENDOR_DIR')) define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor'); |
|
| 13 | -if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
| 14 | -if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
| 15 | -if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
| 16 | -if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
| 12 | +if (!defined('VENDOR_DIR')) define('VENDOR_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'vendor'); |
|
| 13 | +if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs'); |
|
| 14 | +if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache'); |
|
| 15 | +if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config'); |
|
| 16 | +if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html'); |
|
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -4,19 +4,39 @@ |
||
| 4 | 4 | defined('PSFS_START_MEM') or define('PSFS_START_MEM', memory_get_usage()); |
| 5 | 5 | defined('PSFS_START_TS') or define('PSFS_START_TS', microtime(true)); |
| 6 | 6 | |
| 7 | -if (!defined('SOURCE_DIR')) define('SOURCE_DIR', __DIR__); |
|
| 7 | +if (!defined('SOURCE_DIR')) { |
|
| 8 | + define('SOURCE_DIR', __DIR__); |
|
| 9 | +} |
|
| 8 | 10 | if (preg_match('/vendor/', SOURCE_DIR)) { |
| 9 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..'); |
|
| 10 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src'); |
|
| 11 | -} else { |
|
| 12 | - if (!defined('BASE_DIR')) define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..'); |
|
| 13 | - if (!defined('CORE_DIR')) define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules'); |
|
| 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'); |
|
| 14 | 39 | } |
| 15 | -if (!defined('VENDOR_DIR')) define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor'); |
|
| 16 | -if (!defined('LOG_DIR')) define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
| 17 | -if (!defined('CACHE_DIR')) define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
| 18 | -if (!defined('CONFIG_DIR')) define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
| 19 | -if (!defined('WEB_DIR')) define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
| 20 | 40 | |
| 21 | 41 | |
| 22 | 42 | /** |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | class FileHelper { |
| 10 | 10 | /** |
| 11 | - * @param mixed $data |
|
| 11 | + * @param string $data |
|
| 12 | 12 | * @param string $path |
| 13 | 13 | * @return int |
| 14 | 14 | */ |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @param string $path |
| 21 | - * @return mixed|bool |
|
| 21 | + * @return string|false |
|
| 22 | 22 | */ |
| 23 | 23 | public static function readFile($path) { |
| 24 | 24 | $data = false; |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | - * @param $path |
|
| 55 | - * @return bool |
|
| 54 | + * @param string $path |
|
| 55 | + * @return boolean|null |
|
| 56 | 56 | */ |
| 57 | 57 | public static function deleteDir($path) { |
| 58 | 58 | (new Filesystem())->remove($path); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public static function readFile($path) { |
| 24 | 24 | $data = false; |
| 25 | - if(file_exists($path)) { |
|
| 25 | + if (file_exists($path)) { |
|
| 26 | 26 | $data = file_get_contents($path); |
| 27 | 27 | } |
| 28 | 28 | return $data; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @return string |
| 36 | 36 | */ |
| 37 | 37 | public static function generateHashFilename($verb, $slug, array $query = []) { |
| 38 | - return sha1(strtolower($verb) . " " . $slug . " " . strtolower(http_build_query($query))); |
|
| 38 | + return sha1(strtolower($verb)." ".$slug." ".strtolower(http_build_query($query))); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | public static function generateCachePath(array $action, array $query = []) { |
| 47 | 47 | $class = GeneratorHelper::extractClassFromNamespace($action['class']); |
| 48 | 48 | $filename = self::generateHashFilename($action["http"], $action["slug"], $query); |
| 49 | - $subPath = substr($filename, 0, 2) . DIRECTORY_SEPARATOR . substr($filename, 2, 2); |
|
| 50 | - return $action['module'] . DIRECTORY_SEPARATOR . $class . DIRECTORY_SEPARATOR . $action['method'] . DIRECTORY_SEPARATOR . $subPath . DIRECTORY_SEPARATOR; |
|
| 49 | + $subPath = substr($filename, 0, 2).DIRECTORY_SEPARATOR.substr($filename, 2, 2); |
|
| 50 | + return $action['module'].DIRECTORY_SEPARATOR.$class.DIRECTORY_SEPARATOR.$action['method'].DIRECTORY_SEPARATOR.$subPath.DIRECTORY_SEPARATOR; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -196,7 +196,7 @@ |
||
| 196 | 196 | /** |
| 197 | 197 | * Method that returns a config value |
| 198 | 198 | * @param string $param |
| 199 | - * @param mixed $defaultValue |
|
| 199 | + * @param string $defaultValue |
|
| 200 | 200 | * |
| 201 | 201 | * @return mixed|null |
| 202 | 202 | */ |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | protected function init() |
| 74 | 74 | { |
| 75 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE)) { |
|
| 75 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE)) { |
|
| 76 | 76 | $this->loadConfigData(); |
| 77 | 77 | } |
| 78 | 78 | return $this; |
@@ -188,10 +188,10 @@ discard block |
||
| 188 | 188 | $final_data = array_filter($final_data, function($key, $value) { |
| 189 | 189 | return in_array($key, Config::$required) || !empty($value); |
| 190 | 190 | }, ARRAY_FILTER_USE_BOTH); |
| 191 | - $saved = (false !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE, json_encode($final_data, JSON_PRETTY_PRINT))); |
|
| 191 | + $saved = (false !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE, json_encode($final_data, JSON_PRETTY_PRINT))); |
|
| 192 | 192 | Config::getInstance()->loadConfigData(); |
| 193 | 193 | $saved = true; |
| 194 | - } catch (ConfigException $e) { |
|
| 194 | + }catch (ConfigException $e) { |
|
| 195 | 195 | Logger::log($e->getMessage(), LOG_ERR); |
| 196 | 196 | } |
| 197 | 197 | return $saved; |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | public function loadConfigData() |
| 225 | 225 | { |
| 226 | - $this->config = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . self::CONFIG_FILE), true) ?: []; |
|
| 226 | + $this->config = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.self::CONFIG_FILE), true) ?: []; |
|
| 227 | 227 | $this->debug = (array_key_exists('debug', $this->config)) ? (bool)$this->config['debug'] : FALSE; |
| 228 | 228 | } |
| 229 | 229 | |
@@ -244,9 +244,9 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | public static function getParam($key, $defaultValue = null, $module = null) |
| 246 | 246 | { |
| 247 | - if(null !== $module) { |
|
| 248 | - return self::getParam(strtolower($module) . '.' . $key, self::getParam($key, $defaultValue)); |
|
| 249 | - } else { |
|
| 247 | + if (null !== $module) { |
|
| 248 | + return self::getParam(strtolower($module).'.'.$key, self::getParam($key, $defaultValue)); |
|
| 249 | + }else { |
|
| 250 | 250 | $param = Config::getInstance()->get($key); |
| 251 | 251 | return (null !== $param) ? $param : $defaultValue; |
| 252 | 252 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @param string $default |
| 21 | - * @return array|mixed|string |
|
| 21 | + * @return string |
|
| 22 | 22 | */ |
| 23 | 23 | private static function extractLocale($default = null) |
| 24 | 24 | { |
@@ -30,21 +30,21 @@ discard block |
||
| 30 | 30 | list($BrowserLocales[$i]) = explode(";", $BrowserLocales[$i]); //trick for "en;q=0.8" |
| 31 | 31 | } |
| 32 | 32 | $locale = array_shift($BrowserLocales); |
| 33 | - } else { |
|
| 33 | + }else { |
|
| 34 | 34 | $locale = strtolower($locale); |
| 35 | 35 | } |
| 36 | 36 | if (false !== strpos($locale, '_')) { |
| 37 | 37 | $locale = explode('_', $locale); |
| 38 | 38 | if ($locale[0] == 'en') { |
| 39 | - $locale = $locale[0] . '_GB'; |
|
| 40 | - } else { |
|
| 41 | - $locale = $locale[0] . '_' . strtoupper($locale[1]); |
|
| 39 | + $locale = $locale[0].'_GB'; |
|
| 40 | + }else { |
|
| 41 | + $locale = $locale[0].'_'.strtoupper($locale[1]); |
|
| 42 | 42 | } |
| 43 | - } else { |
|
| 43 | + }else { |
|
| 44 | 44 | if (strtolower($locale) === 'en') { |
| 45 | 45 | $locale = 'en_GB'; |
| 46 | - } else { |
|
| 47 | - $locale = $locale . '_' . strtoupper($locale); |
|
| 46 | + }else { |
|
| 47 | + $locale = $locale.'_'.strtoupper($locale); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | if (!in_array($locale, self::$langs)) { |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $translations = array(); |
| 66 | 66 | if (file_exists($absoluteTranslationFileName)) { |
| 67 | 67 | @include($absoluteTranslationFileName); |
| 68 | - } else { |
|
| 68 | + }else { |
|
| 69 | 69 | Cache::getInstance()->storeData($absoluteTranslationFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -78,13 +78,13 @@ discard block |
||
| 78 | 78 | public static function setLocale() |
| 79 | 79 | { |
| 80 | 80 | $locale = self::extractLocale('es_ES'); |
| 81 | - Logger::log('Set locale to project [' . $locale . ']'); |
|
| 81 | + Logger::log('Set locale to project ['.$locale.']'); |
|
| 82 | 82 | // Load translations |
| 83 | - putenv("LC_ALL=" . $locale); |
|
| 83 | + putenv("LC_ALL=".$locale); |
|
| 84 | 84 | setlocale(LC_ALL, $locale); |
| 85 | 85 | // Load the locale path |
| 86 | - $locale_path = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
| 87 | - Logger::log('Set locale dir ' . $locale_path); |
|
| 86 | + $locale_path = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
| 87 | + Logger::log('Set locale dir '.$locale_path); |
|
| 88 | 88 | GeneratorHelper::createDir($locale_path); |
| 89 | 89 | bindtextdomain('translations', $locale_path); |
| 90 | 90 | textdomain('translations'); |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public static function checkI18Class($namespace) { |
| 121 | 121 | $isI18n = false; |
| 122 | - if(preg_match('/I18n$/i', $namespace)) { |
|
| 122 | + if (preg_match('/I18n$/i', $namespace)) { |
|
| 123 | 123 | $parentClass = preg_replace('/I18n$/i', '', $namespace); |
| 124 | - if(Router::exists($parentClass)) { |
|
| 124 | + if (Router::exists($parentClass)) { |
|
| 125 | 125 | $isI18n = true; |
| 126 | 126 | } |
| 127 | 127 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | $dump = ''; |
| 114 | 114 | try { |
| 115 | 115 | $dump = $this->tpl->render($tpl, $vars); |
| 116 | - } catch (\Exception $e) { |
|
| 116 | + }catch (\Exception $e) { |
|
| 117 | 117 | Logger::log($e->getMessage(), LOG_ERR); |
| 118 | 118 | } |
| 119 | 119 | return $dump; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | public function regenerateTemplates() |
| 141 | 141 | { |
| 142 | 142 | $this->generateTemplatesCache(); |
| 143 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, true); |
|
| 143 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, true); |
|
| 144 | 144 | $translations = []; |
| 145 | 145 | if (is_array($domains)) { |
| 146 | 146 | $translations = $this->parsePathTranslations($domains); |
@@ -162,8 +162,8 @@ discard block |
||
| 162 | 162 | // force compilation |
| 163 | 163 | if ($file->isFile()) { |
| 164 | 164 | try { |
| 165 | - $this->tpl->load(str_replace($tplDir . '/', '', $file)); |
|
| 166 | - } catch (\Exception $e) { |
|
| 165 | + $this->tpl->load(str_replace($tplDir.'/', '', $file)); |
|
| 166 | + }catch (\Exception $e) { |
|
| 167 | 167 | Logger::log($e->getMessage(), LOG_ERR, ['file' => $e->getFile(), 'line' => $e->getLine()]); |
| 168 | 168 | } |
| 169 | 169 | } |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | 'getFlash' => TemplateFunctions::GET_FLASH_FUNCTION, |
| 225 | 225 | 'getQuery' => TemplateFunctions::GET_QUERY_FUNCTION, |
| 226 | 226 | ]; |
| 227 | - foreach($functions as $name => $function) { |
|
| 227 | + foreach ($functions as $name => $function) { |
|
| 228 | 228 | $this->addTemplateFunction($name, $function); |
| 229 | 229 | } |
| 230 | 230 | } |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | private function loadDomains() |
| 245 | 245 | { |
| 246 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true); |
|
| 246 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true); |
|
| 247 | 247 | if (null !== $domains) { |
| 248 | 248 | foreach ($domains as $domain => $paths) { |
| 249 | 249 | $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain)); |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | { |
| 259 | 259 | $loader = new \Twig_Loader_Filesystem(GeneratorHelper::getTemplatePath()); |
| 260 | 260 | $this->tpl = new \Twig_Environment($loader, array( |
| 261 | - 'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig', |
|
| 261 | + 'cache' => CACHE_DIR.DIRECTORY_SEPARATOR.'twig', |
|
| 262 | 262 | 'debug' => (bool)$this->debug, |
| 263 | 263 | 'auto_reload' => Config::getParam('twig.autoreload', TRUE), |
| 264 | 264 | )); |
@@ -82,9 +82,9 @@ |
||
| 82 | 82 | "class" => "btn-warning md-default", |
| 83 | 83 | "icon" => "fa-plus", |
| 84 | 84 | ]; |
| 85 | - if(Config::getParam('admin.version', 'v1') === 'v1') { |
|
| 86 | - $add["onclick"] = "javascript:addNewField(document.getElementById('" . $this->getName() . "'));"; |
|
| 87 | - } else { |
|
| 85 | + if (Config::getParam('admin.version', 'v1') === 'v1') { |
|
| 86 | + $add["onclick"] = "javascript:addNewField(document.getElementById('".$this->getName()."'));"; |
|
| 87 | + }else { |
|
| 88 | 88 | $add["ng-click"] = "addNewField()"; |
| 89 | 89 | } |
| 90 | 90 | $this->addButton('submit', _("Guardar configuración"), "submit", array( |