GroupFavoritedPlugin.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. const PLUGIN_VERSION = '2.0.0';
  27. /**
  28. * Hook for RouterInitialized event.
  29. *
  30. * @param URLMapper $m path-to-action mapper
  31. * @return boolean hook return
  32. */
  33. function onRouterInitialized(URLMapper $m)
  34. {
  35. $m->connect('group/:nickname/favorited',
  36. ['action' => 'groupfavorited'],
  37. ['nickname' => '[a-zA-Z0-9]+']);
  38. return true;
  39. }
  40. function onEndGroupGroupNav(Menu $nav)
  41. {
  42. $action_name = $nav->action->trimmed('action');
  43. $nickname = $nav->group->nickname;
  44. $nav->out->menuItem(common_local_url('groupfavorited', array('nickname' =>
  45. $nickname)),
  46. // TRANS: Menu item in the group navigation page.
  47. _m('MENU', 'Popular'),
  48. // TRANS: Tooltip for menu item in the group navigation page.
  49. // TRANS: %s is the nickname of the group.
  50. sprintf(_m('TOOLTIP','Popular notices in %s group'), $nickname),
  51. $action_name == 'groupfavorited',
  52. 'nav_group_group');
  53. }
  54. /**
  55. * Provide plugin version information.
  56. *
  57. * This data is used when showing the version page.
  58. *
  59. * @param array &$versions array of version data arrays; see EVENTS.txt
  60. *
  61. * @return boolean hook value
  62. */
  63. function onPluginVersion(array &$versions)
  64. {
  65. $url = 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/GroupFavorited';
  66. $versions[] = array('name' => 'GroupFavorited',
  67. 'version' => self::PLUGIN_VERSION,
  68. 'author' => 'Brion Vibber',
  69. 'homepage' => $url,
  70. 'rawdescription' =>
  71. // TRANS: Plugin description.
  72. _m('This plugin adds a menu item for popular notices in groups.'));
  73. return true;
  74. }
  75. }