summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSarven Capadisli <csarven@status.net>2009-11-19 20:47:05 +0000
committerSarven Capadisli <csarven@status.net>2009-11-19 20:47:05 +0000
commit3ff5dd6989739ac5c501d9d2016c82c66de87490 (patch)
treeb0e2e3b21fa91aab0f2b88de073278efe7432310 /plugins
parent93f6981b71c5fe4445352ca83a01a964fca9f078 (diff)
Doing content negotiation only once
Diffstat (limited to 'plugins')
-rw-r--r--plugins/MobileProfile/MobileProfilePlugin.php37
1 files changed, 21 insertions, 16 deletions
diff --git a/plugins/MobileProfile/MobileProfilePlugin.php b/plugins/MobileProfile/MobileProfilePlugin.php
index e39edc86c..bc67a3f36 100644
--- a/plugins/MobileProfile/MobileProfilePlugin.php
+++ b/plugins/MobileProfile/MobileProfilePlugin.php
@@ -64,20 +64,7 @@ class MobileProfilePlugin extends WAP20Plugin
function onStartShowHTML($action)
{
- if (!$type) {
- $httpaccept = isset($_SERVER['HTTP_ACCEPT']) ?
- $_SERVER['HTTP_ACCEPT'] : null;
-
- $cp = common_accept_to_prefs($httpaccept);
- $sp = common_accept_to_prefs(PAGE_TYPE_PREFS);
- $type = common_negotiate_type($cp, $sp);
-
- if (!$type) {
- throw new ClientException(_('This page is not available in a '.
- 'media type you accept'), 406);
- }
- }
// XXX: This should probably graduate to WAP20Plugin
@@ -184,11 +171,29 @@ class MobileProfilePlugin extends WAP20Plugin
return true;
}
- header('Content-Type: '.$type);
+ if (!$type) {
+ $httpaccept = isset($_SERVER['HTTP_ACCEPT']) ?
+ $_SERVER['HTTP_ACCEPT'] : null;
+
+ $cp = common_accept_to_prefs($httpaccept);
+ $sp = common_accept_to_prefs(PAGE_TYPE_PREFS);
- $action->extraHeaders();
+ $type = common_negotiate_type($cp, $sp);
- $action->startXML('html',
+ if (!$type) {
+ throw new ClientException(_('This page is not available in a '.
+ 'media type you accept'), 406);
+ }
+ }
+
+ header('Content-Type: '.$type);
+
+ $this->extraHeaders();
+ if (preg_match("/.*\/.*xml/", $type)) {
+ // Required for XML documents
+ $this->xw->startDocument('1.0', 'UTF-8');
+ }
+ $this->xw->writeDTD('html',
'-//WAPFORUM//DTD XHTML Mobile 1.0//EN',
$this->DTD);