content.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * Main content area layout
  4. *
  5. * @uses $vars['content'] HTML of main content area
  6. * @uses $vars['sidebar'] HTML of the sidebar
  7. * @uses $vars['header'] HTML of the content area header (override)
  8. * @uses $vars['nav'] HTML of the content area nav (override)
  9. * @uses $vars['footer'] HTML of the content area footer
  10. * @uses $vars['filter'] HTML of the content area filter (override)
  11. * @uses $vars['title'] Title text (override)
  12. * @uses $vars['context'] Page context (override)
  13. * @uses $vars['filter_context'] Filter context: everyone, friends, mine
  14. * @uses $vars['class'] Additional class to apply to layout
  15. */
  16. $context = elgg_extract('context', $vars, elgg_get_context());
  17. $vars['title'] = elgg_extract('title', $vars, '');
  18. if (!$vars['title'] && $vars['title'] !== false) {
  19. $vars['title'] = elgg_echo($context);
  20. }
  21. // 1.8 supported 'filter_override'
  22. if (isset($vars['filter_override'])) {
  23. $vars['filter'] = $vars['filter_override'];
  24. }
  25. // register the default content filters
  26. if (!isset($vars['filter']) && elgg_is_logged_in() && $context) {
  27. $username = elgg_get_logged_in_user_entity()->username;
  28. $filter_context = elgg_extract('filter_context', $vars, 'all');
  29. // generate a list of default tabs
  30. $tabs = array(
  31. 'all' => array(
  32. 'text' => elgg_echo('all'),
  33. 'href' => (isset($vars['all_link'])) ? $vars['all_link'] : "$context/all",
  34. 'selected' => ($filter_context == 'all'),
  35. 'priority' => 200,
  36. ),
  37. 'mine' => array(
  38. 'text' => elgg_echo('mine'),
  39. 'href' => (isset($vars['mine_link'])) ? $vars['mine_link'] : "$context/owner/$username",
  40. 'selected' => ($filter_context == 'mine'),
  41. 'priority' => 300,
  42. ),
  43. 'friend' => array(
  44. 'text' => elgg_echo('friends'),
  45. 'href' => (isset($vars['friend_link'])) ? $vars['friend_link'] : "$context/friends/$username",
  46. 'selected' => ($filter_context == 'friends'),
  47. 'priority' => 400,
  48. ),
  49. );
  50. foreach ($tabs as $name => $tab) {
  51. $tab['name'] = $name;
  52. elgg_register_menu_item('filter', $tab);
  53. }
  54. }
  55. $filter = elgg_view('page/layouts/elements/filter', $vars);
  56. $vars['content'] = $filter . $vars['content'];
  57. echo elgg_view_layout('one_sidebar', $vars);