* @return boolean hook return
*/
- function onRouterInitialized($m)
+ function onStartInitializeRouter($m)
{
// Facebook App stuff
$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() {';
// 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.
$js .= ' }';
$js .= ' );';
$js .= ' });';
- $js .= '</script>';
$js = sprintf($js, $apikey, $login_url, $logout_url);
$js = str_replace(' ', '', $js);
- $action->raw(" $js"); // leading two spaces to make it line up
+ $action->inlineScript($js);
}
}
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;
}