@@ -38,6 +38,7 @@ |
||
| 38 | 38 | /** |
| 39 | 39 | * Writes a string. |
| 40 | 40 | * @param string string to be written |
| 41 | + * @param string $str |
|
| 41 | 42 | */ |
| 42 | 43 | public function write($str) |
| 43 | 44 | { |
@@ -98,6 +98,7 @@ |
||
| 98 | 98 | * @param integer level filter |
| 99 | 99 | * @param array category filter |
| 100 | 100 | * @param array control filter |
| 101 | + * @param integer $levels |
|
| 101 | 102 | * @return array list of messages. Each array elements represents one message |
| 102 | 103 | * with the following structure: |
| 103 | 104 | * array( |
@@ -63,16 +63,16 @@ discard block |
||
| 63 | 63 | * @param string category of the message |
| 64 | 64 | * @param string|TControl control of the message |
| 65 | 65 | */ |
| 66 | - public function log($message,$level,$category='Uncategorized', $ctl=null) |
|
| 66 | + public function log($message, $level, $category='Uncategorized', $ctl=null) |
|
| 67 | 67 | { |
| 68 | 68 | if($ctl) { |
| 69 | 69 | if($ctl instanceof TControl) |
| 70 | - $ctl = $ctl->ClientId; |
|
| 70 | + $ctl=$ctl->ClientId; |
|
| 71 | 71 | else if(!is_string($ctl)) |
| 72 | - $ctl = null; |
|
| 72 | + $ctl=null; |
|
| 73 | 73 | } else |
| 74 | - $ctl = null; |
|
| 75 | - $this->_logs[]=array($message,$level,$category,microtime(true),memory_get_usage(),$ctl); |
|
| 74 | + $ctl=null; |
|
| 75 | + $this->_logs[]=array($message, $level, $category, microtime(true), memory_get_usage(), $ctl); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * [4] => memory in bytes |
| 109 | 109 | * [5] => control client id |
| 110 | 110 | */ |
| 111 | - public function getLogs($levels=null,$categories=null,$controls=null,$timestamp=null) |
|
| 111 | + public function getLogs($levels=null, $categories=null, $controls=null, $timestamp=null) |
|
| 112 | 112 | { |
| 113 | 113 | $this->_levels=$levels; |
| 114 | 114 | $this->_categories=$categories; |
@@ -116,15 +116,15 @@ discard block |
||
| 116 | 116 | $this->_timestamp=$timestamp; |
| 117 | 117 | if(empty($levels) && empty($categories) && empty($controls) && is_null($timestamp)) |
| 118 | 118 | return $this->_logs; |
| 119 | - $logs = $this->_logs; |
|
| 119 | + $logs=$this->_logs; |
|
| 120 | 120 | if(!empty($levels)) |
| 121 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByLevels')) )); |
|
| 121 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByLevels')))); |
|
| 122 | 122 | if(!empty($categories)) |
| 123 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByCategories')) )); |
|
| 123 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByCategories')))); |
|
| 124 | 124 | if(!empty($controls)) |
| 125 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByControl')) )); |
|
| 125 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByControl')))); |
|
| 126 | 126 | if(!is_null($timestamp)) |
| 127 | - $logs = array_values(array_filter( array_filter($logs,array($this,'filterByTimeStamp')) )); |
|
| 127 | + $logs=array_values(array_filter(array_filter($logs, array($this, 'filterByTimeStamp')))); |
|
| 128 | 128 | return $logs; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @param array category filter |
| 153 | 153 | * @param array control filter |
| 154 | 154 | */ |
| 155 | - public function deleteLogs($levels=null,$categories=null,$controls=null,$timestamp=null) |
|
| 155 | + public function deleteLogs($levels=null, $categories=null, $controls=null, $timestamp=null) |
|
| 156 | 156 | { |
| 157 | 157 | $this->_levels=$levels; |
| 158 | 158 | $this->_categories=$categories; |
@@ -163,16 +163,16 @@ discard block |
||
| 163 | 163 | $this->_logs=array(); |
| 164 | 164 | return; |
| 165 | 165 | } |
| 166 | - $logs = $this->_logs; |
|
| 166 | + $logs=$this->_logs; |
|
| 167 | 167 | if(!empty($levels)) |
| 168 | - $logs = array_filter( array_filter($logs,array($this,'filterByLevels')) ); |
|
| 168 | + $logs=array_filter(array_filter($logs, array($this, 'filterByLevels'))); |
|
| 169 | 169 | if(!empty($categories)) |
| 170 | - $logs = array_filter( array_filter($logs,array($this,'filterByCategories')) ); |
|
| 170 | + $logs=array_filter(array_filter($logs, array($this, 'filterByCategories'))); |
|
| 171 | 171 | if(!empty($controls)) |
| 172 | - $logs = array_filter( array_filter($logs,array($this,'filterByControl')) ); |
|
| 172 | + $logs=array_filter(array_filter($logs, array($this, 'filterByControl'))); |
|
| 173 | 173 | if(!is_null($timestamp)) |
| 174 | - $logs = array_filter( array_filter($logs,array($this,'filterByTimeStamp')) ); |
|
| 175 | - $this->_logs = array_values( array_diff_key($this->_logs, $logs) ); |
|
| 174 | + $logs=array_filter(array_filter($logs, array($this, 'filterByTimeStamp'))); |
|
| 175 | + $this->_logs=array_values(array_diff_key($this->_logs, $logs)); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | foreach($this->_categories as $category) |
| 185 | 185 | { |
| 186 | 186 | // element 2 is the category |
| 187 | - if($value[2]===$category || strpos($value[2],$category.'.')===0) |
|
| 187 | + if($value[2]===$category || strpos($value[2], $category.'.')===0) |
|
| 188 | 188 | return $value; |
| 189 | 189 | } |
| 190 | 190 | return false; |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | // element 5 are the control client ids |
| 213 | 213 | foreach($this->_controls as $control) |
| 214 | 214 | { |
| 215 | - if($value[5]===$control || strpos($value[5],$control)===0) |
|
| 215 | + if($value[5]===$control || strpos($value[5], $control)===0) |
|
| 216 | 216 | return $value; |
| 217 | 217 | } |
| 218 | 218 | return false; |
@@ -105,6 +105,9 @@ |
||
| 105 | 105 | * @param string RPC server URL |
| 106 | 106 | * @param array payload data |
| 107 | 107 | * @param string request mime type |
| 108 | + * @param string $serverUrl |
|
| 109 | + * @param string $mimeType |
|
| 110 | + * @return string |
|
| 108 | 111 | */ |
| 109 | 112 | protected function performRequest($serverUrl, $payload, $mimeType) |
| 110 | 113 | { |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | /** |
| 58 | 58 | * @var boolean whether the request is a notification and therefore should not care about the result (default: false) |
| 59 | 59 | */ |
| 60 | - private $_isNotification = false; |
|
| 60 | + private $_isNotification=false; |
|
| 61 | 61 | |
| 62 | 62 | // magics |
| 63 | 63 | |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | * @param string url to RPC server |
| 66 | 66 | * @param boolean whether requests are considered to be notifications (completely ignoring the response) (default: false) |
| 67 | 67 | */ |
| 68 | - public function __construct($serverUrl, $isNotification = false) |
|
| 68 | + public function __construct($serverUrl, $isNotification=false) |
|
| 69 | 69 | { |
| 70 | - $this->_serverUrl = $serverUrl; |
|
| 71 | - $this->_isNotification = TPropertyValue::ensureBoolean($isNotification); |
|
| 70 | + $this->_serverUrl=$serverUrl; |
|
| 71 | + $this->_isNotification=TPropertyValue::ensureBoolean($isNotification); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // methods |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | * @return TRpcClient instance |
| 79 | 79 | * @throws TApplicationException if an unsupported RPC client type was specified |
| 80 | 80 | */ |
| 81 | - public static function create($type, $serverUrl, $isNotification = false) |
|
| 81 | + public static function create($type, $serverUrl, $isNotification=false) |
|
| 82 | 82 | { |
| 83 | - if(($_handler = constant('TRpcClientTypesEnumerable::'.strtoupper($type))) === null) |
|
| 83 | + if(($_handler=constant('TRpcClientTypesEnumerable::'.strtoupper($type)))===null) |
|
| 84 | 84 | throw new TApplicationException('rpcclient_unsupported_handler'); |
| 85 | 85 | |
| 86 | 86 | return new $_handler($serverUrl, $isNotification); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | protected function performRequest($serverUrl, $payload, $mimeType) |
| 112 | 112 | { |
| 113 | - if(($_response = @file_get_contents($serverUrl, false, $this->createStreamContext($payload, $mimeType))) === false) |
|
| 113 | + if(($_response=@file_get_contents($serverUrl, false, $this->createStreamContext($payload, $mimeType)))===false) |
|
| 114 | 114 | throw new TRpcClientRequestException('Request failed ("'.$http_response_header[0].'")'); |
| 115 | 115 | |
| 116 | 116 | return $_response; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function setIsNotification($bool) |
| 133 | 133 | { |
| 134 | - $this->_isNotification = TPropertyValue::ensureBoolean($bool); |
|
| 134 | + $this->_isNotification=TPropertyValue::ensureBoolean($bool); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -147,6 +147,6 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function setServerUrl($value) |
| 149 | 149 | { |
| 150 | - $this->_serverUrl = $value; |
|
| 150 | + $this->_serverUrl=$value; |
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | \ No newline at end of file |
@@ -55,6 +55,9 @@ |
||
| 55 | 55 | return self::$_output; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | + /** |
|
| 59 | + * @param integer $level |
|
| 60 | + */ |
|
| 58 | 61 | private static function dumpInternal($var,$level) |
| 59 | 62 | { |
| 60 | 63 | switch(gettype($var)) |
@@ -58,8 +58,7 @@ |
||
| 58 | 58 | if ($this->sourcepath === NULL) |
| 59 | 59 | { |
| 60 | 60 | $this->sourcepath = $sourcepath; |
| 61 | - } |
|
| 62 | - else |
|
| 61 | + } else |
|
| 63 | 62 | { |
| 64 | 63 | $this->sourcepath->append($sourcepath); |
| 65 | 64 | } |
@@ -40,27 +40,27 @@ discard block |
||
| 40 | 40 | * @param integer maximum depth that the dumper should go into the variable. Defaults to 10. |
| 41 | 41 | * @return string the string representation of the variable |
| 42 | 42 | */ |
| 43 | - public static function dump($var,$depth=10,$highlight=false) |
|
| 43 | + public static function dump($var, $depth=10, $highlight=false) |
|
| 44 | 44 | { |
| 45 | 45 | self::$_output=''; |
| 46 | 46 | self::$_objects=array(); |
| 47 | 47 | self::$_depth=$depth; |
| 48 | - self::dumpInternal($var,0); |
|
| 48 | + self::dumpInternal($var, 0); |
|
| 49 | 49 | if($highlight) |
| 50 | 50 | { |
| 51 | - $result=highlight_string("<?php\n".self::$_output,true); |
|
| 52 | - return preg_replace('/<\\?php<br \\/>/','',$result,1); |
|
| 51 | + $result=highlight_string("<?php\n".self::$_output, true); |
|
| 52 | + return preg_replace('/<\\?php<br \\/>/', '', $result, 1); |
|
| 53 | 53 | } |
| 54 | 54 | else |
| 55 | 55 | return self::$_output; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - private static function dumpInternal($var,$level) |
|
| 58 | + private static function dumpInternal($var, $level) |
|
| 59 | 59 | { |
| 60 | 60 | switch(gettype($var)) |
| 61 | 61 | { |
| 62 | 62 | case 'boolean': |
| 63 | - self::$_output.=$var?'true':'false'; |
|
| 63 | + self::$_output.=$var ? 'true' : 'false'; |
|
| 64 | 64 | break; |
| 65 | 65 | case 'integer': |
| 66 | 66 | self::$_output.="$var"; |
@@ -81,41 +81,41 @@ discard block |
||
| 81 | 81 | self::$_output.='{unknown}'; |
| 82 | 82 | break; |
| 83 | 83 | case 'array': |
| 84 | - if(self::$_depth<=$level) |
|
| 84 | + if(self::$_depth <= $level) |
|
| 85 | 85 | self::$_output.='array(...)'; |
| 86 | 86 | else if(empty($var)) |
| 87 | 87 | self::$_output.='array()'; |
| 88 | 88 | else |
| 89 | 89 | { |
| 90 | 90 | $keys=array_keys($var); |
| 91 | - $spaces=str_repeat(' ',$level*4); |
|
| 91 | + $spaces=str_repeat(' ', $level * 4); |
|
| 92 | 92 | self::$_output.="array\n".$spaces.'('; |
| 93 | 93 | foreach($keys as $key) |
| 94 | 94 | { |
| 95 | 95 | self::$_output.="\n".$spaces." [$key] => "; |
| 96 | - self::$_output.=self::dumpInternal($var[$key],$level+1); |
|
| 96 | + self::$_output.=self::dumpInternal($var[$key], $level + 1); |
|
| 97 | 97 | } |
| 98 | 98 | self::$_output.="\n".$spaces.')'; |
| 99 | 99 | } |
| 100 | 100 | break; |
| 101 | 101 | case 'object': |
| 102 | - if(($id=array_search($var,self::$_objects,true))!==false) |
|
| 103 | - self::$_output.=get_class($var).'#'.($id+1).'(...)'; |
|
| 104 | - else if(self::$_depth<=$level) |
|
| 102 | + if(($id=array_search($var, self::$_objects, true))!==false) |
|
| 103 | + self::$_output.=get_class($var).'#'.($id + 1).'(...)'; |
|
| 104 | + else if(self::$_depth <= $level) |
|
| 105 | 105 | self::$_output.=get_class($var).'(...)'; |
| 106 | 106 | else |
| 107 | 107 | { |
| 108 | - $id=array_push(self::$_objects,$var); |
|
| 108 | + $id=array_push(self::$_objects, $var); |
|
| 109 | 109 | $className=get_class($var); |
| 110 | - $members=(array)$var; |
|
| 110 | + $members=(array) $var; |
|
| 111 | 111 | $keys=array_keys($members); |
| 112 | - $spaces=str_repeat(' ',$level*4); |
|
| 112 | + $spaces=str_repeat(' ', $level * 4); |
|
| 113 | 113 | self::$_output.="$className#$id\n".$spaces.'('; |
| 114 | 114 | foreach($keys as $key) |
| 115 | 115 | { |
| 116 | - $keyDisplay=strtr(trim($key),array("\0"=>':')); |
|
| 116 | + $keyDisplay=strtr(trim($key), array("\0"=>':')); |
|
| 117 | 117 | self::$_output.="\n".$spaces." [$keyDisplay] => "; |
| 118 | - self::$_output.=self::dumpInternal($members[$key],$level+1); |
|
| 118 | + self::$_output.=self::dumpInternal($members[$key], $level + 1); |
|
| 119 | 119 | } |
| 120 | 120 | self::$_output.="\n".$spaces.')'; |
| 121 | 121 | } |
@@ -73,6 +73,9 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | // -- Protected Instance Methods --------------------------------------------- |
| 75 | 75 | |
| 76 | + /** |
|
| 77 | + * @param integer $d |
|
| 78 | + */ |
|
| 76 | 79 | protected function action($d) { |
| 77 | 80 | switch($d) { |
| 78 | 81 | case 1: |
@@ -132,6 +135,9 @@ discard block |
||
| 132 | 135 | } |
| 133 | 136 | } |
| 134 | 137 | |
| 138 | + /** |
|
| 139 | + * @return string |
|
| 140 | + */ |
|
| 135 | 141 | protected function get() { |
| 136 | 142 | $c = $this->lookAhead; |
| 137 | 143 | $this->lookAhead = null; |
@@ -156,6 +162,9 @@ discard block |
||
| 156 | 162 | return ' '; |
| 157 | 163 | } |
| 158 | 164 | |
| 165 | + /** |
|
| 166 | + * @param string $c |
|
| 167 | + */ |
|
| 159 | 168 | protected function isAlphaNum($c) { |
| 160 | 169 | return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1; |
| 161 | 170 | } |
@@ -191,8 +191,7 @@ discard block |
||
| 191 | 191 | default: |
| 192 | 192 | if ($this->isAlphaNum($this->b)) { |
| 193 | 193 | $this->action(1); |
| 194 | - } |
|
| 195 | - else { |
|
| 194 | + } else { |
|
| 196 | 195 | $this->action(2); |
| 197 | 196 | } |
| 198 | 197 | } |
@@ -224,8 +223,7 @@ discard block |
||
| 224 | 223 | default: |
| 225 | 224 | if ($this->isAlphaNum($this->a)) { |
| 226 | 225 | $this->action(1); |
| 227 | - } |
|
| 228 | - else { |
|
| 226 | + } else { |
|
| 229 | 227 | $this->action(3); |
| 230 | 228 | } |
| 231 | 229 | } |
@@ -59,228 +59,228 @@ |
||
| 59 | 59 | // -- Public Static Methods -------------------------------------------------- |
| 60 | 60 | |
| 61 | 61 | public static function minify($js) { |
| 62 | - $jsmin = new JSMin($js); |
|
| 63 | - return $jsmin->min(); |
|
| 62 | + $jsmin = new JSMin($js); |
|
| 63 | + return $jsmin->min(); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // -- Public Instance Methods ------------------------------------------------ |
| 67 | 67 | |
| 68 | 68 | public function __construct($input) { |
| 69 | - $this->input = str_replace("\r\n", "\n", $input); |
|
| 70 | - $this->inputLength = strlen($this->input); |
|
| 69 | + $this->input = str_replace("\r\n", "\n", $input); |
|
| 70 | + $this->inputLength = strlen($this->input); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // -- Protected Instance Methods --------------------------------------------- |
| 74 | 74 | |
| 75 | 75 | protected function action($d) { |
| 76 | - switch($d) { |
|
| 77 | - case 1: |
|
| 78 | - $this->output .= $this->a; |
|
| 79 | - |
|
| 80 | - case 2: |
|
| 81 | - $this->a = $this->b; |
|
| 82 | - |
|
| 83 | - if ($this->a === "'" || $this->a === '"') { |
|
| 84 | - for (;;) { |
|
| 85 | - $this->output .= $this->a; |
|
| 86 | - $this->a = $this->get(); |
|
| 87 | - |
|
| 88 | - if ($this->a === $this->b) { |
|
| 89 | - break; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - if (ord($this->a) <= self::ORD_LF) { |
|
| 93 | - throw new JSMinException('Unterminated string literal.'); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - if ($this->a === '\\') { |
|
| 97 | - $this->output .= $this->a; |
|
| 98 | - $this->a = $this->get(); |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - case 3: |
|
| 104 | - $this->b = $this->next(); |
|
| 105 | - |
|
| 106 | - if ($this->b === '/' && ( |
|
| 107 | - $this->a === '(' || $this->a === ',' || $this->a === '=' || |
|
| 108 | - $this->a === ':' || $this->a === '[' || $this->a === '!' || |
|
| 109 | - $this->a === '&' || $this->a === '|' || $this->a === '?')) { |
|
| 110 | - |
|
| 111 | - $this->output .= $this->a . $this->b; |
|
| 112 | - |
|
| 113 | - for (;;) { |
|
| 114 | - $this->a = $this->get(); |
|
| 115 | - |
|
| 116 | - if ($this->a === '/') { |
|
| 117 | - break; |
|
| 118 | - } elseif ($this->a === '\\') { |
|
| 119 | - $this->output .= $this->a; |
|
| 120 | - $this->a = $this->get(); |
|
| 121 | - } elseif (ord($this->a) <= self::ORD_LF) { |
|
| 122 | - throw new JSMinException('Unterminated regular expression '. |
|
| 123 | - 'literal.'); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - $this->output .= $this->a; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - $this->b = $this->next(); |
|
| 130 | - } |
|
| 131 | - } |
|
| 76 | + switch($d) { |
|
| 77 | + case 1: |
|
| 78 | + $this->output .= $this->a; |
|
| 79 | + |
|
| 80 | + case 2: |
|
| 81 | + $this->a = $this->b; |
|
| 82 | + |
|
| 83 | + if ($this->a === "'" || $this->a === '"') { |
|
| 84 | + for (;;) { |
|
| 85 | + $this->output .= $this->a; |
|
| 86 | + $this->a = $this->get(); |
|
| 87 | + |
|
| 88 | + if ($this->a === $this->b) { |
|
| 89 | + break; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + if (ord($this->a) <= self::ORD_LF) { |
|
| 93 | + throw new JSMinException('Unterminated string literal.'); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if ($this->a === '\\') { |
|
| 97 | + $this->output .= $this->a; |
|
| 98 | + $this->a = $this->get(); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + case 3: |
|
| 104 | + $this->b = $this->next(); |
|
| 105 | + |
|
| 106 | + if ($this->b === '/' && ( |
|
| 107 | + $this->a === '(' || $this->a === ',' || $this->a === '=' || |
|
| 108 | + $this->a === ':' || $this->a === '[' || $this->a === '!' || |
|
| 109 | + $this->a === '&' || $this->a === '|' || $this->a === '?')) { |
|
| 110 | + |
|
| 111 | + $this->output .= $this->a . $this->b; |
|
| 112 | + |
|
| 113 | + for (;;) { |
|
| 114 | + $this->a = $this->get(); |
|
| 115 | + |
|
| 116 | + if ($this->a === '/') { |
|
| 117 | + break; |
|
| 118 | + } elseif ($this->a === '\\') { |
|
| 119 | + $this->output .= $this->a; |
|
| 120 | + $this->a = $this->get(); |
|
| 121 | + } elseif (ord($this->a) <= self::ORD_LF) { |
|
| 122 | + throw new JSMinException('Unterminated regular expression '. |
|
| 123 | + 'literal.'); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + $this->output .= $this->a; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + $this->b = $this->next(); |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | protected function get() { |
| 135 | - $c = $this->lookAhead; |
|
| 136 | - $this->lookAhead = null; |
|
| 137 | - |
|
| 138 | - if ($c === null) { |
|
| 139 | - if ($this->inputIndex < $this->inputLength) { |
|
| 140 | - $c = $this->input[$this->inputIndex]; |
|
| 141 | - $this->inputIndex += 1; |
|
| 142 | - } else { |
|
| 143 | - $c = null; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - if ($c === "\r") { |
|
| 148 | - return "\n"; |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) { |
|
| 152 | - return $c; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - return ' '; |
|
| 135 | + $c = $this->lookAhead; |
|
| 136 | + $this->lookAhead = null; |
|
| 137 | + |
|
| 138 | + if ($c === null) { |
|
| 139 | + if ($this->inputIndex < $this->inputLength) { |
|
| 140 | + $c = $this->input[$this->inputIndex]; |
|
| 141 | + $this->inputIndex += 1; |
|
| 142 | + } else { |
|
| 143 | + $c = null; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + if ($c === "\r") { |
|
| 148 | + return "\n"; |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) { |
|
| 152 | + return $c; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + return ' '; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | protected function isAlphaNum($c) { |
| 159 | - return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1; |
|
| 159 | + return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | protected function min() { |
| 163 | - $this->a = "\n"; |
|
| 164 | - $this->action(3); |
|
| 165 | - |
|
| 166 | - while ($this->a !== null) { |
|
| 167 | - switch ($this->a) { |
|
| 168 | - case ' ': |
|
| 169 | - if ($this->isAlphaNum($this->b)) { |
|
| 170 | - $this->action(1); |
|
| 171 | - } else { |
|
| 172 | - $this->action(2); |
|
| 173 | - } |
|
| 174 | - break; |
|
| 175 | - |
|
| 176 | - case "\n": |
|
| 177 | - switch ($this->b) { |
|
| 178 | - case '{': |
|
| 179 | - case '[': |
|
| 180 | - case '(': |
|
| 181 | - case '+': |
|
| 182 | - case '-': |
|
| 183 | - $this->action(1); |
|
| 184 | - break; |
|
| 185 | - |
|
| 186 | - case ' ': |
|
| 187 | - $this->action(3); |
|
| 188 | - break; |
|
| 189 | - |
|
| 190 | - default: |
|
| 191 | - if ($this->isAlphaNum($this->b)) { |
|
| 192 | - $this->action(1); |
|
| 193 | - } |
|
| 194 | - else { |
|
| 195 | - $this->action(2); |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - break; |
|
| 199 | - |
|
| 200 | - default: |
|
| 201 | - switch ($this->b) { |
|
| 202 | - case ' ': |
|
| 203 | - if ($this->isAlphaNum($this->a)) { |
|
| 204 | - $this->action(1); |
|
| 205 | - break; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - $this->action(3); |
|
| 209 | - break; |
|
| 210 | - |
|
| 211 | - case "\n": |
|
| 212 | - switch ($this->a) { |
|
| 213 | - case '}': |
|
| 214 | - case ']': |
|
| 215 | - case ')': |
|
| 216 | - case '+': |
|
| 217 | - case '-': |
|
| 218 | - case '"': |
|
| 219 | - case "'": |
|
| 220 | - $this->action(1); |
|
| 221 | - break; |
|
| 222 | - |
|
| 223 | - default: |
|
| 224 | - if ($this->isAlphaNum($this->a)) { |
|
| 225 | - $this->action(1); |
|
| 226 | - } |
|
| 227 | - else { |
|
| 228 | - $this->action(3); |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - break; |
|
| 232 | - |
|
| 233 | - default: |
|
| 234 | - $this->action(1); |
|
| 235 | - break; |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - return $this->output; |
|
| 163 | + $this->a = "\n"; |
|
| 164 | + $this->action(3); |
|
| 165 | + |
|
| 166 | + while ($this->a !== null) { |
|
| 167 | + switch ($this->a) { |
|
| 168 | + case ' ': |
|
| 169 | + if ($this->isAlphaNum($this->b)) { |
|
| 170 | + $this->action(1); |
|
| 171 | + } else { |
|
| 172 | + $this->action(2); |
|
| 173 | + } |
|
| 174 | + break; |
|
| 175 | + |
|
| 176 | + case "\n": |
|
| 177 | + switch ($this->b) { |
|
| 178 | + case '{': |
|
| 179 | + case '[': |
|
| 180 | + case '(': |
|
| 181 | + case '+': |
|
| 182 | + case '-': |
|
| 183 | + $this->action(1); |
|
| 184 | + break; |
|
| 185 | + |
|
| 186 | + case ' ': |
|
| 187 | + $this->action(3); |
|
| 188 | + break; |
|
| 189 | + |
|
| 190 | + default: |
|
| 191 | + if ($this->isAlphaNum($this->b)) { |
|
| 192 | + $this->action(1); |
|
| 193 | + } |
|
| 194 | + else { |
|
| 195 | + $this->action(2); |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + break; |
|
| 199 | + |
|
| 200 | + default: |
|
| 201 | + switch ($this->b) { |
|
| 202 | + case ' ': |
|
| 203 | + if ($this->isAlphaNum($this->a)) { |
|
| 204 | + $this->action(1); |
|
| 205 | + break; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + $this->action(3); |
|
| 209 | + break; |
|
| 210 | + |
|
| 211 | + case "\n": |
|
| 212 | + switch ($this->a) { |
|
| 213 | + case '}': |
|
| 214 | + case ']': |
|
| 215 | + case ')': |
|
| 216 | + case '+': |
|
| 217 | + case '-': |
|
| 218 | + case '"': |
|
| 219 | + case "'": |
|
| 220 | + $this->action(1); |
|
| 221 | + break; |
|
| 222 | + |
|
| 223 | + default: |
|
| 224 | + if ($this->isAlphaNum($this->a)) { |
|
| 225 | + $this->action(1); |
|
| 226 | + } |
|
| 227 | + else { |
|
| 228 | + $this->action(3); |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + break; |
|
| 232 | + |
|
| 233 | + default: |
|
| 234 | + $this->action(1); |
|
| 235 | + break; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + return $this->output; |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | protected function next() { |
| 244 | - $c = $this->get(); |
|
| 245 | - |
|
| 246 | - if ($c === '/') { |
|
| 247 | - switch($this->peek()) { |
|
| 248 | - case '/': |
|
| 249 | - for (;;) { |
|
| 250 | - $c = $this->get(); |
|
| 251 | - |
|
| 252 | - if (ord($c) <= self::ORD_LF) { |
|
| 253 | - return $c; |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - case '*': |
|
| 258 | - $this->get(); |
|
| 259 | - |
|
| 260 | - for (;;) { |
|
| 261 | - switch($this->get()) { |
|
| 262 | - case '*': |
|
| 263 | - if ($this->peek() === '/') { |
|
| 264 | - $this->get(); |
|
| 265 | - return ' '; |
|
| 266 | - } |
|
| 267 | - break; |
|
| 268 | - |
|
| 269 | - case null: |
|
| 270 | - throw new JSMinException('Unterminated comment.'); |
|
| 271 | - } |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - default: |
|
| 275 | - return $c; |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - return $c; |
|
| 244 | + $c = $this->get(); |
|
| 245 | + |
|
| 246 | + if ($c === '/') { |
|
| 247 | + switch($this->peek()) { |
|
| 248 | + case '/': |
|
| 249 | + for (;;) { |
|
| 250 | + $c = $this->get(); |
|
| 251 | + |
|
| 252 | + if (ord($c) <= self::ORD_LF) { |
|
| 253 | + return $c; |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + case '*': |
|
| 258 | + $this->get(); |
|
| 259 | + |
|
| 260 | + for (;;) { |
|
| 261 | + switch($this->get()) { |
|
| 262 | + case '*': |
|
| 263 | + if ($this->peek() === '/') { |
|
| 264 | + $this->get(); |
|
| 265 | + return ' '; |
|
| 266 | + } |
|
| 267 | + break; |
|
| 268 | + |
|
| 269 | + case null: |
|
| 270 | + throw new JSMinException('Unterminated comment.'); |
|
| 271 | + } |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + default: |
|
| 275 | + return $c; |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + return $c; |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | protected function peek() { |
| 283 | - $this->lookAhead = $this->get(); |
|
| 284 | - return $this->lookAhead; |
|
| 283 | + $this->lookAhead = $this->get(); |
|
| 284 | + return $this->lookAhead; |
|
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | \ No newline at end of file |
@@ -45,29 +45,29 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | |
| 47 | 47 | class JSMin { |
| 48 | - const ORD_LF = 10; |
|
| 49 | - const ORD_SPACE = 32; |
|
| 48 | + const ORD_LF=10; |
|
| 49 | + const ORD_SPACE=32; |
|
| 50 | 50 | |
| 51 | - protected $a = ''; |
|
| 52 | - protected $b = ''; |
|
| 53 | - protected $input = ''; |
|
| 54 | - protected $inputIndex = 0; |
|
| 55 | - protected $inputLength = 0; |
|
| 56 | - protected $lookAhead = null; |
|
| 57 | - protected $output = ''; |
|
| 51 | + protected $a=''; |
|
| 52 | + protected $b=''; |
|
| 53 | + protected $input=''; |
|
| 54 | + protected $inputIndex=0; |
|
| 55 | + protected $inputLength=0; |
|
| 56 | + protected $lookAhead=null; |
|
| 57 | + protected $output=''; |
|
| 58 | 58 | |
| 59 | 59 | // -- Public Static Methods -------------------------------------------------- |
| 60 | 60 | |
| 61 | 61 | public static function minify($js) { |
| 62 | - $jsmin = new JSMin($js); |
|
| 62 | + $jsmin=new JSMin($js); |
|
| 63 | 63 | return $jsmin->min(); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // -- Public Instance Methods ------------------------------------------------ |
| 67 | 67 | |
| 68 | 68 | public function __construct($input) { |
| 69 | - $this->input = str_replace("\r\n", "\n", $input); |
|
| 70 | - $this->inputLength = strlen($this->input); |
|
| 69 | + $this->input=str_replace("\r\n", "\n", $input); |
|
| 70 | + $this->inputLength=strlen($this->input); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // -- Protected Instance Methods --------------------------------------------- |
@@ -75,80 +75,80 @@ discard block |
||
| 75 | 75 | protected function action($d) { |
| 76 | 76 | switch($d) { |
| 77 | 77 | case 1: |
| 78 | - $this->output .= $this->a; |
|
| 78 | + $this->output.=$this->a; |
|
| 79 | 79 | |
| 80 | 80 | case 2: |
| 81 | - $this->a = $this->b; |
|
| 81 | + $this->a=$this->b; |
|
| 82 | 82 | |
| 83 | - if ($this->a === "'" || $this->a === '"') { |
|
| 84 | - for (;;) { |
|
| 85 | - $this->output .= $this->a; |
|
| 86 | - $this->a = $this->get(); |
|
| 83 | + if($this->a==="'" || $this->a==='"') { |
|
| 84 | + for(;;) { |
|
| 85 | + $this->output.=$this->a; |
|
| 86 | + $this->a=$this->get(); |
|
| 87 | 87 | |
| 88 | - if ($this->a === $this->b) { |
|
| 88 | + if($this->a===$this->b) { |
|
| 89 | 89 | break; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if (ord($this->a) <= self::ORD_LF) { |
|
| 92 | + if(ord($this->a) <= self::ORD_LF) { |
|
| 93 | 93 | throw new JSMinException('Unterminated string literal.'); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - if ($this->a === '\\') { |
|
| 97 | - $this->output .= $this->a; |
|
| 98 | - $this->a = $this->get(); |
|
| 96 | + if($this->a==='\\') { |
|
| 97 | + $this->output.=$this->a; |
|
| 98 | + $this->a=$this->get(); |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | case 3: |
| 104 | - $this->b = $this->next(); |
|
| 104 | + $this->b=$this->next(); |
|
| 105 | 105 | |
| 106 | - if ($this->b === '/' && ( |
|
| 107 | - $this->a === '(' || $this->a === ',' || $this->a === '=' || |
|
| 108 | - $this->a === ':' || $this->a === '[' || $this->a === '!' || |
|
| 109 | - $this->a === '&' || $this->a === '|' || $this->a === '?')) { |
|
| 106 | + if($this->b==='/' && ( |
|
| 107 | + $this->a==='(' || $this->a===',' || $this->a==='=' || |
|
| 108 | + $this->a===':' || $this->a==='[' || $this->a==='!' || |
|
| 109 | + $this->a==='&' || $this->a==='|' || $this->a==='?')) { |
|
| 110 | 110 | |
| 111 | - $this->output .= $this->a . $this->b; |
|
| 111 | + $this->output.=$this->a.$this->b; |
|
| 112 | 112 | |
| 113 | - for (;;) { |
|
| 114 | - $this->a = $this->get(); |
|
| 113 | + for(;;) { |
|
| 114 | + $this->a=$this->get(); |
|
| 115 | 115 | |
| 116 | - if ($this->a === '/') { |
|
| 116 | + if($this->a==='/') { |
|
| 117 | 117 | break; |
| 118 | - } elseif ($this->a === '\\') { |
|
| 119 | - $this->output .= $this->a; |
|
| 120 | - $this->a = $this->get(); |
|
| 121 | - } elseif (ord($this->a) <= self::ORD_LF) { |
|
| 118 | + } elseif($this->a==='\\') { |
|
| 119 | + $this->output.=$this->a; |
|
| 120 | + $this->a=$this->get(); |
|
| 121 | + } elseif(ord($this->a) <= self::ORD_LF) { |
|
| 122 | 122 | throw new JSMinException('Unterminated regular expression '. |
| 123 | 123 | 'literal.'); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - $this->output .= $this->a; |
|
| 126 | + $this->output.=$this->a; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - $this->b = $this->next(); |
|
| 129 | + $this->b=$this->next(); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | protected function get() { |
| 135 | - $c = $this->lookAhead; |
|
| 136 | - $this->lookAhead = null; |
|
| 135 | + $c=$this->lookAhead; |
|
| 136 | + $this->lookAhead=null; |
|
| 137 | 137 | |
| 138 | - if ($c === null) { |
|
| 139 | - if ($this->inputIndex < $this->inputLength) { |
|
| 140 | - $c = $this->input[$this->inputIndex]; |
|
| 141 | - $this->inputIndex += 1; |
|
| 138 | + if($c===null) { |
|
| 139 | + if($this->inputIndex < $this->inputLength) { |
|
| 140 | + $c=$this->input[$this->inputIndex]; |
|
| 141 | + $this->inputIndex+=1; |
|
| 142 | 142 | } else { |
| 143 | - $c = null; |
|
| 143 | + $c=null; |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if ($c === "\r") { |
|
| 147 | + if($c==="\r") { |
|
| 148 | 148 | return "\n"; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) { |
|
| 151 | + if($c===null || $c==="\n" || ord($c) >= self::ORD_SPACE) { |
|
| 152 | 152 | return $c; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -156,17 +156,17 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | protected function isAlphaNum($c) { |
| 159 | - return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1; |
|
| 159 | + return ord($c) > 126 || $c==='\\' || preg_match('/^[\w\$]$/', $c)===1; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | protected function min() { |
| 163 | - $this->a = "\n"; |
|
| 163 | + $this->a="\n"; |
|
| 164 | 164 | $this->action(3); |
| 165 | 165 | |
| 166 | - while ($this->a !== null) { |
|
| 167 | - switch ($this->a) { |
|
| 166 | + while($this->a!==null) { |
|
| 167 | + switch($this->a) { |
|
| 168 | 168 | case ' ': |
| 169 | - if ($this->isAlphaNum($this->b)) { |
|
| 169 | + if($this->isAlphaNum($this->b)) { |
|
| 170 | 170 | $this->action(1); |
| 171 | 171 | } else { |
| 172 | 172 | $this->action(2); |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | break; |
| 175 | 175 | |
| 176 | 176 | case "\n": |
| 177 | - switch ($this->b) { |
|
| 177 | + switch($this->b) { |
|
| 178 | 178 | case '{': |
| 179 | 179 | case '[': |
| 180 | 180 | case '(': |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | break; |
| 189 | 189 | |
| 190 | 190 | default: |
| 191 | - if ($this->isAlphaNum($this->b)) { |
|
| 191 | + if($this->isAlphaNum($this->b)) { |
|
| 192 | 192 | $this->action(1); |
| 193 | 193 | } |
| 194 | 194 | else { |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | break; |
| 199 | 199 | |
| 200 | 200 | default: |
| 201 | - switch ($this->b) { |
|
| 201 | + switch($this->b) { |
|
| 202 | 202 | case ' ': |
| 203 | - if ($this->isAlphaNum($this->a)) { |
|
| 203 | + if($this->isAlphaNum($this->a)) { |
|
| 204 | 204 | $this->action(1); |
| 205 | 205 | break; |
| 206 | 206 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | break; |
| 210 | 210 | |
| 211 | 211 | case "\n": |
| 212 | - switch ($this->a) { |
|
| 212 | + switch($this->a) { |
|
| 213 | 213 | case '}': |
| 214 | 214 | case ']': |
| 215 | 215 | case ')': |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | break; |
| 222 | 222 | |
| 223 | 223 | default: |
| 224 | - if ($this->isAlphaNum($this->a)) { |
|
| 224 | + if($this->isAlphaNum($this->a)) { |
|
| 225 | 225 | $this->action(1); |
| 226 | 226 | } |
| 227 | 227 | else { |
@@ -241,15 +241,15 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | protected function next() { |
| 244 | - $c = $this->get(); |
|
| 244 | + $c=$this->get(); |
|
| 245 | 245 | |
| 246 | - if ($c === '/') { |
|
| 246 | + if($c==='/') { |
|
| 247 | 247 | switch($this->peek()) { |
| 248 | 248 | case '/': |
| 249 | - for (;;) { |
|
| 250 | - $c = $this->get(); |
|
| 249 | + for(;;) { |
|
| 250 | + $c=$this->get(); |
|
| 251 | 251 | |
| 252 | - if (ord($c) <= self::ORD_LF) { |
|
| 252 | + if(ord($c) <= self::ORD_LF) { |
|
| 253 | 253 | return $c; |
| 254 | 254 | } |
| 255 | 255 | } |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | case '*': |
| 258 | 258 | $this->get(); |
| 259 | 259 | |
| 260 | - for (;;) { |
|
| 260 | + for(;;) { |
|
| 261 | 261 | switch($this->get()) { |
| 262 | 262 | case '*': |
| 263 | - if ($this->peek() === '/') { |
|
| 263 | + if($this->peek()==='/') { |
|
| 264 | 264 | $this->get(); |
| 265 | 265 | return ' '; |
| 266 | 266 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | protected function peek() { |
| 283 | - $this->lookAhead = $this->get(); |
|
| 283 | + $this->lookAhead=$this->get(); |
|
| 284 | 284 | return $this->lookAhead; |
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | \ No newline at end of file |
@@ -140,6 +140,7 @@ |
||
| 140 | 140 | /** |
| 141 | 141 | * Renders content provided by TJsonResponse::getJsonContent() as |
| 142 | 142 | * javascript in JSON format. |
| 143 | + * @param TJsonResponse $service |
|
| 143 | 144 | */ |
| 144 | 145 | protected function createJsonResponse($service,$properties,$config) |
| 145 | 146 | { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | if(is_array($config)) |
| 78 | 78 | { |
| 79 | 79 | foreach($config['json'] as $id => $json) |
| 80 | - $this->_services[$id] = $json; |
|
| 80 | + $this->_services[$id]=$json; |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | else |
@@ -109,14 +109,14 @@ discard block |
||
| 109 | 109 | $service=Prado::createComponent($serviceConfig['class']); |
| 110 | 110 | if($service instanceof TJsonResponse) |
| 111 | 111 | { |
| 112 | - $properties = isset($serviceConfig['properties'])?$serviceConfig['properties']:array(); |
|
| 113 | - $this->createJsonResponse($service,$properties,$serviceConfig); |
|
| 112 | + $properties=isset($serviceConfig['properties']) ? $serviceConfig['properties'] : array(); |
|
| 113 | + $this->createJsonResponse($service, $properties, $serviceConfig); |
|
| 114 | 114 | } |
| 115 | 115 | else |
| 116 | - throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
|
| 116 | + throw new TConfigurationException('jsonservice_response_type_invalid', $id); |
|
| 117 | 117 | } |
| 118 | 118 | else |
| 119 | - throw new TConfigurationException('jsonservice_class_required',$id); |
|
| 119 | + throw new TConfigurationException('jsonservice_class_required', $id); |
|
| 120 | 120 | } |
| 121 | 121 | else |
| 122 | 122 | { |
@@ -125,33 +125,33 @@ discard block |
||
| 125 | 125 | { |
| 126 | 126 | $service=Prado::createComponent($class); |
| 127 | 127 | if($service instanceof TJsonResponse) |
| 128 | - $this->createJsonResponse($service,$properties,$serviceConfig); |
|
| 128 | + $this->createJsonResponse($service, $properties, $serviceConfig); |
|
| 129 | 129 | else |
| 130 | - throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
|
| 130 | + throw new TConfigurationException('jsonservice_response_type_invalid', $id); |
|
| 131 | 131 | } |
| 132 | 132 | else |
| 133 | - throw new TConfigurationException('jsonservice_class_required',$id); |
|
| 133 | + throw new TConfigurationException('jsonservice_class_required', $id); |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | else |
| 137 | - throw new THttpException(404,'jsonservice_provider_unknown',$id); |
|
| 137 | + throw new THttpException(404, 'jsonservice_provider_unknown', $id); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
| 141 | 141 | * Renders content provided by TJsonResponse::getJsonContent() as |
| 142 | 142 | * javascript in JSON format. |
| 143 | 143 | */ |
| 144 | - protected function createJsonResponse($service,$properties,$config) |
|
| 144 | + protected function createJsonResponse($service, $properties, $config) |
|
| 145 | 145 | { |
| 146 | 146 | // init service properties |
| 147 | 147 | foreach($properties as $name=>$value) |
| 148 | - $service->setSubproperty($name,$value); |
|
| 148 | + $service->setSubproperty($name, $value); |
|
| 149 | 149 | $service->init($config); |
| 150 | 150 | |
| 151 | 151 | //send content if not null |
| 152 | 152 | if(($content=$service->getJsonContent())!==null) |
| 153 | 153 | { |
| 154 | - $response = $this->getResponse(); |
|
| 154 | + $response=$this->getResponse(); |
|
| 155 | 155 | $response->setContentType('application/json'); |
| 156 | 156 | $response->setCharset('UTF-8'); |
| 157 | 157 | //send content |
@@ -79,8 +79,7 @@ discard block |
||
| 79 | 79 | foreach($config['json'] as $id => $json) |
| 80 | 80 | $this->_services[$id] = $json; |
| 81 | 81 | } |
| 82 | - } |
|
| 83 | - else |
|
| 82 | + } else |
|
| 84 | 83 | { |
| 85 | 84 | foreach($config->getElementsByTagName('json') as $json) |
| 86 | 85 | { |
@@ -111,14 +110,11 @@ discard block |
||
| 111 | 110 | { |
| 112 | 111 | $properties = isset($serviceConfig['properties'])?$serviceConfig['properties']:array(); |
| 113 | 112 | $this->createJsonResponse($service,$properties,$serviceConfig); |
| 114 | - } |
|
| 115 | - else |
|
| 113 | + } else |
|
| 116 | 114 | throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
| 117 | - } |
|
| 118 | - else |
|
| 115 | + } else |
|
| 119 | 116 | throw new TConfigurationException('jsonservice_class_required',$id); |
| 120 | - } |
|
| 121 | - else |
|
| 117 | + } else |
|
| 122 | 118 | { |
| 123 | 119 | $properties=$serviceConfig->getAttributes(); |
| 124 | 120 | if(($class=$properties->remove('class'))!==null) |
@@ -128,12 +124,10 @@ discard block |
||
| 128 | 124 | $this->createJsonResponse($service,$properties,$serviceConfig); |
| 129 | 125 | else |
| 130 | 126 | throw new TConfigurationException('jsonservice_response_type_invalid',$id); |
| 131 | - } |
|
| 132 | - else |
|
| 127 | + } else |
|
| 133 | 128 | throw new TConfigurationException('jsonservice_class_required',$id); |
| 134 | 129 | } |
| 135 | - } |
|
| 136 | - else |
|
| 130 | + } else |
|
| 137 | 131 | throw new THttpException(404,'jsonservice_provider_unknown',$id); |
| 138 | 132 | } |
| 139 | 133 | |
@@ -31,6 +31,7 @@ |
||
| 31 | 31 | /** |
| 32 | 32 | * Constructor. Attach a response to be adapted. |
| 33 | 33 | * @param THttpResponse the response object the adapter is to attach to. |
| 34 | + * @param THttpResponse $response |
|
| 34 | 35 | */ |
| 35 | 36 | public function __construct($response) |
| 36 | 37 | { |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | */ |
| 72 | 72 | public function createNewHtmlWriter($type, $writer) |
| 73 | 73 | { |
| 74 | - return $this->_response->createNewHtmlWriter($type,$writer); |
|
| 74 | + return $this->_response->createNewHtmlWriter($type, $writer); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
@@ -265,6 +265,7 @@ discard block |
||
| 265 | 265 | * If true, make sure the methods {@link _open}, {@link _close}, {@link _read}, |
| 266 | 266 | * {@link _write}, {@link _destroy}, and {@link _gc} are overridden in child |
| 267 | 267 | * class, because they will be used as the callback handlers. |
| 268 | + * @param boolean $value |
|
| 268 | 269 | */ |
| 269 | 270 | public function setUseCustomStorage($value) |
| 270 | 271 | { |
@@ -527,6 +528,7 @@ discard block |
||
| 527 | 528 | * Returns the session variable value with the session variable name. |
| 528 | 529 | * This method is exactly the same as {@link offsetGet}. |
| 529 | 530 | * @param mixed the session variable name |
| 531 | + * @param string $key |
|
| 530 | 532 | * @return mixed the session variable value, null if no such variable exists |
| 531 | 533 | */ |
| 532 | 534 | public function itemAt($key) |
@@ -539,6 +541,7 @@ discard block |
||
| 539 | 541 | * Note, if the specified name already exists, the old value will be removed first. |
| 540 | 542 | * @param mixed session variable name |
| 541 | 543 | * @param mixed session variable value |
| 544 | + * @param string $key |
|
| 542 | 545 | */ |
| 543 | 546 | public function add($key,$value) |
| 544 | 547 | { |
@@ -306,10 +306,10 @@ |
||
| 306 | 306 | { |
| 307 | 307 | $value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode'); |
| 308 | 308 | if($value===THttpSessionCookieMode::None) |
| 309 | - { |
|
| 309 | + { |
|
| 310 | 310 | ini_set('session.use_cookies','0'); |
| 311 | 311 | ini_set('session.use_only_cookies','0'); |
| 312 | - } |
|
| 312 | + } |
|
| 313 | 313 | else if($value===THttpSessionCookieMode::Allow) |
| 314 | 314 | { |
| 315 | 315 | ini_set('session.use_cookies','1'); |
@@ -309,13 +309,11 @@ discard block |
||
| 309 | 309 | { |
| 310 | 310 | ini_set('session.use_cookies','0'); |
| 311 | 311 | ini_set('session.use_only_cookies','0'); |
| 312 | - } |
|
| 313 | - else if($value===THttpSessionCookieMode::Allow) |
|
| 312 | + } else if($value===THttpSessionCookieMode::Allow) |
|
| 314 | 313 | { |
| 315 | 314 | ini_set('session.use_cookies','1'); |
| 316 | 315 | ini_set('session.use_only_cookies','0'); |
| 317 | - } |
|
| 318 | - else |
|
| 316 | + } else |
|
| 319 | 317 | { |
| 320 | 318 | ini_set('session.use_cookies','1'); |
| 321 | 319 | ini_set('session.use_only_cookies','1'); |
@@ -368,8 +366,7 @@ discard block |
||
| 368 | 366 | { |
| 369 | 367 | ini_set('session.gc_probability',$value); |
| 370 | 368 | ini_set('session.gc_divisor','100'); |
| 371 | - } |
|
| 372 | - else |
|
| 369 | + } else |
|
| 373 | 370 | throw new TInvalidDataValueException('httpsession_gcprobability_invalid',$value); |
| 374 | 371 | } |
| 375 | 372 | } |
@@ -557,8 +554,7 @@ discard block |
||
| 557 | 554 | $value=$_SESSION[$key]; |
| 558 | 555 | unset($_SESSION[$key]); |
| 559 | 556 | return $value; |
| 560 | - } |
|
| 561 | - else |
|
| 557 | + } else |
|
| 562 | 558 | return null; |
| 563 | 559 | } |
| 564 | 560 | |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | if(!$this->_started) |
| 139 | 139 | { |
| 140 | 140 | if($this->_customStorage) |
| 141 | - session_set_save_handler(array($this,'_open'),array($this,'_close'),array($this,'_read'),array($this,'_write'),array($this,'_destroy'),array($this,'_gc')); |
|
| 141 | + session_set_save_handler(array($this, '_open'), array($this, '_close'), array($this, '_read'), array($this, '_write'), array($this, '_destroy'), array($this, '_gc')); |
|
| 142 | 142 | if($this->_cookie!==null) |
| 143 | - session_set_cookie_params($this->_cookie->getExpire(),$this->_cookie->getPath(),$this->_cookie->getDomain(),$this->_cookie->getSecure(),$this->_cookie->getHttpOnly()); |
|
| 143 | + session_set_cookie_params($this->_cookie->getExpire(), $this->_cookie->getPath(), $this->_cookie->getDomain(), $this->_cookie->getSecure(), $this->_cookie->getHttpOnly()); |
|
| 144 | 144 | if(ini_get('session.auto_start')!=='1') |
| 145 | 145 | session_start(); |
| 146 | 146 | $this->_started=true; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function regenerate($deleteOld=false) |
| 182 | 182 | { |
| 183 | - $old = $this->getSessionID(); |
|
| 183 | + $old=$this->getSessionID(); |
|
| 184 | 184 | session_regenerate_id($deleteOld); |
| 185 | 185 | return $old; |
| 186 | 186 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | else if(ctype_alnum($value)) |
| 233 | 233 | session_name($value); |
| 234 | 234 | else |
| 235 | - throw new TInvalidDataValueException('httpsession_sessionname_invalid',$value); |
|
| 235 | + throw new TInvalidDataValueException('httpsession_sessionname_invalid', $value); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | else if(is_dir($value)) |
| 255 | 255 | session_save_path($value); |
| 256 | 256 | else |
| 257 | - throw new TInvalidDataValueException('httpsession_savepath_invalid',$value); |
|
| 257 | + throw new TInvalidDataValueException('httpsession_savepath_invalid', $value); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | public function getCookie() |
| 283 | 283 | { |
| 284 | 284 | if($this->_cookie===null) |
| 285 | - $this->_cookie=new THttpCookie($this->getSessionName(),$this->getSessionID()); |
|
| 285 | + $this->_cookie=new THttpCookie($this->getSessionName(), $this->getSessionID()); |
|
| 286 | 286 | return $this->_cookie; |
| 287 | 287 | } |
| 288 | 288 | |
@@ -309,21 +309,21 @@ discard block |
||
| 309 | 309 | throw new TInvalidOperationException('httpsession_cookiemode_unchangeable'); |
| 310 | 310 | else |
| 311 | 311 | { |
| 312 | - $value=TPropertyValue::ensureEnum($value,'Prado\\Web\\THttpSessionCookieMode'); |
|
| 312 | + $value=TPropertyValue::ensureEnum($value, 'Prado\\Web\\THttpSessionCookieMode'); |
|
| 313 | 313 | if($value===THttpSessionCookieMode::None) |
| 314 | 314 | { |
| 315 | - ini_set('session.use_cookies','0'); |
|
| 316 | - ini_set('session.use_only_cookies','0'); |
|
| 315 | + ini_set('session.use_cookies', '0'); |
|
| 316 | + ini_set('session.use_only_cookies', '0'); |
|
| 317 | 317 | } |
| 318 | 318 | else if($value===THttpSessionCookieMode::Allow) |
| 319 | 319 | { |
| 320 | - ini_set('session.use_cookies','1'); |
|
| 321 | - ini_set('session.use_only_cookies','0'); |
|
| 320 | + ini_set('session.use_cookies', '1'); |
|
| 321 | + ini_set('session.use_only_cookies', '0'); |
|
| 322 | 322 | } |
| 323 | 323 | else |
| 324 | 324 | { |
| 325 | - ini_set('session.use_cookies','1'); |
|
| 326 | - ini_set('session.use_only_cookies','1'); |
|
| 325 | + ini_set('session.use_cookies', '1'); |
|
| 326 | + ini_set('session.use_only_cookies', '1'); |
|
| 327 | 327 | ini_set('session.use_trans_sid', 0); |
| 328 | 328 | } |
| 329 | 329 | } |
@@ -369,13 +369,13 @@ discard block |
||
| 369 | 369 | else |
| 370 | 370 | { |
| 371 | 371 | $value=TPropertyValue::ensureInteger($value); |
| 372 | - if($value>=0 && $value<=100) |
|
| 372 | + if($value >= 0 && $value <= 100) |
|
| 373 | 373 | { |
| 374 | - ini_set('session.gc_probability',$value); |
|
| 375 | - ini_set('session.gc_divisor','100'); |
|
| 374 | + ini_set('session.gc_probability', $value); |
|
| 375 | + ini_set('session.gc_divisor', '100'); |
|
| 376 | 376 | } |
| 377 | 377 | else |
| 378 | - throw new TInvalidDataValueException('httpsession_gcprobability_invalid',$value); |
|
| 378 | + throw new TInvalidDataValueException('httpsession_gcprobability_invalid', $value); |
|
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | 381 | |
@@ -397,9 +397,9 @@ discard block |
||
| 397 | 397 | else |
| 398 | 398 | { |
| 399 | 399 | $value=TPropertyValue::ensureBoolean($value); |
| 400 | - if ($value && $this->getCookieMode()==THttpSessionCookieMode::Only) |
|
| 400 | + if($value && $this->getCookieMode()==THttpSessionCookieMode::Only) |
|
| 401 | 401 | throw new TInvalidOperationException('httpsession_transid_cookieonly'); |
| 402 | - ini_set('session.use_trans_sid',$value?'1':'0'); |
|
| 402 | + ini_set('session.use_trans_sid', $value ? '1' : '0'); |
|
| 403 | 403 | } |
| 404 | 404 | } |
| 405 | 405 | |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | if($this->_started) |
| 421 | 421 | throw new TInvalidOperationException('httpsession_maxlifetime_unchangeable'); |
| 422 | 422 | else |
| 423 | - ini_set('session.gc_maxlifetime',$value); |
|
| 423 | + ini_set('session.gc_maxlifetime', $value); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | /** |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | * @param string session name |
| 431 | 431 | * @return boolean whether session is opened successfully |
| 432 | 432 | */ |
| 433 | - public function _open($savePath,$sessionName) |
|
| 433 | + public function _open($savePath, $sessionName) |
|
| 434 | 434 | { |
| 435 | 435 | return true; |
| 436 | 436 | } |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | * @param string session data |
| 464 | 464 | * @return boolean whether session write is successful |
| 465 | 465 | */ |
| 466 | - public function _write($id,$data) |
|
| 466 | + public function _write($id, $data) |
|
| 467 | 467 | { |
| 468 | 468 | return true; |
| 469 | 469 | } |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | * @param mixed session variable name |
| 546 | 546 | * @param mixed session variable value |
| 547 | 547 | */ |
| 548 | - public function add($key,$value) |
|
| 548 | + public function add($key, $value) |
|
| 549 | 549 | { |
| 550 | 550 | $_SESSION[$key]=$value; |
| 551 | 551 | } |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | * @param integer the offset to set element |
| 619 | 619 | * @param mixed the element value |
| 620 | 620 | */ |
| 621 | - public function offsetSet($offset,$item) |
|
| 621 | + public function offsetSet($offset, $item) |
|
| 622 | 622 | { |
| 623 | 623 | $_SESSION[$offset]=$item; |
| 624 | 624 | } |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | /** |
| 71 | 71 | * Javascript client class for this control. |
| 72 | 72 | * This method overrides the parent implementation. |
| 73 | - * @return null no javascript class name. |
|
| 73 | + * @return string no javascript class name. |
|
| 74 | 74 | */ |
| 75 | 75 | protected function getClientClassName() |
| 76 | 76 | { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | protected function createListItemCollection() |
| 64 | 64 | { |
| 65 | - $collection = new TActiveListItemCollection; |
|
| 65 | + $collection=new TActiveListItemCollection; |
|
| 66 | 66 | $collection->setControl($this); |
| 67 | 67 | return $collection; |
| 68 | 68 | } |
@@ -85,15 +85,15 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function setSelectionMode($value) |
| 87 | 87 | { |
| 88 | - if(parent::getSelectionMode() === $value) |
|
| 88 | + if(parent::getSelectionMode()===$value) |
|
| 89 | 89 | return; |
| 90 | 90 | |
| 91 | 91 | parent::setSelectionMode($value); |
| 92 | - $multiple = $this->getIsMultiSelect(); |
|
| 93 | - $id = $this->getUniqueID(); $multi_id = $id.'[]'; |
|
| 92 | + $multiple=$this->getIsMultiSelect(); |
|
| 93 | + $id=$this->getUniqueID(); $multi_id=$id.'[]'; |
|
| 94 | 94 | if($this->getActiveControl()->canUpdateClientSide()) |
| 95 | 95 | { |
| 96 | - $client = $this->getPage()->getCallbackClient(); |
|
| 96 | + $client=$this->getPage()->getCallbackClient(); |
|
| 97 | 97 | $client->setAttribute($this, 'multiple', $multiple ? 'multiple' : false); |
| 98 | 98 | $client->setAttribute($this, 'name', $multiple ? $multi_id : $id); |
| 99 | 99 | } |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | protected function addAttributesToRender($writer) |
| 147 | 147 | { |
| 148 | 148 | parent::addAttributesToRender($writer); |
| 149 | - $writer->addAttribute('id',$this->getClientID()); |
|
| 150 | - if ($this->getAutoPostBack()) |
|
| 149 | + $writer->addAttribute('id', $this->getClientID()); |
|
| 150 | + if($this->getAutoPostBack()) |
|
| 151 | 151 | $this->getActiveControl()->registerCallbackClientScript( |
| 152 | 152 | $this->getClientClassName(), $this->getPostBackOptions()); |
| 153 | 153 | } |