[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/includes/Cache/Lite/ -> Output.php (source)

   1  <?php
   2  
   3  /**
   4  * This class extends Cache_Lite and uses output buffering to get the data to cache.
   5  *
   6  * There are some examples in the 'docs/examples' file
   7  * Technical choices are described in the 'docs/technical' file
   8  *
   9  * @package Cache_Lite
  10  * @version $Id: Output.php,v 1.1 2005/07/22 01:57:13 eddieajau Exp $
  11  * @author Fabien MARTY <fab@php.net>
  12  */
  13  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  14  
  15  require_once ($mosConfig_absolute_path . '/includes/Cache/Lite.php');
  16  
  17  class Cache_Lite_Output extends Cache_Lite
  18  {
  19  
  20      // --- Public methods ---
  21  
  22      /**
  23      * Constructor
  24      *
  25      * $options is an assoc. To have a look at availables options,
  26      * see the constructor of the Cache_Lite class in 'Cache_Lite.php'
  27      *
  28      * @param array $options options
  29      * @access public
  30      */
  31      function Cache_Lite_Output($options)
  32      {
  33          $this->Cache_Lite($options);
  34      }
  35  
  36      /**
  37      * Start the cache
  38      *
  39      * @param string $id cache id
  40      * @param string $group name of the cache group
  41      * @return boolean true if the cache is hit (false else)
  42      * @access public
  43      */
  44      function start($id, $group = 'default')
  45      {
  46          $data = $this->get($id, $group);
  47          if ($data !== false) {
  48              echo($data);
  49              return true;
  50          } else {
  51              ob_start();
  52              ob_implicit_flush(false);
  53              return false;
  54          }
  55      }
  56  
  57      /**
  58      * Stop the cache
  59      *
  60      * @access public
  61      */
  62      function end()
  63      {
  64          $data = ob_get_contents();
  65          ob_end_clean();
  66          $this->save($data, $this->_id, $this->_group);
  67          echo($data);
  68      }
  69  
  70  }
  71  
  72  
  73  ?>