@@ -199,9 +199,9 @@ |
||
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
| 202 | - * Gets the CultureInfo that for this culture string |
|
| 203 | - * @return CultureInfo invariant culture info is "en". |
|
| 204 | - */ |
|
| 202 | + * Gets the CultureInfo that for this culture string |
|
| 203 | + * @return CultureInfo invariant culture info is "en". |
|
| 204 | + */ |
|
| 205 | 205 | public static function getInstance($culture) |
| 206 | 206 | { |
| 207 | 207 | static $instances = array(); |
@@ -1,20 +1,20 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * TGettext_MO class file. |
|
| 4 | - * |
|
| 5 | - * This program is free software; you can redistribute it and/or modify |
|
| 6 | - * it under the terms of the BSD License. |
|
| 7 | - * |
|
| 8 | - * Copyright(c) 2004 by Qiang Xue. All rights reserved. |
|
| 9 | - * |
|
| 10 | - * To contact the author write to {@link mailto:[email protected] Qiang Xue} |
|
| 11 | - * The latest version of PRADO can be obtained from: |
|
| 12 | - * {@link http://prado.sourceforge.net/} |
|
| 13 | - * |
|
| 14 | - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> |
|
| 15 | - * @version $Revision: 1.3 $ $Date: 2005/08/27 03:21:12 $ |
|
| 16 | - * @package System.I18N.core |
|
| 17 | - */ |
|
| 3 | + * TGettext_MO class file. |
|
| 4 | + * |
|
| 5 | + * This program is free software; you can redistribute it and/or modify |
|
| 6 | + * it under the terms of the BSD License. |
|
| 7 | + * |
|
| 8 | + * Copyright(c) 2004 by Qiang Xue. All rights reserved. |
|
| 9 | + * |
|
| 10 | + * To contact the author write to {@link mailto:[email protected] Qiang Xue} |
|
| 11 | + * The latest version of PRADO can be obtained from: |
|
| 12 | + * {@link http://prado.sourceforge.net/} |
|
| 13 | + * |
|
| 14 | + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> |
|
| 15 | + * @version $Revision: 1.3 $ $Date: 2005/08/27 03:21:12 $ |
|
| 16 | + * @package System.I18N.core |
|
| 17 | + */ |
|
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | // +----------------------------------------------------------------------+ |
@@ -52,304 +52,304 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | class TGettext_MO extends TGettext |
| 54 | 54 | { |
| 55 | - /** |
|
| 56 | - * file handle |
|
| 57 | - * |
|
| 58 | - * @access private |
|
| 59 | - * @var resource |
|
| 60 | - */ |
|
| 61 | - protected $_handle = null; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * big endianess |
|
| 65 | - * |
|
| 66 | - * Whether to write with big endian byte order. |
|
| 67 | - * |
|
| 68 | - * @access public |
|
| 69 | - * @var bool |
|
| 70 | - */ |
|
| 71 | - protected $writeBigEndian = false; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Constructor |
|
| 75 | - * |
|
| 76 | - * @access public |
|
| 77 | - * @return object File_Gettext_MO |
|
| 78 | - * @param string $file path to GNU MO file |
|
| 79 | - */ |
|
| 80 | - function TGettext_MO($file = '') |
|
| 81 | - { |
|
| 82 | - $this->file = $file; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * _read |
|
| 87 | - * |
|
| 88 | - * @access private |
|
| 89 | - * @return mixed |
|
| 90 | - * @param int $bytes |
|
| 91 | - */ |
|
| 92 | - function _read($bytes = 1) |
|
| 93 | - { |
|
| 94 | - if (0 < $bytes = abs($bytes)) { |
|
| 95 | - return fread($this->_handle, $bytes); |
|
| 96 | - } |
|
| 97 | - return null; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * _readInt |
|
| 102 | - * |
|
| 103 | - * @access private |
|
| 104 | - * @return int |
|
| 105 | - * @param bool $bigendian |
|
| 106 | - */ |
|
| 107 | - function _readInt($bigendian = false) |
|
| 108 | - { |
|
| 55 | + /** |
|
| 56 | + * file handle |
|
| 57 | + * |
|
| 58 | + * @access private |
|
| 59 | + * @var resource |
|
| 60 | + */ |
|
| 61 | + protected $_handle = null; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * big endianess |
|
| 65 | + * |
|
| 66 | + * Whether to write with big endian byte order. |
|
| 67 | + * |
|
| 68 | + * @access public |
|
| 69 | + * @var bool |
|
| 70 | + */ |
|
| 71 | + protected $writeBigEndian = false; |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Constructor |
|
| 75 | + * |
|
| 76 | + * @access public |
|
| 77 | + * @return object File_Gettext_MO |
|
| 78 | + * @param string $file path to GNU MO file |
|
| 79 | + */ |
|
| 80 | + function TGettext_MO($file = '') |
|
| 81 | + { |
|
| 82 | + $this->file = $file; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * _read |
|
| 87 | + * |
|
| 88 | + * @access private |
|
| 89 | + * @return mixed |
|
| 90 | + * @param int $bytes |
|
| 91 | + */ |
|
| 92 | + function _read($bytes = 1) |
|
| 93 | + { |
|
| 94 | + if (0 < $bytes = abs($bytes)) { |
|
| 95 | + return fread($this->_handle, $bytes); |
|
| 96 | + } |
|
| 97 | + return null; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * _readInt |
|
| 102 | + * |
|
| 103 | + * @access private |
|
| 104 | + * @return int |
|
| 105 | + * @param bool $bigendian |
|
| 106 | + */ |
|
| 107 | + function _readInt($bigendian = false) |
|
| 108 | + { |
|
| 109 | 109 | //unpack returns a reference???? |
| 110 | 110 | $unpacked = unpack($bigendian ? 'N' : 'V', $this->_read(4)); |
| 111 | - return array_shift($unpacked); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * _writeInt |
|
| 116 | - * |
|
| 117 | - * @access private |
|
| 118 | - * @return int |
|
| 119 | - * @param int $int |
|
| 120 | - */ |
|
| 121 | - function _writeInt($int) |
|
| 122 | - { |
|
| 123 | - return $this->_write(pack($this->writeBigEndian ? 'N' : 'V', (int) $int)); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * _write |
|
| 128 | - * |
|
| 129 | - * @access private |
|
| 130 | - * @return int |
|
| 131 | - * @param string $data |
|
| 132 | - */ |
|
| 133 | - function _write($data) |
|
| 134 | - { |
|
| 135 | - return fwrite($this->_handle, $data); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * _writeStr |
|
| 140 | - * |
|
| 141 | - * @access private |
|
| 142 | - * @return int |
|
| 143 | - * @param string $string |
|
| 144 | - */ |
|
| 145 | - function _writeStr($string) |
|
| 146 | - { |
|
| 147 | - return $this->_write($string . "\0"); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * _readStr |
|
| 152 | - * |
|
| 153 | - * @access private |
|
| 154 | - * @return string |
|
| 155 | - * @param array $params associative array with offset and length |
|
| 156 | - * of the string |
|
| 157 | - */ |
|
| 158 | - function _readStr($params) |
|
| 159 | - { |
|
| 160 | - fseek($this->_handle, $params['offset']); |
|
| 161 | - return $this->_read($params['length']); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Load MO file |
|
| 166 | - * |
|
| 167 | - * @access public |
|
| 168 | - * @return mixed Returns true on success or PEAR_Error on failure. |
|
| 169 | - * @param string $file |
|
| 170 | - */ |
|
| 171 | - function load($file = null) |
|
| 172 | - { |
|
| 173 | - if (!isset($file)) { |
|
| 174 | - $file = $this->file; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - // open MO file |
|
| 178 | - if (!is_resource($this->_handle = @fopen($file, 'rb'))) { |
|
| 179 | - return false; |
|
| 180 | - } |
|
| 181 | - // lock MO file shared |
|
| 182 | - if (!@flock($this->_handle, LOCK_SH)) { |
|
| 183 | - @fclose($this->_handle); |
|
| 184 | - return false; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - // read (part of) magic number from MO file header and define endianess |
|
| 111 | + return array_shift($unpacked); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * _writeInt |
|
| 116 | + * |
|
| 117 | + * @access private |
|
| 118 | + * @return int |
|
| 119 | + * @param int $int |
|
| 120 | + */ |
|
| 121 | + function _writeInt($int) |
|
| 122 | + { |
|
| 123 | + return $this->_write(pack($this->writeBigEndian ? 'N' : 'V', (int) $int)); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * _write |
|
| 128 | + * |
|
| 129 | + * @access private |
|
| 130 | + * @return int |
|
| 131 | + * @param string $data |
|
| 132 | + */ |
|
| 133 | + function _write($data) |
|
| 134 | + { |
|
| 135 | + return fwrite($this->_handle, $data); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * _writeStr |
|
| 140 | + * |
|
| 141 | + * @access private |
|
| 142 | + * @return int |
|
| 143 | + * @param string $string |
|
| 144 | + */ |
|
| 145 | + function _writeStr($string) |
|
| 146 | + { |
|
| 147 | + return $this->_write($string . "\0"); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * _readStr |
|
| 152 | + * |
|
| 153 | + * @access private |
|
| 154 | + * @return string |
|
| 155 | + * @param array $params associative array with offset and length |
|
| 156 | + * of the string |
|
| 157 | + */ |
|
| 158 | + function _readStr($params) |
|
| 159 | + { |
|
| 160 | + fseek($this->_handle, $params['offset']); |
|
| 161 | + return $this->_read($params['length']); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Load MO file |
|
| 166 | + * |
|
| 167 | + * @access public |
|
| 168 | + * @return mixed Returns true on success or PEAR_Error on failure. |
|
| 169 | + * @param string $file |
|
| 170 | + */ |
|
| 171 | + function load($file = null) |
|
| 172 | + { |
|
| 173 | + if (!isset($file)) { |
|
| 174 | + $file = $this->file; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + // open MO file |
|
| 178 | + if (!is_resource($this->_handle = @fopen($file, 'rb'))) { |
|
| 179 | + return false; |
|
| 180 | + } |
|
| 181 | + // lock MO file shared |
|
| 182 | + if (!@flock($this->_handle, LOCK_SH)) { |
|
| 183 | + @fclose($this->_handle); |
|
| 184 | + return false; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + // read (part of) magic number from MO file header and define endianess |
|
| 188 | 188 | |
| 189 | 189 | //unpack returns a reference???? |
| 190 | 190 | $unpacked = unpack('c', $this->_read(4)); |
| 191 | - switch ($magic = array_shift($unpacked)) |
|
| 192 | - { |
|
| 193 | - case -34: |
|
| 194 | - $be = false; |
|
| 195 | - break; |
|
| 196 | - |
|
| 197 | - case -107: |
|
| 198 | - $be = true; |
|
| 199 | - break; |
|
| 200 | - |
|
| 201 | - default: |
|
| 202 | - return false; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - // check file format revision - we currently only support 0 |
|
| 206 | - if (0 !== ($_rev = $this->_readInt($be))) { |
|
| 207 | - return false; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - // count of strings in this file |
|
| 211 | - $count = $this->_readInt($be); |
|
| 212 | - |
|
| 213 | - // offset of hashing table of the msgids |
|
| 214 | - $offset_original = $this->_readInt($be); |
|
| 215 | - // offset of hashing table of the msgstrs |
|
| 216 | - $offset_translat = $this->_readInt($be); |
|
| 217 | - |
|
| 218 | - // move to msgid hash table |
|
| 219 | - fseek($this->_handle, $offset_original); |
|
| 220 | - // read lengths and offsets of msgids |
|
| 221 | - $original = array(); |
|
| 222 | - for ($i = 0; $i < $count; $i++) { |
|
| 223 | - $original[$i] = array( |
|
| 224 | - 'length' => $this->_readInt($be), |
|
| 225 | - 'offset' => $this->_readInt($be) |
|
| 226 | - ); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - // move to msgstr hash table |
|
| 230 | - fseek($this->_handle, $offset_translat); |
|
| 231 | - // read lengths and offsets of msgstrs |
|
| 232 | - $translat = array(); |
|
| 233 | - for ($i = 0; $i < $count; $i++) { |
|
| 234 | - $translat[$i] = array( |
|
| 235 | - 'length' => $this->_readInt($be), |
|
| 236 | - 'offset' => $this->_readInt($be) |
|
| 237 | - ); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - // read all |
|
| 241 | - for ($i = 0; $i < $count; $i++) { |
|
| 242 | - $this->strings[$this->_readStr($original[$i])] = |
|
| 243 | - $this->_readStr($translat[$i]); |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - // done |
|
| 247 | - @flock($this->_handle, LOCK_UN); |
|
| 248 | - @fclose($this->_handle); |
|
| 249 | - $this->_handle = null; |
|
| 250 | - |
|
| 251 | - // check for meta info |
|
| 252 | - if (isset($this->strings[''])) { |
|
| 253 | - $this->meta = parent::meta2array($this->strings['']); |
|
| 254 | - unset($this->strings['']); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - return true; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * Save MO file |
|
| 262 | - * |
|
| 263 | - * @access public |
|
| 264 | - * @return mixed Returns true on success or PEAR_Error on failure. |
|
| 265 | - * @param string $file |
|
| 266 | - */ |
|
| 267 | - function save($file = null) |
|
| 268 | - { |
|
| 269 | - if (!isset($file)) { |
|
| 270 | - $file = $this->file; |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - // open MO file |
|
| 274 | - if (!is_resource($this->_handle = @fopen($file, 'wb'))) { |
|
| 275 | - return false; |
|
| 276 | - } |
|
| 277 | - // lock MO file exclusively |
|
| 278 | - if (!@flock($this->_handle, LOCK_EX)) { |
|
| 279 | - @fclose($this->_handle); |
|
| 280 | - return false; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - // write magic number |
|
| 284 | - if ($this->writeBigEndian) { |
|
| 285 | - $this->_write(pack('c*', 0x95, 0x04, 0x12, 0xde)); |
|
| 286 | - } else { |
|
| 287 | - $this->_write(pack('c*', 0xde, 0x12, 0x04, 0x95)); |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - // write file format revision |
|
| 291 | - $this->_writeInt(0); |
|
| 292 | - |
|
| 293 | - $count = count($this->strings) + ($meta = (count($this->meta) ? 1 : 0)); |
|
| 294 | - // write count of strings |
|
| 295 | - $this->_writeInt($count); |
|
| 296 | - |
|
| 297 | - $offset = 28; |
|
| 298 | - // write offset of orig. strings hash table |
|
| 299 | - $this->_writeInt($offset); |
|
| 300 | - |
|
| 301 | - $offset += ($count * 8); |
|
| 302 | - // write offset transl. strings hash table |
|
| 303 | - $this->_writeInt($offset); |
|
| 304 | - |
|
| 305 | - // write size of hash table (we currently ommit the hash table) |
|
| 306 | - $this->_writeInt(0); |
|
| 307 | - |
|
| 308 | - $offset += ($count * 8); |
|
| 309 | - // write offset of hash table |
|
| 310 | - $this->_writeInt($offset); |
|
| 311 | - |
|
| 312 | - // unshift meta info |
|
| 313 | - if ($this->meta) { |
|
| 314 | - $meta = ''; |
|
| 315 | - foreach ($this->meta as $key => $val) { |
|
| 316 | - $meta .= $key . ': ' . $val . "\n"; |
|
| 317 | - } |
|
| 318 | - $strings = array('' => $meta) + $this->strings; |
|
| 319 | - } else { |
|
| 320 | - $strings = $this->strings; |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - // write offsets for original strings |
|
| 324 | - foreach (array_keys($strings) as $o) { |
|
| 325 | - $len = strlen($o); |
|
| 326 | - $this->_writeInt($len); |
|
| 327 | - $this->_writeInt($offset); |
|
| 328 | - $offset += $len + 1; |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - // write offsets for translated strings |
|
| 332 | - foreach ($strings as $t) { |
|
| 333 | - $len = strlen($t); |
|
| 334 | - $this->_writeInt($len); |
|
| 335 | - $this->_writeInt($offset); |
|
| 336 | - $offset += $len + 1; |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - // write original strings |
|
| 340 | - foreach (array_keys($strings) as $o) { |
|
| 341 | - $this->_writeStr($o); |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - // write translated strings |
|
| 345 | - foreach ($strings as $t) { |
|
| 346 | - $this->_writeStr($t); |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - // done |
|
| 350 | - @flock($this->_handle, LOCK_UN); |
|
| 351 | - @fclose($this->_handle); |
|
| 352 | - chmod($file,PRADO_CHMOD); |
|
| 353 | - return true; |
|
| 354 | - } |
|
| 191 | + switch ($magic = array_shift($unpacked)) |
|
| 192 | + { |
|
| 193 | + case -34: |
|
| 194 | + $be = false; |
|
| 195 | + break; |
|
| 196 | + |
|
| 197 | + case -107: |
|
| 198 | + $be = true; |
|
| 199 | + break; |
|
| 200 | + |
|
| 201 | + default: |
|
| 202 | + return false; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + // check file format revision - we currently only support 0 |
|
| 206 | + if (0 !== ($_rev = $this->_readInt($be))) { |
|
| 207 | + return false; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + // count of strings in this file |
|
| 211 | + $count = $this->_readInt($be); |
|
| 212 | + |
|
| 213 | + // offset of hashing table of the msgids |
|
| 214 | + $offset_original = $this->_readInt($be); |
|
| 215 | + // offset of hashing table of the msgstrs |
|
| 216 | + $offset_translat = $this->_readInt($be); |
|
| 217 | + |
|
| 218 | + // move to msgid hash table |
|
| 219 | + fseek($this->_handle, $offset_original); |
|
| 220 | + // read lengths and offsets of msgids |
|
| 221 | + $original = array(); |
|
| 222 | + for ($i = 0; $i < $count; $i++) { |
|
| 223 | + $original[$i] = array( |
|
| 224 | + 'length' => $this->_readInt($be), |
|
| 225 | + 'offset' => $this->_readInt($be) |
|
| 226 | + ); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + // move to msgstr hash table |
|
| 230 | + fseek($this->_handle, $offset_translat); |
|
| 231 | + // read lengths and offsets of msgstrs |
|
| 232 | + $translat = array(); |
|
| 233 | + for ($i = 0; $i < $count; $i++) { |
|
| 234 | + $translat[$i] = array( |
|
| 235 | + 'length' => $this->_readInt($be), |
|
| 236 | + 'offset' => $this->_readInt($be) |
|
| 237 | + ); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + // read all |
|
| 241 | + for ($i = 0; $i < $count; $i++) { |
|
| 242 | + $this->strings[$this->_readStr($original[$i])] = |
|
| 243 | + $this->_readStr($translat[$i]); |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + // done |
|
| 247 | + @flock($this->_handle, LOCK_UN); |
|
| 248 | + @fclose($this->_handle); |
|
| 249 | + $this->_handle = null; |
|
| 250 | + |
|
| 251 | + // check for meta info |
|
| 252 | + if (isset($this->strings[''])) { |
|
| 253 | + $this->meta = parent::meta2array($this->strings['']); |
|
| 254 | + unset($this->strings['']); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + return true; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * Save MO file |
|
| 262 | + * |
|
| 263 | + * @access public |
|
| 264 | + * @return mixed Returns true on success or PEAR_Error on failure. |
|
| 265 | + * @param string $file |
|
| 266 | + */ |
|
| 267 | + function save($file = null) |
|
| 268 | + { |
|
| 269 | + if (!isset($file)) { |
|
| 270 | + $file = $this->file; |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + // open MO file |
|
| 274 | + if (!is_resource($this->_handle = @fopen($file, 'wb'))) { |
|
| 275 | + return false; |
|
| 276 | + } |
|
| 277 | + // lock MO file exclusively |
|
| 278 | + if (!@flock($this->_handle, LOCK_EX)) { |
|
| 279 | + @fclose($this->_handle); |
|
| 280 | + return false; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + // write magic number |
|
| 284 | + if ($this->writeBigEndian) { |
|
| 285 | + $this->_write(pack('c*', 0x95, 0x04, 0x12, 0xde)); |
|
| 286 | + } else { |
|
| 287 | + $this->_write(pack('c*', 0xde, 0x12, 0x04, 0x95)); |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + // write file format revision |
|
| 291 | + $this->_writeInt(0); |
|
| 292 | + |
|
| 293 | + $count = count($this->strings) + ($meta = (count($this->meta) ? 1 : 0)); |
|
| 294 | + // write count of strings |
|
| 295 | + $this->_writeInt($count); |
|
| 296 | + |
|
| 297 | + $offset = 28; |
|
| 298 | + // write offset of orig. strings hash table |
|
| 299 | + $this->_writeInt($offset); |
|
| 300 | + |
|
| 301 | + $offset += ($count * 8); |
|
| 302 | + // write offset transl. strings hash table |
|
| 303 | + $this->_writeInt($offset); |
|
| 304 | + |
|
| 305 | + // write size of hash table (we currently ommit the hash table) |
|
| 306 | + $this->_writeInt(0); |
|
| 307 | + |
|
| 308 | + $offset += ($count * 8); |
|
| 309 | + // write offset of hash table |
|
| 310 | + $this->_writeInt($offset); |
|
| 311 | + |
|
| 312 | + // unshift meta info |
|
| 313 | + if ($this->meta) { |
|
| 314 | + $meta = ''; |
|
| 315 | + foreach ($this->meta as $key => $val) { |
|
| 316 | + $meta .= $key . ': ' . $val . "\n"; |
|
| 317 | + } |
|
| 318 | + $strings = array('' => $meta) + $this->strings; |
|
| 319 | + } else { |
|
| 320 | + $strings = $this->strings; |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + // write offsets for original strings |
|
| 324 | + foreach (array_keys($strings) as $o) { |
|
| 325 | + $len = strlen($o); |
|
| 326 | + $this->_writeInt($len); |
|
| 327 | + $this->_writeInt($offset); |
|
| 328 | + $offset += $len + 1; |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + // write offsets for translated strings |
|
| 332 | + foreach ($strings as $t) { |
|
| 333 | + $len = strlen($t); |
|
| 334 | + $this->_writeInt($len); |
|
| 335 | + $this->_writeInt($offset); |
|
| 336 | + $offset += $len + 1; |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + // write original strings |
|
| 340 | + foreach (array_keys($strings) as $o) { |
|
| 341 | + $this->_writeStr($o); |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + // write translated strings |
|
| 345 | + foreach ($strings as $t) { |
|
| 346 | + $this->_writeStr($t); |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + // done |
|
| 350 | + @flock($this->_handle, LOCK_UN); |
|
| 351 | + @fclose($this->_handle); |
|
| 352 | + chmod($file,PRADO_CHMOD); |
|
| 353 | + return true; |
|
| 354 | + } |
|
| 355 | 355 | } |
@@ -92,43 +92,43 @@ |
||
| 92 | 92 | */ |
| 93 | 93 | $dsninfo = $this->dns; |
| 94 | 94 | |
| 95 | - if (isset($dsninfo['protocol']) && $dsninfo['protocol'] == 'unix') |
|
| 96 | - $dbhost = ':' . $dsninfo['socket']; |
|
| 97 | - else |
|
| 98 | - { |
|
| 95 | + if (isset($dsninfo['protocol']) && $dsninfo['protocol'] == 'unix') |
|
| 96 | + $dbhost = ':' . $dsninfo['socket']; |
|
| 97 | + else |
|
| 98 | + { |
|
| 99 | 99 | $dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost'; |
| 100 | - if (!empty($dsninfo['port'])) |
|
| 101 | - $dbhost .= ':' . $dsninfo['port']; |
|
| 102 | - } |
|
| 103 | - $user = $dsninfo['username']; |
|
| 104 | - $pw = $dsninfo['password']; |
|
| 105 | - |
|
| 106 | - $connect_function = 'mysql_connect'; |
|
| 107 | - |
|
| 108 | - if ($dbhost && $user && $pw) |
|
| 109 | - $conn = @$connect_function($dbhost, $user, $pw); |
|
| 110 | - elseif ($dbhost && $user) |
|
| 111 | - $conn = @$connect_function($dbhost, $user); |
|
| 112 | - elseif ($dbhost) |
|
| 113 | - $conn = @$connect_function($dbhost); |
|
| 114 | - else |
|
| 115 | - $conn = false; |
|
| 116 | - |
|
| 117 | - if (empty($conn)) |
|
| 118 | - { |
|
| 119 | - throw new Exception('Error in connecting to '.$dsninfo); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - if ($dsninfo['database']) |
|
| 123 | - { |
|
| 124 | - if (!@mysql_select_db($dsninfo['database'], $conn)) |
|
| 125 | - throw new Exception('Error in connecting database, dns:'. |
|
| 126 | - $dsninfo); |
|
| 127 | - } |
|
| 128 | - else |
|
| 129 | - throw new Exception('Please provide a database for message'. |
|
| 130 | - ' translation.'); |
|
| 131 | - return $conn; |
|
| 100 | + if (!empty($dsninfo['port'])) |
|
| 101 | + $dbhost .= ':' . $dsninfo['port']; |
|
| 102 | + } |
|
| 103 | + $user = $dsninfo['username']; |
|
| 104 | + $pw = $dsninfo['password']; |
|
| 105 | + |
|
| 106 | + $connect_function = 'mysql_connect'; |
|
| 107 | + |
|
| 108 | + if ($dbhost && $user && $pw) |
|
| 109 | + $conn = @$connect_function($dbhost, $user, $pw); |
|
| 110 | + elseif ($dbhost && $user) |
|
| 111 | + $conn = @$connect_function($dbhost, $user); |
|
| 112 | + elseif ($dbhost) |
|
| 113 | + $conn = @$connect_function($dbhost); |
|
| 114 | + else |
|
| 115 | + $conn = false; |
|
| 116 | + |
|
| 117 | + if (empty($conn)) |
|
| 118 | + { |
|
| 119 | + throw new Exception('Error in connecting to '.$dsninfo); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + if ($dsninfo['database']) |
|
| 123 | + { |
|
| 124 | + if (!@mysql_select_db($dsninfo['database'], $conn)) |
|
| 125 | + throw new Exception('Error in connecting database, dns:'. |
|
| 126 | + $dsninfo); |
|
| 127 | + } |
|
| 128 | + else |
|
| 129 | + throw new Exception('Please provide a database for message'. |
|
| 130 | + ' translation.'); |
|
| 131 | + return $conn; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * TCallChain class file. |
|
| 4 | - * |
|
| 5 | - * @author Brad Anderson <[email protected]> |
|
| 6 | - * @link https://github.com/pradosoft/prado |
|
| 7 | - * @copyright Copyright © 2008-2015 Pradosoft |
|
| 8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | - */ |
|
| 3 | + * TCallChain class file. |
|
| 4 | + * |
|
| 5 | + * @author Brad Anderson <[email protected]> |
|
| 6 | + * @link https://github.com/pradosoft/prado |
|
| 7 | + * @copyright Copyright © 2008-2015 Pradosoft |
|
| 8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
| 9 | + */ |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * TCallChain is a recursive event calling mechanism. This class implements |
@@ -104,30 +104,30 @@ discard block |
||
| 104 | 104 | /** |
| 105 | 105 | * @var boolean controls the use of a persistent connection. Default to true. |
| 106 | 106 | */ |
| 107 | - private $_persistence = true; |
|
| 108 | - /** |
|
| 109 | - * @var integer number of buckets to create for this server which in turn control its |
|
| 110 | - * probability of it being selected. The probability is relative to the total weight |
|
| 111 | - * of all servers. |
|
| 112 | - */ |
|
| 113 | - private $_weight = 1; |
|
| 107 | + private $_persistence = true; |
|
| 108 | + /** |
|
| 109 | + * @var integer number of buckets to create for this server which in turn control its |
|
| 110 | + * probability of it being selected. The probability is relative to the total weight |
|
| 111 | + * of all servers. |
|
| 112 | + */ |
|
| 113 | + private $_weight = 1; |
|
| 114 | 114 | |
| 115 | - private $_timeout = 360; |
|
| 115 | + private $_timeout = 360; |
|
| 116 | 116 | |
| 117 | - private $_retryInterval = 15; |
|
| 117 | + private $_retryInterval = 15; |
|
| 118 | 118 | /** |
| 119 | - * @var integer Controls the minimum value length before attempting to compress automatically. |
|
| 120 | - */ |
|
| 121 | - private $_threshold=0; |
|
| 119 | + * @var integer Controls the minimum value length before attempting to compress automatically. |
|
| 120 | + */ |
|
| 121 | + private $_threshold=0; |
|
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | - * @var float Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1. Default value is 0.2 giving a minimum 20% compression savings. |
|
| 125 | - */ |
|
| 126 | - private $_minSavings=0.0; |
|
| 124 | + * @var float Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1. Default value is 0.2 giving a minimum 20% compression savings. |
|
| 125 | + */ |
|
| 126 | + private $_minSavings=0.0; |
|
| 127 | 127 | |
| 128 | - private $_status = true; |
|
| 128 | + private $_status = true; |
|
| 129 | 129 | |
| 130 | - private $_failureCallback = null; |
|
| 130 | + private $_failureCallback = null; |
|
| 131 | 131 | |
| 132 | 132 | /** |
| 133 | 133 | * @var boolean whether to use memcached or memcache as the underlying caching extension. |
@@ -171,63 +171,63 @@ discard block |
||
| 171 | 171 | $this->_cache = $this->_useMemcached ? new Memcached : new Memcache; |
| 172 | 172 | $this->loadConfig($config); |
| 173 | 173 | if(count($this->_servers)) |
| 174 | - { |
|
| 175 | - foreach($this->_servers as $server) |
|
| 176 | - { |
|
| 177 | - Prado::trace('Adding server '.$server['Host'].' from serverlist', 'System.Caching.TMemCache'); |
|
| 178 | - if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'], |
|
| 179 | - $server['Weight'],$server['Timeout'],$server['RetryInterval'])===false) |
|
| 180 | - throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']); |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - else |
|
| 184 | - { |
|
| 185 | - Prado::trace('Adding server '.$this->_host, 'System.Caching.TMemCache'); |
|
| 186 | - if($this->_cache->addServer($this->_host,$this->_port)===false) |
|
| 187 | - throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port); |
|
| 188 | - } |
|
| 174 | + { |
|
| 175 | + foreach($this->_servers as $server) |
|
| 176 | + { |
|
| 177 | + Prado::trace('Adding server '.$server['Host'].' from serverlist', 'System.Caching.TMemCache'); |
|
| 178 | + if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'], |
|
| 179 | + $server['Weight'],$server['Timeout'],$server['RetryInterval'])===false) |
|
| 180 | + throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + else |
|
| 184 | + { |
|
| 185 | + Prado::trace('Adding server '.$this->_host, 'System.Caching.TMemCache'); |
|
| 186 | + if($this->_cache->addServer($this->_host,$this->_port)===false) |
|
| 187 | + throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port); |
|
| 188 | + } |
|
| 189 | 189 | if($this->_threshold!==0) |
| 190 | - $this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings); |
|
| 190 | + $this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings); |
|
| 191 | 191 | $this->_initialized=true; |
| 192 | 192 | parent::init($config); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - /** |
|
| 195 | + /** |
|
| 196 | 196 | * Loads configuration from an XML element |
| 197 | 197 | * @param TXmlElement configuration node |
| 198 | 198 | * @throws TConfigurationException if log route class or type is not specified |
| 199 | 199 | */ |
| 200 | 200 | private function loadConfig($xml) |
| 201 | 201 | { |
| 202 | - if($xml instanceof TXmlElement) |
|
| 202 | + if($xml instanceof TXmlElement) |
|
| 203 | 203 | { |
| 204 | - foreach($xml->getElementsByTagName('server') as $serverConfig) |
|
| 205 | - { |
|
| 206 | - $properties=$serverConfig->getAttributes(); |
|
| 207 | - if(($host=$properties->remove('Host'))===null) |
|
| 208 | - throw new TConfigurationException('memcache_serverhost_required'); |
|
| 209 | - if(($port=$properties->remove('Port'))===null) |
|
| 210 | - throw new TConfigurationException('memcache_serverport_required'); |
|
| 211 | - if(!is_numeric($port)) |
|
| 212 | - throw new TConfigurationException('memcache_serverport_invalid'); |
|
| 213 | - $server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true); |
|
| 214 | - $checks = array( |
|
| 215 | - 'Weight'=>'memcache_serverweight_invalid', |
|
| 216 | - 'Timeout'=>'memcache_servertimeout_invalid', |
|
| 217 | - 'RetryInterval'=>'memcach_serverretryinterval_invalid' |
|
| 218 | - ); |
|
| 219 | - foreach($checks as $property=>$exception) |
|
| 220 | - { |
|
| 221 | - $value=$properties->remove($property); |
|
| 222 | - if($value!==null && is_numeric($value)) |
|
| 223 | - $server[$property]=$value; |
|
| 224 | - else if($value!==null) |
|
| 225 | - throw new TConfigurationException($exception); |
|
| 226 | - } |
|
| 227 | - $server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
| 228 | - $this->_servers[]=$server; |
|
| 229 | - } |
|
| 230 | - } |
|
| 204 | + foreach($xml->getElementsByTagName('server') as $serverConfig) |
|
| 205 | + { |
|
| 206 | + $properties=$serverConfig->getAttributes(); |
|
| 207 | + if(($host=$properties->remove('Host'))===null) |
|
| 208 | + throw new TConfigurationException('memcache_serverhost_required'); |
|
| 209 | + if(($port=$properties->remove('Port'))===null) |
|
| 210 | + throw new TConfigurationException('memcache_serverport_required'); |
|
| 211 | + if(!is_numeric($port)) |
|
| 212 | + throw new TConfigurationException('memcache_serverport_invalid'); |
|
| 213 | + $server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true); |
|
| 214 | + $checks = array( |
|
| 215 | + 'Weight'=>'memcache_serverweight_invalid', |
|
| 216 | + 'Timeout'=>'memcache_servertimeout_invalid', |
|
| 217 | + 'RetryInterval'=>'memcach_serverretryinterval_invalid' |
|
| 218 | + ); |
|
| 219 | + foreach($checks as $property=>$exception) |
|
| 220 | + { |
|
| 221 | + $value=$properties->remove($property); |
|
| 222 | + if($value!==null && is_numeric($value)) |
|
| 223 | + $server[$property]=$value; |
|
| 224 | + else if($value!==null) |
|
| 225 | + throw new TConfigurationException($exception); |
|
| 226 | + } |
|
| 227 | + $server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
| 228 | + $this->_servers[]=$server; |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -60,229 +60,229 @@ |
||
| 60 | 60 | // -- Public Static Methods -------------------------------------------------- |
| 61 | 61 | |
| 62 | 62 | public static function minify($js) { |
| 63 | - $jsmin = new JSMin($js); |
|
| 64 | - return $jsmin->min(); |
|
| 63 | + $jsmin = new JSMin($js); |
|
| 64 | + return $jsmin->min(); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // -- Public Instance Methods ------------------------------------------------ |
| 68 | 68 | |
| 69 | 69 | public function __construct($input) { |
| 70 | - $this->input = str_replace("\r\n", "\n", $input); |
|
| 71 | - $this->inputLength = strlen($this->input); |
|
| 70 | + $this->input = str_replace("\r\n", "\n", $input); |
|
| 71 | + $this->inputLength = strlen($this->input); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // -- Protected Instance Methods --------------------------------------------- |
| 75 | 75 | |
| 76 | 76 | protected function action($d) { |
| 77 | - switch($d) { |
|
| 78 | - case 1: |
|
| 79 | - $this->output .= $this->a; |
|
| 80 | - |
|
| 81 | - case 2: |
|
| 82 | - $this->a = $this->b; |
|
| 83 | - |
|
| 84 | - if ($this->a === "'" || $this->a === '"') { |
|
| 85 | - for (;;) { |
|
| 86 | - $this->output .= $this->a; |
|
| 87 | - $this->a = $this->get(); |
|
| 88 | - |
|
| 89 | - if ($this->a === $this->b) { |
|
| 90 | - break; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - if (ord($this->a) <= self::ORD_LF) { |
|
| 94 | - throw new JSMinException('Unterminated string literal.'); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - if ($this->a === '\\') { |
|
| 98 | - $this->output .= $this->a; |
|
| 99 | - $this->a = $this->get(); |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - case 3: |
|
| 105 | - $this->b = $this->next(); |
|
| 106 | - |
|
| 107 | - if ($this->b === '/' && ( |
|
| 108 | - $this->a === '(' || $this->a === ',' || $this->a === '=' || |
|
| 109 | - $this->a === ':' || $this->a === '[' || $this->a === '!' || |
|
| 110 | - $this->a === '&' || $this->a === '|' || $this->a === '?')) { |
|
| 111 | - |
|
| 112 | - $this->output .= $this->a . $this->b; |
|
| 113 | - |
|
| 114 | - for (;;) { |
|
| 115 | - $this->a = $this->get(); |
|
| 116 | - |
|
| 117 | - if ($this->a === '/') { |
|
| 118 | - break; |
|
| 119 | - } elseif ($this->a === '\\') { |
|
| 120 | - $this->output .= $this->a; |
|
| 121 | - $this->a = $this->get(); |
|
| 122 | - } elseif (ord($this->a) <= self::ORD_LF) { |
|
| 123 | - throw new JSMinException('Unterminated regular expression '. |
|
| 124 | - 'literal.'); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $this->output .= $this->a; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - $this->b = $this->next(); |
|
| 131 | - } |
|
| 132 | - } |
|
| 77 | + switch($d) { |
|
| 78 | + case 1: |
|
| 79 | + $this->output .= $this->a; |
|
| 80 | + |
|
| 81 | + case 2: |
|
| 82 | + $this->a = $this->b; |
|
| 83 | + |
|
| 84 | + if ($this->a === "'" || $this->a === '"') { |
|
| 85 | + for (;;) { |
|
| 86 | + $this->output .= $this->a; |
|
| 87 | + $this->a = $this->get(); |
|
| 88 | + |
|
| 89 | + if ($this->a === $this->b) { |
|
| 90 | + break; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + if (ord($this->a) <= self::ORD_LF) { |
|
| 94 | + throw new JSMinException('Unterminated string literal.'); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + if ($this->a === '\\') { |
|
| 98 | + $this->output .= $this->a; |
|
| 99 | + $this->a = $this->get(); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + case 3: |
|
| 105 | + $this->b = $this->next(); |
|
| 106 | + |
|
| 107 | + if ($this->b === '/' && ( |
|
| 108 | + $this->a === '(' || $this->a === ',' || $this->a === '=' || |
|
| 109 | + $this->a === ':' || $this->a === '[' || $this->a === '!' || |
|
| 110 | + $this->a === '&' || $this->a === '|' || $this->a === '?')) { |
|
| 111 | + |
|
| 112 | + $this->output .= $this->a . $this->b; |
|
| 113 | + |
|
| 114 | + for (;;) { |
|
| 115 | + $this->a = $this->get(); |
|
| 116 | + |
|
| 117 | + if ($this->a === '/') { |
|
| 118 | + break; |
|
| 119 | + } elseif ($this->a === '\\') { |
|
| 120 | + $this->output .= $this->a; |
|
| 121 | + $this->a = $this->get(); |
|
| 122 | + } elseif (ord($this->a) <= self::ORD_LF) { |
|
| 123 | + throw new JSMinException('Unterminated regular expression '. |
|
| 124 | + 'literal.'); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $this->output .= $this->a; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + $this->b = $this->next(); |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | protected function get() { |
| 136 | - $c = $this->lookAhead; |
|
| 137 | - $this->lookAhead = null; |
|
| 138 | - |
|
| 139 | - if ($c === null) { |
|
| 140 | - if ($this->inputIndex < $this->inputLength) { |
|
| 141 | - $c = $this->input[$this->inputIndex]; |
|
| 142 | - $this->inputIndex += 1; |
|
| 143 | - } else { |
|
| 144 | - $c = null; |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - if ($c === "\r") { |
|
| 149 | - return "\n"; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) { |
|
| 153 | - return $c; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - return ' '; |
|
| 136 | + $c = $this->lookAhead; |
|
| 137 | + $this->lookAhead = null; |
|
| 138 | + |
|
| 139 | + if ($c === null) { |
|
| 140 | + if ($this->inputIndex < $this->inputLength) { |
|
| 141 | + $c = $this->input[$this->inputIndex]; |
|
| 142 | + $this->inputIndex += 1; |
|
| 143 | + } else { |
|
| 144 | + $c = null; |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + if ($c === "\r") { |
|
| 149 | + return "\n"; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) { |
|
| 153 | + return $c; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + return ' '; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | protected function isAlphaNum($c) { |
| 160 | - return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1; |
|
| 160 | + return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | protected function min() { |
| 164 | - $this->a = "\n"; |
|
| 165 | - $this->action(3); |
|
| 166 | - |
|
| 167 | - while ($this->a !== null) { |
|
| 168 | - switch ($this->a) { |
|
| 169 | - case ' ': |
|
| 170 | - if ($this->isAlphaNum($this->b)) { |
|
| 171 | - $this->action(1); |
|
| 172 | - } else { |
|
| 173 | - $this->action(2); |
|
| 174 | - } |
|
| 175 | - break; |
|
| 176 | - |
|
| 177 | - case "\n": |
|
| 178 | - switch ($this->b) { |
|
| 179 | - case '{': |
|
| 180 | - case '[': |
|
| 181 | - case '(': |
|
| 182 | - case '+': |
|
| 183 | - case '-': |
|
| 184 | - $this->action(1); |
|
| 185 | - break; |
|
| 186 | - |
|
| 187 | - case ' ': |
|
| 188 | - $this->action(3); |
|
| 189 | - break; |
|
| 190 | - |
|
| 191 | - default: |
|
| 192 | - if ($this->isAlphaNum($this->b)) { |
|
| 193 | - $this->action(1); |
|
| 194 | - } |
|
| 195 | - else { |
|
| 196 | - $this->action(2); |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - break; |
|
| 200 | - |
|
| 201 | - default: |
|
| 202 | - switch ($this->b) { |
|
| 203 | - case ' ': |
|
| 204 | - if ($this->isAlphaNum($this->a)) { |
|
| 205 | - $this->action(1); |
|
| 206 | - break; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - $this->action(3); |
|
| 210 | - break; |
|
| 211 | - |
|
| 212 | - case "\n": |
|
| 213 | - switch ($this->a) { |
|
| 214 | - case '}': |
|
| 215 | - case ']': |
|
| 216 | - case ')': |
|
| 217 | - case '+': |
|
| 218 | - case '-': |
|
| 219 | - case '"': |
|
| 220 | - case "'": |
|
| 221 | - $this->action(1); |
|
| 222 | - break; |
|
| 223 | - |
|
| 224 | - default: |
|
| 225 | - if ($this->isAlphaNum($this->a)) { |
|
| 226 | - $this->action(1); |
|
| 227 | - } |
|
| 228 | - else { |
|
| 229 | - $this->action(3); |
|
| 230 | - } |
|
| 231 | - } |
|
| 232 | - break; |
|
| 233 | - |
|
| 234 | - default: |
|
| 235 | - $this->action(1); |
|
| 236 | - break; |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - return $this->output; |
|
| 164 | + $this->a = "\n"; |
|
| 165 | + $this->action(3); |
|
| 166 | + |
|
| 167 | + while ($this->a !== null) { |
|
| 168 | + switch ($this->a) { |
|
| 169 | + case ' ': |
|
| 170 | + if ($this->isAlphaNum($this->b)) { |
|
| 171 | + $this->action(1); |
|
| 172 | + } else { |
|
| 173 | + $this->action(2); |
|
| 174 | + } |
|
| 175 | + break; |
|
| 176 | + |
|
| 177 | + case "\n": |
|
| 178 | + switch ($this->b) { |
|
| 179 | + case '{': |
|
| 180 | + case '[': |
|
| 181 | + case '(': |
|
| 182 | + case '+': |
|
| 183 | + case '-': |
|
| 184 | + $this->action(1); |
|
| 185 | + break; |
|
| 186 | + |
|
| 187 | + case ' ': |
|
| 188 | + $this->action(3); |
|
| 189 | + break; |
|
| 190 | + |
|
| 191 | + default: |
|
| 192 | + if ($this->isAlphaNum($this->b)) { |
|
| 193 | + $this->action(1); |
|
| 194 | + } |
|
| 195 | + else { |
|
| 196 | + $this->action(2); |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + break; |
|
| 200 | + |
|
| 201 | + default: |
|
| 202 | + switch ($this->b) { |
|
| 203 | + case ' ': |
|
| 204 | + if ($this->isAlphaNum($this->a)) { |
|
| 205 | + $this->action(1); |
|
| 206 | + break; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + $this->action(3); |
|
| 210 | + break; |
|
| 211 | + |
|
| 212 | + case "\n": |
|
| 213 | + switch ($this->a) { |
|
| 214 | + case '}': |
|
| 215 | + case ']': |
|
| 216 | + case ')': |
|
| 217 | + case '+': |
|
| 218 | + case '-': |
|
| 219 | + case '"': |
|
| 220 | + case "'": |
|
| 221 | + $this->action(1); |
|
| 222 | + break; |
|
| 223 | + |
|
| 224 | + default: |
|
| 225 | + if ($this->isAlphaNum($this->a)) { |
|
| 226 | + $this->action(1); |
|
| 227 | + } |
|
| 228 | + else { |
|
| 229 | + $this->action(3); |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + break; |
|
| 233 | + |
|
| 234 | + default: |
|
| 235 | + $this->action(1); |
|
| 236 | + break; |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + return $this->output; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | protected function next() { |
| 245 | - $c = $this->get(); |
|
| 246 | - |
|
| 247 | - if ($c === '/') { |
|
| 248 | - switch($this->peek()) { |
|
| 249 | - case '/': |
|
| 250 | - for (;;) { |
|
| 251 | - $c = $this->get(); |
|
| 252 | - |
|
| 253 | - if (ord($c) <= self::ORD_LF) { |
|
| 254 | - return $c; |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - case '*': |
|
| 259 | - $this->get(); |
|
| 260 | - |
|
| 261 | - for (;;) { |
|
| 262 | - switch($this->get()) { |
|
| 263 | - case '*': |
|
| 264 | - if ($this->peek() === '/') { |
|
| 265 | - $this->get(); |
|
| 266 | - return ' '; |
|
| 267 | - } |
|
| 268 | - break; |
|
| 269 | - |
|
| 270 | - case null: |
|
| 271 | - throw new JSMinException('Unterminated comment.'); |
|
| 272 | - } |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - default: |
|
| 276 | - return $c; |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - return $c; |
|
| 245 | + $c = $this->get(); |
|
| 246 | + |
|
| 247 | + if ($c === '/') { |
|
| 248 | + switch($this->peek()) { |
|
| 249 | + case '/': |
|
| 250 | + for (;;) { |
|
| 251 | + $c = $this->get(); |
|
| 252 | + |
|
| 253 | + if (ord($c) <= self::ORD_LF) { |
|
| 254 | + return $c; |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + case '*': |
|
| 259 | + $this->get(); |
|
| 260 | + |
|
| 261 | + for (;;) { |
|
| 262 | + switch($this->get()) { |
|
| 263 | + case '*': |
|
| 264 | + if ($this->peek() === '/') { |
|
| 265 | + $this->get(); |
|
| 266 | + return ' '; |
|
| 267 | + } |
|
| 268 | + break; |
|
| 269 | + |
|
| 270 | + case null: |
|
| 271 | + throw new JSMinException('Unterminated comment.'); |
|
| 272 | + } |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + default: |
|
| 276 | + return $c; |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + return $c; |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | protected function peek() { |
| 284 | - $this->lookAhead = $this->get(); |
|
| 285 | - return $this->lookAhead; |
|
| 284 | + $this->lookAhead = $this->get(); |
|
| 285 | + return $this->lookAhead; |
|
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |
@@ -144,15 +144,15 @@ |
||
| 144 | 144 | */ |
| 145 | 145 | public function getKeyPrefix() |
| 146 | 146 | { |
| 147 | - return $this->_prefix; |
|
| 147 | + return $this->_prefix; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | - * @param string prefix of cache variable name to avoid conflict with other cache data |
|
| 152 | - */ |
|
| 151 | + * @param string prefix of cache variable name to avoid conflict with other cache data |
|
| 152 | + */ |
|
| 153 | 153 | public function setKeyPrefix($value) |
| 154 | 154 | { |
| 155 | - $this->_prefix=$value; |
|
| 155 | + $this->_prefix=$value; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -334,8 +334,8 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | 336 | * @return boolean a value indicating whether an automatic postback to the server |
| 337 | - * will occur whenever the user makes change to the list control and then tabs out of it. |
|
| 338 | - * Defaults to false. |
|
| 337 | + * will occur whenever the user makes change to the list control and then tabs out of it. |
|
| 338 | + * Defaults to false. |
|
| 339 | 339 | */ |
| 340 | 340 | public function getAutoPostBack() |
| 341 | 341 | { |
@@ -591,23 +591,23 @@ discard block |
||
| 591 | 591 | * @param string the value of the item to be selected. |
| 592 | 592 | */ |
| 593 | 593 | public function setSelectedValue($value) |
| 594 | - { |
|
| 595 | - if($this->_items) |
|
| 596 | - { |
|
| 597 | - if($value===null) |
|
| 598 | - $this->clearSelection(); |
|
| 599 | - else if(($item=$this->_items->findItemByValue($value))!==null) |
|
| 600 | - { |
|
| 601 | - $this->clearSelection(); |
|
| 602 | - $item->setSelected(true); |
|
| 603 | - } |
|
| 604 | - else |
|
| 594 | + { |
|
| 595 | + if($this->_items) |
|
| 596 | + { |
|
| 597 | + if($value===null) |
|
| 598 | + $this->clearSelection(); |
|
| 599 | + else if(($item=$this->_items->findItemByValue($value))!==null) |
|
| 600 | + { |
|
| 601 | + $this->clearSelection(); |
|
| 602 | + $item->setSelected(true); |
|
| 603 | + } |
|
| 604 | + else |
|
| 605 | 605 | $this->clearSelection(); |
| 606 | - } |
|
| 607 | - $this->_cachedSelectedValue=$value; |
|
| 606 | + } |
|
| 607 | + $this->_cachedSelectedValue=$value; |
|
| 608 | 608 | if($this->getAdapter() instanceof IListControlAdapter) |
| 609 | 609 | $this->getAdapter()->setSelectedValue($value); |
| 610 | - } |
|
| 610 | + } |
|
| 611 | 611 | |
| 612 | 612 | |
| 613 | 613 | /** |
@@ -655,36 +655,36 @@ discard block |
||
| 655 | 655 | $this->getAdapter()->setSelectedValues($values); |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | - /** |
|
| 659 | - * @return string selected value |
|
| 660 | - */ |
|
| 661 | - public function getText() |
|
| 662 | - { |
|
| 663 | - return $this->getSelectedValue(); |
|
| 664 | - } |
|
| 665 | - |
|
| 666 | - /** |
|
| 667 | - * @param string value to be selected |
|
| 668 | - */ |
|
| 669 | - public function setText($value) |
|
| 670 | - { |
|
| 671 | - $this->setSelectedValue($value); |
|
| 672 | - } |
|
| 673 | - |
|
| 674 | - /** |
|
| 675 | - * Clears all existing selections. |
|
| 676 | - */ |
|
| 677 | - public function clearSelection() |
|
| 678 | - { |
|
| 679 | - if($this->_items) |
|
| 680 | - { |
|
| 681 | - foreach($this->_items as $item) |
|
| 682 | - $item->setSelected(false); |
|
| 683 | - } |
|
| 658 | + /** |
|
| 659 | + * @return string selected value |
|
| 660 | + */ |
|
| 661 | + public function getText() |
|
| 662 | + { |
|
| 663 | + return $this->getSelectedValue(); |
|
| 664 | + } |
|
| 665 | + |
|
| 666 | + /** |
|
| 667 | + * @param string value to be selected |
|
| 668 | + */ |
|
| 669 | + public function setText($value) |
|
| 670 | + { |
|
| 671 | + $this->setSelectedValue($value); |
|
| 672 | + } |
|
| 673 | + |
|
| 674 | + /** |
|
| 675 | + * Clears all existing selections. |
|
| 676 | + */ |
|
| 677 | + public function clearSelection() |
|
| 678 | + { |
|
| 679 | + if($this->_items) |
|
| 680 | + { |
|
| 681 | + foreach($this->_items as $item) |
|
| 682 | + $item->setSelected(false); |
|
| 683 | + } |
|
| 684 | 684 | |
| 685 | 685 | if($this->getAdapter() instanceof IListControlAdapter) |
| 686 | 686 | $this->getAdapter()->clearSelection(); |
| 687 | - } |
|
| 687 | + } |
|
| 688 | 688 | |
| 689 | 689 | /** |
| 690 | 690 | * @return string the group of validators which the list control causes validation upon postback |
@@ -914,10 +914,10 @@ discard block |
||
| 914 | 914 | */ |
| 915 | 915 | public function setSelectedValues($values); |
| 916 | 916 | |
| 917 | - /** |
|
| 918 | - * Clears all existing selections on the client side. |
|
| 919 | - */ |
|
| 920 | - public function clearSelection(); |
|
| 917 | + /** |
|
| 918 | + * Clears all existing selections on the client side. |
|
| 919 | + */ |
|
| 920 | + public function clearSelection(); |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | |
@@ -180,24 +180,24 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | - * @return string URL for the CSS file including all relevant CSS class definitions. Defaults to ''. |
|
| 184 | - */ |
|
| 183 | + * @return string URL for the CSS file including all relevant CSS class definitions. Defaults to ''. |
|
| 184 | + */ |
|
| 185 | 185 | public function getCssUrl() |
| 186 | 186 | { |
| 187 | 187 | return $this->getViewState('CssUrl','default'); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | - * @param string URL for the CSS file including all relevant CSS class definitions. |
|
| 192 | - */ |
|
| 191 | + * @param string URL for the CSS file including all relevant CSS class definitions. |
|
| 192 | + */ |
|
| 193 | 193 | public function setCssUrl($value) |
| 194 | 194 | { |
| 195 | 195 | $this->setViewState('CssUrl',TPropertyValue::ensureString($value),''); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
| 199 | - * @return string CSS class for the whole accordion control div. |
|
| 200 | - */ |
|
| 199 | + * @return string CSS class for the whole accordion control div. |
|
| 200 | + */ |
|
| 201 | 201 | public function getCssClass() |
| 202 | 202 | { |
| 203 | 203 | $cssClass=parent::getCssClass(); |
@@ -205,32 +205,32 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
| 208 | - * @return string CSS class for the currently displayed view div. Defaults to 'accordion-view'. |
|
| 209 | - */ |
|
| 208 | + * @return string CSS class for the currently displayed view div. Defaults to 'accordion-view'. |
|
| 209 | + */ |
|
| 210 | 210 | public function getViewCssClass() |
| 211 | 211 | { |
| 212 | 212 | return $this->getViewStyle()->getCssClass(); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | - * @param string CSS class for the currently displayed view div. |
|
| 217 | - */ |
|
| 216 | + * @param string CSS class for the currently displayed view div. |
|
| 217 | + */ |
|
| 218 | 218 | public function setViewCssClass($value) |
| 219 | 219 | { |
| 220 | 220 | $this->getViewStyle()->setCssClass($value); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
| 224 | - * @return string CSS class for the currently displayed view div. Defaults to 'accordion-view'. |
|
| 225 | - */ |
|
| 224 | + * @return string CSS class for the currently displayed view div. Defaults to 'accordion-view'. |
|
| 225 | + */ |
|
| 226 | 226 | public function getAnimationDuration() |
| 227 | 227 | { |
| 228 | 228 | return $this->getViewState('AnimationDuration','1'); |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | - * @param string CSS class for the currently displayed view div. |
|
| 233 | - */ |
|
| 232 | + * @param string CSS class for the currently displayed view div. |
|
| 233 | + */ |
|
| 234 | 234 | public function setAnimationDuration($value) |
| 235 | 235 | { |
| 236 | 236 | $this->setViewState('AnimationDuration',$value); |