Update PersonalGroupNav with fixed highlighting checks.

Couldn't use Menu::item() as its checks are only for the action name, so would have highlighted stuff for other users though it always links to self.
This commit is contained in:
Brion Vibber 2011-03-11 14:25:57 -08:00
parent d393ac4bbb
commit 717fed785e
1 changed files with 8 additions and 5 deletions

View File

@ -63,6 +63,9 @@ class PersonalGroupNav extends Menu
$nickname = $user->nickname; $nickname = $user->nickname;
$name = $user_profile->getBestName(); $name = $user_profile->getBestName();
$action = $this->actionName;
$mine = ($this->action->arg('nickname') == $nickname); // @fixme kinda vague
$this->out->elementStart('ul', array('class' => 'nav')); $this->out->elementStart('ul', array('class' => 'nav'));
if (Event::handle('StartPersonalGroupNav', array($this))) { if (Event::handle('StartPersonalGroupNav', array($this))) {
@ -70,23 +73,23 @@ class PersonalGroupNav extends Menu
$nickname)), $nickname)),
_('Home'), _('Home'),
sprintf(_('%s and friends'), $name), sprintf(_('%s and friends'), $name),
$this->action == 'all', 'nav_timeline_personal'); $mine && $action =='all', 'nav_timeline_personal');
$this->out->menuItem(common_local_url('showstream', array('nickname' => $this->out->menuItem(common_local_url('showstream', array('nickname' =>
$nickname)), $nickname)),
_('Profile'), _('Profile'),
_('Your profile'), _('Your profile'),
$this->action == 'showstream', $mine && $action =='showstream',
'nav_profile'); 'nav_profile');
$this->out->menuItem(common_local_url('replies', array('nickname' => $this->out->menuItem(common_local_url('replies', array('nickname' =>
$nickname)), $nickname)),
_('Replies'), _('Replies'),
sprintf(_('Replies to %s'), $name), sprintf(_('Replies to %s'), $name),
$this->action == 'replies', 'nav_timeline_replies'); $mine && $action =='replies', 'nav_timeline_replies');
$this->out->menuItem(common_local_url('showfavorites', array('nickname' => $this->out->menuItem(common_local_url('showfavorites', array('nickname' =>
$nickname)), $nickname)),
_('Favorites'), _('Favorites'),
sprintf(_('%s\'s favorite notices'), ($user_profile) ? $name : _('User')), sprintf(_('%s\'s favorite notices'), ($user_profile) ? $name : _('User')),
$this->action == 'showfavorites', 'nav_timeline_favorites'); $mine && $action =='showfavorites', 'nav_timeline_favorites');
$cur = common_current_user(); $cur = common_current_user();
@ -97,7 +100,7 @@ class PersonalGroupNav extends Menu
$nickname)), $nickname)),
_('Messages'), _('Messages'),
_('Your incoming messages'), _('Your incoming messages'),
$this->action == 'inbox'); $mine && $action =='inbox');
} }
Event::handle('EndPersonalGroupNav', array($this)); Event::handle('EndPersonalGroupNav', array($this));