Source code for file /joomla/environment/browser.php
Documentation is available at browser.php
* @version $Id: browser.php 9764 2007-12-30 07:48:11Z ircmaxell $
* @package Joomla.Framework
* @subpackage Environment
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
// Check to ensure this file is within the rest of the framework
* Browser class, provides capability information about the current web client.
* Browser identification is performed by examining the HTTP_USER_AGENT
* environment variable provided by the web server.
* This class has many influences from the lib/Browser.php code in
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Jon Parise <jon@horde.org>
* @author Johan Janssens <johan.janssens@joomla.org>
* @package Joomla.Framework
* @subpackage Environment
* Full user agent string.
* Lower-case user agent string.
* Platform the browser is running on.
/* The most common ones. */
/* The rest alphabetically. */
'www.almaden.ibm.com/cs/crawler',
* Is this a mobile browser?
'avoid_popup_windows' =>
false,
'break_disposition_header' =>
false,
'break_disposition_filename' =>
false,
'broken_multipart_form' =>
false,
'cache_same_url' =>
false,
'cache_ssl_downloads' =>
false,
'double_linebreak_textarea' =>
false,
'empty_file_input_value' =>
false,
'must_cache_forms' =>
false,
'no_filename_spaces' =>
false,
'no_hidden_overflow_tables' =>
false,
'png_transparency' =>
false,
'scrollbar_in_way' =>
false,
'windowed_controls' =>
false,
* List of viewable image MIME subtypes.
* This list of viewable images works for IE and Netscape/Mozilla.
var $_images =
array('jpeg', 'gif', 'png', 'pjpeg', 'x-png', 'bmp');
* Create a browser instance (Constructor).
* @param string $userAgent The browser string to parse.
* @param string $accept The HTTP_ACCEPT settings to use.
function __construct($userAgent =
null, $accept =
null)
$this->match($userAgent, $accept);
* Returns a reference to the global Browser object, only creating it
* if it doesn't already exist.
* This method must be invoked as:
* <pre> $browser = &JBrowser::getInstance([$userAgent[, $accept]]);</pre>
* @param string $userAgent The browser string to parse.
* @param string $accept The HTTP_ACCEPT settings to use.
* @return JBrowser The Browser object.
function &getInstance($userAgent =
null, $accept =
null)
if (!isset
($instances)) {
$signature =
serialize(array($userAgent, $accept));
if (empty($instances[$signature])) {
$instances[$signature] =
new JBrowser($userAgent, $accept);
return $instances[$signature];
* Parses the user agent string and inititializes the object with
* all the known features and quirks for the given browser.
* @param string $userAgent The browser string to parse.
* @param string $accept The HTTP_ACCEPT settings to use.
function match($userAgent =
null, $accept =
null)
if (isset
($_SERVER['HTTP_USER_AGENT'])) {
$this->_agent =
trim($_SERVER['HTTP_USER_AGENT']);
// Set our accept string.
if (isset
($_SERVER['HTTP_ACCEPT'])) {
// Check if browser excepts content type xhtml+xml
// Check for a mathplayer plugin is installed, so we can use MathML on several browsers
// Check for UTF support.
if (isset
($_SERVER['HTTP_ACCEPT_CHARSET'])) {
$this->setQuirk('double_linebreak_textarea');
$this->setQuirk('break_disposition_filename');
if (strpos($version[1], '.') !==
false) {
/* IE (< 7) on Windows does not support alpha transparency in
/* Some Handhelds have their screen resolution in the
* user agent string, which we can use to look for
$this->setQuirk('broken_multipart_form');
$this->setQuirk('break_disposition_header');
$this->setQuirk('broken_multipart_form');
if (isset
($version[2])) {