00001 <?php
00002
00016
00017
00018
00019 class EditableFile {
00020 var $contents;
00021 var $filename;
00022
00023 function EditableFile($filename) {
00024 import('file.FileWrapper');
00025 $this->filename = $filename;
00026 $wrapper =& FileWrapper::wrapper($this->filename);
00027 $this->setContents($wrapper->contents());
00028 }
00029
00030 function &getContents() {
00031 return $this->contents;
00032 }
00033
00034 function setContents(&$contents) {
00035 $this->contents =& $contents;
00036 }
00037
00038 function write() {
00039 $fp = fopen($this->filename, 'w+');
00040 if ($fp === false) return false;
00041 fwrite($fp, $this->getContents());
00042 fclose($fp);
00043 return true;
00044 }
00045
00046 function xmlEscape($value) {
00047 $escapedValue = XMLNode::xmlentities($value, ENT_NOQUOTES);
00048 if ($value !== $escapedValue) return "<![CDATA[$value]]>";
00049 return $value;
00050 }
00051 }
00052
00053 ?>