[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/web_cache/src/ -> lmbFullPageCacheRequest.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/core/src/lmbArrayHelper.class.php');
  10  
  11  /**

  12   * class lmbFullPageCacheRequest.

  13   *

  14   * @package web_cache

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

  16   */
  17  class lmbFullPageCacheRequest
  18  {
  19    protected $http_request;
  20    protected $user;
  21    protected $ignore_user_groups = array();
  22  
  23    function __construct($http_request, $user)
  24    {
  25      $this->http_request = $http_request;
  26      $this->user = $user;
  27    }
  28  
  29    function getUri()
  30    {
  31      return $this->http_request->getUri();
  32    }
  33  
  34    function getHttpRequest()
  35    {
  36      return $this->http_request;
  37    }
  38  
  39    function getUser()
  40    {
  41      return $this->user;
  42    }
  43  
  44    function getHash()
  45    {
  46      $path = $this->http_request->getUriPath();
  47  
  48      $extra = $this->_serializeHttpAttributes();
  49      $extra .= $this->_serializeUserInfo();
  50  
  51      return $path . ($extra ? '_' . md5($extra) : '') . '/';
  52    }
  53  
  54    protected function _serializeHttpAttributes()
  55    {
  56      $uri = $this->http_request->getUri();
  57  
  58      if(!$query = $uri->getQueryItems())
  59        return '';
  60  
  61      $flat = array();
  62      lmbArrayHelper :: toFlatArray($query, $flat);
  63      ksort($flat);
  64      return serialize($flat);
  65    }
  66  
  67    protected function _serializeUserInfo()
  68    {
  69      $groups = $this->user->getGroups();
  70  
  71      if(!$groups || array_values($groups) == $this->ignore_user_groups)
  72        return '';
  73  
  74      sort($groups);
  75      return serialize($groups);
  76    }
  77  }
  78  
  79  ?>


Generated: Sun Oct 12 04:41:30 2008 Cross-referenced by PHPXref 0.7