+ function onPluginVersion(&$versions)
+ {
+ $versions[] = array('name' => sprintf('BitlyUrl (%s)', $this->shortenerName),
+ 'version' => STATUSNET_VERSION,
+ 'author' => 'Craig Andrews, Brion Vibber',
+ 'homepage' => 'http://status.net/wiki/Plugin:BitlyUrl',
+ 'rawdescription' =>
+ sprintf(_m('Uses <a href="http://%1$s/">%1$s</a> URL-shortener service.'),
+ $this->shortenerName));
+
+ return true;
+ }
+
+ /**
+ * Hook for RouterInitialized event.
+ *
+ * @param Net_URL_Mapper $m path-to-action mapper
+ * @return boolean hook return
+ */
+ function onRouterInitialized($m)
+ {
+ $m->connect('admin/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($nav)
+ {
+ if (AdminPanelAction::canAdmin('bitly')) {
+ $action_name = $nav->action->trimmed('action');
+
+ $nav->out->menuItem(common_local_url('bitlyadminpanel'),
+ _m('bit.ly'),
+ _m('bit.ly URL shortening'),
+ $action_name == 'bitlyadminpanel',
+ 'nav_bitly_admin_panel');
+ }
+
+ return true;
+ }
+
+ /**
+ * Automatically load the actions and libraries used by the plugin
+ *
+ * @param Class $cls the class
+ *
+ * @return boolean hook return
+ *
+ */
+ function onAutoload($cls)
+ {
+ $base = dirname(__FILE__);
+ $lower = strtolower($cls);
+ switch ($lower) {
+ case 'bitlyadminpanelaction':
+ require_once "$base/$lower.php";
+ return false;
+ default:
+ 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;
+ }
+
+}