git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit 592e2be5 authored by Evan Prodromou's avatar Evan Prodromou

Make new menu the default menu

There's a new menu layout in this version of the software. It was
implemented as a plugin in 0.9.x to avoid clashes with existing themes,
but we're going to break that compatibility in this version, so we're just going for it.

This change involved moving all the changes in NewMenuPlugin into the
default code that was calling it. In addition, since
accountsettingsaction and connectsettingsaction differed only by menu,
I removed them, changed all references to them to the settingsmenu, and moved
the combined nav to its own class.

Let's put that episode behind us.

The CSS shim that was loaded by NewMenuPlugin for certain themes and certain actions
was removed.
parent 7699bb3d
......@@ -32,7 +32,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
define('MAX_ORIGINAL', 480);
......@@ -49,7 +49,7 @@ define('MAX_ORIGINAL', 480);
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
class AvatarsettingsAction extends AccountSettingsAction
class AvatarsettingsAction extends SettingsAction
{
var $mode = null;
var $imagefile = null;
......
......@@ -32,7 +32,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
/**
* Settings for email
......@@ -47,7 +47,7 @@ require_once INSTALLDIR.'/lib/accountsettingsaction.php';
* @see Widget
*/
class EmailsettingsAction extends AccountSettingsAction
class EmailsettingsAction extends SettingsAction
{
/**
* Title of the page
......
......@@ -32,7 +32,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
define('MAX_ORIGINAL', 480);
......
......@@ -43,7 +43,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
* @see SettingsAction
*/
class ImsettingsAction extends ConnectSettingsAction
class ImsettingsAction extends SettingsAction
{
/**
* Title of the page
......
......@@ -31,9 +31,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR . '/lib/settingsaction.php';
require_once INSTALLDIR . '/lib/applicationlist.php';
/**
* Show a user's registered OAuth applications
*
......
......@@ -31,8 +31,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR . '/lib/connectsettingsaction.php';
require_once INSTALLDIR . '/lib/applicationlist.php';
require_once INSTALLDIR . '/lib/apioauthstore.php';
/**
......@@ -46,7 +44,7 @@ require_once INSTALLDIR . '/lib/apioauthstore.php';
*
* @see SettingsAction
*/
class OauthconnectionssettingsAction extends ConnectSettingsAction
class OauthconnectionssettingsAction extends SettingsAction
{
var $page = null;
var $oauth_token = null;
......
......@@ -32,7 +32,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
/**
* Change password
......@@ -45,7 +45,7 @@ require_once INSTALLDIR.'/lib/accountsettingsaction.php';
* @link http://status.net/
*/
class PasswordsettingsAction extends AccountSettingsAction
class PasswordsettingsAction extends SettingsAction
{
/**
* Title of the page
......
......@@ -33,7 +33,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
/**
* Change profile settings
......@@ -47,7 +47,7 @@ require_once INSTALLDIR.'/lib/accountsettingsaction.php';
* @link http://status.net/
*/
class ProfilesettingsAction extends AccountSettingsAction
class ProfilesettingsAction extends SettingsAction
{
/**
* Title of the page
......
......@@ -106,7 +106,7 @@ class ShowstreamAction extends ProfileAction
function showLocalNav()
{
$nav = new PersonalGroupNav($this);
$nav = new SubGroupNav($this, $this->user);
$nav->show();
}
......
......@@ -31,8 +31,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/connectsettingsaction.php';
/**
* Settings for SMS
*
......@@ -45,7 +43,7 @@ require_once INSTALLDIR.'/lib/connectsettingsaction.php';
* @see SettingsAction
*/
class SmssettingsAction extends ConnectSettingsAction
class SmssettingsAction extends SettingsAction
{
/**
* Title of the page
......
......@@ -32,7 +32,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/accountsettingsaction.php';
/**
* Miscellaneous settings actions
......@@ -47,7 +47,7 @@ require_once INSTALLDIR.'/lib/accountsettingsaction.php';
* @link http://status.net/
*/
class UrlsettingsAction extends AccountSettingsAction
class UrlsettingsAction extends SettingsAction
{
/**
* Title of the page
......
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Base class for account settings actions
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Settings
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2008-2009 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/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/settingsaction.php';
/**
* Base class for account settings actions
*
* @category Settings
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @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 AccountSettingsAction extends SettingsAction
{
/**
* Show the local navigation menu
*
* This is the same for all settings, so we show it here.
*
* @return void
*/
function showLocalNav()
{
$menu = new AccountSettingsNav($this);
$menu->show();
}
}
/**
* A widget for showing the settings group local nav menu
*
* @category Widget
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @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 AccountSettingsNav 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('StartAccountSettingsNav', array(&$this->action))) {
$user = common_current_user();
if(Event::handle('StartAccountSettingsProfileMenuItem', array($this, &$menu))){
// TRANS: Link title attribute in user account settings menu.
$title = _('Change your profile settings');
// TRANS: Link description in user account settings menu.
$this->showMenuItem('profilesettings',_('Profile'),$title);
Event::handle('EndAccountSettingsProfileMenuItem', array($this, &$menu));
}
if(Event::handle('StartAccountSettingsAvatarMenuItem', array($this, &$menu))){
// TRANS: Link title attribute in user account settings menu.
$title = _('Upload an avatar');
// TRANS: Link description in user account settings menu.
$this->showMenuItem('avatarsettings',_('Avatar'),$title);
Event::handle('EndAccountSettingsAvatarMenuItem', array($this, &$menu));
}
if(Event::handle('StartAccountSettingsPasswordMenuItem', array($this, &$menu))){
// TRANS: Link title attribute in user account settings menu.
$title = _('Change your password');
// TRANS: Link description in user account settings menu.
$this->showMenuItem('passwordsettings',_('Password'),$title);
Event::handle('EndAccountSettingsPasswordMenuItem', array($this, &$menu));
}
if(Event::handle('StartAccountSettingsEmailMenuItem', array($this, &$menu))){
// TRANS: Link title attribute in user account settings menu.
$title = _('Change email handling');
// TRANS: Link description in user account settings menu.
$this->showMenuItem('emailsettings',_('Email'),$title);
Event::handle('EndAccountSettingsEmailMenuItem', array($this, &$menu));
}
if(Event::handle('StartAccountSettingsDesignMenuItem', array($this, &$menu))){
// TRANS: Link title attribute in user account settings menu.
$title = _('Design your profile');
// TRANS: Link description in user account settings menu.
$this->showMenuItem('userdesignsettings',_('Design'),$title);
Event::handle('EndAccountSettingsDesignMenuItem', array($this, &$menu));
}
if(Event::handle('StartAccountSettingsUrlMenuItem', array($this, &$menu))){
// TRANS: Link title attribute in user account settings menu.
$title = _('URL shortener settings');
// TRANS: Link description in user account settings menu.
$this->showMenuItem('urlsettings',_('URL'),$title);
Event::handle('EndAccountSettingsUrlMenuItem', array($this, &$menu));
}
Event::handle('EndAccountSettingsNav', array(&$this->action));
}
$this->action->elementEnd('ul');
}
function showMenuItem($menuaction, $desc1, $desc2)
{
$action_name = $this->action->trimmed('action');
$this->action->menuItem(common_local_url($menuaction),
$desc1,
$desc2,
$action_name === $menuaction);
}
}
......@@ -476,9 +476,13 @@ class Action extends HTMLOutputter // lawsuit
$user = User::singleUser();
$url = common_local_url('showstream',
array('nickname' => $user->nickname));
} else if (common_logged_in()) {
$cur = common_current_user();
$url = common_local_url('all', array('nickname' => $cur->nickname));
} else {
$url = common_local_url('public');
}
$this->elementStart('a', array('class' => 'url home bookmark',
'href' => $url));
......@@ -513,7 +517,8 @@ class Action extends HTMLOutputter // lawsuit
$this->text(' ');
$this->element('span', array('class' => 'fn org'), common_config('site', 'name'));
$this->elementEnd('a');
Event::handle('EndAddressData', array($this));
Event::handle('EndAddressData', array($action));
}
$this->elementEnd('address');
}
......@@ -529,71 +534,62 @@ class Action extends HTMLOutputter // lawsuit
$this->elementStart('ul', array('class' => 'nav',
'id' => 'site_nav_global_primary'));
if (Event::handle('StartPrimaryNav', array($this))) {
if ($user) {
// TRANS: Tooltip for main menu option "Personal"
$tooltip = _m('TOOLTIP', 'Personal profile and friends timeline');
$this->menuItem(common_local_url('all', array('nickname' => $user->nickname)),
// TRANS: Main menu option when logged in for access to personal profile and friends timeline
_m('MENU', 'Personal'), $tooltip, false, 'nav_home');
// TRANS: Tooltip for main menu option "Account"
$tooltip = _m('TOOLTIP', 'Change your email, avatar, password, profile');
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'),
// TRANS: Main menu option when logged in for access to user settings
_('Account'), $tooltip, false, 'nav_account');
// TRANS: Tooltip for main menu option "Services"
$tooltip = _m('TOOLTIP', 'Connect to services');
$this->menuItem(common_local_url('oauthconnectionssettings'),
// TRANS: Main menu option when logged in and connection are possible for access to options to connect to other services
_('Connect'), $tooltip, false, 'nav_connect');
_m('Settings'),
_m('Change your personal settings'),
false,
'nav_account');
if ($user->hasRight(Right::CONFIGURESITE)) {
// TRANS: Tooltip for menu option "Admin"
$tooltip = _m('TOOLTIP', 'Change site configuration');
$this->menuItem(common_local_url('siteadminpanel'),
// TRANS: Main menu option when logged in and site admin for access to site configuration
_m('MENU', 'Admin'), $tooltip, false, 'nav_admin');
}
if (common_config('invite', 'enabled')) {
// TRANS: Tooltip for main menu option "Invite"
$tooltip = _m('TOOLTIP', 'Invite friends and colleagues to join you on %s');
$this->menuItem(common_local_url('invite'),
// TRANS: Main menu option when logged in and invitations are allowed for inviting new users
_m('MENU', 'Invite'),
sprintf($tooltip,
common_config('site', 'name')),
false, 'nav_invitecontact');
_m('Admin'),
_m('Site configuration'),
false,
'nav_admin');
}
// TRANS: Tooltip for main menu option "Logout"
$tooltip = _m('TOOLTIP', 'Logout from the site');
$this->menuItem(common_local_url('logout'),
// TRANS: Main menu option when logged in to log out the current user
_m('MENU', 'Logout'), $tooltip, false, 'nav_logout');
}
else {
if (!common_config('site', 'closed') && !common_config('site', 'inviteonly')) {
// TRANS: Tooltip for main menu option "Register"
$tooltip = _m('TOOLTIP', 'Create an account');
$this->menuItem(common_local_url('register'),
// TRANS: Main menu option when not logged in to register a new account
_m('MENU', 'Register'), $tooltip, false, 'nav_register');
}
// TRANS: Tooltip for main menu option "Login"
$tooltip = _m('TOOLTIP', 'Login to the site');
_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'),
// TRANS: Main menu option when not logged in to log in
_m('MENU', 'Login'), $tooltip, false, 'nav_login');
_m('Login'),
_m('Login to the site'),
false,
'nav_login');
}
// TRANS: Tooltip for main menu option "Help"
$tooltip = _m('TOOLTIP', 'Help me!');
$this->menuItem(common_local_url('doc', array('title' => 'help')),
// TRANS: Main menu option for help on the StatusNet site
_m('MENU', 'Help'), $tooltip, false, 'nav_help');
if ($user || !common_config('site', 'private')) {
// TRANS: Tooltip for main menu option "Search"
$tooltip = _m('TOOLTIP', 'Search for people or text');
$this->menuItem(common_local_url('peoplesearch'),
// TRANS: Main menu option when logged in or when the StatusNet instance is not private
_m('MENU', 'Search'), $tooltip, false, 'nav_search');
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');
......
......@@ -32,9 +32,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR . '/lib/accountsettingsaction.php';
require_once INSTALLDIR . '/lib/webcolor.php';
/**
* Base class for setting a user or group design
*
......@@ -48,7 +45,8 @@ require_once INSTALLDIR . '/lib/webcolor.php';
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
class DesignSettingsAction extends AccountSettingsAction
class DesignSettingsAction extends SettingsAction
{
var $submitaction = null;
......
......@@ -79,7 +79,7 @@ class PersonalGroupNav extends Widget
{
$user = null;
// FIXME: we should probably pass this in
// FIXME: we should probably pass this in
$action = $this->action->trimmed('action');
$nickname = $this->action->trimmed('nickname');
......@@ -98,25 +98,20 @@ class PersonalGroupNav extends Widget
if (Event::handle('StartPersonalGroupNav', array($this))) {
$this->out->menuItem(common_local_url('all', array('nickname' =>
$nickname)),
_('Personal'),
sprintf(_('%s and friends'), $name),
$action == 'all', 'nav_timeline_personal');
$nickname)),
_('Home'),
sprintf(_('%s and friends'), $name),
$action == 'all', 'nav_timeline_personal');
$this->out->menuItem(common_local_url('replies', array('nickname' =>
$nickname)),
_('Replies'),
sprintf(_('Replies to %s'), $name),
$action == 'replies', 'nav_timeline_replies');
$this->out->menuItem(common_local_url('showstream', array('nickname' =>
$nickname)),
_('Profile'),
$name,
$action == 'showstream', 'nav_profile');
$nickname)),
_('Replies'),
sprintf(_('Replies to %s'), $name),
$action == 'replies', 'nav_timeline_replies');
$this->out->menuItem(common_local_url('showfavorites', array('nickname' =>
$nickname)),
_('Favorites'),
sprintf(_('%s\'s favorite notices'), ($user_profile) ? $name : _('User')),
$action == 'showfavorites', 'nav_timeline_favorites');
$nickname)),
_('Favorites'),
sprintf(_('%s\'s favorite notices'), ($user_profile) ? $name : _('User')),
$action == 'showfavorites', 'nav_timeline_favorites');
$cur = common_current_user();
......@@ -124,15 +119,15 @@ class PersonalGroupNav extends Widget
!common_config('singleuser', 'enabled')) {
$this->out->menuItem(common_local_url('inbox', array('nickname' =>
$nickname)),
_('Inbox'),
_('Your incoming messages'),
$action == 'inbox');
$nickname)),
_('Inbox'),
_('Your incoming messages'),
$action == 'inbox');
$this->out->menuItem(common_local_url('outbox', array('nickname' =>
$nickname)),
_('Outbox'),
_('Your sent messages'),
$action == 'outbox');
$nickname)),
_('Outbox'),
_('Your sent messages'),
$action == 'outbox');
}
Event::handle('EndPersonalGroupNav', array($this));
}
......
......@@ -150,4 +150,17 @@ class SettingsAction extends CurrentUserDesignAction
return '';
}
/**
* Show the local navigation menu
*
* This is the same for all settings, so we show it here.
*
* @return void
*/
function showLocalNav()
{
$menu = new SettingsNav($this);
$menu->show();
}
}
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Base class for connection settings actions
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2010, StatusNet, Inc.
*
* Settings menu
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
......@@ -19,49 +20,22 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Settings
* @category Widget
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2008-2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @copyright 2010 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
if (!defined('STATUSNET')) {
// This check helps protect against security problems;
// your code file can't be executed directly from the web.
exit(1);
}
require_once INSTALLDIR.'/lib/settingsaction.php';
/**
* Base class for connection settings actions
*
* @category Settings
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @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 ConnectSettingsAction extends SettingsAction
{
/**
* Show the local navigation menu
*
* This is the same for all settings, so we show it here.
*
* @return void
*/
function showLocalNav()
{
$menu = new ConnectSettingsNav($this);
$menu->show();
}
}
/**
* A widget for showing the connect group local nav menu
* A widget for showing the settings group local nav menu
*
* @category Widget
* @package StatusNet
......@@ -71,7 +45,8 @@ class ConnectSettingsAction extends SettingsAction
*
* @see HTMLOutputter
*/
class ConnectSettingsNav extends Widget
class SettingsNav extends Widget
{
var $action = null;
......@@ -91,45 +66,63 @@ class ConnectSettingsNav extends Widget
*
* @return void
*/
function show()
{
$action_name = $this->action->trimmed('action');
$actionName = $this->action->trimmed('action');
$this->action->elementStart('ul', array('class' => 'nav'));
if (Event::handle('StartConnectSettingsNav', array(&$this->action))) {
# action => array('prompt', 'title')
$menu = array();
$transports = array();
Event::handle('GetImTransports', array(&$transports));
if ($transports) {
$menu['imsettings'] =
// TRANS: Menu item for Instant Messaging settings.
array(_m('MENU','IM'),
// TRANS: Tooltip for Instant Messaging menu item.
_('Updates by instant messenger (IM)'));
if (Event::handle('StartAccountSettingsNav', array(&$this->action))) {
$this->action->menuItem(common_local_url('profilesettings'),
_('Profile'),
_('Change your profile settings'),
$actionName == 'profilesettings');
$this->action->menuItem(common_local_url('avatarsettings'),
_('Avatar'),
_('Upload an avatar'),
$actionName == 'avatarsettings');
$this->action->menuItem(common_local_url('passwordsettings'),
_('Password'),
_('Change your password'),
$actionName == 'passwordsettings');
$this->action->menuItem(common_local_url('emailsettings'),
_('Email'),
_('Change email handling'),
$actionName == 'emailsettings');
$this->action->menuItem(common_local_url('userdesignsettings'),
_('Design'),
_('Design your profile'),
$actionName == 'userdesignsettings');
$this->action->menuItem(common_local_url('urlsettings'),
_('URL'),
_('URL shorteners'),
$actionName == 'urlsettings');
Event::handle('EndAccountSettingsNav', array(&$this->action));
if (common_config('xmpp', 'enabled')) {
$this->action->menuItem(common_local_url('imsettings'),
_m('IM'),
_('Updates by instant messenger (IM)'),
$actionName == 'imsettings');
}
if (common_config('sms', 'enabled')) {
$menu['smssettings'] =
// TRANS: Menu item for Short Message Service settings.
array(_m('MENU','SMS'),
// TRANS: Tooltip for Short Message Service menu item.
_('Updates by SMS'));
$this->action->menuItem(common_local_url('smssettings'),