adminpanelnav.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /**
  3. * StatusNet - the distributed open-source microblogging tool
  4. * Copyright (C) 2011, StatusNet, Inc.
  5. *
  6. * Menu for admin panels
  7. *
  8. * PHP version 5
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. * @category Menu
  24. * @package StatusNet
  25. * @author Evan Prodromou <evan@status.net>
  26. * @copyright 2011 StatusNet, Inc.
  27. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  28. * @link http://status.net/
  29. */
  30. if (!defined('STATUSNET')) {
  31. // This check helps protect against security problems;
  32. // your code file can't be executed directly from the web.
  33. exit(1);
  34. }
  35. /**
  36. * Menu for admin panels
  37. *
  38. * @category Output
  39. * @package StatusNet
  40. * @author Evan Prodromou <evan@status.net>
  41. * @author Sarven Capadisli <csarven@status.net>
  42. * @copyright 2011 StatusNet, Inc.
  43. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  44. * @link http://status.net/
  45. */
  46. class AdminPanelNav extends Menu
  47. {
  48. /**
  49. * Show the menu
  50. *
  51. * @return void
  52. */
  53. function show()
  54. {
  55. $action_name = $this->action->trimmed('action');
  56. $user = common_current_user();
  57. $nickname = $user->nickname;
  58. $name = $user->getProfile()->getBestName();
  59. // Stub section w/ home link
  60. $this->action->elementStart('ul');
  61. $this->action->elementStart('li');
  62. // TRANS: Header in administrator navigation panel.
  63. $this->action->element('h3', null, _m('HEADER','Home'));
  64. $this->action->elementStart('ul', 'nav');
  65. $this->out->menuItem(common_local_url('all', array('nickname' =>
  66. $nickname)),
  67. // TRANS: Menu item in administrator navigation panel.
  68. _m('MENU','Home'),
  69. // TRANS: Menu item title in administrator navigation panel.
  70. // TRANS: %s is a username.
  71. sprintf(_('%s and friends'), $name),
  72. $this->action == 'all', 'nav_timeline_personal');
  73. $this->action->elementEnd('ul');
  74. $this->action->elementEnd('li');
  75. $this->action->elementEnd('ul');
  76. $this->action->elementStart('ul');
  77. $this->action->elementStart('li');
  78. // TRANS: Header in administrator navigation panel.
  79. $this->action->element('h3', null, _m('HEADER','Admin'));
  80. $this->action->elementStart('ul', array('class' => 'nav'));
  81. if (Event::handle('StartAdminPanelNav', array($this))) {
  82. if (AdminPanelAction::canAdmin('site')) {
  83. // TRANS: Menu item title in administrator navigation panel.
  84. $menu_title = _('Basic site configuration');
  85. // TRANS: Menu item in administrator navigation panel.
  86. $this->out->menuItem(common_local_url('siteadminpanel'), _m('MENU', 'Site'),
  87. $menu_title, $action_name == 'siteadminpanel', 'nav_site_admin_panel');
  88. }
  89. if (AdminPanelAction::canAdmin('user')) {
  90. // TRANS: Menu item title in administrator navigation panel.
  91. $menu_title = _('User configuration');
  92. // TRANS: Menu item in administrator navigation panel.
  93. $this->out->menuItem(common_local_url('useradminpanel'), _m('MENU','User'),
  94. $menu_title, $action_name == 'useradminpanel', 'nav_user_admin_panel');
  95. }
  96. if (AdminPanelAction::canAdmin('access')) {
  97. // TRANS: Menu item title in administrator navigation panel.
  98. $menu_title = _('Access configuration');
  99. // TRANS: Menu item in administrator navigation panel.
  100. $this->out->menuItem(common_local_url('accessadminpanel'), _m('MENU','Access'),
  101. $menu_title, $action_name == 'accessadminpanel', 'nav_access_admin_panel');
  102. }
  103. if (AdminPanelAction::canAdmin('paths')) {
  104. // TRANS: Menu item title in administrator navigation panel.
  105. $menu_title = _('Paths configuration');
  106. // TRANS: Menu item in administrator navigation panel.
  107. $this->out->menuItem(common_local_url('pathsadminpanel'), _m('MENU','Paths'),
  108. $menu_title, $action_name == 'pathsadminpanel', 'nav_paths_admin_panel');
  109. }
  110. if (AdminPanelAction::canAdmin('sessions')) {
  111. // TRANS: Menu item title in administrator navigation panel.
  112. $menu_title = _('Sessions configuration');
  113. // TRANS: Menu item in administrator navigation panel.
  114. $this->out->menuItem(common_local_url('sessionsadminpanel'), _m('MENU','Sessions'),
  115. $menu_title, $action_name == 'sessionsadminpanel', 'nav_sessions_admin_panel');
  116. }
  117. if (AdminPanelAction::canAdmin('sitenotice')) {
  118. // TRANS: Menu item title in administrator navigation panel.
  119. $menu_title = _('Edit site notice');
  120. // TRANS: Menu item in administrator navigation panel.
  121. $this->out->menuItem(common_local_url('sitenoticeadminpanel'), _m('MENU','Site notice'),
  122. $menu_title, $action_name == 'sitenoticeadminpanel', 'nav_sitenotice_admin_panel');
  123. }
  124. if (AdminPanelAction::canAdmin('license')) {
  125. // TRANS: Menu item title in administrator navigation panel.
  126. $menu_title = _('Set site license');
  127. // TRANS: Menu item in administrator navigation panel.
  128. $this->out->menuItem(common_local_url('licenseadminpanel'), _m('MENU','License'),
  129. $menu_title, $action_name == 'licenseadminpanel', 'nav_license_admin_panel');
  130. }
  131. if (AdminPanelAction::canAdmin('plugins')) {
  132. // TRANS: Menu item title in administrator navigation panel.
  133. $menu_title = _('Plugins configuration');
  134. // TRANS: Menu item in administrator navigation panel.
  135. $this->out->menuItem(common_local_url('pluginsadminpanel'), _m('MENU','Plugins'),
  136. $menu_title, $action_name == 'pluginsadminpanel', 'nav_plugin_admin_panel');
  137. }
  138. Event::handle('EndAdminPanelNav', array($this));
  139. }
  140. $this->action->elementEnd('ul');
  141. $this->action->elementEnd('li');
  142. $this->action->elementEnd('ul');
  143. }
  144. }