Changeset 8983
- Timestamp:
- 05/15/08 18:46:55 (5 months ago)
- Files:
-
- branches/1.1/lib/config/config/factories.yml (modified) (1 diff)
- branches/1.1/lib/debug/sfWebDebug.class.php (modified) (3 diffs)
- branches/1.1/lib/log/sfWebDebugLogger.class.php (modified) (1 diff)
- branches/1.1/lib/view/sfViewCacheManager.class.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/config/config/factories.yml
r8227 r8983 82 82 class: sfWebDebugLogger 83 83 param: 84 condition: %SF_WEB_DEBUG% 85 xdebug_logging: true 84 condition: %SF_WEB_DEBUG% 85 xdebug_logging: true 86 web_debug_class: sfWebDebug 86 87 sf_file_debug: 87 88 class: sfFileLogger branches/1.1/lib/debug/sfWebDebug.class.php
r8091 r8983 20 20 { 21 21 protected 22 $dispatcher = null, 22 23 $log = array(), 23 24 $maxPriority = 1000, 24 25 $types = array(), 25 26 $lastTimeLog = -1; 27 28 public function __construct(sfEventDispatcher $dispatcher) 29 { 30 $this->dispatcher = $dispatcher; 31 32 $this->dispatcher->connect('view.cache.filter_content', array($this, 'decorateContentWithDebug')); 33 } 26 34 27 35 /** … … 354 362 355 363 /** 356 * Decoratesa chunk of HTML with cache information.357 * 358 * @param s tring The internalUri representing the content364 * Listens to the 'view.cache.filter_content' event to decorate a chunk of HTML with cache information. 365 * 366 * @param sfEvent A sfEvent instance 359 367 * @param string The HTML content 360 * @param boolean true if the content is new in the cache, false otherwise361 368 * 362 369 * @return string The decorated HTML string 363 370 */ 364 static public function decorateContentWithDebug($internalUri, $content, $new = false) 365 { 366 $context = sfContext::getInstance(); 367 371 public function decorateContentWithDebug(sfEvent $event, $content) 372 { 368 373 // don't decorate if not html or if content is null 369 if (!sfConfig::get('sf_web_debug') || !$content || false === strpos($ context->getResponse()->getContentType(), 'html'))374 if (!sfConfig::get('sf_web_debug') || !$content || false === strpos($event['response']->getContentType(), 'html')) 370 375 { 371 376 return $content; 372 377 } 373 378 374 $ cache = $context->getViewCacheManager();379 $viewCacheManager = $event->getSubject(); 375 380 sfLoader::loadHelpers(array('Helper', 'Url', 'Asset', 'Tag')); 376 381 377 $bgColor = $ new? '#9ff' : '#ff9';378 $lastModified = $ cache->getLastModified($internalUri);379 $id = md5($ internalUri);382 $bgColor = $event['new'] ? '#9ff' : '#ff9'; 383 $lastModified = $viewCacheManager->getLastModified($event['uri']); 384 $id = md5($event['uri']); 380 385 381 386 return ' … … 384 389 <div style="height: 16px; padding: 2px"><a href="#" onclick="sfWebDebugToggle(\'sub_main_info_'.$id.'\'); return false;"><strong>cache information</strong></a> <a href="#" onclick="sfWebDebugToggle(\'sub_main_'.$id.'\'); document.getElementById(\'main_'.$id.'\').style.border = \'none\'; return false;">'.image_tag(sfConfig::get('sf_web_debug_web_dir').'/images/close.png').'</a> </div> 385 390 <div style="padding: 2px; display: none" id="sub_main_info_'.$id.'"> 386 [uri] '.htmlspecialchars($ internalUri, ENT_QUOTES, sfConfig::get('sf_charset')).'<br />387 [life time] '.$ cache->getLifeTime($internalUri).' seconds<br />391 [uri] '.htmlspecialchars($event['uri'], ENT_QUOTES, sfConfig::get('sf_charset')).'<br /> 392 [life time] '.$viewCacheManager->getLifeTime($event['uri']).' seconds<br /> 388 393 [last modified] '.(time() - $lastModified).' seconds<br /> 389 394 <br /> branches/1.1/lib/log/sfWebDebugLogger.class.php
r8368 r8983 38 38 $this->dispatcher = $dispatcher; 39 39 40 $class = isset($options['web_debug_class']) ? $options['web_debug_class'] : 'sfWebDebug'; 41 $this->webDebug = new $class($dispatcher); 42 40 43 $dispatcher->connect('response.filter_content', array($this, 'filterResponseContent')); 41 42 if(is_null($this->webDebug))43 {44 $this->webDebug = $this->context->has('sf_web_debug') ? $this->context->get('sf_web_debug') : new sfWebDebug();45 }46 47 $this->context->set('sf_web_debug', $this->webDebug);48 44 49 45 if (isset($options['xdebug_logging'])) branches/1.1/lib/view/sfViewCacheManager.class.php
r8138 r8983 669 669 if (sfConfig::get('sf_web_debug')) 670 670 { 671 $content = sfWebDebug::decorateContentWithDebug($uri, $content, false);671 $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => false)), $content)->getReturnValue(); 672 672 } 673 673 … … 697 697 if ($saved && sfConfig::get('sf_web_debug')) 698 698 { 699 $content = sfWebDebug::decorateContentWithDebug($uri, $content, true);699 $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => true)), $content)->getReturnValue(); 700 700 } 701 701 … … 744 744 if (sfConfig::get('sf_web_debug')) 745 745 { 746 $content = sfWebDebug::decorateContentWithDebug($uri, $content, false);746 $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => false)), $content)->getReturnValue(); 747 747 } 748 748 … … 770 770 if ($saved && sfConfig::get('sf_web_debug')) 771 771 { 772 $content = sfWebDebug::decorateContentWithDebug($uri, $content, true);772 $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => true)), $content)->getReturnValue(); 773 773 } 774 774 … … 793 793 if ($saved && sfConfig::get('sf_web_debug')) 794 794 { 795 $content = sfWebDebug::decorateContentWithDebug($uri, $this->context->getResponse()->getContent(), true); 795 $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => true)), $this->context->getResponse()->getContent())->getReturnValue(); 796 796 797 $this->context->getResponse()->setContent($content); 797 798 } … … 828 829 if (sfConfig::get('sf_web_debug')) 829 830 { 830 $content = sfWebDebug::decorateContentWithDebug($uri, $this->context->getResponse()->getContent(), false); 831 $content = $this->dispatcher->filter(new sfEvent($this, 'view.cache.filter_content', array('response' => $this->context->getResponse(), 'uri' => $uri, 'new' => false)), $this->context->getResponse()->getContent())->getReturnValue(); 832 831 833 $this->context->getResponse()->setContent($content); 832 834 }