@@ -3,9 +3,6 @@ |
||
| 3 | 3 | namespace Jaxon\Utils\View; |
| 4 | 4 | |
| 5 | 5 | use Jaxon\Utils\Config\Config; |
| 6 | - |
|
| 7 | -use stdClass; |
|
| 8 | -use Exception; |
|
| 9 | 6 | use Closure; |
| 10 | 7 | |
| 11 | 8 | class Manager |
@@ -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 = $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 | } |
@@ -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 | } |
@@ -97,7 +97,7 @@ |
||
| 97 | 97 | */ |
| 98 | 98 | public function delete($sKey) |
| 99 | 99 | { |
| 100 | - if(key_exists($sKey, $_SESSION)) |
|
| 100 | + if (key_exists($sKey, $_SESSION)) |
|
| 101 | 101 | { |
| 102 | 102 | unset($_SESSION[$sKey]); |
| 103 | 103 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | protected function getPrevLink($xPaginator) |
| 48 | 48 | { |
| 49 | - if(!($sCall = $xPaginator->getPrevCall())) |
|
| 49 | + if (!($sCall = $xPaginator->getPrevCall())) |
|
| 50 | 50 | { |
| 51 | 51 | return $this->xRenderer->render('pagination::links/disabled', ['text' => $xPaginator->getPreviousText()]); |
| 52 | 52 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | protected function getNextLink($xPaginator) |
| 65 | 65 | { |
| 66 | - if(!($sCall = $xPaginator->getNextCall())) |
|
| 66 | + if (!($sCall = $xPaginator->getNextCall())) |
|
| 67 | 67 | { |
| 68 | 68 | return $this->xRenderer->render('pagination::links/disabled', ['text' => $xPaginator->getNextText()]); |
| 69 | 69 | } |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | protected function getLinks($xPaginator) |
| 82 | 82 | { |
| 83 | 83 | $sLinks = ''; |
| 84 | - foreach($xPaginator->getPages() as $page) |
|
| 84 | + foreach ($xPaginator->getPages() as $page) |
|
| 85 | 85 | { |
| 86 | - if($page['call']) |
|
| 86 | + if ($page['call']) |
|
| 87 | 87 | { |
| 88 | 88 | $sTemplate = ($page['isCurrent'] ? 'pagination::links/current' : 'pagination::links/enabled'); |
| 89 | 89 | $sLinks .= $this->xRenderer->render($sTemplate, ['call' => $page['call'], 'text' => $page['num']]); |
@@ -87,8 +87,7 @@ |
||
| 87 | 87 | { |
| 88 | 88 | $sTemplate = ($page['isCurrent'] ? 'pagination::links/current' : 'pagination::links/enabled'); |
| 89 | 89 | $sLinks .= $this->xRenderer->render($sTemplate, ['call' => $page['call'], 'text' => $page['num']]); |
| 90 | - } |
|
| 91 | - else |
|
| 90 | + } else |
|
| 92 | 91 | { |
| 93 | 92 | $sLinks .= $this->xRenderer->render('pagination::links/disabled', ['text' => $page['num']]); |
| 94 | 93 | } |
@@ -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; |