3 * StatusNet, the distributed open-source microblogging tool
5 * XHTML Mobile Profile plugin that uses WAP 2.0 Plugin
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Sarven Capadisli <csarven@status.net>
25 * @copyright 2009 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
34 define('PAGE_TYPE_PREFS',
35 'application/vnd.wap.xhtml+xml, application/xhtml+xml, text/xml;q=0.9'.
39 require_once INSTALLDIR.'/plugins/Mobile/WAP20Plugin.php';
43 * Superclass for plugin to output XHTML Mobile Profile
47 * @author Sarven Capadisli <csarven@status.net>
48 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
49 * @link http://status.net/
52 class MobileProfilePlugin extends WAP20Plugin
54 public $DTDversion = null;
55 public $serveMobile = false;
57 function __construct($DTD='http://www.wapforum.org/DTD/xhtml-mobile10.dtd')
61 parent::__construct();
65 function onStartShowHTML($action)
68 $httpaccept = isset($_SERVER['HTTP_ACCEPT']) ?
69 $_SERVER['HTTP_ACCEPT'] : null;
71 $cp = common_accept_to_prefs($httpaccept);
72 $sp = common_accept_to_prefs(PAGE_TYPE_PREFS);
74 $type = common_negotiate_type($cp, $sp);
77 throw new ClientException(_('This page is not available in a '.
78 'media type you accept'), 406);
82 // XXX: If user is on the mobile site e.g., m.siteserver.com
83 // or they really want it, serve the mobile version
85 // FIXME: This is dirty and probably not accurate of doing it
86 if ((common_config('site', 'mobileserver').'/'.common_config('site', 'path').'/' ==
87 $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']) ||
88 preg_match("/.*\/.*wap.*xml/", $type)) {
90 $this->serveMobile = true;
93 $this->serveMobile = false;
97 header('Content-Type: '.$type);
99 $action->extraHeaders();
101 $action->startXML('html',
102 '-//WAPFORUM//DTD XHTML Mobile 1.0//EN',
105 $language = $action->getLanguage();
107 $action->elementStart('html', array('xmlns' => 'http://www.w3.org/1999/xhtml',
108 'xml:lang' => $language));
115 function onStartShowAside($action)
121 function onStartShowScripts($action)