00001 <?php 00027 require_once 'Zend/Cache/Core.php'; 00028 00029 00036 class Zend_Cache_Frontend_Output extends Zend_Cache_Core 00037 { 00038 00039 private $_idStack = array(); 00040 00047 public function __construct(array $options = array()) 00048 { 00049 parent::__construct($options); 00050 $this->_idStack = array(); 00051 } 00052 00061 public function start($id, $doNotTestCacheValidity = false, $echoData = true) 00062 { 00063 $data = $this->load($id, $doNotTestCacheValidity); 00064 if ($data !== false) { 00065 if ( $echoData ) { 00066 echo($data); 00067 return true; 00068 } else { 00069 return $data; 00070 } 00071 } 00072 ob_start(); 00073 ob_implicit_flush(false); 00074 $this->_idStack[] = $id; 00075 return false; 00076 } 00077 00088 public function end($tags = array(), $specificLifetime = false, $forcedDatas = null, $echoData = true, $priority = 8) 00089 { 00090 if ($forcedDatas === null) { 00091 $data = ob_get_contents(); 00092 ob_end_clean(); 00093 } else { 00094 $data =& $forcedDatas; 00095 } 00096 $id = array_pop($this->_idStack); 00097 if ($id === null) { 00098 Zend_Cache::throwException('use of end() without a start()'); 00099 } 00100 $this->save($data, $id, $tags, $specificLifetime, $priority); 00101 if ($echoData) { 00102 echo($data); 00103 } 00104 } 00105 00106 }