<?php
class ModuleDataVO implements MotoDomObjectInterface { public $htmlData; public $options; public function __construct(DOMNode $parent = null) { if (!empty($parent)) { $this->loadDomElement($parent); } } public function loadDomElement(DOMNode $parent) { $node = MotoXML::findOneByXPath("./data", $parent); if (!is_null($node)) $this->htmlData = (string) MotoUtil::trim($node->nodeValue); $this->options = ModuleOptionVO::findAll($parent); return $this; } public function saveDomElement(DOMNode $parent, $xmlPath = '') { $node = MotoXML::findOneByXPath('./data', $parent); $data = new DOMElement('data'); if ($node == null) { $parent->appendChild($data); } else { $parent->replaceChild($data, $node); } $data->appendChild($parent->ownerDocument->createCDATASection($this->htmlData)); if ($xmlPath != '') { $htmlFile = preg_replace('/\.xml$/i', '.html', $xmlPath); if (!empty($htmlFile)) @file_put_contents($htmlFile, $this->htmlData); } $configuration = new DOMElement('configuration'); $node = MotoXML::findOneByXPath('./configuration', $parent); if ($node == null) { $parent->appendChild($configuration); } else { $parent->replaceChild($configuration, $node); } foreach ($this->options as $option) { $nodeOption = new DOMElement('option'); $configuration->appendChild($nodeOption); $option->saveDomElement($nodeOption); } } } ?>