X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FRequest.pm;h=7c4fa71989c882e1cac5f79c69330d112cc7d632;hb=9dfd320ff258071e3ad78dd6cf2d76e215efd4f7;hp=0808bd1da9328aae5e2bf972492458e098927038;hpb=7d5fbd92062883ddd2f77167d7b91138ef17aee0;p=kivitendo-erp.git diff --git a/SL/Request.pm b/SL/Request.pm index 0808bd1da..7c4fa7198 100644 --- a/SL/Request.pm +++ b/SL/Request.pm @@ -20,7 +20,7 @@ our @EXPORT_OK = qw(flatten unflatten); use Rose::Object::MakeMethods::Generic ( scalar => [ qw(applying_database_upgrades post_data) ], - 'scalar --get_set_init' => [ qw(cgi layout presenter is_ajax type) ], + 'scalar --get_set_init' => [ qw(cgi layout presenter is_ajax is_mobile type) ], ); sub init_cgi { @@ -39,6 +39,12 @@ sub init_is_ajax { return ($ENV{HTTP_X_REQUESTED_WITH} || '') eq 'XMLHttpRequest' ? 1 : 0; } +sub init_is_mobile { + # mobile clients will change their user agent when the user requests + # desktop version so user agent is the most reliable way to identify + return ($ENV{HTTP_USER_AGENT} || '') =~ /Mobi/ ? 1 : 0; +} + sub init_type { return 'html'; } @@ -308,7 +314,7 @@ sub read_cgi_input { $target->{$_} = $self->post_data->{$_} for keys %{ $self->post_data }; - } elsif (($ENV{CONTENT_TYPE} // '') eq 'application/json') { + } elsif (($ENV{CONTENT_TYPE} // '') =~ m{^application/json}i) { $self->post_data(_parse_json_formdata($content)); } else {