filename = $filename; $wrapper = FileWrapper::wrapper($this->filename); $this->setContents($wrapper->contents()); } /** * Determine whether the file exists. * @return boolean */ function exists() { return file_exists($this->filename); } /** * Get the file contents. * @return string */ function getContents() { return $this->contents; } /** * Set the file contents. * @param $contents string */ function setContents($contents) { $this->contents = $contents; } /** * Write the file. * @return boolean True iff success */ function write() { $fp = fopen($this->filename, 'w+'); if ($fp === false) return false; fwrite($fp, $this->getContents()); fclose($fp); return true; } /** * Perform XML escaping. (This should not be used for anything outside * of locale file editing in a fairly trusted environment. It is done * this way to preserve formatting as much as possible.) * @param $value string * @return string "Escaped" string for inclusion in XML file. */ function xmlEscape($value) { $escapedValue = XMLNode::xmlentities($value, ENT_NOQUOTES); if ($value !== $escapedValue) return ""; return $value; } } ?>