From aa46c9ab78abdd23c273c5e49b402a87a2aefcdb Mon Sep 17 00:00:00 2001 From: xue <> Date: Wed, 8 Feb 2006 23:18:20 +0000 Subject: Changed accessibility of a few render-related methods (needed by adapters). --- framework/I18N/TDateFormat.php | 74 +++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'framework/I18N/TDateFormat.php') diff --git a/framework/I18N/TDateFormat.php b/framework/I18N/TDateFormat.php index 985f5115..711dd563 100644 --- a/framework/I18N/TDateFormat.php +++ b/framework/I18N/TDateFormat.php @@ -2,11 +2,11 @@ /** * TDateFromat formatting component. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the BSD License. * - * Copyright(c) 2004 by Xiang Wei Zhuo. + * Copyright(c) 2004 by Xiang Wei Zhuo. * * To contact the author write to {@link mailto:qiang.xue@gmail.com Qiang Xue} * The latest version of PRADO can be obtained from: @@ -16,20 +16,20 @@ * @version $Revision: 1.11 $ $Date: 2005/12/16 04:33:02 $ * @package System.I18N */ - + /** * Get the DateFormat class. */ Prado::using('System.I18N.core.DateFormat'); /** - * To format dates and/or time according to the current locale use + * To format dates and/or time according to the current locale use * * - * - * The date will be formatted according to the current locale (or culture) + * + * The date will be formatted according to the current locale (or culture) * using the format specified by 'Pattern' attribute. - * + * * To format date and/or time for a locale (e.g. de_DE) include a Culture * attribute, for example: * @@ -37,15 +37,15 @@ Prado::using('System.I18N.core.DateFormat'); * * The date will be formatted according to this format. * - * If no Pattern was specified then the date will be formatted with the + * If no Pattern was specified then the date will be formatted with the * default format (both date and time). If no value for the date is specified - * then the current date will be used. E.g.: + * then the current date will be used. E.g.: * will result in the current date, formatted with default localized pattern. * * Namespace: System.I18N * * Properties - * - Value, date, + * - Value, date, *
Gets or sets the date to format. The tag content is used as Value * if the Value property is not specified. * - Pattern, string, @@ -54,7 +54,7 @@ Prado::using('System.I18N.core.DateFormat'); * 'long time', 'medium time', and 'short time'. Custom patterns can * specified when the Pattern property does not match the predefined * patterns. - * + * * @author Xiang Wei Zhuo * @version v1.0, last update on Sat Dec 11 15:25:11 EST 2004 * @package System.I18N @@ -63,13 +63,13 @@ class TDateFormat extends TI18NControl { /** * Default DateFormat, set to the application culture. - * @var DateFormat + * @var DateFormat */ protected static $formatter; - + /** * A set of pattern presets and their respective formatting shorthand. - * @var array + * @var array */ protected $patternPresets = array( 'fulldate'=>'P','full'=>'P', @@ -78,7 +78,7 @@ class TDateFormat extends TI18NControl 'shortdate'=>'d','short'=>'d', 'fulltime'=>'Q', 'longtime'=>'T', 'mediumtime'=>'q', 'shorttime'=>'t'); - + /** * Sets the date time formatting pattern. * @param string format pattern. @@ -87,15 +87,15 @@ class TDateFormat extends TI18NControl { $this->setViewState('Pattern',$value,''); } - + /** * Gets the date time format pattern. * @return string format pattern. */ function getPattern() - { + { $string = $this->getViewState('Pattern',''); - + $pattern = null; //try the subpattern of "date time" presets @@ -106,9 +106,9 @@ class TDateFormat extends TI18NControl $datetime[] = $this->getPreset($subpatterns[0]); $datetime[] = $this->getPreset($subpatterns[1]); } - + //we have a good subpattern - if(count($datetime) == 2 + if(count($datetime) == 2 && strlen($datetime[0]) == 1 && strlen($datetime[1]) == 1) { @@ -116,20 +116,20 @@ class TDateFormat extends TI18NControl } else //no subpattern, try the presets $pattern = $this->getPreset($string); - + //no presets found, use the string as the pattern //and let the DateFormat handle it. if(is_null($pattern)) $pattern = $string; - if (!is_array($pattern) && strlen($pattern) == 0) + if (!is_array($pattern) && strlen($pattern) == 0) $pattern = null; return $pattern; } - + /** * For a given string, try and find a preset pattern. * @param string the preset pattern name - * @return string a preset pattern if found, null otherwise. + * @return string a preset pattern if found, null otherwise. */ protected function getPreset($string) { @@ -140,10 +140,10 @@ class TDateFormat extends TI18NControl return $preset; } } - + /** * Get the date-time value for this control. - * @return string date time value. + * @return string date time value. */ function getValue() { @@ -152,7 +152,7 @@ class TDateFormat extends TI18NControl return time(); return $value; } - + /** * Set the date-time value for this control. * @param string the date-time value. @@ -161,42 +161,42 @@ class TDateFormat extends TI18NControl { $this->setViewState('Value',$value,''); } - + /** * Renders the localized version of the date-time value. * If the culture is not specified, the default application * culture will be used. * This method overrides parent's implementation. - */ + */ protected function getFormattedDate() { $app = $this->Application->getGlobalization(); - + //initialized the default class wide formatter if(is_null(self::$formatter)) self::$formatter = new DateFormat($app->getCulture()); - + $culture = $this->getCulture(); //return the specific cultural formatted date time if(strlen($culture) && $app->getCulture() !== $culture) { $formatter = new DateFormat($culture); - return $formatter->format($this->getValue(), - $this->getPattern(), + return $formatter->format($this->getValue(), + $this->getPattern(), $this->getCharset()); } //return the application wide culture formatted date time. - $result = self::$formatter->format($this->getValue(), - $this->getPattern(), + $result = self::$formatter->format($this->getValue(), + $this->getPattern(), $this->getCharset()); return $result; } - protected function render($writer) + public function render($writer) { $writer->write($this->getFormattedDate()); } - + } ?> \ No newline at end of file -- cgit v1.2.3