[ Index ]
 

Code source de PRADO 3.0.6

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

title

Body

[fermer]

/framework/Web/UI/WebControls/ -> TLiteralColumn.php (source)

   1  <?php
   2  /**
   3   * TLiteralColumn class file
   4   *
   5   * @author Qiang Xue <qiang.xue@gmail.com>
   6   * @link http://www.pradosoft.com/
   7   * @copyright Copyright &copy; 2005 PradoSoft
   8   * @license http://www.pradosoft.com/license/
   9   * @version $Id: TLiteralColumn.php 1397 2006-09-07 07:55:53Z wei $
  10   * @package System.Web.UI.WebControls
  11   */
  12  
  13  /**
  14   * TDataGridColumn class file
  15   */
  16  Prado::using('System.Web.UI.WebControls.TDataGridColumn');
  17  
  18  /**
  19   * TLiteralColumn class
  20   *
  21   * TLiteralColumn represents a static text column that is bound to a field in a data source.
  22   * The cells in the column will be displayed with static texts using the data indexed by
  23   * {@link setDataField DataField}. You can customize the display by
  24   * setting {@link setDataFormatString DataFormatString}.
  25   *
  26   * If {@link setDataField DataField} is not specified, the cells will be filled
  27   * with {@link setText Text}.
  28   *
  29   * If {@link setEncode Encode} is true, the static texts will be HTML-encoded.
  30   *
  31   * @author Qiang Xue <qiang.xue@gmail.com>
  32   * @version $Id: TLiteralColumn.php 1397 2006-09-07 07:55:53Z wei $
  33   * @package System.Web.UI.WebControls
  34   * @since 3.0.5
  35   */
  36  class TLiteralColumn extends TDataGridColumn
  37  {
  38      /**
  39       * @return string the field name from the data source to bind to the column
  40       */
  41  	public function getDataField()
  42      {
  43          return $this->getViewState('DataField','');
  44      }
  45  
  46      /**
  47       * @param string the field name from the data source to bind to the column
  48       */
  49  	public function setDataField($value)
  50      {
  51          $this->setViewState('DataField',$value,'');
  52      }
  53  
  54      /**
  55       * @return string the formatting string used to control how the bound data will be displayed.
  56       */
  57  	public function getDataFormatString()
  58      {
  59          return $this->getViewState('DataFormatString','');
  60      }
  61  
  62      /**
  63       * @param string the formatting string used to control how the bound data will be displayed.
  64       */
  65  	public function setDataFormatString($value)
  66      {
  67          $this->setViewState('DataFormatString',$value,'');
  68      }
  69  
  70      /**
  71       * @return string static text to be displayed in the column. Defaults to empty.
  72       */
  73  	public function getText()
  74      {
  75          return $this->getViewState('Text','');
  76      }
  77  
  78      /**
  79       * @param string static text to be displayed in the column.
  80       */
  81  	public function setText($value)
  82      {
  83          $this->setViewState('Text',$value,'');
  84      }
  85  
  86      /**
  87       * @return boolean whether the rendered text should be HTML-encoded. Defaults to false.
  88       */
  89  	public function getEncode()
  90      {
  91          return $this->getViewState('Encode',false);
  92      }
  93  
  94      /**
  95       * @param boolean  whether the rendered text should be HTML-encoded.
  96       */
  97  	public function setEncode($value)
  98      {
  99          $this->setViewState('Encode',TPropertyValue::ensureBoolean($value),false);
 100      }
 101  
 102      /**
 103       * Initializes the specified cell to its initial values.
 104       * This method overrides the parent implementation.
 105       * @param TTableCell the cell to be initialized.
 106       * @param integer the index to the Columns property that the cell resides in.
 107       * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem)
 108       */
 109  	public function initializeCell($cell,$columnIndex,$itemType)
 110      {
 111          parent::initializeCell($cell,$columnIndex,$itemType);
 112          if($itemType===TListItemType::Item || $itemType===TListItemType::AlternatingItem || $itemType===TListItemType::EditItem || $itemType===TListItemType::SelectedItem)
 113          {
 114              if($this->getDataField()!=='')
 115                  $cell->attachEventHandler('OnDataBinding',array($this,'dataBindColumn'));
 116              else
 117              {
 118                  if(($dataField=$this->getDataField())!=='')
 119                      $control->attachEventHandler('OnDataBinding',array($this,'dataBindColumn'));
 120                  else
 121                  {
 122                      $text=$this->getText();
 123                      if($this->getEncode())
 124                          $text=THttpUtility::htmlEncode($text);
 125                      $cell->setText($text);
 126                  }
 127              }
 128          }
 129      }
 130  
 131      /**
 132       * Databinds a cell in the column.
 133       * This method is invoked when datagrid performs databinding.
 134       * It populates the content of the cell with the relevant data from data source.
 135       */
 136  	public function dataBindColumn($sender,$param)
 137      {
 138          $item=$sender->getNamingContainer();
 139          $data=$item->getDataItem();
 140          $formatString=$this->getDataFormatString();
 141          if(($field=$this->getDataField())!=='')
 142              $value=$this->formatDataValue($formatString,$this->getDataFieldValue($data,$field));
 143          else
 144              $value=$this->formatDataValue($formatString,$data);
 145          if($sender instanceof TTableCell)
 146          {
 147              if($this->getEncode())
 148                  $value=THttpUtility::htmlEncode($value);
 149              $sender->setText($value);
 150          }
 151      }
 152  }
 153  
 154  ?>


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