From a0db0e391cdeb626436aa5941770ab1340a8156b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Jan 2009 23:45:43 +0000 Subject: Move personal group nav menu to its own class --- lib/personalgroupnav.php | 135 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 lib/personalgroupnav.php (limited to 'lib/personalgroupnav.php') diff --git a/lib/personalgroupnav.php b/lib/personalgroupnav.php new file mode 100644 index 000000000..5d727a505 --- /dev/null +++ b/lib/personalgroupnav.php @@ -0,0 +1,135 @@ +. + * + * @category Action + * @package Laconica + * @author Evan Prodromou + * @author Sarven Capadisli + * @copyright 2008 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/widget.php'; + +/** + * Base class for all actions + * + * This is the base class for all actions in the package. An action is + * more or less a "view" in an MVC framework. + * + * Actions are responsible for extracting and validating parameters; using + * model classes to read and write to the database; and doing ouput. + * + * @category Output + * @package Laconica + * @author Evan Prodromou + * @author Sarven Capadisli + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * + * @see HTMLOutputter + */ + +class PersonalGroupNav extends Widget +{ + var $action = null; + + /** + * Construction + * + * @param Action $action current action, used for output + */ + + function __construct($action=null) + { + parent::__construct($action); + $this->action = $action; + } + + /** + * Show the menu + * + * @return void + */ + + function show() + { + $user = null; + + // FIXME: we should probably pass this in + + $action = $this->action->trimmed('action'); + $nickname = $this->action->trimmed('nickname'); + + if ($nickname) { + $user = User::staticGet('nickname', $nickname); + $user_profile = $user->getProfile(); + } else { + $user_profile = false; + } + + $this->out->elementStart('ul', array('id' => 'nav_views')); + + $this->out->menuItem(common_local_url('all', array('nickname' => + $nickname)), + _('Personal'), + sprintf(_('%s and friends'), (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)), + $action == 'all'); + $this->out->menuItem(common_local_url('replies', array('nickname' => + $nickname)), + _('Replies'), + sprintf(_('Replies to %s'), (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)), + $action == 'replies'); + $this->out->menuItem(common_local_url('showstream', array('nickname' => + $nickname)), + _('Profile'), + ($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname, + $action == 'showstream'); + $this->out->menuItem(common_local_url('showfavorites', array('nickname' => + $nickname)), + _('Favorites'), + sprintf(_('%s\'s favorite notices'), ($user_profile) ? $user_profile->getBestName() : _('User')), + $action == 'showfavorites'); + + $cur = common_current_user(); + + if ($cur && $cur->id == $user->id) { + + $this->out->menuItem(common_local_url('inbox', array('nickname' => + $nickname)), + _('Inbox'), + _('Your incoming messages'), + $action == 'inbox'); + $this->out->menuItem(common_local_url('outbox', array('nickname' => + $nickname)), + _('Outbox'), + _('Your sent messages'), + $action == 'outbox'); + } + + $this->out->elementEnd('ul'); + } +} -- cgit v1.2.3-54-g00ecf From e7687c66b21fec1a2db524842505d229ce896e72 Mon Sep 17 00:00:00 2001 From: sarven Date: Sat, 17 Jan 2009 06:33:45 +0000 Subject: Using @id instead of @class for navigation li --- lib/action.php | 5 ++++- lib/personalgroupnav.php | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'lib/personalgroupnav.php') diff --git a/lib/action.php b/lib/action.php index 35f6f2e3e..71520b84e 100644 --- a/lib/action.php +++ b/lib/action.php @@ -565,7 +565,10 @@ class Action extends HTMLOutputter // lawsuit if ($is_selected) { $lattrs['class'] = 'current'; } - $this->elementStart('li', (is_null($id)) ? $lattrs : $lattr['id'] = $id); + + (is_null($id)) ? $lattrs : $lattrs['id'] = $id; + + $this->elementStart('li', $lattrs); $attrs['href'] = $url; if ($title) { $attrs['title'] = $title; diff --git a/lib/personalgroupnav.php b/lib/personalgroupnav.php index 5d727a505..63e6138df 100644 --- a/lib/personalgroupnav.php +++ b/lib/personalgroupnav.php @@ -91,28 +91,28 @@ class PersonalGroupNav extends Widget $user_profile = false; } - $this->out->elementStart('ul', array('id' => 'nav_views')); + $this->out->elementStart('ul', array('class' => 'nav')); $this->out->menuItem(common_local_url('all', array('nickname' => $nickname)), _('Personal'), sprintf(_('%s and friends'), (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)), - $action == 'all'); + $action == 'all', 'nav_timeline_personal'); $this->out->menuItem(common_local_url('replies', array('nickname' => $nickname)), _('Replies'), sprintf(_('Replies to %s'), (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)), - $action == 'replies'); + $action == 'replies', 'nav_timeline_replies'); $this->out->menuItem(common_local_url('showstream', array('nickname' => $nickname)), _('Profile'), ($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname, - $action == 'showstream'); + $action == 'showstream', 'nav_profile'); $this->out->menuItem(common_local_url('showfavorites', array('nickname' => $nickname)), _('Favorites'), sprintf(_('%s\'s favorite notices'), ($user_profile) ? $user_profile->getBestName() : _('User')), - $action == 'showfavorites'); + $action == 'showfavorites', 'nav_timeline_favorites'); $cur = common_current_user(); -- cgit v1.2.3-54-g00ecf