]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/MobileProfile/MobileProfilePlugin.php
Comment out unreachable code spewing notices due to use of undefined variables in...
[quix0rs-gnu-social.git] / plugins / MobileProfile / MobileProfilePlugin.php
index bc67a3f369d6ce350e6b41aed7e80a9b816f59a1..a104eadd7be37e323f0988de676f73c149087a22 100644 (file)
@@ -31,7 +31,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
-define('PAGE_TYPE_PREFS',
+define('PAGE_TYPE_PREFS_MOBILEPROFILE',
        'application/vnd.wap.xhtml+xml, application/xhtml+xml, text/html;q=0.9');
 
 require_once INSTALLDIR.'/plugins/Mobile/WAP20Plugin.php';
@@ -63,9 +63,6 @@ class MobileProfilePlugin extends WAP20Plugin
 
     function onStartShowHTML($action)
     {
-
-
-
         // XXX: This should probably graduate to WAP20Plugin
 
         // If they are on the mobile site, serve them MP
@@ -76,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
 
@@ -152,7 +151,7 @@ class MobileProfilePlugin extends WAP20Plugin
                         break;
                     }
                 }
-            }
+            //}
 
             // If they are okay with MP, and the site has a mobile server, 
             // redirect there
@@ -162,8 +161,7 @@ class MobileProfilePlugin extends WAP20Plugin
                     common_config('site', 'server'))) {
 
                 // FIXME: Redirect to equivalent page on mobile site instead
-                header("Location: ".$this->_common_path(''));
-                exit();
+                common_redirect($this->_common_path(''), 302);
             }
         }
 
@@ -171,12 +169,14 @@ 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;
 
             $cp = common_accept_to_prefs($httpaccept);
-            $sp = common_accept_to_prefs(PAGE_TYPE_PREFS);
+            $sp = common_accept_to_prefs(PAGE_TYPE_PREFS_MOBILEPROFILE);
 
             $type = common_negotiate_type($cp, $sp);
 
@@ -184,16 +184,16 @@ class MobileProfilePlugin extends WAP20Plugin
                 throw new ClientException(_('This page is not available in a '.
                                             'media type you accept'), 406);
             }
-        }
+        //}
 
         header('Content-Type: '.$type);
 
-        $this->extraHeaders();
+        $action->extraHeaders();
         if (preg_match("/.*\/.*xml/", $type)) {
             // Required for XML documents
-            $this->xw->startDocument('1.0', 'UTF-8');
+            $action->xw->startDocument('1.0', 'UTF-8');
         }
-        $this->xw->writeDTD('html',
+        $action->xw->writeDTD('html',
                         '-//WAPFORUM//DTD XHTML Mobile 1.0//EN',
                         $this->DTD);
 
@@ -225,9 +225,12 @@ class MobileProfilePlugin extends WAP20Plugin
 
     function onStartShowHeadElements($action)
     {
-        if (!$action->serveMobile) {
-            return true;
-        }
+        // @fixme nothing appears to set a serveMobile on any action,
+        // so this is useless and spews errors. Is this supposed to be
+        // checking $this?
+        //if (!$action->serveMobile) {
+        //    return true;
+        //}
 
         $action->showTitle();
         $action->showShortcutIcon();
@@ -244,28 +247,32 @@ class MobileProfilePlugin extends WAP20Plugin
             return true;
         }
 
+        $action->cssLink('css/display.css');
+
         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'));
+            $action->cssLink('plugins/MobileProfile/mp-screen.css',null,'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'));
+            $action->cssLink('plugins/MobileProfile/mp-handheld.css',null,'handheld');
         }
 
         return false;
     }
 
 
+    function onStartShowUAStyles($action) {
+        if (!$this->serveMobile) {
+            return true;
+        }
+
+        return false;
+    }
+
     function onStartShowHeader($action)
     {
         if (!$this->serveMobile) {
@@ -291,7 +298,7 @@ class MobileProfilePlugin extends WAP20Plugin
                                        'href' => common_local_url('public')));
         if (common_config('site', 'mobilelogo') || 
             file_exists(Theme::file('logo.png')) || 
-            file_exists(Theme::file('mobilelogo.gif'))) {
+            file_exists(Theme::file('mobilelogo.png'))) {
 
             $action->element('img', array('class' => 'photo',
                 'src' => (common_config('site', 'mobilelogo')) ? common_config('site', 'mobilelogo') : 
@@ -307,24 +314,17 @@ 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');
             }
             if (common_config('invite', 'enabled')) {
                 $action->menuItem(common_local_url('invite'),
@@ -362,9 +362,6 @@ class MobileProfilePlugin extends WAP20Plugin
 
         $contentLimit = Notice::maxContent();
 
-        $form->out->element('script', array('type' => 'text/javascript'),
-                            'maxLength = ' . $contentLimit . ';');
-
         if ($contentLimit > 0) {
             $form->out->element('div', array('id' => 'notice_text-count'),
                                 $contentLimit);
@@ -423,7 +420,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;
+    }
+}