@@ -38,8 +38,8 @@ |
||
| 38 | 38 | //Generating the templates translations |
| 39 | 39 | $translations = $this->tpl->regenerateTemplates(); |
| 40 | 40 | |
| 41 | - $locale_path = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
| 42 | - $locale_path .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
| 41 | + $locale_path = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
| 42 | + $locale_path .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
| 43 | 43 | |
| 44 | 44 | //xgettext localizations |
| 45 | 45 | $translations = array_merge($translations, GeneratorService::findTranslations(SOURCE_DIR, $locale)); |
@@ -33,7 +33,9 @@ |
||
| 33 | 33 | public function getTranslations($locale) |
| 34 | 34 | { |
| 35 | 35 | //Default locale |
| 36 | - if (null === $locale) $locale = $this->config->get("default_language"); |
|
| 36 | + if (null === $locale) { |
|
| 37 | + $locale = $this->config->get("default_language"); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | //Generating the templates translations |
| 39 | 41 | $translations = $this->tpl->regenerateTemplates(); |
@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | public function getConfigParams() { |
| 26 | 26 | $response = array_merge(Config::$required, Config::$optional); |
| 27 | 27 | $domains = Router::getInstance()->getDomains(); |
| 28 | - foreach($domains as $domain => $routes) { |
|
| 28 | + foreach ($domains as $domain => $routes) { |
|
| 29 | 29 | $pDomain = str_replace('@', '', $domain); |
| 30 | 30 | $pDomain = str_replace('/', '', $pDomain); |
| 31 | - $response[] = strtolower($pDomain) . '.api.secret'; |
|
| 31 | + $response[] = strtolower($pDomain).'.api.secret'; |
|
| 32 | 32 | } |
| 33 | 33 | return $this->json($response); |
| 34 | 34 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function config() |
| 44 | 44 | { |
| 45 | - Logger::log("Config loaded executed by " . $this->getRequest()->getRequestUri()); |
|
| 45 | + Logger::log("Config loaded executed by ".$this->getRequest()->getRequestUri()); |
|
| 46 | 46 | /* @var $form \PSFS\base\config\ConfigForm */ |
| 47 | 47 | $form = new ConfigForm(); |
| 48 | 48 | $form->build(); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | Security::getInstance()->setFlash("callback_message", _("Configuración actualizada correctamente")); |
| 81 | 81 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-config", true)); |
| 82 | - } else { |
|
| 82 | + }else { |
|
| 83 | 83 | throw new \HttpException(_('Error al guardar la configuración, prueba a cambiar los permisos'), 403); |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | * @GET |
| 29 | 29 | * @route /admin/routes/show |
| 30 | 30 | * @visible false |
| 31 | - * @return mixed |
|
| 31 | + * @return string|null |
|
| 32 | 32 | */ |
| 33 | 33 | public function getRouting() |
| 34 | 34 | { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function generateModule() |
| 32 | 32 | { |
| 33 | - Logger::log("Arranque generador de módulos al solicitar " . $this->getRequest()->getRequestUri()); |
|
| 33 | + Logger::log("Arranque generador de módulos al solicitar ".$this->getRequest()->getRequestUri()); |
|
| 34 | 34 | /* @var $form \PSFS\base\config\ConfigForm */ |
| 35 | 35 | $form = new ModuleForm(); |
| 36 | 36 | $form->build(); |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | $this->gen->createStructureModule($module, $force, $type, (bool)$is_module); |
| 62 | 62 | Security::getInstance()->setFlash("callback_message", str_replace("%s", $module, _("Módulo %s generado correctamente"))); |
| 63 | 63 | Security::getInstance()->setFlash("callback_route", $this->getRoute("admin-module", true)); |
| 64 | - } catch (\Exception $e) { |
|
| 64 | + }catch (\Exception $e) { |
|
| 65 | 65 | pre($e->getMessage(), true); |
| 66 | - Logger::getInstance()->infoLog($e->getMessage() . " [" . $e->getFile() . ":" . $e->getLine() . "]"); |
|
| 66 | + Logger::getInstance()->infoLog($e->getMessage()." [".$e->getFile().":".$e->getLine()."]"); |
|
| 67 | 67 | throw new ConfigException('Error al generar el módulo, prueba a cambiar los permisos', 403); |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | protected function init() |
| 48 | 48 | { |
| 49 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json")) { |
|
| 49 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."config.json")) { |
|
| 50 | 50 | $this->loadConfigData(); |
| 51 | 51 | } |
| 52 | 52 | return $this; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function getTemplatePath() |
| 118 | 118 | { |
| 119 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; |
|
| 119 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR; |
|
| 120 | 120 | return realpath($path); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | $final_data = self::saveExtraParams($data); |
| 164 | 164 | $saved = false; |
| 165 | 165 | try { |
| 166 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json", $final_data, Cache::JSON, true); |
|
| 166 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."config.json", $final_data, Cache::JSON, true); |
|
| 167 | 167 | Config::getInstance()->loadConfigData(); |
| 168 | 168 | $saved = true; |
| 169 | - } catch (ConfigException $e) { |
|
| 169 | + }catch (ConfigException $e) { |
|
| 170 | 170 | Logger::log($e->getMessage(), LOG_ERR); |
| 171 | 171 | } |
| 172 | 172 | return $saved; |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function getPropelParams() |
| 200 | 200 | { |
| 201 | - return Cache::getInstance()->getDataFromFile(__DIR__ . DIRECTORY_SEPARATOR . 'properties.json', Cache::JSON, true); |
|
| 201 | + return Cache::getInstance()->getDataFromFile(__DIR__.DIRECTORY_SEPARATOR.'properties.json', Cache::JSON, true); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -210,12 +210,12 @@ discard block |
||
| 210 | 210 | { |
| 211 | 211 | try { |
| 212 | 212 | if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) { |
| 213 | - throw new \Exception(_('Can\'t create directory ') . $dir); |
|
| 213 | + throw new \Exception(_('Can\'t create directory ').$dir); |
|
| 214 | 214 | } |
| 215 | - } catch (\Exception $e) { |
|
| 215 | + }catch (\Exception $e) { |
|
| 216 | 216 | Logger::log($e->getMessage(), LOG_WARNING); |
| 217 | 217 | if (!file_exists(dirname($dir))) { |
| 218 | - throw new ConfigException($e->getMessage() . $dir); |
|
| 218 | + throw new ConfigException($e->getMessage().$dir); |
|
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | } |
@@ -227,10 +227,10 @@ discard block |
||
| 227 | 227 | { |
| 228 | 228 | $rootDirs = array("css", "js", "media", "font"); |
| 229 | 229 | foreach ($rootDirs as $dir) { |
| 230 | - if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) { |
|
| 230 | + if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) { |
|
| 231 | 231 | try { |
| 232 | - @shell_exec("rm -rf " . WEB_DIR . DIRECTORY_SEPARATOR . $dir); |
|
| 233 | - } catch (\Exception $e) { |
|
| 232 | + @shell_exec("rm -rf ".WEB_DIR.DIRECTORY_SEPARATOR.$dir); |
|
| 233 | + }catch (\Exception $e) { |
|
| 234 | 234 | Logger::log($e->getMessage()); |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | public function loadConfigData() |
| 244 | 244 | { |
| 245 | - $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json", |
|
| 245 | + $this->config = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."config.json", |
|
| 246 | 246 | Cache::JSON, |
| 247 | 247 | TRUE) ?: []; |
| 248 | 248 | $this->debug = (array_key_exists('debug', $this->config)) ? (bool)$this->config['debug'] : FALSE; |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace PSFS\base; |
| 4 | 4 | |
| 5 | 5 | use PSFS\base\types\SingletonTrait; |
| 6 | -use PSFS\controller\UserController; |
|
| 7 | 6 | |
| 8 | 7 | |
| 9 | 8 | /** |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | /** |
| 199 | 199 | * Method that returns a config value |
| 200 | 200 | * @param string $param |
| 201 | - * @param mixed $defaultValue |
|
| 201 | + * @param boolean $defaultValue |
|
| 202 | 202 | * |
| 203 | 203 | * @return mixed|null |
| 204 | 204 | */ |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | /** |
| 284 | 284 | * Static wrapper for extracting params |
| 285 | 285 | * @param string $key |
| 286 | - * @param mixed|null $defaultValue |
|
| 286 | + * @param boolean $defaultValue |
|
| 287 | 287 | * @return mixed|null |
| 288 | 288 | */ |
| 289 | 289 | public static function getParam($key, $defaultValue = null) { |
@@ -5,12 +5,9 @@ |
||
| 5 | 5 | use Propel\Runtime\ActiveQuery\ModelCriteria; |
| 6 | 6 | use Propel\Runtime\ActiveRecord\ActiveRecordInterface; |
| 7 | 7 | use Propel\Runtime\Connection\ConnectionInterface; |
| 8 | - use Propel\Runtime\Map\ColumnMap; |
|
| 9 | 8 | use Propel\Runtime\Map\TableMap; |
| 10 | 9 | use Propel\Runtime\Propel; |
| 11 | 10 | use PSFS\base\config\Config; |
| 12 | - use PSFS\base\dto\Field; |
|
| 13 | - use PSFS\base\dto\Form; |
|
| 14 | 11 | use PSFS\base\dto\JsonResponse; |
| 15 | 12 | use PSFS\base\dto\Order; |
| 16 | 13 | use PSFS\base\Logger; |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * |
| 172 | 172 | * @param ModelCriteria $query |
| 173 | 173 | */ |
| 174 | - private function addOrders(ModelCriteria &$query) |
|
| 174 | + private function addOrders(ModelCriteria & $query) |
|
| 175 | 175 | { |
| 176 | 176 | $orderAdded = FALSE; |
| 177 | 177 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | $orderAdded = TRUE; |
| 180 | 180 | if ($direction === Order::ASC) { |
| 181 | 181 | $query->addAscendingOrderByColumn($field); |
| 182 | - } else { |
|
| 182 | + }else { |
|
| 183 | 183 | $query->addDescendingOrderByColumn($field); |
| 184 | 184 | } |
| 185 | 185 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @param ModelCriteria $query |
| 196 | 196 | */ |
| 197 | - private function addExtraColumns(ModelCriteria &$query) |
|
| 197 | + private function addExtraColumns(ModelCriteria & $query) |
|
| 198 | 198 | { |
| 199 | 199 | if (!empty($this->extraColumns)) { |
| 200 | 200 | foreach ($this->extraColumns as $expression => $columnName) { |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * |
| 209 | 209 | * @param ModelCriteria $query |
| 210 | 210 | */ |
| 211 | - protected function joinTables(ModelCriteria &$query) |
|
| 211 | + protected function joinTables(ModelCriteria & $query) |
|
| 212 | 212 | { |
| 213 | 213 | //TODO for specific implementations |
| 214 | 214 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | * @param ModelCriteria $query |
| 220 | 220 | */ |
| 221 | - private function addFilters(ModelCriteria &$query) |
|
| 221 | + private function addFilters(ModelCriteria & $query) |
|
| 222 | 222 | { |
| 223 | 223 | if (count($this->query) > 0) { |
| 224 | 224 | foreach ($this->query as $field => $value) { |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $text = preg_replace('/(\'|\")/', '', $value); |
| 237 | 237 | $text = preg_replace('/\ /', '%', $text); |
| 238 | 238 | $query->filterBy($tableField, '%'.$text.'%', Criteria::LIKE); |
| 239 | - } else { |
|
| 239 | + }else { |
|
| 240 | 240 | $query->filterBy($tableField, $value, Criteria::EQUAL); |
| 241 | 241 | } |
| 242 | 242 | } |
@@ -259,10 +259,10 @@ discard block |
||
| 259 | 259 | list($page, $limit) = $this->extractPagination(); |
| 260 | 260 | if ($limit == -1) { |
| 261 | 261 | $this->list = $query->find($this->con); |
| 262 | - } else { |
|
| 262 | + }else { |
|
| 263 | 263 | $this->list = $query->paginate($page, $limit, $this->con); |
| 264 | 264 | } |
| 265 | - } catch (\Exception $e) { |
|
| 265 | + }catch (\Exception $e) { |
|
| 266 | 266 | Logger::log($e->getMessage(), LOG_ERR); |
| 267 | 267 | } |
| 268 | 268 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | $this->joinTables($query); |
| 280 | 280 | $this->addExtraColumns($query); |
| 281 | 281 | $this->model = $query->findPk($pk); |
| 282 | - } catch (\Exception $e) { |
|
| 282 | + }catch (\Exception $e) { |
|
| 283 | 283 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
| 284 | 284 | } |
| 285 | 285 | } |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | $saved = TRUE; |
| 368 | 368 | $model = $this->model->toArray(); |
| 369 | 369 | } |
| 370 | - } catch (\Exception $e) { |
|
| 370 | + }catch (\Exception $e) { |
|
| 371 | 371 | Logger::log($e->getMessage(), LOG_ERR); |
| 372 | 372 | } |
| 373 | 373 | |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | $this->model->delete($this->con); |
| 396 | 396 | $deleted = TRUE; |
| 397 | 397 | } |
| 398 | - } catch (\Exception $e) { |
|
| 398 | + }catch (\Exception $e) { |
|
| 399 | 399 | Logger::getInstance(get_class($this->model))->errorLog($e->getMessage()); |
| 400 | 400 | } |
| 401 | 401 | } |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | */ |
| 440 | 440 | private function extractQuery() |
| 441 | 441 | { |
| 442 | - $queryReflector = new \ReflectionClass($this->getModelNamespace() . "Query"); |
|
| 442 | + $queryReflector = new \ReflectionClass($this->getModelNamespace()."Query"); |
|
| 443 | 443 | /** @var \Propel\Runtime\ActiveQuery\ModelCriteria $query */ |
| 444 | 444 | $query = $queryReflector->getMethod('create')->invoke($this->con); |
| 445 | 445 | |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | if (null !== $this->con && $this->con->inTransaction()) { |
| 484 | 484 | if ($status === 200) { |
| 485 | 485 | $this->con->commit(); |
| 486 | - } else { |
|
| 486 | + }else { |
|
| 487 | 487 | $this->con->rollBack(); |
| 488 | 488 | } |
| 489 | 489 | } |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | return $this->render('api.admin.html.twig', array( |
| 528 | 528 | "api" => $this->getApi(), |
| 529 | 529 | "domain" => $this->domain, |
| 530 | - "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('api-' . $this->getApi() . "-pk"), TRUE)), |
|
| 530 | + "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('api-'.$this->getApi()."-pk"), TRUE)), |
|
| 531 | 531 | ), [], ''); |
| 532 | 532 | } |
| 533 | 533 | |
@@ -561,12 +561,12 @@ discard block |
||
| 561 | 561 | $pages = 0; |
| 562 | 562 | try { |
| 563 | 563 | $this->paginate(); |
| 564 | - if(null !== $this->list) { |
|
| 564 | + if (null !== $this->list) { |
|
| 565 | 565 | $return = $this->list->toArray(); |
| 566 | 566 | $total = $this->list->getNbResults(); |
| 567 | 567 | $pages = $this->list->getLastPage(); |
| 568 | 568 | } |
| 569 | - } catch (\Exception $e) { |
|
| 569 | + }catch (\Exception $e) { |
|
| 570 | 570 | Logger::getInstance(get_class($this))->errorLog($e->getMessage()); |
| 571 | 571 | } |
| 572 | 572 | |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | $return = array(); |
| 586 | 586 | if (NULL === $model && method_exists($model, 'toArray')) { |
| 587 | 587 | $code = 404; |
| 588 | - } else { |
|
| 588 | + }else { |
|
| 589 | 589 | $return = $model->toArray(); |
| 590 | 590 | } |
| 591 | 591 | |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | /** |
| 618 | 618 | * Método que extrae los parámetros de una función |
| 619 | 619 | * |
| 620 | - * @param array $sr |
|
| 620 | + * @param string[] $sr |
|
| 621 | 621 | * @param \ReflectionMethod $method |
| 622 | 622 | * |
| 623 | 623 | * @return array |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | * |
| 671 | 671 | * @param string $docComments |
| 672 | 672 | * |
| 673 | - * @return bool |
|
| 673 | + * @return string |
|
| 674 | 674 | */ |
| 675 | 675 | private function extractReflectionCacheability($docComments) |
| 676 | 676 | { |
@@ -56,8 +56,10 @@ discard block |
||
| 56 | 56 | $_route = explode("/", $url['path']); |
| 57 | 57 | $_pattern = explode("/", $pattern); |
| 58 | 58 | $get = array(); |
| 59 | - if (!empty($_pattern)) foreach ($_pattern as $index => $component) { |
|
| 59 | + if (!empty($_pattern)) { |
|
| 60 | + foreach ($_pattern as $index => $component) { |
|
| 60 | 61 | $_get = array(); |
| 62 | + } |
|
| 61 | 63 | preg_match_all('/^\{(.*)\}$/i', $component, $_get); |
| 62 | 64 | if (!empty($_get[1]) && isset($_route[$index])) { |
| 63 | 65 | $get[array_pop($_get[1])] = $_route[$index]; |
@@ -151,12 +153,16 @@ discard block |
||
| 151 | 153 | $params = []; |
| 152 | 154 | $parameters = $method->getParameters(); |
| 153 | 155 | /** @var \ReflectionParameter $param */ |
| 154 | - if (count($parameters) > 0) foreach ($parameters as $param) { |
|
| 156 | + if (count($parameters) > 0) { |
|
| 157 | + foreach ($parameters as $param) { |
|
| 155 | 158 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
| 156 | 159 | $params[$param->getName()] = $param->getDefaultValue(); |
| 160 | + } |
|
| 157 | 161 | $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
| 158 | 162 | } |
| 159 | - } else $default = $regex; |
|
| 163 | + } else { |
|
| 164 | + $default = $regex; |
|
| 165 | + } |
|
| 160 | 166 | |
| 161 | 167 | return array($regex, $default, $params); |
| 162 | 168 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | public static function getClassToCall($action) |
| 21 | 21 | { |
| 22 | 22 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
| 23 | - $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"]; |
|
| 23 | + $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"]; |
|
| 24 | 24 | $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass; |
| 25 | 25 | return $class; |
| 26 | 26 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $expr = preg_quote($expr, '/'); |
| 107 | 107 | $expr = str_replace('###', '(.*)', $expr); |
| 108 | 108 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
| 109 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
| 109 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
| 110 | 110 | return $matched; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public static function extractDomainInfo(\ReflectionClass $class, $domain) |
| 119 | 119 | { |
| 120 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
| 121 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
| 120 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
| 121 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
| 122 | 122 | $tpl_path = "templates"; |
| 123 | 123 | $public_path = "public"; |
| 124 | 124 | $model_path = "models"; |
@@ -128,12 +128,12 @@ discard block |
||
| 128 | 128 | $model_path = ucfirst($model_path); |
| 129 | 129 | } |
| 130 | 130 | if ($class->hasConstant("TPL")) { |
| 131 | - $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); |
|
| 131 | + $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); |
|
| 132 | 132 | } |
| 133 | 133 | return [ |
| 134 | - "template" => $path . $tpl_path, |
|
| 135 | - "model" => $path . $model_path, |
|
| 136 | - "public" => $path . $public_path, |
|
| 134 | + "template" => $path.$tpl_path, |
|
| 135 | + "model" => $path.$model_path, |
|
| 136 | + "public" => $path.$public_path, |
|
| 137 | 137 | ]; |
| 138 | 138 | } |
| 139 | 139 | |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | if (count($parameters) > 0) foreach ($parameters as $param) { |
| 156 | 156 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
| 157 | 157 | $params[$param->getName()] = $param->getDefaultValue(); |
| 158 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
| 158 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
| 159 | 159 | } |
| 160 | - } else $default = $regex; |
|
| 160 | + }else $default = $regex; |
|
| 161 | 161 | |
| 162 | 162 | return array($regex, $default, $params); |
| 163 | 163 | } |
@@ -212,10 +212,10 @@ discard block |
||
| 212 | 212 | { |
| 213 | 213 | $is_enabled = true; |
| 214 | 214 | // For non api routes |
| 215 | - if(strlen($api) > 0 && preg_match('/admin/i', $route)) { |
|
| 215 | + if (strlen($api) > 0 && preg_match('/admin/i', $route)) { |
|
| 216 | 216 | // If route is for api, check if admin is enabled in config |
| 217 | 217 | $admin_enabled = Config::getInstance()->get('api.admin'); |
| 218 | - if(empty($admin_enabled)) { |
|
| 218 | + if (empty($admin_enabled)) { |
|
| 219 | 219 | $is_enabled = false; |
| 220 | 220 | } |
| 221 | 221 | } |
@@ -239,8 +239,8 @@ discard block |
||
| 239 | 239 | $default = str_replace('{__API__}', $api, $default); |
| 240 | 240 | } |
| 241 | 241 | $httpMethod = RouterHelper::extractReflectionHttpMethod($docComments); |
| 242 | - if(self::checkCanAddRoute($regex, $api)) { |
|
| 243 | - $route = $httpMethod . "#|#" . $regex; |
|
| 242 | + if (self::checkCanAddRoute($regex, $api)) { |
|
| 243 | + $route = $httpMethod."#|#".$regex; |
|
| 244 | 244 | $info = [ |
| 245 | 245 | "method" => $method->getName(), |
| 246 | 246 | "params" => $params, |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | $default = Config::getInstance()->get('admin_action') ?: 'admin-login'; |
| 268 | 268 | |
| 269 | 269 | } |
| 270 | - if(null !== $default) { |
|
| 270 | + if (null !== $default) { |
|
| 271 | 271 | return Router::getInstance()->execute(Router::getInstance()->getRoute($default)); |
| 272 | 272 | } |
| 273 | 273 | return null; |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | use PSFS\base\config\Config; |
| 5 | 5 | use PSFS\base\Security; |
| 6 | 6 | use PSFS\base\Service; |
| 7 | - use PSFS\controller\Admin; |
|
| 8 | 7 | use Symfony\Component\Finder\Finder; |
| 9 | 8 | |
| 10 | 9 | class AdminServices extends Service{ |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | use PSFS\controller\Admin; |
| 8 | 8 | use Symfony\Component\Finder\Finder; |
| 9 | 9 | |
| 10 | - class AdminServices extends Service{ |
|
| 10 | + class AdminServices extends Service { |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * @Inyectable |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $platform = trim(Config::getInstance()->get("platform_name")); |
| 35 | 35 | header('HTTP/1.1 401 Unauthorized'); |
| 36 | - header('WWW-Authenticate: Basic Realm="' . $platform. '"'); |
|
| 36 | + header('WWW-Authenticate: Basic Realm="'.$platform.'"'); |
|
| 37 | 37 | echo _("Zona restringida"); |
| 38 | 38 | exit(); |
| 39 | 39 | } |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | public function getAdmins() |
| 46 | 46 | { |
| 47 | 47 | $admins = $this->security->getAdmins(); |
| 48 | - if(!empty($admins)) |
|
| 48 | + if (!empty($admins)) |
|
| 49 | 49 | { |
| 50 | - if(!$this->security->checkAdmin()) |
|
| 50 | + if (!$this->security->checkAdmin()) |
|
| 51 | 51 | { |
| 52 | 52 | $this->setAdminHeaders(); |
| 53 | 53 | } |
@@ -62,17 +62,17 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | private function parseAdmins(&$admins) |
| 64 | 64 | { |
| 65 | - if(!empty($admins)) foreach($admins as &$admin) |
|
| 65 | + if (!empty($admins)) foreach ($admins as &$admin) |
|
| 66 | 66 | { |
| 67 | - if(isset($admin["profile"])) |
|
| 67 | + if (isset($admin["profile"])) |
|
| 68 | 68 | { |
| 69 | - switch($admin["profile"]) { |
|
| 69 | + switch ($admin["profile"]) { |
|
| 70 | 70 | case Security::MANAGER_ID_TOKEN: $admin['class'] = 'warning'; break; |
| 71 | 71 | case Security::ADMIN_ID_TOKEN: $admin['class'] = 'info'; break; |
| 72 | 72 | default: |
| 73 | 73 | case Security::USER_ID_TOKEN: $admin['class'] = 'primary'; break; |
| 74 | 74 | } |
| 75 | - }else{ |
|
| 75 | + }else { |
|
| 76 | 76 | $admin["class"] = "primary"; |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | $files->files()->in(LOG_DIR)->name("*.log")->sortByModifiedTime(); |
| 89 | 89 | $logs = array(); |
| 90 | 90 | /** @var \SplFileInfo $file */ |
| 91 | - foreach($files as $file) |
|
| 91 | + foreach ($files as $file) |
|
| 92 | 92 | { |
| 93 | - $size = $file->getSize() / 8 / 1024; |
|
| 93 | + $size = $file->getSize()/8/1024; |
|
| 94 | 94 | $time = date("c", $file->getMTime()); |
| 95 | 95 | $dateTime = new \DateTime($time); |
| 96 | - if(!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array(); |
|
| 96 | + if (!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array(); |
|
| 97 | 97 | $logs[$dateTime->format("Y")][$dateTime->format("m")][$time] = array( |
| 98 | 98 | "filename" => $file->getFilename(), |
| 99 | 99 | "size" => round($size, 3) |
@@ -117,27 +117,27 @@ discard block |
||
| 117 | 117 | $files->files()->in(LOG_DIR)->name($selectedLog); |
| 118 | 118 | $file = null; |
| 119 | 119 | $log = array(); |
| 120 | - foreach($files as $match) |
|
| 120 | + foreach ($files as $match) |
|
| 121 | 121 | { |
| 122 | 122 | $file = $match; |
| 123 | 123 | break; |
| 124 | 124 | } |
| 125 | 125 | /** @var \SplFileInfo $file */ |
| 126 | - if(!empty($file)) |
|
| 126 | + if (!empty($file)) |
|
| 127 | 127 | { |
| 128 | 128 | $time = date("c", $file->getMTime()); |
| 129 | 129 | $dateTime = new \DateTime($time); |
| 130 | 130 | $monthOpen = $dateTime->format("m"); |
| 131 | - $content = file($file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename()); |
|
| 131 | + $content = file($file->getPath().DIRECTORY_SEPARATOR.$file->getFilename()); |
|
| 132 | 132 | krsort($content); |
| 133 | 133 | $detailLog = array(); |
| 134 | - foreach($content as &$line) |
|
| 134 | + foreach ($content as &$line) |
|
| 135 | 135 | { |
| 136 | 136 | list($line, $detail) = $this->parseLogLine($line, $match); |
| 137 | 137 | $detailLog[] = array_merge(array( |
| 138 | 138 | "log" => $line, |
| 139 | 139 | ), $detail); |
| 140 | - if(count($detailLog) >= 1000) break; |
|
| 140 | + if (count($detailLog) >= 1000) break; |
|
| 141 | 141 | } |
| 142 | 142 | $log = $detailLog; |
| 143 | 143 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | $type = (isset($match[1][0])) ? $match[1][0] : ''; |
| 168 | 168 | $type = explode(".", $type); |
| 169 | - $type = count($type)>1 ? $type[1] : $type[0]; |
|
| 169 | + $type = count($type) > 1 ? $type[1] : $type[0]; |
|
| 170 | 170 | switch ($type) { |
| 171 | 171 | case 'INFO': |
| 172 | 172 | $detail["type"] = "success"; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | break; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - } catch (\Exception $e) { |
|
| 185 | + }catch (\Exception $e) { |
|
| 186 | 186 | $detail = array( |
| 187 | 187 | "type" => "danger", |
| 188 | 188 | ); |
@@ -62,17 +62,20 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | private function parseAdmins(&$admins) |
| 64 | 64 | { |
| 65 | - if(!empty($admins)) foreach($admins as &$admin) |
|
| 65 | + if(!empty($admins)) { |
|
| 66 | + foreach($admins as &$admin) |
|
| 66 | 67 | { |
| 67 | 68 | if(isset($admin["profile"])) |
| 68 | 69 | { |
| 69 | 70 | switch($admin["profile"]) { |
| 70 | - case Security::MANAGER_ID_TOKEN: $admin['class'] = 'warning'; break; |
|
| 71 | + case Security::MANAGER_ID_TOKEN: $admin['class'] = 'warning'; |
|
| 72 | + } |
|
| 73 | + break; |
|
| 71 | 74 | case Security::ADMIN_ID_TOKEN: $admin['class'] = 'info'; break; |
| 72 | 75 | default: |
| 73 | 76 | case Security::USER_ID_TOKEN: $admin['class'] = 'primary'; break; |
| 74 | 77 | } |
| 75 | - }else{ |
|
| 78 | + } else{ |
|
| 76 | 79 | $admin["class"] = "primary"; |
| 77 | 80 | } |
| 78 | 81 | } |
@@ -93,7 +96,9 @@ discard block |
||
| 93 | 96 | $size = $file->getSize() / 8 / 1024; |
| 94 | 97 | $time = date("c", $file->getMTime()); |
| 95 | 98 | $dateTime = new \DateTime($time); |
| 96 | - if(!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array(); |
|
| 99 | + if(!isset($logs[$dateTime->format("Y")])) { |
|
| 100 | + $logs[$dateTime->format("Y")] = array(); |
|
| 101 | + } |
|
| 97 | 102 | $logs[$dateTime->format("Y")][$dateTime->format("m")][$time] = array( |
| 98 | 103 | "filename" => $file->getFilename(), |
| 99 | 104 | "size" => round($size, 3) |
@@ -137,7 +142,9 @@ discard block |
||
| 137 | 142 | $detailLog[] = array_merge(array( |
| 138 | 143 | "log" => $line, |
| 139 | 144 | ), $detail); |
| 140 | - if(count($detailLog) >= 1000) break; |
|
| 145 | + if(count($detailLog) >= 1000) { |
|
| 146 | + break; |
|
| 147 | + } |
|
| 141 | 148 | } |
| 142 | 149 | $log = $detailLog; |
| 143 | 150 | } |
@@ -161,7 +168,9 @@ discard block |
||
| 161 | 168 | |
| 162 | 169 | $detail = json_decode($match[0][0], TRUE); |
| 163 | 170 | } |
| 164 | - if (empty($detail)) $detail = array(); |
|
| 171 | + if (empty($detail)) { |
|
| 172 | + $detail = array(); |
|
| 173 | + } |
|
| 165 | 174 | preg_match_all('/\>\ (.*):/i', $line, $match); |
| 166 | 175 | |
| 167 | 176 | $type = (isset($match[1][0])) ? $match[1][0] : ''; |
@@ -393,8 +393,10 @@ |
||
| 393 | 393 | throw new RouterException(_("No existe la ruta especificada")); |
| 394 | 394 | } |
| 395 | 395 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
| 396 | - if (!empty($params)) foreach ($params as $key => $value) { |
|
| 396 | + if (!empty($params)) { |
|
| 397 | + foreach ($params as $key => $value) { |
|
| 397 | 398 | $url = str_replace("{" . $key . "}", $value, $url); |
| 399 | + } |
|
| 398 | 400 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
| 399 | 401 | $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
| 400 | 402 | } |
@@ -59,12 +59,12 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function init() |
| 61 | 61 | { |
| 62 | - if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json") || Config::getInstance()->getDebugMode()) { |
|
| 62 | + if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json") || Config::getInstance()->getDebugMode()) { |
|
| 63 | 63 | $this->hydrateRouting(); |
| 64 | 64 | $this->simpatize(); |
| 65 | - } else { |
|
| 66 | - list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", Cache::JSON, TRUE); |
|
| 67 | - $this->domains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", Cache::JSON, TRUE); |
|
| 65 | + }else { |
|
| 66 | + list($this->routing, $this->slugs) = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", Cache::JSON, TRUE); |
|
| 67 | + $this->domains = $this->cache->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", Cache::JSON, TRUE); |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | "success" => FALSE, |
| 85 | 85 | "error" => $e->getMessage(), |
| 86 | 86 | )), 'application/json'); |
| 87 | - } else { |
|
| 87 | + }else { |
|
| 88 | 88 | if (NULL === $e) { |
| 89 | 89 | Logger::log('Not found page throwed without previous exception', LOG_WARNING); |
| 90 | 90 | $e = new \Exception(_('Page not found'), 404); |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function getAllRoutes() { |
| 115 | 115 | $routes = []; |
| 116 | - foreach($this->routing as $path => $route) { |
|
| 117 | - if(array_key_exists('slug', $route)) { |
|
| 116 | + foreach ($this->routing as $path => $route) { |
|
| 117 | + if (array_key_exists('slug', $route)) { |
|
| 118 | 118 | $routes[$route['slug']] = $path; |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -139,15 +139,15 @@ discard block |
||
| 139 | 139 | SecurityHelper::checkRestrictedAccess($route); |
| 140 | 140 | //Search action and execute |
| 141 | 141 | $this->searchAction($route); |
| 142 | - } catch (AccessDeniedException $e) { |
|
| 142 | + }catch (AccessDeniedException $e) { |
|
| 143 | 143 | Logger::log(_('Solicitamos credenciales de acceso a zona restringida')); |
| 144 | 144 | return Admin::staticAdminLogon($route); |
| 145 | - } catch (RouterException $r) { |
|
| 146 | - if(null === RouterHelper::checkDefaultRoute($route)) { |
|
| 145 | + }catch (RouterException $r) { |
|
| 146 | + if (null === RouterHelper::checkDefaultRoute($route)) { |
|
| 147 | 147 | Logger::log($r->getMessage(), LOG_WARNING); |
| 148 | 148 | throw $r; |
| 149 | 149 | } |
| 150 | - } catch (\Exception $e) { |
|
| 150 | + }catch (\Exception $e) { |
|
| 151 | 151 | Logger::log($e->getMessage(), LOG_ERR); |
| 152 | 152 | throw $e; |
| 153 | 153 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | protected function searchAction($route) |
| 166 | 166 | { |
| 167 | - Logger::log('Searching action to execute: ' . $route, LOG_INFO); |
|
| 167 | + Logger::log('Searching action to execute: '.$route, LOG_INFO); |
|
| 168 | 168 | //Revisamos si tenemos la ruta registrada |
| 169 | 169 | $parts = parse_url($route); |
| 170 | 170 | $path = (array_key_exists('path', $parts)) ? $parts['path'] : $route; |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | $class = RouterHelper::getClassToCall($action); |
| 179 | 179 | try { |
| 180 | 180 | $this->executeCachedRoute($route, $action, $class, $get); |
| 181 | - } catch (\Exception $e) { |
|
| 181 | + }catch (\Exception $e) { |
|
| 182 | 182 | Logger::log($e->getMessage(), LOG_ERR); |
| 183 | 183 | throw new RouterException($e->getMessage(), 404, $e); |
| 184 | 184 | } |
@@ -206,13 +206,13 @@ discard block |
||
| 206 | 206 | $this->routing = $this->inspectDir($base, "PSFS", array()); |
| 207 | 207 | if (file_exists($modules)) { |
| 208 | 208 | $module = ""; |
| 209 | - if(file_exists($modules . DIRECTORY_SEPARATOR . 'module.json')) { |
|
| 210 | - $mod_cfg = json_decode(file_get_contents($modules . DIRECTORY_SEPARATOR . 'module.json'), true); |
|
| 209 | + if (file_exists($modules.DIRECTORY_SEPARATOR.'module.json')) { |
|
| 210 | + $mod_cfg = json_decode(file_get_contents($modules.DIRECTORY_SEPARATOR.'module.json'), true); |
|
| 211 | 211 | $module = $mod_cfg['module']; |
| 212 | 212 | } |
| 213 | 213 | $this->routing = $this->inspectDir($modules, $module, $this->routing); |
| 214 | 214 | } |
| 215 | - $this->cache->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "domains.json", $this->domains, Cache::JSON, TRUE); |
|
| 215 | + $this->cache->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."domains.json", $this->domains, Cache::JSON, TRUE); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | $home_params = NULL; |
| 228 | 228 | foreach ($this->routing as $pattern => $params) { |
| 229 | 229 | list($method, $route) = RouterHelper::extractHttpRoute($pattern); |
| 230 | - if (preg_match("/" . preg_quote($route, "/") . "$/i", "/" . $home)) { |
|
| 230 | + if (preg_match("/".preg_quote($route, "/")."$/i", "/".$home)) { |
|
| 231 | 231 | $home_params = $params; |
| 232 | 232 | } |
| 233 | 233 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $files = $this->finder->files()->in($origen)->path('/(controller|api)/i')->name("*.php"); |
| 253 | 253 | foreach ($files as $file) { |
| 254 | 254 | $filename = str_replace("/", '\\', str_replace($origen, '', $file->getPathname())); |
| 255 | - $routing = $this->addRouting($namespace . str_replace('.php', '', $filename), $routing); |
|
| 255 | + $routing = $this->addRouting($namespace.str_replace('.php', '', $filename), $routing); |
|
| 256 | 256 | } |
| 257 | 257 | $this->finder = new Finder(); |
| 258 | 258 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | } |
| 292 | 292 | foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { |
| 293 | 293 | list($route, $info) = RouterHelper::extractRouteInfo($method, $api); |
| 294 | - if(null !== $route && null !== $info) { |
|
| 294 | + if (null !== $route && null !== $info) { |
|
| 295 | 295 | $info['class'] = $namespace; |
| 296 | 296 | $routing[$route] = $info; |
| 297 | 297 | } |
@@ -314,11 +314,11 @@ discard block |
||
| 314 | 314 | { |
| 315 | 315 | //Calculamos los dominios para las plantillas |
| 316 | 316 | if ($class->hasConstant("DOMAIN") && !$class->isAbstract()) { |
| 317 | - if(!$this->domains) { |
|
| 317 | + if (!$this->domains) { |
|
| 318 | 318 | $this->domains = []; |
| 319 | 319 | } |
| 320 | - $domain = "@" . $class->getConstant("DOMAIN") . "/"; |
|
| 321 | - if(!array_key_exists($domain, $this->domains)) { |
|
| 320 | + $domain = "@".$class->getConstant("DOMAIN")."/"; |
|
| 321 | + if (!array_key_exists($domain, $this->domains)) { |
|
| 322 | 322 | $this->domains[$domain] = RouterHelper::extractDomainInfo($class, $domain); |
| 323 | 323 | } |
| 324 | 324 | } |
@@ -332,11 +332,11 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | public function simpatize() |
| 334 | 334 | { |
| 335 | - $translationFileName = "translations" . DIRECTORY_SEPARATOR . "routes_translations.php"; |
|
| 336 | - $absoluteTranslationFileName = CACHE_DIR . DIRECTORY_SEPARATOR . $translationFileName; |
|
| 335 | + $translationFileName = "translations".DIRECTORY_SEPARATOR."routes_translations.php"; |
|
| 336 | + $absoluteTranslationFileName = CACHE_DIR.DIRECTORY_SEPARATOR.$translationFileName; |
|
| 337 | 337 | $this->generateSlugs($absoluteTranslationFileName); |
| 338 | 338 | Config::createDir(CONFIG_DIR); |
| 339 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
| 339 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json", array($this->routing, $this->slugs), Cache::JSON, TRUE); |
|
| 340 | 340 | |
| 341 | 341 | return $this; |
| 342 | 342 | } |
@@ -354,16 +354,16 @@ discard block |
||
| 354 | 354 | public function getRoute($slug = '', $absolute = FALSE, $params = []) |
| 355 | 355 | { |
| 356 | 356 | if (strlen($slug) === 0) { |
| 357 | - return ($absolute) ? Request::getInstance()->getRootUrl() . '/' : '/'; |
|
| 357 | + return ($absolute) ? Request::getInstance()->getRootUrl().'/' : '/'; |
|
| 358 | 358 | } |
| 359 | 359 | if (NULL === $slug || !array_key_exists($slug, $this->slugs)) { |
| 360 | 360 | throw new RouterException(_("No existe la ruta especificada")); |
| 361 | 361 | } |
| 362 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->slugs[$slug] : $this->slugs[$slug]; |
|
| 362 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->slugs[$slug] : $this->slugs[$slug]; |
|
| 363 | 363 | if (!empty($params)) foreach ($params as $key => $value) { |
| 364 | - $url = str_replace("{" . $key . "}", $value, $url); |
|
| 364 | + $url = str_replace("{".$key."}", $value, $url); |
|
| 365 | 365 | } elseif (!empty($this->routing[$this->slugs[$slug]]["default"])) { |
| 366 | - $url = ($absolute) ? Request::getInstance()->getRootUrl() . $this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
| 366 | + $url = ($absolute) ? Request::getInstance()->getRootUrl().$this->routing[$this->slugs[$slug]]["default"] : $this->routing[$this->slugs[$slug]]["default"]; |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | return preg_replace('/(GET|POST|PUT|DELETE|ALL)\#\|\#/', '', $url); |
@@ -406,24 +406,24 @@ discard block |
||
| 406 | 406 | */ |
| 407 | 407 | protected function executeCachedRoute($route, $action, $class, $params = NULL) |
| 408 | 408 | { |
| 409 | - Logger::log('Executing route ' . $route, LOG_INFO); |
|
| 409 | + Logger::log('Executing route '.$route, LOG_INFO); |
|
| 410 | 410 | Security::getInstance()->setSessionKey("__CACHE__", $action); |
| 411 | 411 | $cache = Cache::needCache(); |
| 412 | 412 | $execute = TRUE; |
| 413 | 413 | if (FALSE !== $cache && Config::getInstance()->getDebugMode() === FALSE) { |
| 414 | 414 | $cacheDataName = $this->cache->getRequestCacheHash(); |
| 415 | - $cachedData = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName, |
|
| 416 | - $cache, function () {}); |
|
| 415 | + $cachedData = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName, |
|
| 416 | + $cache, function() {}); |
|
| 417 | 417 | if (NULL !== $cachedData) { |
| 418 | - $headers = $this->cache->readFromCache("templates" . DIRECTORY_SEPARATOR . $cacheDataName . ".headers", |
|
| 419 | - $cache, function () {}, Cache::JSON); |
|
| 418 | + $headers = $this->cache->readFromCache("templates".DIRECTORY_SEPARATOR.$cacheDataName.".headers", |
|
| 419 | + $cache, function() {}, Cache::JSON); |
|
| 420 | 420 | Template::getInstance()->renderCache($cachedData, $headers); |
| 421 | 421 | $execute = FALSE; |
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | if ($execute) { |
| 425 | 425 | Logger::log(_('Start executing action'), LOG_DEBUG); |
| 426 | - if(false === call_user_func_array(array($class, $action['method']), $params)) { |
|
| 426 | + if (false === call_user_func_array(array($class, $action['method']), $params)) { |
|
| 427 | 427 | Logger::log(_('An error ocurred trying to execute the action'), LOG_ERR, [error_get_last()]); |
| 428 | 428 | } |
| 429 | 429 | } |
@@ -4,16 +4,16 @@ discard block |
||
| 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('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'); |
|
| 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 | //Cargamos en memoria la función de desarrollo PRE |
| 19 | 19 | if (!function_exists('pre')) { |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $html = '<pre style="padding:10px;margin:0;display:block;background: #EEE; box-shadow: inset 0 0 3px 3px #DDD; color: #666; text-shadow: 1px 1px 1px #CCC;border-radius: 5px;">'; |
| 23 | 23 | $html .= (is_null($var)) ? '<b>NULL</b>' : print_r($var, TRUE); |
| 24 | 24 | $html .= '</pre>'; |
| 25 | - if(class_exists('\\PSFS\\Dispatcher')) { |
|
| 25 | + if (class_exists('\\PSFS\\Dispatcher')) { |
|
| 26 | 26 | $html .= '<pre>['.round(\PSFS\Dispatcher::getInstance()->getMem('MBytes'), 3).'Mb - '.round(\PSFS\Dispatcher::getInstance()->getTs(), 3).'s]</pre>'; |
| 27 | 27 | } |
| 28 | 28 | ob_start(); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | ob_flush(); |
| 31 | 31 | ob_end_clean(); |
| 32 | 32 | if ($die) { |
| 33 | - if(class_exists('\\PSFS\\base\\Logger')) { |
|
| 33 | + if (class_exists('\\PSFS\\base\\Logger')) { |
|
| 34 | 34 | \PSFS\base\Logger::log('Execution finished via pre', LOG_WARNING); |
| 35 | 35 | } |
| 36 | 36 | die; |
@@ -1,19 +1,39 @@ |
||
| 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'); |
|
| 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('LOG_DIR')) { |
|
| 26 | + define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs'); |
|
| 27 | +} |
|
| 28 | +if (!defined('CACHE_DIR')) { |
|
| 29 | + define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache'); |
|
| 30 | +} |
|
| 31 | +if (!defined('CONFIG_DIR')) { |
|
| 32 | + define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config'); |
|
| 33 | +} |
|
| 34 | +if (!defined('WEB_DIR')) { |
|
| 35 | + define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html'); |
|
| 12 | 36 | } |
| 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 | 37 | |
| 18 | 38 | //Cargamos en memoria la función de desarrollo PRE |
| 19 | 39 | if (!function_exists('pre')) { |