@@ -71,13 +71,13 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function append(Response $xResponse) |
| 73 | 73 | { |
| 74 | - if(!$this->xResponse) |
|
| 74 | + if (!$this->xResponse) |
|
| 75 | 75 | { |
| 76 | 76 | $this->xResponse = $xResponse; |
| 77 | 77 | } |
| 78 | - elseif(get_class($this->xResponse) == get_class($xResponse)) |
|
| 78 | + elseif (get_class($this->xResponse) == get_class($xResponse)) |
|
| 79 | 79 | { |
| 80 | - if($this->xResponse != $xResponse) |
|
| 80 | + if ($this->xResponse != $xResponse) |
|
| 81 | 81 | { |
| 82 | 82 | $this->xResponse->appendResponse($xResponse); |
| 83 | 83 | } |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function printDebug() |
| 112 | 112 | { |
| 113 | - if(($this->xResponse)) |
|
| 113 | + if (($this->xResponse)) |
|
| 114 | 114 | { |
| 115 | - foreach($this->aDebugMessages as $sMessage) |
|
| 115 | + foreach ($this->aDebugMessages as $sMessage) |
|
| 116 | 116 | { |
| 117 | 117 | $this->xResponse->debug($sMessage); |
| 118 | 118 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function sendHeaders() |
| 129 | 129 | { |
| 130 | - if(($this->xResponse)) |
|
| 130 | + if (($this->xResponse)) |
|
| 131 | 131 | { |
| 132 | 132 | $this->xResponse->sendHeaders(); |
| 133 | 133 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function getOutput() |
| 142 | 142 | { |
| 143 | - if(($this->xResponse)) |
|
| 143 | + if (($this->xResponse)) |
|
| 144 | 144 | { |
| 145 | 145 | return $this->xResponse->getOutput(); |
| 146 | 146 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | public function sendOutput() |
| 156 | 156 | { |
| 157 | - if(($this->xResponse)) |
|
| 157 | + if (($this->xResponse)) |
|
| 158 | 158 | { |
| 159 | 159 | $this->xResponse->sendHeaders(); |
| 160 | 160 | $this->xResponse->printOutput(); |
@@ -74,15 +74,13 @@ |
||
| 74 | 74 | if(!$this->xResponse) |
| 75 | 75 | { |
| 76 | 76 | $this->xResponse = $xResponse; |
| 77 | - } |
|
| 78 | - elseif(get_class($this->xResponse) == get_class($xResponse)) |
|
| 77 | + } elseif(get_class($this->xResponse) == get_class($xResponse)) |
|
| 79 | 78 | { |
| 80 | 79 | if($this->xResponse != $xResponse) |
| 81 | 80 | { |
| 82 | 81 | $this->xResponse->appendResponse($xResponse); |
| 83 | 82 | } |
| 84 | - } |
|
| 85 | - else |
|
| 83 | + } else |
|
| 86 | 84 | { |
| 87 | 85 | $this->debug($this->trans('errors.mismatch.types', array('class' => get_class($xResponse)))); |
| 88 | 86 | } |
@@ -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); |
@@ -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(array('"',"'",'<','>'), array('%22','%27','%3C','%3E'), $_SERVER['REQUEST_URI']); |
|
| 30 | + $_SERVER['REQUEST_URI'] = str_replace(array('"', "'", '<', '>'), array('%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,20 +78,20 @@ 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 | 93 | $sPath = []; |
| 94 | - if(!empty($_SERVER['PATH_INFO'])) |
|
| 94 | + if (!empty($_SERVER['PATH_INFO'])) |
|
| 95 | 95 | { |
| 96 | 96 | $sPath = parse_url($_SERVER['PATH_INFO']); |
| 97 | 97 | } |
@@ -99,61 +99,61 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | $sPath = parse_url($_SERVER['PHP_SELF']); |
| 101 | 101 | } |
| 102 | - if(isset($sPath['path'])) |
|
| 102 | + if (isset($sPath['path'])) |
|
| 103 | 103 | { |
| 104 | - $aURL['path'] = str_replace(array('"',"'",'<','>'), array('%22','%27','%3C','%3E'), $sPath['path']); |
|
| 104 | + $aURL['path'] = str_replace(array('"', "'", '<', '>'), array('%22', '%27', '%3C', '%3E'), $sPath['path']); |
|
| 105 | 105 | } |
| 106 | 106 | unset($sPath); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if(empty($aURL['query']) && !empty($_SERVER['QUERY_STRING'])) |
|
| 109 | + if (empty($aURL['query']) && !empty($_SERVER['QUERY_STRING'])) |
|
| 110 | 110 | { |
| 111 | 111 | $aURL['query'] = $_SERVER['QUERY_STRING']; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if(!empty($aURL['query'])) |
|
| 114 | + if (!empty($aURL['query'])) |
|
| 115 | 115 | { |
| 116 | - $aURL['query'] = '?'.$aURL['query']; |
|
| 116 | + $aURL['query'] = '?' . $aURL['query']; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Build the URL: Start with scheme, user and pass |
| 120 | - $sURL = $aURL['scheme'].'://'; |
|
| 121 | - if(!empty($aURL['user'])) |
|
| 120 | + $sURL = $aURL['scheme'] . '://'; |
|
| 121 | + if (!empty($aURL['user'])) |
|
| 122 | 122 | { |
| 123 | - $sURL.= $aURL['user']; |
|
| 124 | - if(!empty($aURL['pass'])) |
|
| 123 | + $sURL .= $aURL['user']; |
|
| 124 | + if (!empty($aURL['pass'])) |
|
| 125 | 125 | { |
| 126 | - $sURL.= ':'.$aURL['pass']; |
|
| 126 | + $sURL .= ':' . $aURL['pass']; |
|
| 127 | 127 | } |
| 128 | - $sURL.= '@'; |
|
| 128 | + $sURL .= '@'; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // Add the host |
| 132 | - $sURL.= $aURL['host']; |
|
| 132 | + $sURL .= $aURL['host']; |
|
| 133 | 133 | |
| 134 | 134 | // Add the port if needed |
| 135 | - if(!empty($aURL['port']) |
|
| 135 | + if (!empty($aURL['port']) |
|
| 136 | 136 | && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) |
| 137 | 137 | || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) |
| 138 | 138 | { |
| 139 | - $sURL.= ':'.$aURL['port']; |
|
| 139 | + $sURL .= ':' . $aURL['port']; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | // Add the path and the query string |
| 143 | - $sURL.= $aURL['path'].@$aURL['query']; |
|
| 143 | + $sURL .= $aURL['path'] . @$aURL['query']; |
|
| 144 | 144 | |
| 145 | 145 | // Clean up |
| 146 | 146 | unset($aURL); |
| 147 | 147 | |
| 148 | 148 | $aURL = explode("?", $sURL); |
| 149 | 149 | |
| 150 | - if(1 < count($aURL)) |
|
| 150 | + if (1 < count($aURL)) |
|
| 151 | 151 | { |
| 152 | 152 | $aQueries = explode("&", $aURL[1]); |
| 153 | 153 | |
| 154 | - foreach($aQueries as $sKey => $sQuery) |
|
| 154 | + foreach ($aQueries as $sKey => $sQuery) |
|
| 155 | 155 | { |
| 156 | - if("jxnGenerate" == substr($sQuery, 0, 11)) |
|
| 156 | + if ("jxnGenerate" == substr($sQuery, 0, 11)) |
|
| 157 | 157 | unset($aQueries[$sKey]); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -29,13 +29,13 @@ discard block |
||
| 29 | 29 | public static function read($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 30 | 30 | { |
| 31 | 31 | $sConfigFile = realpath($sConfigFile); |
| 32 | - if(!is_readable($sConfigFile)) |
|
| 32 | + if (!is_readable($sConfigFile)) |
|
| 33 | 33 | { |
| 34 | 34 | throw new \Jaxon\Exception\Config\File(jaxon_trans('config.errors.file.access', array('path' => $sConfigFile))); |
| 35 | 35 | } |
| 36 | 36 | $sFileContent = file_get_contents($sConfigFile); |
| 37 | 37 | $aConfigOptions = json_decode($sFileContent, true); |
| 38 | - if(!is_array($aConfigOptions)) |
|
| 38 | + if (!is_array($aConfigOptions)) |
|
| 39 | 39 | { |
| 40 | 40 | throw new \Jaxon\Exception\Config\File(jaxon_trans('config.errors.file.content', array('path' => $sConfigFile))); |
| 41 | 41 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $jaxon = jaxon(); |
| 45 | 45 | $jaxon->setOptions($aConfigOptions, $sLibKey); |
| 46 | 46 | $config = null; |
| 47 | - if(is_string($sAppKey)) |
|
| 47 | + if (is_string($sAppKey)) |
|
| 48 | 48 | { |
| 49 | 49 | $config = new Config(); |
| 50 | 50 | $config->setOptions($aConfigOptions, $sAppKey); |
@@ -29,16 +29,16 @@ discard block |
||
| 29 | 29 | public static function read($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 30 | 30 | { |
| 31 | 31 | $sConfigFile = realpath($sConfigFile); |
| 32 | - if(!extension_loaded('yaml')) |
|
| 32 | + if (!extension_loaded('yaml')) |
|
| 33 | 33 | { |
| 34 | 34 | throw new \Jaxon\Exception\Config\Yaml(jaxon_trans('config.errors.yaml.install')); |
| 35 | 35 | } |
| 36 | - if(!is_readable($sConfigFile)) |
|
| 36 | + if (!is_readable($sConfigFile)) |
|
| 37 | 37 | { |
| 38 | 38 | throw new \Jaxon\Exception\Config\File(jaxon_trans('config.errors.file.access', array('path' => $sConfigFile))); |
| 39 | 39 | } |
| 40 | 40 | $aConfigOptions = yaml_parse_file($sConfigFile); |
| 41 | - if(!is_array($aConfigOptions)) |
|
| 41 | + if (!is_array($aConfigOptions)) |
|
| 42 | 42 | { |
| 43 | 43 | throw new \Jaxon\Exception\Config\File(jaxon_trans('config.errors.file.content', array('path' => $sConfigFile))); |
| 44 | 44 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | // Setup the config options into the library. |
| 47 | 47 | $jaxon = jaxon(); |
| 48 | 48 | $jaxon->setOptions($aConfigOptions, $sLibKey); |
| 49 | - if(!is_string($sAppKey)) |
|
| 49 | + if (!is_string($sAppKey)) |
|
| 50 | 50 | { |
| 51 | 51 | return null; |
| 52 | 52 | } |
@@ -29,12 +29,12 @@ discard block |
||
| 29 | 29 | public static function read($sConfigFile, $sLibKey = '', $sAppKey = null) |
| 30 | 30 | { |
| 31 | 31 | $sConfigFile = realpath($sConfigFile); |
| 32 | - if(!is_readable($sConfigFile)) |
|
| 32 | + if (!is_readable($sConfigFile)) |
|
| 33 | 33 | { |
| 34 | 34 | throw new \Jaxon\Exception\Config\File(jaxon_trans('config.errors.file.access', array('path' => $sConfigFile))); |
| 35 | 35 | } |
| 36 | 36 | $aConfigOptions = include($sConfigFile); |
| 37 | - if(!is_array($aConfigOptions)) |
|
| 37 | + if (!is_array($aConfigOptions)) |
|
| 38 | 38 | { |
| 39 | 39 | throw new \Jaxon\Exception\Config\File(jaxon_trans('config.errors.file.content', array('path' => $sConfigFile))); |
| 40 | 40 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | // Setup the config options into the library. |
| 43 | 43 | $jaxon = jaxon(); |
| 44 | 44 | $jaxon->setOptions($aConfigOptions, $sLibKey); |
| 45 | - if(!is_string($sAppKey)) |
|
| 45 | + if (!is_string($sAppKey)) |
|
| 46 | 46 | { |
| 47 | 47 | return null; |
| 48 | 48 | } |
@@ -91,19 +91,19 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public static function make($xValue) |
| 93 | 93 | { |
| 94 | - if($xValue instanceof Interfaces\Parameter) |
|
| 94 | + if ($xValue instanceof Interfaces\Parameter) |
|
| 95 | 95 | { |
| 96 | 96 | return $xValue; |
| 97 | 97 | } |
| 98 | - elseif(is_numeric($xValue)) |
|
| 98 | + elseif (is_numeric($xValue)) |
|
| 99 | 99 | { |
| 100 | 100 | return new Parameter(Jaxon::NUMERIC_VALUE, $xValue); |
| 101 | 101 | } |
| 102 | - elseif(is_string($xValue)) |
|
| 102 | + elseif (is_string($xValue)) |
|
| 103 | 103 | { |
| 104 | 104 | return new Parameter(Jaxon::QUOTED_VALUE, $xValue); |
| 105 | 105 | } |
| 106 | - elseif(is_bool($xValue)) |
|
| 106 | + elseif (is_bool($xValue)) |
|
| 107 | 107 | { |
| 108 | 108 | return new Parameter(Jaxon::BOOL_VALUE, $xValue); |
| 109 | 109 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | { |
| 123 | 123 | $sJsCode = ''; |
| 124 | 124 | $sQuoteCharacter = "'"; |
| 125 | - switch($this->sType) |
|
| 125 | + switch ($this->sType) |
|
| 126 | 126 | { |
| 127 | 127 | case Jaxon::FORM_VALUES: |
| 128 | 128 | $sFormID = (string)$this->xValue; |
@@ -130,11 +130,11 @@ discard block |
||
| 130 | 130 | break; |
| 131 | 131 | case Jaxon::INPUT_VALUE: |
| 132 | 132 | $sInputID = (string)$this->xValue; |
| 133 | - $sJsCode = "jaxon.$(" . $sQuoteCharacter . $sInputID . $sQuoteCharacter . ").value"; |
|
| 133 | + $sJsCode = "jaxon.$(" . $sQuoteCharacter . $sInputID . $sQuoteCharacter . ").value"; |
|
| 134 | 134 | break; |
| 135 | 135 | case Jaxon::CHECKED_VALUE: |
| 136 | 136 | $sCheckedID = (string)$this->xValue; |
| 137 | - $sJsCode = "jaxon.$(" . $sQuoteCharacter . $sCheckedID . $sQuoteCharacter . ").checked"; |
|
| 137 | + $sJsCode = "jaxon.$(" . $sQuoteCharacter . $sCheckedID . $sQuoteCharacter . ").checked"; |
|
| 138 | 138 | break; |
| 139 | 139 | case Jaxon::ELEMENT_INNERHTML: |
| 140 | 140 | $sElementID = (string)$this->xValue; |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | $sJsCode = (string)$this->xValue; |
| 154 | 154 | break; |
| 155 | 155 | case Jaxon::JS_VALUE: |
| 156 | - if(is_array($this->xValue) || is_object($this->xValue)) |
|
| 156 | + if (is_array($this->xValue) || is_object($this->xValue)) |
|
| 157 | 157 | { |
| 158 | 158 | // Unable to use double quotes here because they cannot be handled on client side. |
| 159 | 159 | // So we are using simple quotes even if the Json standard recommends double quotes. |
@@ -94,20 +94,16 @@ discard block |
||
| 94 | 94 | if($xValue instanceof Interfaces\Parameter) |
| 95 | 95 | { |
| 96 | 96 | return $xValue; |
| 97 | - } |
|
| 98 | - elseif(is_numeric($xValue)) |
|
| 97 | + } elseif(is_numeric($xValue)) |
|
| 99 | 98 | { |
| 100 | 99 | return new Parameter(Jaxon::NUMERIC_VALUE, $xValue); |
| 101 | - } |
|
| 102 | - elseif(is_string($xValue)) |
|
| 100 | + } elseif(is_string($xValue)) |
|
| 103 | 101 | { |
| 104 | 102 | return new Parameter(Jaxon::QUOTED_VALUE, $xValue); |
| 105 | - } |
|
| 106 | - elseif(is_bool($xValue)) |
|
| 103 | + } elseif(is_bool($xValue)) |
|
| 107 | 104 | { |
| 108 | 105 | return new Parameter(Jaxon::BOOL_VALUE, $xValue); |
| 109 | - } |
|
| 110 | - else // if(is_array($xValue) || is_object($xValue)) |
|
| 106 | + } else // if(is_array($xValue) || is_object($xValue)) |
|
| 111 | 107 | { |
| 112 | 108 | return new Parameter(Jaxon::JS_VALUE, $xValue); |
| 113 | 109 | } |
@@ -158,8 +154,7 @@ discard block |
||
| 158 | 154 | // Unable to use double quotes here because they cannot be handled on client side. |
| 159 | 155 | // So we are using simple quotes even if the Json standard recommends double quotes. |
| 160 | 156 | $sJsCode = str_replace(['"'], ["'"], json_encode($this->xValue, JSON_HEX_APOS | JSON_HEX_QUOT)); |
| 161 | - } |
|
| 162 | - else |
|
| 157 | + } else |
|
| 163 | 158 | { |
| 164 | 159 | $sJsCode = (string)$this->xValue; |
| 165 | 160 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | // Verify the file extension |
| 130 | 130 | $xDefault = $this->xConfig->getOption('upload.default.types'); |
| 131 | 131 | $aAllowed = $this->xConfig->getOption('upload.files.' . $sName . '.types', $xDefault); |
| 132 | - if(is_array($aAllowed) && !in_array($aUploadedFile['type'], $aAllowed)) |
|
| 132 | + if (is_array($aAllowed) && !in_array($aUploadedFile['type'], $aAllowed)) |
|
| 133 | 133 | { |
| 134 | 134 | $this->sErrorMessage = $this->xTranslator->trans('errors.upload.type', $aUploadedFile); |
| 135 | 135 | return false; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | // Verify the file extension |
| 138 | 138 | $xDefault = $this->xConfig->getOption('upload.default.extensions'); |
| 139 | 139 | $aAllowed = $this->xConfig->getOption('upload.files.' . $sName . '.extensions', $xDefault); |
| 140 | - if(is_array($aAllowed) && !in_array($aUploadedFile['extension'], $aAllowed)) |
|
| 140 | + if (is_array($aAllowed) && !in_array($aUploadedFile['extension'], $aAllowed)) |
|
| 141 | 141 | { |
| 142 | 142 | $this->sErrorMessage = $this->xTranslator->trans('errors.upload.extension', $aUploadedFile); |
| 143 | 143 | return false; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | // Verify the max size |
| 146 | 146 | $xDefault = $this->xConfig->getOption('upload.default.max-size', 0); |
| 147 | 147 | $iSize = $this->xConfig->getOption('upload.files.' . $sName . '.max-size', $xDefault); |
| 148 | - if($iSize > 0 && $aUploadedFile['size'] > $iSize) |
|
| 148 | + if ($iSize > 0 && $aUploadedFile['size'] > $iSize) |
|
| 149 | 149 | { |
| 150 | 150 | $this->sErrorMessage = $this->xTranslator->trans('errors.upload.max-size', $aUploadedFile); |
| 151 | 151 | return false; |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | // Verify the min size |
| 154 | 154 | $xDefault = $this->xConfig->getOption('upload.default.min-size', 0); |
| 155 | 155 | $iSize = $this->xConfig->getOption('upload.files.' . $sName . '.min-size', $xDefault); |
| 156 | - if($iSize > 0 && $aUploadedFile['size'] < $iSize) |
|
| 156 | + if ($iSize > 0 && $aUploadedFile['size'] < $iSize) |
|
| 157 | 157 | { |
| 158 | 158 | $this->sErrorMessage = $this->xTranslator->trans('errors.upload.min-size', $aUploadedFile); |
| 159 | 159 | return false; |
@@ -121,7 +121,7 @@ |
||
| 121 | 121 | } |
| 122 | 122 | if(!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage])) |
| 123 | 123 | { |
| 124 | - return $sText; |
|
| 124 | + return $sText; |
|
| 125 | 125 | } |
| 126 | 126 | $message = $this->aTranslations[$sLanguage][$sText]; |
| 127 | 127 | foreach($aPlaceHolders as $name => $value) |
@@ -63,8 +63,7 @@ |
||
| 63 | 63 | { |
| 64 | 64 | // Save this translation |
| 65 | 65 | $this->aTranslations[$sLanguage][$sName] = $xTranslation; |
| 66 | - } |
|
| 67 | - else |
|
| 66 | + } else |
|
| 68 | 67 | { |
| 69 | 68 | // Recursively read the translations in the array |
| 70 | 69 | $this->_loadTranslations($sLanguage, $sName, $xTranslation); |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | private function _loadTranslations($sLanguage, $sPrefix, array $aTranslations) |
| 57 | 57 | { |
| 58 | - foreach($aTranslations as $sName => $xTranslation) |
|
| 58 | + foreach ($aTranslations as $sName => $xTranslation) |
|
| 59 | 59 | { |
| 60 | 60 | $sName = trim($sName); |
| 61 | 61 | $sName = ($sPrefix) ? $sPrefix . '.' . $sName : $sName; |
| 62 | - if(!is_array($xTranslation)) |
|
| 62 | + if (!is_array($xTranslation)) |
|
| 63 | 63 | { |
| 64 | 64 | // Save this translation |
| 65 | 65 | $this->aTranslations[$sLanguage][$sName] = $xTranslation; |
@@ -82,17 +82,17 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function loadTranslations($sFilePath, $sLanguage) |
| 84 | 84 | { |
| 85 | - if(!file_exists($sFilePath)) |
|
| 85 | + if (!file_exists($sFilePath)) |
|
| 86 | 86 | { |
| 87 | 87 | return; |
| 88 | 88 | } |
| 89 | 89 | $aTranslations = require($sFilePath); |
| 90 | - if(!is_array($aTranslations)) |
|
| 90 | + if (!is_array($aTranslations)) |
|
| 91 | 91 | { |
| 92 | 92 | return; |
| 93 | 93 | } |
| 94 | 94 | // Load the translations |
| 95 | - if(!array_key_exists($sLanguage, $this->aTranslations)) |
|
| 95 | + if (!array_key_exists($sLanguage, $this->aTranslations)) |
|
| 96 | 96 | { |
| 97 | 97 | $this->aTranslations[$sLanguage] = []; |
| 98 | 98 | } |
@@ -111,20 +111,20 @@ discard block |
||
| 111 | 111 | public function trans($sText, array $aPlaceHolders = [], $sLanguage = null) |
| 112 | 112 | { |
| 113 | 113 | $sText = trim((string)$sText); |
| 114 | - if(!$sLanguage) |
|
| 114 | + if (!$sLanguage) |
|
| 115 | 115 | { |
| 116 | 116 | $sLanguage = $this->xConfig->getOption('language'); |
| 117 | 117 | } |
| 118 | - if(!$sLanguage) |
|
| 118 | + if (!$sLanguage) |
|
| 119 | 119 | { |
| 120 | 120 | $sLanguage = $this->sDefaultLocale; |
| 121 | 121 | } |
| 122 | - if(!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage])) |
|
| 122 | + if (!array_key_exists($sLanguage, $this->aTranslations) || !array_key_exists($sText, $this->aTranslations[$sLanguage])) |
|
| 123 | 123 | { |
| 124 | 124 | return $sText; |
| 125 | 125 | } |
| 126 | 126 | $message = $this->aTranslations[$sLanguage][$sText]; |
| 127 | - foreach($aPlaceHolders as $name => $value) |
|
| 127 | + foreach ($aPlaceHolders as $name => $value) |
|
| 128 | 128 | { |
| 129 | 129 | $message = str_replace(':' . $name, $value, $message); |
| 130 | 130 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | * |
| 281 | 281 | * @param array $aArgs An array containing the event specification |
| 282 | 282 | * |
| 283 | - * @return \Jaxon\Request\Request |
|
| 283 | + * @return boolean |
|
| 284 | 284 | */ |
| 285 | 285 | public function register($aArgs) |
| 286 | 286 | { |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | /** |
| 343 | 343 | * Check uploaded files validity and move them to the user dir |
| 344 | 344 | * |
| 345 | - * @return boolean |
|
| 345 | + * @return string |
|
| 346 | 346 | */ |
| 347 | 347 | public function saveUploadedFiles() |
| 348 | 348 | { |
@@ -217,7 +217,7 @@ |
||
| 217 | 217 | $aFiles[$sVarName] = []; |
| 218 | 218 | foreach($aUserFiles as $aUserFile) |
| 219 | 219 | { |
| 220 | - $aFiles[$sVarName][] = $aUserFile->toTempData(); |
|
| 220 | + $aFiles[$sVarName][] = $aUserFile->toTempData(); |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | // Save upload data in a temp file |
@@ -52,8 +52,7 @@ discard block |
||
| 52 | 52 | if(array_key_exists('jxnupl', $_POST)) |
| 53 | 53 | { |
| 54 | 54 | $this->sTempFile = $_POST['jxnupl']; |
| 55 | - } |
|
| 56 | - elseif(array_key_exists('jxnupl', $_GET)) |
|
| 55 | + } elseif(array_key_exists('jxnupl', $_GET)) |
|
| 57 | 56 | { |
| 58 | 57 | $this->sTempFile = $_GET['jxnupl']; |
| 59 | 58 | } |
@@ -125,8 +124,7 @@ discard block |
||
| 125 | 124 | 'extension' => pathinfo($aFile['name'][$i], PATHINFO_EXTENSION), |
| 126 | 125 | ]; |
| 127 | 126 | } |
| 128 | - } |
|
| 129 | - else |
|
| 127 | + } else |
|
| 130 | 128 | { |
| 131 | 129 | if(!$aFile['name']) |
| 132 | 130 | { |
@@ -331,8 +329,7 @@ discard block |
||
| 331 | 329 | if(count($_FILES) > 0) |
| 332 | 330 | { |
| 333 | 331 | $this->readFromHttpData(); |
| 334 | - } |
|
| 335 | - elseif(($this->sTempFile)) |
|
| 332 | + } elseif(($this->sTempFile)) |
|
| 336 | 333 | { |
| 337 | 334 | $this->readFromTempFile(); |
| 338 | 335 | } |
@@ -15,7 +15,6 @@ |
||
| 15 | 15 | use Jaxon\Jaxon; |
| 16 | 16 | use Jaxon\Plugin\Request as RequestPlugin; |
| 17 | 17 | use Jaxon\Request\Support\UploadedFile; |
| 18 | - |
|
| 19 | 18 | use Closure; |
| 20 | 19 | |
| 21 | 20 | class FileUpload extends RequestPlugin |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | $this->aUserFiles = []; |
| 60 | 60 | $this->sUploadSubdir = uniqid() . DIRECTORY_SEPARATOR; |
| 61 | 61 | |
| 62 | - if(array_key_exists('jxnupl', $_POST)) |
|
| 62 | + if (array_key_exists('jxnupl', $_POST)) |
|
| 63 | 63 | { |
| 64 | 64 | $this->sTempFile = $_POST['jxnupl']; |
| 65 | 65 | } |
| 66 | - elseif(array_key_exists('jxnupl', $_GET)) |
|
| 66 | + elseif (array_key_exists('jxnupl', $_GET)) |
|
| 67 | 67 | { |
| 68 | 68 | $this->sTempFile = $_GET['jxnupl']; |
| 69 | 69 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | protected function filterFilename($sFilename, $sVarName) |
| 93 | 93 | { |
| 94 | - if(($this->fFileFilter)) |
|
| 94 | + if (($this->fFileFilter)) |
|
| 95 | 95 | { |
| 96 | 96 | $fFileFilter = $this->fFileFilter; |
| 97 | 97 | $sFilename = (string)$fFileFilter($sFilename, $sVarName); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | $sUploadDir = $this->getOption('upload.files.' . $sFieldId . '.dir', $sDefaultUploadDir); |
| 114 | 114 | $sUploadDir = rtrim(trim($sUploadDir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
| 115 | 115 | // Verify that the upload dir exists and is writable |
| 116 | - if(!is_writable($sUploadDir)) |
|
| 116 | + if (!is_writable($sUploadDir)) |
|
| 117 | 117 | { |
| 118 | 118 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
| 119 | 119 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $sUploadDir = $this->getOption('upload.default.dir'); |
| 134 | 134 | $sUploadDir = rtrim(trim($sUploadDir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
| 135 | 135 | // Verify that the upload dir exists and is writable |
| 136 | - if(!is_writable($sUploadDir)) |
|
| 136 | + if (!is_writable($sUploadDir)) |
|
| 137 | 137 | { |
| 138 | 138 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
| 139 | 139 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | $sUploadDir = rtrim(trim($sUploadDir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
| 154 | 154 | $sUploadDir .= 'tmp' . DIRECTORY_SEPARATOR; |
| 155 | 155 | $sUploadTempFile = $sUploadDir . $this->sTempFile . '.json'; |
| 156 | - if(!is_readable($sUploadTempFile)) |
|
| 156 | + if (!is_readable($sUploadTempFile)) |
|
| 157 | 157 | { |
| 158 | 158 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.access')); |
| 159 | 159 | } |
@@ -169,17 +169,17 @@ discard block |
||
| 169 | 169 | { |
| 170 | 170 | // Check validity of the uploaded files |
| 171 | 171 | $aTempFiles = []; |
| 172 | - foreach($_FILES as $sVarName => $aFile) |
|
| 172 | + foreach ($_FILES as $sVarName => $aFile) |
|
| 173 | 173 | { |
| 174 | - if(is_array($aFile['name'])) |
|
| 174 | + if (is_array($aFile['name'])) |
|
| 175 | 175 | { |
| 176 | - for($i = 0; $i < count($aFile['name']); $i++) |
|
| 176 | + for ($i = 0; $i < count($aFile['name']); $i++) |
|
| 177 | 177 | { |
| 178 | - if(!$aFile['name'][$i]) |
|
| 178 | + if (!$aFile['name'][$i]) |
|
| 179 | 179 | { |
| 180 | 180 | continue; |
| 181 | 181 | } |
| 182 | - if(!array_key_exists($sVarName, $aTempFiles)) |
|
| 182 | + if (!array_key_exists($sVarName, $aTempFiles)) |
|
| 183 | 183 | { |
| 184 | 184 | $aTempFiles[$sVarName] = []; |
| 185 | 185 | } |
@@ -199,11 +199,11 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | else |
| 201 | 201 | { |
| 202 | - if(!$aFile['name']) |
|
| 202 | + if (!$aFile['name']) |
|
| 203 | 203 | { |
| 204 | 204 | continue; |
| 205 | 205 | } |
| 206 | - if(!array_key_exists($sVarName, $aTempFiles)) |
|
| 206 | + if (!array_key_exists($sVarName, $aTempFiles)) |
|
| 207 | 207 | { |
| 208 | 208 | $aTempFiles[$sVarName] = []; |
| 209 | 209 | } |
@@ -223,17 +223,17 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // Check uploaded files validity |
| 226 | - foreach($aTempFiles as $sVarName => $aFiles) |
|
| 226 | + foreach ($aTempFiles as $sVarName => $aFiles) |
|
| 227 | 227 | { |
| 228 | - foreach($aFiles as $aFile) |
|
| 228 | + foreach ($aFiles as $aFile) |
|
| 229 | 229 | { |
| 230 | 230 | // Verify upload result |
| 231 | - if($aFile['error'] != 0) |
|
| 231 | + if ($aFile['error'] != 0) |
|
| 232 | 232 | { |
| 233 | 233 | throw new \Jaxon\Exception\Error($this->trans('errors.upload.failed', $aFile)); |
| 234 | 234 | } |
| 235 | 235 | // Verify file validity (format, size) |
| 236 | - if(!$this->validateUploadedFile($sVarName, $aFile)) |
|
| 236 | + if (!$this->validateUploadedFile($sVarName, $aFile)) |
|
| 237 | 237 | { |
| 238 | 238 | throw new \Jaxon\Exception\Error($this->getValidatorMessage()); |
| 239 | 239 | } |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // Copy the uploaded files from the temp dir to the user dir |
| 246 | - foreach($aTempFiles as $sVarName => $aTempFiles) |
|
| 246 | + foreach ($aTempFiles as $sVarName => $aTempFiles) |
|
| 247 | 247 | { |
| 248 | 248 | $this->aUserFiles[$sVarName] = []; |
| 249 | - foreach($aTempFiles as $aFile) |
|
| 249 | + foreach ($aTempFiles as $aFile) |
|
| 250 | 250 | { |
| 251 | 251 | // Get the path to the upload dir |
| 252 | 252 | $sUploadDir = $this->getUploadDir($sVarName); |
@@ -268,10 +268,10 @@ discard block |
||
| 268 | 268 | { |
| 269 | 269 | // Convert uploaded file to an array |
| 270 | 270 | $aFiles = []; |
| 271 | - foreach($this->aUserFiles as $sVarName => $aUserFiles) |
|
| 271 | + foreach ($this->aUserFiles as $sVarName => $aUserFiles) |
|
| 272 | 272 | { |
| 273 | 273 | $aFiles[$sVarName] = []; |
| 274 | - foreach($aUserFiles as $aUserFile) |
|
| 274 | + foreach ($aUserFiles as $aUserFile) |
|
| 275 | 275 | { |
| 276 | 276 | $aFiles[$sVarName][] = $aUserFile->toTempData(); |
| 277 | 277 | } |
@@ -292,10 +292,10 @@ discard block |
||
| 292 | 292 | // Upload temp file |
| 293 | 293 | $sUploadTempFile = $this->getUploadTempFile(); |
| 294 | 294 | $aFiles = json_decode(file_get_contents($sUploadTempFile), true); |
| 295 | - foreach($aFiles as $sVarName => $aUserFiles) |
|
| 295 | + foreach ($aFiles as $sVarName => $aUserFiles) |
|
| 296 | 296 | { |
| 297 | 297 | $this->aUserFiles[$sVarName] = []; |
| 298 | - foreach($aUserFiles as $aUserFile) |
|
| 298 | + foreach ($aUserFiles as $aUserFile) |
|
| 299 | 299 | { |
| 300 | 300 | $this->aUserFiles[$sVarName][] = UploadedFile::fromTempData($aUserFile); |
| 301 | 301 | } |
@@ -372,15 +372,15 @@ discard block |
||
| 372 | 372 | */ |
| 373 | 373 | public function processRequest() |
| 374 | 374 | { |
| 375 | - if(!$this->canProcessRequest()) |
|
| 375 | + if (!$this->canProcessRequest()) |
|
| 376 | 376 | { |
| 377 | 377 | return false; |
| 378 | 378 | } |
| 379 | - if(count($_FILES) > 0) |
|
| 379 | + if (count($_FILES) > 0) |
|
| 380 | 380 | { |
| 381 | 381 | $this->readFromHttpData(); |
| 382 | 382 | } |
| 383 | - elseif(($this->sTempFile)) |
|
| 383 | + elseif (($this->sTempFile)) |
|
| 384 | 384 | { |
| 385 | 385 | $this->readFromTempFile(); |
| 386 | 386 | } |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | public function saveUploadedFiles() |
| 396 | 396 | { |
| 397 | 397 | // Process uploaded files |
| 398 | - if(!$this->processRequest()) |
|
| 398 | + if (!$this->processRequest()) |
|
| 399 | 399 | { |
| 400 | 400 | return ''; |
| 401 | 401 | } |