function getFormat() { if (isset($this->_format)) { return $this->_format; } else { if (isset($this->_request['format'])) { $this->_format = $this->_request['format']; } else { list($format, $requestPath) = AkRequestMimeType::getFormat(@$this->_request['ak']); $this->_format = $format; $this->_request['format'] = $format; if ($requestPath != null) { $this->_request['ak'] = $requestPath; } } } return $this->_format; }
function _buildCacheId($path, $forcedLanguage = null, $normalize = true) { if ($path === null) { $path = @$_REQUEST['ak']; } else if (is_array($path)) { unset($path['lang']); $path = $this->_pathFor($path, $normalize); } else if (is_string($path)) { ; } $path = ltrim($path,'/'); if (preg_match('@^([a-z]{2,2}|[a-z]{2,2}_[a-z]{2,2})/.*$@', $path)) { $parts = split('/',$path); $forcedLanguage = array_shift($parts); $path = implode('/',$parts); } $cacheId = preg_replace('|'.DS.'+|','/',$path); $cacheId = rtrim($cacheId,'/'); $parts = split('/',$cacheId); $hasExtension = preg_match('/.+\..{2,4}/',$parts[count($parts)-1]); if (!$hasExtension) { if (isset($this->_controller)) { $cacheId.= '.'.$this->_controller->Request->getFormat(); } else { list($format, $requestPath) = AkRequestMimeType::getFormat($path); $cacheId.= '.'.$format; } } $getParameters = $_GET; unset($getParameters['ak']); if (is_array($this->_include_get_parameters) && !empty($this->_include_get_parameters) && !empty($getParameters)) { $cacheableGetParameters = array(); sort($this->_include_get_parameters); foreach ($this->_include_get_parameters as $include_get) { if (isset($getParameters[$include_get])) { $cacheableGetParameters[] = $include_get .DS.$getParameters[$include_get]; } } /** * writing cache fragment for the get_params that should be cached */ $this->writeFragment('get_params'.DS.$cacheId,serialize($this->_include_get_parameters)); $cacheIdGetPart = implode(DS,$cacheableGetParameters); $cacheId .= DS . $cacheIdGetPart; } else if (!$this->_controller) { /** * reading cacheable get_parameters and adding them to the cacheId */ if(($useCacheGetParams = $this->readFragment('get_params'.DS.$cacheId))) { $useCacheGetParams = unserialize($useCacheGetParams); $cacheableGetParameters = array(); foreach($useCacheGetParams as $p) { if(isset($getParameters[$p])) { $cacheableGetParameters[]=$p.DS.$getParameters[$p]; } } if (!empty($cacheableGetParameters)) { $cacheIdGetPart = implode(DS,$cacheableGetParameters); $cacheId .= DS . $cacheIdGetPart; } } } $cacheId=strlen($cacheId)>$this->_max_url_length?md5($cacheId):$cacheId; $cacheId = ($forcedLanguage!=null?$forcedLanguage:$this->_getDefaultLanguageForUser()).DS. $cacheId; $this->_lastCacheId = preg_replace('|'.DS.'+|','/',$cacheId); return $this->_lastCacheId; }
function _bestMimeType() { return AkRequestMimeType::_getMimeType(AkRequestMimeType::getAccepts()); }