Bug #20784 » 0011585_v2.patch

Administrator Admin, 2009-07-27 15:18

View differences:

t3lib/class.t3lib_matchcondition.php (Arbeitskopie)
534 534
			}
535 535
		}
536 536

  
537
		$useragent = trim($useragent);
538
		$browserInfo=Array();
539
		$browserInfo['useragent']=$useragent;
540
		if ($useragent)	{
541
			// browser
542
			if (strstr($useragent,'MSIE'))	{
543
				$browserInfo['browser']='msie';
544
			} elseif(strstr($useragent,'Konqueror'))	{
545
				$browserInfo['browser']='konqueror';
546
			} elseif(strstr($useragent,'Opera'))	{
547
				$browserInfo['browser']='opera';
548
			} elseif(strstr($useragent,'Lynx'))	{
549
				$browserInfo['browser']='lynx';
550
			} elseif(strstr($useragent,'PHP'))	{
551
				$browserInfo['browser']='php';
552
			} elseif(strstr($useragent,'AvantGo'))	{
553
				$browserInfo['browser']='avantgo';
554
			} elseif(strstr($useragent,'WebCapture'))	{
555
				$browserInfo['browser']='acrobat';
556
			} elseif(strstr($useragent,'IBrowse'))	{
557
				$browserInfo['browser']='ibrowse';
558
			} elseif(strstr($useragent,'Teleport'))	{
559
				$browserInfo['browser']='teleport';
560
			} elseif(strstr($useragent,'Mozilla'))	{
561
				$browserInfo['browser']='netscape';
562
			} else {
563
				$browserInfo['browser']='unknown';
564
			}
565
			// version
566
			switch($browserInfo['browser'])	{
567
				case 'netscape':
568
					$browserInfo['version'] = $this->browserInfo_version(substr($useragent,8));
569
					if (strstr($useragent,'Netscape6')) {$browserInfo['version']=6;}
570
				break;
571
				case 'msie':
572
					$tmp = strstr($useragent,'MSIE');
573
					$browserInfo['version'] = $this->browserInfo_version(substr($tmp,4));
574
				break;
575
				case 'opera':
576
					$tmp = strstr($useragent,'Opera');
577
					$browserInfo['version'] = $this->browserInfo_version(substr($tmp,5));
578
				break;
579
				case 'lynx':
580
					$tmp = strstr($useragent,'Lynx/');
581
					$browserInfo['version'] = $this->browserInfo_version(substr($tmp,5));
582
				break;
583
				case 'php':
584
					$tmp = strstr($useragent,'PHP/');
585
					$browserInfo['version'] = $this->browserInfo_version(substr($tmp,4));
586
				break;
587
				case 'avantgo':
588
					$tmp = strstr($useragent,'AvantGo');
589
					$browserInfo['version'] = $this->browserInfo_version(substr($tmp,7));
590
				break;
591
				case 'acrobat':
592
					$tmp = strstr($useragent,'WebCapture');
593
					$browserInfo['version'] = $this->browserInfo_version(substr($tmp,10));
594
				break;
595
				case 'ibrowse':
596
					$tmp = strstr($useragent,'IBrowse/');
597
					$browserInfo['version'] = $this->browserInfo_version(substr($tmp,8));
598
				break;
599
				case 'konqueror':
600
					$tmp = strstr($useragent,'Konqueror/');
601
					$browserInfo['version'] = $this->browserInfo_version(substr($tmp,10));
602
				break;
603
			}
604
			// system
605
			$browserInfo['system']='';
606
			if (strstr($useragent,'Win'))	{
607
				// windows
608
				if (strstr($useragent,'Win98') || strstr($useragent,'Windows 98'))	{
609
					$browserInfo['system']='win98';
610
				} elseif (strstr($useragent,'Win95') || strstr($useragent,'Windows 95'))	{
611
					$browserInfo['system']='win95';
612
				} elseif (strstr($useragent,'WinNT') || strstr($useragent,'Windows NT'))	{
613
					$browserInfo['system']='winNT';
614
				} elseif (strstr($useragent,'Win16') || strstr($useragent,'Windows 311'))	{
615
					$browserInfo['system']='win311';
616
				}
617
			} elseif (strstr($useragent,'Mac'))	{
618
				$browserInfo['system']='mac';
619
				// unixes
620
			} elseif (strstr($useragent,'Linux'))	{
621
				$browserInfo['system']='linux';
622
			} elseif (strstr($useragent,'SGI') && strstr($useragent,' IRIX '))	{
623
				$browserInfo['system']='unix_sgi';
624
			} elseif (strstr($useragent,' SunOS '))	{
625
				$browserInfo['system']='unix_sun';
626
			} elseif (strstr($useragent,' HP-UX '))	{
627
				$browserInfo['system']='unix_hp';
628
			}
629
		}
