]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/MobileProfile/MobileProfilePlugin.php
use bigint for status_ids
[quix0rs-gnu-social.git] / plugins / MobileProfile / MobileProfilePlugin.php
index 14d2500e8fdc4859d880b46f2e24204ed3291355..72a6a04fbd9ac27a7f428d361b5179b751cab0e8 100644 (file)
@@ -73,9 +73,11 @@ class MobileProfilePlugin extends WAP20Plugin
             $this->serveMobile = true;
         } else {
             // If they like the WAP 2.0 mimetype, serve them MP
-            if (strstr('application/vnd.wap.xhtml+xml', $type) !== false) {
-                $this->serveMobile = true;
-            } else {
+            // @fixme $type is undefined, making this if case useless and spewing errors.
+            // What's the intent?
+            //if (strstr('application/vnd.wap.xhtml+xml', $type) !== false) {
+            //    $this->serveMobile = true;
+            //} else {
                 // If they are a mobile device that supports WAP 2.0, 
                 // serve them MP
 
@@ -136,11 +138,23 @@ class MobileProfilePlugin extends WAP20Plugin
                     'vodafone',
                     'wap1',
                     'wap2',
+                    'webos',
                     'windows ce'
                 );
 
+                $blacklist = array(
+                    'ipad', // Larger screen handles the full theme fairly well.
+                );
+
                 $httpuseragent = strtolower($_SERVER['HTTP_USER_AGENT']);
 
+                foreach ($blacklist as $md) {
+                    if (strstr($httpuseragent, $md) !== false) {
+                        $this->serveMobile = false;
+                        return true;
+                    }
+                }
+
                 foreach ($this->mobiledevices as $md) {
                     if (strstr($httpuseragent, $md) !== false) {
                         $this->setMobileFeatures($httpuseragent);
@@ -149,7 +163,7 @@ class MobileProfilePlugin extends WAP20Plugin
                         break;
                     }
                 }
-            }
+            //}
 
             // If they are okay with MP, and the site has a mobile server, 
             // redirect there
@@ -167,7 +181,9 @@ class MobileProfilePlugin extends WAP20Plugin
             return true;
         }
 
-        if (!$type) {
+        // @fixme $type is undefined, making this if case useless and spewing errors.
+        // What's the intent?
+        //if (!$type) {
             $httpaccept = isset($_SERVER['HTTP_ACCEPT']) ?
               $_SERVER['HTTP_ACCEPT'] : null;
 
@@ -180,7 +196,7 @@ class MobileProfilePlugin extends WAP20Plugin
                 throw new ClientException(_('This page is not available in a '.
                                             'media type you accept'), 406);
             }
-        }
+        //}
 
         header('Content-Type: '.$type);
 
@@ -219,27 +235,14 @@ class MobileProfilePlugin extends WAP20Plugin
     }
 
 
-    function onStartShowHeadElements($action)
-    {
-        if (!$action->serveMobile) {
-            return true;
-        }
-
-        $action->showTitle();
-        $action->showShortcutIcon();
-        $action->showStylesheets();
-        $action->showFeeds();
-        $action->showDescription();
-        $action->extraHead();
-    }
-
-
     function onStartShowStatusNetStyles($action)
     {
         if (!$this->serveMobile) {
             return true;
         }
 
+        $action->primaryCssLink();
+
         if (file_exists(Theme::file('css/mp-screen.css'))) {
             $action->cssLink('css/mp-screen.css', null, 'screen');
         } else {
@@ -252,10 +255,22 @@ class MobileProfilePlugin extends WAP20Plugin
             $action->cssLink('plugins/MobileProfile/mp-handheld.css',null,'handheld');
         }
 
+        // Allow other plugins to load their styles.
+        Event::handle('EndShowStatusNetStyles', array($action));
+        Event::handle('EndShowLaconicaStyles', array($action));
+
         return false;
     }
 
 
+    function onStartShowUAStyles($action) {
+        if (!$this->serveMobile) {
+            return true;
+        }
+
+        return false;
+    }
+
     function onStartShowHeader($action)
     {
         if (!$this->serveMobile) {
@@ -297,25 +312,14 @@ class MobileProfilePlugin extends WAP20Plugin
     function _showPrimaryNav($action)
     {
         $user    = common_current_user();
-        $connect = '';
-        if (common_config('xmpp', 'enabled')) {
-            $connect = 'imsettings';
-        } else if (common_config('sms', 'enabled')) {
-            $connect = 'smssettings';
-        } else if (common_config('twitter', 'enabled')) {
-            $connect = 'twittersettings';
-        }
-
         $action->elementStart('ul', array('id' => 'site_nav_global_primary'));
         if ($user) {
             $action->menuItem(common_local_url('all', array('nickname' => $user->nickname)),
                             _('Home'));
             $action->menuItem(common_local_url('profilesettings'),
                             _('Account'));
-            if ($connect) {
-                $action->menuItem(common_local_url($connect),
+            $action->menuItem(common_local_url('oauthconnectionssettings'),
                                 _('Connect'));
-            }
             if ($user->hasRight(Right::CONFIGURESITE)) {
                 $action->menuItem(common_local_url('siteadminpanel'),
                                 _('Admin'), _('Change site configuration'), false, 'nav_admin');
@@ -356,8 +360,6 @@ class MobileProfilePlugin extends WAP20Plugin
 
         $contentLimit = Notice::maxContent();
 
-        $form->out->inlineScript('maxLength = ' . $contentLimit . ';');
-
         if ($contentLimit > 0) {
             $form->out->element('div', array('id' => 'notice_text-count'),
                                 $contentLimit);
@@ -416,7 +418,15 @@ class MobileProfilePlugin extends WAP20Plugin
 
         return $proto.'://'.$serverpart.'/'.$pathpart.$relative;
     }
-}
 
-
-?>
+    function onPluginVersion(&$versions)
+    {
+        $versions[] = array('name' => 'MobileProfile',
+                            'version' => STATUSNET_VERSION,
+                            'author' => 'Sarven Capadisli',
+                            'homepage' => 'http://status.net/wiki/Plugin:MobileProfile',
+                            'rawdescription' =>
+                            _m('XHTML MobileProfile output for supporting user agents.'));
+        return true;
+    }
+}