@@ -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']; |
@@ -39,8 +39,8 @@ |
||
| 39 | 39 | "domain" => $this->getDomain(), |
| 40 | 40 | "listLabel" => Api::API_LIST_NAME_FIELD, |
| 41 | 41 | 'modelId' => Api::API_MODEL_KEY_FIELD, |
| 42 | - 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $this->getDomain() . '-' . $this->getApi()), TRUE)), |
|
| 43 | - "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain() . '-' . 'api-' . $this->getApi() . "-pk"), TRUE)), |
|
| 42 | + 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-'.$this->getDomain().'-'.$this->getApi()), TRUE)), |
|
| 43 | + "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain().'-'.'api-'.$this->getApi()."-pk"), TRUE)), |
|
| 44 | 44 | ), [], ''); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -41,11 +41,11 @@ discard block |
||
| 41 | 41 | public function render($template, array $vars = array(), $cookies = array(), $domain = null) |
| 42 | 42 | { |
| 43 | 43 | $vars['__menu__'] = $this->getMenu(); |
| 44 | - if(Config::getParam('profiling.enable')) { |
|
| 44 | + if (Config::getParam('profiling.enable')) { |
|
| 45 | 45 | $vars['__profiling__'] = Inspector::getStats(); |
| 46 | 46 | } |
| 47 | 47 | $domain = (null === $domain) ? $this->getDomain() : $domain; |
| 48 | - return $this->tpl->render($domain . $template, $vars, $cookies); |
|
| 48 | + return $this->tpl->render($domain.$template, $vars, $cookies); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $vars['__menu__'] = $this->getMenu(); |
| 78 | 78 | $domain = $domain ?: $this->getDomain(); |
| 79 | - return $this->tpl->dump($domain . $template, $vars); |
|
| 79 | + return $this->tpl->dump($domain.$template, $vars); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | $this->success = $result; |
| 44 | 44 | $this->total = $total ?: (is_array($data) ? count($data) : 0); |
| 45 | 45 | $this->pages = $pages; |
| 46 | - if(null !== $message) { |
|
| 46 | + if (null !== $message) { |
|
| 47 | 47 | $this->message = $message; |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | */ |
| 41 | 41 | public static function dropInstance() { |
| 42 | 42 | $class = static::class; |
| 43 | - if(isset(self::$instance[$class])) { |
|
| 43 | + if (isset(self::$instance[$class])) { |
|
| 44 | 44 | self::$instance[$class] = null; |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | public function init() |
| 14 | 14 | { |
| 15 | - if(!Security::getInstance()->isLogged()) { |
|
| 15 | + if (!Security::getInstance()->isLogged()) { |
|
| 16 | 16 | throw new ApiException(t('Resource not authorized'), 401); |
| 17 | 17 | } |
| 18 | 18 | parent::init(); |
@@ -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 | } |
@@ -73,18 +73,18 @@ |
||
| 73 | 73 | if (!Request::getInstance()->isFile()) { |
| 74 | 74 | return $this->router->execute($uri ?: $this->actualUri); |
| 75 | 75 | } |
| 76 | - } else { |
|
| 76 | + }else { |
|
| 77 | 77 | return ConfigController::getInstance()->config(); |
| 78 | 78 | } |
| 79 | - } catch (AdminCredentialsException $a) { |
|
| 79 | + }catch (AdminCredentialsException $a) { |
|
| 80 | 80 | return UserController::showAdminManager(); |
| 81 | - } catch (SecurityException $s) { |
|
| 81 | + }catch (SecurityException $s) { |
|
| 82 | 82 | return $this->security->notAuthorized($this->actualUri); |
| 83 | - } catch (RouterException $r) { |
|
| 83 | + }catch (RouterException $r) { |
|
| 84 | 84 | return $this->router->httpNotFound($r); |
| 85 | - } catch(ApiException $a) { |
|
| 85 | + }catch (ApiException $a) { |
|
| 86 | 86 | return $this->router->httpNotFound($a, true); |
| 87 | - } catch (\Exception $e) { |
|
| 87 | + }catch (\Exception $e) { |
|
| 88 | 88 | return $this->dumpException($e); |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $this->setStatusCode(Template::STATUS_OK); |
| 122 | 122 | break; |
| 123 | 123 | default: |
| 124 | - $this->setStatusCode('HTTP/1.0 ' .($status ?: 200)); |
|
| 124 | + $this->setStatusCode('HTTP/1.0 '.($status ?: 200)); |
|
| 125 | 125 | break; |
| 126 | 126 | } |
| 127 | 127 | return $this; |
@@ -135,11 +135,11 @@ discard block |
||
| 135 | 135 | private function setReponseHeaders($contentType = 'text/html', array $cookies = array()) |
| 136 | 136 | { |
| 137 | 137 | $powered = Config::getParam('poweredBy', 'PSFS'); |
| 138 | - header('X-Powered-By: ' . $powered); |
|
| 138 | + header('X-Powered-By: '.$powered); |
|
| 139 | 139 | ResponseHelper::setStatusHeader($this->getStatusCode()); |
| 140 | 140 | ResponseHelper::setAuthHeaders($this->isPublicZone()); |
| 141 | 141 | ResponseHelper::setCookieHeaders($cookies); |
| 142 | - header('Content-type: ' . $contentType); |
|
| 142 | + header('Content-type: '.$contentType); |
|
| 143 | 143 | |
| 144 | 144 | } |
| 145 | 145 | |
@@ -152,20 +152,20 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function output($output = '', $contentType = 'text/html', array $cookies = array()) |
| 154 | 154 | { |
| 155 | - if(!self::isTest()) { |
|
| 155 | + if (!self::isTest()) { |
|
| 156 | 156 | Logger::log('Start output response'); |
| 157 | 157 | ob_start(); |
| 158 | 158 | $this->setReponseHeaders($contentType, $cookies); |
| 159 | - header('Content-length: ' . strlen($output)); |
|
| 160 | - header('CRC: ' . crc32($output)); |
|
| 159 | + header('Content-length: '.strlen($output)); |
|
| 160 | + header('CRC: '.crc32($output)); |
|
| 161 | 161 | |
| 162 | 162 | $needCache = Cache::needCache(); |
| 163 | 163 | $cache = Cache::getInstance(); |
| 164 | 164 | list($path, $cacheDataName) = $cache->getRequestCacheHash(); |
| 165 | 165 | if (null !== $cacheDataName && false !== $needCache && $this->getStatusCode() === Template::STATUS_OK) { |
| 166 | 166 | Logger::log('Saving output response into cache'); |
| 167 | - $cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output); |
|
| 168 | - $cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', headers_list(), Cache::JSON); |
|
| 167 | + $cache->storeData('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $output); |
|
| 168 | + $cache->storeData('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', headers_list(), Cache::JSON); |
|
| 169 | 169 | } elseif (Request::getInstance()->getMethod() !== 'GET') { |
| 170 | 170 | $cache->flushCache(); |
| 171 | 171 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | ob_end_clean(); |
| 176 | 176 | Logger::log('End output response'); |
| 177 | 177 | $this->closeRender(); |
| 178 | - } else { |
|
| 178 | + }else { |
|
| 179 | 179 | return $output; |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -188,11 +188,11 @@ discard block |
||
| 188 | 188 | Logger::log('Close template render'); |
| 189 | 189 | $uri = Request::requestUri(); |
| 190 | 190 | Security::getInstance()->setSessionKey('lastRequest', array( |
| 191 | - 'url' => Request::getInstance()->getRootUrl() . $uri, |
|
| 191 | + 'url' => Request::getInstance()->getRootUrl().$uri, |
|
| 192 | 192 | 'ts' => microtime(true), |
| 193 | 193 | )); |
| 194 | 194 | Security::getInstance()->updateSession(); |
| 195 | - Logger::log('End request: ' . $uri, LOG_INFO); |
|
| 195 | + Logger::log('End request: '.$uri, LOG_INFO); |
|
| 196 | 196 | exit; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -230,17 +230,17 @@ discard block |
||
| 230 | 230 | ///////////////////////////////////////////////////////////// |
| 231 | 231 | // Date in the past sets the value to already have been expired. |
| 232 | 232 | header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); |
| 233 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
| 233 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
| 234 | 234 | header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
| 235 | 235 | header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
| 236 | 236 | header('Pragma: no-cache'); |
| 237 | 237 | header('Expires: 0'); |
| 238 | 238 | header('Content-Transfer-Encoding: binary'); |
| 239 | - header('Content-type: ' . $content); |
|
| 240 | - header('Content-length: ' . strlen($data)); |
|
| 241 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
| 239 | + header('Content-type: '.$content); |
|
| 240 | + header('Content-length: '.strlen($data)); |
|
| 241 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
| 242 | 242 | header('Access-Control-Expose-Headers: Filename'); |
| 243 | - header('Filename: ' . $filename); |
|
| 243 | + header('Filename: '.$filename); |
|
| 244 | 244 | echo $data; |
| 245 | 245 | ob_flush(); |
| 246 | 246 | ob_end_clean(); |