Changeset 4154
- Timestamp:
- 06/04/07 16:36:42 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfBrowserDetectPlugin/lib/sfBrowserDetect.class.php
r4143 r4154 32 32 class sfBrowserDetect 33 33 { 34 35 /** 36 * Array with browser info 37 * @access private 38 * @var array 39 */ 40 private $browser_info; 41 42 /** 43 * Path to browscap.ini file 44 * @access private 45 * @var string 46 */ 47 private $browscap_ini; 48 34 49 function __construct() 35 50 { 51 $browscap_ini = sfConfig::get('app_php_browscap_ini_path',dirname(__FILE__).'/php_browscap.ini'); 52 53 } 54 55 /** 56 * Intantiates a exiting sfBrowserDetect object 57 * 58 * @author Jonathan R. Todd <jtodd@adventexdesign.com> 59 */ 60 public static function getInstance() 61 { 62 static $sfBrowserDetect; 36 63 64 if( !isset($sfThumbnailCache) ) 65 { 66 // Get instance 67 $className = sfConfig::get('app_sf_browser_detect_class'); 68 $sfBrowserDetect = new $className(); 69 } 70 return $sfBrowserDetect; 37 71 } 38 72 … … 51 85 52 86 /** 87 * Get the path for browscap.ini 88 * 89 * @author Jonathan R. Todd <jtodd@adventexdesign.com> 90 */ 91 public function getBrowscapIni() 92 { 93 return $this->browscap_ini; 94 } 95 96 /** 97 * Get browser info array 98 * 99 * @author Jonathan R. Todd <jtodd@adventexdesign.com> 100 */ 101 public function getBrowserInfo() 102 { 103 if(count($this->browser_info)) 104 return $this->browser_info; 105 else 106 return $this->get_browser_local(null, 107 true,$this->browscap_ini,false); 108 } 109 110 /** 53 111 * Static function which creates sfBrowserDetect object and returns 54 112 * array with browser info and capabilities … … 58 116 public static function getBrowser() 59 117 { 60 $ini = sfConfig::get('app_php_browscap_ini_path',null); 61 if(!$ini) 62 $ini = dirname(__FILE__).'/php_browscap.ini'; 118 $user = sfContext::getInstance()->getUser(); 119 if(!$user->hasAttribute('browser_info')) 120 $user->setAttribute('browser_info', 121 self::getInstance()->getBrowserInfo()); 63 122 64 return self::getNewInstance()->get_browser_local(null, 65 true,$ini,false); 123 return $user->getAttribute('browser_info'); 66 124 } 67 125