• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/Zend/View/Stream.php

00001 <?php
00040 class Zend_View_Stream
00041 {
00047     protected $_pos = 0;
00048 
00054     protected $_data;
00055 
00061     protected $_stat;
00062 
00066     public function stream_open($path, $mode, $options, &$opened_path)
00067     {
00068         // get the view script source
00069         $path        = str_replace('zend.view://', '', $path);
00070         $this->_data = file_get_contents($path);
00071 
00076         if ($this->_data === false) {
00077             $this->_stat = stat($path);
00078             return false;
00079         }
00080 
00085         $this->_data = preg_replace('/<\?\=/',          "<?php echo ",  $this->_data);
00086         $this->_data = preg_replace('/<\?(?!xml|php)/s', '<?php ',       $this->_data);
00087 
00093         $this->_stat = stat($path);
00094 
00095         return true;
00096     }
00097 
00103     public function url_stat()
00104     {
00105         return $this->_stat;
00106     }
00107 
00111     public function stream_read($count)
00112     {
00113         $ret = substr($this->_data, $this->_pos, $count);
00114         $this->_pos += strlen($ret);
00115         return $ret;
00116     }
00117 
00118 
00122     public function stream_tell()
00123     {
00124         return $this->_pos;
00125     }
00126 
00127 
00131     public function stream_eof()
00132     {
00133         return $this->_pos >= strlen($this->_data);
00134     }
00135 
00136 
00140     public function stream_stat()
00141     {
00142         return $this->_stat;
00143     }
00144 
00145 
00149     public function stream_seek($offset, $whence)
00150     {
00151         switch ($whence) {
00152             case SEEK_SET:
00153                 if ($offset < strlen($this->_data) && $offset >= 0) {
00154                 $this->_pos = $offset;
00155                     return true;
00156                 } else {
00157                     return false;
00158                 }
00159                 break;
00160 
00161             case SEEK_CUR:
00162                 if ($offset >= 0) {
00163                     $this->_pos += $offset;
00164                     return true;
00165                 } else {
00166                     return false;
00167                 }
00168                 break;
00169 
00170             case SEEK_END:
00171                 if (strlen($this->_data) + $offset >= 0) {
00172                     $this->_pos = strlen($this->_data) + $offset;
00173                     return true;
00174                 } else {
00175                     return false;
00176                 }
00177                 break;
00178 
00179             default:
00180                 return false;
00181         }
00182     }
00183 }

Generated on Thu Apr 19 2012 17:01:18 for openbiz by  doxygen 1.7.2