@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | { |
33 | 33 | $this->con = Propel::getConnection($tableMap::DATABASE_NAME); |
34 | 34 | $this->con->beginTransaction(); |
35 | - if(method_exists($this->con, 'useDebug')) { |
|
35 | + if (method_exists($this->con, 'useDebug')) { |
|
36 | 36 | Logger::log('Enabling debug queries mode', LOG_INFO); |
37 | 37 | $this->con->useDebug(Config::getParam('debug')); |
38 | 38 | } |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | */ |
46 | 46 | protected function closeTransaction($status) |
47 | 47 | { |
48 | - if(null !== $this->con) { |
|
48 | + if (null !== $this->con) { |
|
49 | 49 | $this->traceDebugQuery(); |
50 | 50 | if (null !== $this->con && $this->con->inTransaction()) { |
51 | 51 | if ($status === 200) { |
52 | 52 | $this->con->commit(); |
53 | - } else { |
|
53 | + }else { |
|
54 | 54 | $this->con->rollBack(); |
55 | 55 | } |
56 | 56 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | protected function traceDebugQuery() |
65 | 65 | { |
66 | 66 | if (Config::getParam('debug')) { |
67 | - Logger::log($this->con->getLastExecutedQuery()?: 'Empty Query', LOG_DEBUG); |
|
67 | + Logger::log($this->con->getLastExecutedQuery() ?: 'Empty Query', LOG_DEBUG); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | * Checks if the connection has a transaction initialized |
73 | 73 | */ |
74 | 74 | protected function checkTransaction() { |
75 | - if(null !== $this->con && !$this->con->inTransaction()) { |
|
75 | + if (null !== $this->con && !$this->con->inTransaction()) { |
|
76 | 76 | $this->con->beginTransaction(); |
77 | 77 | } |
78 | - if(null !== $this->con && $this->con->inTransaction()) { |
|
78 | + if (null !== $this->con && $this->con->inTransaction()) { |
|
79 | 79 | $this->items++; |
80 | 80 | } |
81 | - if($this->items >= Config::getParam('api.block.limit', 1000)) { |
|
81 | + if ($this->items >= Config::getParam('api.block.limit', 1000)) { |
|
82 | 82 | $this->con->commit(); |
83 | 83 | $this->items = 0; |
84 | 84 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | } |
16 | 16 | |
17 | 17 | public static function parseRawData($type, array $params = []) { |
18 | - switch($type) { |
|
18 | + switch ($type) { |
|
19 | 19 | default: |
20 | 20 | case self::TYPE_HTTP: |
21 | 21 | $parsedParams = http_build_query($params); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public static function header($name, $default = null) |
147 | 147 | { |
148 | - return self::getInstance()->getHeader($name, $default); |
|
148 | + return self::getInstance()->getHeader($name, $default); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -158,10 +158,10 @@ discard block |
||
158 | 158 | $header = null; |
159 | 159 | if ($this->hasHeader($name)) { |
160 | 160 | $header = $this->header[$name]; |
161 | - } else if(array_key_exists('h_' . strtolower($name), $this->query)) { |
|
162 | - $header = $this->query['h_' . strtolower($name)]; |
|
163 | - } else if(array_key_exists('HTTP_' . strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
164 | - $header = $this->server['HTTP_' . strtoupper(str_replace('-', '_', $name))]; |
|
161 | + }else if (array_key_exists('h_'.strtolower($name), $this->query)) { |
|
162 | + $header = $this->query['h_'.strtolower($name)]; |
|
163 | + }else if (array_key_exists('HTTP_'.strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
164 | + $header = $this->server['HTTP_'.strtoupper(str_replace('-', '_', $name))]; |
|
165 | 165 | } |
166 | 166 | return $header ?: $default; |
167 | 167 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $url = $this->getServer('HTTP_ORIGIN'); |
261 | 261 | } |
262 | 262 | ob_start(); |
263 | - header('Location: ' . $url); |
|
263 | + header('Location: '.$url); |
|
264 | 264 | ob_end_clean(); |
265 | 265 | Security::getInstance()->updateSession(); |
266 | 266 | exit(t('Redireccionando...')); |
@@ -305,10 +305,10 @@ discard block |
||
305 | 305 | $url = $this->getServerName(); |
306 | 306 | $protocol = $hasProtocol ? $this->getProtocol() : ''; |
307 | 307 | if (!empty($protocol)) { |
308 | - $url = $protocol . $url; |
|
308 | + $url = $protocol.$url; |
|
309 | 309 | } |
310 | 310 | if (!in_array($this->getServer('SERVER_PORT'), [80, 443], true)) { |
311 | - $url .= ':' . $this->getServer('SERVER_PORT'); |
|
311 | + $url .= ':'.$this->getServer('SERVER_PORT'); |
|
312 | 312 | } |
313 | 313 | return $url; |
314 | 314 | } |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | |
40 | 40 | $filePath = ''; |
41 | 41 | if (!file_exists($filePath)) { |
42 | - $filePath = BASE_DIR . $string; |
|
42 | + $filePath = BASE_DIR.$string; |
|
43 | 43 | } |
44 | 44 | $filenamePath = AssetsParser::findDomainPath($string, $filePath); |
45 | 45 | |
46 | 46 | $filePath = self::processAsset($string, $name, $return, $filenamePath); |
47 | 47 | $basePath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl()); |
48 | - $returnPath = empty($name) ? $basePath . '/' . $filePath : $name; |
|
48 | + $returnPath = empty($name) ? $basePath.'/'.$filePath : $name; |
|
49 | 49 | return $return ? $returnPath : ''; |
50 | 50 | } |
51 | 51 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $router = Router::getInstance(); |
63 | 63 | try { |
64 | 64 | return $router->getRoute($path, $absolute, $params); |
65 | - } catch (\Exception $e) { |
|
65 | + }catch (\Exception $e) { |
|
66 | 66 | return $router->getRoute('', $absolute, $params); |
67 | 67 | } |
68 | 68 | } |
@@ -205,9 +205,9 @@ discard block |
||
205 | 205 | { |
206 | 206 | $data = file_get_contents($filenamePath); |
207 | 207 | if (!empty($name)) { |
208 | - file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data); |
|
208 | + file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data); |
|
209 | 209 | }else { |
210 | - file_put_contents($base . $filePath, $data); |
|
210 | + file_put_contents($base.$filePath, $data); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
@@ -226,9 +226,9 @@ discard block |
||
226 | 226 | if (file_exists($filenamePath)) { |
227 | 227 | list($base, $htmlBase, $filePath) = AssetsParser::calculateAssetPath($string, $name, $return, $filenamePath); |
228 | 228 | //Creamos el directorio si no existe |
229 | - GeneratorHelper::createDir($base . $htmlBase); |
|
229 | + GeneratorHelper::createDir($base.$htmlBase); |
|
230 | 230 | //Si se ha modificado |
231 | - if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($filenamePath)) { |
|
231 | + if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($filenamePath)) { |
|
232 | 232 | if ($htmlBase === 'css') { |
233 | 233 | self::processCssLines($filenamePath); |
234 | 234 | } |
@@ -206,7 +206,7 @@ |
||
206 | 206 | $data = file_get_contents($filenamePath); |
207 | 207 | if (!empty($name)) { |
208 | 208 | file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data); |
209 | - }else { |
|
209 | + } else { |
|
210 | 210 | file_put_contents($base . $filePath, $data); |
211 | 211 | } |
212 | 212 | } |
@@ -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 | ]; |
@@ -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 | } |