@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | public function init() |
75 | 75 | { |
76 | 76 | parent::init(); |
77 | - Logger::log(get_called_class() . ' init', LOG_DEBUG); |
|
77 | + Logger::log(get_called_class().' init', LOG_DEBUG); |
|
78 | 78 | $this->domain = $this->getDomain(); |
79 | 79 | $this->hydrateRequestData(); |
80 | 80 | $this->hydrateOrders(); |
81 | - if($this instanceof CustomApi === false) { |
|
81 | + if ($this instanceof CustomApi === false) { |
|
82 | 82 | $this->createConnection($this->getTableMap()); |
83 | 83 | } |
84 | 84 | $this->setLoaded(true); |
85 | - Logger::log(get_called_class() . ' loaded', LOG_DEBUG); |
|
85 | + Logger::log(get_called_class().' loaded', LOG_DEBUG); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | protected function hydrateOrders() |
92 | 92 | { |
93 | 93 | if (count($this->query)) { |
94 | - Logger::log(get_called_class() . ' gathering query string', LOG_DEBUG); |
|
94 | + Logger::log(get_called_class().' gathering query string', LOG_DEBUG); |
|
95 | 95 | foreach ($this->query as $key => $value) { |
96 | 96 | if ($key === self::API_ORDER_FIELD && is_array($value)) { |
97 | 97 | foreach ($value as $field => $direction) { |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | */ |
109 | 109 | protected function extractPagination() |
110 | 110 | { |
111 | - Logger::log(get_called_class() . ' extract pagination start', LOG_DEBUG); |
|
111 | + Logger::log(get_called_class().' extract pagination start', LOG_DEBUG); |
|
112 | 112 | $page = (array_key_exists(self::API_PAGE_FIELD, $this->query)) ? $this->query[self::API_PAGE_FIELD] : 1; |
113 | 113 | $limit = (array_key_exists(self::API_LIMIT_FIELD, $this->query)) ? $this->query[self::API_LIMIT_FIELD] : 100; |
114 | - Logger::log(get_called_class() . ' extract pagination end', LOG_DEBUG); |
|
114 | + Logger::log(get_called_class().' extract pagination end', LOG_DEBUG); |
|
115 | 115 | return array($page, $limit); |
116 | 116 | } |
117 | 117 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | private function addOrders(ModelCriteria &$query) |
124 | 124 | { |
125 | - Logger::log(get_called_class() . ' extract orders start ', LOG_DEBUG); |
|
125 | + Logger::log(get_called_class().' extract orders start ', LOG_DEBUG); |
|
126 | 126 | $orderAdded = FALSE; |
127 | 127 | $tableMap = $this->getTableMap(); |
128 | 128 | foreach ($this->order->getOrders() as $field => $direction) { |
@@ -130,17 +130,17 @@ discard block |
||
130 | 130 | $orderAdded = TRUE; |
131 | 131 | if ($direction === Order::ASC) { |
132 | 132 | $query->addAscendingOrderByColumn($column->getPhpName()); |
133 | - } else { |
|
133 | + }else { |
|
134 | 134 | $query->addDescendingOrderByColumn($column->getPhpName()); |
135 | 135 | } |
136 | 136 | } |
137 | 137 | } |
138 | 138 | if (!$orderAdded) { |
139 | - foreach($this->getPkDbName() as $pk => $phpName) { |
|
139 | + foreach ($this->getPkDbName() as $pk => $phpName) { |
|
140 | 140 | $query->addAscendingOrderByColumn($pk); |
141 | 141 | } |
142 | 142 | } |
143 | - Logger::log(get_called_class() . ' extract orders end', LOG_DEBUG); |
|
143 | + Logger::log(get_called_class().' extract orders end', LOG_DEBUG); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | foreach ($this->query as $field => $value) { |
156 | 156 | if (self::API_COMBO_FIELD === $field) { |
157 | 157 | ApiHelper::composerComboField($tableMap, $query, $this->extraColumns, $value); |
158 | - } elseif(!preg_match('/^__/', $field)) { |
|
158 | + } elseif (!preg_match('/^__/', $field)) { |
|
159 | 159 | ApiHelper::addModelField($tableMap, $query, $field, $value); |
160 | 160 | } |
161 | 161 | } |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | list($page, $limit) = $this->extractPagination(); |
177 | 177 | if ($limit == -1) { |
178 | 178 | $this->list = $query->find($this->con); |
179 | - } else { |
|
179 | + }else { |
|
180 | 180 | $this->list = $query->paginate($page, $limit, $this->con); |
181 | 181 | } |
182 | - } catch (\Exception $e) { |
|
182 | + }catch (\Exception $e) { |
|
183 | 183 | Logger::log($e->getMessage(), LOG_ERR); |
184 | 184 | } |
185 | 185 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $code = 200; |
199 | 199 | list($return, $total, $pages) = $this->getList(); |
200 | 200 | $message = null; |
201 | - if(!$total) { |
|
201 | + if (!$total) { |
|
202 | 202 | $message = i18n::_('No se han encontrado elementos para la búsqueda'); |
203 | 203 | } |
204 | 204 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $pages = 1; |
225 | 225 | $message = null; |
226 | 226 | list($code, $return) = $this->getSingleResult($pk); |
227 | - if($code !== 200) { |
|
227 | + if ($code !== 200) { |
|
228 | 228 | $message = i18n::_('No se ha encontrado el elemento solicitado'); |
229 | 229 | } |
230 | 230 | |
@@ -253,13 +253,13 @@ discard block |
||
253 | 253 | $status = 200; |
254 | 254 | $saved = TRUE; |
255 | 255 | $model = $this->model->toArray(); |
256 | - } else { |
|
256 | + }else { |
|
257 | 257 | $message = i18n::_('No se ha podido guardar el modelo seleccionado'); |
258 | 258 | } |
259 | - } catch (\Exception $e) { |
|
260 | - $message = i18n::_('Ha ocurrido un error intentando guardar el elemento: ') .'<br>'. $e->getMessage(); |
|
259 | + }catch (\Exception $e) { |
|
260 | + $message = i18n::_('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage(); |
|
261 | 261 | $context = []; |
262 | - if(null !== $e->getPrevious()) { |
|
262 | + if (null !== $e->getPrevious()) { |
|
263 | 263 | $context[] = $e->getPrevious()->getMessage(); |
264 | 264 | } |
265 | 265 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
@@ -295,18 +295,18 @@ discard block |
||
295 | 295 | $updated = TRUE; |
296 | 296 | $status = 200; |
297 | 297 | $model = $this->model->toArray(); |
298 | - } else { |
|
298 | + }else { |
|
299 | 299 | $message = i18n::_('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
300 | 300 | } |
301 | - } catch (\Exception $e) { |
|
301 | + }catch (\Exception $e) { |
|
302 | 302 | $message = i18n::_('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
303 | 303 | $context = []; |
304 | - if(null !== $e->getPrevious()) { |
|
304 | + if (null !== $e->getPrevious()) { |
|
305 | 305 | $context[] = $e->getPrevious()->getMessage(); |
306 | 306 | } |
307 | 307 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
308 | 308 | } |
309 | - } else { |
|
309 | + }else { |
|
310 | 310 | $message = i18n::_('No se ha encontrado el modelo al que se hace referencia para actualizar'); |
311 | 311 | } |
312 | 312 | |
@@ -334,15 +334,15 @@ discard block |
||
334 | 334 | $this->con->beginTransaction(); |
335 | 335 | $this->hydrateModel($pk); |
336 | 336 | if (NULL !== $this->model) { |
337 | - if(method_exists('clearAllReferences', $this->model)) { |
|
337 | + if (method_exists('clearAllReferences', $this->model)) { |
|
338 | 338 | $this->model->clearAllReferences(true); |
339 | 339 | } |
340 | 340 | $this->model->delete($this->con); |
341 | 341 | $deleted = TRUE; |
342 | 342 | } |
343 | - } catch (\Exception $e) { |
|
343 | + }catch (\Exception $e) { |
|
344 | 344 | $context = []; |
345 | - if(null !== $e->getPrevious()) { |
|
345 | + if (null !== $e->getPrevious()) { |
|
346 | 346 | $context[] = $e->getPrevious()->getMessage(); |
347 | 347 | } |
348 | 348 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | $this->saveBulk(); |
373 | 373 | $saved = true; |
374 | 374 | $status = 200; |
375 | - } catch(\Exception $e) { |
|
375 | + }catch (\Exception $e) { |
|
376 | 376 | Logger::log($e->getMessage(), LOG_CRIT, $this->getRequest()->getData()); |
377 | 377 | $message = i18n::_('Bulk insert rolled back'); |
378 | 378 | } |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | |
395 | 395 | /** @var CustomerTableMap $tableMap */ |
396 | 396 | $modelPk = ApiHelper::extractPrimaryKeyColumnName($this->getTableMap()); |
397 | - foreach($this->list->getData() as $data) { |
|
397 | + foreach ($this->list->getData() as $data) { |
|
398 | 398 | $return[] = ApiHelper::mapArrayObject($this->getModelNamespace(), $modelPk, $this->query, $data); |
399 | 399 | } |
400 | 400 | return $return; |
@@ -411,20 +411,20 @@ discard block |
||
411 | 411 | try { |
412 | 412 | $this->paginate(); |
413 | 413 | if (null !== $this->list) { |
414 | - if(array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) { |
|
414 | + if (array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) { |
|
415 | 415 | $return = $this->extractDataWithFormat(); |
416 | - } else { |
|
416 | + }else { |
|
417 | 417 | $return = $this->list->toArray(null, false, TableMap::TYPE_PHPNAME, false); |
418 | 418 | } |
419 | 419 | $total = 0; |
420 | 420 | $pages = 0; |
421 | - if($this->list instanceof PropelModelPager) { |
|
421 | + if ($this->list instanceof PropelModelPager) { |
|
422 | 422 | $total = $this->list->getNbResults(); |
423 | 423 | $pages = $this->list->getLastPage(); |
424 | 424 | } |
425 | 425 | } |
426 | - } catch (\Exception $e) { |
|
427 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
426 | + }catch (\Exception $e) { |
|
427 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | return array($return, $total, $pages); |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | $return = array(); |
443 | 443 | if (NULL === $model || !method_exists($model, 'toArray')) { |
444 | 444 | $code = 404; |
445 | - } else { |
|
445 | + }else { |
|
446 | 446 | $return = $model->toArray(TableMap::TYPE_PHPNAME, true, [], true); |
447 | 447 | } |
448 | 448 |
@@ -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 | unset($cssMinifier); |
149 | 149 | ini_restore('memory_limit'); |
150 | 150 | ini_restore('max_execution_time'); |
@@ -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 | } |