Changeset 7717
- Timestamp:
- 03/02/08 20:28:31 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/plugins/sfCompat10Plugin/lib/helper/PartialHelper.php
r7691 r7717 114 114 { 115 115 $cacheManager->registerConfiguration($moduleName); 116 $uri = '@sf_cache_partial?module='.$moduleName.'&action='.$actionName.'&sf_cache_key='.(isset($vars['sf_cache_key']) ? $vars['sf_cache_key'] : md5(serialize($vars))); 117 if ($retval = _get_cache($cacheManager, $uri)) 116 if ($retval = $cacheManager->getPartialCache($moduleName, $actionName, $vars)) 118 117 { 119 118 return $retval; … … 178 177 if ($cacheManager) 179 178 { 180 $retval = _set_cache($cacheManager, $uri, $retval);179 $retval = $cacheManager->setPartialCache($moduleName, $actionName, $vars, $retval); 181 180 } 182 181 … … 243 242 $cacheManager->registerConfiguration($moduleName); 244 243 $uri = '@sf_cache_partial?module='.$moduleName.'&action='.$actionName.'&sf_cache_key='.(isset($vars['sf_cache_key']) ? $vars['sf_cache_key'] : md5(serialize($vars))); 245 if ($retval = _get_cache($cacheManager, $uri))244 if ($retval = $cacheManager->getPartialCache($moduleName, $actionName, $vars)) 246 245 { 247 246 return $retval; … … 256 255 if ($cacheManager) 257 256 { 258 $retval = _set_cache($cacheManager, $uri, $retval); 259 } 260 261 return $retval; 262 } 263 264 function _get_cache($cacheManager, $uri) 265 { 266 $retval = $cacheManager->get($uri); 267 268 if (sfConfig::get('sf_web_debug')) 269 { 270 $retval = sfWebDebug::decorateContentWithDebug($uri, $retval, false); 271 } 272 273 return $retval; 274 } 275 276 function _set_cache($cacheManager, $uri, $retval) 277 { 278 $saved = $cacheManager->set($retval, $uri); 279 280 if ($saved && sfConfig::get('sf_web_debug')) 281 { 282 $retval = sfWebDebug::decorateContentWithDebug($uri, $retval, true); 257 $retval = $cacheManager->setPartialCache($moduleName, $actionName, $vars, $retval); 283 258 } 284 259 branches/1.1/lib/view/sfViewCacheManager.class.php
r7691 r7717 520 520 } 521 521 522 public function computeCacheKey($parameters) 523 { 524 return isset($parameters['sf_cache_key']) ? $parameters['sf_cache_key'] : md5(serialize($parameters)); 525 } 526 527 public function getPartialUri($module, $action, $parameters) 528 { 529 return sprintf('@sf_cache_partial?module=%s&action=%s&sf_cache_key=%s', $module, $action, $this->computeCacheKey($parameters)); 530 } 531 532 /** 533 * Returns whether a partial template is in the cache. 534 * 535 * @param string The internal URI 536 * 537 * @return Boolean true if a partial is in the cache, false otherwise 538 */ 539 public function hasPartialCache($module, $action, $parameters) 540 { 541 return $this->has($this->getPartialUri($module, $action, $parameters)); 542 } 543 544 /** 545 * Gets a partial template from the cache. 546 * 547 * @param string The internal URI 548 * 549 * @return string The cache content 550 */ 551 public function getPartialCache($module, $action, $parameters) 552 { 553 $uri = $this->getPartialUri($module, $action, $parameters); 554 555 if (!$this->isCacheable($uri)) 556 { 557 return null; 558 } 559 560 // retrieve content from cache 561 $content = $this->get($uri); 562 563 if (is_null($content)) 564 { 565 return null; 566 } 567 568 if (sfConfig::get('sf_web_debug')) 569 { 570 $content = sfWebDebug::decorateContentWithDebug($uri, $content, true); 571 } 572 573 return $content; 574 } 575 576 /** 577 * Sets an action template in the cache. 578 * 579 * @param string The internal URI 580 * @param string The content to cache 581 * @param string The view attribute holder to cache 582 * 583 * @return string The cached content 584 */ 585 public function setPartialCache($module, $action, $parameters, $content) 586 { 587 $uri = $this->getPartialUri($module, $action, $parameters); 588 if (!$this->isCacheable($uri)) 589 { 590 return $content; 591 } 592 593 $saved = $this->set($content, $uri); 594 595 if ($saved && sfConfig::get('sf_web_debug')) 596 { 597 $content = sfWebDebug::decorateContentWithDebug($uri, $content, true); 598 } 599 600 return $content; 601 } 602 522 603 /** 523 604 * Returns whether an action template is in the cache.

