diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index 7f5706835..aa5793bbe 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -1067,36 +1067,6 @@ # "extrasExclude": ["tinymce", "^blah$"] # }, -#A list of UserAgents of recognized mobile platforms. If useMobileStyle is set in the -#Admin settings, then the mobile style will be used for these browsers. - "mobileUserAgents" : [ - "AvantGo", - "DoCoMo", - "Vodafone", - "EudoraWeb", - "Minimo", - "UP\\.Browser", - "PLink", - "Plucker", - "NetFront", - "^WM5 PIE$", - "Xiino", - "iPhone", - "Opera Mobi", - "BlackBerry", - "Opera Mini", - "HP iPAQ", - "IEMobile", - "Profile/MIDP", - "Smartphone", - "Symbian ?OS", - "J2ME/MIDP", - "PalmSource", - "PalmOS", - "Windows CE", - "Opera Mini" - ], - # For the siteIndex content plugin. Whether or not the auto-generated siteIndex should # show hidden pages "siteIndex" : { diff --git a/lib/WebGUI/Asset/Wobject/ProjectManager.pm b/lib/WebGUI/Asset/Wobject/ProjectManager.pm index 0920eab41..b04b7529f 100644 --- a/lib/WebGUI/Asset/Wobject/ProjectManager.pm +++ b/lib/WebGUI/Asset/Wobject/ProjectManager.pm @@ -1044,7 +1044,7 @@ sub www_drawGanttChart { } #Adjust top for MSIE - my $isMSIE = ($session->env->request->user_agent =~ /msie/i); + my $isMSIE = $session->request->browser->ie; my $divTop = $isMSIE ? 45 : 45; #Start at 45 px and add 20px as the start of the new task #Set the propert mutiplier diff --git a/lib/WebGUI/Macro/L_loginBox.pm b/lib/WebGUI/Macro/L_loginBox.pm index a9feadc7b..3553c9fc1 100644 --- a/lib/WebGUI/Macro/L_loginBox.pm +++ b/lib/WebGUI/Macro/L_loginBox.pm @@ -90,7 +90,7 @@ sub process { # Fix box size my $boxSize = $param[0]; $boxSize = 12 unless ($boxSize); - if (index(lc($session->request->user_agent),"msie") < 0) { + if ($session->request->browser->ie) { $boxSize = int($boxSize=$boxSize*2/3); } diff --git a/lib/WebGUI/Session/Request.pm b/lib/WebGUI/Session/Request.pm index 393a7cf46..947cfea2f 100644 --- a/lib/WebGUI/Session/Request.pm +++ b/lib/WebGUI/Session/Request.pm @@ -2,6 +2,7 @@ package WebGUI::Session::Request; use strict; use parent qw(Plack::Request); use WebGUI::Session::Response; +use HTTP::BrowserDetect; =head1 SYNOPSIS @@ -21,6 +22,19 @@ is created. #------------------------------------------------------------------- +=head2 browser + +Returns a HTTP::BrowserDetect object for the request. + +=cut + +sub browser { + my $self = shift; + return $self->env->{'webgui.browser'} ||= HTTP::BrowserDetect->new($self->user_agent); +} + +#------------------------------------------------------------------- + =head2 clientIsSpider ( ) Returns true is the client/agent is a spider/indexer or some other non-human interface, determined @@ -29,29 +43,12 @@ by checking the user agent against a list of known spiders. =cut sub clientIsSpider { - my $self = shift; - my $userAgent = $self->user_agent; - - return 1 if $userAgent eq '' - || $userAgent =~ m<(^wre\/| # the WRE wget's http://localhost/ every 2-3 minutes 24 hours a day... - ^morpheus| - libwww| - s[pb]ider| - bot| - robo| - sco[ou]t| - crawl| - miner| - reaper| - finder| - search| - engine| - download| - fetch| - scan| - slurp)>ix; + return 1 + if $self->user_agent eq '' + || $self->user_agent =~ /^wre/ + || $self->browser->robot; return 0; } diff --git a/lib/WebGUI/Session/Style.pm b/lib/WebGUI/Session/Style.pm index 6bf3980ae..29f4e4d8d 100644 --- a/lib/WebGUI/Session/Style.pm +++ b/lib/WebGUI/Session/Style.pm @@ -130,11 +130,9 @@ sub useMobileStyle { if (! $session->setting->get('useMobileStyle')) { return $self->{_useMobileStyle} = 0; } - my $ua = $session->request->user_agent; - for my $mobileUA (@{ $self->session->config->get('mobileUserAgents') }) { - if ($ua =~ m/$mobileUA/) { - return $self->{_useMobileStyle} = 1; - } + + if ($session->request->browser->mobile) { + return $self->{_useMobileStyle} = 1; } return $self->{_useMobileStyle} = 0; } diff --git a/sbin/testEnvironment.pl b/sbin/testEnvironment.pl index b62c88908..ebbcd68d6 100755 --- a/sbin/testEnvironment.pl +++ b/sbin/testEnvironment.pl @@ -158,6 +158,7 @@ checkModule('Net::Twitter', "3.13006" ); checkModule('Number::Format', ); checkModule('Email::Valid', ); checkModule('Facebook::Graph', '0.0505' ); +checkModule('HTTP::BrowserDetect', ); failAndExit("Required modules are missing, running no more checks.") if $missingModule; diff --git a/share/upgrades/7.9.13-8.0.0/removeMobileUserAgents.pl b/share/upgrades/7.9.13-8.0.0/removeMobileUserAgents.pl new file mode 100644 index 000000000..c1516d79e --- /dev/null +++ b/share/upgrades/7.9.13-8.0.0/removeMobileUserAgents.pl @@ -0,0 +1,7 @@ +use WebGUI::Upgrade::Script; + +start_step "Removing mobile agent list"; + +config->delete('mobileUserAgents'); + +done;