<?php
 class AdvancedCatalogModuleItemVO implements MotoDomObjectInterface { public $id; public $order; public $enabled; public $itemType; public $parent; public $properties; public function __construct(DOMNode $parent = null, $loadType = true) { if (!empty($parent)) { $this->loadDomElement($parent, $loadType); } } public function loadDomElement(DOMNode $parent, $loadType = true) { $this->id = (integer) $parent->getAttribute('id'); $this->order = (integer) $parent->getAttribute('order'); if ($loadType === true) $this->itemType = AdvancedCatalogModuleItemTypeVO::findById($parent->getAttribute('itemType'), AdvancedCatalogModuleService::$dom); else $this->itemType = null; $this->parent = (integer) $parent->getAttribute('parent'); $this->enabled = (boolean) MotoUtil::toBoolean($parent->getAttribute('enabled')); $this->properties = PropertyVO::findAll($parent); return $this; } public function saveDomElement(DOMNode $parent) { $parent->setAttribute('id', (integer) $this->id); $parent->setAttribute('order', (integer) $this->order); $parent->setAttribute('parent', (integer) $this->parent); $parent->setAttribute('itemType', (integer) $this->itemType->id); $parent->setAttribute('enabled', (string) MotoUtil::boolToString($this->enabled)); $propertiesNode = $parent->appendChild(new DOMElement('properties')); foreach ($this->properties as $property) { $property->saveDomElement($propertiesNode->appendChild(new DOMElement('item'))); } return $parent; } public function remove() { if (!is_null($this->_node)) { $this->_node->parentNode->removeChild($this->_node); $this->_node = null; } return true; } public static function findById($id, DOMNode $context) { return MotoXML::findOneByXPath(".//data/item[@id='{$id}']", $context, get_class()); } public static function findAll(DOMNode $context) { return MotoXML::findByXPath(".//data/item", $context, get_class()); } } ?>