GroupFavoritedPlugin.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /*
  3. * StatusNet - the distributed open-source microblogging tool
  4. * Copyright (C) 2010, StatusNet, Inc.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * @package GroupFavoritedPlugin
  21. * @maintainer Brion Vibber <brion@status.net>
  22. */
  23. if (!defined('STATUSNET')) { exit(1); }
  24. class GroupFavoritedPlugin extends Plugin
  25. {
  26. /**
  27. * Hook for RouterInitialized event.
  28. *
  29. * @param URLMapper $m path-to-action mapper
  30. * @return boolean hook return
  31. */
  32. function onRouterInitialized(URLMapper $m)
  33. {
  34. $m->connect('group/:nickname/favorited',
  35. array('action' => 'groupfavorited'),
  36. array('nickname' => '[a-zA-Z0-9]+'));
  37. return true;
  38. }
  39. function onEndGroupGroupNav(Menu $nav)
  40. {
  41. $action_name = $nav->action->trimmed('action');
  42. $nickname = $nav->group->nickname;
  43. $nav->out->menuItem(common_local_url('groupfavorited', array('nickname' =>
  44. $nickname)),
  45. // TRANS: Menu item in the group navigation page.
  46. _m('MENU', 'Popular'),
  47. // TRANS: Tooltip for menu item in the group navigation page.
  48. // TRANS: %s is the nickname of the group.
  49. sprintf(_m('TOOLTIP','Popular notices in %s group'), $nickname),
  50. $action_name == 'groupfavorited',
  51. 'nav_group_group');
  52. }
  53. /**
  54. * Provide plugin version information.
  55. *
  56. * This data is used when showing the version page.
  57. *
  58. * @param array &$versions array of version data arrays; see EVENTS.txt
  59. *
  60. * @return boolean hook value
  61. */
  62. function onPluginVersion(array &$versions)
  63. {
  64. $url = 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/GroupFavorited';
  65. $versions[] = array('name' => 'GroupFavorited',
  66. 'version' => GNUSOCIAL_VERSION,
  67. 'author' => 'Brion Vibber',
  68. 'homepage' => $url,
  69. 'rawdescription' =>
  70. // TRANS: Plugin description.
  71. _m('This plugin adds a menu item for popular notices in groups.'));
  72. return true;
  73. }
  74. }