Phundament-Components
[ class tree: Phundament-Components ] [ index: Phundament-Components ] [ all elements ]

Source for file LTranslate.php

Documentation is available at LTranslate.php

  1. <?php
  2. /**
  3.  * class file.
  4.  *
  5.  * @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
  6.  * @copyright 2005, diemeisterei GmbH. All rights reserved.
  7.  * @author $Author: schmunk $
  8.  * @version $Revision: 601 $  $Date: 2007-02-24 23:49:30 +0100 (Sat, 24 Feb 2007) $
  9.  * @package Phundament.Components
  10.  * @subpackage I18N
  11.  */
  12.  
  13. /**
  14.  * Extended TTranslate control, with uc_first
  15.  *
  16.  * @package System.I18N
  17.  */
  18. class LTranslate extends TTranslate
  19. {
  20.  
  21.     /**
  22.      * Sets the ucfirst param
  23.      */
  24.     public function setUcfirst($value)
  25.     {
  26.         $this->setViewstate("Ucfirst"TPropertyValue :: ensureBoolean($value));
  27.     }
  28.  
  29.     /**
  30.      * @return Wheter use uc_first with input string, default is false
  31.      */
  32.     public function getUcfirst()
  33.     {
  34.         return $this->getViewstate("Ucfirst"false);
  35.     }
  36.  
  37.     /**
  38.      * Renders the control
  39.      */
  40.     public function render($writer)
  41.     {
  42.         $textWriter=new TTextWriter;
  43.         $htmlWriter=new THtmlWriter($textWriter);
  44.         $subs array();
  45.         foreach($this->getControls(as $control)
  46.         {
  47.             if($control instanceof TTranslateParameter)
  48.                 $subs['{'.$control->getKey().'}'$control->getParameter();
  49.             elseif($control instanceof TControl)
  50.                 $control->render($htmlWriter);
  51.             elseif(is_string($control))
  52.                 $textWriter->write($control);
  53.         }
  54.  
  55.         $text $this->getText();
  56.         if(strlen($text)==0)
  57.             $text $textWriter->flush();
  58.         if($this->getTrim())
  59.             $text trim($text);
  60.  
  61.         if ($this->getUcfirst())
  62.         {
  63.             $text ucfirst($this->translateText($text$subs));
  64.         }
  65.         else
  66.         {
  67.             $text $this->translateText($text$subs);
  68.  
  69.         }
  70.         $writer->write($text);
  71.     }
  72. }
  73. ?>

Documentation generated on Sun, 25 Feb 2007 16:11:47 +0100 by phpDocumentor 1.3.1