diff --git a/actions/all.php b/actions/all.php index 2936df4599..2826319c0d 100644 --- a/actions/all.php +++ b/actions/all.php @@ -127,12 +127,6 @@ class AllAction extends ProfileAction ); } - function showLocalNav() - { - $nav = new PersonalGroupNav($this); - $nav->show(); - } - function showEmptyListMessage() { // TRANS: Empty list message. %s is a user nickname. diff --git a/actions/blockedfromgroup.php b/actions/blockedfromgroup.php index 6ff572c05d..dd916b170a 100644 --- a/actions/blockedfromgroup.php +++ b/actions/blockedfromgroup.php @@ -122,7 +122,7 @@ class BlockedfromgroupAction extends GroupDesignAction _('A list of the users blocked from joining this group.')); } - function showLocalNav() + function showObjectNav() { $nav = new GroupNav($this, $this->group); $nav->show(); diff --git a/actions/editgroup.php b/actions/editgroup.php index 0e04170051..08a75da12c 100644 --- a/actions/editgroup.php +++ b/actions/editgroup.php @@ -139,7 +139,7 @@ class EditgroupAction extends GroupDesignAction $this->showPage(); } - function showLocalNav() + function showObjectNav() { $nav = new GroupNav($this, $this->group); $nav->show(); diff --git a/actions/favorited.php b/actions/favorited.php index c137cf424f..17c2a58c94 100644 --- a/actions/favorited.php +++ b/actions/favorited.php @@ -163,19 +163,6 @@ class FavoritedAction extends Action $this->elementEnd('div'); } - /** - * Local navigation - * - * This page is part of the public group, so show that. - * - * @return void - */ - function showLocalNav() - { - $nav = new PublicGroupNav($this); - $nav->show(); - } - /** * Content area * diff --git a/actions/featured.php b/actions/featured.php index 9a7f128b57..394cfe6a8b 100644 --- a/actions/featured.php +++ b/actions/featured.php @@ -90,12 +90,6 @@ class FeaturedAction extends Action $this->elementEnd('div'); } - function showLocalNav() - { - $nav = new PublicGroupNav($this); - $nav->show(); - } - function getInstructions() { // TRANS: Description on page displaying featured users. diff --git a/actions/groupdesignsettings.php b/actions/groupdesignsettings.php index 3ef5e20e44..798064d16c 100644 --- a/actions/groupdesignsettings.php +++ b/actions/groupdesignsettings.php @@ -163,12 +163,22 @@ class GroupDesignSettingsAction extends DesignSettingsAction * * @return nothing */ - function showLocalNav() + function showObjectNav() { $nav = new GroupNav($this, $this->group); $nav->show(); } + /** + * Override to show default nav stuff + * + * @return nothing + */ + function showLocalNav() + { + Action::showLocalNav(); + } + /** * Get the design we want to edit * diff --git a/actions/grouplogo.php b/actions/grouplogo.php index d490cd9875..db0d40ff0c 100644 --- a/actions/grouplogo.php +++ b/actions/grouplogo.php @@ -458,7 +458,7 @@ class GrouplogoAction extends GroupDesignAction $this->autofocus('avatarfile'); } - function showLocalNav() + function showObjectNav() { $nav = new GroupNav($this, $this->group); $nav->show(); diff --git a/actions/groupmembers.php b/actions/groupmembers.php index 7b1512dfab..e280fd1fd1 100644 --- a/actions/groupmembers.php +++ b/actions/groupmembers.php @@ -125,7 +125,7 @@ class GroupmembersAction extends GroupDesignAction _('A list of the users in this group.')); } - function showLocalNav() + function showObjectNav() { $nav = new GroupNav($this, $this->group); $nav->show(); diff --git a/actions/groups.php b/actions/groups.php index 958c5921bf..d1bc8d9458 100644 --- a/actions/groups.php +++ b/actions/groups.php @@ -80,12 +80,6 @@ class GroupsAction extends Action $this->showPage(); } - function showLocalNav() - { - $nav = new PublicGroupNav($this); - $nav->show(); - } - function showPageNotice() { $notice = diff --git a/actions/invite.php b/actions/invite.php index a2a0e0714a..c64ff8adda 100644 --- a/actions/invite.php +++ b/actions/invite.php @@ -289,7 +289,7 @@ class InviteAction extends CurrentUserDesignAction mail_send($recipients, $headers, $body); } - function showLocalNav() + function showObjectNav() { $nav = new SubGroupNav($this, common_current_user()); $nav->show(); diff --git a/actions/public.php b/actions/public.php index 727c76d528..adeb58b0ee 100644 --- a/actions/public.php +++ b/actions/public.php @@ -168,21 +168,6 @@ class PublicAction extends Action _('Public Stream Feed (Atom)'))); } - /** - * Show tabset for this page - * - * Uses the PublicGroupNav widget - * - * @return void - * @see PublicGroupNav - */ - - function showLocalNav() - { - $nav = new PublicGroupNav($this); - $nav->show(); - } - function showEmptyList() { $message = _('This is the public timeline for %%site.name%% but no one has posted anything yet.') . ' '; diff --git a/actions/publictagcloud.php b/actions/publictagcloud.php index f6f1d31625..1432ca66a8 100644 --- a/actions/publictagcloud.php +++ b/actions/publictagcloud.php @@ -92,12 +92,6 @@ class PublictagcloudAction extends Action $this->elementEnd('div'); } - function showLocalNav() - { - $nav = new PublicGroupNav($this); - $nav->show(); - } - function handle($args) { parent::handle($args); diff --git a/actions/replies.php b/actions/replies.php index 8f2fc6c7f3..fd178175d2 100644 --- a/actions/replies.php +++ b/actions/replies.php @@ -160,18 +160,6 @@ class RepliesAction extends OwnerDesignAction $this->user->nickname))); } - /** - * show the personal group nav - * - * @return void - */ - - function showLocalNav() - { - $nav = new PersonalGroupNav($this); - $nav->show(); - } - /** * Show the content * diff --git a/actions/showfavorites.php b/actions/showfavorites.php index eda2cf38eb..67ee914a91 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -189,17 +189,6 @@ class ShowfavoritesAction extends OwnerDesignAction $this->user->nickname))); } - /** - * show the personal group nav - * - * @return void - */ - function showLocalNav() - { - $nav = new PersonalGroupNav($this); - $nav->show(); - } - function showEmptyListMessage() { if (common_logged_in()) { diff --git a/actions/showgroup.php b/actions/showgroup.php index a38945c131..411940ef9a 100644 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@ -167,7 +167,7 @@ class ShowgroupAction extends GroupDesignAction * * @return void */ - function showLocalNav() + function showObjectNav() { $nav = new GroupNav($this, $this->group); $nav->show(); diff --git a/actions/showstream.php b/actions/showstream.php index 0fd1c2c29f..afde49ecea 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -104,7 +104,7 @@ class ShowstreamAction extends ProfileAction $this->showNotices(); } - function showLocalNav() + function showObjectNav() { $nav = new SubGroupNav($this, $this->user); $nav->show(); diff --git a/actions/usergroups.php b/actions/usergroups.php index 6606e76cdb..cf904bc929 100644 --- a/actions/usergroups.php +++ b/actions/usergroups.php @@ -112,7 +112,7 @@ class UsergroupsAction extends OwnerDesignAction $this->showPage(); } - function showLocalNav() + function showObjectNav() { $nav = new SubGroupNav($this, $this->user); $nav->show(); diff --git a/lib/action.php b/lib/action.php index b7f0036699..e7c55ef10c 100644 --- a/lib/action.php +++ b/lib/action.php @@ -476,14 +476,7 @@ class Action extends HTMLOutputter // lawsuit Event::handle('EndShowSiteNotice', array($this)); } - if (common_logged_in()) { - if (Event::handle('StartShowNoticeForm', array($this))) { - $this->showNoticeForm(); - Event::handle('EndShowNoticeForm', array($this)); - } - } else { - $this->showAnonymousMessage(); - } + $this->elementEnd('div'); } @@ -555,69 +548,10 @@ class Action extends HTMLOutputter // lawsuit */ function showPrimaryNav() { - $user = common_current_user(); - $this->elementStart('ul', array('class' => 'nav', - 'id' => 'site_nav_global_primary')); - if (Event::handle('StartPrimaryNav', array($this))) { - if (!empty($user)) { - $this->menuItem(common_local_url('all', - array('nickname' => $user->nickname)), - _m('Home'), - _m('Friends timeline'), - false, - 'nav_home'); - $this->menuItem(common_local_url('showstream', - array('nickname' => $user->nickname)), - _m('Profile'), - _m('Your profile'), - false, - 'nav_profile'); - $this->menuItem(common_local_url('public'), - _m('Public'), - _m('Everyone on this site'), - false, - 'nav_public'); - $this->menuItem(common_local_url('profilesettings'), - _m('Settings'), - _m('Change your personal settings'), - false, - 'nav_account'); - if ($user->hasRight(Right::CONFIGURESITE)) { - $this->menuItem(common_local_url('siteadminpanel'), - _m('Admin'), - _m('Site configuration'), - false, - 'nav_admin'); - } - $this->menuItem(common_local_url('logout'), - _m('Logout'), - _m('Logout from the site'), - false, - 'nav_logout'); - } else { - $this->menuItem(common_local_url('public'), - _m('Public'), - _m('Everyone on this site'), - false, - 'nav_public'); - $this->menuItem(common_local_url('login'), - _m('Login'), - _m('Login to the site'), - false, - 'nav_login'); - } - - if (!empty($user) || !common_config('site', 'private')) { - $this->menuItem(common_local_url('noticesearch'), - _m('Search'), - _m('Search the site'), - false, - 'nav_search'); - } - - Event::handle('EndPrimaryNav', array($this)); - } - $this->elementEnd('ul'); + $this->elementStart('div', array('id' => 'site_nav_global_primary')); + $pn = new PrimaryNav($this); + $pn->show(); + $this->elementEnd('div'); } /** @@ -733,6 +667,10 @@ class Action extends HTMLOutputter // lawsuit $this->showContentBlock(); Event::handle('EndShowContentBlock', array($this)); } + if (Event::handle('StartShowObjectNavBlock', array($this))) { + $this->showObjectNavBlock(); + Event::handle('EndShowObjectNavBlock', array($this)); + } if (Event::handle('StartShowAside', array($this))) { $this->showAside(); Event::handle('EndShowAside', array($this)); @@ -763,7 +701,34 @@ class Action extends HTMLOutputter // lawsuit */ function showLocalNav() { - // does nothing by default + $nav = new DefaultLocalNav($this); + $nav->show(); + } + + /** + * Show menu for an object (group, profile) + * + * @return nothing + */ + function showObjectNavBlock() + { + // Need to have this ID for CSS; I'm too lazy to add it to + // all menus + $this->elementStart('div', array('id' => 'site_nav_object')); + $this->showObjectNav(); + $this->elementEnd('div'); + } + + /** + * Show object navigation. + * + * If there are things to do with this object, show it here. + * + * @return nothing + */ + function showObjectNav() + { + /* Nothing here. */ } /** @@ -774,6 +739,12 @@ class Action extends HTMLOutputter // lawsuit function showContentBlock() { $this->elementStart('div', array('id' => 'content')); + if (common_logged_in()) { + if (Event::handle('StartShowNoticeForm', array($this))) { + $this->showNoticeForm(); + Event::handle('EndShowNoticeForm', array($this)); + } + } if (Event::handle('StartShowPageTitle', array($this))) { $this->showPageTitle(); Event::handle('EndShowPageTitle', array($this)); @@ -915,43 +886,8 @@ class Action extends HTMLOutputter // lawsuit */ function showSecondaryNav() { - $this->elementStart('ul', array('class' => 'nav', - 'id' => 'site_nav_global_secondary')); - if (Event::handle('StartSecondaryNav', array($this))) { - $this->menuItem(common_local_url('doc', array('title' => 'help')), - // TRANS: Secondary navigation menu option leading to help on StatusNet. - _('Help')); - $this->menuItem(common_local_url('doc', array('title' => 'about')), - // TRANS: Secondary navigation menu option leading to text about StatusNet site. - _('About')); - $this->menuItem(common_local_url('doc', array('title' => 'faq')), - // TRANS: Secondary navigation menu option leading to Frequently Asked Questions. - _('FAQ')); - $bb = common_config('site', 'broughtby'); - if (!empty($bb)) { - $this->menuItem(common_local_url('doc', array('title' => 'tos')), - // TRANS: Secondary navigation menu option leading to Terms of Service. - _('TOS')); - } - $this->menuItem(common_local_url('doc', array('title' => 'privacy')), - // TRANS: Secondary navigation menu option leading to privacy policy. - _('Privacy')); - $this->menuItem(common_local_url('doc', array('title' => 'source')), - // TRANS: Secondary navigation menu option. Leads to information about StatusNet and its license. - _('Source')); - $this->menuItem(common_local_url('version'), - // TRANS: Secondary navigation menu option leading to version information on the StatusNet site. - _('Version')); - $this->menuItem(common_local_url('doc', array('title' => 'contact')), - // TRANS: Secondary navigation menu option leading to e-mail contact information on the - // TRANS: StatusNet site, where to report bugs, ... - _('Contact')); - $this->menuItem(common_local_url('doc', array('title' => 'badge')), - // TRANS: Secondary navigation menu option. Leads to information about embedding a timeline widget. - _('Badge')); - Event::handle('EndSecondaryNav', array($this)); - } - $this->elementEnd('ul'); + $sn = new SecondaryNav($this); + $sn->show(); } /** diff --git a/lib/adminpanelaction.php b/lib/adminpanelaction.php index 8dd16e9d0c..a085fcd5dc 100644 --- a/lib/adminpanelaction.php +++ b/lib/adminpanelaction.php @@ -291,129 +291,3 @@ class AdminPanelAction extends Action return $isOK; } } - -/** - * Menu for public group of actions - * - * @category Output - * @package StatusNet - * @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://status.net/ - * - * @see Widget - */ -class AdminPanelNav 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() - { - $action_name = $this->action->trimmed('action'); - - $this->action->elementStart('ul', array('class' => 'nav')); - - if (Event::handle('StartAdminPanelNav', array($this))) { - - if (AdminPanelAction::canAdmin('site')) { - // TRANS: Menu item title/tooltip - $menu_title = _('Basic site configuration'); - // TRANS: Menu item for site administration - $this->out->menuItem(common_local_url('siteadminpanel'), _m('MENU', 'Site'), - $menu_title, $action_name == 'siteadminpanel', 'nav_site_admin_panel'); - } - - if (AdminPanelAction::canAdmin('design')) { - // TRANS: Menu item title/tooltip - $menu_title = _('Design configuration'); - // TRANS: Menu item for site administration - $this->out->menuItem(common_local_url('designadminpanel'), _m('MENU', 'Design'), - $menu_title, $action_name == 'designadminpanel', 'nav_design_admin_panel'); - } - - if (AdminPanelAction::canAdmin('user')) { - // TRANS: Menu item title/tooltip - $menu_title = _('User configuration'); - // TRANS: Menu item for site administration - $this->out->menuItem(common_local_url('useradminpanel'), _('User'), - $menu_title, $action_name == 'useradminpanel', 'nav_user_admin_panel'); - } - - if (AdminPanelAction::canAdmin('access')) { - // TRANS: Menu item title/tooltip - $menu_title = _('Access configuration'); - // TRANS: Menu item for site administration - $this->out->menuItem(common_local_url('accessadminpanel'), _('Access'), - $menu_title, $action_name == 'accessadminpanel', 'nav_access_admin_panel'); - } - - if (AdminPanelAction::canAdmin('paths')) { - // TRANS: Menu item title/tooltip - $menu_title = _('Paths configuration'); - // TRANS: Menu item for site administration - $this->out->menuItem(common_local_url('pathsadminpanel'), _('Paths'), - $menu_title, $action_name == 'pathsadminpanel', 'nav_paths_admin_panel'); - } - - if (AdminPanelAction::canAdmin('sessions')) { - // TRANS: Menu item title/tooltip - $menu_title = _('Sessions configuration'); - // TRANS: Menu item for site administration - $this->out->menuItem(common_local_url('sessionsadminpanel'), _('Sessions'), - $menu_title, $action_name == 'sessionsadminpanel', 'nav_sessions_admin_panel'); - } - - if (AdminPanelAction::canAdmin('sitenotice')) { - // TRANS: Menu item title/tooltip - $menu_title = _('Edit site notice'); - // TRANS: Menu item for site administration - $this->out->menuItem(common_local_url('sitenoticeadminpanel'), _('Site notice'), - $menu_title, $action_name == 'sitenoticeadminpanel', 'nav_sitenotice_admin_panel'); - } - - if (AdminPanelAction::canAdmin('snapshot')) { - // TRANS: Menu item title/tooltip - $menu_title = _('Snapshots configuration'); - // TRANS: Menu item for site administration - $this->out->menuItem(common_local_url('snapshotadminpanel'), _('Snapshots'), - $menu_title, $action_name == 'snapshotadminpanel', 'nav_snapshot_admin_panel'); - } - - if (AdminPanelAction::canAdmin('license')) { - // TRANS: Menu item title/tooltip - $menu_title = _('Set site license'); - // TRANS: Menu item for site administration - $this->out->menuItem(common_local_url('licenseadminpanel'), _('License'), - $menu_title, $action_name == 'licenseadminpanel', 'nav_license_admin_panel'); - } - - if (AdminPanelAction::canAdmin('plugins')) { - // TRANS: Menu item title/tooltip - $menu_title = _('Plugins configuration'); - // TRANS: Menu item for site administration - $this->out->menuItem(common_local_url('pluginsadminpanel'), _('Plugins'), - $menu_title, $action_name == 'pluginsadminpanel', 'nav_design_admin_panel'); - } - - Event::handle('EndAdminPanelNav', array($this)); - } - $this->action->elementEnd('ul'); - } -} diff --git a/lib/adminpanelnav.php b/lib/adminpanelnav.php new file mode 100644 index 0000000000..ceedf6ceac --- /dev/null +++ b/lib/adminpanelnav.php @@ -0,0 +1,148 @@ +. + * + * @category Menu + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Menu for admin panels + * + * @category Output + * @package StatusNet + * @author Evan Prodromou + * @author Sarven Capadisli + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class AdminPanelNav extends Menu +{ + /** + * Show the menu + * + * @return void + */ + function show() + { + $action_name = $this->action->trimmed('action'); + + $this->action->elementStart('ul', array('class' => 'nav')); + + if (Event::handle('StartAdminPanelNav', array($this))) { + + if (AdminPanelAction::canAdmin('site')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Basic site configuration'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('siteadminpanel'), _m('MENU', 'Site'), + $menu_title, $action_name == 'siteadminpanel', 'nav_site_admin_panel'); + } + + if (AdminPanelAction::canAdmin('design')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Design configuration'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('designadminpanel'), _m('MENU', 'Design'), + $menu_title, $action_name == 'designadminpanel', 'nav_design_admin_panel'); + } + + if (AdminPanelAction::canAdmin('user')) { + // TRANS: Menu item title/tooltip + $menu_title = _('User configuration'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('useradminpanel'), _('User'), + $menu_title, $action_name == 'useradminpanel', 'nav_user_admin_panel'); + } + + if (AdminPanelAction::canAdmin('access')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Access configuration'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('accessadminpanel'), _('Access'), + $menu_title, $action_name == 'accessadminpanel', 'nav_access_admin_panel'); + } + + if (AdminPanelAction::canAdmin('paths')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Paths configuration'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('pathsadminpanel'), _('Paths'), + $menu_title, $action_name == 'pathsadminpanel', 'nav_paths_admin_panel'); + } + + if (AdminPanelAction::canAdmin('sessions')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Sessions configuration'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('sessionsadminpanel'), _('Sessions'), + $menu_title, $action_name == 'sessionsadminpanel', 'nav_sessions_admin_panel'); + } + + if (AdminPanelAction::canAdmin('sitenotice')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Edit site notice'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('sitenoticeadminpanel'), _('Site notice'), + $menu_title, $action_name == 'sitenoticeadminpanel', 'nav_sitenotice_admin_panel'); + } + + if (AdminPanelAction::canAdmin('snapshot')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Snapshots configuration'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('snapshotadminpanel'), _('Snapshots'), + $menu_title, $action_name == 'snapshotadminpanel', 'nav_snapshot_admin_panel'); + } + + if (AdminPanelAction::canAdmin('license')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Set site license'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('licenseadminpanel'), _('License'), + $menu_title, $action_name == 'licenseadminpanel', 'nav_license_admin_panel'); + } + + if (AdminPanelAction::canAdmin('plugins')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Plugins configuration'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('pluginsadminpanel'), _('Plugins'), + $menu_title, $action_name == 'pluginsadminpanel', 'nav_design_admin_panel'); + } + + Event::handle('EndAdminPanelNav', array($this)); + } + $this->action->elementEnd('ul'); + } +} diff --git a/lib/defaultlocalnav.php b/lib/defaultlocalnav.php new file mode 100644 index 0000000000..7af3c9673f --- /dev/null +++ b/lib/defaultlocalnav.php @@ -0,0 +1,66 @@ +. + * + * @category Menu + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Default menu + * + * @category Menu + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class DefaultLocalNav extends Menu +{ + function show() + { + $this->action->elementStart('ul', array('id' => 'nav_local_default')); + + $user = common_current_user(); + + if (!empty($user)) { + $pn = new PersonalGroupNav($this->action); + $this->submenu(_m('Home'), $pn); + } + + $bn = new PublicGroupNav($this->action); + $this->submenu(_('Public'), $bn); + + $this->action->elementEnd('ul'); + } +} diff --git a/lib/galleryaction.php b/lib/galleryaction.php index b8edbbb7ba..107134a09b 100644 --- a/lib/galleryaction.php +++ b/lib/galleryaction.php @@ -94,7 +94,7 @@ class GalleryAction extends OwnerDesignAction $this->showPage(); } - function showLocalNav() + function showObjectNav() { $nav = new SubGroupNav($this, $this->user); $nav->show(); diff --git a/lib/groupnav.php b/lib/groupnav.php index ee988d0a98..a2dd6eac00 100644 --- a/lib/groupnav.php +++ b/lib/groupnav.php @@ -49,9 +49,8 @@ require_once INSTALLDIR.'/lib/widget.php'; * @see HTMLOutputter */ -class GroupNav extends Widget +class GroupNav extends Menu { - var $action = null; var $group = null; /** @@ -63,7 +62,6 @@ class GroupNav extends Widget function __construct($action=null, $group=null) { parent::__construct($action); - $this->action = $action; $this->group = $group; } diff --git a/lib/logingroupnav.php b/lib/logingroupnav.php index a309e7320f..3c67f76322 100644 --- a/lib/logingroupnav.php +++ b/lib/logingroupnav.php @@ -44,21 +44,8 @@ require_once INSTALLDIR.'/lib/widget.php'; * * @see Widget */ -class LoginGroupNav extends Widget +class LoginGroupNav extends Menu { - 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 * diff --git a/lib/mailbox.php b/lib/mailbox.php index 7faeb7dba3..cb56eb5904 100644 --- a/lib/mailbox.php +++ b/lib/mailbox.php @@ -168,4 +168,10 @@ class MailboxAction extends CurrentUserDesignAction { return true; } + + function showObjectNav() + { + $mm = new MailboxMenu($this); + $mm->show(); + } } diff --git a/lib/mailboxmenu.php b/lib/mailboxmenu.php new file mode 100644 index 0000000000..d2d3607dce --- /dev/null +++ b/lib/mailboxmenu.php @@ -0,0 +1,70 @@ +. + * + * @category Cache + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Menu of existing mailboxes + * + * @category General + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class MailboxMenu extends Menu +{ + function show() + { + $cur = common_current_user(); + $nickname = $cur->nickname; + + $this->out->elementStart('ul', array('class' => 'nav')); + + $this->item('inbox', + array('nickname' => $nickname), + _('Inbox'), + _('Your incoming messages')); + + $this->item('outbox', + array('nickname' => $nickname), + _('Outbox'), + _('Your sent messages')); + + $this->out->elementEnd('ul'); + } + +} diff --git a/lib/menu.php b/lib/menu.php new file mode 100644 index 0000000000..2713b44d50 --- /dev/null +++ b/lib/menu.php @@ -0,0 +1,92 @@ +. + * + * @category Widget + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Superclass for menus + * + * @category General + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class Menu extends Widget +{ + var $action = null; + var $actionName = null; + /** + * Construction + * + * @param Action $action current action, used for output + */ + function __construct($action=null) + { + parent::__construct($action); + + $this->action = $action; + $this->actionName = $action->trimmed('action'); + } + + function item($actionName, $args, $label, $description, $id=null) + { + if (empty($id)) { + $id = $this->menuItemID($actionName); + } + + $url = common_local_url($actionName, $args); + + $this->out->menuItem($url, + $label, + $description, + $actionName == $this->actionName, + $id); + } + + function menuItemID($actionName) + { + return sprintf('nav_%s', $actionName); + } + + function submenu($label, $menu) + { + $this->action->elementStart('li'); + $this->action->element('h3', null, $label); + $menu->show(); + $this->action->elementEnd('li'); + } +} diff --git a/lib/personalgroupnav.php b/lib/personalgroupnav.php index 72d0893af7..9d78857c6d 100644 --- a/lib/personalgroupnav.php +++ b/lib/personalgroupnav.php @@ -2,7 +2,7 @@ /** * StatusNet, the distributed open-source microblogging tool * - * Base class for all actions (~views) + * Menu for personal group of actions * * PHP version 5 * @@ -19,11 +19,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * - * @category Action + * @category Menu * @package StatusNet * @author Evan Prodromou * @author Sarven Capadisli - * @copyright 2008 StatusNet, Inc. + * @copyright 2008-2011 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -32,41 +32,20 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/widget.php'; - /** - * Base class for all actions + * Menu for personal group of 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 + * @category Menu * @package StatusNet * @author Evan Prodromou * @author Sarven Capadisli + * @copyright 2008-2011 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ - * - * @see HTMLOutputter */ -class PersonalGroupNav extends Widget + +class PersonalGroupNav extends Menu { - 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 * @@ -74,23 +53,16 @@ class PersonalGroupNav extends Widget */ function show() { - $user = null; + $user = common_current_user(); - // 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(); - $name = $user_profile->getBestName(); - } else { - // @fixme can this happen? is this valid? - $user_profile = false; - $name = $nickname; + if (empty($user)) { + throw new ServerException('Do not show personal group nav with no current user.'); } + $user_profile = $user->getProfile(); + $nickname = $user->nickname; + $name = $user_profile->getBestName(); + $this->out->elementStart('ul', array('class' => 'nav')); if (Event::handle('StartPersonalGroupNav', array($this))) { @@ -99,6 +71,12 @@ class PersonalGroupNav extends Widget _('Home'), sprintf(_('%s and friends'), $name), $action == 'all', 'nav_timeline_personal'); + $this->out->menuItem(common_local_url('showstream', array('nickname' => + $nickname)), + _('Profile'), + _('Your profile'), + $action == 'showstream', + 'nav_profile'); $this->out->menuItem(common_local_url('replies', array('nickname' => $nickname)), _('Replies'), @@ -117,15 +95,11 @@ class PersonalGroupNav extends Widget $this->out->menuItem(common_local_url('inbox', array('nickname' => $nickname)), - _('Inbox'), + _('Messages'), _('Your incoming messages'), $action == 'inbox'); - $this->out->menuItem(common_local_url('outbox', array('nickname' => - $nickname)), - _('Outbox'), - _('Your sent messages'), - $action == 'outbox'); } + Event::handle('EndPersonalGroupNav', array($this)); } $this->out->elementEnd('ul'); diff --git a/lib/primarynav.php b/lib/primarynav.php new file mode 100644 index 0000000000..7748d7a1c7 --- /dev/null +++ b/lib/primarynav.php @@ -0,0 +1,94 @@ +. + * + * @category Menu + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Primary, top-level menu + * + * @category General + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class PrimaryNav extends Menu +{ + function show() + { + $user = common_current_user(); + $this->action->elementStart('ul', array('class' => 'nav')); + if (Event::handle('StartPrimaryNav', array($this->action))) { + if (!empty($user)) { + $this->action->menuItem(common_local_url('profilesettings'), + _m('Settings'), + _m('Change your personal settings'), + false, + 'nav_account'); + if ($user->hasRight(Right::CONFIGURESITE)) { + $this->action->menuItem(common_local_url('siteadminpanel'), + _m('Admin'), + _m('Site configuration'), + false, + 'nav_admin'); + } + $this->action->menuItem(common_local_url('logout'), + _m('Logout'), + _m('Logout from the site'), + false, + 'nav_logout'); + } else { + $this->action->menuItem(common_local_url('login'), + _m('Login'), + _m('Login to the site'), + false, + 'nav_login'); + } + + if (!empty($user) || !common_config('site', 'private')) { + $this->action->menuItem(common_local_url('noticesearch'), + _m('Search'), + _m('Search the site'), + false, + 'nav_search'); + } + + Event::handle('EndPrimaryNav', array($this->action)); + } + + $this->action->elementEnd('ul'); + } +} diff --git a/lib/publicgroupnav.php b/lib/publicgroupnav.php index ae9cbdebb4..bd2ad53124 100644 --- a/lib/publicgroupnav.php +++ b/lib/publicgroupnav.php @@ -46,22 +46,8 @@ require_once INSTALLDIR.'/lib/widget.php'; * @see Widget */ -class PublicGroupNav extends Widget +class PublicGroupNav extends Menu { - 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 * diff --git a/lib/searchaction.php b/lib/searchaction.php index 67d0bcdeb8..73c287eef3 100644 --- a/lib/searchaction.php +++ b/lib/searchaction.php @@ -70,7 +70,7 @@ class SearchAction extends Action * @return void * @see SearchGroupNav */ - function showLocalNav() + function showObjectNav() { $nav = new SearchGroupNav($this, $this->trimmed('q')); $nav->show(); diff --git a/lib/searchgroupnav.php b/lib/searchgroupnav.php index e843dc096c..cfe8fde353 100644 --- a/lib/searchgroupnav.php +++ b/lib/searchgroupnav.php @@ -2,7 +2,7 @@ /** * StatusNet, the distributed open-source microblogging tool * - * Menu for search actions + * Menu for search group of actions * * PHP version 5 * @@ -22,7 +22,7 @@ * @category Menu * @package StatusNet * @author Evan Prodromou - * @copyright 2008 StatusNet, Inc. + * @copyright 2008-2011 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -31,12 +31,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/widget.php'; - /** * Menu for public group of actions * - * @category Output + * @category Menu * @package StatusNet * @author Evan Prodromou * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 @@ -45,9 +43,8 @@ require_once INSTALLDIR.'/lib/widget.php'; * @see Widget */ -class SearchGroupNav extends Widget +class SearchGroupNav extends Menu { - var $action = null; var $q = null; /** @@ -59,7 +56,6 @@ class SearchGroupNav extends Widget function __construct($action=null, $q = null) { parent::__construct($action); - $this->action = $action; $this->q = $q; } diff --git a/lib/secondarynav.php b/lib/secondarynav.php new file mode 100644 index 0000000000..542de51ac1 --- /dev/null +++ b/lib/secondarynav.php @@ -0,0 +1,90 @@ +. + * + * @category Cache + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Secondary menu, shown at the bottom of all pages + * + * @category General + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class SecondaryNav extends Menu +{ + function show() + { + $this->out->elementStart('ul', array('class' => 'nav', + 'id' => 'site_nav_global_secondary')); + if (Event::handle('StartSecondaryNav', array($this->action))) { + $this->out->menuItem(common_local_url('doc', array('title' => 'help')), + // TRANS: Secondary navigation menu option leading to help on StatusNet. + _('Help')); + $this->out->menuItem(common_local_url('doc', array('title' => 'about')), + // TRANS: Secondary navigation menu option leading to text about StatusNet site. + _('About')); + $this->out->menuItem(common_local_url('doc', array('title' => 'faq')), + // TRANS: Secondary navigation menu option leading to Frequently Asked Questions. + _('FAQ')); + $bb = common_config('site', 'broughtby'); + if (!empty($bb)) { + $this->out->menuItem(common_local_url('doc', array('title' => 'tos')), + // TRANS: Secondary navigation menu option leading to Terms of Service. + _('TOS')); + } + $this->out->menuItem(common_local_url('doc', array('title' => 'privacy')), + // TRANS: Secondary navigation menu option leading to privacy policy. + _('Privacy')); + $this->out->menuItem(common_local_url('doc', array('title' => 'source')), + // TRANS: Secondary navigation menu option. Leads to information about StatusNet and its license. + _('Source')); + $this->out->menuItem(common_local_url('version'), + // TRANS: Secondary navigation menu option leading to version information on the StatusNet site. + _('Version')); + $this->out->menuItem(common_local_url('doc', array('title' => 'contact')), + // TRANS: Secondary navigation menu option leading to e-mail contact information on the + // TRANS: StatusNet site, where to report bugs, ... + _('Contact')); + $this->out->menuItem(common_local_url('doc', array('title' => 'badge')), + // TRANS: Secondary navigation menu option. Leads to information about embedding a timeline widget. + _('Badge')); + Event::handle('EndSecondaryNav', array($this->action)); + } + $this->out->elementEnd('ul'); + } +} \ No newline at end of file diff --git a/lib/settingsaction.php b/lib/settingsaction.php index 8c00054dcb..dc60137ab4 100644 --- a/lib/settingsaction.php +++ b/lib/settingsaction.php @@ -163,4 +163,15 @@ class SettingsAction extends CurrentUserDesignAction $menu = new SettingsNav($this); $menu->show(); } + + /** + * Show notice form. + * + * @return nothing + */ + + function showNoticeForm() + { + return; + } } diff --git a/lib/settingsnav.php b/lib/settingsnav.php index a73f73f86a..697e7ee46b 100644 --- a/lib/settingsnav.php +++ b/lib/settingsnav.php @@ -1,7 +1,7 @@ - * @copyright 2010 StatusNet, Inc. + * @copyright 2010,2011 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ @@ -46,21 +46,8 @@ if (!defined('STATUSNET')) { * @see HTMLOutputter */ -class SettingsNav extends Widget +class SettingsNav extends Menu { - 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 * diff --git a/lib/subgroupnav.php b/lib/subgroupnav.php index be3ba27480..ee4b0a8dff 100644 --- a/lib/subgroupnav.php +++ b/lib/subgroupnav.php @@ -22,7 +22,7 @@ * @category Subs * @package StatusNet * @author Evan Prodromou - * @copyright 2008-2009 StatusNet, Inc. + * @copyright 2008-2011 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -43,9 +43,8 @@ require_once INSTALLDIR.'/lib/widget.php'; * @link http://status.net/ */ -class SubGroupNav extends Widget +class SubGroupNav extends Menu { - var $action = null; var $user = null; /** @@ -57,7 +56,6 @@ class SubGroupNav extends Widget function __construct($action=null, $user=null) { parent::__construct($action); - $this->action = $action; $this->user = $user; } diff --git a/lib/userprofile.php b/lib/userprofile.php index 0b7efb22fc..9c563db5d0 100644 --- a/lib/userprofile.php +++ b/lib/userprofile.php @@ -95,6 +95,8 @@ class UserProfile extends Widget function showAvatar() { + $this->out->elementStart('div', 'ur_face'); + if (Event::handle('StartProfilePageAvatar', array($this->out, $this->profile))) { $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE); @@ -119,6 +121,8 @@ class UserProfile extends Widget Event::handle('EndProfilePageAvatar', array($this->out, $this->profile)); } + + $this->out->elementEnd('div'); } function showNickname()