[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/web_cache/src/ -> lmbFullPageCacheIniPolicyLoader.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  lmb_require('limb/web_cache/src/lmbFullPageCachePolicy.class.php');
  10  lmb_require('limb/web_cache/src/lmbFullPageCacheRuleset.class.php');
  11  lmb_require('limb/web_cache/src/lmbFullPageCacheUriPathRule.class.php');
  12  lmb_require('limb/web_cache/src/lmbFullPageCacheUserRule.class.php');
  13  lmb_require('limb/web_cache/src/lmbFullPageCacheRequestRule.class.php');
  14  lmb_require('limb/config/toolkit.inc.php');
  15  
  16  /**

  17   * class lmbFullPageCacheIniPolicyLoader.

  18   *

  19   * @package web_cache

  20   * @version $Id: lmbFullPageCacheIniPolicyLoader.class.php 5945 2007-06-06 08:31:43Z pachanga $

  21   */
  22  class lmbFullPageCacheIniPolicyLoader
  23  {
  24    protected $ini;
  25  
  26    function __construct($ini_path)
  27    {
  28      $this->ini = lmbToolkit :: instance()->getConf($ini_path);
  29    }
  30  
  31    function load()
  32    {
  33      $policy = new lmbFullPageCachePolicy();
  34      $groups = $this->ini->getAll();
  35      ksort($groups);
  36  
  37      foreach($groups as $rule_name => $options)
  38      {
  39        $ruleset = new lmbFullPageCacheRuleset();
  40  
  41        if(isset($options['type']) && $options['type'] == 'deny')
  42          $ruleset->setType(false);
  43  
  44        if(isset($options['path_regex']))
  45        {
  46          $rule = new lmbFullPageCacheUriPathRule($options['path_regex']);
  47  
  48          if(isset($options['path_offset']))
  49            $rule->useOffset(rtrim($options['path_offset'], '/'));
  50          $ruleset->addRule($rule);
  51        }
  52  
  53        if(isset($options['groups']))
  54        {
  55          $rule = new lmbFullPageCacheUserRule($options['groups']);
  56          $ruleset->addRule($rule);
  57        }
  58  
  59        if(isset($options['request']) || isset($options['get']) || isset($options['post']))
  60        {
  61          $rule = new lmbFullPageCacheRequestRule(isset($options['request']) ? $options['request'] : null,
  62                                                  isset($options['get']) ? $options['get'] : null,
  63                                                  isset($options['post']) ? $options['post'] : null);
  64          $ruleset->addRule($rule);
  65        }
  66  
  67        $policy->addRuleset($ruleset);
  68      }
  69      return $policy;
  70    }
  71  }
  72  
  73  ?>


Generated: Fri Aug 29 04:49:26 2008 Cross-referenced by PHPXref 0.7