uw              Fri Mar  2 07:17:23 2001 EDT

  Modified files:              
    /php4/pear/Cache    Output.php 
  Log:
  ... must forgot this commit - endGet(), $cache_id => $output_id
  
   - added endGet() which returns the output buffering content 
   - changed $cache_id to $output_id seems to be a better name as the class 
     is named Cache_Output
  
  
  
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.4 php4/pear/Cache/Output.php:1.5
--- php4/pear/Cache/Output.php:1.4      Fri Mar  2 06:46:01 2001
+++ php4/pear/Cache/Output.php  Fri Mar  2 07:17:22 2001
@@ -17,9 +17,9 @@
 // |          Vinai Kopp <[EMAIL PROTECTED]>                           |
 // +----------------------------------------------------------------------+
 //
-// $Id: Output.php,v 1.4 2001/03/02 14:46:01 chregu Exp $
+// $Id: Output.php,v 1.5 2001/03/02 15:17:22 uw Exp $
 
-require_once'Cache.php';
+require_once SHOP_INCLUDE_DIR . 'Cache/Cache.php';
 
 /**
 * Class to cache the output of a script using the output buffering functions
@@ -36,9 +36,11 @@
 *
 *  // place this somewhere in a central config file
 *  define(CACHE_STORAGE_CLASS, "cache_container_file");
+* // file storage needs a dir to put the cache files
+* define(CACHE_DIR, "/var/tmp/");
 *
 * // get a cache object
-*  $cache = new Cache_Output(CACHE_STORAGE_CLASS)
+*  $cache = new Cache_Output(CACHE_STORAGE_CLASS, array("cache_dir" => CACHE_DIR));
 *
 *  // compute the unique handle.
 *  // if your script depends on Cookie and HTTP Post data as well 
@@ -86,8 +88,9 @@
     * @var  string
     * @see  start(), end()
     */
-    var $cache_id = "";
+    var $output_id = "";
     
+    
     /**
     * starts the output buffering and returns an empty string or returns the cached 
output from the cache.
     * 
@@ -98,14 +101,14 @@
     function start($id) {
         if ($this->no_cache)
             return "";
-            
-        // this is already cached return it from the cache so that the user
+
+        // this is already cached return it from the cache so that the user 
         // can use the cache content and stop script execution
         if ($content = $this->get($id))
             return $content;
-            
+
         // remember some data to be able to fill the cache on calling end()
-        $this->cache_id = $id;
+        $this->output_id = $id;
         
         // WARNING: we need the output buffer - possible clashes
         ob_start();
@@ -113,6 +116,7 @@
         
         return "";
     } // end func start
+
     
     /*
     * Stores the content of the output buffer into the cache and returns the content.
@@ -120,7 +124,7 @@
     * @param    integer lifetime of the cached data in seconds - 0 for endless
     * @return   string  cached output
     * @access   public
-    * @see      endPrint()
+    * @see      endPrint(), endGet()
     */
     function end($expire = 0) {
     
@@ -129,22 +133,45 @@
         
         // store in the cache
         if (!$this->no_cache)
-            $this->container->save($this->cache_id,$content,  $expire);
-            
+            $this->container->save($this->output_id, $content, $expire);
+
         return $content;
     } // end func end()
     
+    
     /**
     * Stores the content of the output buffer into the cache and prints the content.
     *
-    * @brother  end()
+    * @brother  end(), endGet()
     */
     function endPrint($expire = 0) {
     
-        print $this->end($expire);
+        print $this->end($expire);      
         
     } // end func endPrint
     
     
+    /**
+    * Returns the content of the output buffer but does not store it into the cache.
+    *
+    * Use this method if the content of your script is markup (XML) 
+    * that has to be parsed/converted (XSLT) before you can output 
+    * and store it into the cache using save().
+    *
+    * @return   string
+    * @access   public
+    * @see      endPrint(), end()
+    */
+    function endGet() {
+
+        $content = ob_get_contents();
+        ob_end_clean();
+
+        $this->output_id = "";
+
+        return $content;
+    } // end func endGet
+
+
 } // end class output
-?>
\ No newline at end of file
+?>



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to