コード例 #1
0
ファイル: fragment.php プロジェクト: ZerGabriel/cms-1
 /**
  * Load a fragment from cache and display it. Multiple fragments can
  * be nested with different life times.
  *
  *     if ( ! Fragment::load('footer')) {
  *         // Anything that is echo'ed here will be saved
  *         Fragment::save();
  *     }
  *
  * @param   string  $name       fragment name
  * @param   integer $lifetime   fragment cache lifetime
  * @param   boolean $i18n       multilingual fragment support
  * @return  boolean
  */
 public static function load($name, $lifetime = NULL, $i18n = NULL)
 {
     if (($fragment = Fragment::get($name, $lifetime, $i18n)) !== NULL) {
         // Display the cached fragment now
         echo $fragment;
         return TRUE;
     } else {
         // Start the output buffer
         ob_start();
         // Store the cache key by the buffer level
         Fragment::$_caches[ob_get_level()] = Fragment::_cache_key($name, $i18n);
         return FALSE;
     }
 }