+
+ /**
+ * Hook for RouterInitialized event.
+ *
+ * @param URLMapper $m path-to-action mapper
+ * @return boolean hook return
+ */
+ public function onRouterInitialized(URLMapper $m)
+ {
+ $m->connect('panel/bitly',
+ array('action' => 'bitlyadminpanel'));
+ return true;
+ }
+
+ /**
+ * If the plugin's installed, this should be accessible to admins.
+ */
+ function onAdminPanelCheck($name, &$isOK)
+ {
+ if ($name == 'bitly') {
+ $isOK = true;
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Add the bit.ly admin panel to the list...
+ */
+ function onEndAdminPanelNav(Menu $nav)
+ {
+ if (AdminPanelAction::canAdmin('bitly')) {
+ $action_name = $nav->action->trimmed('action');
+
+ $nav->out->menuItem(common_local_url('bitlyadminpanel'),
+ // TRANS: Menu item in administration menus for bit.ly URL shortening settings.
+ _m('bit.ly'),
+ // TRANS: Title for menu item in administration menus for bit.ly URL shortening settings.
+ _m('bit.ly URL shortening.'),
+ $action_name == 'bitlyadminpanel',
+ 'nav_bitly_admin_panel');
+ }
+
+ return true;
+ }
+
+ /**
+ * Internal hook point to check the default global credentials so
+ * the admin form knows if we have a fallback or not.
+ *
+ * @param string $login
+ * @param string $apiKey
+ * @return boolean hook return value
+ */
+ function onBitlyDefaultCredentials(&$login, &$apiKey)
+ {
+ $login = $this->login;
+ $apiKey = $this->apiKey;
+ return false;
+ }
+