From 2ecbae308d0fba0ace43009f0d062301b2a86c81 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 30 Sep 2010 15:56:38 -0700 Subject: GroupFavorited plugin: adds 'Popular' tab to group navigation showing a popular pages subset for just posts in the group. Not necessarily terribly efficient, should be tested and benchmarked on non-trivial sites --- plugins/GroupFavorited/GroupFavoritedPlugin.php | 79 +++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 plugins/GroupFavorited/GroupFavoritedPlugin.php (limited to 'plugins/GroupFavorited/GroupFavoritedPlugin.php') diff --git a/plugins/GroupFavorited/GroupFavoritedPlugin.php b/plugins/GroupFavorited/GroupFavoritedPlugin.php new file mode 100644 index 000000000..68815530a --- /dev/null +++ b/plugins/GroupFavorited/GroupFavoritedPlugin.php @@ -0,0 +1,79 @@ +. + */ + +/** + * @package GroupFavoritedPlugin + * @maintainer Brion Vibber + */ + +if (!defined('STATUSNET')) { exit(1); } + +class GroupFavoritedPlugin extends Plugin +{ + /** + * Hook for RouterInitialized event. + * + * @param Net_URL_Mapper $m path-to-action mapper + * @return boolean hook return + */ + function onRouterInitialized($m) + { + $m->connect('group/:nickname/favorited', + array('action' => 'groupfavorited'), + array('nickname' => '[a-zA-Z0-9]+')); + + 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 'groupfavoritedaction': + require_once "$base/$lower.php"; + return false; + default: + return true; + } + } + + function onEndGroupGroupNav(GroupNav $nav) + { + $action_name = $nav->action->trimmed('action'); + $nickname = $nav->group->nickname; + $nav->out->menuItem(common_local_url('groupfavorited', array('nickname' => + $nickname)), + // TRANS: Menu item in the group navigation page. + _m('MENU', 'Popular'), + // TRANS: Tooltip for menu item in the group navigation page. + // TRANS: %s is the nickname of the group. + sprintf(_m('TOOLTIP','Popular notices in %s group'), $nickname), + $action_name == 'groupfavorited', + 'nav_group_group'); + } +} -- cgit v1.2.3-54-g00ecf