/** * Test that I can load the ATOM page and that it returns valid XML. * The XMLLoader will take care of the validation, since it should be a valid document anyway. */ public function testATOMPage() { // Get the RSS feed and download it to a local file. $rewriteurl = $this->blog->get('rewriteurl'); $this->assertNotEmpty($rewriteurl); // Go to the page and make sure that it loads up! $request = new PageRequest($rewriteurl . '.atom'); $request->execute(); $view = $request->getView(); $this->assertEquals(200, $view->error); $markup = $view->fetch(); $this->assertNotEmpty($markup); // DEVELOPMENT DEBUG //echo $markup; // DEBUG // $xml = new XMLLoader(); $xml->setRootName('feed'); // If it's invalid markup, this load will throw an error, causing phpunit to return an error :) // If the bug is fixed, this will not throw any errors. $xml->loadFromString($markup); $parsedmarkup = $xml->asMinifiedXML(); $this->assertNotEmpty($parsedmarkup); }
/** * Get the raw XML of this theme, useful for debugging. * * @return string (XML) */ public function getRawXML($minified = false) { return $minified ? $this->_xmlloader->asMinifiedXML() : $this->_xmlloader->asPrettyXML(); }
/** * 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()); } }