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.

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