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