path = $path; $this->xmldb_structure = NULL; } /** * Determine if the XML file exists */ function fileExists() { if (file_exists($this->path) && is_readable($this->path)) { return true; } return false; } /** * Determine if the XML is writeable */ function fileWriteable() { if (is_writeable(dirname($this->path))) { return true; } return false; } function &getStructure() { return $this->xmldb_structure; } /** * Load and the XMLDB structure from file */ function loadXMLStructure() { if ($this->fileExists()) { /// File exists, so let's process it /// Load everything to a big array $xmlarr = xmlize(file_get_contents($this->path)); /// Convert array to xmldb structure $this->xmldb_structure = $this->arr2XMLDBStructure($xmlarr); /// Analize results if ($this->xmldb_structure->isLoaded()) { $this->loaded = true; return true; } else { return false; } } return true; } /** * This function takes an xmlized array and put it into one XMLDBStructure */ function arr2XMLDBStructure ($xmlarr) { $structure = new XMLDBStructure($this->path); $structure->arr2XMLDBStructure($xmlarr); return $structure; } /** * This function saves the whole XMLDBStructure to its file */ function saveXMLFile() { $result = true; $structure =& $this->getStructure(); $result = file_put_contents($this->path, $structure->xmlOutput()); return $result; } } ?>