Source for file Container.class.php

Documentation is available at Container.class.php

  1. /**
  2.  * Содержит класс Container
  3.  *
  4.  * @package energine
  5.  * @subpackage share
  6.  * @author dr.Pavka
  7.  * @copyright ColoCall 2006
  8.  * @version $Id: fsource_energine_share_modulessharecomponentsContainer.class.php.html,v 1.1 2007/09/17 14:32:36 pavka Exp $
  9.  */
  10.  
  11. require_once('core/modules/share/components/Control.class.php');
  12.  
  13. /**
  14.  * Выпадающее меню
  15.  *
  16.  * @package energine
  17.  * @subpackage share
  18.  */
  19. class Container extends Control {
  20.  
  21.     private $controls = array();
  22.  
  23.     /**
  24.      * Конструктор класса
  25.      *
  26.      * @return void 
  27.      */
  28.     public function __construct($id$action false$image false$title false$tooltip false{
  29.         parent::__construct();
  30.         $this->type = 'container';
  31.         $this->setAttribute('id'$id);
  32.         if ($action)  $this->setAttribute('action',  $action);
  33.         if ($image)   $this->setAttribute('image',   $image);
  34.         if ($title)   $this->setAttribute('title',   $title);
  35.         if ($tooltip$this->setAttribute('tooltip'$tooltip);
  36.     }
  37.  
  38.     public function loadFromXml(SimpleXMLElement $description{
  39.         parent::loadFromXml($description);
  40.  
  41.         foreach ($description->control as $controlDescription{
  42.             if (!isset($controlDescription['type'])) {
  43.                 throw new SystemException('ERR_DEV_NO_CONTROL_TYPE'SystemException::ERR_DEVELOPER);
  44.             }
  45.  
  46.             $controlClassName = ucfirst((string)$controlDescription['type']);
  47.             if (!class_exists($controlClassNamefalse)) {
  48.                 throw new SystemException('ERR_DEV_NO_CONTROL_CLASS'SystemException::ERR_DEVELOPER$controlClassName);
  49.             }
  50.  
  51.             $control new $controlClassName(
  52.                 isset($controlDescription['id']? (string)$controlDescription['id'null
  53.             );
  54.  
  55.             $this->attachControl($control);
  56.             $control->loadFromXml($controlDescription);
  57.         }
  58.     }
  59.  
  60.     public function build({
  61.         parent::build();
  62.  
  63.         foreach ($this->controls as $control{
  64.             $this->doc->documentElement->appendChild($this->doc->importNode($control->build()true));
  65.         }
  66.  
  67.         return $this->doc->documentElement;
  68.     }
  69.  
  70.     public function attachControl(Control $control{
  71.         $control->setIndex(arrayPush($this->controls$control));
  72.         $control->attach($this->getToolbar());
  73.     }
  74. }

Documentation generated on Mon, 17 Sep 2007 13:26:13 +0300 by phpDocumentor 1.4.0a2