New: Test on browser version during install step.
Mutualize code to detect browser version.
This commit is contained in:
parent
07ee6208a9
commit
55904f7f37
@ -221,6 +221,41 @@ function getEntity($element=false, $shared=false)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return information about user browser
|
||||||
|
*
|
||||||
|
* @return array Array of information ('browsername'=>,'browseros'=>,'phone'=>,'browserfirefox'=>)
|
||||||
|
*/
|
||||||
|
function getBrowserInfo()
|
||||||
|
{
|
||||||
|
$name='unknown'; $version=''; $os='unknown'; $phone='';
|
||||||
|
|
||||||
|
// If phone/smartphone, we set phone os name.
|
||||||
|
if (preg_match('/android/i',$_SERVER["HTTP_USER_AGENT"])) { $os=$phone='android'; }
|
||||||
|
elseif (preg_match('/blackberry/i',$_SERVER["HTTP_USER_AGENT"])) { $os=$phone='blackberry'; }
|
||||||
|
elseif (preg_match('/iphone/i',$_SERVER["HTTP_USER_AGENT"])) { $os='ios'; $phone='iphone'; }
|
||||||
|
elseif (preg_match('/ipod/i',$_SERVER["HTTP_USER_AGENT"])) { $os='ios'; $phone='iphone'; }
|
||||||
|
elseif (preg_match('/palm/i',$_SERVER["HTTP_USER_AGENT"])) { $os=$phone='palm'; }
|
||||||
|
elseif (preg_match('/symbian/i',$_SERVER["HTTP_USER_AGENT"])) { $os='symbian'; $phone='unknown'; }
|
||||||
|
elseif (preg_match('/webos/i',$_SERVER["HTTP_USER_AGENT"])) { $os='webos'; $phone='unknown'; }
|
||||||
|
elseif (preg_match('/maemo/i',$_SERVER["HTTP_USER_AGENT"])) { $os='maemo'; $phone='unknown'; }
|
||||||
|
// MS products at end
|
||||||
|
elseif (preg_match('/iemobile/i',$_SERVER["HTTP_USER_AGENT"])) { $os='windows'; $phone='unkown'; }
|
||||||
|
elseif (preg_match('/windows ce/i',$_SERVER["HTTP_USER_AGENT"])) { $os='windows'; $phone='unkown'; }
|
||||||
|
// Name
|
||||||
|
if (preg_match('/firefox(\/|\s)*([\d\.]*)/i',$_SERVER["HTTP_USER_AGENT"],$reg)) { $name='firefox'; $version=$reg[2]; }
|
||||||
|
elseif (preg_match('/chrome(\/|\s)*([\d\.]*)/i',$_SERVER["HTTP_USER_AGENT"],$reg)) { $name='chrome'; $version=$reg[2]; }
|
||||||
|
elseif (preg_match('/iceweasel/i',$_SERVER["HTTP_USER_AGENT"])) { $name='iceweasel'; $version=$reg[2]; }
|
||||||
|
elseif ((empty($phone) || preg_match('/iphone/i',$_SERVER["HTTP_USER_AGENT"])) && preg_match('/safari(\/|\s)*([\d\.]*)/i',$_SERVER["HTTP_USER_AGENT"],$reg)) { $name='safari'; $version=$reg[2]; } // Safari is often present in string for mobile but its not.
|
||||||
|
elseif (preg_match('/opera(\/|\s)*([\d\.]*)/i',$_SERVER["HTTP_USER_AGENT"],$reg)) { $name='opera'; $version=$reg[2]; }
|
||||||
|
elseif (preg_match('/msie(\/|\s)*([\d\.]*)/i',$_SERVER["HTTP_USER_AGENT"],$reg)) { $name='ie'; $version=$reg[2]; } // MS products at end
|
||||||
|
// Other
|
||||||
|
$firefox=0;
|
||||||
|
if (in_array($name,array('firefox','iceweasel'))) $firefox=1;
|
||||||
|
|
||||||
|
return array('browsername'=>$name, 'browserversion'=>$version, 'browseros'=>$os, 'phone'=>$phone, 'browserfirefox'=>$firefox);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called at end of web php process
|
* Function called at end of web php process
|
||||||
*
|
*
|
||||||
|
|||||||
@ -63,6 +63,16 @@ print '</center>';
|
|||||||
|
|
||||||
print '<b>'.$langs->trans("MiscellanousChecks")."</b>:<br>\n";
|
print '<b>'.$langs->trans("MiscellanousChecks")."</b>:<br>\n";
|
||||||
|
|
||||||
|
// Check browser
|
||||||
|
$useragent=$_SERVER['HTTP_USER_AGENT'];
|
||||||
|
if (! empty($useragent))
|
||||||
|
{
|
||||||
|
$tmp=getBrowserInfo();
|
||||||
|
$browserversion=$tmp['browserversion'];
|
||||||
|
$browsername=$tmp['browsername'];
|
||||||
|
if ($browsername == 'ie' && $browserversion < 7) print '<img src="../theme/eldy/img/warning.png" alt="Error"> '.$langs->trans("WarningBrowserTooOld")."<br>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check PHP version
|
// Check PHP version
|
||||||
if (versioncompare(versionphparray(),array(4,3,10)) < 0) // Minimum to use (error if lower)
|
if (versioncompare(versionphparray(),array(4,3,10)) < 0) // Minimum to use (error if lower)
|
||||||
|
|||||||
@ -32,6 +32,7 @@ ErrorConnectedButDatabaseNotFound=Connection to server successfull but database
|
|||||||
ErrorDatabaseAlreadyExists=Database '%s' already exists.
|
ErrorDatabaseAlreadyExists=Database '%s' already exists.
|
||||||
IfDatabaseNotExistsGoBackAndUncheckCreate=If database does not exists, go back and check option "Create database".
|
IfDatabaseNotExistsGoBackAndUncheckCreate=If database does not exists, go back and check option "Create database".
|
||||||
IfDatabaseExistsGoBackAndCheckCreate=If database already exists, go back and uncheck "Create database" option.
|
IfDatabaseExistsGoBackAndCheckCreate=If database already exists, go back and uncheck "Create database" option.
|
||||||
|
WarningBrowserTooOld=Too old version of browser. Upgrading your browser to a recent version of Firefox, Chrome or Opera is highly recommanded.
|
||||||
PHPVersion=PHP Version
|
PHPVersion=PHP Version
|
||||||
YouCanContinue=You can continue...
|
YouCanContinue=You can continue...
|
||||||
PleaseBePatient=Please be patient...
|
PleaseBePatient=Please be patient...
|
||||||
|
|||||||
@ -32,6 +32,7 @@ ErrorConnectedButDatabaseNotFound=Connexion au serveur réussi mais base '%s' in
|
|||||||
ErrorDatabaseAlreadyExists=La base de données '%s' existe déjà.
|
ErrorDatabaseAlreadyExists=La base de données '%s' existe déjà.
|
||||||
IfDatabaseNotExistsGoBackAndUncheckCreate=Si la base n'existe pas, revenez en arrière et cochez l'option "Créer la base de données".
|
IfDatabaseNotExistsGoBackAndUncheckCreate=Si la base n'existe pas, revenez en arrière et cochez l'option "Créer la base de données".
|
||||||
IfDatabaseExistsGoBackAndCheckCreate=Si la base existe déjà, revenez en arrière et désactiver l'option "Créer la base de données".
|
IfDatabaseExistsGoBackAndCheckCreate=Si la base existe déjà, revenez en arrière et désactiver l'option "Créer la base de données".
|
||||||
|
WarningBrowserTooOld=Version de navigateur trop ancienne. Nous vous recommandons de mettre à jour vers un version récente de Firefox, Chrome ou Opera.
|
||||||
PHPVersion=Version PHP
|
PHPVersion=Version PHP
|
||||||
YouCanContinue=Vous pouvez continuer...
|
YouCanContinue=Vous pouvez continuer...
|
||||||
PleaseBePatient=Merci de patienter...
|
PleaseBePatient=Merci de patienter...
|
||||||
|
|||||||
@ -8,17 +8,17 @@
|
|||||||
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
|
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
|
||||||
* Copyright (C) 2008 Matteli
|
* Copyright (C) 2008 Matteli
|
||||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
@ -174,30 +174,12 @@ register_shutdown_function('dol_shutdown');
|
|||||||
// Detection browser
|
// Detection browser
|
||||||
if (isset($_SERVER["HTTP_USER_AGENT"]))
|
if (isset($_SERVER["HTTP_USER_AGENT"]))
|
||||||
{
|
{
|
||||||
// If phone/smartphone, we set phone os name.
|
$tmp=getBrowserInfo();
|
||||||
if (preg_match('/android/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='android';
|
$conf->browser->phone=$tmp['phone'];
|
||||||
elseif (preg_match('/blackberry/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='blackberry';
|
$conf->browser->name=$tmp['browsername'];
|
||||||
elseif (preg_match('/iphone/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='iphone';
|
$conf->browser->os=$tmp['browseros'];
|
||||||
elseif (preg_match('/ipod/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='iphone';
|
$conf->browser->firefox=$tmp['browserfirefox'];
|
||||||
elseif (preg_match('/palm/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='palm';
|
$conf->browser->version=$tmp['browserversion'];
|
||||||
elseif (preg_match('/symbian/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='symbian';
|
|
||||||
elseif (preg_match('/webos/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='webos';
|
|
||||||
elseif (preg_match('/maemo/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='maemo';
|
|
||||||
// MS products at end
|
|
||||||
elseif (preg_match('/iemobile/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='windowsmobile';
|
|
||||||
elseif (preg_match('/windows ce/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->phone='windowsmobile';
|
|
||||||
// Name
|
|
||||||
if (preg_match('/firefox/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='firefox';
|
|
||||||
elseif (preg_match('/chrome/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='chrome';
|
|
||||||
elseif (preg_match('/iceweasel/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='iceweasel';
|
|
||||||
elseif ((empty($conf->browser->phone) || preg_match('/iphone/i',$_SERVER["HTTP_USER_AGENT"])) && preg_match('/safari/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='safari'; // Safari is often present in string but its not.
|
|
||||||
elseif (preg_match('/opera/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='opera';
|
|
||||||
// MS products at end
|
|
||||||
elseif (preg_match('/msie/i',$_SERVER["HTTP_USER_AGENT"])) $conf->browser->name='ie';
|
|
||||||
else $conf->browser->name='unknown';
|
|
||||||
// Other
|
|
||||||
if (in_array($conf->browser->name,array('firefox','iceweasel'))) $conf->browser->firefox=1;
|
|
||||||
//$conf->browser->phone='android';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1065,7 +1047,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
|
|||||||
global $user, $conf, $langs, $db;
|
global $user, $conf, $langs, $db;
|
||||||
global $dolibarr_main_authentication;
|
global $dolibarr_main_authentication;
|
||||||
global $hookmanager;
|
global $hookmanager;
|
||||||
|
|
||||||
// Instantiate hooks of thirdparty module only if not already define
|
// Instantiate hooks of thirdparty module only if not already define
|
||||||
if (! is_object($hookmanager))
|
if (! is_object($hookmanager))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -213,7 +213,6 @@ else
|
|||||||
$fieldlist = $object->field_list;
|
$fieldlist = $object->field_list;
|
||||||
$datas = $object->list_datas;
|
$datas = $object->list_datas;
|
||||||
$picto='title.png';
|
$picto='title.png';
|
||||||
if (empty($conf->browser->firefox)) $picto='title.gif';
|
|
||||||
$title_picto = img_picto('',$picto);
|
$title_picto = img_picto('',$picto);
|
||||||
$title_text = $title;
|
$title_text = $title;
|
||||||
|
|
||||||
|
|||||||
@ -117,6 +117,35 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testDolHtmlCleanLastBr
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testGetBrowserVersion()
|
||||||
|
{
|
||||||
|
$_SERVER['HTTP_USER_AGENT']='Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)'; // MSIE 5.0
|
||||||
|
$tmp=getBrowserInfo();
|
||||||
|
$this->assertEquals('ie',$tmp['browsername']);
|
||||||
|
$this->assertEquals('5.0',$tmp['browserversion']);
|
||||||
|
$_SERVER['HTTP_USER_AGENT']='Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1'; // Firefox 0.9.1
|
||||||
|
$tmp=getBrowserInfo();
|
||||||
|
$this->assertEquals('firefox',$tmp['browsername']);
|
||||||
|
$this->assertEquals('0.9.1',$tmp['browserversion']);
|
||||||
|
$_SERVER['HTTP_USER_AGENT']='Mozilla/3.0 (Windows 98; U) Opera 6.03 [en]';
|
||||||
|
$tmp=getBrowserInfo();
|
||||||
|
$this->assertEquals('opera',$tmp['browsername']);
|
||||||
|
$this->assertEquals('6.03',$tmp['browserversion']);
|
||||||
|
$_SERVER['HTTP_USER_AGENT']='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21';
|
||||||
|
$tmp=getBrowserInfo();
|
||||||
|
$this->assertEquals('chrome',$tmp['browsername']);
|
||||||
|
$this->assertEquals('19.0.1042.0',$tmp['browserversion']);
|
||||||
|
$_SERVER['HTTP_USER_AGENT']='Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1';
|
||||||
|
$tmp=getBrowserInfo();
|
||||||
|
$this->assertEquals('safari',$tmp['browsername']);
|
||||||
|
$this->assertEquals('533.21.1',$tmp['browserversion']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testDolHtmlCleanLastBr
|
* testDolHtmlCleanLastBr
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user