]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/MobileProfile/MobileProfilePlugin.php
Notice form cleanup: removing hardcoded id from counter references; prep for reusable...
[quix0rs-gnu-social.git] / plugins / MobileProfile / MobileProfilePlugin.php
index b9c25ab998913d65cbf79ca2794a6f07ff30f9fc..fa0c4e7c22a12ada5d8f11d34369a49c0f48d6b1 100644 (file)
@@ -68,6 +68,9 @@ class MobileProfilePlugin extends WAP20Plugin
             $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'])) {
 
             $this->serveMobile = true;
+        } else if (isset($_COOKIE['MobileOverride'])) {
+            // Cookie override is controlled by link at bottom.
+            $this->serveMobile = (bool)$_COOKIE['MobileOverride'];
         } else {
             // If they like the WAP 2.0 mimetype, serve them MP
             // @fixme $type is undefined, making this if case useless and spewing errors.
@@ -352,7 +355,7 @@ class MobileProfilePlugin extends WAP20Plugin
         $contentLimit = Notice::maxContent();
 
         if ($contentLimit > 0) {
-            $form->out->element('div', array('id' => 'notice_text-count'),
+            $form->out->element('div', array('class' => 'count'),
                                 $contentLimit);
         }
 
@@ -381,9 +384,40 @@ class MobileProfilePlugin extends WAP20Plugin
         }
     }
 
-    function onStartShowScripts($action)
+    function onEndShowScripts($action)
     {
+        $action->inlineScript('
+            $(function() {
+                $("#mobile-toggle-disable").click(function() {
+                    $.cookie("MobileOverride", "0", {path: "/"});
+                    window.location.reload();
+                    return false;
+                });
+                $("#mobile-toggle-enable").click(function() {
+                    $.cookie("MobileOverride", "1", {path: "/"});
+                    window.location.reload();
+                    return false;
+                });
+            });'
+        );
+    }
 
+
+    function onEndShowInsideFooter($action)
+    {
+        if ($this->serveMobile) {
+            // TRANS: Link to switch site layout from mobile to desktop mode. Appears at very bottom of page.
+            $linkText = _m('Switch to desktop site layout.');
+            $key = 'mobile-toggle-disable';
+        } else {
+            // TRANS: Link to switch site layout from desktop to mobile mode. Appears at very bottom of page.
+            $linkText = _m('Switch to mobile site layout.');
+            $key = 'mobile-toggle-enable';
+        }
+        $action->elementStart('p');
+        $action->element('a', array('href' => '#', 'id' => $key), $linkText);
+        $action->elementEnd('p');
+        return true;
     }
 
     function _common_path($relative, $ssl=false)