[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/I18N/ -> TTranslateParameter.php (source)

   1  <?php
   2  /**
   3   * TTranslateParameter component.
   4   *
   5   * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
   6   * @link http://www.pradosoft.com/
   7   * @copyright Copyright &copy; 2005 PradoSoft
   8   * @license http://www.pradosoft.com/license/
   9   * @version $Id: TTranslateParameter.php 1397 2006-09-07 07:55:53Z wei $
  10   * @package System.I18N
  11   */
  12  
  13  /**
  14   * TTranslateParameter component should be used inside the TTranslate component to
  15   * allow parameter substitution.
  16   *
  17   * For example, the strings "{greeting}" and "{name}" will be replace
  18   * with the values of "Hello" and "World", respectively.
  19   * The substitution string must be enclose with "{" and "}".
  20   * The parameters can be further translated by using TTranslate.
  21   * <code>
  22   * <com:TTranslate>
  23   *   {greeting} {name}!
  24   *   <com:TTranslateParameter Key="name">World</com:TTranslateParameter>
  25   *   <com:TTranslateParameter Key="greeting">Hello</com:TTranslateParameter>
  26   * </com:TTranslate>
  27   * </code>
  28   *
  29   * Namespace: System.I18N
  30   *
  31   * Properties
  32   * - <b>Key</b>, string, <b>required</b>.
  33   *   <br>Gets or sets the string in TTranslate to substitute.
  34   * - <b>Trim</b>, boolean,
  35   *   <br>Gets or sets an option to trim the contents of the TParam.
  36   *   Default is to trim the contents.
  37   *
  38   * @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
  39   * @version v3.0, last update on Friday, 6 January 2006
  40   * @package System.I18N
  41   */
  42  class TTranslateParameter extends TControl
  43  {
  44      /**
  45       * The substitution key.
  46       * @var string
  47       */
  48      protected $key;
  49  
  50      /**
  51       * To trim or not to trim the contents.
  52       * @var boolean
  53       */
  54      protected $trim = true;
  55  
  56  
  57      /**
  58       * Get the parameter substitution key.
  59       * @return string substitution key.
  60       */
  61  	public function getKey()
  62      {
  63          if(empty($this->key))
  64              throw new TException('The Key property must be specified.');
  65          return $this->key;
  66      }
  67  
  68      /**
  69       * Set the parameter substitution key.
  70       * @param string substitution key.
  71       */
  72  	public function setKey($value)
  73      {
  74          $this->key = $value;
  75      }
  76  
  77      /**
  78       * Set the option to trim the contents.
  79       * @param boolean trim or not.
  80       */
  81  	public function setTrim($value)
  82      {
  83          $this->trim = TPropertyValue::ensureBoolean($value);
  84      }
  85  
  86      /**
  87       * Trim the content or not.
  88       * @return boolean trim or not.
  89       */
  90  	public function getTrim()
  91      {
  92          return $this->trim;
  93      }
  94  
  95  	public function getValue()
  96      {
  97          return $this->getViewState('Value', '');
  98      }
  99  
 100  	public function setValue($value)
 101      {
 102          $this->setViewState('Value', $value, '');
 103      }
 104  
 105      /**
 106       * @return string parameter contents.
 107       */
 108  	public function getParameter()
 109      {
 110          $value = $this->getValue();
 111          if(strlen($value) > 0)
 112              return $value;
 113          $textWriter = new TTextWriter;
 114          $this->renderControl(new THtmlWriter($textWriter));
 115          return $this->getTrim() ?
 116              trim($textWriter->flush()) : $textWriter->flush();
 117      }
 118  }
 119  
 120  ?>


Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7