@@ -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 |
@@ -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 | ); |
@@ -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] : ''; |
@@ -360,7 +360,7 @@ |
||
| 360 | 360 | * Translator from php types to swagger types |
| 361 | 361 | * @param string $format |
| 362 | 362 | * |
| 363 | - * @return array |
|
| 363 | + * @return string[] |
|
| 364 | 364 | */ |
| 365 | 365 | public static function translateSwaggerFormats($format) |
| 366 | 366 | { |
@@ -39,10 +39,10 @@ discard block |
||
| 39 | 39 | if (!preg_match('/^ROOT/i', $module)) { |
| 40 | 40 | $modules[] = [ |
| 41 | 41 | 'name' => $module, |
| 42 | - 'path' => realpath($info['template'] . DIRECTORY_SEPARATOR . '..'), |
|
| 42 | + 'path' => realpath($info['template'].DIRECTORY_SEPARATOR.'..'), |
|
| 43 | 43 | ]; |
| 44 | 44 | } |
| 45 | - } catch (\Exception $e) { |
|
| 45 | + }catch (\Exception $e) { |
|
| 46 | 46 | $modules[] = $e->getMessage(); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function extractApiEndpoints(array $module) |
| 62 | 62 | { |
| 63 | - $module_path = $module['path'] . DIRECTORY_SEPARATOR . 'Api'; |
|
| 63 | + $module_path = $module['path'].DIRECTORY_SEPARATOR.'Api'; |
|
| 64 | 64 | $module_name = $module['name']; |
| 65 | 65 | $endpoints = []; |
| 66 | 66 | if (file_exists($module_path)) { |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | if (count($finder)) { |
| 70 | 70 | /** @var \SplFileInfo $file */ |
| 71 | 71 | foreach ($finder as $file) { |
| 72 | - $namespace = "\\{$module_name}\\Api\\" . str_replace('.php', '', $file->getFilename()); |
|
| 72 | + $namespace = "\\{$module_name}\\Api\\".str_replace('.php', '', $file->getFilename()); |
|
| 73 | 73 | $info = $this->extractApiInfo($namespace, $module_name); |
| 74 | 74 | if (!empty($info)) { |
| 75 | 75 | $endpoints[$namespace] = $info; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | if (NULL !== $mInfo) { |
| 99 | 99 | $info[] = $mInfo; |
| 100 | 100 | } |
| 101 | - } catch (\Exception $e) { |
|
| 101 | + }catch (\Exception $e) { |
|
| 102 | 102 | Logger::getInstance()->errorLog($e->getMessage()); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) { |
| 310 | 310 | $payload = $this->extractDtoProperties($namespace); |
| 311 | 311 | } |
| 312 | - } catch (\Exception $e) { |
|
| 312 | + }catch (\Exception $e) { |
|
| 313 | 313 | Logger::getInstance()->errorLog($e->getMessage()); |
| 314 | 314 | } |
| 315 | 315 | |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | if (in_array($methodInfo['method'], ['POST', 'PUT'])) { |
| 347 | 347 | $methodInfo['payload'] = $this->extractPayload($modelNamespace, $docComments); |
| 348 | 348 | } |
| 349 | - } catch (\Exception $e) { |
|
| 349 | + }catch (\Exception $e) { |
|
| 350 | 350 | jpre($e->getMessage()); |
| 351 | 351 | Logger::getInstance()->errorLog($e->getMessage()); |
| 352 | 352 | } |
@@ -425,13 +425,13 @@ discard block |
||
| 425 | 425 | ]]); |
| 426 | 426 | if (array_key_exists($subDtoName, $subDto)) { |
| 427 | 427 | $definitions = $subDto; |
| 428 | - } else { |
|
| 428 | + }else { |
|
| 429 | 429 | $definitions[$subDtoName] = $subDto; |
| 430 | 430 | } |
| 431 | 431 | $dto['properties'][$field] = [ |
| 432 | - '$ref' => "#/definitions/" . $subDtoName, |
|
| 432 | + '$ref' => "#/definitions/".$subDtoName, |
|
| 433 | 433 | ]; |
| 434 | - } else { |
|
| 434 | + }else { |
|
| 435 | 435 | list($type, $format) = self::translateSwaggerFormats($format); |
| 436 | 436 | $dto['properties'][$field] = [ |
| 437 | 437 | "type" => $type, |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | protected function extractDtoName($dto, $isArray = false) |
| 490 | 490 | { |
| 491 | 491 | $dto = explode('\\', $dto); |
| 492 | - $modelDto = array_pop($dto) . "Dto"; |
|
| 492 | + $modelDto = array_pop($dto)."Dto"; |
|
| 493 | 493 | if ($isArray) { |
| 494 | 494 | $modelDto .= "List"; |
| 495 | 495 | } |
@@ -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 | } |
@@ -78,7 +78,7 @@ |
||
| 78 | 78 | "class" => "btn-success col-md-offset-2" |
| 79 | 79 | )) |
| 80 | 80 | ->addButton('add_field', _('Añadir nuevo parámetro'), 'button', array( |
| 81 | - "onclick" => "javascript:addNewField(document.getElementById('" . $this->getName() . "'));", |
|
| 81 | + "onclick" => "javascript:addNewField(document.getElementById('".$this->getName()."'));", |
|
| 82 | 82 | "class" => "btn-warning", |
| 83 | 83 | )); |
| 84 | 84 | } |
@@ -36,8 +36,8 @@ |
||
| 36 | 36 | $dto[$property->getName()] = $property->getValue($this); |
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | - } catch (\Exception $e) { |
|
| 40 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 39 | + }catch (\Exception $e) { |
|
| 40 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 41 | 41 | } |
| 42 | 42 | return $dto; |
| 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 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | $vars['__menu__'] = $this->getMenu(); |
| 38 | 38 | $domain = (null === $domain) ? $this->getDomain() : $domain; |
| 39 | - return $this->tpl->render($domain . $template, $vars, $cookies); |
|
| 39 | + return $this->tpl->render($domain.$template, $vars, $cookies); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | $vars['__menu__'] = $this->getMenu(); |
| 69 | 69 | $domain = $domain ?: $this->getDomain(); |
| 70 | - return $this->tpl->dump($domain . $template, $vars); |
|
| 70 | + return $this->tpl->dump($domain.$template, $vars); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -96,15 +96,15 @@ discard block |
||
| 96 | 96 | ///////////////////////////////////////////////////////////// |
| 97 | 97 | // Date in the past sets the value to already have been expired. |
| 98 | 98 | header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); |
| 99 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
| 99 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
| 100 | 100 | header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
| 101 | 101 | header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
| 102 | 102 | header("Pragma: no-cache"); |
| 103 | 103 | header("Expires: 0"); |
| 104 | 104 | header('Content-Transfer-Encoding: none'); |
| 105 | - header("Content-type: " . $content); |
|
| 106 | - header("Content-length: " . strlen($data)); |
|
| 107 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
| 105 | + header("Content-type: ".$content); |
|
| 106 | + header("Content-length: ".strlen($data)); |
|
| 107 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
| 108 | 108 | echo $data; |
| 109 | 109 | ob_flush(); |
| 110 | 110 | ob_end_clean(); |
@@ -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']; |