<?php
/**
* СодеÑÐ¶Ð¸Ñ ÐºÐ»Ð°ÑÑ Container
*
* @package energine
* @subpackage share
* @author dr.Pavka
* @copyright ColoCall 2006
* @version $Id: Container.class.php,v 1.3 2007/12/17 14:16:14 pavka Exp $
*/
//require_once('core/modules/share/components/Control.class.php');
/**
* ÐÑпадаÑÑее менÑ
*
* @package energine
* @subpackage share
*/
class Container extends Control {
private $controls = array();
/**
* ÐонÑÑÑÑкÑÐ¾Ñ ÐºÐ»Ð°ÑÑа
*
* @return void
*/
public function __construct($id, $action = false, $image = false, $title = false, $tooltip = false) {
parent::__construct();
$this->type = 'container';
$this->setAttribute('id', $id);
if ($action) $this->setAttribute('action', $action);
if ($image) $this->setAttribute('image', $image);
if ($title) $this->setAttribute('title', $title);
if ($tooltip) $this->setAttribute('tooltip', $tooltip);
}
public function loadFromXml(SimpleXMLElement $description) {
parent::loadFromXml($description);
foreach ($description->control as $controlDescription) {
if (!isset($controlDescription['type'])) {
throw new SystemException('ERR_DEV_NO_CONTROL_TYPE', SystemException::ERR_DEVELOPER);
}
$controlClassName = ucfirst((string)$controlDescription['type']);
if (!class_exists($controlClassName, false)) {
throw new SystemException('ERR_DEV_NO_CONTROL_CLASS', SystemException::ERR_DEVELOPER, $controlClassName);
}
$control = new $controlClassName(
isset($controlDescription['id']) ? (string)$controlDescription['id'] : null
);
$this->attachControl($control);
$control->loadFromXml($controlDescription);
}
}
public function build() {
parent::build();
foreach ($this->controls as $control) {
$this->doc->documentElement->appendChild($this->doc->importNode($control->build(), true));
}
return $this->doc->documentElement;
}
public function attachControl(Control $control) {
$control->setIndex(arrayPush($this->controls, $control));
$control->attach($this->getToolbar());
}
}