@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | public static function getClassToCall(array $action) |
20 | 20 | { |
21 | 21 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
22 | - $actionClass = class_exists($action['class']) ? $action['class'] : "\\" . $action['class']; |
|
22 | + $actionClass = class_exists($action['class']) ? $action['class'] : "\\".$action['class']; |
|
23 | 23 | $reflectionClass = new \ReflectionClass($actionClass); |
24 | - if($reflectionClass->hasMethod('getInstance')) { |
|
24 | + if ($reflectionClass->hasMethod('getInstance')) { |
|
25 | 25 | $class = $reflectionClass->getMethod('getInstance')->invoke(null, $action['method']); |
26 | - } else { |
|
26 | + }else { |
|
27 | 27 | $class = new $actionClass; |
28 | 28 | } |
29 | 29 | return $class; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $expr = preg_quote($expr, '/'); |
113 | 113 | $expr = str_replace('###', '(.*)', $expr); |
114 | 114 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
115 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
115 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
116 | 116 | return $matched; |
117 | 117 | } |
118 | 118 | |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public static function extractDomainInfo(\ReflectionClass $class, $domain) |
125 | 125 | { |
126 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
127 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
126 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
127 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
128 | 128 | $templatesPath = 'templates'; |
129 | 129 | $publicPath = 'public'; |
130 | 130 | $modelsPath = 'models'; |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | $modelsPath = ucfirst($modelsPath); |
135 | 135 | } |
136 | 136 | if ($class->hasConstant('TPL')) { |
137 | - $templatesPath .= DIRECTORY_SEPARATOR . $class->getConstant('TPL'); |
|
137 | + $templatesPath .= DIRECTORY_SEPARATOR.$class->getConstant('TPL'); |
|
138 | 138 | } |
139 | 139 | return [ |
140 | 140 | 'base' => $path, |
141 | - 'template' => $path . $templatesPath, |
|
142 | - 'model' => $path . $modelsPath, |
|
143 | - 'public' => $path . $publicPath, |
|
141 | + 'template' => $path.$templatesPath, |
|
142 | + 'model' => $path.$modelsPath, |
|
143 | + 'public' => $path.$publicPath, |
|
144 | 144 | ]; |
145 | 145 | } |
146 | 146 | |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | foreach ($parameters as $param) { |
165 | 165 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
166 | 166 | $params[$param->getName()] = $param->getDefaultValue(); |
167 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
168 | - } elseif(!$param->isOptional()) { |
|
167 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
168 | + } elseif (!$param->isOptional()) { |
|
169 | 169 | $requirements[] = $param->getName(); |
170 | 170 | } |
171 | 171 | } |
172 | - } else { |
|
172 | + }else { |
|
173 | 173 | $default = $regex; |
174 | 174 | } |
175 | 175 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $default = str_replace('{__DOMAIN__}', $module, $default); |
252 | 252 | $httpMethod = self::extractReflectionHttpMethod($docComments); |
253 | 253 | $label = self::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
254 | - $route = $httpMethod . "#|#" . $regex; |
|
254 | + $route = $httpMethod."#|#".$regex; |
|
255 | 255 | $route = preg_replace('/(\\r|\\f|\\t|\\n)/', '', $route); |
256 | 256 | $info = [ |
257 | 257 | 'method' => $method->getName(), |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | if (!headers_sent()) { |
46 | 46 | // TODO include this headers in Template class output method |
47 | 47 | header('Access-Control-Allow-Credentials: true'); |
48 | - header('Access-Control-Allow-Origin: ' . Request::getInstance()->getServer('HTTP_ORIGIN', '*')); |
|
48 | + header('Access-Control-Allow-Origin: '.Request::getInstance()->getServer('HTTP_ORIGIN', '*')); |
|
49 | 49 | header('Vary: Origin'); |
50 | 50 | header('Access-Control-Allow-Methods: GET, POST, DELETE, PUT, PATCH, OPTIONS'); |
51 | - header('Access-Control-Allow-Headers: ' . implode(', ', self::getCorsHeaders())); |
|
51 | + header('Access-Control-Allow-Headers: '.implode(', ', self::getCorsHeaders())); |
|
52 | 52 | } |
53 | 53 | if (Request::getInstance()->getMethod() === Request::VERB_OPTIONS) { |
54 | 54 | Logger::log('Returning OPTIONS header confirmation for CORS pre flight requests', LOG_DEBUG); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | return $ip; |
79 | 79 | } |
80 | 80 | } |
81 | - } else { |
|
81 | + }else { |
|
82 | 82 | if (self::validateIpAddress($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
83 | 83 | return $_SERVER['HTTP_X_FORWARDED_FOR']; |
84 | 84 | } |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | protected function hydrateBulkRequest() { |
97 | 97 | $class = new \ReflectionClass($this->getModelNamespace()); |
98 | 98 | $this->list = []; |
99 | - foreach($this->data as $item) { |
|
100 | - if(is_array($item)) { |
|
101 | - if(count($this->list) < Config::getParam('api.block.limit', 1000)) { |
|
99 | + foreach ($this->data as $item) { |
|
100 | + if (is_array($item)) { |
|
101 | + if (count($this->list) < Config::getParam('api.block.limit', 1000)) { |
|
102 | 102 | /** @var ActiveRecordInterface $model */ |
103 | 103 | $model = $class->newInstance(); |
104 | 104 | $this->hydrateModelFromRequest($model, $item); |
105 | 105 | $this->list[] = $model; |
106 | - } else { |
|
107 | - Logger::log(t('Max items per bulk insert raised'), LOG_WARNING, count($this->data) . t('items')); |
|
106 | + }else { |
|
107 | + Logger::log(t('Max items per bulk insert raised'), LOG_WARNING, count($this->data).t('items')); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | } |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | */ |
116 | 116 | protected function saveBulk() { |
117 | 117 | $tablemap = $this->getTableMap(); |
118 | - foreach($this->list as &$model) { |
|
118 | + foreach ($this->list as &$model) { |
|
119 | 119 | $con = Propel::getWriteConnection($tablemap::DATABASE_NAME); |
120 | 120 | try { |
121 | 121 | $model->save($con); |
122 | 122 | $con->commit(); |
123 | - } catch(\Exception $e) { |
|
123 | + }catch (\Exception $e) { |
|
124 | 124 | Logger::log($e->getMessage(), LOG_ERR, $model->toArray()); |
125 | 125 | $con->rollBack(); |
126 | 126 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | protected function exportList() { |
134 | 134 | $list = []; |
135 | 135 | /** @var ActiveRecordInterface $item */ |
136 | - foreach($this->list as $item) { |
|
136 | + foreach ($this->list as $item) { |
|
137 | 137 | $list[] = $item->toArray(); |
138 | 138 | } |
139 | 139 | return $list; |
@@ -157,18 +157,18 @@ discard block |
||
157 | 157 | */ |
158 | 158 | protected function findPk(ModelCriteria $query, $primaryKey) { |
159 | 159 | $pks = explode(Api::API_PK_SEPARATOR, urldecode($primaryKey)); |
160 | - if(count($pks) === 1 && !empty($pks[0])) { |
|
160 | + if (count($pks) === 1 && !empty($pks[0])) { |
|
161 | 161 | $query->filterByPrimaryKey($pks[0]); |
162 | - } else { |
|
162 | + }else { |
|
163 | 163 | $item = 0; |
164 | - foreach($this->getPkDbName() as $phpName) { |
|
164 | + foreach ($this->getPkDbName() as $phpName) { |
|
165 | 165 | try { |
166 | 166 | $query->filterBy($phpName, $pks[$item]); |
167 | 167 | $item++; |
168 | - if($item >= count($pks)) { |
|
168 | + if ($item >= count($pks)) { |
|
169 | 169 | break; |
170 | 170 | } |
171 | - } catch(\Exception $e) { |
|
171 | + }catch (\Exception $e) { |
|
172 | 172 | Logger::log($e->getMessage(), LOG_DEBUG); |
173 | 173 | } |
174 | 174 | } |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | try { |
199 | 199 | $query = $this->prepareQuery(); |
200 | 200 | $this->model = $this->findPk($query, $primaryKey); |
201 | - } catch (\Exception $e) { |
|
202 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
201 | + }catch (\Exception $e) { |
|
202 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 |
@@ -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 t('Zona restringida'); |
38 | 38 | exit(); |
39 | 39 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $admin['class'] = 'primary'; |
76 | 76 | break; |
77 | 77 | } |
78 | - } else { |
|
78 | + }else { |
|
79 | 79 | $admin['class'] = 'primary'; |
80 | 80 | } |
81 | 81 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $logs = array(); |
94 | 94 | /** @var \SplFileInfo $file */ |
95 | 95 | foreach ($files as $file) { |
96 | - $size = $file->getSize() / 8 / 1024; |
|
96 | + $size = $file->getSize()/8/1024; |
|
97 | 97 | $time = date('c', $file->getMTime()); |
98 | 98 | $dateTime = new \DateTime($time); |
99 | 99 | if (!isset($logs[$dateTime->format('Y')])) { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $files->files()->in(LOG_DIR)->name($selectedLog); |
123 | 123 | $file = $match = null; |
124 | 124 | $log = array(); |
125 | - foreach($files as $item) { |
|
125 | + foreach ($files as $item) { |
|
126 | 126 | $file = $item; |
127 | 127 | $match = $item; |
128 | 128 | break; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $time = date('c', $file->getMTime()); |
133 | 133 | $dateTime = new \DateTime($time); |
134 | 134 | $monthOpen = $dateTime->format('m'); |
135 | - $content = file($file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename()); |
|
135 | + $content = file($file->getPath().DIRECTORY_SEPARATOR.$file->getFilename()); |
|
136 | 136 | krsort($content); |
137 | 137 | $detailLog = array(); |
138 | 138 | foreach ($content as &$line) { |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | break; |
191 | 191 | } |
192 | 192 | |
193 | - } catch (\Exception $e) { |
|
193 | + }catch (\Exception $e) { |
|
194 | 194 | $detail = [ |
195 | 195 | 'type' => 'danger', |
196 | 196 | ]; |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | if ($module === $requestModule && 0 === stripos($module, 'ROOT')) { |
56 | 56 | $modules = [ |
57 | 57 | 'name' => $module, |
58 | - 'path' => dirname($info['template'] . DIRECTORY_SEPARATOR . '..'), |
|
58 | + 'path' => dirname($info['template'].DIRECTORY_SEPARATOR.'..'), |
|
59 | 59 | ]; |
60 | 60 | } |
61 | - } catch (\Exception $e) { |
|
61 | + }catch (\Exception $e) { |
|
62 | 62 | $modules[] = $e->getMessage(); |
63 | 63 | } |
64 | 64 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function extractApiEndpoints(array $module) |
78 | 78 | { |
79 | - $modulePath = $module['path'] . DIRECTORY_SEPARATOR . 'Api'; |
|
79 | + $modulePath = $module['path'].DIRECTORY_SEPARATOR.'Api'; |
|
80 | 80 | $moduleName = $module['name']; |
81 | 81 | $endpoints = []; |
82 | 82 | if (file_exists($modulePath)) { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | if (count($finder)) { |
86 | 86 | /** @var \SplFileInfo $file */ |
87 | 87 | foreach ($finder as $file) { |
88 | - $namespace = "\\{$moduleName}\\Api\\" . str_replace('.php', '', $file->getFilename()); |
|
88 | + $namespace = "\\{$moduleName}\\Api\\".str_replace('.php', '', $file->getFilename()); |
|
89 | 89 | $info = $this->extractApiInfo($namespace, $moduleName); |
90 | 90 | if (!empty($info)) { |
91 | 91 | $endpoints[$namespace] = $info; |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | if (Router::exists($namespace) && !I18nHelper::checkI18Class($namespace)) { |
109 | 109 | $reflection = new \ReflectionClass($namespace); |
110 | 110 | $visible = InjectorHelper::checkIsVisible($reflection->getDocComment()); |
111 | - if($visible) { |
|
111 | + if ($visible) { |
|
112 | 112 | foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { |
113 | 113 | try { |
114 | 114 | $mInfo = $this->extractMethodInfo($namespace, $method, $reflection, $module); |
115 | 115 | if (NULL !== $mInfo) { |
116 | 116 | $info[] = $mInfo; |
117 | 117 | } |
118 | - } catch (\Exception $e) { |
|
118 | + }catch (\Exception $e) { |
|
119 | 119 | Logger::log($e->getMessage(), LOG_ERR); |
120 | 120 | } |
121 | 121 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | $payload = $this->extractModelFields($namespace); |
249 | 249 | $reflector = new \ReflectionClass($namespace); |
250 | 250 | $shortName = $reflector->getShortName(); |
251 | - } else { |
|
251 | + }else { |
|
252 | 252 | $namespace = $model; |
253 | 253 | $shortName = $model; |
254 | 254 | } |
@@ -337,13 +337,13 @@ discard block |
||
337 | 337 | "required" => $field->isNotNull(), |
338 | 338 | 'format' => $format, |
339 | 339 | ]; |
340 | - if(count($field->getValueSet())) { |
|
340 | + if (count($field->getValueSet())) { |
|
341 | 341 | $info['enum'] = array_values($field->getValueSet()); |
342 | 342 | } |
343 | - if(null !== $field->getDefaultValue()) { |
|
343 | + if (null !== $field->getDefaultValue()) { |
|
344 | 344 | $info['default'] = $field->getDefaultValue(); |
345 | 345 | } |
346 | - switch(Config::getParam('api.field.type', TableMap::TYPE_PHPNAME)) { |
|
346 | + switch (Config::getParam('api.field.type', TableMap::TYPE_PHPNAME)) { |
|
347 | 347 | case 'UpperCamelCase': |
348 | 348 | case TableMap::TYPE_PHPNAME: |
349 | 349 | $payload[$field->getPhpName()] = $info; |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) { |
366 | 366 | $payload = $this->extractDtoProperties($namespace); |
367 | 367 | } |
368 | - } catch (\Exception $e) { |
|
368 | + }catch (\Exception $e) { |
|
369 | 369 | Logger::log($e->getMessage(), LOG_ERR); |
370 | 370 | } |
371 | 371 | |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | $return = $this->extractReturn($modelNamespace, $docComments); |
397 | 397 | $url = array_pop($route); |
398 | 398 | $methodInfo = [ |
399 | - 'url' => str_replace('/' . $module . '/api', '', $url), |
|
399 | + 'url' => str_replace('/'.$module.'/api', '', $url), |
|
400 | 400 | 'method' => $info['http'], |
401 | 401 | 'description' => $info['label'], |
402 | 402 | 'return' => $return, |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | $this->setRequestParams($method, $methodInfo, $modelNamespace, $docComments); |
408 | 408 | $this->setQueryParams($method, $methodInfo); |
409 | 409 | $this->setRequestHeaders($reflection, $methodInfo); |
410 | - } catch (\Exception $e) { |
|
410 | + }catch (\Exception $e) { |
|
411 | 411 | Logger::log($e->getMessage(), LOG_ERR); |
412 | 412 | } |
413 | 413 | } |
@@ -476,10 +476,10 @@ discard block |
||
476 | 476 | $formatted = [ |
477 | 477 | "swagger" => "2.0", |
478 | 478 | "host" => preg_replace('/^(http|https)\:\/\/(.*)\/$/i', '$2', Router::getInstance()->getRoute('', true)), |
479 | - "basePath" => '/' . $module['name'] . '/api', |
|
479 | + "basePath" => '/'.$module['name'].'/api', |
|
480 | 480 | "schemes" => [Request::getInstance()->getServer('HTTPS') === 'on' ? 'https' : 'http'], |
481 | 481 | "info" => [ |
482 | - "title" => t('Documentación API módulo ') . $module['name'], |
|
482 | + "title" => t('Documentación API módulo ').$module['name'], |
|
483 | 483 | "version" => Config::getParam('api.version', '1.0.0'), |
484 | 484 | "contact" => [ |
485 | 485 | "name" => Config::getParam("author", "Fran López"), |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | foreach ($endpoints as $model) { |
493 | 493 | foreach ($model as $endpoint) { |
494 | 494 | if (!preg_match('/^\/(admin|api)\//i', $endpoint['url']) && strlen($endpoint['url'])) { |
495 | - $url = preg_replace('/\/' . $module['name'] . '\/api/i', '', $endpoint['url']); |
|
495 | + $url = preg_replace('/\/'.$module['name'].'\/api/i', '', $endpoint['url']); |
|
496 | 496 | $description = $endpoint['description']; |
497 | 497 | $method = strtolower($endpoint['method']); |
498 | 498 | $paths[$url][$method] = [ |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | protected function extractDtoName($dto, $isArray = false) |
554 | 554 | { |
555 | 555 | $dto = explode('\\', $dto); |
556 | - $modelDto = array_pop($dto) . "Dto"; |
|
556 | + $modelDto = array_pop($dto)."Dto"; |
|
557 | 557 | if ($isArray) { |
558 | 558 | $modelDto .= "List"; |
559 | 559 | } |
@@ -603,10 +603,10 @@ discard block |
||
603 | 603 | { |
604 | 604 | |
605 | 605 | $methodInfo['headers'] = []; |
606 | - foreach($reflection->getProperties() as $property) { |
|
606 | + foreach ($reflection->getProperties() as $property) { |
|
607 | 607 | $doc = $property->getDocComment(); |
608 | 608 | preg_match('/@header\ (.*)\n/i', $doc, $headers); |
609 | - if(count($headers)) { |
|
609 | + if (count($headers)) { |
|
610 | 610 | $header = [ |
611 | 611 | "name" => $headers[1], |
612 | 612 | "in" => "header", |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | foreach ($method->getParameters() as $parameter) { |
652 | 652 | $parameterName = $parameter->getName(); |
653 | 653 | $types = []; |
654 | - preg_match_all('/\@param\ (.*)\ \$' . $parameterName . '$/im', $docComments, $types); |
|
654 | + preg_match_all('/\@param\ (.*)\ \$'.$parameterName.'$/im', $docComments, $types); |
|
655 | 655 | if (count($types) > 1 && count($types[1]) > 0) { |
656 | 656 | $methodInfo['parameters'][$parameterName] = $types[1][0]; |
657 | 657 | } |
@@ -673,21 +673,21 @@ discard block |
||
673 | 673 | $modelDto['objects'][$dtoName][$param] = [ |
674 | 674 | 'type' => 'array', |
675 | 675 | 'items' => [ |
676 | - '$ref' => '#/definitions/' . $info['type'], |
|
676 | + '$ref' => '#/definitions/'.$info['type'], |
|
677 | 677 | ] |
678 | 678 | ]; |
679 | - } else { |
|
679 | + }else { |
|
680 | 680 | $modelDto['objects'][$dtoName][$param] = [ |
681 | 681 | 'type' => 'object', |
682 | - '$ref' => '#/definitions/' . $info['type'], |
|
682 | + '$ref' => '#/definitions/'.$info['type'], |
|
683 | 683 | ]; |
684 | 684 | } |
685 | 685 | $modelDto['objects'][$info['class']] = $info['properties']; |
686 | 686 | $paramDto = $this->checkDtoAttributes($info['properties'], $info['properties'], $info['class']); |
687 | - if(array_key_exists('objects', $paramDto)) { |
|
687 | + if (array_key_exists('objects', $paramDto)) { |
|
688 | 688 | $modelDto['objects'] = array_merge($modelDto['objects'], $paramDto['objects']); |
689 | 689 | } |
690 | - } else { |
|
690 | + }else { |
|
691 | 691 | $modelDto['objects'][$dtoName][$param] = $info; |
692 | 692 | } |
693 | 693 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public function __construct($type = 'js') |
36 | 36 | { |
37 | 37 | $this->type = $type; |
38 | - $this->path = WEB_DIR . DIRECTORY_SEPARATOR; |
|
38 | + $this->path = WEB_DIR.DIRECTORY_SEPARATOR; |
|
39 | 39 | $this->domains = Template::getDomains(true); |
40 | 40 | $this->debug = Config::getParam('debug'); |
41 | 41 | $this->cdnPath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl()); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $source_file = explode("?", $source_file); |
59 | 59 | $source_file = $source_file[0]; |
60 | 60 | } |
61 | - $orig = realpath(dirname($filename_path) . DIRECTORY_SEPARATOR . $source_file); |
|
61 | + $orig = realpath(dirname($filename_path).DIRECTORY_SEPARATOR.$source_file); |
|
62 | 62 | return $orig; |
63 | 63 | } |
64 | 64 | |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function addFile($filename) |
73 | 73 | { |
74 | - if (file_exists($this->path . $filename) && preg_match('/\.' . $this->type . '$/i', $filename)) { |
|
74 | + if (file_exists($this->path.$filename) && preg_match('/\.'.$this->type.'$/i', $filename)) { |
|
75 | 75 | $this->files[] = $filename; |
76 | 76 | } elseif (!empty($this->domains)) { |
77 | 77 | foreach ($this->domains as $domain => $paths) { |
78 | 78 | $domain_filename = str_replace($domain, $paths["public"], $filename); |
79 | - if (file_exists($domain_filename) && preg_match('/\.' . $this->type . '$/i', $domain_filename)) { |
|
79 | + if (file_exists($domain_filename) && preg_match('/\.'.$this->type.'$/i', $domain_filename)) { |
|
80 | 80 | $this->files[] = $domain_filename; |
81 | 81 | } |
82 | 82 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | public function setHash($hash) |
94 | 94 | { |
95 | 95 | $cache = Config::getParam('cache.var', ''); |
96 | - $this->hash = $hash . (strlen($cache) ? '.' : '') . $cache; |
|
96 | + $this->hash = $hash.(strlen($cache) ? '.' : '').$cache; |
|
97 | 97 | return $this; |
98 | 98 | } |
99 | 99 | |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function compileCss() |
129 | 129 | { |
130 | - $base = $this->path . "css" . DIRECTORY_SEPARATOR; |
|
131 | - if ($this->debug || !file_exists($base . $this->hash . ".css")) { |
|
130 | + $base = $this->path."css".DIRECTORY_SEPARATOR; |
|
131 | + if ($this->debug || !file_exists($base.$this->hash.".css")) { |
|
132 | 132 | $data = ''; |
133 | 133 | if (0 < count($this->files)) { |
134 | 134 | $minifier = new CSS(); |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | $data = $this->processCssLine($file, $base, $data); |
137 | 137 | } |
138 | 138 | } |
139 | - if($this->debug) { |
|
140 | - $this->storeContents($base . $this->hash . ".css", $data); |
|
141 | - } else { |
|
139 | + if ($this->debug) { |
|
140 | + $this->storeContents($base.$this->hash.".css", $data); |
|
141 | + }else { |
|
142 | 142 | $minifier = new CSS(); |
143 | 143 | $minifier->add($data); |
144 | 144 | ini_set('max_execution_time', -1); |
145 | 145 | ini_set('memory_limit', -1); |
146 | 146 | GeneratorHelper::createDir($base); |
147 | - $minifier->minify($base . $this->hash . ".css"); |
|
147 | + $minifier->minify($base.$this->hash.".css"); |
|
148 | 148 | ini_restore('memory_limit'); |
149 | 149 | ini_restore('max_execution_time'); |
150 | 150 | } |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | */ |
161 | 161 | protected function compileJs() |
162 | 162 | { |
163 | - $base = $this->path . "js" . DIRECTORY_SEPARATOR; |
|
164 | - if ($this->debug || !file_exists($base . $this->hash . ".js")) { |
|
163 | + $base = $this->path."js".DIRECTORY_SEPARATOR; |
|
164 | + if ($this->debug || !file_exists($base.$this->hash.".js")) { |
|
165 | 165 | $data = ''; |
166 | 166 | if (0 < count($this->files)) { |
167 | 167 | $minifier = new JS(); |
@@ -170,19 +170,19 @@ discard block |
||
170 | 170 | if (file_exists($file)) { |
171 | 171 | if ($this->debug) { |
172 | 172 | $data = $this->putDebugJs($path_parts, $base, $file); |
173 | - } elseif (!file_exists($base . $this->hash . ".js")) { |
|
173 | + } elseif (!file_exists($base.$this->hash.".js")) { |
|
174 | 174 | $minifier->add($file); |
175 | 175 | //$data = $this->putProductionJs($base, $file, $data); |
176 | 176 | } |
177 | 177 | } |
178 | 178 | } |
179 | - if($this->debug) { |
|
180 | - $this->storeContents($base . $this->hash . ".js", $data); |
|
181 | - } else { |
|
179 | + if ($this->debug) { |
|
180 | + $this->storeContents($base.$this->hash.".js", $data); |
|
181 | + }else { |
|
182 | 182 | ini_set('max_execution_time', -1); |
183 | 183 | ini_set('memory_limit', -1); |
184 | 184 | GeneratorHelper::createDir($base); |
185 | - $minifier->minify($base . $this->hash . ".js"); |
|
185 | + $minifier->minify($base.$this->hash.".js"); |
|
186 | 186 | ini_restore('memory_limit'); |
187 | 187 | ini_restore('max_execution_time'); |
188 | 188 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | { |
203 | 203 | GeneratorHelper::createDir(dirname($path)); |
204 | 204 | if ("" !== $content && false === file_put_contents($path, $content)) { |
205 | - throw new ConfigException(_('No se tienen permisos para escribir en ' . $path)); |
|
205 | + throw new ConfigException(_('No se tienen permisos para escribir en '.$path)); |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | foreach ($this->compiled_files as $file) { |
232 | 232 | echo "\t\t<script type='text/javascript' src='{$file}'></script>\n"; |
233 | 233 | } |
234 | - } else { |
|
234 | + }else { |
|
235 | 235 | $basePath = $this->cdnPath ?: ''; |
236 | - echo "\t\t<script type='text/javascript' src='" . $basePath . "/js/" . $this->hash . ".js'></script>\n"; |
|
236 | + echo "\t\t<script type='text/javascript' src='".$basePath."/js/".$this->hash.".js'></script>\n"; |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | foreach ($this->compiled_files as $file) { |
247 | 247 | echo "\t\t<link href='{$file}' rel='stylesheet' media='screen, print'>"; |
248 | 248 | } |
249 | - } else { |
|
249 | + }else { |
|
250 | 250 | $basePath = $this->cdnPath ?: ''; |
251 | - echo "\t\t<link href='" . $basePath . "/css/" . $this->hash . ".css' rel='stylesheet'>"; |
|
251 | + echo "\t\t<link href='".$basePath."/css/".$this->hash.".css' rel='stylesheet'>"; |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
@@ -259,20 +259,20 @@ discard block |
||
259 | 259 | protected function extractCssResources($source, $file) |
260 | 260 | { |
261 | 261 | $source_file = $this->extractSourceFilename($source); |
262 | - $orig = realpath(dirname($file) . DIRECTORY_SEPARATOR . $source_file); |
|
262 | + $orig = realpath(dirname($file).DIRECTORY_SEPARATOR.$source_file); |
|
263 | 263 | $orig_part = preg_split('/(\/|\\\)public(\/|\\\)/i', $orig); |
264 | 264 | try { |
265 | 265 | if (count($source) > 1 && array_key_exists(1, $orig_part)) { |
266 | - $dest = $this->path . $orig_part[1]; |
|
266 | + $dest = $this->path.$orig_part[1]; |
|
267 | 267 | GeneratorHelper::createDir(dirname($dest)); |
268 | 268 | if (!file_exists($dest) || filemtime($orig) > filemtime($dest)) { |
269 | 269 | if (@copy($orig, $dest) === FALSE) { |
270 | - throw new \RuntimeException('Can\' copy ' . $dest . ''); |
|
270 | + throw new \RuntimeException('Can\' copy '.$dest.''); |
|
271 | 271 | } |
272 | 272 | Logger::log("$orig copiado a $dest", LOG_INFO); |
273 | 273 | } |
274 | 274 | } |
275 | - } catch (\Exception $e) { |
|
275 | + }catch (\Exception $e) { |
|
276 | 276 | Logger::log($e->getMessage(), LOG_ERR); |
277 | 277 | } |
278 | 278 | } |
@@ -289,21 +289,21 @@ discard block |
||
289 | 289 | { |
290 | 290 | if (file_exists($file)) { |
291 | 291 | $path_parts = explode("/", $file); |
292 | - $file_path = $this->hash . "_" . $path_parts[count($path_parts) - 1]; |
|
293 | - if (!file_exists($base . $file_path) || filemtime($base . $file_path) < filemtime($file) || $this->debug) { |
|
292 | + $file_path = $this->hash."_".$path_parts[count($path_parts) - 1]; |
|
293 | + if (!file_exists($base.$file_path) || filemtime($base.$file_path) < filemtime($file) || $this->debug) { |
|
294 | 294 | //Si tenemos modificaciones tenemos que compilar de nuevo todos los ficheros modificados |
295 | - if (file_exists($base . $this->hash . ".css") && @unlink($base . $this->hash . ".css") === false) { |
|
296 | - throw new ConfigException("Can't unlink file " . $base . $this->hash . ".css"); |
|
295 | + if (file_exists($base.$this->hash.".css") && @unlink($base.$this->hash.".css") === false) { |
|
296 | + throw new ConfigException("Can't unlink file ".$base.$this->hash.".css"); |
|
297 | 297 | } |
298 | 298 | $this->loopCssLines($file); |
299 | 299 | } |
300 | 300 | if ($this->debug) { |
301 | 301 | $data = file_get_contents($file); |
302 | - $this->storeContents($base . $file_path, $data); |
|
303 | - } else { |
|
302 | + $this->storeContents($base.$file_path, $data); |
|
303 | + }else { |
|
304 | 304 | $data .= file_get_contents($file); |
305 | 305 | } |
306 | - $this->compiled_files[] = "/css/" . $file_path; |
|
306 | + $this->compiled_files[] = "/css/".$file_path; |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | return $data; |
@@ -318,12 +318,12 @@ discard block |
||
318 | 318 | */ |
319 | 319 | protected function putDebugJs($path_parts, $base, $file) |
320 | 320 | { |
321 | - $file_path = $this->hash . "_" . $path_parts[count($path_parts) - 1]; |
|
322 | - $this->compiled_files[] = "/js/" . $file_path; |
|
321 | + $file_path = $this->hash."_".$path_parts[count($path_parts) - 1]; |
|
322 | + $this->compiled_files[] = "/js/".$file_path; |
|
323 | 323 | $data = ""; |
324 | - if (!file_exists($base . $file_path) || filemtime($base . $file_path) < filemtime($file)) { |
|
324 | + if (!file_exists($base.$file_path) || filemtime($base.$file_path) < filemtime($file)) { |
|
325 | 325 | $data = file_get_contents($file); |
326 | - $this->storeContents($base . $file_path, $data); |
|
326 | + $this->storeContents($base.$file_path, $data); |
|
327 | 327 | } |
328 | 328 | return $data; |
329 | 329 | } |
@@ -365,60 +365,60 @@ discard block |
||
365 | 365 | { |
366 | 366 | $ppath = explode("/", $string); |
367 | 367 | $original_filename = $ppath[count($ppath) - 1]; |
368 | - $base = WEB_DIR . DIRECTORY_SEPARATOR; |
|
368 | + $base = WEB_DIR.DIRECTORY_SEPARATOR; |
|
369 | 369 | $file = ""; |
370 | 370 | $html_base = ""; |
371 | 371 | $debug = Config::getInstance()->getDebugMode(); |
372 | 372 | $cache = Config::getInstance()->get('cache.var'); |
373 | - $cache = $cache ? '.' . $cache : ''; |
|
373 | + $cache = $cache ? '.'.$cache : ''; |
|
374 | 374 | $finfo = finfo_open(FILEINFO_MIME_TYPE); // devuelve el tipo mime de su extensión |
375 | 375 | $mime = finfo_file($finfo, $filename_path); |
376 | 376 | finfo_close($finfo); |
377 | 377 | if (preg_match('/\.css$/i', $string)) { |
378 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.css"; |
|
378 | + $file = "/".substr(md5($string), 0, 8)."$cache.css"; |
|
379 | 379 | $html_base = "css"; |
380 | 380 | if ($debug) { |
381 | - $file = str_replace(".css", "_" . $original_filename, $file); |
|
381 | + $file = str_replace(".css", "_".$original_filename, $file); |
|
382 | 382 | } |
383 | 383 | } elseif (preg_match('/\.js$/i', $string)) { |
384 | - $file = "/" . substr(md5($string), 0, 8) . "$cache.js"; |
|
384 | + $file = "/".substr(md5($string), 0, 8)."$cache.js"; |
|
385 | 385 | $html_base = "js"; |
386 | 386 | if ($debug) { |
387 | - $file = str_replace(".js", "_" . $original_filename, $file); |
|
387 | + $file = str_replace(".js", "_".$original_filename, $file); |
|
388 | 388 | } |
389 | 389 | } elseif (preg_match("/image/i", $mime)) { |
390 | 390 | $ext = explode(".", $string); |
391 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
391 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
392 | 392 | $html_base = "img"; |
393 | 393 | if ($debug) { |
394 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
394 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
395 | 395 | } |
396 | 396 | } elseif (preg_match("/(doc|pdf)/i", $mime)) { |
397 | 397 | $ext = explode(".", $string); |
398 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
398 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
399 | 399 | $html_base = "docs"; |
400 | 400 | if ($debug) { |
401 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
401 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
402 | 402 | } |
403 | 403 | } elseif (preg_match("/(video|audio|ogg)/i", $mime)) { |
404 | 404 | $ext = explode(".", $string); |
405 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
405 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
406 | 406 | $html_base = "media"; |
407 | 407 | if ($debug) { |
408 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
408 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
409 | 409 | } |
410 | 410 | } elseif (preg_match("/(text|html)/i", $mime)) { |
411 | 411 | $ext = explode(".", $string); |
412 | - $file = "/" . substr(md5($string), 0, 8) . "." . $ext[count($ext) - 1]; |
|
412 | + $file = "/".substr(md5($string), 0, 8).".".$ext[count($ext) - 1]; |
|
413 | 413 | $html_base = "templates"; |
414 | 414 | if ($debug) { |
415 | - $file = str_replace("." . $ext[count($ext) - 1], "_" . $original_filename, $file); |
|
415 | + $file = str_replace(".".$ext[count($ext) - 1], "_".$original_filename, $file); |
|
416 | 416 | } |
417 | 417 | } elseif (!$return && !is_null($name)) { |
418 | 418 | $html_base = ''; |
419 | 419 | $file = $name; |
420 | 420 | } |
421 | - $file_path = $html_base . $file; |
|
421 | + $file_path = $html_base.$file; |
|
422 | 422 | |
423 | 423 | return array($base, $html_base, $file_path); |
424 | 424 | } |
@@ -436,15 +436,15 @@ discard block |
||
436 | 436 | if (preg_match_all('#url\((.*?)\)#', $line, $urls, PREG_SET_ORDER)) { |
437 | 437 | foreach ($urls as $source) { |
438 | 438 | $orig = self::calculateResourcePathname($filename_path, $source); |
439 | - if(!empty($orig)) { |
|
439 | + if (!empty($orig)) { |
|
440 | 440 | $orig_part = preg_split("/Public/i", $orig); |
441 | - $dest = WEB_DIR . $orig_part[1]; |
|
441 | + $dest = WEB_DIR.$orig_part[1]; |
|
442 | 442 | GeneratorHelper::createDir(dirname($dest)); |
443 | 443 | if (@copy($orig, $dest) === false) { |
444 | - throw new ConfigException("Can't copy " . $orig . " to " . $dest); |
|
444 | + throw new ConfigException("Can't copy ".$orig." to ".$dest); |
|
445 | 445 | } |
446 | - } else { |
|
447 | - Logger::log($filename_path . ' has an empty origin with the url ' . $source, LOG_WARNING); |
|
446 | + }else { |
|
447 | + Logger::log($filename_path.' has an empty origin with the url '.$source, LOG_WARNING); |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | protected function getTmpAttribute($node = null) |
115 | 115 | { |
116 | 116 | $tmp = []; |
117 | - if(null !== $node) { |
|
117 | + if (null !== $node) { |
|
118 | 118 | $tmp = $node->getAttribute('value'); |
119 | 119 | if (!is_array($tmp)) { |
120 | 120 | $tmp = [$tmp]; |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | $tmp = []; |
137 | 137 | if (null === $node) { |
138 | 138 | $node = $value; |
139 | - } else { |
|
139 | + }else { |
|
140 | 140 | $tmp = $this->getTmpAttribute($node); |
141 | 141 | } |
142 | - if(null !== $node) { |
|
142 | + if (null !== $node) { |
|
143 | 143 | $tmp[] = $value->getAttribute('value'); |
144 | 144 | } |
145 | 145 | return [$tmp, $node]; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $dump = ''; |
115 | 115 | try { |
116 | 116 | $dump = $this->tpl->render($tpl, $vars); |
117 | - } catch (\Exception $e) { |
|
117 | + }catch (\Exception $e) { |
|
118 | 118 | Logger::log($e->getMessage(), LOG_ERR); |
119 | 119 | } |
120 | 120 | return $dump; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | public function regenerateTemplates() |
142 | 142 | { |
143 | 143 | $this->generateTemplatesCache(); |
144 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true); |
|
144 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true); |
|
145 | 145 | $translations = []; |
146 | 146 | if (is_array($domains)) { |
147 | 147 | $translations = $this->parsePathTranslations($domains); |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | // force compilation |
164 | 164 | if ($file->isFile()) { |
165 | 165 | try { |
166 | - $this->tpl->load(str_replace($tplDir . '/', '', $file)); |
|
167 | - } catch (\Exception $e) { |
|
166 | + $this->tpl->load(str_replace($tplDir.'/', '', $file)); |
|
167 | + }catch (\Exception $e) { |
|
168 | 168 | Logger::log($e->getMessage(), LOG_ERR, ['file' => $e->getFile(), 'line' => $e->getLine()]); |
169 | 169 | } |
170 | 170 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | 'getFlash' => TemplateFunctions::GET_FLASH_FUNCTION, |
226 | 226 | 'getQuery' => TemplateFunctions::GET_QUERY_FUNCTION, |
227 | 227 | ]; |
228 | - foreach($functions as $name => $function) { |
|
228 | + foreach ($functions as $name => $function) { |
|
229 | 229 | $this->addTemplateFunction($name, $function); |
230 | 230 | } |
231 | 231 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | private function loadDomains() |
246 | 246 | { |
247 | - $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, true); |
|
247 | + $domains = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json', Cache::JSON, true); |
|
248 | 248 | if (null !== $domains) { |
249 | 249 | foreach ($domains as $domain => $paths) { |
250 | 250 | $this->addPath($paths['template'], preg_replace('/(@|\/)/', '', $domain)); |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | { |
260 | 260 | $loader = new \Twig_Loader_Filesystem(GeneratorHelper::getTemplatePath()); |
261 | 261 | $this->tpl = new \Twig_Environment($loader, array( |
262 | - 'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig', |
|
262 | + 'cache' => CACHE_DIR.DIRECTORY_SEPARATOR.'twig', |
|
263 | 263 | 'debug' => (bool)$this->debug, |
264 | 264 | 'auto_reload' => Config::getParam('twig.autoreload', TRUE), |
265 | 265 | )); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | { |
32 | 32 | $routes = []; |
33 | 33 | foreach ($systemRoutes as $params) { |
34 | - if(isset($params['http']) && 'GET' === $params['http'] && preg_match('/^\/admin(\/|$)/', $params['default'])) { |
|
34 | + if (isset($params['http']) && 'GET' === $params['http'] && preg_match('/^\/admin(\/|$)/', $params['default'])) { |
|
35 | 35 | $module = strtoupper($params['module']); |
36 | 36 | $mode = $params['visible'] ? 'visible' : 'hidden'; |
37 | 37 | $routes[$module][$mode][] = [ |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | ]; |
42 | 42 | } |
43 | 43 | } |
44 | - foreach($routes as $module => &$route) { |
|
45 | - if(array_key_exists('visible', $route)) { |
|
44 | + foreach ($routes as $module => &$route) { |
|
45 | + if (array_key_exists('visible', $route)) { |
|
46 | 46 | uasort($route['visible'], '\PSFS\base\types\helpers\AdminHelper::sortByLabel'); |
47 | 47 | } |
48 | - if(array_key_exists('hidden', $route)) { |
|
48 | + if (array_key_exists('hidden', $route)) { |
|
49 | 49 | uasort($route['hidden'], '\PSFS\base\types\helpers\AdminHelper::sortByLabel'); |
50 | 50 | } |
51 | 51 | } |