+
+ public function onStartInitializeRouter(URLMapper $m)
+ {
+ $m->connect('settings/linkback', array('action' => 'linkbacksettings'));
+ return true;
+ }
+
+ function onEndAccountSettingsNav($action)
+ {
+ $action_name = $action->trimmed('action');
+
+ $action->menuItem(common_local_url('linkbacksettings'),
+ // TRANS: OpenID plugin menu item on user settings page.
+ _m('MENU', 'Send Linkbacks'),
+ // TRANS: OpenID plugin tooltip for user settings menu item.
+ _m('Opt-out of sending linkbacks.'),
+ $action_name === 'linkbacksettings');
+ return true;
+ }
+
+ function onStartNoticeSourceLink($notice, &$name, &$url, &$title)
+ {
+ // If we don't handle this, keep the event handler going
+ if (!in_array($notice->source, array('linkback'))) {
+ return true;
+ }
+
+ try {
+ $url = $notice->getUrl();
+ // If getUrl() throws exception, $url is never set
+
+ $bits = parse_url($url);
+ $domain = $bits['host'];
+ if (substr($domain, 0, 4) == 'www.') {
+ $name = substr($domain, 4);
+ } else {
+ $name = $domain;
+ }
+
+ // TRANS: Title. %s is a domain name.
+ $title = sprintf(_m('Sent from %s via Linkback'), $domain);
+
+ // Abort event handler, we have a name and URL!
+ return false;
+ } catch (InvalidUrlException $e) {
+ // This just means we don't have the notice source data
+ return true;
+ }
+ }