]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/MobileProfile/MobileProfilePlugin.php
Added ability to define mobile stylesheets (handheld, screen) at the
[quix0rs-gnu-social.git] / plugins / MobileProfile / MobileProfilePlugin.php
index cd88a6f7b7383f7897bb06f8e55b659a3cb6492f..35756cfe79e425d16f22585f03f066ea48dd9429 100644 (file)
@@ -49,7 +49,7 @@ require_once INSTALLDIR.'/plugins/Mobile/WAP20Plugin.php';
 
 class MobileProfilePlugin extends WAP20Plugin
 {
-    public $DTD      = null;
+    public $DTD             = null;
     public $serveMobile     = false;
 
     function __construct($DTD='http://www.wapforum.org/DTD/xhtml-mobile10.dtd')
@@ -131,9 +131,12 @@ class MobileProfilePlugin extends WAP20Plugin
             // 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();
             }
         }
@@ -155,10 +158,36 @@ class MobileProfilePlugin extends WAP20Plugin
     }
 
 
+    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;
+        }
     }
 
 
@@ -167,6 +196,27 @@ class MobileProfilePlugin extends WAP20Plugin
 
     }
 
+
+    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;
+    }
 }