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

Source for file LMetaDataContainer.php

Documentation is available at LMetaDataContainer.php

  1. <?php
  2.  
  3.  
  4. /**
  5.  * class file.
  6.  *
  7.  * @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
  8.  * @copyright 2005, diemeisterei GmbH. All rights reserved.
  9.  * @author $Author: schmunk $
  10.  * @version $Revision: 601 $  $Date: 2007-02-24 23:49:30 +0100 (Sa, 24 Feb 2007) $
  11.  * @package Phundament.Packages
  12.  * @subpackage LMetaData
  13.  */
  14.  
  15. /**
  16.  * Wrapper for displaying IMetaData components
  17.  *
  18.  * @package System.Web.UI.WebControls
  19.  * @subpackage MetaData
  20.  */
  21. {
  22.     /**
  23.      * creates controls, if defined in config
  24.      */
  25.     function onInit($param)
  26.     {
  27.         #Prado::log("OnInit() LMetaDataContainer", 1,"Lithron.LMetaData");
  28.         $this->autogenerateControls();
  29.  
  30.         $this->setEnableViewState(false)// otherwise problems in Postback
  31.  
  32.         parent :: onInit($param);
  33.     }
  34.  
  35.     /**
  36.      * creates controls, if defined in config
  37.      */
  38.     function onLoad($param)
  39.     {
  40.         #Prado::log("OnLoad() LMetaDataContainer", 1,"Lithron.LMetaData");
  41.         #$this->autogenerateControls();
  42.         parent :: onLoad($param);
  43.     }
  44.  
  45.     /**
  46.      * fills the controls with data
  47.      */
  48.     function onPreRender($param)
  49.     {
  50.         #Prado::log("OnPreRender() LMetaDataContainer", 1,"Lithron.LMetaData");
  51.         parent :: onPreRender($param);
  52.         $this->applyData();
  53.     }
  54.  
  55.  
  56.     private function autogenerateControls()
  57.     {
  58.         $meta_data$this->Application->getModule("meta_data");
  59.         $config$meta_data->getConfiguration();
  60.         $key$this->getMetaId(":Container";
  61.  
  62.         if (isset ($config[$key]))
  63.         {
  64.             $controls$config[$key];
  65.             // only if not defined in template
  66.             if (is_array($controls))
  67.             {
  68.                 #Prado::log("Auto-generating meta data controls for ".$key, TLogger::DEBUG, "Lithron.LMetaData");
  69.                 foreach ($controls AS $c)
  70.                 {
  71.                     $newnew $c['class'];
  72.                     $new->setId($c['id']);
  73.                     $new->setMetaId($c['id']);
  74.                     $this->Controls[]$new;
  75.                 }
  76.             }
  77.         }
  78.     }
  79.  
  80.     private function applyData()
  81.     {
  82.         $_obj$this->getDataObject();
  83.         #var_dump($_obj);
  84.         #Prado::log("Applying data for LMetaDataContainer [".$this->Id."]", 1,"Lithron.LMetaData");
  85.         if (isset ($_obj[self :: DATA_KEY]&& is_array($_obj[self :: DATA_KEY]))
  86.             foreach ($_obj[self :: DATA_KEYAS $id => $data)
  87.             {
  88.                 $control$this->findControlByMetaId($id);
  89.                 if (!$control instanceof TControl)
  90.                     $control$this->findControl($id);
  91.                 if (method_exists($control"setData"))
  92.                 {
  93.                     $control->setData($data);
  94.                     #Prado::log("Setting meta data [{$id}]", 1,"Lithron.LMetaData");
  95.                 }
  96.                 else
  97.                 {
  98.                     Prado::log("Component [{$id}] has no meta data (setter)"1,"Lithron.LMetaData");
  99.                 }
  100.             }
  101.         else
  102.             {#$this->setVisible("false");
  103.             }
  104.  
  105.     }
  106.  
  107.     private function findControlByMetaId($metaId)
  108.     {
  109.         foreach ($this->Controls AS $c)
  110.         {
  111.             $cMetaIdnull;
  112.             try
  113.             {
  114.                 if ($c instanceof LMetaDataContent)
  115.                     $cMetaId$c->getMetaId();
  116.             }
  117.             catch (Exception $e)
  118.             {
  119.  
  120.             }
  121.             if ($cMetaId == $metaId)
  122.             {
  123.                 return $c;
  124.             }
  125.         }
  126.     }
  127. }
  128. ?>

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