class MobileProfilePlugin extends WAP20Plugin
{
- public $DTDversion = null;
+ public $DTD = null;
public $serveMobile = false;
function __construct($DTD='http://www.wapforum.org/DTD/xhtml-mobile10.dtd')
// If they are okay with MP, and the site has a mobile server,
// redirect there
if ($this->serveMobile &&
- common_config('site', 'mobileserver') !== false) {
+ common_config('site', 'mobileserver') !== false &&
+ (common_config('site', 'mobileserver') !=
+ common_config('site', 'server'))) {
- header("Location: ".common_config('site', 'mobileserver'));
+ // FIXME: Redirect to equivalent page on mobile site instead
+ header("Location: ".$this->_common_path(''));
exit();
}
}
}
+ function onStartShowStatusNetStyles($action) {
+ if (file_exists(theme_file('css/mp-screen.css'))) {
+ $action->cssLink('css/mp-screen.css', null, 'screen');
+ }
+ else {
+ $action->element('link', array('rel' => 'stylesheet',
+ 'type' => 'text/css',
+ 'href' => common_path('plugins/MobileProfile/mp-screen.css') . '?version=' . STATUSNET_VERSION,
+ 'media' => 'screen'));
+ }
+
+ if (file_exists(theme_file('css/mp-handheld.css'))) {
+ $action->cssLink('css/mp-handheld.css', null, 'handheld');
+ }
+ else {
+ $action->element('link', array('rel' => 'stylesheet',
+ 'type' => 'text/css',
+ 'href' => common_path('plugins/MobileProfile/mp-handheld.css') . '?version=' . STATUSNET_VERSION,
+ 'media' => 'handheld'));
+ }
+
+ return false;
+ }
+
function onStartShowAside($action)
{
-
+ if ($this->serveMobile) {
+ return false;
+ }
}
}
+
+ function _common_path($relative, $ssl=false)
+ {
+ $pathpart = (common_config('site', 'path')) ? common_config('site', 'path')."/" : '';
+
+ if (($ssl && (common_config('site', 'ssl') === 'sometimes'))
+ || common_config('site', 'ssl') === 'always') {
+ $proto = 'https';
+ if (is_string(common_config('site', 'sslserver')) &&
+ mb_strlen(common_config('site', 'sslserver')) > 0) {
+ $serverpart = common_config('site', 'sslserver');
+ } else {
+ $serverpart = common_config('site', 'mobileserver');
+ }
+ } else {
+ $proto = 'http';
+ $serverpart = common_config('site', 'mobileserver');
+ }
+
+ return $proto.'://'.$serverpart.'/'.$pathpart.$relative;
+ }
}