]> 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 d854b6e5e3165af1aa48206bb37206f72651c970..35756cfe79e425d16f22585f03f066ea48dd9429 100644 (file)
@@ -132,10 +132,11 @@ class MobileProfilePlugin extends WAP20Plugin
             // redirect there
             if ($this->serveMobile && 
                 common_config('site', 'mobileserver') !== false &&
-                common_config('site', 'mobileserver') != 
-                    common_config('site', 'server')) {
+                (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();
             }
         }
@@ -157,6 +158,30 @@ 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)
     {
@@ -171,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;
+    }
 }