[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/web_cache/src/ -> lmbFullPageCacheUriPathRule.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  
  10  /**

  11   * class lmbFullPageCacheUriPathRule.

  12   *

  13   * @package web_cache

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

  15   */
  16  class lmbFullPageCacheUriPathRule
  17  {
  18    protected $path_regex;
  19    protected $offset;
  20    protected $dont_negate = true;
  21  
  22    function __construct($path_regex, $dont_negate = true)
  23    {
  24      $this->path_regex = $path_regex;
  25      $this->dont_negate = $dont_negate;
  26    }
  27  
  28    function useOffset($offset)
  29    {
  30      $this->offset = $offset;
  31    }
  32  
  33    function isSatisfiedBy($request)
  34    {
  35      $path = $request->getHttpRequest()->getUriPath();
  36      $path = $this->_applyOffset($path);
  37  
  38      if($this->dont_negate)
  39        return preg_match($this->path_regex, $path);
  40      else
  41        return !preg_match($this->path_regex, $path);
  42    }
  43  
  44    function _applyOffset($path)
  45    {
  46      if(!$this->offset)
  47        return $path;
  48  
  49      $pieces = explode($this->offset, $path, 2);
  50      return isset($pieces[1]) ? $pieces[1] : $pieces[0];
  51    }
  52  }
  53  
  54  ?>


Generated: Tue Oct 7 05:02:03 2008 Cross-referenced by PHPXref 0.7