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

Source for file LApplicationStateEditor.php

Documentation is available at LApplicationStateEditor.php

  1. <?php
  2.  
  3. /**
  4.  * class file
  5.  * @package Phundament.Components
  6.  * @subpackage WebControls
  7.  */
  8.  
  9. /**
  10. * This component displays the Application State Editor.
  11.  * @package System.Web.UI.WebControls
  12.  * @subpackage Admin
  13.  */
  14. class LApplicationStateEditor extends TTable
  15. {
  16.     private $_valEditorsarray ();
  17.     private $_valChangedarray ();
  18.     private $_keysarray ();
  19.  
  20.     public function onLoad($param)
  21.     {
  22.         //$this->clearChildState();
  23.         $asarray_keys($this->getApplication()->getApplicationStatePersister()->load());
  24.         $this->_keys$as;
  25.         $ncount($as);
  26.  
  27.         for ($i0$i $n$i++)
  28.         {
  29.             $rownew TTableRow();
  30.             $this->Rows[]$row;
  31.             $cellTextnew TTableCell();
  32.             $cellText->Controls[]$as[$i];
  33.             $row->Cells[]$cellText;
  34.             $cellValuenew TTableCell();
  35.  
  36.             $val$this->getApplication()->getGlobalState($as[$i]);
  37.             if (is_bool($val))
  38.             {
  39.                 $class"TCheckBox";
  40.                 $setter"setChecked";
  41.                 $event"OnCheckedChanged";
  42.             }
  43.             else
  44.                 if (is_string($val))
  45.                 {
  46.                     $class"TTextBox";
  47.                     $setter"setText";
  48.                     $event"OnTextChanged";
  49.                 }
  50.                 else
  51.                 {
  52.                     $class"TLabel";
  53.                     $setter"setText";
  54.                     $event"";
  55.                 }
  56.  
  57.             $valueEditnew $class;
  58.             $this->_valEditors[]$valueEdit;
  59.             #$valueEdit->setWidth("24em");
  60.             $valueEdit-> $setter ($val);
  61.  
  62.             if ($event)
  63.             {
  64.                 $ev$valueEdit-> $event;
  65.                 $ev[]array (
  66.                     $this,
  67.                     "changedEvent"
  68.                 );
  69.             }
  70.             $cellValue->Controls[]$valueEdit;
  71.             $row->Cells[]$cellValue;
  72.         }
  73.     }
  74.  
  75.     public function changedEvent($sender$param)
  76.     {
  77.         echo "CHANGE FOR " get_class($sender"<br>";
  78.         foreach ($this->_valEditors as $key => $editor)
  79.             if ($editor === $sender)
  80.             {
  81.                 $this->_valChanged[$key]$sender;
  82.             }
  83.     }
  84.  
  85.     public function applyApplicationState($sender$param)
  86.     {
  87.         echo "APPLY!<br>";
  88.         foreach ($this->_valChanged as $key => $editor)
  89.         {
  90.             switch (get_class($editor))
  91.             {
  92.                 case "TCheckBox" :
  93.                     $value$editor->getChecked();
  94.                     break;
  95.                 case "TTextBox" :
  96.                     $value$editor->getText();
  97.                     break;
  98.                 default :
  99.                     throw new Exception("not implemented!");
  100.  
  101.             }
  102.  
  103.             echo "setting " $this->_keys[$key" to ";
  104.             var_dump($value);
  105.             $this->Application->setGlobalState($this->_keys[$key]$value);
  106.         }
  107.     }
  108. }
  109. ?>

Documentation generated on Sun, 25 Feb 2007 16:09:39 +0100 by phpDocumentor 1.3.1