537
		$browserInfo = t3lib_div_browser::getBrowserInfo($useragent);
630 538

  
631 539
		return $browserInfo;
632 540
	}
......
636 544
	 *
637 545
	 * @param	string		A string with version number, eg. "/7.32 blablabla"
638 546
	 * @return	double		Returns double value, eg. "7.32"
547
	 * @deprecated	since TYPO3 4.3 - use t3lib_div_browser::getVersion() instead
639 548
	 */
640 549
	function browserInfo_version($tmp)	{
641
		return doubleval(preg_replace('/^[^0-9]*/','',$tmp));
550
		t3lib_div::logDeprecatedFunction();
551
		return t3lib_div_browser::getVersion($tmp);
642 552
	}
643 553

  
644 554
	/**
t3lib/core_autoload.php (Arbeitskopie)
95 95
	't3lib_cache_frontend_stringfrontend' => PATH_t3lib . 'cache/frontend/class.t3lib_cache_frontend_stringfrontend.php',
96 96
	't3lib_cache_frontend_variablefrontend' => PATH_t3lib . 'cache/frontend/class.t3lib_cache_frontend_variablefrontend.php',
97 97
	't3lib_cache_frontend_frontend' => PATH_t3lib . 'cache/frontend/interfaces/interface.t3lib_cache_frontend_frontend.php',
98
	't3lib_div_browser' => PATH_t3lib . 'div/class.t3lib_div_browser.php',
98 99
	't3lib_browselinkshook' => PATH_t3lib . 'interfaces/interface.t3lib_browselinkshook.php',
99 100
	't3lib_localrecordlistgettablehook' => PATH_t3lib . 'interfaces/interface.t3lib_localrecordlistgettablehook.php',
100 101
	't3lib_singleton' => PATH_t3lib . 'interfaces/interface.t3lib_singleton.php',
t3lib/div/class.t3lib_div_browser.php (Revision 0)
1
<?php
2
/***************************************************************
3
 * Copyright notice
4
 *
5
 * (c) 2009 Oliver Hader <oliver@typo3.org>
6
 * All rights reserved
7
 *
8
 * This script is part of the TYPO3 project. The TYPO3 project is
9
 * free software; you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation; either version 2 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * The GNU General Public License can be found at
15
 * http://www.gnu.org/copyleft/gpl.html.
16
 * A copy is found in the textfile GPL.txt and important notices to the license
17
 * from the author is found in LICENSE.txt distributed with these scripts.
18
 *
19
 *
20
 * This script is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27

  
28
/**
29
 * Class to handle and determine browser specific information.
30
 *
31
 * $Id$
32
 *
33
 * @author	Oliver Hader <oliver@typo3.org>
34
 */
