/** * Save this component metadata back to its XML file. * Useful in packager scripts. */ public function save($minified = false) { // Set the schema version to the newest API version. $this->_xmlloader->setSchema('http://corepl.us/api/2_4/component.dtd'); // Ensure there's a required namespace on the root node. $this->_xmlloader->getRootDOM()->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance"); // Hack // If there is an empty smartydir set, don't let that get saved. if(!$this->getSmartyPluginDirectory()){ $this->_xmlloader->removeElements('//smartyplugins'); } /* /////////////// Handle the hard-set pages, ie: admin ones \\\\\\\\\\\\\ if(!isset($viewclasses)) $viewclasses = array(); foreach($viewclasses as $c){ // Should end in Controller. if(strlen($c) - strpos($c, 'Controller') == 10) $c = substr($c, 0, -10); $data = Dataset::Init()->table('page')->select('*')->where("baseurl = /$c", 'admin=1', 'fuzzy=0')->execute(); //$rs = DB::Execute("SELECT * FROM " . DB_PREFIX . "page WHERE ( `baseurl` = '/$c' OR `baseurl` LIKE '/$c/%' ) AND `fuzzy` = '0' AND `admin` = '1'"); foreach($data as $row){ $node = $this->_xmlloader->getElement('/pages/page[@baseurl="' . $row['baseurl'] . '"]'); $node->setAttribute('admin', $row['admin']); $node->setAttribute('widget', $row['widget']); $node->setAttribute('access', $row['access']); $node->setAttribute('title', $row['title']); } $data = Dataset::Init()->table('page')->select('*')->where("baseurl LIKE /$c/%", 'admin=1', 'fuzzy=0')->execute(); //$rs = DB::Execute("SELECT * FROM " . DB_PREFIX . "page WHERE ( `baseurl` = '/$c' OR `baseurl` LIKE '/$c/%' ) AND `fuzzy` = '0' AND `admin` = '1'"); foreach($data as $row){ $node = $this->_xmlloader->getElement('/pages/page[@baseurl="' . $row['baseurl'] . '"]'); $node->setAttribute('admin', $row['admin']); $node->setAttribute('widget', $row['widget']); $node->setAttribute('access', $row['access']); $node->setAttribute('title', $row['title']); } } */ /* /////////////////////// Handle the config options \\\\\\\\\\\\\\\\\\\\\ $data = Dataset::Init()->table('config')->select('*')->where('key LIKE /' . $this->getName() . '/%')->execute(); //$rs = DB::Execute("SELECT * FROM " . DB_PREFIX . "config WHERE `key` LIKE '/" . $this->getName() . "/%'"); foreach($data as $row){ $node = $this->_xmlloader->getElement('/configs/config[@key="' . $row['key'] . '"]'); $node->setAttribute('type', $row['type']); $node->setAttribute('default', $row['default_value']); $node->setAttribute('description', $row['description']); if($row['options']) $node->setAttribute('options', $row['options']); else $node->removeAttribute('options'); } */ // This needs to be the final step... write the XML doc back to the file. $XMLFilename = $this->_file->getFilename(); //echo $this->asPrettyXML(); // DEBUG // if ($minified) { file_put_contents($XMLFilename, $this->_xmlloader->asMinifiedXML()); } else { file_put_contents($XMLFilename, $this->_xmlloader->asPrettyXML()); } }