00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Varien_Simplexml_Config_Cache_File extends Varien_Simplexml_Config_Cache_Abstract
00036 {
00037
00038
00039
00040
00041
00042
00043
00044 public function setKey($key)
00045 {
00046 $this->setData('key', $key);
00047
00048 $file = $this->getDir().DS.$this->getKey();
00049 $this->setFileName($file.'.xml');
00050 $this->setStatFileName($file.'.stat');
00051
00052 return $this;
00053 }
00054
00055
00056
00057
00058
00059
00060 public function load()
00061 {
00062 $this->setIsLoaded(false);
00063
00064
00065 if (!($stats = @file_get_contents($this->getStatFileName()))) {
00066 return false;
00067 }
00068
00069
00070 if (!$this->validateComponents(unserialize($stats))) {
00071 return false;
00072 }
00073
00074
00075 if (!($cache = @file_get_contents($this->getFileName()))) {
00076 return false;
00077 }
00078
00079
00080 if (!($data = $this->getConfig()->processFileData($cache))) {
00081 return false;
00082 }
00083
00084 $xml = $this->getConfig()->loadString($data);
00085 $this->getConfig()->setXml($xml);
00086 $this->setIsLoaded(true);
00087
00088 return true;
00089 }
00090
00091
00092
00093
00094
00095
00096 public function save()
00097 {
00098 if (!$this->getIsAllowedToSave()) {
00099 return false;
00100 }
00101
00102
00103 @file_put_contents($this->getStatFileName(), serialize($this->getComponents()));
00104
00105
00106 @file_put_contents($this->getFileName(), $this->getConfig()->getNode()->asNiceXml());
00107
00108 return true;
00109 }
00110 }