@@ -8,7 +8,13 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | interface ControllerInterface |
| 10 | 10 | { |
| 11 | + /** |
|
| 12 | + * @return string|null |
|
| 13 | + */ |
|
| 11 | 14 | public function render($template, array $vars = [], $cookies = []); |
| 12 | 15 | |
| 16 | + /** |
|
| 17 | + * @return void |
|
| 18 | + */ |
|
| 13 | 19 | public function response($response, $type = 'text/html'); |
| 14 | 20 | } |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | use PSFS\base\config\Config; |
| 5 | 5 | use PSFS\base\Security; |
| 6 | 6 | use PSFS\base\Service; |
| 7 | -use PSFS\controller\Admin; |
|
| 8 | 7 | use Symfony\Component\Finder\Finder; |
| 9 | 8 | |
| 10 | 9 | class AdminServices extends Service |
@@ -61,11 +61,13 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | private function parseAdmins(&$admins) |
| 63 | 63 | { |
| 64 | - if (!empty($admins)) foreach ($admins as &$admin) { |
|
| 64 | + if (!empty($admins)) { |
|
| 65 | + foreach ($admins as &$admin) { |
|
| 65 | 66 | if (isset($admin["profile"])) { |
| 66 | 67 | switch ($admin["profile"]) { |
| 67 | 68 | case Security::MANAGER_ID_TOKEN: |
| 68 | 69 | $admin['class'] = 'warning'; |
| 70 | + } |
|
| 69 | 71 | break; |
| 70 | 72 | case Security::ADMIN_ID_TOKEN: |
| 71 | 73 | $admin['class'] = 'info'; |
@@ -95,7 +97,9 @@ discard block |
||
| 95 | 97 | $size = $file->getSize() / 8 / 1024; |
| 96 | 98 | $time = date("c", $file->getMTime()); |
| 97 | 99 | $dateTime = new \DateTime($time); |
| 98 | - if (!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array(); |
|
| 100 | + if (!isset($logs[$dateTime->format("Y")])) { |
|
| 101 | + $logs[$dateTime->format("Y")] = array(); |
|
| 102 | + } |
|
| 99 | 103 | $logs[$dateTime->format("Y")][$dateTime->format("m")][$time] = array( |
| 100 | 104 | "filename" => $file->getFilename(), |
| 101 | 105 | "size" => round($size, 3) |
@@ -136,7 +140,9 @@ discard block |
||
| 136 | 140 | $detailLog[] = array_merge(array( |
| 137 | 141 | "log" => $line, |
| 138 | 142 | ), $detail); |
| 139 | - if (count($detailLog) >= 1000) break; |
|
| 143 | + if (count($detailLog) >= 1000) { |
|
| 144 | + break; |
|
| 145 | + } |
|
| 140 | 146 | } |
| 141 | 147 | $log = $detailLog; |
| 142 | 148 | } |
@@ -160,7 +166,9 @@ discard block |
||
| 160 | 166 | |
| 161 | 167 | $detail = json_decode($match[0][0], TRUE); |
| 162 | 168 | } |
| 163 | - if (empty($detail)) $detail = array(); |
|
| 169 | + if (empty($detail)) { |
|
| 170 | + $detail = array(); |
|
| 171 | + } |
|
| 164 | 172 | preg_match_all('/\>\ (.*):/i', $line, $match); |
| 165 | 173 | |
| 166 | 174 | $type = (isset($match[1][0])) ? $match[1][0] : ''; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $platform = trim(Config::getInstance()->get("platform.name")); |
| 36 | 36 | header('HTTP/1.1 401 Unauthorized'); |
| 37 | - header('WWW-Authenticate: Basic Realm="' . $platform . '"'); |
|
| 37 | + header('WWW-Authenticate: Basic Realm="'.$platform.'"'); |
|
| 38 | 38 | echo _("Zona restringida"); |
| 39 | 39 | exit(); |
| 40 | 40 | } |
@@ -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 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $logs = array(); |
| 93 | 93 | /** @var \SplFileInfo $file */ |
| 94 | 94 | foreach ($files as $file) { |
| 95 | - $size = $file->getSize() / 8 / 1024; |
|
| 95 | + $size = $file->getSize()/8/1024; |
|
| 96 | 96 | $time = date("c", $file->getMTime()); |
| 97 | 97 | $dateTime = new \DateTime($time); |
| 98 | 98 | if (!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array(); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $time = date("c", $file->getMTime()); |
| 129 | 129 | $dateTime = new \DateTime($time); |
| 130 | 130 | $monthOpen = $dateTime->format("m"); |
| 131 | - $content = file($file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename()); |
|
| 131 | + $content = file($file->getPath().DIRECTORY_SEPARATOR.$file->getFilename()); |
|
| 132 | 132 | krsort($content); |
| 133 | 133 | $detailLog = array(); |
| 134 | 134 | foreach ($content as &$line) { |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | break; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - } catch (\Exception $e) { |
|
| 184 | + }catch (\Exception $e) { |
|
| 185 | 185 | $detail = array( |
| 186 | 186 | "type" => "danger", |
| 187 | 187 | ); |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | )) |
| 38 | 38 | ->addButton('submit', _("Acceder como {{username}}")) |
| 39 | 39 | ->addButton("cancel", _("Cancelar"), "button", array( |
| 40 | - "onclick" => "javacript:location.href = \"" . Router::getInstance()->getRoute('') . "\";", |
|
| 40 | + "onclick" => "javacript:location.href = \"".Router::getInstance()->getRoute('')."\";", |
|
| 41 | 41 | "class" => "btn-link", |
| 42 | 42 | )); |
| 43 | 43 | } |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | { |
| 63 | 63 | if (preg_match('/^asc$/i', $direction)) { |
| 64 | 64 | return Order::ASC; |
| 65 | - } else { |
|
| 65 | + }else { |
|
| 66 | 66 | return Order::DESC; |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -26,13 +26,13 @@ |
||
| 26 | 26 | { |
| 27 | 27 | $namespace = explode('\\', $this->getModelTableMap()); |
| 28 | 28 | $module = strtolower($namespace[0]); |
| 29 | - $secret = Config::getInstance()->get($module . '.api.secret'); |
|
| 29 | + $secret = Config::getInstance()->get($module.'.api.secret'); |
|
| 30 | 30 | if (NULL === $secret) { |
| 31 | 31 | $secret = Config::getInstance()->get("api.secret"); |
| 32 | 32 | } |
| 33 | 33 | if (NULL === $secret) { |
| 34 | 34 | $auth = TRUE; |
| 35 | - } else { |
|
| 35 | + }else { |
|
| 36 | 36 | $token = Request::getInstance()->getHeader('X-API-SEC-TOKEN'); |
| 37 | 37 | if (array_key_exists('API_TOKEN', $this->query)) { |
| 38 | 38 | $token = $this->query['API_TOKEN']; |
@@ -30,16 +30,16 @@ |
||
| 30 | 30 | $scripts = $this->getNode("scripts"); |
| 31 | 31 | |
| 32 | 32 | //Creamos el parser |
| 33 | - $compiler->addDebugInfo($scripts)->write('$parser = new \\PSFS\\base\\extension\\AssetsParser(\'' . $this->type . '\')') |
|
| 33 | + $compiler->addDebugInfo($scripts)->write('$parser = new \\PSFS\\base\\extension\\AssetsParser(\''.$this->type.'\')') |
|
| 34 | 34 | ->raw(";\n"); |
| 35 | 35 | |
| 36 | 36 | //Asociamos el hash |
| 37 | - $compiler->write('$parser->setHash(\'' . $this->hash . '\')') |
|
| 37 | + $compiler->write('$parser->setHash(\''.$this->hash.'\')') |
|
| 38 | 38 | ->raw(";\n"); |
| 39 | 39 | |
| 40 | 40 | //Asociamos los ficheros |
| 41 | 41 | foreach ($scripts->getAttribute("value") as $value) { |
| 42 | - $compiler->write('$parser->addFile(\'' . $value . '\')')->raw(";\n"); |
|
| 42 | + $compiler->write('$parser->addFile(\''.$value.'\')')->raw(";\n"); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | //Procesamos los ficheros |
@@ -139,7 +139,7 @@ |
||
| 139 | 139 | $tmp = array(); |
| 140 | 140 | if (NULL === $node) { |
| 141 | 141 | $node = $value; |
| 142 | - } else { |
|
| 142 | + }else { |
|
| 143 | 143 | $tmp = $this->getTmpAttribute($node); |
| 144 | 144 | } |
| 145 | 145 | $tmp[] = $value->getAttribute("value"); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | /** |
| 117 | 117 | * Add request param |
| 118 | 118 | * |
| 119 | - * @param $key |
|
| 119 | + * @param integer $key |
|
| 120 | 120 | * @param null $value |
| 121 | 121 | * |
| 122 | 122 | * @return \PSFS\base\Service |
@@ -153,8 +153,8 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | - * @param $header |
|
| 157 | - * @param null $content |
|
| 156 | + * @param string $header |
|
| 157 | + * @param string $content |
|
| 158 | 158 | * |
| 159 | 159 | * @return $this |
| 160 | 160 | */ |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | protected $isMultipart = false; |
| 69 | 69 | |
| 70 | 70 | private function closeConnection() { |
| 71 | - if(null !== $this->con) { |
|
| 71 | + if (null !== $this->con) { |
|
| 72 | 72 | curl_close($this->con); |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | public function setIsJson($isJson = true) { |
| 233 | 233 | $this->isJson = $isJson; |
| 234 | - if($isJson) { |
|
| 234 | + if ($isJson) { |
|
| 235 | 235 | $this->setIsMultipart(false); |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | public function setIsMultipart($isMultipart = true) { |
| 250 | 250 | $this->isMultipart = $isMultipart; |
| 251 | - if($isMultipart) { |
|
| 251 | + if ($isMultipart) { |
|
| 252 | 252 | $this->setIsJson(false); |
| 253 | 253 | } |
| 254 | 254 | } |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | $this->url = NULL; |
| 269 | 269 | $this->params = array(); |
| 270 | 270 | $this->headers = array(); |
| 271 | - Logger::log("Context service for " . get_called_class() . " cleared!"); |
|
| 271 | + Logger::log("Context service for ".get_called_class()." cleared!"); |
|
| 272 | 272 | $this->closeConnection(); |
| 273 | 273 | } |
| 274 | 274 | |
@@ -311,17 +311,17 @@ discard block |
||
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | protected function applyOptions() { |
| 314 | - if(count($this->options)) { |
|
| 314 | + if (count($this->options)) { |
|
| 315 | 315 | curl_setopt_array($this->con, $this->options); |
| 316 | 316 | } |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | protected function applyHeaders() { |
| 320 | 320 | $headers = []; |
| 321 | - foreach($this->headers as $key => $value) { |
|
| 322 | - $headers[] = $key . ': ' . $value; |
|
| 321 | + foreach ($this->headers as $key => $value) { |
|
| 322 | + $headers[] = $key.': '.$value; |
|
| 323 | 323 | } |
| 324 | - if(count($headers)) { |
|
| 324 | + if (count($headers)) { |
|
| 325 | 325 | curl_setopt($this->con, CURLOPT_HTTPHEADER, $headers); |
| 326 | 326 | } |
| 327 | 327 | } |
@@ -332,18 +332,18 @@ discard block |
||
| 332 | 332 | case 'GET': |
| 333 | 333 | default: |
| 334 | 334 | $this->addOption(CURLOPT_CUSTOMREQUEST, "GET"); |
| 335 | - if(!empty($this->params)) { |
|
| 335 | + if (!empty($this->params)) { |
|
| 336 | 336 | $sep = !preg_match('/\?/', $this->getUrl()) ? '?' : ''; |
| 337 | - $this->url = $this->url . $sep . http_build_query($this->params); |
|
| 337 | + $this->url = $this->url.$sep.http_build_query($this->params); |
|
| 338 | 338 | } |
| 339 | 339 | break; |
| 340 | 340 | case 'POST': |
| 341 | 341 | $this->addOption(CURLOPT_CUSTOMREQUEST, "POST"); |
| 342 | - if($this->getIsJson()) { |
|
| 342 | + if ($this->getIsJson()) { |
|
| 343 | 343 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
| 344 | - } elseif($this->getIsMultipart()) { |
|
| 344 | + } elseif ($this->getIsMultipart()) { |
|
| 345 | 345 | $this->addOption(CURLOPT_POSTFIELDS, $this->params); |
| 346 | - } else { |
|
| 346 | + }else { |
|
| 347 | 347 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
| 348 | 348 | } |
| 349 | 349 | break; |
@@ -353,21 +353,21 @@ discard block |
||
| 353 | 353 | case 'PUT': |
| 354 | 354 | $this->addOption(CURLOPT_CUSTOMREQUEST, "PUT"); |
| 355 | 355 | |
| 356 | - if($this->getIsJson()) { |
|
| 356 | + if ($this->getIsJson()) { |
|
| 357 | 357 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
| 358 | - } elseif($this->getIsMultipart()) { |
|
| 358 | + } elseif ($this->getIsMultipart()) { |
|
| 359 | 359 | $this->addOption(CURLOPT_POSTFIELDS, $this->params); |
| 360 | - } else { |
|
| 360 | + }else { |
|
| 361 | 361 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
| 362 | 362 | } |
| 363 | 363 | break; |
| 364 | 364 | case 'PATCH': |
| 365 | 365 | $this->addOption(CURLOPT_CUSTOMREQUEST, "PATCH"); |
| 366 | - if($this->getIsJson()) { |
|
| 366 | + if ($this->getIsJson()) { |
|
| 367 | 367 | $this->addOption(CURLOPT_POSTFIELDS, json_encode($this->params)); |
| 368 | - } elseif($this->getIsMultipart()) { |
|
| 368 | + } elseif ($this->getIsMultipart()) { |
|
| 369 | 369 | $this->addOption(CURLOPT_POSTFIELDS, $this->params); |
| 370 | - } else { |
|
| 370 | + }else { |
|
| 371 | 371 | $this->addOption(CURLOPT_POSTFIELDS, http_build_query($this->params)); |
| 372 | 372 | } |
| 373 | 373 | break; |
@@ -384,14 +384,14 @@ discard block |
||
| 384 | 384 | $this->setDefaults(); |
| 385 | 385 | $this->applyOptions(); |
| 386 | 386 | $this->applyHeaders(); |
| 387 | - if('debug' === Config::getParam('log.level')) { |
|
| 387 | + if ('debug' === Config::getParam('log.level')) { |
|
| 388 | 388 | curl_setopt($this->con, CURLOPT_VERBOSE, true); |
| 389 | 389 | $verbose = fopen('php://temp', 'w+'); |
| 390 | 390 | curl_setopt($this->con, CURLOPT_STDERR, $verbose); |
| 391 | 391 | } |
| 392 | 392 | $result = curl_exec($this->con); |
| 393 | 393 | $this->result = $this->isJson ? json_decode($result, true) : $result; |
| 394 | - if('debug' === Config::getParam('log.level')) { |
|
| 394 | + if ('debug' === Config::getParam('log.level')) { |
|
| 395 | 395 | rewind($verbose); |
| 396 | 396 | $verboseLog = stream_get_contents($verbose); |
| 397 | 397 | Logger::log($verboseLog, LOG_DEBUG, [ |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | ]); |
| 402 | 402 | $this->info['verbose'] = $verboseLog; |
| 403 | 403 | } |
| 404 | - Logger::log($this->url . ' response: ', LOG_DEBUG, $this->result); |
|
| 404 | + Logger::log($this->url.' response: ', LOG_DEBUG, $this->result); |
|
| 405 | 405 | $this->info = array_merge($this->info, curl_getinfo($this->con)); |
| 406 | 406 | } |
| 407 | 407 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | { |
| 32 | 32 | $routes = []; |
| 33 | 33 | foreach ($systemRoutes as $route => $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 | } |