35
final class t3lib_div_browser {
36
	/**
37
	 * Generates an array with abstracted browser information
38
	 * This method is used in the function match() in this class
39
	 *
40
	 * @param	string		$userAgent: The useragent string, t3lib_div::getIndpEnv('HTTP_USER_AGENT')
41
	 * @return	array		Contains keys "browser", "version", "system"
42
	 */
43
	static public function getBrowserInfo($userAgent) {
44
			// Hook: $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/div/class.t3lib_div_browser.php']['getBrowserInfo']:
45
		$getBrowserInfoHooks =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/div/class.t3lib_div_browser.php']['getBrowserInfo'];
46
		if (is_array($getBrowserInfoHooks)) {
47
			foreach ($getBrowserInfoHooks as $hookFunction) {
48
				$returnResult = true;
49
				$hookParameters = array(
50
					'userAgent' => &$userAgent,
51
					'returnResult' => &$returnResult,
52
				);
53

  
54
				$hookResult = t3lib_div::callUserFunction($hookFunction, $hookParameters, NULL);
55
				if ($returnResult && is_array($hookResult) && count($hookResult)) {
56
					return $hookResult;
57
				}
58
			}
59
		}
60

  
61
		$userAgent = trim($userAgent);
62
		$browserInfo = array(
63
			'useragent' => $userAgent,
64
		);
65

  
66
		if ($userAgent) {
67
			// browser
68
			if (strstr($userAgent,'MSIE'))	{
69
				$browserInfo['browser']='msie';
70
			} elseif(strstr($userAgent,'Konqueror'))	{
71
				$browserInfo['browser']='konqueror';
72
			} elseif(strstr($userAgent,'Opera'))	{
73
				$browserInfo['browser']='opera';
74
			} elseif(strstr($userAgent,'Lynx'))	{
75
				$browserInfo['browser']='lynx';
76
			} elseif(strstr($userAgent,'PHP'))	{
77
				$browserInfo['browser']='php';
78
			} elseif(strstr($userAgent,'AvantGo'))	{
79
				$browserInfo['browser']='avantgo';
80
			} elseif(strstr($userAgent,'WebCapture'))	{
81
				$browserInfo['browser']='acrobat';
82
			} elseif(strstr($userAgent,'IBrowse'))	{
83
				$browserInfo['browser']='ibrowse';
84
			} elseif(strstr($userAgent,'Teleport'))	{
85
				$browserInfo['browser']='teleport';
86
			} elseif(strstr($userAgent,'Mozilla'))	{
87
				$browserInfo['browser']='netscape';
88
			} else {
89
				$browserInfo['browser']='unknown';
90
			}
91

  
92
			// version
93
			switch($browserInfo['browser']) {
94
				case 'netscape':
95
					$browserInfo['version'] = self::getVersion(substr($userAgent, 8));
96
					if (strstr($userAgent, 'Netscape6')) {
97
						$browserInfo['version'] = 6;
98
					}
99
				break;
100
				case 'msie':
101
					$tmp = strstr($userAgent, 'MSIE');
102
					$browserInfo['version'] = self::getVersion(substr($tmp, 4));
103
				break;
104
				case 'opera':
105
					$tmp = strstr($userAgent, 'Opera');
106
					$browserInfo['version'] = self::getVersion(substr($tmp, 5));
107
				break;
108
				case 'lynx':
109
					$tmp = strstr($userAgent, 'Lynx/');
110
					$browserInfo['version'] = self::getVersion(substr($tmp, 5));
111
				break;
112
				case 'php':
113
					$tmp = strstr($userAgent, 'PHP/');
114
					$browserInfo['version'] = self::getVersion(substr($tmp, 4));
115
				break;
116
				case 'avantgo':
117
					$tmp = strstr($userAgent, 'AvantGo');
118
					$browserInfo['version'] = self::getVersion(substr($tmp, 7));
119
				break;
120
				case 'acrobat':
121
					$tmp = strstr($userAgent, 'WebCapture');
122
					$browserInfo['version'] = self::getVersion(substr($tmp, 10));
123
				break;
124
				case 'ibrowse':
125
					$tmp = strstr($userAgent, 'IBrowse/');
126
					$browserInfo['version'] = self::getVersion(substr($tmp ,8));
127
				break;
128
				case 'konqueror':
129
					$tmp = strstr($userAgent, 'Konqueror/');
130
					$browserInfo['version'] = self::getVersion(substr($tmp, 10));
131
				break;
132
			}
133
			// system
134
			$browserInfo['system'] = '';
135
			if (strstr($userAgent, 'Win')) {
136
				// windows
137
				if (strstr($userAgent, 'Win98') || strstr($userAgent, 'Windows 98')) {
138
					$browserInfo['system'] = 'win98';
139
				} elseif (strstr($userAgent, 'Win95') || strstr($userAgent, 'Windows 95')) {
140
					$browserInfo['system'] = 'win95';
141
				} elseif (strstr($userAgent, 'WinNT') || strstr($userAgent, 'Windows NT')) {
142
					$browserInfo['system'] = 'winNT';
143
				} elseif (strstr($userAgent, 'Win16') || strstr($userAgent, 'Windows 311')) {
144
					$browserInfo['system'] = 'win311';
145
				}
146
			} elseif (strstr($userAgent,'Mac')) {
147
				$browserInfo['system'] = 'mac';
148
				// unixes
149
			} elseif (strstr($userAgent, 'Linux')) {
150
				$browserInfo['system'] = 'linux';
151
			} elseif (strstr($userAgent, 'SGI') && strstr($userAgent, ' IRIX ')) {
152
				$browserInfo['system'] = 'unix_sgi';
153
			} elseif (strstr($userAgent, ' SunOS ')) {
154
				$browserInfo['system'] = 'unix_sun';
155
			} elseif (strstr($userAgent, ' HP-UX ')) {
156
				$browserInfo['system'] = 'unix_hp';
157
			}
158
		}
159

  
160
		return $browserInfo;
161
	}
162

  
163
	/**
164
	 * Returns the version of a browser; Basically getting doubleval() of the input string,
165
	 * stripping of any non-numeric values in the beginning of the string first.
166
	 *
167
	 * @param	string		$version: A string with version number, eg. "/7.32 blablabla"
168
	 * @return	double		Returns double value, eg. "7.32"
169
	 */
170
	static public function getVersion($version) {
171
		return doubleval(preg_replace('/^[^0-9]*/', '', $version));
172
	}
173
}
174
?>
typo3/template.php (Arbeitskopie)
674 674
		}
675 675

  
676 676
			// Get the browser info
677
		$matchObject = t3lib_div::makeInstance('t3lib_matchCondition');
678
		$browserInfo = $matchObject->browserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
677
		$browserInfo = t3lib_div_browser::getBrowserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
679 678

  
680 679
			// Set the XML prologue
681 680
		$xmlPrologue = '<?xml version="1.0" encoding="' . $this->charset . '"?>';
(1-1/4)