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.

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