diff options
Diffstat (limited to 'views')
-rw-r--r-- | views/default/page_elements/content_header.php | 126 | ||||
-rw-r--r-- | views/default/page_elements/content_header_member.php | 15 |
2 files changed, 57 insertions, 84 deletions
diff --git a/views/default/page_elements/content_header.php b/views/default/page_elements/content_header.php index cb547cd96..483d85c4b 100644 --- a/views/default/page_elements/content_header.php +++ b/views/default/page_elements/content_header.php @@ -1,6 +1,8 @@ <?php /** - * Displays the dropdown filter menu. + * Displays the Add New button, and the All, Mine, My Friends tabs for plugins + * If a user is not logged in, this only displays the All tab. + * If this is in a group context, it doesn't display any tabs * * @package Elgg * @subpackage Core @@ -9,19 +11,23 @@ * */ -global $CONFIG; - -// set variables $page_owner = page_owner_entity(); +$logged_in_user = get_loggedin_user(); +$username = $logged_in_user->username; + if (!$page_owner) { - $page_owner = get_loggedin_user(); + $page_owner = $logged_in_user; } -$filter_context = $vars['context']; // so we know if the user is looking at their own, everyone's or all friends -$type = $vars['type']; // get the object type -$mine_selected = ''; -$all_selected = ''; -$friend_selected = ''; -$action_buttons = ''; + +// so we know if the user is looking at their own, everyone's or all friends +$filter_context = $vars['context']; + +// get the object type +$type = $vars['type']; + +// tons of empty strings. +$mine_selected = $all_selected = $friend_selected = +$new_button = $action_buttons = $filter_content = ''; $all_title = elgg_echo('all'); $mine_title = elgg_echo('mine'); @@ -37,75 +43,57 @@ if (!($page_owner instanceof ElggGroup)){ if($filter_context == 'friends') { $friend_selected = "class = 'selected'"; } - if($filter_context == 'action') { - // if this is an action page - } } - // allow plugins to override default page handlers -if (isset($vars['all_link'])) { - $all_link = $vars['all_link']; -} else { - // @todo switch this over to proper page handling style - $all_link = "{$vars['url']}mod/$type/all.php"; -} +// @todo switch this over to proper page handling style +$all_link = (isset($vars['all_link'])) ? $vars['all_link'] : "{$vars['url']}mod/$type/all.php"; +$mine_link = (isset($vars['mine_link'])) ? $vars['mine_link'] : "{$vars['url']}pg/$type/$username"; +$friend_link = (isset($vars['friend_link'])) ? $vars['friend_link'] : "{$vars['url']}pg/$type/$username/friends"; +$new_link = (isset($vars['new_link'])) ? $vars['new_link'] : "{$CONFIG->wwwroot}pg/$type/$username/new"; -if (isset($vars['mine_link'])) { - $mine_link = $vars['mine_link']; -} else { - $mine_link = "{$vars['url']}pg/$type/{$_SESSION['user']->username}"; -} - -if (isset($vars['friend_link'])) { - $friend_link = $vars['friend_link']; -} else { - $friend_link = "{$vars['url']}pg/$type/{$_SESSION['user']->username}/friends"; -} +$title = elgg_echo($type); +$title = '<div class="content_header_title">' . elgg_view_title($title) . '</div>'; +$tabs = <<<EOT + <div class="elgg_horizontal_tabbed_nav margin_top"> + <ul> + <li $all_selected><a href="$all_link">$all_title</a></li> + <li $mine_selected><a href="$mine_link">$mine_title</a></li> + <li $friend_selected><a href="$friend_link">$friend_title</a></li> + </ul> + </div> +EOT; // must be logged in to see the filter menu and any action buttons -if ( isloggedin() ) { - // if we're not on an action page (add a bookmark, create a blog, upload a file etc), or a group page - if ( ($filter_context != 'action') && (get_context() != 'groups') ) { - $title = elgg_echo($type); - $title = "<div class='content_header_title'>".elgg_view_title($title)."</div>"; - $page_filter = <<<EOT - <div class="elgg_horizontal_tabbed_nav margin_top"> - <ul> - <li $all_selected><a href="$all_link">$all_title</a></li> - <li $mine_selected><a href="$mine_link">$mine_title</a></li> - <li $friend_selected><a href="$friend_link">$friend_title</a></li> - </ul> - </div> -EOT; - // action buttons - if(get_context() != 'bookmarks'){ - $url = "{$CONFIG->wwwroot}pg/$type/{$page_owner->username}/new"; - } else { - $url = "{$CONFIG->wwwroot}pg/$type/{$page_owner->username}/add"; - } - $action_buttons = "<a href=\"{$url}\" class='action_button'>" . elgg_echo($type . ':new') . "</a>"; - $action_buttons = "<div class='content_header_options'>".$action_buttons."</div>"; +if (isloggedin()) { + // only show the new button when not on the add form. + // hide the tabs when on the add form. + if ($filter_context == 'action') { + $tabs = ''; + } else { + $new_button = "<a href=\"{$new_link}\" class='action_button'>" . elgg_echo($type . ':new') . '</a>'; + $new_button = "<div class='content_header_options'>$new_button</div>"; + } - } elseif(get_context() == 'groups'){ - $title = elgg_echo($type); - $title = "<div class='content_header_title'>".elgg_view_title( $title )."</div>"; - $page_filter = ''; - $url = "{$CONFIG->wwwroot}pg/groups/new/"; - $action_buttons = "<a href=\"{$url}\" class='action_button'>" . elgg_echo($type . ':new') . "</a>"; - $action_buttons = "<div class='content_header_options'>".$action_buttons."</div>"; - - } else { // we're on an action page - we'll just have a simple page title, and no filter menu - $title = elgg_echo($type); - $title = "<div class='content_header_title'>".elgg_view_title( $title )."</div>"; - $page_filter = ''; + // also hide the tabs if in a group context (ie, listing groups) or + // when viewing tools belonging to a group + if (get_context() == 'groups' || $page_owner instanceof ElggGroup) { + $tabs = ''; } +} else { + // only show logged out users the all tab + $page_filter = <<<EOT + <div class="elgg_horizontal_tabbed_nav margin_top"> + <ul> + <li $all_selected><a href="$all_link">$all_title</a></li> + </ul> + </div> +EOT; } ?> -<!-- construct the page content area header --> <div id="content_header" class="clearfloat"> - <?php echo $title . $action_buttons; ?> + <?php echo $title . $new_button; ?> </div> -<?php echo $page_filter; ?> +<?php echo $tabs; ?> diff --git a/views/default/page_elements/content_header_member.php b/views/default/page_elements/content_header_member.php deleted file mode 100644 index f90c87384..000000000 --- a/views/default/page_elements/content_header_member.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php -/** - * Page Content header when viewing another members entities - holds the filter menu and any content action buttons - used on bookmarks, blog, file, pages, - **/ -$type = $vars['type'];//get the object type -$user = page_owner_entity(); -$user_name = elgg_view_title($user->name . "'s " . elgg_echo($type)); -?> -<div id="content_header" class="clearfloat"> - <div class="content_header_title"> - <?php echo $user_name; ?> - </div> -</div>
\ No newline at end of file |