@@ -26,13 +26,13 @@ |
||
26 | 26 | public static function read($sConfigFile) |
27 | 27 | { |
28 | 28 | $sConfigFile = realpath($sConfigFile); |
29 | - if(!is_readable($sConfigFile)) |
|
29 | + if (!is_readable($sConfigFile)) |
|
30 | 30 | { |
31 | 31 | throw new \Jaxon\Utils\Config\Exception\File(jaxon_trans('config.errors.file.access', ['path' => $sConfigFile])); |
32 | 32 | } |
33 | 33 | $sFileContent = file_get_contents($sConfigFile); |
34 | 34 | $aConfigOptions = json_decode($sFileContent, true); |
35 | - if(!is_array($aConfigOptions)) |
|
35 | + if (!is_array($aConfigOptions)) |
|
36 | 36 | { |
37 | 37 | throw new \Jaxon\Utils\Config\Exception\File(jaxon_trans('config.errors.file.content', ['path' => $sConfigFile])); |
38 | 38 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function __construct(array $aOptions = [], $sKeys = '') |
35 | 35 | { |
36 | - if(count($aOptions) > 0) |
|
36 | + if (count($aOptions) > 0) |
|
37 | 37 | { |
38 | 38 | $this->setOptions($aOptions, $sKeys); |
39 | 39 | } |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | $sPrefix = trim((string)$sPrefix); |
67 | 67 | $nDepth = intval($nDepth); |
68 | 68 | // Check the max depth |
69 | - if($nDepth < 0 || $nDepth > 9) |
|
69 | + if ($nDepth < 0 || $nDepth > 9) |
|
70 | 70 | { |
71 | 71 | throw new \Jaxon\Utils\Config\Exception\Data(jaxon_trans('config.errors.data.depth', |
72 | 72 | ['key' => $sPrefix, 'depth' => $nDepth])); |
73 | 73 | } |
74 | - foreach($aOptions as $sName => $xOption) |
|
74 | + foreach ($aOptions as $sName => $xOption) |
|
75 | 75 | { |
76 | - if(is_int($sName)) |
|
76 | + if (is_int($sName)) |
|
77 | 77 | { |
78 | 78 | continue; |
79 | 79 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // Save the value of this option |
84 | 84 | $this->aOptions[$sFullName] = $xOption; |
85 | 85 | // Save the values of its sub-options |
86 | - if(is_array($xOption)) |
|
86 | + if (is_array($xOption)) |
|
87 | 87 | { |
88 | 88 | // Recursively read the options in the array |
89 | 89 | $this->_setOptions($xOption, $sFullName, $nDepth + 1); |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | $aKeys = explode('.', (string)$sKeys); |
106 | 106 | foreach ($aKeys as $sKey) |
107 | 107 | { |
108 | - if(($sKey)) |
|
108 | + if (($sKey)) |
|
109 | 109 | { |
110 | - if(!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
110 | + if (!array_key_exists($sKey, $aOptions) || !is_array($aOptions[$sKey])) |
|
111 | 111 | { |
112 | 112 | return; |
113 | 113 | } |
@@ -157,13 +157,12 @@ discard block |
||
157 | 157 | $sPrefix = rtrim($sPrefix, '.') . '.'; |
158 | 158 | $sPrefixLen = strlen($sPrefix); |
159 | 159 | $aOptions = []; |
160 | - foreach($this->aOptions as $sName => $xValue) |
|
160 | + foreach ($this->aOptions as $sName => $xValue) |
|
161 | 161 | { |
162 | - if(substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
162 | + if (substr($sName, 0, $sPrefixLen) == $sPrefix) |
|
163 | 163 | { |
164 | 164 | $iNextDotPos = strpos($sName, '.', $sPrefixLen); |
165 | - $sOptionName = $iNextDotPos === false ? substr($sName, $sPrefixLen) : |
|
166 | - substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
165 | + $sOptionName = $iNextDotPos === false ? substr($sName, $sPrefixLen) : substr($sName, $sPrefixLen, $iNextDotPos - $sPrefixLen); |
|
167 | 166 | $aOptions[$sOptionName] = $sPrefix . $sOptionName; |
168 | 167 | } |
169 | 168 | } |
@@ -26,12 +26,12 @@ |
||
26 | 26 | public static function read($sConfigFile) |
27 | 27 | { |
28 | 28 | $sConfigFile = realpath($sConfigFile); |
29 | - if(!is_readable($sConfigFile)) |
|
29 | + if (!is_readable($sConfigFile)) |
|
30 | 30 | { |
31 | 31 | throw new \Jaxon\Utils\Config\Exception\File(jaxon_trans('config.errors.file.access', ['path' => $sConfigFile])); |
32 | 32 | } |
33 | 33 | $aConfigOptions = include($sConfigFile); |
34 | - if(!is_array($aConfigOptions)) |
|
34 | + if (!is_array($aConfigOptions)) |
|
35 | 35 | { |
36 | 36 | throw new \Jaxon\Utils\Config\Exception\File(jaxon_trans('config.errors.file.content', ['path' => $sConfigFile])); |
37 | 37 | } |
@@ -26,16 +26,16 @@ |
||
26 | 26 | public static function read($sConfigFile) |
27 | 27 | { |
28 | 28 | $sConfigFile = realpath($sConfigFile); |
29 | - if(!extension_loaded('yaml')) |
|
29 | + if (!extension_loaded('yaml')) |
|
30 | 30 | { |
31 | 31 | throw new \Jaxon\Utils\Config\Exception\Yaml(jaxon_trans('config.errors.yaml.install')); |
32 | 32 | } |
33 | - if(!is_readable($sConfigFile)) |
|
33 | + if (!is_readable($sConfigFile)) |
|
34 | 34 | { |
35 | 35 | throw new \Jaxon\Utils\Config\Exception\File(jaxon_trans('config.errors.file.access', ['path' => $sConfigFile])); |
36 | 36 | } |
37 | 37 | $aConfigOptions = yaml_parse_file($sConfigFile); |
38 | - if(!is_array($aConfigOptions)) |
|
38 | + if (!is_array($aConfigOptions)) |
|
39 | 39 | { |
40 | 40 | throw new \Jaxon\Utils\Config\Exception\File(jaxon_trans('config.errors.file.content', ['path' => $sConfigFile])); |
41 | 41 | } |
@@ -24,7 +24,7 @@ |
||
24 | 24 | public function read($sConfigFile) |
25 | 25 | { |
26 | 26 | $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION); |
27 | - switch($sExt) |
|
27 | + switch ($sExt) |
|
28 | 28 | { |
29 | 29 | case 'php': |
30 | 30 | $aConfigOptions = Php::read($sConfigFile); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | protected function store() |
42 | 42 | { |
43 | - if(!$this->xStore) |
|
43 | + if (!$this->xStore) |
|
44 | 44 | { |
45 | 45 | $this->xStore = new Store(); |
46 | 46 | } |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | $sNamespace = $this->xManager->getDefaultNamespace(); |
94 | 94 | // Get the namespace from the view name |
95 | 95 | $iSeparatorPosition = strrpos($sViewName, '::'); |
96 | - if($iSeparatorPosition !== false) |
|
96 | + if ($iSeparatorPosition !== false) |
|
97 | 97 | { |
98 | 98 | $sNamespace = substr($sViewName, 0, $iSeparatorPosition); |
99 | 99 | } |
100 | 100 | $aRenderers = $this->xManager->getRenderers(); |
101 | - if(!key_exists($sNamespace, $aRenderers)) |
|
101 | + if (!key_exists($sNamespace, $aRenderers)) |
|
102 | 102 | { |
103 | 103 | // Cannot render a view if there's no renderer corresponding to the namespace. |
104 | 104 | return null; |
@@ -48,7 +48,7 @@ |
||
48 | 48 | $sViewName = $store->getViewName(); |
49 | 49 | $sNamespace = $store->getNamespace(); |
50 | 50 | // In this view renderer, the namespace must always be prepended to the view name. |
51 | - if(substr($sViewName, 0, strlen($sNamespace) + 2) != $sNamespace . '::') |
|
51 | + if (substr($sViewName, 0, strlen($sNamespace) + 2) != $sNamespace . '::') |
|
52 | 52 | { |
53 | 53 | $sViewName = $sNamespace . '::' . $sViewName; |
54 | 54 | } |
@@ -81,8 +81,7 @@ |
||
81 | 81 | if(key_exists($sRenderer, $this->aNamespaces)) |
82 | 82 | { |
83 | 83 | $this->aNamespaces[$sRenderer][] = $aNamespace; |
84 | - } |
|
85 | - else |
|
84 | + } else |
|
86 | 85 | { |
87 | 86 | $this->aNamespaces[$sRenderer] = [$aNamespace]; |
88 | 87 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | 'directory' => $sDirectory, |
79 | 79 | 'extension' => $sExtension, |
80 | 80 | ]; |
81 | - if(key_exists($sRenderer, $this->aNamespaces)) |
|
81 | + if (key_exists($sRenderer, $this->aNamespaces)) |
|
82 | 82 | { |
83 | 83 | $this->aNamespaces[$sRenderer][] = $aNamespace; |
84 | 84 | } |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | public function addNamespaces($xAppConfig) |
100 | 100 | { |
101 | 101 | $this->sDefaultNamespace = $xAppConfig->getOption('options.views.default', false); |
102 | - if(is_array($namespaces = $xAppConfig->getOptionNames('views'))) |
|
102 | + if (is_array($namespaces = $xAppConfig->getOptionNames('views'))) |
|
103 | 103 | { |
104 | - foreach($namespaces as $namespace => $option) |
|
104 | + foreach ($namespaces as $namespace => $option) |
|
105 | 105 | { |
106 | 106 | // If no default namespace is defined, use the first one as default. |
107 | - if($this->sDefaultNamespace == false) |
|
107 | + if ($this->sDefaultNamespace == false) |
|
108 | 108 | { |
109 | 109 | $this->sDefaultNamespace = (string)$namespace; |
110 | 110 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function getRenderer($sId = '') |
128 | 128 | { |
129 | - if(!$sId) |
|
129 | + if (!$sId) |
|
130 | 130 | { |
131 | 131 | // Return the view renderer facade |
132 | 132 | return jaxon()->di()->get(\Jaxon\Utils\View\Renderer::class); |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | jaxon()->di()->set('jaxon.app.view.base.' . $sId, $xClosure); |
150 | 150 | |
151 | 151 | // Return the initialized view renderer |
152 | - jaxon()->di()->set('jaxon.app.view.' . $sId, function ($c) use ($sId) { |
|
152 | + jaxon()->di()->set('jaxon.app.view.' . $sId, function($c) use ($sId) { |
|
153 | 153 | // Get the defined renderer |
154 | 154 | $renderer = $c['jaxon.app.view.base.' . $sId]; |
155 | 155 | |
156 | 156 | // Init the renderer with the template namespaces |
157 | - if(key_exists($sId, $this->aNamespaces)) |
|
157 | + if (key_exists($sId, $this->aNamespaces)) |
|
158 | 158 | { |
159 | - foreach($this->aNamespaces[$sId] as $ns) |
|
159 | + foreach ($this->aNamespaces[$sId] as $ns) |
|
160 | 160 | { |
161 | 161 | $renderer->addNamespace($ns['namespace'], $ns['directory'], $ns['extension']); |
162 | 162 | } |
@@ -25,16 +25,16 @@ discard block |
||
25 | 25 | { |
26 | 26 | $aURL = []; |
27 | 27 | // Try to get the request URL |
28 | - if(!empty($_SERVER['REQUEST_URI'])) |
|
28 | + if (!empty($_SERVER['REQUEST_URI'])) |
|
29 | 29 | { |
30 | - $_SERVER['REQUEST_URI'] = str_replace(['"',"'",'<','>'], ['%22','%27','%3C','%3E'], $_SERVER['REQUEST_URI']); |
|
30 | + $_SERVER['REQUEST_URI'] = str_replace(['"', "'", '<', '>'], ['%22', '%27', '%3C', '%3E'], $_SERVER['REQUEST_URI']); |
|
31 | 31 | $aURL = parse_url($_SERVER['REQUEST_URI']); |
32 | 32 | } |
33 | 33 | |
34 | 34 | // Fill in the empty values |
35 | - if(empty($aURL['scheme'])) |
|
35 | + if (empty($aURL['scheme'])) |
|
36 | 36 | { |
37 | - if(!empty($_SERVER['HTTP_SCHEME'])) |
|
37 | + if (!empty($_SERVER['HTTP_SCHEME'])) |
|
38 | 38 | { |
39 | 39 | $aURL['scheme'] = $_SERVER['HTTP_SCHEME']; |
40 | 40 | } |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | - if(empty($aURL['host'])) |
|
47 | + if (empty($aURL['host'])) |
|
48 | 48 | { |
49 | - if(!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) |
|
49 | + if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) |
|
50 | 50 | { |
51 | - if(strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ':') > 0) |
|
51 | + if (strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ':') > 0) |
|
52 | 52 | { |
53 | 53 | list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_X_FORWARDED_HOST']); |
54 | 54 | } |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | $aURL['host'] = $_SERVER['HTTP_X_FORWARDED_HOST']; |
58 | 58 | } |
59 | 59 | } |
60 | - elseif(!empty($_SERVER['HTTP_HOST'])) |
|
60 | + elseif (!empty($_SERVER['HTTP_HOST'])) |
|
61 | 61 | { |
62 | - if(strpos($_SERVER['HTTP_HOST'], ':') > 0) |
|
62 | + if (strpos($_SERVER['HTTP_HOST'], ':') > 0) |
|
63 | 63 | { |
64 | 64 | list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_HOST']); |
65 | 65 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $aURL['host'] = $_SERVER['HTTP_HOST']; |
69 | 69 | } |
70 | 70 | } |
71 | - elseif(!empty($_SERVER['SERVER_NAME'])) |
|
71 | + elseif (!empty($_SERVER['SERVER_NAME'])) |
|
72 | 72 | { |
73 | 73 | $aURL['host'] = $_SERVER['SERVER_NAME']; |
74 | 74 | } |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | - if(empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) |
|
81 | + if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) |
|
82 | 82 | { |
83 | 83 | $aURL['port'] = $_SERVER['SERVER_PORT']; |
84 | 84 | } |
85 | 85 | |
86 | - if(!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0) |
|
86 | + if (!empty($aURL['path']) && strlen(basename($aURL['path'])) == 0) |
|
87 | 87 | { |
88 | 88 | unset($aURL['path']); |
89 | 89 | } |
90 | 90 | |
91 | - if(empty($aURL['path'])) |
|
91 | + if (empty($aURL['path'])) |
|
92 | 92 | { |
93 | - if(!empty($_SERVER['PATH_INFO'])) |
|
93 | + if (!empty($_SERVER['PATH_INFO'])) |
|
94 | 94 | { |
95 | 95 | $sPath = parse_url($_SERVER['PATH_INFO']); |
96 | 96 | } |
@@ -98,61 +98,61 @@ discard block |
||
98 | 98 | { |
99 | 99 | $sPath = parse_url($_SERVER['PHP_SELF']); |
100 | 100 | } |
101 | - if(isset($sPath['path'])) |
|
101 | + if (isset($sPath['path'])) |
|
102 | 102 | { |
103 | - $aURL['path'] = str_replace(['"',"'",'<','>'], ['%22','%27','%3C','%3E'], $sPath['path']); |
|
103 | + $aURL['path'] = str_replace(['"', "'", '<', '>'], ['%22', '%27', '%3C', '%3E'], $sPath['path']); |
|
104 | 104 | } |
105 | 105 | unset($sPath); |
106 | 106 | } |
107 | 107 | |
108 | - if(empty($aURL['query']) && !empty($_SERVER['QUERY_STRING'])) |
|
108 | + if (empty($aURL['query']) && !empty($_SERVER['QUERY_STRING'])) |
|
109 | 109 | { |
110 | 110 | $aURL['query'] = $_SERVER['QUERY_STRING']; |
111 | 111 | } |
112 | 112 | |
113 | - if(!empty($aURL['query'])) |
|
113 | + if (!empty($aURL['query'])) |
|
114 | 114 | { |
115 | - $aURL['query'] = '?'.$aURL['query']; |
|
115 | + $aURL['query'] = '?' . $aURL['query']; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | // Build the URL: Start with scheme, user and pass |
119 | - $sURL = $aURL['scheme'].'://'; |
|
120 | - if(!empty($aURL['user'])) |
|
119 | + $sURL = $aURL['scheme'] . '://'; |
|
120 | + if (!empty($aURL['user'])) |
|
121 | 121 | { |
122 | - $sURL.= $aURL['user']; |
|
123 | - if(!empty($aURL['pass'])) |
|
122 | + $sURL .= $aURL['user']; |
|
123 | + if (!empty($aURL['pass'])) |
|
124 | 124 | { |
125 | - $sURL.= ':'.$aURL['pass']; |
|
125 | + $sURL .= ':' . $aURL['pass']; |
|
126 | 126 | } |
127 | - $sURL.= '@'; |
|
127 | + $sURL .= '@'; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | // Add the host |
131 | - $sURL.= $aURL['host']; |
|
131 | + $sURL .= $aURL['host']; |
|
132 | 132 | |
133 | 133 | // Add the port if needed |
134 | - if(!empty($aURL['port']) |
|
134 | + if (!empty($aURL['port']) |
|
135 | 135 | && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) |
136 | 136 | || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) |
137 | 137 | { |
138 | - $sURL.= ':'.$aURL['port']; |
|
138 | + $sURL .= ':' . $aURL['port']; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | // Add the path and the query string |
142 | - $sURL.= $aURL['path'].@$aURL['query']; |
|
142 | + $sURL .= $aURL['path'] . @$aURL['query']; |
|
143 | 143 | |
144 | 144 | // Clean up |
145 | 145 | unset($aURL); |
146 | 146 | |
147 | 147 | $aURL = explode("?", $sURL); |
148 | 148 | |
149 | - if(1 < count($aURL)) |
|
149 | + if (1 < count($aURL)) |
|
150 | 150 | { |
151 | 151 | $aQueries = explode("&", $aURL[1]); |
152 | 152 | |
153 | - foreach($aQueries as $sKey => $sQuery) |
|
153 | + foreach ($aQueries as $sKey => $sQuery) |
|
154 | 154 | { |
155 | - if("jxnGenerate" == substr($sQuery, 0, 11)) |
|
155 | + if ("jxnGenerate" == substr($sQuery, 0, 11)) |
|
156 | 156 | unset($aQueries[$sKey]); |
157 | 157 | } |
158 | 158 |
@@ -37,8 +37,7 @@ discard block |
||
37 | 37 | if(!empty($_SERVER['HTTP_SCHEME'])) |
38 | 38 | { |
39 | 39 | $aURL['scheme'] = $_SERVER['HTTP_SCHEME']; |
40 | - } |
|
41 | - else |
|
40 | + } else |
|
42 | 41 | { |
43 | 42 | $aURL['scheme'] = ((!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http'); |
44 | 43 | } |
@@ -51,28 +50,23 @@ discard block |
||
51 | 50 | if(strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ':') > 0) |
52 | 51 | { |
53 | 52 | list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_X_FORWARDED_HOST']); |
54 | - } |
|
55 | - else |
|
53 | + } else |
|
56 | 54 | { |
57 | 55 | $aURL['host'] = $_SERVER['HTTP_X_FORWARDED_HOST']; |
58 | 56 | } |
59 | - } |
|
60 | - elseif(!empty($_SERVER['HTTP_HOST'])) |
|
57 | + } elseif(!empty($_SERVER['HTTP_HOST'])) |
|
61 | 58 | { |
62 | 59 | if(strpos($_SERVER['HTTP_HOST'], ':') > 0) |
63 | 60 | { |
64 | 61 | list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_HOST']); |
65 | - } |
|
66 | - else |
|
62 | + } else |
|
67 | 63 | { |
68 | 64 | $aURL['host'] = $_SERVER['HTTP_HOST']; |
69 | 65 | } |
70 | - } |
|
71 | - elseif(!empty($_SERVER['SERVER_NAME'])) |
|
66 | + } elseif(!empty($_SERVER['SERVER_NAME'])) |
|
72 | 67 | { |
73 | 68 | $aURL['host'] = $_SERVER['SERVER_NAME']; |
74 | - } |
|
75 | - else |
|
69 | + } else |
|
76 | 70 | { |
77 | 71 | throw new \Jaxon\Exception\URI(); |
78 | 72 | } |
@@ -94,8 +88,7 @@ discard block |
||
94 | 88 | if(!empty($_SERVER['PATH_INFO'])) |
95 | 89 | { |
96 | 90 | $sPath = parse_url($_SERVER['PATH_INFO']); |
97 | - } |
|
98 | - else |
|
91 | + } else |
|
99 | 92 | { |
100 | 93 | $sPath = parse_url($_SERVER['PHP_SELF']); |
101 | 94 | } |
@@ -153,8 +146,9 @@ discard block |
||
153 | 146 | |
154 | 147 | foreach($aQueries as $sKey => $sQuery) |
155 | 148 | { |
156 | - if("jxnGenerate" == substr($sQuery, 0, 11)) |
|
157 | - unset($aQueries[$sKey]); |
|
149 | + if("jxnGenerate" == substr($sQuery, 0, 11)) { |
|
150 | + unset($aQueries[$sKey]); |
|
151 | + } |
|
158 | 152 | } |
159 | 153 | |
160 | 154 | $sQueries = implode("&", $aQueries); |