@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Clears all existing selections on the client side. |
|
| 125 | - */ |
|
| 126 | - public function clearSelection() |
|
| 127 | - { |
|
| 123 | + /** |
|
| 124 | + * Clears all existing selections on the client side. |
|
| 125 | + */ |
|
| 126 | + public function clearSelection() |
|
| 127 | + { |
|
| 128 | 128 | if($this->canUpdateClientSide()) |
| 129 | 129 | { |
| 130 | 130 | $this->updateListItems(); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $this->getPage()->getCallbackClient()->select($this->getControl(), 'Clear'); |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | - } |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | 142 | /** |
| 143 | 143 | * Update the client-side list options. |
@@ -173,15 +173,15 @@ |
||
| 173 | 173 | { |
| 174 | 174 | if(($forControl=$this->getForControl())==='') |
| 175 | 175 | throw new TConfigurationException('keyboard_forcontrol_required'); |
| 176 | - if(($target=$this->findControl($forControl))===null) |
|
| 177 | - throw new TConfigurationException('keyboard_forcontrol_invalid',$forControl); |
|
| 176 | + if(($target=$this->findControl($forControl))===null) |
|
| 177 | + throw new TConfigurationException('keyboard_forcontrol_invalid',$forControl); |
|
| 178 | 178 | |
| 179 | - $options['ID'] = $this->getClientID(); |
|
| 180 | - $options['ForControl'] = $target->getClientID(); |
|
| 181 | - $options['AutoHide'] = $this->getAutoHide(); |
|
| 182 | - $options['CssClass'] = $this->getKeyboardCssClass(); |
|
| 179 | + $options['ID'] = $this->getClientID(); |
|
| 180 | + $options['ForControl'] = $target->getClientID(); |
|
| 181 | + $options['AutoHide'] = $this->getAutoHide(); |
|
| 182 | + $options['CssClass'] = $this->getKeyboardCssClass(); |
|
| 183 | 183 | |
| 184 | - return $options; |
|
| 184 | + return $options; |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
@@ -19,7 +19,6 @@ |
||
| 19 | 19 | * |
| 20 | 20 | * The following property is provided by TDataRenderer: |
| 21 | 21 | * - {@link getData Data}: data associated with this renderer. |
| 22 | - |
|
| 23 | 22 | * @author Qiang Xue <[email protected]> |
| 24 | 23 | * @package System.Web.UI.WebControls |
| 25 | 24 | * @since 3.1.2 |
@@ -463,14 +463,14 @@ |
||
| 463 | 463 | */ |
| 464 | 464 | public function getIsValid() |
| 465 | 465 | { |
| 466 | - return $this->_isValid; |
|
| 466 | + return $this->_isValid; |
|
| 467 | 467 | } |
| 468 | 468 | /** |
| 469 | 469 | * @param bool wether this control is valid. |
| 470 | 470 | */ |
| 471 | 471 | public function setIsValid($value) |
| 472 | 472 | { |
| 473 | - $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
| 473 | + $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * Sets the horizontal alignment of the contents within the table item. |
| 92 | - * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center' |
|
| 92 | + * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center' |
|
| 93 | 93 | * @param string the horizontal alignment |
| 94 | 94 | */ |
| 95 | 95 | public function setHorizontalAlign($value) |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * Sets the vertical alignment of the contents within the table item. |
| 113 | - * Valid values include 'NotSet','Top','Bottom','Middle' |
|
| 113 | + * Valid values include 'NotSet','Top','Bottom','Middle' |
|
| 114 | 114 | * @param string the horizontal alignment |
| 115 | 115 | */ |
| 116 | 116 | public function setVerticalAlign($value) |
@@ -463,14 +463,14 @@ |
||
| 463 | 463 | */ |
| 464 | 464 | public function getIsValid() |
| 465 | 465 | { |
| 466 | - return $this->_isValid; |
|
| 466 | + return $this->_isValid; |
|
| 467 | 467 | } |
| 468 | 468 | /** |
| 469 | 469 | * @param bool wether this control is valid. |
| 470 | 470 | */ |
| 471 | 471 | public function setIsValid($value) |
| 472 | 472 | { |
| 473 | - $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
| 473 | + $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
@@ -463,14 +463,14 @@ |
||
| 463 | 463 | */ |
| 464 | 464 | public function getIsValid() |
| 465 | 465 | { |
| 466 | - return $this->_isValid; |
|
| 466 | + return $this->_isValid; |
|
| 467 | 467 | } |
| 468 | 468 | /** |
| 469 | 469 | * @param bool wether this control is valid. |
| 470 | 470 | */ |
| 471 | 471 | public function setIsValid($value) |
| 472 | 472 | { |
| 473 | - $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
| 473 | + $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
@@ -51,110 +51,110 @@ |
||
| 51 | 51 | */ |
| 52 | 52 | class TGettext_PO extends TGettext |
| 53 | 53 | { |
| 54 | - /** |
|
| 55 | - * Constructor |
|
| 56 | - * |
|
| 57 | - * @access public |
|
| 58 | - * @return object File_Gettext_PO |
|
| 59 | - * @param string path to GNU PO file |
|
| 60 | - */ |
|
| 61 | - function TGettext_PO($file = '') |
|
| 62 | - { |
|
| 63 | - $this->file = $file; |
|
| 64 | - } |
|
| 54 | + /** |
|
| 55 | + * Constructor |
|
| 56 | + * |
|
| 57 | + * @access public |
|
| 58 | + * @return object File_Gettext_PO |
|
| 59 | + * @param string path to GNU PO file |
|
| 60 | + */ |
|
| 61 | + function TGettext_PO($file = '') |
|
| 62 | + { |
|
| 63 | + $this->file = $file; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Load PO file |
|
| 68 | - * |
|
| 69 | - * @access public |
|
| 70 | - * @return mixed Returns true on success or PEAR_Error on failure. |
|
| 71 | - * @param string $file |
|
| 72 | - */ |
|
| 73 | - function load($file = null) |
|
| 74 | - { |
|
| 75 | - if (!isset($file)) { |
|
| 76 | - $file = $this->file; |
|
| 77 | - } |
|
| 66 | + /** |
|
| 67 | + * Load PO file |
|
| 68 | + * |
|
| 69 | + * @access public |
|
| 70 | + * @return mixed Returns true on success or PEAR_Error on failure. |
|
| 71 | + * @param string $file |
|
| 72 | + */ |
|
| 73 | + function load($file = null) |
|
| 74 | + { |
|
| 75 | + if (!isset($file)) { |
|
| 76 | + $file = $this->file; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - // load file |
|
| 80 | - if (!$contents = @file($file)) { |
|
| 81 | - return false; |
|
| 82 | - } |
|
| 83 | - $contents = implode('', $contents); |
|
| 79 | + // load file |
|
| 80 | + if (!$contents = @file($file)) { |
|
| 81 | + return false; |
|
| 82 | + } |
|
| 83 | + $contents = implode('', $contents); |
|
| 84 | 84 | |
| 85 | - // match all msgid/msgstr entries |
|
| 86 | - $matched = preg_match_all( |
|
| 87 | - '/(msgid\s+("([^"]|\\\\")*?"\s*)+)\s+' . |
|
| 88 | - '(msgstr\s+("([^"]|\\\\")*?"\s*)+)/', |
|
| 89 | - $contents, $matches |
|
| 90 | - ); |
|
| 91 | - unset($contents); |
|
| 85 | + // match all msgid/msgstr entries |
|
| 86 | + $matched = preg_match_all( |
|
| 87 | + '/(msgid\s+("([^"]|\\\\")*?"\s*)+)\s+' . |
|
| 88 | + '(msgstr\s+("([^"]|\\\\")*?"\s*)+)/', |
|
| 89 | + $contents, $matches |
|
| 90 | + ); |
|
| 91 | + unset($contents); |
|
| 92 | 92 | |
| 93 | - if (!$matched) { |
|
| 94 | - return false; |
|
| 95 | - } |
|
| 93 | + if (!$matched) { |
|
| 94 | + return false; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - // get all msgids and msgtrs |
|
| 98 | - for ($i = 0; $i < $matched; $i++) { |
|
| 99 | - $msgid = preg_replace( |
|
| 100 | - '/\s*msgid\s*"(.*)"\s*/s', '\\1', $matches[1][$i]); |
|
| 101 | - $msgstr= preg_replace( |
|
| 102 | - '/\s*msgstr\s*"(.*)"\s*/s', '\\1', $matches[4][$i]); |
|
| 103 | - $this->strings[parent::prepare($msgid)] = parent::prepare($msgstr); |
|
| 104 | - } |
|
| 97 | + // get all msgids and msgtrs |
|
| 98 | + for ($i = 0; $i < $matched; $i++) { |
|
| 99 | + $msgid = preg_replace( |
|
| 100 | + '/\s*msgid\s*"(.*)"\s*/s', '\\1', $matches[1][$i]); |
|
| 101 | + $msgstr= preg_replace( |
|
| 102 | + '/\s*msgstr\s*"(.*)"\s*/s', '\\1', $matches[4][$i]); |
|
| 103 | + $this->strings[parent::prepare($msgid)] = parent::prepare($msgstr); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - // check for meta info |
|
| 107 | - if (isset($this->strings[''])) { |
|
| 108 | - $this->meta = parent::meta2array($this->strings['']); |
|
| 109 | - unset($this->strings['']); |
|
| 110 | - } |
|
| 106 | + // check for meta info |
|
| 107 | + if (isset($this->strings[''])) { |
|
| 108 | + $this->meta = parent::meta2array($this->strings['']); |
|
| 109 | + unset($this->strings['']); |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - return true; |
|
| 113 | - } |
|
| 112 | + return true; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Save PO file |
|
| 117 | - * |
|
| 118 | - * @access public |
|
| 119 | - * @return mixed Returns true on success or PEAR_Error on failure. |
|
| 120 | - * @param string $file |
|
| 121 | - */ |
|
| 122 | - function save($file = null) |
|
| 123 | - { |
|
| 124 | - if (!isset($file)) { |
|
| 125 | - $file = $this->file; |
|
| 126 | - } |
|
| 115 | + /** |
|
| 116 | + * Save PO file |
|
| 117 | + * |
|
| 118 | + * @access public |
|
| 119 | + * @return mixed Returns true on success or PEAR_Error on failure. |
|
| 120 | + * @param string $file |
|
| 121 | + */ |
|
| 122 | + function save($file = null) |
|
| 123 | + { |
|
| 124 | + if (!isset($file)) { |
|
| 125 | + $file = $this->file; |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - // open PO file |
|
| 129 | - if (!is_resource($fh = @fopen($file, 'w'))) { |
|
| 130 | - return false; |
|
| 131 | - } |
|
| 128 | + // open PO file |
|
| 129 | + if (!is_resource($fh = @fopen($file, 'w'))) { |
|
| 130 | + return false; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - // lock PO file exclusively |
|
| 134 | - if (!flock($fh, LOCK_EX)) { |
|
| 135 | - fclose($fh); |
|
| 136 | - return false; |
|
| 137 | - } |
|
| 138 | - // write meta info |
|
| 139 | - if (count($this->meta)) { |
|
| 140 | - $meta = 'msgid ""' . "\nmsgstr " . '""' . "\n"; |
|
| 141 | - foreach ($this->meta as $k => $v) { |
|
| 142 | - $meta .= '"' . $k . ': ' . $v . '\n"' . "\n"; |
|
| 143 | - } |
|
| 144 | - fwrite($fh, $meta . "\n"); |
|
| 145 | - } |
|
| 146 | - // write strings |
|
| 147 | - foreach ($this->strings as $o => $t) { |
|
| 148 | - fwrite($fh, |
|
| 149 | - 'msgid "' . parent::prepare($o, true) . '"' . "\n" . |
|
| 150 | - 'msgstr "' . parent::prepare($t, true) . '"' . "\n\n" |
|
| 151 | - ); |
|
| 152 | - } |
|
| 133 | + // lock PO file exclusively |
|
| 134 | + if (!flock($fh, LOCK_EX)) { |
|
| 135 | + fclose($fh); |
|
| 136 | + return false; |
|
| 137 | + } |
|
| 138 | + // write meta info |
|
| 139 | + if (count($this->meta)) { |
|
| 140 | + $meta = 'msgid ""' . "\nmsgstr " . '""' . "\n"; |
|
| 141 | + foreach ($this->meta as $k => $v) { |
|
| 142 | + $meta .= '"' . $k . ': ' . $v . '\n"' . "\n"; |
|
| 143 | + } |
|
| 144 | + fwrite($fh, $meta . "\n"); |
|
| 145 | + } |
|
| 146 | + // write strings |
|
| 147 | + foreach ($this->strings as $o => $t) { |
|
| 148 | + fwrite($fh, |
|
| 149 | + 'msgid "' . parent::prepare($o, true) . '"' . "\n" . |
|
| 150 | + 'msgstr "' . parent::prepare($t, true) . '"' . "\n\n" |
|
| 151 | + ); |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - //done |
|
| 155 | - @flock($fh, LOCK_UN); |
|
| 156 | - @fclose($fh); |
|
| 157 | - chmod($file,PRADO_CHMOD); |
|
| 158 | - return true; |
|
| 159 | - } |
|
| 154 | + //done |
|
| 155 | + @flock($fh, LOCK_UN); |
|
| 156 | + @fclose($fh); |
|
| 157 | + chmod($file,PRADO_CHMOD); |
|
| 158 | + return true; |
|
| 159 | + } |
|
| 160 | 160 | } |
@@ -1,20 +1,20 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * TGettext 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.4 $ $Date: 2005/01/09 23:36:23 $ |
|
| 16 | - * @package System.I18N.core |
|
| 17 | - */ |
|
| 3 | + * TGettext 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.4 $ $Date: 2005/01/09 23:36:23 $ |
|
| 16 | + * @package System.I18N.core |
|
| 17 | + */ |
|
| 18 | 18 | |
| 19 | 19 | // +----------------------------------------------------------------------+ |
| 20 | 20 | // | PEAR :: File :: Gettext | |
@@ -58,229 +58,229 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | class TGettext |
| 60 | 60 | { |
| 61 | - /** |
|
| 62 | - * strings |
|
| 63 | - * |
|
| 64 | - * associative array with all [msgid => msgstr] entries |
|
| 65 | - * |
|
| 66 | - * @access protected |
|
| 67 | - * @var array |
|
| 68 | - */ |
|
| 69 | - protected $strings = array(); |
|
| 61 | + /** |
|
| 62 | + * strings |
|
| 63 | + * |
|
| 64 | + * associative array with all [msgid => msgstr] entries |
|
| 65 | + * |
|
| 66 | + * @access protected |
|
| 67 | + * @var array |
|
| 68 | + */ |
|
| 69 | + protected $strings = array(); |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * meta |
|
| 73 | - * |
|
| 74 | - * associative array containing meta |
|
| 75 | - * information like project name or content type |
|
| 76 | - * |
|
| 77 | - * @access protected |
|
| 78 | - * @var array |
|
| 79 | - */ |
|
| 80 | - protected $meta = array(); |
|
| 71 | + /** |
|
| 72 | + * meta |
|
| 73 | + * |
|
| 74 | + * associative array containing meta |
|
| 75 | + * information like project name or content type |
|
| 76 | + * |
|
| 77 | + * @access protected |
|
| 78 | + * @var array |
|
| 79 | + */ |
|
| 80 | + protected $meta = array(); |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * file path |
|
| 84 | - * |
|
| 85 | - * @access protected |
|
| 86 | - * @var string |
|
| 87 | - */ |
|
| 88 | - protected $file = ''; |
|
| 82 | + /** |
|
| 83 | + * file path |
|
| 84 | + * |
|
| 85 | + * @access protected |
|
| 86 | + * @var string |
|
| 87 | + */ |
|
| 88 | + protected $file = ''; |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Factory |
|
| 92 | - * |
|
| 93 | - * @static |
|
| 94 | - * @access public |
|
| 95 | - * @return object Returns File_Gettext_PO or File_Gettext_MO on success |
|
| 96 | - * or PEAR_Error on failure. |
|
| 97 | - * @param string $format MO or PO |
|
| 98 | - * @param string $file path to GNU gettext file |
|
| 99 | - */ |
|
| 100 | - static function factory($format, $file = '') |
|
| 101 | - { |
|
| 102 | - $format = strToUpper($format); |
|
| 103 | - $filename = dirname(__FILE__).'/'.$format.'.php'; |
|
| 104 | - if(is_file($filename) == false) |
|
| 105 | - throw new Exception ("Class file $file not found"); |
|
| 90 | + /** |
|
| 91 | + * Factory |
|
| 92 | + * |
|
| 93 | + * @static |
|
| 94 | + * @access public |
|
| 95 | + * @return object Returns File_Gettext_PO or File_Gettext_MO on success |
|
| 96 | + * or PEAR_Error on failure. |
|
| 97 | + * @param string $format MO or PO |
|
| 98 | + * @param string $file path to GNU gettext file |
|
| 99 | + */ |
|
| 100 | + static function factory($format, $file = '') |
|
| 101 | + { |
|
| 102 | + $format = strToUpper($format); |
|
| 103 | + $filename = dirname(__FILE__).'/'.$format.'.php'; |
|
| 104 | + if(is_file($filename) == false) |
|
| 105 | + throw new Exception ("Class file $file not found"); |
|
| 106 | 106 | |
| 107 | - include_once $filename; |
|
| 108 | - $class = 'TGettext_' . $format; |
|
| 107 | + include_once $filename; |
|
| 108 | + $class = 'TGettext_' . $format; |
|
| 109 | 109 | |
| 110 | - return new $class($file); |
|
| 111 | - } |
|
| 110 | + return new $class($file); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * poFile2moFile |
|
| 115 | - * |
|
| 116 | - * That's a simple fake of the 'msgfmt' console command. It reads the |
|
| 117 | - * contents of a GNU PO file and saves them to a GNU MO file. |
|
| 118 | - * |
|
| 119 | - * @static |
|
| 120 | - * @access public |
|
| 121 | - * @return mixed Returns true on success or PEAR_Error on failure. |
|
| 122 | - * @param string $pofile path to GNU PO file |
|
| 123 | - * @param string $mofile path to GNU MO file |
|
| 124 | - */ |
|
| 125 | - static function poFile2moFile($pofile, $mofile) |
|
| 126 | - { |
|
| 127 | - if (!is_file($pofile)) { |
|
| 128 | - throw new Exception("File $pofile doesn't exist."); |
|
| 129 | - } |
|
| 113 | + /** |
|
| 114 | + * poFile2moFile |
|
| 115 | + * |
|
| 116 | + * That's a simple fake of the 'msgfmt' console command. It reads the |
|
| 117 | + * contents of a GNU PO file and saves them to a GNU MO file. |
|
| 118 | + * |
|
| 119 | + * @static |
|
| 120 | + * @access public |
|
| 121 | + * @return mixed Returns true on success or PEAR_Error on failure. |
|
| 122 | + * @param string $pofile path to GNU PO file |
|
| 123 | + * @param string $mofile path to GNU MO file |
|
| 124 | + */ |
|
| 125 | + static function poFile2moFile($pofile, $mofile) |
|
| 126 | + { |
|
| 127 | + if (!is_file($pofile)) { |
|
| 128 | + throw new Exception("File $pofile doesn't exist."); |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - include_once dirname(__FILE__).'/PO.php'; |
|
| 131 | + include_once dirname(__FILE__).'/PO.php'; |
|
| 132 | 132 | |
| 133 | - $PO = new TGettext_PO($pofile); |
|
| 134 | - if (true !== ($e = $PO->load())) { |
|
| 135 | - return $e; |
|
| 136 | - } |
|
| 133 | + $PO = new TGettext_PO($pofile); |
|
| 134 | + if (true !== ($e = $PO->load())) { |
|
| 135 | + return $e; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - $MO = $PO->toMO(); |
|
| 139 | - if (true !== ($e = $MO->save($mofile))) { |
|
| 140 | - return $e; |
|
| 141 | - } |
|
| 142 | - unset($PO, $MO); |
|
| 138 | + $MO = $PO->toMO(); |
|
| 139 | + if (true !== ($e = $MO->save($mofile))) { |
|
| 140 | + return $e; |
|
| 141 | + } |
|
| 142 | + unset($PO, $MO); |
|
| 143 | 143 | |
| 144 | - return true; |
|
| 145 | - } |
|
| 144 | + return true; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * prepare |
|
| 149 | - * |
|
| 150 | - * @static |
|
| 151 | - * @access protected |
|
| 152 | - * @return string |
|
| 153 | - * @param string $string |
|
| 154 | - * @param bool $reverse |
|
| 155 | - */ |
|
| 156 | - static function prepare($string, $reverse = false) |
|
| 157 | - { |
|
| 158 | - if ($reverse) { |
|
| 159 | - $smap = array('"', "\n", "\t", "\r"); |
|
| 160 | - $rmap = array('\"', '\\n"' . "\n" . '"', '\\t', '\\r'); |
|
| 161 | - return (string) str_replace($smap, $rmap, $string); |
|
| 162 | - } else { |
|
| 163 | - $string = preg_replace('/"\s+"/', '', $string); |
|
| 164 | - $smap = array('\\n', '\\r', '\\t', '\"'); |
|
| 165 | - $rmap = array("\n", "\r", "\t", '"'); |
|
| 166 | - return (string) str_replace($smap, $rmap, $string); |
|
| 167 | - } |
|
| 168 | - } |
|
| 147 | + /** |
|
| 148 | + * prepare |
|
| 149 | + * |
|
| 150 | + * @static |
|
| 151 | + * @access protected |
|
| 152 | + * @return string |
|
| 153 | + * @param string $string |
|
| 154 | + * @param bool $reverse |
|
| 155 | + */ |
|
| 156 | + static function prepare($string, $reverse = false) |
|
| 157 | + { |
|
| 158 | + if ($reverse) { |
|
| 159 | + $smap = array('"', "\n", "\t", "\r"); |
|
| 160 | + $rmap = array('\"', '\\n"' . "\n" . '"', '\\t', '\\r'); |
|
| 161 | + return (string) str_replace($smap, $rmap, $string); |
|
| 162 | + } else { |
|
| 163 | + $string = preg_replace('/"\s+"/', '', $string); |
|
| 164 | + $smap = array('\\n', '\\r', '\\t', '\"'); |
|
| 165 | + $rmap = array("\n", "\r", "\t", '"'); |
|
| 166 | + return (string) str_replace($smap, $rmap, $string); |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - /** |
|
| 171 | - * meta2array |
|
| 172 | - * |
|
| 173 | - * @static |
|
| 174 | - * @access public |
|
| 175 | - * @return array |
|
| 176 | - * @param string $meta |
|
| 177 | - */ |
|
| 178 | - static function meta2array($meta) |
|
| 179 | - { |
|
| 180 | - $array = array(); |
|
| 181 | - foreach (explode("\n", $meta) as $info) { |
|
| 182 | - if ($info = trim($info)) { |
|
| 183 | - list($key, $value) = explode(':', $info, 2); |
|
| 184 | - $array[trim($key)] = trim($value); |
|
| 185 | - } |
|
| 186 | - } |
|
| 187 | - return $array; |
|
| 188 | - } |
|
| 170 | + /** |
|
| 171 | + * meta2array |
|
| 172 | + * |
|
| 173 | + * @static |
|
| 174 | + * @access public |
|
| 175 | + * @return array |
|
| 176 | + * @param string $meta |
|
| 177 | + */ |
|
| 178 | + static function meta2array($meta) |
|
| 179 | + { |
|
| 180 | + $array = array(); |
|
| 181 | + foreach (explode("\n", $meta) as $info) { |
|
| 182 | + if ($info = trim($info)) { |
|
| 183 | + list($key, $value) = explode(':', $info, 2); |
|
| 184 | + $array[trim($key)] = trim($value); |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + return $array; |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | - /** |
|
| 191 | - * toArray |
|
| 192 | - * |
|
| 193 | - * Returns meta info and strings as an array of a structure like that: |
|
| 194 | - * <code> |
|
| 195 | - * array( |
|
| 196 | - * 'meta' => array( |
|
| 197 | - * 'Content-Type' => 'text/plain; charset=iso-8859-1', |
|
| 198 | - * 'Last-Translator' => 'Michael Wallner <[email protected]>', |
|
| 199 | - * 'PO-Revision-Date' => '2004-07-21 17:03+0200', |
|
| 200 | - * 'Language-Team' => 'German <[email protected]>', |
|
| 201 | - * ), |
|
| 202 | - * 'strings' => array( |
|
| 203 | - * 'All rights reserved' => 'Alle Rechte vorbehalten', |
|
| 204 | - * 'Welcome' => 'Willkommen', |
|
| 205 | - * // ... |
|
| 206 | - * ) |
|
| 207 | - * ) |
|
| 208 | - * </code> |
|
| 209 | - * |
|
| 210 | - * @see fromArray() |
|
| 211 | - * @access protected |
|
| 212 | - * @return array |
|
| 213 | - */ |
|
| 214 | - function toArray() |
|
| 215 | - { |
|
| 216 | - return array('meta' => $this->meta, 'strings' => $this->strings); |
|
| 217 | - } |
|
| 190 | + /** |
|
| 191 | + * toArray |
|
| 192 | + * |
|
| 193 | + * Returns meta info and strings as an array of a structure like that: |
|
| 194 | + * <code> |
|
| 195 | + * array( |
|
| 196 | + * 'meta' => array( |
|
| 197 | + * 'Content-Type' => 'text/plain; charset=iso-8859-1', |
|
| 198 | + * 'Last-Translator' => 'Michael Wallner <[email protected]>', |
|
| 199 | + * 'PO-Revision-Date' => '2004-07-21 17:03+0200', |
|
| 200 | + * 'Language-Team' => 'German <[email protected]>', |
|
| 201 | + * ), |
|
| 202 | + * 'strings' => array( |
|
| 203 | + * 'All rights reserved' => 'Alle Rechte vorbehalten', |
|
| 204 | + * 'Welcome' => 'Willkommen', |
|
| 205 | + * // ... |
|
| 206 | + * ) |
|
| 207 | + * ) |
|
| 208 | + * </code> |
|
| 209 | + * |
|
| 210 | + * @see fromArray() |
|
| 211 | + * @access protected |
|
| 212 | + * @return array |
|
| 213 | + */ |
|
| 214 | + function toArray() |
|
| 215 | + { |
|
| 216 | + return array('meta' => $this->meta, 'strings' => $this->strings); |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - /** |
|
| 220 | - * fromArray |
|
| 221 | - * |
|
| 222 | - * Assigns meta info and strings from an array of a structure like that: |
|
| 223 | - * <code> |
|
| 224 | - * array( |
|
| 225 | - * 'meta' => array( |
|
| 226 | - * 'Content-Type' => 'text/plain; charset=iso-8859-1', |
|
| 227 | - * 'Last-Translator' => 'Michael Wallner <[email protected]>', |
|
| 228 | - * 'PO-Revision-Date' => date('Y-m-d H:iO'), |
|
| 229 | - * 'Language-Team' => 'German <[email protected]>', |
|
| 230 | - * ), |
|
| 231 | - * 'strings' => array( |
|
| 232 | - * 'All rights reserved' => 'Alle Rechte vorbehalten', |
|
| 233 | - * 'Welcome' => 'Willkommen', |
|
| 234 | - * // ... |
|
| 235 | - * ) |
|
| 236 | - * ) |
|
| 237 | - * </code> |
|
| 238 | - * |
|
| 239 | - * @see toArray() |
|
| 240 | - * @access protected |
|
| 241 | - * @return bool |
|
| 242 | - * @param array $array |
|
| 243 | - */ |
|
| 244 | - function fromArray($array) |
|
| 245 | - { |
|
| 246 | - if (!array_key_exists('strings', $array)) { |
|
| 247 | - if (count($array) != 2) { |
|
| 248 | - return false; |
|
| 249 | - } else { |
|
| 250 | - list($this->meta, $this->strings) = $array; |
|
| 251 | - } |
|
| 252 | - } else { |
|
| 253 | - $this->meta = @$array['meta']; |
|
| 254 | - $this->strings = @$array['strings']; |
|
| 255 | - } |
|
| 256 | - return true; |
|
| 257 | - } |
|
| 219 | + /** |
|
| 220 | + * fromArray |
|
| 221 | + * |
|
| 222 | + * Assigns meta info and strings from an array of a structure like that: |
|
| 223 | + * <code> |
|
| 224 | + * array( |
|
| 225 | + * 'meta' => array( |
|
| 226 | + * 'Content-Type' => 'text/plain; charset=iso-8859-1', |
|
| 227 | + * 'Last-Translator' => 'Michael Wallner <[email protected]>', |
|
| 228 | + * 'PO-Revision-Date' => date('Y-m-d H:iO'), |
|
| 229 | + * 'Language-Team' => 'German <[email protected]>', |
|
| 230 | + * ), |
|
| 231 | + * 'strings' => array( |
|
| 232 | + * 'All rights reserved' => 'Alle Rechte vorbehalten', |
|
| 233 | + * 'Welcome' => 'Willkommen', |
|
| 234 | + * // ... |
|
| 235 | + * ) |
|
| 236 | + * ) |
|
| 237 | + * </code> |
|
| 238 | + * |
|
| 239 | + * @see toArray() |
|
| 240 | + * @access protected |
|
| 241 | + * @return bool |
|
| 242 | + * @param array $array |
|
| 243 | + */ |
|
| 244 | + function fromArray($array) |
|
| 245 | + { |
|
| 246 | + if (!array_key_exists('strings', $array)) { |
|
| 247 | + if (count($array) != 2) { |
|
| 248 | + return false; |
|
| 249 | + } else { |
|
| 250 | + list($this->meta, $this->strings) = $array; |
|
| 251 | + } |
|
| 252 | + } else { |
|
| 253 | + $this->meta = @$array['meta']; |
|
| 254 | + $this->strings = @$array['strings']; |
|
| 255 | + } |
|
| 256 | + return true; |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - /** |
|
| 260 | - * toMO |
|
| 261 | - * |
|
| 262 | - * @access protected |
|
| 263 | - * @return object File_Gettext_MO |
|
| 264 | - */ |
|
| 265 | - function toMO() |
|
| 266 | - { |
|
| 267 | - include_once dirname(__FILE__).'/MO.php'; |
|
| 268 | - $MO = new TGettext_MO; |
|
| 269 | - $MO->fromArray($this->toArray()); |
|
| 270 | - return $MO; |
|
| 271 | - } |
|
| 259 | + /** |
|
| 260 | + * toMO |
|
| 261 | + * |
|
| 262 | + * @access protected |
|
| 263 | + * @return object File_Gettext_MO |
|
| 264 | + */ |
|
| 265 | + function toMO() |
|
| 266 | + { |
|
| 267 | + include_once dirname(__FILE__).'/MO.php'; |
|
| 268 | + $MO = new TGettext_MO; |
|
| 269 | + $MO->fromArray($this->toArray()); |
|
| 270 | + return $MO; |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - /** |
|
| 274 | - * toPO |
|
| 275 | - * |
|
| 276 | - * @access protected |
|
| 277 | - * @return object File_Gettext_PO |
|
| 278 | - */ |
|
| 279 | - function toPO() |
|
| 280 | - { |
|
| 281 | - include_once dirname(__FILE__).'/PO.php'; |
|
| 282 | - $PO = new TGettext_PO; |
|
| 283 | - $PO->fromArray($this->toArray()); |
|
| 284 | - return $PO; |
|
| 285 | - } |
|
| 273 | + /** |
|
| 274 | + * toPO |
|
| 275 | + * |
|
| 276 | + * @access protected |
|
| 277 | + * @return object File_Gettext_PO |
|
| 278 | + */ |
|
| 279 | + function toPO() |
|
| 280 | + { |
|
| 281 | + include_once dirname(__FILE__).'/PO.php'; |
|
| 282 | + $PO = new TGettext_PO; |
|
| 283 | + $PO->fromArray($this->toArray()); |
|
| 284 | + return $PO; |
|
| 285 | + } |
|
| 286 | 286 | } |