From 9b24cccd0bf61bd3306a40d4f360eaf8f7f8af01 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Oct 2014 12:24:36 +0200 Subject: [PATCH] Fix: Better layout detection --- htdocs/categories/categorie.php | 2 +- htdocs/core/class/html.formfile.class.php | 6 +++--- htdocs/core/class/mobiledetect.class.php | 15 ++++++++++----- htdocs/core/lib/functions.lib.php | 1 + htdocs/theme/eldy/style.css.php | 4 ++-- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index c74eefdc430..3200513d11d 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -634,7 +634,7 @@ function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1) print ''; print ''; print ''; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 50c681d8366..674be61311d 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -73,12 +73,12 @@ class FormFile global $conf,$langs, $hookmanager; $hookmanager->initHooks(array('formfile')); - if (! empty($conf->browser->phone)) return 0; + if (! empty($conf->browser->layout) && $conf->browser->layout != 'classic') return 0; if ((! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) && $useajax) || ($useajax==2)) { - // TODO: Cheeck this works with 2 forms on same page - // TODO: Cheeck this works with GED module, otherwise, force useajax to 0 + // TODO: Check this works with 2 forms on same page + // TODO: Check this works with GED module, otherwise, force useajax to 0 // TODO: This does not support option savingdocmask // TODO: This break feature to upload links too return $this->_formAjaxFileUpload($object); diff --git a/htdocs/core/class/mobiledetect.class.php b/htdocs/core/class/mobiledetect.class.php index c39111d04be..0c7b742421a 100644 --- a/htdocs/core/class/mobiledetect.class.php +++ b/htdocs/core/class/mobiledetect.class.php @@ -155,7 +155,7 @@ class MobileDetect 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile', // @ref: http://www.micromaxinfo.com/mobiles/smartphones // Added because the codes might conflict with Acer Tablets. - 'Micromax' => 'Micromax.*\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\b', + 'Micromax' => 'Micromax.*\b(A\d+)\b', 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ; @todo - complete the regex. 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;) // @ref: http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH) @@ -179,7 +179,7 @@ class MobileDetect protected static $tabletDevices = array( 'iPad' => 'iPad|iPad.*Mobile', // @todo: check for mobile friendly emails topic. 'NexusTablet' => 'Android.*Nexus[\s]+(7|10)|^.*Android.*Nexus(?:(?!Mobile).)*$', - 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-I9205|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705C|SM-T535|SM-T331', // SCH-P709|SCH-P729|SM-T2558 - Samsung Mega - treat them like a regular phone. + 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P\d+|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-N8000|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-N8010|GT-N8005|GT-N8020|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-I9205|SM-T\d+|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-P6000|SM-T3100|SGH-I467|XE500|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|XE500T1C|SM-P605V|SM-P905V|SM-P600X|SM-P900X|', // SCH-P709|SCH-P729|SM-T2558 - Samsung Mega - treat them like a regular phone. // @reference: http://www.labnol.org/software/kindle-user-agent-string/20378/ 'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE)\b', // Only the Surface tablets with Windows RT are considered mobile. @@ -963,10 +963,15 @@ class MobileDetect $this->setDetectionType(self::DETECTION_TYPE_MOBILE); - if ($this->checkHttpHeadersForMobile()) { + if ($this->checkHttpHeadersForMobile()) + { + //print "Found it's a mobile from http header"; return true; - } else { - return $this->matchDetectionRulesAgainstUA(); + } + else + { + //print "Check into user agent ".$this->getUserAgent(); + return $this->matchDetectionRulesAgainstUA(); } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4be2583aa63..38e19eb31fd 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -148,6 +148,7 @@ function getBrowserInfo() $detectmobile=new MobileDetect(); $phone=$detectmobile->isMobile(); $tablet=$detectmobile->isTablet(); + unset($detectmobile); // free memory return array('browsername'=>$name, 'browserversion'=>$version, 'browseros'=>$os, 'browserfirefox'=>$firefox, 'layout'=> ($tablet?'tablet':($phone?'phone':'classic')), 'phone'=>$phone, 'tablet'=>$tablet); } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 657d48f32d3..cd1801ca275 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -131,12 +131,12 @@ if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED)) $conf->global->THEME_ELDY_LINEIMPAIR2='255,255,255'; $conf->global->THEME_ELDY_LINEIMPAIRHOVER='238,246,252'; $conf->global->THEME_ELDY_TEXT='50,50,130'; - if ($dol_use_jmobile) + /*if ($dol_use_jmobile) { $conf->global->THEME_ELDY_BACKTABCARD1='245,245,245'; // topmenu $conf->global->THEME_ELDY_BACKTABCARD2='245,245,245'; $conf->global->THEME_ELDY_BACKTABACTIVE='245,245,245'; - } + }*/ } $colorbackhmenu1 =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$conf->global->THEME_ELDY_TOPMENU_BACK1) :(empty($user->conf->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$user->conf->THEME_ELDY_TOPMENU_BACK1);
'; - print $langs->trans("ClassifyInCategory").'  '; + print ''.$langs->trans("ClassifyInCategory").'  '; print $form->select_all_categories($typeid,'auto'); print ''; print '