Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

242 lines
8.2 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. <?php
  2. use Friendica\App;
  3. function nav(App $a) {
  4. /*
  5. *
  6. * Build page header and site navigation bars
  7. *
  8. */
  9. if(!(x($a->page,'nav')))
  10. $a->page['nav'] = '';
  11. $a->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), array());
  12. /*
  13. * Placeholder div for popup panel
  14. */
  15. $a->page['nav'] .= '<div id="panel" style="display: none;"></div>' ;
  16. $nav_info = nav_info($a);
  17. /*
  18. * Build the page
  19. */
  20. $tpl = get_markup_template('nav.tpl');
  21. $a->page['nav'] .= replace_macros($tpl, array(
  22. '$baseurl' => App::get_baseurl(),
  23. '$sitelocation' => $nav_info['sitelocation'],
  24. '$nav' => $nav_info['nav'],
  25. '$banner' => $nav_info['banner'],
  26. '$emptynotifications' => t('Nothing new here'),
  27. '$userinfo' => $nav_info['userinfo'],
  28. '$sel' => $a->nav_sel,
  29. '$apps' => $a->apps,
  30. '$clear_notifs' => t('Clear notifications'),
  31. '$search_hint' => t('@name, !forum, #tags, content')
  32. ));
  33. call_hooks('page_header', $a->page['nav']);
  34. }
  35. /**
  36. * @brief Prepares a list of navigation links
  37. *
  38. * @param App $a
  39. * @return array Navigation links
  40. * string 'sitelocation' => The webbie (username@site.com)
  41. * array 'nav' => Array of links used in the nav menu
  42. * string 'banner' => Formatted html link with banner image
  43. * array 'userinfo' => Array of user information (name, icon)
  44. */
  45. function nav_info(App $a)
  46. {
  47. $ssl_state = ((local_user()) ? true : false);
  48. /*
  49. * Our network is distributed, and as you visit friends some of the
  50. * sites look exactly the same - it isn't always easy to know where you are.
  51. * Display the current site location as a navigation aid.
  52. */
  53. $myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : '');
  54. $sitelocation = $myident . substr(App::get_baseurl($ssl_state), strpos(App::get_baseurl($ssl_state), '//') + 2 );
  55. // nav links: array of array('href', 'text', 'extra css classes', 'title')
  56. $nav = array();
  57. // Display login or logout
  58. $nav['usermenu'] = array();
  59. $userinfo = null;
  60. if (local_user()) {
  61. $nav['logout'] = array('logout', t('Logout'), '', t('End this session'));
  62. // user menu
  63. $nav['usermenu'][] = array('profile/' . $a->user['nickname'], t('Status'), '', t('Your posts and conversations'));
  64. $nav['usermenu'][] = array('profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), '', t('Your profile page'));
  65. $nav['usermenu'][] = array('photos/' . $a->user['nickname'], t('Photos'), '', t('Your photos'));
  66. $nav['usermenu'][] = array('videos/' . $a->user['nickname'], t('Videos'), '', t('Your videos'));
  67. $nav['usermenu'][] = array('events/', t('Events'), '', t('Your events'));
  68. $nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes'));
  69. // user info
  70. $r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self` = 1", intval($a->user['uid']));
  71. $userinfo = array(
  72. 'icon' => (dbm::is_result($r) ? $a->remove_baseurl($r[0]['micro']) : 'images/person-48.jpg'),
  73. 'name' => $a->user['username'],
  74. );
  75. } else {
  76. $nav['login'] = array('login', t('Login'), ($a->module == 'login' ? 'selected' : ''), t('Sign in'));
  77. }
  78. // "Home" should also take you home from an authenticated remote profile connection
  79. $homelink = get_my_url();
  80. if (! $homelink) {
  81. $homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : '');
  82. }
  83. if (($a->module != 'home') && (! (local_user()))) {
  84. $nav['home'] = array($homelink, t('Home'), '', t('Home Page'));
  85. }
  86. if (($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) {
  87. $nav['register'] = array('register', t('Register'), '', t('Create an account'));
  88. }
  89. $help_url = 'help';
  90. if (! get_config('system', 'hide_help')) {
  91. $nav['help'] = array($help_url, t('Help'), '', t('Help and documentation'));
  92. }
  93. if (count($a->apps) > 0) {
  94. $nav['apps'] = array('apps', t('Apps'), '', t('Addon applications, utilities, games'));
  95. }
  96. if (local_user() OR !get_config('system', 'local_search')) {
  97. $nav['search'] = array('search', t('Search'), '', t('Search site content'));
  98. $nav['searchoption'] = array(
  99. t('Full Text'),
  100. t('Tags'),
  101. t('Contacts'));
  102. if (get_config('system', 'poco_local_search')) {
  103. $nav['searchoption'][] = t('Forums');
  104. }
  105. }
  106. $gdirpath = 'directory';
  107. if (strlen(get_config('system', 'singleuser'))) {
  108. $gdir = get_config('system', 'directory');
  109. if(strlen($gdir)) {
  110. $gdirpath = zrl($gdir, true);
  111. }
  112. } elseif (get_config('system', 'community_page_style') == CP_USERS_ON_SERVER) {
  113. $nav['community'] = array('community', t('Community'), '', t('Conversations on this site'));
  114. } elseif (get_config('system', 'community_page_style') == CP_GLOBAL_COMMUNITY) {
  115. $nav['community'] = array('community', t('Community'), '', t('Conversations on the network'));
  116. }
  117. if (local_user()) {
  118. $nav['events'] = array('events', t('Events'), '', t('Events and Calendar'));
  119. }
  120. $nav['directory'] = array($gdirpath, t('Directory'), '', t('People directory'));
  121. $nav['about'] = array('friendica', t('Information'), '', t('Information about this friendica instance'));
  122. // The following nav links are only show to logged in users
  123. if (local_user()) {
  124. $nav['network'] = array('network', t('Network'), '', t('Conversations from your friends'));
  125. $nav['net_reset'] = array('network/0?f=&order=comment&nets=all', t('Network Reset'), '', t('Load Network page with no filters'));
  126. $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), '', t('Your posts and conversations'));
  127. if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP))) {
  128. // only show friend requests for normal pages. Other page types have automatic friendship.
  129. if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP))) {
  130. $nav['introductions'] = array('notifications/intros', t('Introductions'), '', t('Friend Requests'));
  131. }
  132. if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) {
  133. $nav['notifications'] = array('notifications', t('Notifications'), '', t('Notifications'));
  134. $nav['notifications']['all'] = array('notifications/system', t('See all notifications'), '', '');
  135. $nav['notifications']['mark'] = array('', t('Mark as seen'), '', t('Mark all system notifications seen'));
  136. }
  137. }
  138. $nav['messages'] = array('message', t('Messages'), '', t('Private mail'));
  139. $nav['messages']['inbox'] = array('message', t('Inbox'), '', t('Inbox'));
  140. $nav['messages']['outbox'] = array('message/sent', t('Outbox'), '', t('Outbox'));
  141. $nav['messages']['new'] = array('message/new', t('New Message'), '', t('New Message'));
  142. if (is_array($a->identities) && count($a->identities) > 1) {
  143. $nav['manage'] = array('manage', t('Manage'), '', t('Manage other pages'));
  144. }
  145. $nav['delegations'] = array('delegate', t('Delegations'), '', t('Delegate Page Management'));
  146. $nav['settings'] = array('settings', t('Settings'), '', t('Account settings'));
  147. if (feature_enabled(local_user(), 'multi_profiles')) {
  148. $nav['profiles'] = array('profiles', t('Profiles'), '', t('Manage/Edit Profiles'));
  149. }
  150. $nav['contacts'] = array('contacts', t('Contacts'), '', t('Manage/edit friends and contacts'));
  151. }
  152. // Show the link to the admin configuration page if user is admin
  153. if (is_site_admin()) {
  154. $nav['admin'] = array('admin/', t('Admin'), '', t('Site setup and configuration'));
  155. }
  156. $nav['navigation'] = array('navigation/', t('Navigation'), '', t('Site map'));
  157. // Provide a banner/logo/whatever
  158. $banner = get_config('system', 'banner');
  159. if ($banner === false) {
  160. $banner = '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>';
  161. }
  162. call_hooks('nav_info', $nav);
  163. return array(
  164. 'sitelocation' => $sitelocation,
  165. 'nav' => $nav,
  166. 'banner' => $banner,
  167. 'userinfo' => $userinfo,
  168. );
  169. }
  170. /**
  171. * Set a menu item in navbar as selected
  172. *
  173. */
  174. function nav_set_selected($item){
  175. $a = get_app();
  176. $a->nav_sel = array(
  177. 'community' => null,
  178. 'network' => null,
  179. 'home' => null,
  180. 'profiles' => null,
  181. 'introductions' => null,
  182. 'notifications' => null,
  183. 'messages' => null,
  184. 'directory' => null,
  185. 'settings' => null,
  186. 'contacts' => null,
  187. 'manage' => null,
  188. 'events' => null,
  189. 'register' => null,
  190. );
  191. $a->nav_sel[$item] = 'selected';
  192. }