| @@ -289,7 +289,7 @@ | ||
| 289 | 289 | |
| 290 | 290 | // check for authentication expiration | 
| 291 | 291 | $isAuthExpired = $this->_authExpire>0 && !$user->getIsGuest() && | 
| 292 | -        ($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime<time(); | |
| 292 | +		($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime<time(); | |
| 293 | 293 | |
| 294 | 294 | // try authenticating through cookie if possible | 
| 295 | 295 | if($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired)) | 
| @@ -79,7 +79,7 @@ discard block | ||
| 79 | 79 | |
| 80 | 80 | /** | 
| 81 | 81 | * The DateTimeFormatInfo, containing culture specific patterns and names. | 
| 82 | - * @var DateTimeFormatInfo | |
| 82 | + * @var DateTimeFormatInfo | |
| 83 | 83 | */ | 
| 84 | 84 | protected $formatInfo; | 
| 85 | 85 | |
| @@ -308,8 +308,8 @@ discard block | ||
| 308 | 308 | |
| 309 | 309 | /** | 
| 310 | 310 | * Get the year. | 
| 311 | - * "yy" will return the last two digits of year. | |
| 312 | - * "yyyy" will return the full integer year. | |
| 311 | + * "yy" will return the last two digits of year. | |
| 312 | + * "yyyy" will return the full integer year. | |
| 313 | 313 | * @param array getdate format. | 
| 314 | 314 | * @param string a pattern. | 
| 315 | 315 | * @return string year | 
| @@ -330,10 +330,10 @@ discard block | ||
| 330 | 330 | |
| 331 | 331 | /** | 
| 332 | 332 | * Get the month. | 
| 333 | - * "M" will return integer 1 through 12 | |
| 334 | - * "MM" will return the narrow month name, e.g. "J" | |
| 335 | - * "MMM" will return the abrreviated month name, e.g. "Jan" | |
| 336 | - * "MMMM" will return the month name, e.g. "January" | |
| 333 | + * "M" will return integer 1 through 12 | |
| 334 | + * "MM" will return the narrow month name, e.g. "J" | |
| 335 | + * "MMM" will return the abrreviated month name, e.g. "Jan" | |
| 336 | + * "MMMM" will return the month name, e.g. "January" | |
| 337 | 337 | * @param array getdate format. | 
| 338 | 338 | * @param string a pattern. | 
| 339 | 339 | * @return string month name | 
| @@ -361,10 +361,10 @@ discard block | ||
| 361 | 361 | |
| 362 | 362 | /** | 
| 363 | 363 | * Get the day of the week. | 
| 364 | - * "E" will return integer 0 (for Sunday) through 6 (for Saturday). | |
| 365 | - * "EE" will return the narrow day of the week, e.g. "M" | |
| 366 | - * "EEE" will return the abrreviated day of the week, e.g. "Mon" | |
| 367 | - * "EEEE" will return the day of the week, e.g. "Monday" | |
| 364 | + * "E" will return integer 0 (for Sunday) through 6 (for Saturday). | |
| 365 | + * "EE" will return the narrow day of the week, e.g. "M" | |
| 366 | + * "EEE" will return the abrreviated day of the week, e.g. "Mon" | |
| 367 | + * "EEEE" will return the day of the week, e.g. "Monday" | |
| 368 | 368 | * @param array getdate format. | 
| 369 | 369 | * @param string a pattern. | 
| 370 | 370 | * @return string day of the week. | 
| @@ -394,7 +394,7 @@ discard block | ||
| 394 | 394 | |
| 395 | 395 | /** | 
| 396 | 396 | * Get the day of the month. | 
| 397 | - * "d" for non-padding, "dd" will always return 2 characters. | |
| 397 | + * "d" for non-padding, "dd" will always return 2 characters. | |
| 398 | 398 | * @param array getdate format. | 
| 399 | 399 | * @param string a pattern. | 
| 400 | 400 | * @return string day of the month | 
| @@ -581,14 +581,14 @@ discard block | ||
| 581 | 581 | protected function getDayInMonth($date, $pattern='FF') | 
| 582 | 582 |  	{ | 
| 583 | 583 |  		switch ($pattern) { | 
| 584 | - case 'F': | |
| 585 | -		      return @date('j', @mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year'])); | |
| 586 | - break; | |
| 587 | - case 'FF': | |
| 588 | -		      return @date('d', @mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year'])); | |
| 589 | - break; | |
| 590 | - default: | |
| 591 | -		      throw new Exception('The pattern for day in month is "F" or "FF".'); | |
| 584 | + case 'F': | |
| 585 | +			  return @date('j', @mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year'])); | |
| 586 | + break; | |
| 587 | + case 'FF': | |
| 588 | +			  return @date('d', @mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year'])); | |
| 589 | + break; | |
| 590 | + default: | |
| 591 | +			  throw new Exception('The pattern for day in month is "F" or "FF".'); | |
| 592 | 592 | } | 
| 593 | 593 | } | 
| 594 | 594 | |
| @@ -149,46 +149,46 @@ discard block | ||
| 149 | 149 | * (invariant). | 
| 150 | 150 | * @return DateTimeFormatInfo default DateTimeFormatInfo. | 
| 151 | 151 | */ | 
| 152 | - static function getInvariantInfo() | |
| 153 | -    { | |
| 154 | - static $invariant; | |
| 152 | + static function getInvariantInfo() | |
| 153 | +	{ | |
| 154 | + static $invariant; | |
| 155 | 155 | if($invariant === null) | 
| 156 | -        { | |
| 157 | - $culture = CultureInfo::getInvariantCulture(); | |
| 158 | - $invariant = $culture->getDateTimeFormat(); | |
| 159 | - } | |
| 156 | +		{ | |
| 157 | + $culture = CultureInfo::getInvariantCulture(); | |
| 158 | + $invariant = $culture->getDateTimeFormat(); | |
| 159 | + } | |
| 160 | 160 | return $invariant; | 
| 161 | - } | |
| 162 | - | |
| 163 | - /** | |
| 164 | - * Returns the DateTimeFormatInfo associated with the specified culture. | |
| 165 | - * @param CultureInfo the culture that gets the DateTimeFormat property. | |
| 166 | - * @return DateTimeFormatInfo DateTimeFormatInfo for the specified | |
| 167 | - * culture. | |
| 168 | - */ | |
| 169 | - static function getInstance($culture=null) | |
| 170 | -    { | |
| 171 | - | |
| 172 | - if ($culture instanceof CultureInfo) | |
| 173 | - return $culture->getDateTimeFormat(); | |
| 174 | - else if(is_string($culture)) | |
| 175 | -       	{ | |
| 176 | - $cultureInfo = CultureInfo::getInstance($culture); | |
| 177 | - return $cultureInfo->getDateTimeFormat(); | |
| 178 | - } | |
| 179 | - else | |
| 180 | -       	{ | |
| 161 | + } | |
| 162 | + | |
| 163 | + /** | |
| 164 | + * Returns the DateTimeFormatInfo associated with the specified culture. | |
| 165 | + * @param CultureInfo the culture that gets the DateTimeFormat property. | |
| 166 | + * @return DateTimeFormatInfo DateTimeFormatInfo for the specified | |
| 167 | + * culture. | |
| 168 | + */ | |
| 169 | + static function getInstance($culture=null) | |
| 170 | +	{ | |
| 171 | + | |
| 172 | + if ($culture instanceof CultureInfo) | |
| 173 | + return $culture->getDateTimeFormat(); | |
| 174 | + else if(is_string($culture)) | |
| 175 | +	   	{ | |
| 176 | + $cultureInfo = CultureInfo::getInstance($culture); | |
| 177 | + return $cultureInfo->getDateTimeFormat(); | |
| 178 | + } | |
| 179 | + else | |
| 180 | +	   	{ | |
| 181 | 181 | $cultureInfo = CultureInfo::getInvariantCulture(); | 
| 182 | - return $cultureInfo->getDateTimeFormat(); | |
| 183 | - } | |
| 184 | - } | |
| 182 | + return $cultureInfo->getDateTimeFormat(); | |
| 183 | + } | |
| 184 | + } | |
| 185 | 185 | |
| 186 | 186 | /** | 
| 187 | 187 | * A one-dimensional array of type String containing | 
| 188 | 188 | * the culture-specific abbreviated names of the days | 
| 189 | 189 | * of the week. The array for InvariantInfo contains | 
| 190 | 190 | * "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", and "Sat". | 
| 191 | - * @return array abbreviated day names | |
| 191 | + * @return array abbreviated day names | |
| 192 | 192 | */ | 
| 193 | 193 | function getAbbreviatedDayNames() | 
| 194 | 194 |  	{ | 
| @@ -196,37 +196,37 @@ discard block | ||
| 196 | 196 | //return $this->data['dayNames/format/abbreviated']; | 
| 197 | 197 | } | 
| 198 | 198 | |
| 199 | - /** | |
| 200 | - * Set the abbreviated day names. The value should be | |
| 201 | - * an array of string starting with Sunday and ends in Saturady. | |
| 202 | - * For example, | |
| 203 | -     * <code>array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");</code> | |
| 204 | - * @param array abbreviated day names. | |
| 205 | - */ | |
| 206 | - function setAbbreviatedDayNames($value) | |
| 207 | -    { | |
| 208 | - $this->data['dayNames']['format']['abbreviated'] = $value; | |
| 209 | - } | |
| 199 | + /** | |
| 200 | + * Set the abbreviated day names. The value should be | |
| 201 | + * an array of string starting with Sunday and ends in Saturady. | |
| 202 | + * For example, | |
| 203 | +	 * <code>array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");</code> | |
| 204 | + * @param array abbreviated day names. | |
| 205 | + */ | |
| 206 | + function setAbbreviatedDayNames($value) | |
| 207 | +	{ | |
| 208 | + $this->data['dayNames']['format']['abbreviated'] = $value; | |
| 209 | + } | |
| 210 | 210 | |
| 211 | 211 | /** | 
| 212 | 212 | * A one-dimensional array of type String containing | 
| 213 | 213 | * the culture-specific narrow names of the days | 
| 214 | 214 | * of the week. The array for InvariantInfo contains | 
| 215 | 215 | * "S", "M", "T", "W", "T", "F", and "S". | 
| 216 | - * @return array narrow day names | |
| 216 | + * @return array narrow day names | |
| 217 | 217 | */ | 
| 218 | 218 | function getNarrowDayNames() | 
| 219 | 219 |  	{ | 
| 220 | 220 | return $this->data['dayNames']['format']['narrow']; | 
| 221 | 221 | } | 
| 222 | 222 | |
| 223 | - /** | |
| 224 | - * Set the narrow day names. The value should be | |
| 225 | - * an array of string starting with Sunday and ends in Saturady. | |
| 226 | - * For example, | |
| 227 | -     * <code>array("S", "M", "T", "W", "T", "F", "S");</code> | |
| 228 | - * @param array narrow day names. | |
| 229 | - */ | |
| 223 | + /** | |
| 224 | + * Set the narrow day names. The value should be | |
| 225 | + * an array of string starting with Sunday and ends in Saturady. | |
| 226 | + * For example, | |
| 227 | +	 * <code>array("S", "M", "T", "W", "T", "F", "S");</code> | |
| 228 | + * @param array narrow day names. | |
| 229 | + */ | |
| 230 | 230 | function setNarrowDayNames($value) | 
| 231 | 231 |  	{ | 
| 232 | 232 | $this->data['dayNames']['format']['narrow'] = $value; | 
| @@ -237,7 +237,7 @@ discard block | ||
| 237 | 237 | * culture-specific full names of the days of the week. | 
| 238 | 238 | * The array for InvariantInfo contains "Sunday", "Monday", | 
| 239 | 239 | * "Tuesday", "Wednesday", "Thursday", "Friday", and "Saturday". | 
| 240 | - * @return array day names | |
| 240 | + * @return array day names | |
| 241 | 241 | */ | 
| 242 | 242 | function getDayNames() | 
| 243 | 243 |  	{ | 
| @@ -245,14 +245,14 @@ discard block | ||
| 245 | 245 | } | 
| 246 | 246 | |
| 247 | 247 | |
| 248 | - /** | |
| 249 | - * Set the day names. The value should be | |
| 250 | - * an array of string starting with Sunday and ends in Saturady. | |
| 251 | - * For example, | |
| 252 | -     * <code>array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", | |
| 253 | - * "Friday", "Saturday".);</code> | |
| 254 | - * @param array day names. | |
| 255 | - */ | |
| 248 | + /** | |
| 249 | + * Set the day names. The value should be | |
| 250 | + * an array of string starting with Sunday and ends in Saturady. | |
| 251 | + * For example, | |
| 252 | +	 * <code>array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", | |
| 253 | + * "Friday", "Saturday".);</code> | |
| 254 | + * @param array day names. | |
| 255 | + */ | |
| 256 | 256 | function setDayNames($value) | 
| 257 | 257 |  	{ | 
| 258 | 258 | $this->data['dayNames']['format']['wide'] = $value; | 
| @@ -270,17 +270,17 @@ discard block | ||
| 270 | 270 | return $this->data['monthNames']['format']['narrow']; | 
| 271 | 271 | } | 
| 272 | 272 | |
| 273 | - /** | |
| 274 | - * Set the narrow month names. The value should be | |
| 275 | - * an array of string starting with J and ends in D. | |
| 276 | - * For example, | |
| 277 | -     * <code>array("J","F","M","A","M","J","J","A","S","O","N","D");</code> | |
| 278 | - * @param array month names. | |
| 279 | - */ | |
| 280 | - function setNarrowMonthNames($value) | |
| 281 | -    { | |
| 282 | - $this->data['monthNames']['format']['narrow'] = $value; | |
| 283 | - } | |
| 273 | + /** | |
| 274 | + * Set the narrow month names. The value should be | |
| 275 | + * an array of string starting with J and ends in D. | |
| 276 | + * For example, | |
| 277 | +	 * <code>array("J","F","M","A","M","J","J","A","S","O","N","D");</code> | |
| 278 | + * @param array month names. | |
| 279 | + */ | |
| 280 | + function setNarrowMonthNames($value) | |
| 281 | +	{ | |
| 282 | + $this->data['monthNames']['format']['narrow'] = $value; | |
| 283 | + } | |
| 284 | 284 | |
| 285 | 285 | /** | 
| 286 | 286 | * A one-dimensional array of type String containing the | 
| @@ -298,18 +298,18 @@ discard block | ||
| 298 | 298 | return $this->data['monthNames']['format']['wide']; | 
| 299 | 299 | } | 
| 300 | 300 | |
| 301 | - /** | |
| 302 | - * Set the abbreviated month names. The value should be | |
| 303 | - * an array of string starting with Jan and ends in Dec. | |
| 304 | - * For example, | |
| 305 | -     * <code>array("Jan", "Feb", "Mar", "Apr", "May", "Jun", | |
| 306 | - * "Jul", "Aug", "Sep","Oct","Nov","Dec");</code> | |
| 307 | - * @param array month names. | |
| 308 | - */ | |
| 309 | - function setAbbreviatedMonthNames($value) | |
| 310 | -    { | |
| 311 | - $this->data['monthNames']['format']['abbreviated'] = $value; | |
| 312 | - } | |
| 301 | + /** | |
| 302 | + * Set the abbreviated month names. The value should be | |
| 303 | + * an array of string starting with Jan and ends in Dec. | |
| 304 | + * For example, | |
| 305 | +	 * <code>array("Jan", "Feb", "Mar", "Apr", "May", "Jun", | |
| 306 | + * "Jul", "Aug", "Sep","Oct","Nov","Dec");</code> | |
| 307 | + * @param array month names. | |
| 308 | + */ | |
| 309 | + function setAbbreviatedMonthNames($value) | |
| 310 | +	{ | |
| 311 | + $this->data['monthNames']['format']['abbreviated'] = $value; | |
| 312 | + } | |
| 313 | 313 | |
| 314 | 314 | /** | 
| 315 | 315 | * A one-dimensional array of type String containing the | 
| @@ -324,18 +324,18 @@ discard block | ||
| 324 | 324 | return $this->data['monthNames']['format']['wide']; | 
| 325 | 325 | } | 
| 326 | 326 | |
| 327 | - /** | |
| 328 | - * Set the month names. The value should be | |
| 329 | - * an array of string starting with Janurary and ends in December. | |
| 330 | - * For example, | |
| 331 | -     * <code>array("January", "February", "March", "April", "May", "June", | |
| 332 | - * "July", "August", "September","October","November","December");</code> | |
| 333 | - * @param array month names. | |
| 334 | - */ | |
| 335 | - function setMonthNames($value) | |
| 336 | -    { | |
| 337 | - $this->data['monthNames']['format']['wide'] = $value; | |
| 338 | - } | |
| 327 | + /** | |
| 328 | + * Set the month names. The value should be | |
| 329 | + * an array of string starting with Janurary and ends in December. | |
| 330 | + * For example, | |
| 331 | +	 * <code>array("January", "February", "March", "April", "May", "June", | |
| 332 | + * "July", "August", "September","October","November","December");</code> | |
| 333 | + * @param array month names. | |
| 334 | + */ | |
| 335 | + function setMonthNames($value) | |
| 336 | +	{ | |
| 337 | + $this->data['monthNames']['format']['wide'] = $value; | |
| 338 | + } | |
| 339 | 339 | |
| 340 | 340 | /** | 
| 341 | 341 | * A string containing the name of the era. | 
| @@ -359,16 +359,16 @@ discard block | ||
| 359 | 359 | return $result[0]; | 
| 360 | 360 | } | 
| 361 | 361 | |
| 362 | - /** | |
| 363 | - * Set the AM Designator. For example, 'AM'. | |
| 364 | - * @param string AM designator. | |
| 365 | - */ | |
| 366 | - function setAMDesignator($value) | |
| 367 | -    { | |
| 368 | - $markers = $this->getAMPMMarkers(); | |
| 369 | - $markers[0] = $value; | |
| 370 | - $this->setAMPMMarkers($markers); | |
| 371 | - } | |
| 362 | + /** | |
| 363 | + * Set the AM Designator. For example, 'AM'. | |
| 364 | + * @param string AM designator. | |
| 365 | + */ | |
| 366 | + function setAMDesignator($value) | |
| 367 | +	{ | |
| 368 | + $markers = $this->getAMPMMarkers(); | |
| 369 | + $markers[0] = $value; | |
| 370 | + $this->setAMPMMarkers($markers); | |
| 371 | + } | |
| 372 | 372 | |
| 373 | 373 | /** | 
| 374 | 374 | * The string designator for hours that are "post meridiem" (after noon). | 
| @@ -381,41 +381,41 @@ discard block | ||
| 381 | 381 | return $result[1]; | 
| 382 | 382 | } | 
| 383 | 383 | |
| 384 | - /** | |
| 385 | - * Set the PM Designator. For example, 'PM'. | |
| 386 | - * @param string PM designator. | |
| 387 | - */ | |
| 388 | - function setPMDesignator($value) | |
| 389 | -    { | |
| 390 | - $markers = $this->getAMPMMarkers(); | |
| 391 | - $markers[1] = $value; | |
| 392 | - $this->setAMPMMarkers($markers); | |
| 393 | - } | |
| 394 | - | |
| 395 | - /** | |
| 396 | - * Get the AM and PM markers array. | |
| 397 | -     * Default InvariantInfo for AM and PM is <code>array('AM','PM');</code> | |
| 398 | - * @return array AM and PM markers | |
| 399 | - */ | |
| 400 | - function getAMPMMarkers() | |
| 384 | + /** | |
| 385 | + * Set the PM Designator. For example, 'PM'. | |
| 386 | + * @param string PM designator. | |
| 387 | + */ | |
| 388 | + function setPMDesignator($value) | |
| 389 | +	{ | |
| 390 | + $markers = $this->getAMPMMarkers(); | |
| 391 | + $markers[1] = $value; | |
| 392 | + $this->setAMPMMarkers($markers); | |
| 393 | + } | |
| 394 | + | |
| 395 | + /** | |
| 396 | + * Get the AM and PM markers array. | |
| 397 | +	 * Default InvariantInfo for AM and PM is <code>array('AM','PM');</code> | |
| 398 | + * @return array AM and PM markers | |
| 399 | + */ | |
| 400 | + function getAMPMMarkers() | |
| 401 | 401 |  	{ | 
| 402 | 402 | return $this->data['AmPmMarkers']; | 
| 403 | 403 | } | 
| 404 | 404 | |
| 405 | - /** | |
| 406 | - * Set the AM and PM markers array. | |
| 407 | -     * For example <code>array('AM','PM');</code> | |
| 408 | - * @param array AM and PM markers | |
| 409 | - */ | |
| 410 | - function setAMPMMarkers($value) | |
| 411 | -    { | |
| 412 | - $this->data['AmPmMarkers'] = $value; | |
| 413 | - } | |
| 405 | + /** | |
| 406 | + * Set the AM and PM markers array. | |
| 407 | +	 * For example <code>array('AM','PM');</code> | |
| 408 | + * @param array AM and PM markers | |
| 409 | + */ | |
| 410 | + function setAMPMMarkers($value) | |
| 411 | +	{ | |
| 412 | + $this->data['AmPmMarkers'] = $value; | |
| 413 | + } | |
| 414 | 414 | |
| 415 | 415 | /** | 
| 416 | 416 | * Returns the full time pattern "HH:mm:ss z" (default). | 
| 417 | - * This is culture sensitive. | |
| 418 | - * @return string pattern "HH:mm:ss z". | |
| 417 | + * This is culture sensitive. | |
| 418 | + * @return string pattern "HH:mm:ss z". | |
| 419 | 419 | */ | 
| 420 | 420 | function getFullTimePattern() | 
| 421 | 421 |  	{ | 
| @@ -424,8 +424,8 @@ discard block | ||
| 424 | 424 | |
| 425 | 425 | /** | 
| 426 | 426 | * Returns the long time pattern "HH:mm:ss z" (default). | 
| 427 | - * This is culture sensitive. | |
| 428 | - * @return string pattern "HH:mm:ss z". | |
| 427 | + * This is culture sensitive. | |
| 428 | + * @return string pattern "HH:mm:ss z". | |
| 429 | 429 | */ | 
| 430 | 430 | function getLongTimePattern() | 
| 431 | 431 |  	{ | 
| @@ -434,8 +434,8 @@ discard block | ||
| 434 | 434 | |
| 435 | 435 | /** | 
| 436 | 436 | * Returns the medium time pattern "HH:mm:ss" (default). | 
| 437 | - * This is culture sensitive. | |
| 438 | - * @return string pattern "HH:mm:ss". | |
| 437 | + * This is culture sensitive. | |
| 438 | + * @return string pattern "HH:mm:ss". | |
| 439 | 439 | */ | 
| 440 | 440 | function getMediumTimePattern() | 
| 441 | 441 |  	{ | 
| @@ -444,8 +444,8 @@ discard block | ||
| 444 | 444 | |
| 445 | 445 | /** | 
| 446 | 446 | * Returns the short time pattern "HH:mm" (default). | 
| 447 | - * This is culture sensitive. | |
| 448 | - * @return string pattern "HH:mm". | |
| 447 | + * This is culture sensitive. | |
| 448 | + * @return string pattern "HH:mm". | |
| 449 | 449 | */ | 
| 450 | 450 | function getShortTimePattern() | 
| 451 | 451 |  	{ | 
| @@ -454,8 +454,8 @@ discard block | ||
| 454 | 454 | |
| 455 | 455 | /** | 
| 456 | 456 | * Returns the full date pattern "EEEE, yyyy MMMM dd" (default). | 
| 457 | - * This is culture sensitive. | |
| 458 | - * @return string pattern "EEEE, yyyy MMMM dd". | |
| 457 | + * This is culture sensitive. | |
| 458 | + * @return string pattern "EEEE, yyyy MMMM dd". | |
| 459 | 459 | */ | 
| 460 | 460 | function getFullDatePattern() | 
| 461 | 461 |  	{ | 
| @@ -464,8 +464,8 @@ discard block | ||
| 464 | 464 | |
| 465 | 465 | /** | 
| 466 | 466 | * Returns the long date pattern "yyyy MMMM d" (default). | 
| 467 | - * This is culture sensitive. | |
| 468 | - * @return string pattern "yyyy MMMM d". | |
| 467 | + * This is culture sensitive. | |
| 468 | + * @return string pattern "yyyy MMMM d". | |
| 469 | 469 | */ | 
| 470 | 470 | function getLongDatePattern() | 
| 471 | 471 |  	{ | 
| @@ -474,8 +474,8 @@ discard block | ||
| 474 | 474 | |
| 475 | 475 | /** | 
| 476 | 476 | * Returns the medium date pattern "yyyy MMMM d" (default). | 
| 477 | - * This is culture sensitive. | |
| 478 | - * @return string pattern "yyyy MMM d". | |
| 477 | + * This is culture sensitive. | |
| 478 | + * @return string pattern "yyyy MMM d". | |
| 479 | 479 | */ | 
| 480 | 480 | function getMediumDatePattern() | 
| 481 | 481 |  	{ | 
| @@ -484,28 +484,28 @@ discard block | ||
| 484 | 484 | |
| 485 | 485 | /** | 
| 486 | 486 | * Returns the short date pattern "yy/MM/dd" (default). | 
| 487 | - * This is culture sensitive. | |
| 488 | - * @return string pattern "yy/MM/dd". | |
| 487 | + * This is culture sensitive. | |
| 488 | + * @return string pattern "yy/MM/dd". | |
| 489 | 489 | */ | 
| 490 | 490 | function getShortDatePattern() | 
| 491 | 491 |  	{ | 
| 492 | 492 | return $this->data['DateTimePatterns'][7]; | 
| 493 | 493 | } | 
| 494 | 494 | |
| 495 | - /** | |
| 496 | -     * Returns the date time order pattern, "{1} {0}" (default). | |
| 497 | - * This is culture sensitive. | |
| 498 | -     * @return string pattern "{1} {0}". | |
| 499 | - */ | |
| 500 | - function getDateTimeOrderPattern() | |
| 501 | -    { | |
| 502 | - return $this->data['DateTimePatterns'][8]; | |
| 503 | - } | |
| 495 | + /** | |
| 496 | +	 * Returns the date time order pattern, "{1} {0}" (default). | |
| 497 | + * This is culture sensitive. | |
| 498 | +	 * @return string pattern "{1} {0}". | |
| 499 | + */ | |
| 500 | + function getDateTimeOrderPattern() | |
| 501 | +	{ | |
| 502 | + return $this->data['DateTimePatterns'][8]; | |
| 503 | + } | |
| 504 | 504 | |
| 505 | 505 | /** | 
| 506 | 506 | * Formats the date and time in a culture sensitive paterrn. | 
| 507 | - * The default is "Date Time". | |
| 508 | - * @return string date and time formated | |
| 507 | + * The default is "Date Time". | |
| 508 | + * @return string date and time formated | |
| 509 | 509 | */ | 
| 510 | 510 | function formatDateTime($date, $time) | 
| 511 | 511 |  	{ | 
| @@ -76,7 +76,7 @@ discard block | ||
| 76 | 76 | |
| 77 | 77 | /** | 
| 78 | 78 | * The DateTimeFormatInfo, containing culture specific patterns and names. | 
| 79 | - * @var DateTimeFormatInfo | |
| 79 | + * @var DateTimeFormatInfo | |
| 80 | 80 | */ | 
| 81 | 81 | protected $formatInfo; | 
| 82 | 82 | |
| @@ -116,7 +116,7 @@ discard block | ||
| 116 | 116 | function format($number, $pattern='d', $currency='USD', $charset='UTF-8') | 
| 117 | 117 |  	{ | 
| 118 | 118 | $oldLocale=setLocale(LC_NUMERIC, '0'); | 
| 119 | - setlocale(LC_NUMERIC, 'C'); | |
| 119 | + setlocale(LC_NUMERIC, 'C'); | |
| 120 | 120 | |
| 121 | 121 | $this->setPattern($pattern); | 
| 122 | 122 | |
| @@ -122,7 +122,7 @@ discard block | ||
| 122 | 122 | /** | 
| 123 | 123 | * Set the pattern for a specific number pattern. The validate patterns | 
| 124 | 124 | * NumberFormatInfo::DECIMAL, NumberFormatInfo::CURRENCY, | 
| 125 | - * NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC | |
| 125 | + * NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC | |
| 126 | 126 | * @param int pattern type. | 
| 127 | 127 | */ | 
| 128 | 128 | public function setPattern($type=NumberFormatInfo::DECIMAL) | 
| @@ -152,94 +152,94 @@ discard block | ||
| 152 | 152 | * (invariant). | 
| 153 | 153 | * @return NumberFormatInfo default NumberFormatInfo. | 
| 154 | 154 | */ | 
| 155 | - public static function getInvariantInfo($type=NumberFormatInfo::DECIMAL) | |
| 156 | -    { | |
| 157 | - static $invariant; | |
| 155 | + public static function getInvariantInfo($type=NumberFormatInfo::DECIMAL) | |
| 156 | +	{ | |
| 157 | + static $invariant; | |
| 158 | 158 | if($invariant === null) | 
| 159 | -        { | |
| 160 | - $culture = CultureInfo::getInvariantCulture(); | |
| 161 | - $invariant = $culture->NumberFormat; | |
| 162 | - $invariant->setPattern($type); | |
| 163 | - } | |
| 159 | +		{ | |
| 160 | + $culture = CultureInfo::getInvariantCulture(); | |
| 161 | + $invariant = $culture->NumberFormat; | |
| 162 | + $invariant->setPattern($type); | |
| 163 | + } | |
| 164 | 164 | return $invariant; | 
| 165 | - } | |
| 166 | - | |
| 167 | - /** | |
| 168 | - * Returns the NumberFormatInfo associated with the specified culture. | |
| 169 | - * @param CultureInfo the culture that gets the NumberFormat property. | |
| 170 | - * @param int the number formatting type, it should be | |
| 171 | - * NumberFormatInfo::DECIMAL, NumberFormatInfo::CURRENCY, | |
| 172 | - * NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC | |
| 173 | - * @return NumberFormatInfo NumberFormatInfo for the specified | |
| 174 | - * culture. | |
| 175 | - * @see getCurrencyInstance(); | |
| 176 | - * @see getPercentageInstance(); | |
| 177 | - * @see getScientificInstance(); | |
| 178 | - */ | |
| 179 | - public static function getInstance($culture=null, | |
| 180 | - $type=NumberFormatInfo::DECIMAL) | |
| 181 | -    { | |
| 165 | + } | |
| 166 | + | |
| 167 | + /** | |
| 168 | + * Returns the NumberFormatInfo associated with the specified culture. | |
| 169 | + * @param CultureInfo the culture that gets the NumberFormat property. | |
| 170 | + * @param int the number formatting type, it should be | |
| 171 | + * NumberFormatInfo::DECIMAL, NumberFormatInfo::CURRENCY, | |
| 172 | + * NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC | |
| 173 | + * @return NumberFormatInfo NumberFormatInfo for the specified | |
| 174 | + * culture. | |
| 175 | + * @see getCurrencyInstance(); | |
| 176 | + * @see getPercentageInstance(); | |
| 177 | + * @see getScientificInstance(); | |
| 178 | + */ | |
| 179 | + public static function getInstance($culture=null, | |
| 180 | + $type=NumberFormatInfo::DECIMAL) | |
| 181 | +	{ | |
| 182 | 182 | if ($culture instanceof CultureInfo) | 
| 183 | 183 |     		{ | 
| 184 | - $formatInfo = $culture->NumberFormat; | |
| 185 | - $formatInfo->setPattern($type); | |
| 186 | - return $formatInfo; | |
| 184 | + $formatInfo = $culture->NumberFormat; | |
| 185 | + $formatInfo->setPattern($type); | |
| 186 | + return $formatInfo; | |
| 187 | 187 | } | 
| 188 | - else if(is_string($culture)) | |
| 189 | -       	{ | |
| 190 | - $cultureInfo = new CultureInfo($culture); | |
| 191 | - $formatInfo = $cultureInfo->NumberFormat; | |
| 192 | - $formatInfo->setPattern($type); | |
| 193 | - return $formatInfo; | |
| 194 | - } | |
| 195 | - else | |
| 196 | -       	{ | |
| 197 | - $cultureInfo = new CultureInfo(); | |
| 198 | - $formatInfo = $cultureInfo->NumberFormat; | |
| 199 | - $formatInfo->setPattern($type); | |
| 200 | - return $formatInfo; | |
| 201 | - } | |
| 202 | - } | |
| 203 | - | |
| 204 | - /** | |
| 205 | - * Returns the currency format info associated with the specified culture. | |
| 206 | - * @param CultureInfo the culture that gets the NumberFormat property. | |
| 207 | - * @return NumberFormatInfo NumberFormatInfo for the specified | |
| 208 | - * culture. | |
| 209 | - */ | |
| 210 | - public static function getCurrencyInstance($culture=null) | |
| 211 | -    { | |
| 212 | - return self::getInstance($culture, self::CURRENCY); | |
| 213 | - } | |
| 214 | - | |
| 215 | - /** | |
| 216 | - * Returns the percentage format info associated with the specified culture. | |
| 217 | - * @param CultureInfo the culture that gets the NumberFormat property. | |
| 218 | - * @return NumberFormatInfo NumberFormatInfo for the specified | |
| 219 | - * culture. | |
| 220 | - */ | |
| 221 | - public static function getPercentageInstance($culture=null) | |
| 222 | -    { | |
| 223 | - return self::getInstance($culture, self::PERCENTAGE); | |
| 224 | - } | |
| 225 | - | |
| 226 | - /** | |
| 227 | - * Returns the scientific format info associated with the specified culture. | |
| 228 | - * @param CultureInfo the culture that gets the NumberFormat property. | |
| 229 | - * @return NumberFormatInfo NumberFormatInfo for the specified | |
| 230 | - * culture. | |
| 231 | - */ | |
| 232 | - public static function getScientificInstance($culture=null) | |
| 233 | -    { | |
| 234 | - return self::getInstance($culture, self::SCIENTIFIC); | |
| 235 | - } | |
| 236 | - | |
| 237 | - /** | |
| 238 | - * Parse the given pattern and return a list of known properties. | |
| 239 | - * @param string a number pattern. | |
| 240 | - * @return array list of pattern properties. | |
| 241 | - */ | |
| 242 | - protected function parsePattern($pattern) | |
| 188 | + else if(is_string($culture)) | |
| 189 | +	   	{ | |
| 190 | + $cultureInfo = new CultureInfo($culture); | |
| 191 | + $formatInfo = $cultureInfo->NumberFormat; | |
| 192 | + $formatInfo->setPattern($type); | |
| 193 | + return $formatInfo; | |
| 194 | + } | |
| 195 | + else | |
| 196 | +	   	{ | |
| 197 | + $cultureInfo = new CultureInfo(); | |
| 198 | + $formatInfo = $cultureInfo->NumberFormat; | |
| 199 | + $formatInfo->setPattern($type); | |
| 200 | + return $formatInfo; | |
| 201 | + } | |
| 202 | + } | |
| 203 | + | |
| 204 | + /** | |
| 205 | + * Returns the currency format info associated with the specified culture. | |
| 206 | + * @param CultureInfo the culture that gets the NumberFormat property. | |
| 207 | + * @return NumberFormatInfo NumberFormatInfo for the specified | |
| 208 | + * culture. | |
| 209 | + */ | |
| 210 | + public static function getCurrencyInstance($culture=null) | |
| 211 | +	{ | |
| 212 | + return self::getInstance($culture, self::CURRENCY); | |
| 213 | + } | |
| 214 | + | |
| 215 | + /** | |
| 216 | + * Returns the percentage format info associated with the specified culture. | |
| 217 | + * @param CultureInfo the culture that gets the NumberFormat property. | |
| 218 | + * @return NumberFormatInfo NumberFormatInfo for the specified | |
| 219 | + * culture. | |
| 220 | + */ | |
| 221 | + public static function getPercentageInstance($culture=null) | |
| 222 | +	{ | |
| 223 | + return self::getInstance($culture, self::PERCENTAGE); | |
| 224 | + } | |
| 225 | + | |
| 226 | + /** | |
| 227 | + * Returns the scientific format info associated with the specified culture. | |
| 228 | + * @param CultureInfo the culture that gets the NumberFormat property. | |
| 229 | + * @return NumberFormatInfo NumberFormatInfo for the specified | |
| 230 | + * culture. | |
| 231 | + */ | |
| 232 | + public static function getScientificInstance($culture=null) | |
| 233 | +	{ | |
| 234 | + return self::getInstance($culture, self::SCIENTIFIC); | |
| 235 | + } | |
| 236 | + | |
| 237 | + /** | |
| 238 | + * Parse the given pattern and return a list of known properties. | |
| 239 | + * @param string a number pattern. | |
| 240 | + * @return array list of pattern properties. | |
| 241 | + */ | |
| 242 | + protected function parsePattern($pattern) | |
| 243 | 243 |  	{ | 
| 244 | 244 |  		$pattern = explode(';',$pattern); | 
| 245 | 245 | |
| @@ -355,296 +355,296 @@ discard block | ||
| 355 | 355 | } | 
| 356 | 356 | |
| 357 | 357 | |
| 358 | - /** | |
| 359 | - * Indicates the number of decimal places. | |
| 360 | - * @return int number of decimal places. | |
| 361 | - */ | |
| 362 | - function getDecimalDigits() | |
| 363 | -    { | |
| 364 | - return $this->pattern['decimalPoints']; | |
| 365 | - } | |
| 366 | - | |
| 367 | - /** | |
| 368 | - * Set the number of decimal places. | |
| 369 | - * @param int number of decimal places. | |
| 370 | - */ | |
| 371 | - function setDecimalDigits($value) | |
| 372 | -    { | |
| 373 | - return $this->pattern['decimalPoints'] = $value; | |
| 374 | - } | |
| 375 | - | |
| 376 | - function getDigitSize() | |
| 377 | -    { | |
| 378 | - return $this->pattern['digitSize']; | |
| 379 | - } | |
| 380 | - | |
| 381 | - function setDigitSize($value) | |
| 382 | -    { | |
| 383 | - $this->pattern['digitSize'] = $value; | |
| 384 | - } | |
| 385 | - | |
| 386 | - /** | |
| 387 | - * Gets the string to use as the decimal separator. | |
| 388 | - * @return string decimal separator. | |
| 389 | - */ | |
| 390 | - function getDecimalSeparator() | |
| 391 | -    { | |
| 392 | - return $this->data['NumberElements'][0]; | |
| 393 | - } | |
| 394 | - | |
| 395 | - /** | |
| 396 | - * Set the string to use as the decimal separator. | |
| 397 | - * @param string the decimal point | |
| 398 | - */ | |
| 399 | - function setDecimalSeparator($value) | |
| 400 | -    { | |
| 401 | - return $this->data['NumberElements'][0] = $value; | |
| 402 | - } | |
| 403 | - | |
| 404 | - /** | |
| 405 | - * Gets the string that separates groups of digits to the left | |
| 406 | - * of the decimal in currency values. | |
| 407 | - * @param parameter | |
| 408 | - * @return string currency group separator. | |
| 409 | - */ | |
| 410 | - function getGroupSeparator() | |
| 411 | -    { | |
| 412 | - return $this->data['NumberElements'][1]; | |
| 413 | - } | |
| 414 | - | |
| 415 | - /** | |
| 416 | - * Set the string to use as the group separator. | |
| 417 | - * @param string the group separator. | |
| 418 | - */ | |
| 419 | - function setGroupSeparator($value) | |
| 420 | -    { | |
| 421 | - return $this->data['NumberElements'][1] = $value; | |
| 422 | - } | |
| 423 | - | |
| 424 | - /** | |
| 425 | - * Gets the number of digits in each group to the left of the decimal | |
| 426 | - * There can be two grouping sizes, this fucntion | |
| 427 | - * returns <b>array(group1, group2)</b>, if there is only 1 grouping size, | |
| 428 | - * group2 will be false. | |
| 429 | - * @return array grouping size(s). | |
| 430 | - */ | |
| 431 | - function getGroupSizes() | |
| 432 | -    { | |
| 433 | - $group1 = $this->pattern['groupSize1']; | |
| 434 | - $group2 = $this->pattern['groupSize2']; | |
| 435 | - | |
| 436 | - return array($group1, $group2); | |
| 437 | - } | |
| 438 | - | |
| 439 | - /** | |
| 440 | - * Set the number of digits in each group to the left of the decimal. | |
| 441 | - * There can be two grouping sizes, the value should | |
| 442 | - * be an <b>array(group1, group2)</b>, if there is only 1 grouping size, | |
| 443 | - * group2 should be false. | |
| 444 | - * @param array grouping size(s). | |
| 445 | - */ | |
| 446 | - function setGroupSizes($groupSize) | |
| 447 | -    { | |
| 358 | + /** | |
| 359 | + * Indicates the number of decimal places. | |
| 360 | + * @return int number of decimal places. | |
| 361 | + */ | |
| 362 | + function getDecimalDigits() | |
| 363 | +	{ | |
| 364 | + return $this->pattern['decimalPoints']; | |
| 365 | + } | |
| 366 | + | |
| 367 | + /** | |
| 368 | + * Set the number of decimal places. | |
| 369 | + * @param int number of decimal places. | |
| 370 | + */ | |
| 371 | + function setDecimalDigits($value) | |
| 372 | +	{ | |
| 373 | + return $this->pattern['decimalPoints'] = $value; | |
| 374 | + } | |
| 375 | + | |
| 376 | + function getDigitSize() | |
| 377 | +	{ | |
| 378 | + return $this->pattern['digitSize']; | |
| 379 | + } | |
| 380 | + | |
| 381 | + function setDigitSize($value) | |
| 382 | +	{ | |
| 383 | + $this->pattern['digitSize'] = $value; | |
| 384 | + } | |
| 385 | + | |
| 386 | + /** | |
| 387 | + * Gets the string to use as the decimal separator. | |
| 388 | + * @return string decimal separator. | |
| 389 | + */ | |
| 390 | + function getDecimalSeparator() | |
| 391 | +	{ | |
| 392 | + return $this->data['NumberElements'][0]; | |
| 393 | + } | |
| 394 | + | |
| 395 | + /** | |
| 396 | + * Set the string to use as the decimal separator. | |
| 397 | + * @param string the decimal point | |
| 398 | + */ | |
| 399 | + function setDecimalSeparator($value) | |
| 400 | +	{ | |
| 401 | + return $this->data['NumberElements'][0] = $value; | |
| 402 | + } | |
| 403 | + | |
| 404 | + /** | |
| 405 | + * Gets the string that separates groups of digits to the left | |
| 406 | + * of the decimal in currency values. | |
| 407 | + * @param parameter | |
| 408 | + * @return string currency group separator. | |
| 409 | + */ | |
| 410 | + function getGroupSeparator() | |
| 411 | +	{ | |
| 412 | + return $this->data['NumberElements'][1]; | |
| 413 | + } | |
| 414 | + | |
| 415 | + /** | |
| 416 | + * Set the string to use as the group separator. | |
| 417 | + * @param string the group separator. | |
| 418 | + */ | |
| 419 | + function setGroupSeparator($value) | |
| 420 | +	{ | |
| 421 | + return $this->data['NumberElements'][1] = $value; | |
| 422 | + } | |
| 423 | + | |
| 424 | + /** | |
| 425 | + * Gets the number of digits in each group to the left of the decimal | |
| 426 | + * There can be two grouping sizes, this fucntion | |
| 427 | + * returns <b>array(group1, group2)</b>, if there is only 1 grouping size, | |
| 428 | + * group2 will be false. | |
| 429 | + * @return array grouping size(s). | |
| 430 | + */ | |
| 431 | + function getGroupSizes() | |
| 432 | +	{ | |
| 433 | + $group1 = $this->pattern['groupSize1']; | |
| 434 | + $group2 = $this->pattern['groupSize2']; | |
| 435 | + | |
| 436 | + return array($group1, $group2); | |
| 437 | + } | |
| 438 | + | |
| 439 | + /** | |
| 440 | + * Set the number of digits in each group to the left of the decimal. | |
| 441 | + * There can be two grouping sizes, the value should | |
| 442 | + * be an <b>array(group1, group2)</b>, if there is only 1 grouping size, | |
| 443 | + * group2 should be false. | |
| 444 | + * @param array grouping size(s). | |
| 445 | + */ | |
| 446 | + function setGroupSizes($groupSize) | |
| 447 | +	{ | |
| 448 | 448 | $this->pattern['groupSize1'] = $groupSize[0]; | 
| 449 | 449 | $this->pattern['groupSize2'] = $groupSize[1]; | 
| 450 | - } | |
| 451 | - | |
| 452 | - /** | |
| 453 | - * Gets the format pattern for negative values. | |
| 454 | - * The negative pattern is composed of a prefix, and postfix. | |
| 455 | - * This function returns <b>array(prefix, postfix)</b>. | |
| 456 | - * @return arary negative pattern. | |
| 457 | - */ | |
| 458 | - function getNegativePattern() | |
| 459 | -    { | |
| 460 | - $prefix = $this->pattern['negPref']; | |
| 461 | - $postfix = $this->pattern['negPost']; | |
| 462 | - return array($prefix, $postfix); | |
| 463 | - } | |
| 464 | - | |
| 465 | - /** | |
| 466 | - * Set the format pattern for negative values. | |
| 467 | - * The negative pattern is composed of a prefix, and postfix in the form | |
| 468 | - * <b>array(prefix, postfix)</b>. | |
| 469 | - * @param arary negative pattern. | |
| 470 | - */ | |
| 471 | - function setNegativePattern($pattern) | |
| 472 | -    { | |
| 473 | - $this->pattern['negPref'] = $pattern[0]; | |
| 474 | - $this->pattern['negPost'] = $pattern[1]; | |
| 475 | - } | |
| 476 | - | |
| 477 | - /** | |
| 478 | - * Gets the format pattern for positive values. | |
| 479 | - * The positive pattern is composed of a prefix, and postfix. | |
| 480 | - * This function returns <b>array(prefix, postfix)</b>. | |
| 481 | - * @return arary positive pattern. | |
| 482 | - */ | |
| 483 | - function getPositivePattern() | |
| 484 | -    { | |
| 485 | - $prefix = $this->pattern['posPref']; | |
| 486 | - $postfix = $this->pattern['posPost']; | |
| 487 | - return array($prefix, $postfix); | |
| 488 | - } | |
| 489 | - | |
| 490 | - /** | |
| 491 | - * Set the format pattern for positive values. | |
| 492 | - * The positive pattern is composed of a prefix, and postfix in the form | |
| 493 | - * <b>array(prefix, postfix)</b>. | |
| 494 | - * @param arary positive pattern. | |
| 495 | - */ | |
| 496 | - function setPositivePattern($pattern) | |
| 497 | -    { | |
| 498 | - $this->pattern['posPref'] = $pattern[0]; | |
| 499 | - $this->pattern['posPost'] = $pattern[1]; | |
| 500 | - } | |
| 501 | - | |
| 502 | - /** | |
| 503 | - * Gets the string to use as the currency symbol. | |
| 504 | - * @return string currency symbol. | |
| 505 | - */ | |
| 506 | - function getCurrencySymbol($currency='USD') | |
| 507 | -    { | |
| 508 | - if(isset($this->pattern['symbol'])) | |
| 450 | + } | |
| 451 | + | |
| 452 | + /** | |
| 453 | + * Gets the format pattern for negative values. | |
| 454 | + * The negative pattern is composed of a prefix, and postfix. | |
| 455 | + * This function returns <b>array(prefix, postfix)</b>. | |
| 456 | + * @return arary negative pattern. | |
| 457 | + */ | |
| 458 | + function getNegativePattern() | |
| 459 | +	{ | |
| 460 | + $prefix = $this->pattern['negPref']; | |
| 461 | + $postfix = $this->pattern['negPost']; | |
| 462 | + return array($prefix, $postfix); | |
| 463 | + } | |
| 464 | + | |
| 465 | + /** | |
| 466 | + * Set the format pattern for negative values. | |
| 467 | + * The negative pattern is composed of a prefix, and postfix in the form | |
| 468 | + * <b>array(prefix, postfix)</b>. | |
| 469 | + * @param arary negative pattern. | |
| 470 | + */ | |
| 471 | + function setNegativePattern($pattern) | |
| 472 | +	{ | |
| 473 | + $this->pattern['negPref'] = $pattern[0]; | |
| 474 | + $this->pattern['negPost'] = $pattern[1]; | |
| 475 | + } | |
| 476 | + | |
| 477 | + /** | |
| 478 | + * Gets the format pattern for positive values. | |
| 479 | + * The positive pattern is composed of a prefix, and postfix. | |
| 480 | + * This function returns <b>array(prefix, postfix)</b>. | |
| 481 | + * @return arary positive pattern. | |
| 482 | + */ | |
| 483 | + function getPositivePattern() | |
| 484 | +	{ | |
| 485 | + $prefix = $this->pattern['posPref']; | |
| 486 | + $postfix = $this->pattern['posPost']; | |
| 487 | + return array($prefix, $postfix); | |
| 488 | + } | |
| 489 | + | |
| 490 | + /** | |
| 491 | + * Set the format pattern for positive values. | |
| 492 | + * The positive pattern is composed of a prefix, and postfix in the form | |
| 493 | + * <b>array(prefix, postfix)</b>. | |
| 494 | + * @param arary positive pattern. | |
| 495 | + */ | |
| 496 | + function setPositivePattern($pattern) | |
| 497 | +	{ | |
| 498 | + $this->pattern['posPref'] = $pattern[0]; | |
| 499 | + $this->pattern['posPost'] = $pattern[1]; | |
| 500 | + } | |
| 501 | + | |
| 502 | + /** | |
| 503 | + * Gets the string to use as the currency symbol. | |
| 504 | + * @return string currency symbol. | |
| 505 | + */ | |
| 506 | + function getCurrencySymbol($currency='USD') | |
| 507 | +	{ | |
| 508 | + if(isset($this->pattern['symbol'])) | |
| 509 | 509 | return $this->pattern['symbol']; | 
| 510 | - else | |
| 511 | - return $this->data['Currencies'][$currency][0]; | |
| 512 | - } | |
| 513 | - | |
| 514 | - | |
| 515 | - /** | |
| 516 | - * Set the string to use as the currency symbol. | |
| 517 | - * @param string currency symbol. | |
| 518 | - */ | |
| 519 | - function setCurrencySymbol($symbol) | |
| 520 | -    { | |
| 521 | - $this->pattern['symbol'] = $symbol; | |
| 522 | - } | |
| 523 | - | |
| 524 | - /** | |
| 525 | - * Gets the string that represents negative infinity. | |
| 526 | - * @return string negative infinity. | |
| 527 | - */ | |
| 528 | - function getNegativeInfinitySymbol() | |
| 529 | -    { | |
| 510 | + else | |
| 511 | + return $this->data['Currencies'][$currency][0]; | |
| 512 | + } | |
| 513 | + | |
| 514 | + | |
| 515 | + /** | |
| 516 | + * Set the string to use as the currency symbol. | |
| 517 | + * @param string currency symbol. | |
| 518 | + */ | |
| 519 | + function setCurrencySymbol($symbol) | |
| 520 | +	{ | |
| 521 | + $this->pattern['symbol'] = $symbol; | |
| 522 | + } | |
| 523 | + | |
| 524 | + /** | |
| 525 | + * Gets the string that represents negative infinity. | |
| 526 | + * @return string negative infinity. | |
| 527 | + */ | |
| 528 | + function getNegativeInfinitySymbol() | |
| 529 | +	{ | |
| 530 | 530 | return $this->pattern['negInfty']; | 
| 531 | - } | |
| 532 | - | |
| 533 | - /** | |
| 534 | - * Set the string that represents negative infinity. | |
| 535 | - * @param string negative infinity. | |
| 536 | - */ | |
| 537 | - function setNegativeInfinitySymbol($value) | |
| 538 | -    { | |
| 531 | + } | |
| 532 | + | |
| 533 | + /** | |
| 534 | + * Set the string that represents negative infinity. | |
| 535 | + * @param string negative infinity. | |
| 536 | + */ | |
| 537 | + function setNegativeInfinitySymbol($value) | |
| 538 | +	{ | |
| 539 | 539 | $this->pattern['negInfty'] = $value; | 
| 540 | - } | |
| 541 | - | |
| 542 | - /** | |
| 543 | - * Gets the string that represents positive infinity. | |
| 544 | - * @return string positive infinity. | |
| 545 | - */ | |
| 546 | - function getPositiveInfinitySymbol() | |
| 547 | -    { | |
| 540 | + } | |
| 541 | + | |
| 542 | + /** | |
| 543 | + * Gets the string that represents positive infinity. | |
| 544 | + * @return string positive infinity. | |
| 545 | + */ | |
| 546 | + function getPositiveInfinitySymbol() | |
| 547 | +	{ | |
| 548 | 548 | return $this->pattern['posInfty']; | 
| 549 | - } | |
| 550 | - | |
| 551 | - /** | |
| 552 | - * Set the string that represents positive infinity. | |
| 553 | - * @param string positive infinity. | |
| 554 | - */ | |
| 555 | - function setPositiveInfinitySymbol($value) | |
| 556 | -    { | |
| 549 | + } | |
| 550 | + | |
| 551 | + /** | |
| 552 | + * Set the string that represents positive infinity. | |
| 553 | + * @param string positive infinity. | |
| 554 | + */ | |
| 555 | + function setPositiveInfinitySymbol($value) | |
| 556 | +	{ | |
| 557 | 557 | $this->pattern['posInfty'] = $value; | 
| 558 | - } | |
| 559 | - | |
| 560 | - /** | |
| 561 | - * Gets the string that denotes that the associated number is negative. | |
| 562 | - * @return string negative sign. | |
| 563 | - */ | |
| 564 | - function getNegativeSign() | |
| 565 | -    { | |
| 566 | - return $this->data['NumberElements'][6]; | |
| 567 | - } | |
| 568 | - | |
| 569 | - /** | |
| 570 | - * Set the string that denotes that the associated number is negative. | |
| 571 | - * @param string negative sign. | |
| 572 | - */ | |
| 573 | - function setNegativeSign($value) | |
| 574 | -    { | |
| 575 | - $this->data['NumberElements'][6] = $value; | |
| 576 | - } | |
| 577 | - | |
| 578 | - /** | |
| 579 | - * Gets the string that denotes that the associated number is positive. | |
| 580 | - * @return string positive sign. | |
| 581 | - */ | |
| 582 | - function getPositiveSign() | |
| 583 | -    { | |
| 584 | - return $this->data['NumberElements'][11]; | |
| 585 | - } | |
| 586 | - | |
| 587 | - /** | |
| 588 | - * Set the string that denotes that the associated number is positive. | |
| 589 | - * @param string positive sign. | |
| 590 | - */ | |
| 591 | - function setPositiveSign($value) | |
| 592 | -    { | |
| 593 | - $this->data['NumberElements'][11] = $value; | |
| 594 | - } | |
| 595 | - | |
| 596 | - /** | |
| 597 | - * Gets the string that represents the IEEE NaN (not a number) value. | |
| 598 | - * @return string NaN symbol. | |
| 599 | - */ | |
| 600 | - function getNaNSymbol() | |
| 601 | -    { | |
| 602 | - return $this->data['NumberElements'][10]; | |
| 603 | - } | |
| 604 | - | |
| 605 | - /** | |
| 606 | - * Set the string that represents the IEEE NaN (not a number) value. | |
| 607 | - * @param string NaN symbol. | |
| 608 | - */ | |
| 609 | - function setNaNSymbol($value) | |
| 610 | -    { | |
| 611 | - $this->data['NumberElements'][10] = $value; | |
| 612 | - } | |
| 613 | - | |
| 614 | - /** | |
| 615 | - * Gets the string to use as the percent symbol. | |
| 616 | - * @return string percent symbol. | |
| 617 | - */ | |
| 618 | - function getPercentSymbol() | |
| 619 | -    { | |
| 620 | - return $this->data['NumberElements'][3]; | |
| 621 | - } | |
| 622 | - | |
| 623 | - /** | |
| 624 | - * Set the string to use as the percent symbol. | |
| 625 | - * @param string percent symbol. | |
| 626 | - */ | |
| 627 | - function setPercentSymbol($value) | |
| 628 | -    { | |
| 629 | - $this->data['NumberElements'][3] = $value; | |
| 630 | - } | |
| 631 | - | |
| 632 | - /** | |
| 633 | - * Gets the string to use as the per mille symbol. | |
| 634 | - * @return string percent symbol. | |
| 635 | - */ | |
| 636 | - function getPerMilleSymbol() | |
| 637 | -    { | |
| 638 | - return $this->data['NumberElements'][8]; | |
| 639 | - } | |
| 640 | - | |
| 641 | - /** | |
| 642 | - * Set the string to use as the per mille symbol. | |
| 643 | - * @param string percent symbol. | |
| 644 | - */ | |
| 645 | - function setPerMilleSymbol($value) | |
| 646 | -    { | |
| 647 | - $this->data['NumberElements'][8] = $value; | |
| 648 | - } | |
| 558 | + } | |
| 559 | + | |
| 560 | + /** | |
| 561 | + * Gets the string that denotes that the associated number is negative. | |
| 562 | + * @return string negative sign. | |
| 563 | + */ | |
| 564 | + function getNegativeSign() | |
| 565 | +	{ | |
| 566 | + return $this->data['NumberElements'][6]; | |
| 567 | + } | |
| 568 | + | |
| 569 | + /** | |
| 570 | + * Set the string that denotes that the associated number is negative. | |
| 571 | + * @param string negative sign. | |
| 572 | + */ | |
| 573 | + function setNegativeSign($value) | |
| 574 | +	{ | |
| 575 | + $this->data['NumberElements'][6] = $value; | |
| 576 | + } | |
| 577 | + | |
| 578 | + /** | |
| 579 | + * Gets the string that denotes that the associated number is positive. | |
| 580 | + * @return string positive sign. | |
| 581 | + */ | |
| 582 | + function getPositiveSign() | |
| 583 | +	{ | |
| 584 | + return $this->data['NumberElements'][11]; | |
| 585 | + } | |
| 586 | + | |
| 587 | + /** | |
| 588 | + * Set the string that denotes that the associated number is positive. | |
| 589 | + * @param string positive sign. | |
| 590 | + */ | |
| 591 | + function setPositiveSign($value) | |
| 592 | +	{ | |
| 593 | + $this->data['NumberElements'][11] = $value; | |
| 594 | + } | |
| 595 | + | |
| 596 | + /** | |
| 597 | + * Gets the string that represents the IEEE NaN (not a number) value. | |
| 598 | + * @return string NaN symbol. | |
| 599 | + */ | |
| 600 | + function getNaNSymbol() | |
| 601 | +	{ | |
| 602 | + return $this->data['NumberElements'][10]; | |
| 603 | + } | |
| 604 | + | |
| 605 | + /** | |
| 606 | + * Set the string that represents the IEEE NaN (not a number) value. | |
| 607 | + * @param string NaN symbol. | |
| 608 | + */ | |
| 609 | + function setNaNSymbol($value) | |
| 610 | +	{ | |
| 611 | + $this->data['NumberElements'][10] = $value; | |
| 612 | + } | |
| 613 | + | |
| 614 | + /** | |
| 615 | + * Gets the string to use as the percent symbol. | |
| 616 | + * @return string percent symbol. | |
| 617 | + */ | |
| 618 | + function getPercentSymbol() | |
| 619 | +	{ | |
| 620 | + return $this->data['NumberElements'][3]; | |
| 621 | + } | |
| 622 | + | |
| 623 | + /** | |
| 624 | + * Set the string to use as the percent symbol. | |
| 625 | + * @param string percent symbol. | |
| 626 | + */ | |
| 627 | + function setPercentSymbol($value) | |
| 628 | +	{ | |
| 629 | + $this->data['NumberElements'][3] = $value; | |
| 630 | + } | |
| 631 | + | |
| 632 | + /** | |
| 633 | + * Gets the string to use as the per mille symbol. | |
| 634 | + * @return string percent symbol. | |
| 635 | + */ | |
| 636 | + function getPerMilleSymbol() | |
| 637 | +	{ | |
| 638 | + return $this->data['NumberElements'][8]; | |
| 639 | + } | |
| 640 | + | |
| 641 | + /** | |
| 642 | + * Set the string to use as the per mille symbol. | |
| 643 | + * @param string percent symbol. | |
| 644 | + */ | |
| 645 | + function setPerMilleSymbol($value) | |
| 646 | +	{ | |
| 647 | + $this->data['NumberElements'][8] = $value; | |
| 648 | + } | |
| 649 | 649 | } | 
| 650 | 650 | |
| @@ -290,7 +290,7 @@ | ||
| 290 | 290 | |
| 291 | 291 | //find the body element | 
| 292 | 292 | $xpath = new DomXPath($dom); | 
| 293 | -    	$body = $xpath->query('//body')->item(0); | |
| 293 | +		$body = $xpath->query('//body')->item(0); | |
| 294 | 294 | |
| 295 | 295 |  		$lastNodes = $xpath->query('//trans-unit[last()]'); | 
| 296 | 296 |  		if(($last=$lastNodes->item(0))!==null) { | 
| @@ -19,7 +19,6 @@ | ||
| 19 | 19 | namespace Prado\I18N\core; | 
| 20 | 20 | |
| 21 | 21 | use DOMDocument; | 
| 22 | -use DOMXPath; | |
| 23 | 22 | use Prado\Exceptions\TException; | 
| 24 | 23 | use Prado\Exceptions\TIOException; | 
| 25 | 24 | |
| @@ -58,7 +58,7 @@ discard block | ||
| 58 | 58 | $this->languages = array(); | 
| 59 | 59 | |
| 60 | 60 | if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) | 
| 61 | - return $this->languages; | |
| 61 | + return $this->languages; | |
| 62 | 62 | |
| 63 | 63 | //$basedir = CultureInfo::dataDir(); | 
| 64 | 64 | //$ext = CultureInfo::fileExt(); | 
| @@ -66,18 +66,18 @@ discard block | ||
| 66 | 66 | |
| 67 | 67 |  		foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $lang) | 
| 68 | 68 |  		{ | 
| 69 | - // Cut off any q-value that might come after a semi-colon | |
| 70 | - if ($pos = strpos($lang, ';')) | |
| 71 | - $lang = trim(substr($lang, 0, $pos)); | |
| 69 | + // Cut off any q-value that might come after a semi-colon | |
| 70 | + if ($pos = strpos($lang, ';')) | |
| 71 | + $lang = trim(substr($lang, 0, $pos)); | |
| 72 | 72 | |
| 73 | 73 | if (strstr($lang, '-')) | 
| 74 | 74 |  			{ | 
| 75 | 75 |  				$codes = explode('-',$lang); | 
| 76 | 76 | if($codes[0] == 'i') | 
| 77 | 77 |  				{ | 
| 78 | - // Language not listed in ISO 639 that are not variants | |
| 79 | - // of any listed language, which can be registerd with the | |
| 80 | - // i-prefix, such as i-cherokee | |
| 78 | + // Language not listed in ISO 639 that are not variants | |
| 79 | + // of any listed language, which can be registerd with the | |
| 80 | + // i-prefix, such as i-cherokee | |
| 81 | 81 | if(count($codes)>1) | 
| 82 | 82 | $lang = $codes[1]; | 
| 83 | 83 | } | 
| @@ -91,13 +91,13 @@ discard block | ||
| 91 | 91 | $lang .= '_'.strtoupper($codes[$i]); | 
| 92 | 92 | } | 
| 93 | 93 | } | 
| 94 | - } | |
| 94 | + } | |
| 95 | 95 | |
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 | if($info->validCulture($lang)) | 
| 99 | 99 | $this->languages[] = $lang; | 
| 100 | - } | |
| 100 | + } | |
| 101 | 101 | |
| 102 | 102 | return $this->languages; | 
| 103 | 103 | } | 
| @@ -108,20 +108,20 @@ discard block | ||
| 108 | 108 | */ | 
| 109 | 109 | function getCharsets() | 
| 110 | 110 |  	{ | 
| 111 | -        if($this->charsets !== null) { | |
| 111 | +		if($this->charsets !== null) { | |
| 112 | 112 | return $this->charsets; | 
| 113 | 113 | } | 
| 114 | 114 | |
| 115 | 115 | $this->charsets = array(); | 
| 116 | 116 | |
| 117 | 117 | if (!isset($_SERVER['HTTP_ACCEPT_CHARSET'])) | 
| 118 | - return $this->charsets; | |
| 118 | + return $this->charsets; | |
| 119 | 119 | |
| 120 | 120 |  		foreach (explode(',', $_SERVER['HTTP_ACCEPT_CHARSET']) as $charset) | 
| 121 | 121 |  		{ | 
| 122 | - if (!empty($charset)) | |
| 123 | -                $this->charsets[] = preg_replace('/;.*/', '', $charset); | |
| 124 | - } | |
| 122 | + if (!empty($charset)) | |
| 123 | +				$this->charsets[] = preg_replace('/;.*/', '', $charset); | |
| 124 | + } | |
| 125 | 125 | |
| 126 | 126 | return $this->charsets; | 
| 127 | 127 | } | 
| @@ -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(); | 
| @@ -58,229 +58,229 @@ | ||
| 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 | } |