| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version 0.9 4 * @author Carlos Souza 5 * @copyright Copyright (c) 2005 Carlos Souza <csouza@web-sense.net> 6 * @package PHPGettext 7 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) 8 * @link http://phpgettext.web-sense.net 9 * 10 * 11 */ 12 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 13 14 class PHPGettext_Message 15 { 16 // --- ATTRIBUTES --- 17 /** 18 * Short description of attribute comments 19 * 20 * @access public 21 * @var int 22 */ 23 var $comments = array(); 24 25 /** 26 * Short description of attribute is_fuzzy 27 * 28 * @access public 29 * @var int 30 */ 31 var $is_fuzzy = false; 32 33 /** 34 * Short description of attribute msgid 35 * 36 * @access public 37 * @var int 38 */ 39 var $msgid = ''; 40 41 /** 42 * Short description of attribute msgid 43 * 44 * @access public 45 * @var int 46 */ 47 var $msgid_plural = ''; 48 49 /** 50 * Short description of attribute msgstr 51 * 52 * @access public 53 * @var int 54 */ 55 var $msgstr = ''; 56 57 // --- OPERATIONS --- 58 59 /** 60 * Short description of method PHPGettext_Catalog_Entry 61 * 62 * @access public 63 * @author firstname and lastname of author, <author@example.org> 64 * @param void 65 * @param void 66 * @return void 67 */ 68 function PHPGettext_Message($msgid = "", $msgid_plural = null) 69 { 70 $this->msgid = $msgid; 71 $this->msgid_plural = $msgid_plural; 72 } 73 74 /** 75 * Short description of method setmsgstr 76 * 77 * @access public 78 * @author firstname and lastname of author, <author@example.org> 79 * @param void 80 * @return void 81 */ 82 function setmsgstr($msgstr) 83 { 84 $this->msgstr = $msgstr; 85 if (is_array($msgstr) && count($msgstr) == 1) $this->msgstr = $msgstr[0]; 86 } 87 88 /** 89 * Short description of method setFuzzy 90 * 91 * @access public 92 * @author firstname and lastname of author, <author@example.org> 93 * @param void 94 * @return void 95 */ 96 function setfuzzy($is_fuzzy = true) 97 { 98 $this->is_fuzzy = ($is_fuzzy) ? true : false; 99 } 100 101 /** 102 * Short description of method setComments 103 * 104 * @access public 105 * @author firstname and lastname of author, <author@example.org> 106 * @param void 107 * @return void 108 */ 109 function setcomments($comments) 110 { 111 if (is_array($comments)) 112 return $this->comments = $comments; 113 114 return false; 115 } 116 117 /** 118 * Short description of method reset 119 * 120 * @access public 121 * @author firstname and lastname of author, <author@example.org> 122 * @param void 123 * @return void 124 */ 125 function reset($property = 'all') 126 { 127 switch ($property) 128 { 129 case 'comments': 130 unset($this->comments); 131 break; 132 case 'is_fuzzy': 133 unset($this->fuzzy); 134 break; 135 case 'msgid': 136 unset($this->msgid); 137 break; 138 case 'msgstr': 139 unset($this->msgstr); 140 break; 141 case 'all': 142 default: 143 unset($this->comments); 144 unset($this->is_fuzzy); 145 unset($this->msgid); 146 unset($this->msgstr); 147 break; 148 } 149 } 150 151 152 /** 153 * Short description of method toString 154 * 155 * @access public 156 * @author firstname and lastname of author, <author@example.org> 157 * @return void 158 */ 159 function toString() 160 { 161 $string = ''; 162 // comments 163 if (count($this->comments > 0)) { 164 foreach ($this->comments as $comment){ 165 if (!preg_match('/^#,/', $comment) && !is_null($comment)) { 166 $string .= trim($comment)."\n"; 167 } elseif (strncmp($comment, "#:", 2) == 0) { 168 $string .= trim($comment)."\n"; 169 } else { 170 continue; 171 } 172 } 173 } 174 175 // fuzzy entries 176 if ($this->is_fuzzy) { 177 $string .= "#, fuzzy\n"; 178 } 179 /* 180 181 if (strlen($msgid) > 76) { 182 $entry .= 'msgid ""'."\n"; 183 $entry .= '"'.wordwrap($msgid, 76, " \"\n\"")."\"\n"; 184 } else { 185 $entry .= 'msgid "'.$msgid.'"'."\n"; 186 } 187 */ 188 // msgid 189 if (strpos($this->msgid, "\n") > 0) { 190 $string .= "msgid \"\"\n"; 191 $msgid = explode("\n", $this->msgid); 192 foreach ($msgid as $line) 193 $string .= "\"$line\\n\"\n"; 194 } else { 195 $string .= "msgid \"$this->msgid\"\n"; 196 } 197 198 if (!empty($this->msgid_plural)) { 199 $string .= "msgid_plural \"$this->msgid_plural\"\n"; 200 } 201 // msgstr 202 if (!is_array($this->msgstr) && strpos($this->msgstr, "\n") > 0) { 203 $string .= "msgstr \"\"\n"; 204 $msgstr = explode("\n", $this->msgstr); 205 foreach ($msgstr as $line) 206 $string .= "\"$line\\n\"\n"; 207 $string .= "\n"; 208 } // plurals 209 elseif (is_array($this->msgstr)){ 210 foreach ($this->msgstr as $k => $msgstr) { 211 $string .= "msgstr[$k] \"$msgstr\"\n"; 212 } 213 $string .= "\n"; 214 } else { 215 $string .= "msgstr \"$this->msgstr\"\n\n"; 216 } 217 return $string; 218 } 219 220 } /* end of class PHPGettext_Catalog_Entry */ 221 222 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed May 23 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |