@@ -42,755 +42,755 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | class Router implements LoggerAwareInterface |
| 44 | 44 | { |
| 45 | - /** |
|
| 46 | - * The base Uri to construct the route |
|
| 47 | - * |
|
| 48 | - * @access private |
|
| 49 | - * @var string |
|
| 50 | - */ |
|
| 51 | - private $_sBaseUri = ''; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * get the security of page |
|
| 55 | - * |
|
| 56 | - * @access private |
|
| 57 | - * @var \Venus\core\Security |
|
| 58 | - */ |
|
| 59 | - private $_oSecurity = null; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * The Routes of the actual host |
|
| 63 | - * |
|
| 64 | - * @access private |
|
| 65 | - * @var object |
|
| 66 | - */ |
|
| 67 | - private $_oRoutes = null; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * Logger |
|
| 71 | - * |
|
| 72 | - * @access private |
|
| 73 | - * @var object |
|
| 74 | - */ |
|
| 75 | - private $_oLogger = null; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * constructor |
|
| 79 | - * |
|
| 80 | - * @access public |
|
| 81 | - */ |
|
| 82 | - public function __construct() |
|
| 83 | - { |
|
| 84 | - $oLogger = Debug::getInstance(); |
|
| 85 | - $this->setLogger($oLogger); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * run the routeur |
|
| 90 | - * |
|
| 91 | - * @access public |
|
| 92 | - * @return null|boolean |
|
| 93 | - */ |
|
| 94 | - public function run() |
|
| 95 | - { |
|
| 96 | - date_default_timezone_set(Config::get('Const')->timezone); |
|
| 97 | - |
|
| 98 | - $this->_create_constant(); |
|
| 99 | - |
|
| 100 | - if (Request::isHttpRequest()) { |
|
| 45 | + /** |
|
| 46 | + * The base Uri to construct the route |
|
| 47 | + * |
|
| 48 | + * @access private |
|
| 49 | + * @var string |
|
| 50 | + */ |
|
| 51 | + private $_sBaseUri = ''; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * get the security of page |
|
| 55 | + * |
|
| 56 | + * @access private |
|
| 57 | + * @var \Venus\core\Security |
|
| 58 | + */ |
|
| 59 | + private $_oSecurity = null; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * The Routes of the actual host |
|
| 63 | + * |
|
| 64 | + * @access private |
|
| 65 | + * @var object |
|
| 66 | + */ |
|
| 67 | + private $_oRoutes = null; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * Logger |
|
| 71 | + * |
|
| 72 | + * @access private |
|
| 73 | + * @var object |
|
| 74 | + */ |
|
| 75 | + private $_oLogger = null; |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * constructor |
|
| 79 | + * |
|
| 80 | + * @access public |
|
| 81 | + */ |
|
| 82 | + public function __construct() |
|
| 83 | + { |
|
| 84 | + $oLogger = Debug::getInstance(); |
|
| 85 | + $this->setLogger($oLogger); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * run the routeur |
|
| 90 | + * |
|
| 91 | + * @access public |
|
| 92 | + * @return null|boolean |
|
| 93 | + */ |
|
| 94 | + public function run() |
|
| 95 | + { |
|
| 96 | + date_default_timezone_set(Config::get('Const')->timezone); |
|
| 97 | + |
|
| 98 | + $this->_create_constant(); |
|
| 99 | + |
|
| 100 | + if (Request::isHttpRequest()) { |
|
| 101 | 101 | |
| 102 | - // Search if a Less file exists |
|
| 103 | - if (defined('LESS_ACTIVE') && LESS_ACTIVE === true) { |
|
| 102 | + // Search if a Less file exists |
|
| 103 | + if (defined('LESS_ACTIVE') && LESS_ACTIVE === true) { |
|
| 104 | 104 | |
| 105 | - if (strstr($_SERVER['REQUEST_URI'], '.css') |
|
| 106 | - && file_exists(preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI']))) { |
|
| 105 | + if (strstr($_SERVER['REQUEST_URI'], '.css') |
|
| 106 | + && file_exists(preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI']))) { |
|
| 107 | 107 | |
| 108 | - Less::toCss($_SERVER['REQUEST_URI']); |
|
| 109 | - exit; |
|
| 110 | - } |
|
| 111 | - } |
|
| 108 | + Less::toCss($_SERVER['REQUEST_URI']); |
|
| 109 | + exit; |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - // Search if a typescript file exists |
|
| 114 | - if (defined('TYPESCRIPT_ACTIVE') && TYPESCRIPT_ACTIVE === true) { |
|
| 113 | + // Search if a typescript file exists |
|
| 114 | + if (defined('TYPESCRIPT_ACTIVE') && TYPESCRIPT_ACTIVE === true) { |
|
| 115 | 115 | |
| 116 | - if (strstr($_SERVER['REQUEST_URI'], '.js') |
|
| 117 | - && file_exists(preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI']))) { |
|
| 116 | + if (strstr($_SERVER['REQUEST_URI'], '.js') |
|
| 117 | + && file_exists(preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI']))) { |
|
| 118 | 118 | |
| 119 | - Typescript::toJs($_SERVER['REQUEST_URI']); |
|
| 120 | - exit; |
|
| 121 | - } |
|
| 122 | - } |
|
| 119 | + Typescript::toJs($_SERVER['REQUEST_URI']); |
|
| 120 | + exit; |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - // Search public files in all plugins |
|
| 125 | - if ($_SERVER['REQUEST_URI'] !== '/') { |
|
| 124 | + // Search public files in all plugins |
|
| 125 | + if ($_SERVER['REQUEST_URI'] !== '/') { |
|
| 126 | 126 | |
| 127 | - foreach (Config::get('Plugins')->list as $iKey => $sPlugin) { |
|
| 127 | + foreach (Config::get('Plugins')->list as $iKey => $sPlugin) { |
|
| 128 | 128 | |
| 129 | - if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.$_SERVER['REQUEST_URI'])) { |
|
| 129 | + if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.$_SERVER['REQUEST_URI'])) { |
|
| 130 | 130 | |
| 131 | - echo file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.$_SERVER['REQUEST_URI']); |
|
| 132 | - exit; |
|
| 133 | - } else if (strstr($_SERVER['REQUEST_URI'], '.css') |
|
| 134 | - && file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI']))) { |
|
| 131 | + echo file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.$_SERVER['REQUEST_URI']); |
|
| 132 | + exit; |
|
| 133 | + } else if (strstr($_SERVER['REQUEST_URI'], '.css') |
|
| 134 | + && file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI']))) { |
|
| 135 | 135 | |
| 136 | - Less::toCss(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI'])); |
|
| 137 | - exit; |
|
| 138 | - } else if (strstr($_SERVER['REQUEST_URI'], '.js') |
|
| 139 | - && file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI']))) { |
|
| 136 | + Less::toCss(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI'])); |
|
| 137 | + exit; |
|
| 138 | + } else if (strstr($_SERVER['REQUEST_URI'], '.js') |
|
| 139 | + && file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI']))) { |
|
| 140 | 140 | |
| 141 | - Typescript::toJs(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI'])); |
|
| 142 | - exit; |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - } |
|
| 141 | + Typescript::toJs(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI'])); |
|
| 142 | + exit; |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - foreach (Config::get('Route') as $sMultiHost => $oHost) { |
|
| 147 | + foreach (Config::get('Route') as $sMultiHost => $oHost) { |
|
| 148 | 148 | |
| 149 | - foreach (explode(',', $sMultiHost) as $sHost) { |
|
| 149 | + foreach (explode(',', $sMultiHost) as $sHost) { |
|
| 150 | 150 | |
| 151 | - if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) || (strstr($sHost, '/') |
|
| 152 | - && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
| 151 | + if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) || (strstr($sHost, '/') |
|
| 152 | + && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
| 153 | 153 | |
| 154 | - $this->_oRoutes = $oHost; |
|
| 154 | + $this->_oRoutes = $oHost; |
|
| 155 | 155 | |
| 156 | - if (strstr($sHost, '/') |
|
| 157 | - && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
| 156 | + if (strstr($sHost, '/') |
|
| 157 | + && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
| 158 | 158 | |
| 159 | - $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
| 160 | - } |
|
| 159 | + $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - if (isset($oHost->location)) { |
|
| 162 | + if (isset($oHost->location)) { |
|
| 163 | 163 | |
| 164 | - header('Status: 301 Moved Permanently', false, 301); |
|
| 165 | - header('Location: '.$oHost->location); |
|
| 166 | - exit; |
|
| 167 | - } else if (preg_match('#getCss\?#', $_SERVER['REQUEST_URI'])) { |
|
| 164 | + header('Status: 301 Moved Permanently', false, 301); |
|
| 165 | + header('Location: '.$oHost->location); |
|
| 166 | + exit; |
|
| 167 | + } else if (preg_match('#getCss\?#', $_SERVER['REQUEST_URI'])) { |
|
| 168 | 168 | |
| 169 | - foreach ($_GET as $sKey => $sValue) { |
|
| 169 | + foreach ($_GET as $sKey => $sValue) { |
|
| 170 | 170 | |
| 171 | - if (file_exists(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.css')) { |
|
| 171 | + if (file_exists(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.css')) { |
|
| 172 | 172 | |
| 173 | - echo file_get_contents(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.css')."\n"; |
|
| 174 | - } |
|
| 175 | - } |
|
| 173 | + echo file_get_contents(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.css')."\n"; |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - exit; |
|
| 178 | - } else if (preg_match('#getJs\?#', $_SERVER['REQUEST_URI'])) { |
|
| 177 | + exit; |
|
| 178 | + } else if (preg_match('#getJs\?#', $_SERVER['REQUEST_URI'])) { |
|
| 179 | 179 | |
| 180 | - foreach ($_GET as $sKey => $sValue) { |
|
| 180 | + foreach ($_GET as $sKey => $sValue) { |
|
| 181 | 181 | |
| 182 | - if (file_exists(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.js')) { |
|
| 182 | + if (file_exists(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.js')) { |
|
| 183 | 183 | |
| 184 | - echo file_get_contents(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.js')."\n"; |
|
| 185 | - } |
|
| 186 | - } |
|
| 184 | + echo file_get_contents(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.js')."\n"; |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | - exit; |
|
| 189 | - } else if (isset($oHost->routes)) { |
|
| 188 | + exit; |
|
| 189 | + } else if (isset($oHost->routes)) { |
|
| 190 | 190 | |
| 191 | - foreach ($oHost->routes as $sKey => $oRoute) { |
|
| 191 | + foreach ($oHost->routes as $sKey => $oRoute) { |
|
| 192 | 192 | |
| 193 | - $mReturn = $this->_route($oRoute, $_SERVER['REQUEST_URI']); |
|
| 193 | + $mReturn = $this->_route($oRoute, $_SERVER['REQUEST_URI']); |
|
| 194 | 194 | |
| 195 | - if ($mReturn === 403) { |
|
| 195 | + if ($mReturn === 403) { |
|
| 196 | 196 | |
| 197 | - $this->_getPage403(); |
|
| 198 | - } |
|
| 199 | - else if ($mReturn === true) { |
|
| 197 | + $this->_getPage403(); |
|
| 198 | + } |
|
| 199 | + else if ($mReturn === true) { |
|
| 200 | 200 | |
| 201 | - if (isset($oRoute->cache)) { $this->_checkCache($oRoute->cache); } |
|
| 201 | + if (isset($oRoute->cache)) { $this->_checkCache($oRoute->cache); } |
|
| 202 | 202 | |
| 203 | - return true; |
|
| 204 | - } |
|
| 205 | - } |
|
| 203 | + return true; |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - $this->_getPage404(); |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - } |
|
| 211 | - } |
|
| 212 | - } else if (Request::isCliRequest()) { |
|
| 207 | + $this->_getPage404(); |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | + } |
|
| 212 | + } else if (Request::isCliRequest()) { |
|
| 213 | 213 | |
| 214 | - if (isset($_SERVER['argv'])) { $aArguments = $_SERVER['argv']; } |
|
| 215 | - else { $aArguments = []; } |
|
| 214 | + if (isset($_SERVER['argv'])) { $aArguments = $_SERVER['argv']; } |
|
| 215 | + else { $aArguments = []; } |
|
| 216 | 216 | |
| 217 | - define('PORTAL', 'Batch'); |
|
| 218 | - set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
| 217 | + define('PORTAL', 'Batch'); |
|
| 218 | + set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
| 219 | 219 | |
| 220 | - if (!isset($aArguments[1]) && strstr($aArguments[0], '/phpunit')) { |
|
| 220 | + if (!isset($aArguments[1]) && strstr($aArguments[0], '/phpunit')) { |
|
| 221 | 221 | |
| 222 | - $sBatchName = "phpunit"; |
|
| 223 | - $aArguments[0] = "bin/console"; |
|
| 224 | - $aArguments[1] = "phpunit"; |
|
| 225 | - } else if (isset($aArguments[1])) { |
|
| 226 | - $sBatchName = $aArguments[1]; |
|
| 227 | - } |
|
| 228 | - else { |
|
| 229 | - $aArguments[1] = 'help'; |
|
| 230 | - $sBatchName = $aArguments[1]; |
|
| 231 | - } |
|
| 222 | + $sBatchName = "phpunit"; |
|
| 223 | + $aArguments[0] = "bin/console"; |
|
| 224 | + $aArguments[1] = "phpunit"; |
|
| 225 | + } else if (isset($aArguments[1])) { |
|
| 226 | + $sBatchName = $aArguments[1]; |
|
| 227 | + } |
|
| 228 | + else { |
|
| 229 | + $aArguments[1] = 'help'; |
|
| 230 | + $sBatchName = $aArguments[1]; |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - if (isset(Config::get('Route')->batch->script->{$sBatchName})) { |
|
| 233 | + if (isset(Config::get('Route')->batch->script->{$sBatchName})) { |
|
| 234 | 234 | |
| 235 | - $oBatch = Config::get('Route')->batch->script->{$sBatchName}; |
|
| 236 | - array_shift($aArguments); |
|
| 237 | - array_shift($aArguments); |
|
| 238 | - |
|
| 239 | - $aOptions = array(); |
|
| 240 | - |
|
| 241 | - while (count($aArguments) > 0) { |
|
| 242 | - |
|
| 243 | - if (preg_match('/^-[a-z]/', $aArguments[0])) { |
|
| 235 | + $oBatch = Config::get('Route')->batch->script->{$sBatchName}; |
|
| 236 | + array_shift($aArguments); |
|
| 237 | + array_shift($aArguments); |
|
| 238 | + |
|
| 239 | + $aOptions = array(); |
|
| 240 | + |
|
| 241 | + while (count($aArguments) > 0) { |
|
| 242 | + |
|
| 243 | + if (preg_match('/^-[a-z]/', $aArguments[0])) { |
|
| 244 | 244 | |
| 245 | - $sOptionName = str_replace('-', '', $aArguments[0]); |
|
| 245 | + $sOptionName = str_replace('-', '', $aArguments[0]); |
|
| 246 | 246 | |
| 247 | - if (isset($aArguments[1])) { |
|
| 248 | - $sOptionValue = $aArguments[1]; |
|
| 249 | - } else { |
|
| 250 | - $sOptionValue = ''; |
|
| 251 | - } |
|
| 247 | + if (isset($aArguments[1])) { |
|
| 248 | + $sOptionValue = $aArguments[1]; |
|
| 249 | + } else { |
|
| 250 | + $sOptionValue = ''; |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - if (isset($oBatch->options->$sOptionName) && isset($oBatch->options->$sOptionName->type) |
|
| 254 | - && $oBatch->options->$sOptionName->type === false) { |
|
| 253 | + if (isset($oBatch->options->$sOptionName) && isset($oBatch->options->$sOptionName->type) |
|
| 254 | + && $oBatch->options->$sOptionName->type === false) { |
|
| 255 | 255 | |
| 256 | - $aOptions[$sOptionName] = true; |
|
| 257 | - array_shift($aArguments); |
|
| 258 | - } else if (isset($oBatch->options->$sOptionName) && isset($oBatch->options->$sOptionName->type) |
|
| 259 | - && ($oBatch->options->$sOptionName->type === 'string' |
|
| 260 | - || $oBatch->options->$sOptionName->type === 'int') |
|
| 261 | - ) { |
|
| 256 | + $aOptions[$sOptionName] = true; |
|
| 257 | + array_shift($aArguments); |
|
| 258 | + } else if (isset($oBatch->options->$sOptionName) && isset($oBatch->options->$sOptionName->type) |
|
| 259 | + && ($oBatch->options->$sOptionName->type === 'string' |
|
| 260 | + || $oBatch->options->$sOptionName->type === 'int') |
|
| 261 | + ) { |
|
| 262 | 262 | |
| 263 | - $aOptions[$sOptionName] = $sOptionValue; |
|
| 264 | - array_shift($aArguments); |
|
| 265 | - array_shift($aArguments); |
|
| 266 | - } else { |
|
| 263 | + $aOptions[$sOptionName] = $sOptionValue; |
|
| 264 | + array_shift($aArguments); |
|
| 265 | + array_shift($aArguments); |
|
| 266 | + } else { |
|
| 267 | 267 | |
| 268 | - array_shift($aArguments); |
|
| 269 | - } |
|
| 270 | - } else { |
|
| 271 | - |
|
| 272 | - array_shift($aArguments); |
|
| 273 | - } |
|
| 274 | - } |
|
| 275 | - } |
|
| 268 | + array_shift($aArguments); |
|
| 269 | + } |
|
| 270 | + } else { |
|
| 271 | + |
|
| 272 | + array_shift($aArguments); |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | - if (isset($oBatch->controller) && isset($oBatch->action)) { |
|
| 277 | + if (isset($oBatch->controller) && isset($oBatch->action)) { |
|
| 278 | 278 | |
| 279 | - echo $this->_loadController($oBatch->controller, $oBatch->action, array($aOptions)); |
|
| 280 | - } else { |
|
| 279 | + echo $this->_loadController($oBatch->controller, $oBatch->action, array($aOptions)); |
|
| 280 | + } else { |
|
| 281 | 281 | |
| 282 | - if (Request::isCliRequest()) { |
|
| 283 | - |
|
| 284 | - echo "Error : The batch not exists - please verify your Route or the name passed in your command name.\n"; |
|
| 285 | - } |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * run the routeur by the forwarsd metho (in the controller) |
|
| 293 | - * |
|
| 294 | - * @access public |
|
| 295 | - * @param string $sRoute route we wantload |
|
| 296 | - * @param array $aParams parameters to passe |
|
| 297 | - * @return void |
|
| 298 | - */ |
|
| 299 | - public function runByFoward(string $sRoute, array $aParams) |
|
| 300 | - { |
|
| 301 | - $this->_create_constant(); |
|
| 282 | + if (Request::isCliRequest()) { |
|
| 283 | + |
|
| 284 | + echo "Error : The batch not exists - please verify your Route or the name passed in your command name.\n"; |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * run the routeur by the forwarsd metho (in the controller) |
|
| 293 | + * |
|
| 294 | + * @access public |
|
| 295 | + * @param string $sRoute route we wantload |
|
| 296 | + * @param array $aParams parameters to passe |
|
| 297 | + * @return void |
|
| 298 | + */ |
|
| 299 | + public function runByFoward(string $sRoute, array $aParams) |
|
| 300 | + { |
|
| 301 | + $this->_create_constant(); |
|
| 302 | 302 | |
| 303 | - if (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) { |
|
| 303 | + if (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) { |
|
| 304 | 304 | |
| 305 | - foreach (Config::get('Route') as $sHost => $oHost) { |
|
| 305 | + foreach (Config::get('Route') as $sHost => $oHost) { |
|
| 306 | 306 | |
| 307 | - if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) |
|
| 308 | - || (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
| 307 | + if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) |
|
| 308 | + || (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
| 309 | 309 | |
| 310 | - $this->_oRoutes = $oHost; |
|
| 310 | + $this->_oRoutes = $oHost; |
|
| 311 | 311 | |
| 312 | - if (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
| 312 | + if (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
| 313 | 313 | |
| 314 | - $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
| 315 | - } |
|
| 314 | + $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | - foreach ($oHost->routes as $sKey => $oRoute) { |
|
| 317 | + foreach ($oHost->routes as $sKey => $oRoute) { |
|
| 318 | 318 | |
| 319 | - $this->_route($oRoute, $sRoute); |
|
| 320 | - } |
|
| 321 | - } |
|
| 322 | - } |
|
| 323 | - } |
|
| 324 | - else if (defined('STDIN')) { |
|
| 319 | + $this->_route($oRoute, $sRoute); |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | + else if (defined('STDIN')) { |
|
| 325 | 325 | |
| 326 | - $oBatch = Config::get('Route')->batch->script->{$sRoute}; |
|
| 327 | - echo $this->_loadController($oBatch->controller, $oBatch->action, $aParams); |
|
| 328 | - } |
|
| 329 | - } |
|
| 326 | + $oBatch = Config::get('Route')->batch->script->{$sRoute}; |
|
| 327 | + echo $this->_loadController($oBatch->controller, $oBatch->action, $aParams); |
|
| 328 | + } |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - /** |
|
| 332 | - * run the error http page |
|
| 333 | - * |
|
| 334 | - * @access public |
|
| 335 | - * @param int iError http error |
|
| 336 | - * @return void |
|
| 337 | - */ |
|
| 338 | - public function runHttpErrorPage(int $iError) |
|
| 339 | - { |
|
| 340 | - $this->_create_constant(); |
|
| 331 | + /** |
|
| 332 | + * run the error http page |
|
| 333 | + * |
|
| 334 | + * @access public |
|
| 335 | + * @param int iError http error |
|
| 336 | + * @return void |
|
| 337 | + */ |
|
| 338 | + public function runHttpErrorPage(int $iError) |
|
| 339 | + { |
|
| 340 | + $this->_create_constant(); |
|
| 341 | 341 | |
| 342 | - if (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) { |
|
| 342 | + if (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) { |
|
| 343 | 343 | |
| 344 | - foreach (Config::get('Route') as $sHost => $oHost) { |
|
| 344 | + foreach (Config::get('Route') as $sHost => $oHost) { |
|
| 345 | 345 | |
| 346 | - if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) |
|
| 347 | - || (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
| 346 | + if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) |
|
| 347 | + || (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
| 348 | 348 | |
| 349 | - $this->_oRoutes = $oHost->routes; |
|
| 349 | + $this->_oRoutes = $oHost->routes; |
|
| 350 | 350 | |
| 351 | - if (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
| 351 | + if (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
| 352 | 352 | |
| 353 | - $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
| 354 | - } |
|
| 353 | + $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | - $sHttpErrorPageName = '_getPage'.iError; |
|
| 357 | - $this->$sHttpErrorPageName(); |
|
| 358 | - } |
|
| 359 | - } |
|
| 360 | - } |
|
| 361 | - } |
|
| 356 | + $sHttpErrorPageName = '_getPage'.iError; |
|
| 357 | + $this->$sHttpErrorPageName(); |
|
| 358 | + } |
|
| 359 | + } |
|
| 360 | + } |
|
| 361 | + } |
|
| 362 | 362 | |
| 363 | - /** |
|
| 364 | - * load a route |
|
| 365 | - * |
|
| 366 | - * @access private |
|
| 367 | - * @param \stdClass $oRoute one route |
|
| 368 | - * @param string $RequestUri URI |
|
| 369 | - * @return void |
|
| 370 | - */ |
|
| 371 | - private function _route(\stdClass $oRoute, string $RequestUri) |
|
| 372 | - { |
|
| 373 | - $sCharset = 'UTF-8'; |
|
| 363 | + /** |
|
| 364 | + * load a route |
|
| 365 | + * |
|
| 366 | + * @access private |
|
| 367 | + * @param \stdClass $oRoute one route |
|
| 368 | + * @param string $RequestUri URI |
|
| 369 | + * @return void |
|
| 370 | + */ |
|
| 371 | + private function _route(\stdClass $oRoute, string $RequestUri) |
|
| 372 | + { |
|
| 373 | + $sCharset = 'UTF-8'; |
|
| 374 | 374 | |
| 375 | - if (isset($oRoute->route)) { |
|
| 375 | + if (isset($oRoute->route)) { |
|
| 376 | 376 | |
| 377 | - $sRoute = str_replace("*", ".*", $oRoute->route); |
|
| 377 | + $sRoute = str_replace("*", ".*", $oRoute->route); |
|
| 378 | 378 | |
| 379 | - $sFinalRoute = preg_replace_callback( |
|
| 380 | - '|\[/{0,1}:([a-zA-Z_]+)\]|', |
|
| 381 | - function($aMatches) use ($oRoute) { |
|
| 382 | - return "/{0,1}(?P<".$aMatches[1].">".$oRoute->constraints->{$aMatches[1]}.")"; |
|
| 383 | - }, |
|
| 384 | - $sRoute |
|
| 385 | - ); |
|
| 386 | - } |
|
| 387 | - else { |
|
| 379 | + $sFinalRoute = preg_replace_callback( |
|
| 380 | + '|\[/{0,1}:([a-zA-Z_]+)\]|', |
|
| 381 | + function($aMatches) use ($oRoute) { |
|
| 382 | + return "/{0,1}(?P<".$aMatches[1].">".$oRoute->constraints->{$aMatches[1]}.")"; |
|
| 383 | + }, |
|
| 384 | + $sRoute |
|
| 385 | + ); |
|
| 386 | + } |
|
| 387 | + else { |
|
| 388 | 388 | |
| 389 | - $sFinalRoute = '.*'; |
|
| 390 | - } |
|
| 389 | + $sFinalRoute = '.*'; |
|
| 390 | + } |
|
| 391 | 391 | |
| 392 | - $RequestUri = preg_replace('/^([^?]+)\?.*$/', '$1', $RequestUri); |
|
| 393 | - $RequestUri = preg_replace('#^'.$this->_sBaseUri.'#', '', $RequestUri); |
|
| 392 | + $RequestUri = preg_replace('/^([^?]+)\?.*$/', '$1', $RequestUri); |
|
| 393 | + $RequestUri = preg_replace('#^'.$this->_sBaseUri.'#', '', $RequestUri); |
|
| 394 | 394 | |
| 395 | - if (preg_match('#^'.$sFinalRoute.'$#', $RequestUri, $aMatch)) { |
|
| 395 | + if (preg_match('#^'.$sFinalRoute.'$#', $RequestUri, $aMatch)) { |
|
| 396 | 396 | |
| 397 | - if (isset($oRoute->location)) { |
|
| 397 | + if (isset($oRoute->location)) { |
|
| 398 | 398 | |
| 399 | - $aParamEntries = array(); |
|
| 399 | + $aParamEntries = array(); |
|
| 400 | 400 | |
| 401 | - foreach ($oRoute->constraints as $sName => $sType) { |
|
| 401 | + foreach ($oRoute->constraints as $sName => $sType) { |
|
| 402 | 402 | |
| 403 | - if (isset($aMatch[$sName])) { |
|
| 403 | + if (isset($aMatch[$sName])) { |
|
| 404 | 404 | |
| 405 | - $aParamEntries[$sName] = $aMatch[$sName]; |
|
| 406 | - } |
|
| 407 | - } |
|
| 405 | + $aParamEntries[$sName] = $aMatch[$sName]; |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | 408 | |
| 409 | - $oUrlManager = new UrlManager; |
|
| 410 | - header('Status: 301 Moved Permanently', false, 301); |
|
| 411 | - header('Location: '.$oUrlManager->getUrl($oRoute->location, $aParamEntries)); |
|
| 412 | - exit; |
|
| 413 | - } |
|
| 409 | + $oUrlManager = new UrlManager; |
|
| 410 | + header('Status: 301 Moved Permanently', false, 301); |
|
| 411 | + header('Location: '.$oUrlManager->getUrl($oRoute->location, $aParamEntries)); |
|
| 412 | + exit; |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | - $this->_oSecurity = new Security; |
|
| 415 | + $this->_oSecurity = new Security; |
|
| 416 | 416 | |
| 417 | - if (!$this->_oSecurity->checkSecurity() !== null) { return 403; } |
|
| 417 | + if (!$this->_oSecurity->checkSecurity() !== null) { return 403; } |
|
| 418 | 418 | |
| 419 | - // create the $_GET by the URL |
|
| 419 | + // create the $_GET by the URL |
|
| 420 | 420 | |
| 421 | - foreach ($aMatch as $mKey => $sResults) { |
|
| 421 | + foreach ($aMatch as $mKey => $sResults) { |
|
| 422 | 422 | |
| 423 | - if (is_string($mKey)) { |
|
| 423 | + if (is_string($mKey)) { |
|
| 424 | 424 | |
| 425 | - $_GET[$mKey] = $sResults; |
|
| 426 | - } |
|
| 427 | - } |
|
| 425 | + $_GET[$mKey] = $sResults; |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | 428 | |
| 429 | - if (isset($oRoute->methods) && $oRoute->methods != $_SERVER['REQUEST_METHOD']) { return false; } |
|
| 429 | + if (isset($oRoute->methods) && $oRoute->methods != $_SERVER['REQUEST_METHOD']) { return false; } |
|
| 430 | 430 | |
| 431 | - if (isset($oRoute->schemes) && $oRoute->schemes == 'https' && !Request::isHttpsRequest()) { return false; } |
|
| 431 | + if (isset($oRoute->schemes) && $oRoute->schemes == 'https' && !Request::isHttpsRequest()) { return false; } |
|
| 432 | 432 | |
| 433 | - if (isset($oRoute->cache) && isset($oRoute->cache->max_age) && !isset($_GET['flush'])) { |
|
| 433 | + if (isset($oRoute->cache) && isset($oRoute->cache->max_age) && !isset($_GET['flush'])) { |
|
| 434 | 434 | |
| 435 | - $oMobileDetect = new \Mobile_Detect; |
|
| 435 | + $oMobileDetect = new \Mobile_Detect; |
|
| 436 | 436 | |
| 437 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
| 438 | - else { $sCacheExt = ''; } |
|
| 437 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
| 438 | + else { $sCacheExt = ''; } |
|
| 439 | 439 | |
| 440 | - $mCacheReturn = Cache::get($RequestUri.$sCacheExt, $oRoute->cache->max_age); |
|
| 440 | + $mCacheReturn = Cache::get($RequestUri.$sCacheExt, $oRoute->cache->max_age); |
|
| 441 | 441 | |
| 442 | - if ($mCacheReturn && count($_POST) < 1) { |
|
| 442 | + if ($mCacheReturn && count($_POST) < 1) { |
|
| 443 | 443 | |
| 444 | - echo $mCacheReturn; |
|
| 445 | - return true; |
|
| 446 | - } |
|
| 447 | - } |
|
| 444 | + echo $mCacheReturn; |
|
| 445 | + return true; |
|
| 446 | + } |
|
| 447 | + } |
|
| 448 | 448 | |
| 449 | - if (isset($oRoute->cache)) { $this->_checkCache($oRoute->cache); } |
|
| 449 | + if (isset($oRoute->cache)) { $this->_checkCache($oRoute->cache); } |
|
| 450 | 450 | |
| 451 | - if (isset($oRoute->controller)) { |
|
| 451 | + if (isset($oRoute->controller)) { |
|
| 452 | 452 | |
| 453 | - define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->controller)); |
|
| 454 | - set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
| 453 | + define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->controller)); |
|
| 454 | + set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
| 455 | 455 | |
| 456 | - if (isset($oRoute->content_type)) { |
|
| 456 | + if (isset($oRoute->content_type)) { |
|
| 457 | 457 | |
| 458 | - if ($oRoute->content_type == 'json') { |
|
| 458 | + if ($oRoute->content_type == 'json') { |
|
| 459 | 459 | |
| 460 | - header('Content-type: application/json; charset='.$sCharset.''); |
|
| 461 | - } else if ($oRoute->content_type == 'html') { |
|
| 460 | + header('Content-type: application/json; charset='.$sCharset.''); |
|
| 461 | + } else if ($oRoute->content_type == 'html') { |
|
| 462 | 462 | |
| 463 | - header('Content-type: text/html; charset='.$sCharset.''); |
|
| 464 | - } else if ($oRoute->content_type == 'jpeg') { |
|
| 463 | + header('Content-type: text/html; charset='.$sCharset.''); |
|
| 464 | + } else if ($oRoute->content_type == 'jpeg') { |
|
| 465 | 465 | |
| 466 | - header('Content-type: image/jpeg'); |
|
| 467 | - } |
|
| 468 | - } |
|
| 469 | - else { |
|
| 466 | + header('Content-type: image/jpeg'); |
|
| 467 | + } |
|
| 468 | + } |
|
| 469 | + else { |
|
| 470 | 470 | |
| 471 | - header('Content-type: text/html; charset='.$sCharset.''); |
|
| 472 | - } |
|
| 471 | + header('Content-type: text/html; charset='.$sCharset.''); |
|
| 472 | + } |
|
| 473 | 473 | |
| 474 | - $sControllerName = $oRoute->controller; |
|
| 475 | - $sActionName = $oRoute->action; |
|
| 474 | + $sControllerName = $oRoute->controller; |
|
| 475 | + $sActionName = $oRoute->action; |
|
| 476 | 476 | |
| 477 | - $oController = new $sControllerName; |
|
| 477 | + $oController = new $sControllerName; |
|
| 478 | 478 | |
| 479 | - $aEntries = array(); |
|
| 479 | + $aEntries = array(); |
|
| 480 | 480 | |
| 481 | - if (isset($oRoute->constraints) && is_object($oRoute->constraints)) { |
|
| 481 | + if (isset($oRoute->constraints) && is_object($oRoute->constraints)) { |
|
| 482 | 482 | |
| 483 | - $mReturn = null; |
|
| 483 | + $mReturn = null; |
|
| 484 | 484 | |
| 485 | - foreach ($oRoute->constraints as $sName => $sType) { |
|
| 485 | + foreach ($oRoute->constraints as $sName => $sType) { |
|
| 486 | 486 | |
| 487 | - if (isset($_GET[$sName]) && $_GET[$sName] != '') { |
|
| 487 | + if (isset($_GET[$sName]) && $_GET[$sName] != '') { |
|
| 488 | 488 | |
| 489 | - $aEntries[] = $_GET[$sName]; |
|
| 490 | - } else if (isset($oRoute->defaults_constraints) && is_object($oRoute->defaults_constraints) |
|
| 491 | - && isset($oRoute->defaults_constraints->{$sName})) { |
|
| 489 | + $aEntries[] = $_GET[$sName]; |
|
| 490 | + } else if (isset($oRoute->defaults_constraints) && is_object($oRoute->defaults_constraints) |
|
| 491 | + && isset($oRoute->defaults_constraints->{$sName})) { |
|
| 492 | 492 | |
| 493 | - $aEntries[] = $oRoute->defaults_constraints->{$sName}; |
|
| 494 | - } else if (isset($_GET[$sName])) { |
|
| 493 | + $aEntries[] = $oRoute->defaults_constraints->{$sName}; |
|
| 494 | + } else if (isset($_GET[$sName])) { |
|
| 495 | 495 | |
| 496 | - $aEntries[] = $_GET[$sName]; |
|
| 497 | - } else if (preg_match('/'.$sType.'/', '')) { |
|
| 496 | + $aEntries[] = $_GET[$sName]; |
|
| 497 | + } else if (preg_match('/'.$sType.'/', '')) { |
|
| 498 | 498 | |
| 499 | - $aEntries[] = ''; |
|
| 500 | - } else { |
|
| 499 | + $aEntries[] = ''; |
|
| 500 | + } else { |
|
| 501 | 501 | |
| 502 | - $this->_oLogger->warning('Error: Parameter '.$sName.' not exists!'); |
|
| 503 | - break; |
|
| 504 | - } |
|
| 505 | - } |
|
| 502 | + $this->_oLogger->warning('Error: Parameter '.$sName.' not exists!'); |
|
| 503 | + break; |
|
| 504 | + } |
|
| 505 | + } |
|
| 506 | 506 | |
| 507 | - if ($mReturn === null) { |
|
| 507 | + if ($mReturn === null) { |
|
| 508 | 508 | |
| 509 | - $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
|
| 509 | + $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
|
| 510 | 510 | |
| 511 | - } |
|
| 512 | - } |
|
| 513 | - else { |
|
| 511 | + } |
|
| 512 | + } |
|
| 513 | + else { |
|
| 514 | 514 | |
| 515 | - $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
|
| 516 | - } |
|
| 515 | + $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | - if (isset($oRoute->content_type)) { |
|
| 518 | + if (isset($oRoute->content_type)) { |
|
| 519 | 519 | |
| 520 | - if ($oRoute->content_type === 'json') { |
|
| 520 | + if ($oRoute->content_type === 'json') { |
|
| 521 | 521 | |
| 522 | - $mReturn = json_encode($mReturn, JSON_PRETTY_PRINT); |
|
| 523 | - } |
|
| 524 | - } |
|
| 525 | - } |
|
| 526 | - else if (isset($oRoute->template) && isset($oRoute->layout) && $oRoute->layout === true) { |
|
| 522 | + $mReturn = json_encode($mReturn, JSON_PRETTY_PRINT); |
|
| 523 | + } |
|
| 524 | + } |
|
| 525 | + } |
|
| 526 | + else if (isset($oRoute->template) && isset($oRoute->layout) && $oRoute->layout === true) { |
|
| 527 | 527 | |
| 528 | - define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
|
| 529 | - set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
| 528 | + define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
|
| 529 | + set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
| 530 | 530 | |
| 531 | - $oLayout = Vendor::getVendor('Apollina\Template', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.'Layout.tpl'); |
|
| 531 | + $oLayout = Vendor::getVendor('Apollina\Template', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.'Layout.tpl'); |
|
| 532 | 532 | |
| 533 | - if (isset($oRoute->vars)) { |
|
| 533 | + if (isset($oRoute->vars)) { |
|
| 534 | 534 | |
| 535 | - foreach ($oRoute->vars as $sKey => $mValue) { |
|
| 535 | + foreach ($oRoute->vars as $sKey => $mValue) { |
|
| 536 | 536 | |
| 537 | - $oLayout->assign($sKey, $mValue); |
|
| 538 | - } |
|
| 539 | - } |
|
| 537 | + $oLayout->assign($sKey, $mValue); |
|
| 538 | + } |
|
| 539 | + } |
|
| 540 | 540 | |
| 541 | - $mReturn = $oLayout->assign('model', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$oRoute->template.'.tpl') |
|
| 542 | - ->fetch(); |
|
| 543 | - } |
|
| 544 | - else if (isset($oRoute->template)) { |
|
| 541 | + $mReturn = $oLayout->assign('model', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$oRoute->template.'.tpl') |
|
| 542 | + ->fetch(); |
|
| 543 | + } |
|
| 544 | + else if (isset($oRoute->template)) { |
|
| 545 | 545 | |
| 546 | - define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
|
| 547 | - set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
| 546 | + define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
|
| 547 | + set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
| 548 | 548 | |
| 549 | - $oTemplate = Vendor::getVendor('Apollina\Template', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$oRoute->template.'.tpl'); |
|
| 549 | + $oTemplate = Vendor::getVendor('Apollina\Template', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$oRoute->template.'.tpl'); |
|
| 550 | 550 | |
| 551 | - if (isset($oRoute->vars)) { |
|
| 551 | + if (isset($oRoute->vars)) { |
|
| 552 | 552 | |
| 553 | - foreach ($oRoute->vars as $sKey => $mValue) { |
|
| 553 | + foreach ($oRoute->vars as $sKey => $mValue) { |
|
| 554 | 554 | |
| 555 | - $oTemplate->assign($sKey, $mValue); |
|
| 556 | - } |
|
| 557 | - } |
|
| 555 | + $oTemplate->assign($sKey, $mValue); |
|
| 556 | + } |
|
| 557 | + } |
|
| 558 | 558 | |
| 559 | - $mReturn = $oTemplate->fetch(); |
|
| 560 | - } |
|
| 559 | + $mReturn = $oTemplate->fetch(); |
|
| 560 | + } |
|
| 561 | 561 | |
| 562 | - // management of return or cache of it |
|
| 562 | + // management of return or cache of it |
|
| 563 | 563 | |
| 564 | - if (isset($oRoute->cache) && isset($oRoute->cache->max_age) && $mReturn) { |
|
| 564 | + if (isset($oRoute->cache) && isset($oRoute->cache->max_age) && $mReturn) { |
|
| 565 | 565 | |
| 566 | - $oMobileDetect = new \Mobile_Detect; |
|
| 566 | + $oMobileDetect = new \Mobile_Detect; |
|
| 567 | 567 | |
| 568 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
| 569 | - else { $sCacheExt = ''; } |
|
| 568 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
| 569 | + else { $sCacheExt = ''; } |
|
| 570 | 570 | |
| 571 | - if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
|
| 571 | + if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
|
| 572 | 572 | |
| 573 | - $mReturn = str_replace(array("\t", "\r", " "), array("", "", " "), $mReturn); |
|
| 574 | - } |
|
| 573 | + $mReturn = str_replace(array("\t", "\r", " "), array("", "", " "), $mReturn); |
|
| 574 | + } |
|
| 575 | 575 | |
| 576 | - Cache::set($RequestUri.$sCacheExt, $mReturn, $oRoute->cache->max_age); |
|
| 577 | - } |
|
| 576 | + Cache::set($RequestUri.$sCacheExt, $mReturn, $oRoute->cache->max_age); |
|
| 577 | + } |
|
| 578 | 578 | |
| 579 | - if ($mReturn) { |
|
| 579 | + if ($mReturn) { |
|
| 580 | 580 | |
| 581 | - echo $mReturn; |
|
| 582 | - return true; |
|
| 583 | - } |
|
| 584 | - } |
|
| 585 | - } |
|
| 581 | + echo $mReturn; |
|
| 582 | + return true; |
|
| 583 | + } |
|
| 584 | + } |
|
| 585 | + } |
|
| 586 | 586 | |
| 587 | - /** |
|
| 588 | - * create the constants |
|
| 589 | - * |
|
| 590 | - * @access private |
|
| 591 | - * @return void |
|
| 592 | - */ |
|
| 593 | - private function _create_constant() |
|
| 594 | - { |
|
| 595 | - foreach (Config::get('Const') as $sKey => $mValue) { |
|
| 587 | + /** |
|
| 588 | + * create the constants |
|
| 589 | + * |
|
| 590 | + * @access private |
|
| 591 | + * @return void |
|
| 592 | + */ |
|
| 593 | + private function _create_constant() |
|
| 594 | + { |
|
| 595 | + foreach (Config::get('Const') as $sKey => $mValue) { |
|
| 596 | 596 | |
| 597 | - if (is_string($mValue) || is_int($mValue) || is_float($mValue) || is_bool($mValue)) { |
|
| 597 | + if (is_string($mValue) || is_int($mValue) || is_float($mValue) || is_bool($mValue)) { |
|
| 598 | 598 | |
| 599 | - define(strtoupper($sKey), $mValue); |
|
| 600 | - } |
|
| 601 | - } |
|
| 602 | - } |
|
| 599 | + define(strtoupper($sKey), $mValue); |
|
| 600 | + } |
|
| 601 | + } |
|
| 602 | + } |
|
| 603 | 603 | |
| 604 | - /** |
|
| 605 | - * load the controller |
|
| 606 | - * |
|
| 607 | - * @access private |
|
| 608 | - * @param object $oControllerName controller name |
|
| 609 | - * @param string $sActionName method name |
|
| 610 | - * @param array $aParams parameters |
|
| 611 | - * @return mixed |
|
| 612 | - */ |
|
| 613 | - private function _loadController($oControllerName, string $sActionName, array $aParams = array()) |
|
| 614 | - { |
|
| 615 | - $aPhpDoc = PhpDoc::getPhpDocOfMethod($oControllerName, $sActionName); |
|
| 604 | + /** |
|
| 605 | + * load the controller |
|
| 606 | + * |
|
| 607 | + * @access private |
|
| 608 | + * @param object $oControllerName controller name |
|
| 609 | + * @param string $sActionName method name |
|
| 610 | + * @param array $aParams parameters |
|
| 611 | + * @return mixed |
|
| 612 | + */ |
|
| 613 | + private function _loadController($oControllerName, string $sActionName, array $aParams = array()) |
|
| 614 | + { |
|
| 615 | + $aPhpDoc = PhpDoc::getPhpDocOfMethod($oControllerName, $sActionName); |
|
| 616 | 616 | |
| 617 | - if (isset($aPhpDoc['Cache'])) { |
|
| 617 | + if (isset($aPhpDoc['Cache'])) { |
|
| 618 | 618 | |
| 619 | - if (!isset($aPhpDoc['Cache']['maxage'])) { $aPhpDoc['Cache']['maxage'] = 0; } |
|
| 619 | + if (!isset($aPhpDoc['Cache']['maxage'])) { $aPhpDoc['Cache']['maxage'] = 0; } |
|
| 620 | 620 | |
| 621 | - $oMobileDetect = new \Mobile_Detect; |
|
| 621 | + $oMobileDetect = new \Mobile_Detect; |
|
| 622 | 622 | |
| 623 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
| 624 | - else { $sCacheExt = ''; } |
|
| 623 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
| 624 | + else { $sCacheExt = ''; } |
|
| 625 | 625 | |
| 626 | - $mCacheReturn = Cache::get($sActionName.$sCacheExt, $aPhpDoc['Cache']['maxage']); |
|
| 626 | + $mCacheReturn = Cache::get($sActionName.$sCacheExt, $aPhpDoc['Cache']['maxage']); |
|
| 627 | 627 | |
| 628 | - if ($mCacheReturn !== false) { return $mCacheReturn; } |
|
| 629 | - } |
|
| 628 | + if ($mCacheReturn !== false) { return $mCacheReturn; } |
|
| 629 | + } |
|
| 630 | 630 | |
| 631 | - if (isset($aPhpDoc['Secure'])) { |
|
| 631 | + if (isset($aPhpDoc['Secure'])) { |
|
| 632 | 632 | |
| 633 | - if (isset($aPhpDoc['Secure']['roles']) && $this->_oSecurity->getUserRole() != $aPhpDoc['Secure']['roles']) { |
|
| 633 | + if (isset($aPhpDoc['Secure']['roles']) && $this->_oSecurity->getUserRole() != $aPhpDoc['Secure']['roles']) { |
|
| 634 | 634 | |
| 635 | - $this->_getPage403(); |
|
| 636 | - } |
|
| 637 | - } |
|
| 635 | + $this->_getPage403(); |
|
| 636 | + } |
|
| 637 | + } |
|
| 638 | 638 | |
| 639 | - $oController = new $oControllerName; |
|
| 639 | + $oController = new $oControllerName; |
|
| 640 | 640 | |
| 641 | - ob_start(); |
|
| 641 | + ob_start(); |
|
| 642 | 642 | |
| 643 | - if (!defined('PORTAL')) { define('PORTAL', 'Batch'); } |
|
| 643 | + if (!defined('PORTAL')) { define('PORTAL', 'Batch'); } |
|
| 644 | 644 | |
| 645 | - if (method_exists($oController, 'beforeExecuteRoute')) { |
|
| 645 | + if (method_exists($oController, 'beforeExecuteRoute')) { |
|
| 646 | 646 | |
| 647 | - call_user_func_array(array($oController, 'beforeExecuteRoute'), array()); |
|
| 648 | - } |
|
| 647 | + call_user_func_array(array($oController, 'beforeExecuteRoute'), array()); |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | - $mReturnController = call_user_func_array(array($oController, $sActionName), $aParams); |
|
| 650 | + $mReturnController = call_user_func_array(array($oController, $sActionName), $aParams); |
|
| 651 | 651 | |
| 652 | - if (method_exists($oController, 'afterExecuteRoute')) { |
|
| 652 | + if (method_exists($oController, 'afterExecuteRoute')) { |
|
| 653 | 653 | |
| 654 | - call_user_func_array(array($oController, 'afterExecuteRoute'), array()); |
|
| 655 | - } |
|
| 654 | + call_user_func_array(array($oController, 'afterExecuteRoute'), array()); |
|
| 655 | + } |
|
| 656 | 656 | |
| 657 | - $mReturn = ob_get_clean(); |
|
| 657 | + $mReturn = ob_get_clean(); |
|
| 658 | 658 | |
| 659 | - if ($mReturn == '') { $mReturn = $mReturnController; } |
|
| 659 | + if ($mReturn == '') { $mReturn = $mReturnController; } |
|
| 660 | 660 | |
| 661 | - if (isset($aPhpDoc['Cache'])) { |
|
| 661 | + if (isset($aPhpDoc['Cache'])) { |
|
| 662 | 662 | |
| 663 | - $oMobileDetect = new \Mobile_Detect; |
|
| 663 | + $oMobileDetect = new \Mobile_Detect; |
|
| 664 | 664 | |
| 665 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
| 666 | - else { $sCacheExt = ''; } |
|
| 665 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
| 666 | + else { $sCacheExt = ''; } |
|
| 667 | 667 | |
| 668 | - if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
|
| 668 | + if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
|
| 669 | 669 | |
| 670 | - $mReturn = str_replace(array("\t", "\r", " "), array("", "", "", " "), $mReturn); |
|
| 671 | - } |
|
| 670 | + $mReturn = str_replace(array("\t", "\r", " "), array("", "", "", " "), $mReturn); |
|
| 671 | + } |
|
| 672 | 672 | |
| 673 | - Cache::set($sActionName.$sCacheExt, $mReturn, $aPhpDoc['Cache']['maxage']); |
|
| 674 | - } |
|
| 673 | + Cache::set($sActionName.$sCacheExt, $mReturn, $aPhpDoc['Cache']['maxage']); |
|
| 674 | + } |
|
| 675 | 675 | |
| 676 | - return $mReturn; |
|
| 677 | - } |
|
| 676 | + return $mReturn; |
|
| 677 | + } |
|
| 678 | 678 | |
| 679 | - /** |
|
| 680 | - * get the page 403 |
|
| 681 | - * |
|
| 682 | - * @access private |
|
| 683 | - * @return void |
|
| 684 | - */ |
|
| 685 | - private function _getPage403() |
|
| 686 | - { |
|
| 687 | - header("HTTP/1.0 403 Forbidden"); |
|
| 679 | + /** |
|
| 680 | + * get the page 403 |
|
| 681 | + * |
|
| 682 | + * @access private |
|
| 683 | + * @return void |
|
| 684 | + */ |
|
| 685 | + private function _getPage403() |
|
| 686 | + { |
|
| 687 | + header("HTTP/1.0 403 Forbidden"); |
|
| 688 | 688 | |
| 689 | - if (isset($this->_oRoutes->e403)) { |
|
| 689 | + if (isset($this->_oRoutes->e403)) { |
|
| 690 | 690 | |
| 691 | - $this->_oRoutes->e403->route = '/'; |
|
| 692 | - $_SERVER['REQUEST_URI'] = '/'; |
|
| 693 | - $this->_route($this->_oRoutes->e403, $_SERVER['REQUEST_URI']); |
|
| 694 | - } |
|
| 691 | + $this->_oRoutes->e403->route = '/'; |
|
| 692 | + $_SERVER['REQUEST_URI'] = '/'; |
|
| 693 | + $this->_route($this->_oRoutes->e403, $_SERVER['REQUEST_URI']); |
|
| 694 | + } |
|
| 695 | 695 | |
| 696 | - exit; |
|
| 697 | - } |
|
| 696 | + exit; |
|
| 697 | + } |
|
| 698 | 698 | |
| 699 | - /** |
|
| 700 | - * get the page 404 |
|
| 701 | - * |
|
| 702 | - * @access private |
|
| 703 | - * @return void |
|
| 704 | - */ |
|
| 705 | - private function _getPage404() |
|
| 706 | - { |
|
| 707 | - header("HTTP/1.0 404 Not Found"); |
|
| 699 | + /** |
|
| 700 | + * get the page 404 |
|
| 701 | + * |
|
| 702 | + * @access private |
|
| 703 | + * @return void |
|
| 704 | + */ |
|
| 705 | + private function _getPage404() |
|
| 706 | + { |
|
| 707 | + header("HTTP/1.0 404 Not Found"); |
|
| 708 | 708 | |
| 709 | - if (isset($this->_oRoutes->e404)) { |
|
| 709 | + if (isset($this->_oRoutes->e404)) { |
|
| 710 | 710 | |
| 711 | - $this->_oRoutes->e404->route = '/'; |
|
| 712 | - $_SERVER['REQUEST_URI'] = '/'; |
|
| 713 | - $this->_route($this->_oRoutes->e404, $_SERVER['REQUEST_URI']); |
|
| 714 | - } |
|
| 711 | + $this->_oRoutes->e404->route = '/'; |
|
| 712 | + $_SERVER['REQUEST_URI'] = '/'; |
|
| 713 | + $this->_route($this->_oRoutes->e404, $_SERVER['REQUEST_URI']); |
|
| 714 | + } |
|
| 715 | 715 | |
| 716 | - exit; |
|
| 717 | - } |
|
| 716 | + exit; |
|
| 717 | + } |
|
| 718 | 718 | |
| 719 | - /** |
|
| 720 | - * check the cache - just if it's not yet defined |
|
| 721 | - * |
|
| 722 | - * @access private |
|
| 723 | - * @param \stdClass $oCache object of cache configuration |
|
| 724 | - * @return void |
|
| 725 | - */ |
|
| 726 | - private function _checkCache(\stdClass $oCache) |
|
| 727 | - { |
|
| 728 | - /** |
|
| 729 | - * cache-control http |
|
| 730 | - */ |
|
| 719 | + /** |
|
| 720 | + * check the cache - just if it's not yet defined |
|
| 721 | + * |
|
| 722 | + * @access private |
|
| 723 | + * @param \stdClass $oCache object of cache configuration |
|
| 724 | + * @return void |
|
| 725 | + */ |
|
| 726 | + private function _checkCache(\stdClass $oCache) |
|
| 727 | + { |
|
| 728 | + /** |
|
| 729 | + * cache-control http |
|
| 730 | + */ |
|
| 731 | 731 | |
| 732 | - $sHearderValidity = false; |
|
| 733 | - $sHeader = "Cache-Control:"; |
|
| 732 | + $sHearderValidity = false; |
|
| 733 | + $sHeader = "Cache-Control:"; |
|
| 734 | 734 | |
| 735 | - if (isset($oCache->visibility) && ($oCache->visibility = 'public' || $oCache->visibility = 'private')) { |
|
| 735 | + if (isset($oCache->visibility) && ($oCache->visibility = 'public' || $oCache->visibility = 'private')) { |
|
| 736 | 736 | |
| 737 | - $sHearderValidity = true; |
|
| 738 | - $sHeader .= " ".$oCache->visibility.","; |
|
| 739 | - } |
|
| 737 | + $sHearderValidity = true; |
|
| 738 | + $sHeader .= " ".$oCache->visibility.","; |
|
| 739 | + } |
|
| 740 | 740 | |
| 741 | - if (isset($oCache->max_age)) { |
|
| 741 | + if (isset($oCache->max_age)) { |
|
| 742 | 742 | |
| 743 | - $sHearderValidity = true; |
|
| 744 | - $sHeader .= " maxage=".$oCache->max_age.","; |
|
| 745 | - } |
|
| 743 | + $sHearderValidity = true; |
|
| 744 | + $sHeader .= " maxage=".$oCache->max_age.","; |
|
| 745 | + } |
|
| 746 | 746 | |
| 747 | - if (isset($oCache->must_revalidate) && $oCache->must_revalidate === true) { |
|
| 747 | + if (isset($oCache->must_revalidate) && $oCache->must_revalidate === true) { |
|
| 748 | 748 | |
| 749 | - $sHearderValidity = true; |
|
| 750 | - $sHeader .= " must-revalidate,"; |
|
| 751 | - } |
|
| 749 | + $sHearderValidity = true; |
|
| 750 | + $sHeader .= " must-revalidate,"; |
|
| 751 | + } |
|
| 752 | 752 | |
| 753 | - if ($sHearderValidity === true) { |
|
| 753 | + if ($sHearderValidity === true) { |
|
| 754 | 754 | |
| 755 | - $sHeader = substr($sHeader, 0, -1); |
|
| 755 | + $sHeader = substr($sHeader, 0, -1); |
|
| 756 | 756 | |
| 757 | - if (!headers_sent()) { header($sHeader); } |
|
| 758 | - } |
|
| 757 | + if (!headers_sent()) { header($sHeader); } |
|
| 758 | + } |
|
| 759 | 759 | |
| 760 | - /** |
|
| 761 | - * ETag http |
|
| 762 | - */ |
|
| 760 | + /** |
|
| 761 | + * ETag http |
|
| 762 | + */ |
|
| 763 | 763 | |
| 764 | - if (isset($oCache->ETag)) { header("ETag: \"".$oCache->ETag."\""); } |
|
| 764 | + if (isset($oCache->ETag)) { header("ETag: \"".$oCache->ETag."\""); } |
|
| 765 | 765 | |
| 766 | - /** |
|
| 767 | - * expire |
|
| 768 | - */ |
|
| 766 | + /** |
|
| 767 | + * expire |
|
| 768 | + */ |
|
| 769 | 769 | |
| 770 | - if (isset($oCache->max_age)) { if (!headers_sent()) { header('Expires: '.gmdate('D, d M Y H:i:s', time() + $oCache->max_age).' GMT'); } } |
|
| 770 | + if (isset($oCache->max_age)) { if (!headers_sent()) { header('Expires: '.gmdate('D, d M Y H:i:s', time() + $oCache->max_age).' GMT'); } } |
|
| 771 | 771 | |
| 772 | - /** |
|
| 773 | - * Last-Modified http |
|
| 774 | - */ |
|
| 772 | + /** |
|
| 773 | + * Last-Modified http |
|
| 774 | + */ |
|
| 775 | 775 | |
| 776 | - if (isset($oCache->last_modified)) { if (!headers_sent()) { header('Last-Modified: '.gmdate('D, d M Y H:i:s', time() + $oCache->last_modified).' GMT'); } } |
|
| 776 | + if (isset($oCache->last_modified)) { if (!headers_sent()) { header('Last-Modified: '.gmdate('D, d M Y H:i:s', time() + $oCache->last_modified).' GMT'); } } |
|
| 777 | 777 | |
| 778 | - /** |
|
| 779 | - * vary http |
|
| 780 | - */ |
|
| 778 | + /** |
|
| 779 | + * vary http |
|
| 780 | + */ |
|
| 781 | 781 | |
| 782 | - if (isset($oCache->vary)) { header('Vary: '.$oCache->vary); } |
|
| 783 | - } |
|
| 782 | + if (isset($oCache->vary)) { header('Vary: '.$oCache->vary); } |
|
| 783 | + } |
|
| 784 | 784 | |
| 785 | - /** |
|
| 786 | - * Sets a logger instance on the object |
|
| 787 | - * |
|
| 788 | - * @access private |
|
| 789 | - * @param LoggerInterface $logger |
|
| 790 | - * @return null |
|
| 791 | - */ |
|
| 792 | - public function setLogger(LoggerInterface $logger) { |
|
| 785 | + /** |
|
| 786 | + * Sets a logger instance on the object |
|
| 787 | + * |
|
| 788 | + * @access private |
|
| 789 | + * @param LoggerInterface $logger |
|
| 790 | + * @return null |
|
| 791 | + */ |
|
| 792 | + public function setLogger(LoggerInterface $logger) { |
|
| 793 | 793 | |
| 794 | - $this->_oLogger = $logger; |
|
| 795 | - } |
|
| 794 | + $this->_oLogger = $logger; |
|
| 795 | + } |
|
| 796 | 796 | } |
@@ -195,8 +195,7 @@ discard block |
||
| 195 | 195 | if ($mReturn === 403) { |
| 196 | 196 | |
| 197 | 197 | $this->_getPage403(); |
| 198 | - } |
|
| 199 | - else if ($mReturn === true) { |
|
| 198 | + } else if ($mReturn === true) { |
|
| 200 | 199 | |
| 201 | 200 | if (isset($oRoute->cache)) { $this->_checkCache($oRoute->cache); } |
| 202 | 201 | |
@@ -211,8 +210,7 @@ discard block |
||
| 211 | 210 | } |
| 212 | 211 | } else if (Request::isCliRequest()) { |
| 213 | 212 | |
| 214 | - if (isset($_SERVER['argv'])) { $aArguments = $_SERVER['argv']; } |
|
| 215 | - else { $aArguments = []; } |
|
| 213 | + if (isset($_SERVER['argv'])) { $aArguments = $_SERVER['argv']; } else { $aArguments = []; } |
|
| 216 | 214 | |
| 217 | 215 | define('PORTAL', 'Batch'); |
| 218 | 216 | set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
@@ -224,8 +222,7 @@ discard block |
||
| 224 | 222 | $aArguments[1] = "phpunit"; |
| 225 | 223 | } else if (isset($aArguments[1])) { |
| 226 | 224 | $sBatchName = $aArguments[1]; |
| 227 | - } |
|
| 228 | - else { |
|
| 225 | + } else { |
|
| 229 | 226 | $aArguments[1] = 'help'; |
| 230 | 227 | $sBatchName = $aArguments[1]; |
| 231 | 228 | } |
@@ -320,8 +317,7 @@ discard block |
||
| 320 | 317 | } |
| 321 | 318 | } |
| 322 | 319 | } |
| 323 | - } |
|
| 324 | - else if (defined('STDIN')) { |
|
| 320 | + } else if (defined('STDIN')) { |
|
| 325 | 321 | |
| 326 | 322 | $oBatch = Config::get('Route')->batch->script->{$sRoute}; |
| 327 | 323 | echo $this->_loadController($oBatch->controller, $oBatch->action, $aParams); |
@@ -383,8 +379,7 @@ discard block |
||
| 383 | 379 | }, |
| 384 | 380 | $sRoute |
| 385 | 381 | ); |
| 386 | - } |
|
| 387 | - else { |
|
| 382 | + } else { |
|
| 388 | 383 | |
| 389 | 384 | $sFinalRoute = '.*'; |
| 390 | 385 | } |
@@ -434,8 +429,7 @@ discard block |
||
| 434 | 429 | |
| 435 | 430 | $oMobileDetect = new \Mobile_Detect; |
| 436 | 431 | |
| 437 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
| 438 | - else { $sCacheExt = ''; } |
|
| 432 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } else { $sCacheExt = ''; } |
|
| 439 | 433 | |
| 440 | 434 | $mCacheReturn = Cache::get($RequestUri.$sCacheExt, $oRoute->cache->max_age); |
| 441 | 435 | |
@@ -465,8 +459,7 @@ discard block |
||
| 465 | 459 | |
| 466 | 460 | header('Content-type: image/jpeg'); |
| 467 | 461 | } |
| 468 | - } |
|
| 469 | - else { |
|
| 462 | + } else { |
|
| 470 | 463 | |
| 471 | 464 | header('Content-type: text/html; charset='.$sCharset.''); |
| 472 | 465 | } |
@@ -509,8 +502,7 @@ discard block |
||
| 509 | 502 | $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
| 510 | 503 | |
| 511 | 504 | } |
| 512 | - } |
|
| 513 | - else { |
|
| 505 | + } else { |
|
| 514 | 506 | |
| 515 | 507 | $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
| 516 | 508 | } |
@@ -522,8 +514,7 @@ discard block |
||
| 522 | 514 | $mReturn = json_encode($mReturn, JSON_PRETTY_PRINT); |
| 523 | 515 | } |
| 524 | 516 | } |
| 525 | - } |
|
| 526 | - else if (isset($oRoute->template) && isset($oRoute->layout) && $oRoute->layout === true) { |
|
| 517 | + } else if (isset($oRoute->template) && isset($oRoute->layout) && $oRoute->layout === true) { |
|
| 527 | 518 | |
| 528 | 519 | define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
| 529 | 520 | set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
@@ -540,8 +531,7 @@ discard block |
||
| 540 | 531 | |
| 541 | 532 | $mReturn = $oLayout->assign('model', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$oRoute->template.'.tpl') |
| 542 | 533 | ->fetch(); |
| 543 | - } |
|
| 544 | - else if (isset($oRoute->template)) { |
|
| 534 | + } else if (isset($oRoute->template)) { |
|
| 545 | 535 | |
| 546 | 536 | define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
| 547 | 537 | set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
@@ -565,8 +555,7 @@ discard block |
||
| 565 | 555 | |
| 566 | 556 | $oMobileDetect = new \Mobile_Detect; |
| 567 | 557 | |
| 568 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
| 569 | - else { $sCacheExt = ''; } |
|
| 558 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } else { $sCacheExt = ''; } |
|
| 570 | 559 | |
| 571 | 560 | if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
| 572 | 561 | |
@@ -620,8 +609,7 @@ discard block |
||
| 620 | 609 | |
| 621 | 610 | $oMobileDetect = new \Mobile_Detect; |
| 622 | 611 | |
| 623 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
| 624 | - else { $sCacheExt = ''; } |
|
| 612 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } else { $sCacheExt = ''; } |
|
| 625 | 613 | |
| 626 | 614 | $mCacheReturn = Cache::get($sActionName.$sCacheExt, $aPhpDoc['Cache']['maxage']); |
| 627 | 615 | |
@@ -662,8 +650,7 @@ discard block |
||
| 662 | 650 | |
| 663 | 651 | $oMobileDetect = new \Mobile_Detect; |
| 664 | 652 | |
| 665 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
| 666 | - else { $sCacheExt = ''; } |
|
| 653 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } else { $sCacheExt = ''; } |
|
| 667 | 654 | |
| 668 | 655 | if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
| 669 | 656 | |
@@ -61,26 +61,26 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | $sActualDirectory = str_replace(DIRECTORY_SEPARATOR, '/', __DIR__); |
| 63 | 63 | $sPrivatePath = str_replace('/Batch/app/Controller', DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app', $sActualDirectory).DIRECTORY_SEPARATOR; |
| 64 | - $sPublicPath = str_replace('/Batch/app/Controller', DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'public', $sActualDirectory).DIRECTORY_SEPARATOR; |
|
| 64 | + $sPublicPath = str_replace('/Batch/app/Controller', DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'public', $sActualDirectory).DIRECTORY_SEPARATOR; |
|
| 65 | 65 | |
| 66 | - if (!is_writable($sActualDirectory.'/../../../')) { |
|
| 66 | + if (!is_writable($sActualDirectory.'/../../../')) { |
|
| 67 | 67 | |
| 68 | - echo 'The batch can`t create public folders for '.$sPortal.'! Please check the rights.'; |
|
| 69 | - throw new \Exception('The batch can`t create public folders for '.$sPortal.'! Please check the rights.'); |
|
| 70 | - } |
|
| 71 | - else { |
|
| 68 | + echo 'The batch can`t create public folders for '.$sPortal.'! Please check the rights.'; |
|
| 69 | + throw new \Exception('The batch can`t create public folders for '.$sPortal.'! Please check the rights.'); |
|
| 70 | + } |
|
| 71 | + else { |
|
| 72 | 72 | |
| 73 | - if (!file_exists($sPrivatePath.'Controller')) { |
|
| 73 | + if (!file_exists($sPrivatePath.'Controller')) { |
|
| 74 | 74 | |
| 75 | - mkdir($sPublicPath . 'css', 0777, true); |
|
| 76 | - mkdir($sPublicPath . 'js', 0777, true); |
|
| 77 | - mkdir($sPublicPath . 'img', 0777, true); |
|
| 78 | - } |
|
| 79 | - else { |
|
| 75 | + mkdir($sPublicPath . 'css', 0777, true); |
|
| 76 | + mkdir($sPublicPath . 'js', 0777, true); |
|
| 77 | + mkdir($sPublicPath . 'img', 0777, true); |
|
| 78 | + } |
|
| 79 | + else { |
|
| 80 | 80 | |
| 81 | - echo 'The Project (public part) ' . $sPrivatePath . " exists\n"; |
|
| 82 | - } |
|
| 83 | - } |
|
| 81 | + echo 'The Project (public part) ' . $sPrivatePath . " exists\n"; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | if (!is_writable($sActualDirectory.'/../../../')) { |
| 86 | 86 | |
@@ -98,19 +98,19 @@ discard block |
||
| 98 | 98 | mkdir($sPrivatePath . 'conf', 0777, true); |
| 99 | 99 | mkdir($sPrivatePath . 'common', 0777, true); |
| 100 | 100 | |
| 101 | - $sContent = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'Controller.php'); |
|
| 102 | - $sContent = str_replace('Batch', $sPortal, $sContent); |
|
| 103 | - file_put_contents($sPrivatePath.'common'.DIRECTORY_SEPARATOR.'Controller.php', $sContent); |
|
| 101 | + $sContent = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'Controller.php'); |
|
| 102 | + $sContent = str_replace('Batch', $sPortal, $sContent); |
|
| 103 | + file_put_contents($sPrivatePath.'common'.DIRECTORY_SEPARATOR.'Controller.php', $sContent); |
|
| 104 | 104 | |
| 105 | - $sContent = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'Model.php'); |
|
| 106 | - $sContent = str_replace('Batch', $sPortal, $sContent); |
|
| 107 | - file_put_contents($sPrivatePath.'common'.DIRECTORY_SEPARATOR.'Model.php', $sContent); |
|
| 105 | + $sContent = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'Model.php'); |
|
| 106 | + $sContent = str_replace('Batch', $sPortal, $sContent); |
|
| 107 | + file_put_contents($sPrivatePath.'common'.DIRECTORY_SEPARATOR.'Model.php', $sContent); |
|
| 108 | 108 | |
| 109 | - $sContent = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'Entity.php'); |
|
| 110 | - $sContent = str_replace('Batch', $sPortal, $sContent); |
|
| 111 | - file_put_contents($sPrivatePath.'common'.DIRECTORY_SEPARATOR.'Entity.php', $sContent); |
|
| 109 | + $sContent = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'Entity.php'); |
|
| 110 | + $sContent = str_replace('Batch', $sPortal, $sContent); |
|
| 111 | + file_put_contents($sPrivatePath.'common'.DIRECTORY_SEPARATOR.'Entity.php', $sContent); |
|
| 112 | 112 | |
| 113 | - $content = "<?php |
|
| 113 | + $content = "<?php |
|
| 114 | 114 | |
| 115 | 115 | namespace Venus\\src\\".$sPortal."\\Controller; |
| 116 | 116 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | "; |
| 131 | 131 | |
| 132 | - file_put_contents($sPrivatePath.'Controller'.DIRECTORY_SEPARATOR.$sPortal.'.php', $content); |
|
| 132 | + file_put_contents($sPrivatePath.'Controller'.DIRECTORY_SEPARATOR.$sPortal.'.php', $content); |
|
| 133 | 133 | } |
| 134 | 134 | else { |
| 135 | 135 | |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | echo 'The project '.$sPortal.' is created!'; |
| 141 | 141 | |
| 142 | 142 | |
| 143 | - echo "\n\n"; |
|
| 144 | - echo Bash::setBackground(" ", 'green'); |
|
| 145 | - echo Bash::setBackground(" [OK] The bundle is created ", 'green'); |
|
| 146 | - echo Bash::setBackground(" ", 'green'); |
|
| 147 | - echo "\n\n"; |
|
| 143 | + echo "\n\n"; |
|
| 144 | + echo Bash::setBackground(" ", 'green'); |
|
| 145 | + echo Bash::setBackground(" [OK] The bundle is created ", 'green'); |
|
| 146 | + echo Bash::setBackground(" ", 'green'); |
|
| 147 | + echo "\n\n"; |
|
| 148 | 148 | } |
| 149 | 149 | } |
@@ -7,35 +7,35 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Help extends Controller |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Constructs a test case with the given name. |
|
| 12 | - * |
|
| 13 | - */ |
|
| 14 | - public function __construct() |
|
| 15 | - { |
|
| 16 | - parent::__construct(); |
|
| 17 | - } |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * new method to launch a web server |
|
| 21 | - * @param array $options |
|
| 22 | - * @tutorial php bin/console server:run |
|
| 23 | - * php bin/console server:run -a 192.168.0.1:8000 |
|
| 24 | - */ |
|
| 25 | - public function load(array $options = array()) |
|
| 26 | - { |
|
| 27 | - $BatchConf = Config::get('Route')->batch->script; |
|
| 28 | - |
|
| 29 | - foreach ($BatchConf as $key => $batchContent) { |
|
| 30 | - |
|
| 31 | - echo '-----------------------------------------------------------------------------------------------------'."\n"; |
|
| 32 | - echo '|'.$key.' => '.$batchContent->description."\n|\n"; |
|
| 33 | - |
|
| 34 | - foreach ($batchContent->options as $keyOption => $optionContent) { |
|
| 35 | - |
|
| 36 | - echo '| '.$keyOption.' : '.$optionContent->description."\n"; |
|
| 37 | - } |
|
| 38 | - echo '-----------------------------------------------------------------------------------------------------'."\n"; |
|
| 39 | - } |
|
| 40 | - } |
|
| 10 | + /** |
|
| 11 | + * Constructs a test case with the given name. |
|
| 12 | + * |
|
| 13 | + */ |
|
| 14 | + public function __construct() |
|
| 15 | + { |
|
| 16 | + parent::__construct(); |
|
| 17 | + } |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * new method to launch a web server |
|
| 21 | + * @param array $options |
|
| 22 | + * @tutorial php bin/console server:run |
|
| 23 | + * php bin/console server:run -a 192.168.0.1:8000 |
|
| 24 | + */ |
|
| 25 | + public function load(array $options = array()) |
|
| 26 | + { |
|
| 27 | + $BatchConf = Config::get('Route')->batch->script; |
|
| 28 | + |
|
| 29 | + foreach ($BatchConf as $key => $batchContent) { |
|
| 30 | + |
|
| 31 | + echo '-----------------------------------------------------------------------------------------------------'."\n"; |
|
| 32 | + echo '|'.$key.' => '.$batchContent->description."\n|\n"; |
|
| 33 | + |
|
| 34 | + foreach ($batchContent->options as $keyOption => $optionContent) { |
|
| 35 | + |
|
| 36 | + echo '| '.$keyOption.' : '.$optionContent->description."\n"; |
|
| 37 | + } |
|
| 38 | + echo '-----------------------------------------------------------------------------------------------------'."\n"; |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | 41 | } |