From 6fced77b37933fd22629e52d6003f5a21c9cabb3 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 25 Oct 2010 15:30:23 -0700 Subject: [PATCH] Make the display of a textarea instead of an HTMLarea independent of whether mobile styles are configured for the site. Refixes #11902. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Form/HTMLArea.pm | 2 +- lib/WebGUI/Session/Style.pm | 26 +++++++++++++++++++++----- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index c25f9a7ea..c6335866d 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -5,6 +5,7 @@ - fixed #11923: Collaboration System Mail Cron Errors - fixed #11925: Some problems in Thingy export (metaData values in CSV export) - fixed #11925: Some problems in Thingy export (export times out on Things with many rows) + - refixed #11902: forums bug (works without mobile style being set) 7.10.3 - fixed #11903: Unnecessary debug in Thingy diff --git a/lib/WebGUI/Form/HTMLArea.pm b/lib/WebGUI/Form/HTMLArea.pm index b9378d158..7d8da86f4 100644 --- a/lib/WebGUI/Form/HTMLArea.pm +++ b/lib/WebGUI/Form/HTMLArea.pm @@ -184,7 +184,7 @@ Renders an HTML area field. sub toHtml { my $self = shift; ##Do not display a rich editor on any mobile browser. - if ($self->session->style->useMobileStyle) { + if ($self->session->style->mobileBrowser) { return $self->SUPER::toHtml; } my $i18n = WebGUI::International->new($self->session); diff --git a/lib/WebGUI/Session/Style.pm b/lib/WebGUI/Session/Style.pm index 503008429..3d351670e 100644 --- a/lib/WebGUI/Session/Style.pm +++ b/lib/WebGUI/Session/Style.pm @@ -123,6 +123,25 @@ sub makePrintable { #------------------------------------------------------------------- +=head2 mobileBrowser ( ) + +Returns true if the user's browser matches any of the mobile browsers set in the config file. + +=cut + +sub mobileBrowser { + my $self = shift; + my $session = $self->session; + my $ua = $session->env->get('HTTP_USER_AGENT'); + for my $mobileUA (@{ $session->config->get('mobileUserAgents') }) { + if ($ua =~ m/$mobileUA/) { + return 1; + } + } +} + +#------------------------------------------------------------------- + =head2 useMobileStyle Returns a true value if we are on a mobile display. @@ -143,11 +162,8 @@ sub useMobileStyle { if (! $session->setting->get('useMobileStyle')) { return $self->{_useMobileStyle} = 0; } - my $ua = $session->env->get('HTTP_USER_AGENT'); - for my $mobileUA (@{ $self->session->config->get('mobileUserAgents') }) { - if ($ua =~ m/$mobileUA/) { - return $self->{_useMobileStyle} = 1; - } + if ($self->mobileBrowser) { + return $self->{_useMobileStyle} = 1; } return $self->{_useMobileStyle} = 0; }