]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Facebook/FacebookPlugin.php
Merge branch 'testing'
[quix0rs-gnu-social.git] / plugins / Facebook / FacebookPlugin.php
index cd1ad7b45e7cba2f8e480145db822e14df083daf..39b2ef28767641e08322256fbca42cc70b9ccc12 100644 (file)
@@ -58,7 +58,7 @@ class FacebookPlugin extends Plugin
      * @return boolean hook return
      */
 
-    function onRouterInitialized($m)
+    function onStartInitializeRouter($m)
     {
 
         // Facebook App stuff
@@ -182,10 +182,9 @@ class FacebookPlugin extends Plugin
             $login_url  = common_local_url('FBConnectAuth');
             $logout_url = common_local_url('logout');
 
-            // XXX: Facebook says we do not need this FB_RequireFeatures(),
+            // XXX: Facebook says we don't need this FB_RequireFeatures(),
             // but we actually do, for IE and Safari. Gar.
 
-            $js  = '<script type="text/javascript">';
             $js .= '    $(document).ready(function () {';
             $js .= '         FB_RequireFeatures(';
             $js .= '             ["XFBML"], function() {';
@@ -201,7 +200,7 @@ class FacebookPlugin extends Plugin
             // The below function alters the logout link so that it logs the user out
             // of Facebook Connect as well as the site.  However, for some pages
             // (FB Connect Settings) we need to output the FB Connect scripts (to
-            // show an existing FB connection even if the user is not authenticated
+            // show an existing FB connection even if the user isn't authenticated
             // with Facebook connect) but NOT alter the logout link. And the only
             // way to reliably do that is with the FB Connect .js libs.  Crazy.
 
@@ -219,7 +218,6 @@ class FacebookPlugin extends Plugin
             $js .= '            }';
             $js .= '        );';
             $js .= '     });';
-            $js .= '</script>';
 
             $js = sprintf($js, $apikey, $login_url, $logout_url);
 
@@ -227,7 +225,7 @@ class FacebookPlugin extends Plugin
 
             $js = str_replace('  ', '', $js);
 
-            $action->raw("  $js");  // leading two spaces to make it line up
+            $action->inlineScript($js);
         }
 
     }
@@ -394,37 +392,43 @@ class FacebookPlugin extends Plugin
         return true;
     }
 
-    /**
-     * Alter the local nav menu to have a Facebook Connect login and
-     * settings pages
+    /*
+     * Add a login tab for Facebook Connect
      *
-     * @param Action $action the current action
+     * @param Action &action the current action
      *
      * @return void
-     *
      */
 
-    function onStartShowLocalNavBlock($action)
+    function onEndLoginGroupNav(&$action)
     {
-        $action_name = get_class($action);
 
-        $login_actions = array('LoginAction', 'RegisterAction',
-            'OpenidloginAction', 'FBConnectLoginAction');
+        $action_name = $action->trimmed('action');
 
-        if (in_array($action_name, $login_actions)) {
-            $nav = new FBCLoginGroupNav($action);
-            $nav->show();
-            return false;
-        }
+        $action->menuItem(common_local_url('FBConnectLogin'),
+                                           _m('Facebook'),
+                                           _m('Login or register using Facebook'),
+                                           'FBConnectLogin' === $action_name);
 
-        $connect_actions = array('SmssettingsAction', 'ImsettingsAction',
-            'TwittersettingsAction', 'FBConnectSettingsAction');
+        return true;
+    }
 
-        if (in_array($action_name, $connect_actions)) {
-            $nav = new FBCSettingsNav($action);
-            $nav->show();
-            return false;
-        }
+    /*
+     * Add a tab for managing Facebook Connect settings
+     *
+     * @param Action &action the current action
+     *
+     * @return void
+     */
+
+    function onEndConnectSettingsNav(&$action)
+    {
+        $action_name = $action->trimmed('action');
+
+        $action->menuItem(common_local_url('FBConnectSettings'),
+                          _m('Facebook'),
+                          _m('Facebook Connect Settings'),
+                          $action_name === 'FBConnectSettings');
 
         return true;
     }