From: Evan Prodromou Date: Sun, 23 Jan 2011 17:35:35 +0000 (-0500) Subject: Make new menu the default menu X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=592e2be5e1534c954c834fac65958d32bf0d874f;p=quix0rs-gnu-social.git 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. --- diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php index 375420c5c9..7b671d9e32 100644 --- a/actions/avatarsettings.php +++ b/actions/avatarsettings.php @@ -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; diff --git a/actions/emailsettings.php b/actions/emailsettings.php index 4a7dc1b871..41c12f2a04 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -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 diff --git a/actions/grouplogo.php b/actions/grouplogo.php index f414a23cc3..69840485e0 100644 --- a/actions/grouplogo.php +++ b/actions/grouplogo.php @@ -32,7 +32,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/accountsettingsaction.php'; + define('MAX_ORIGINAL', 480); diff --git a/actions/imsettings.php b/actions/imsettings.php index 1b1bc0dc0d..76fb2285c3 100644 --- a/actions/imsettings.php +++ b/actions/imsettings.php @@ -43,7 +43,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @see SettingsAction */ -class ImsettingsAction extends ConnectSettingsAction +class ImsettingsAction extends SettingsAction { /** * Title of the page diff --git a/actions/oauthappssettings.php b/actions/oauthappssettings.php index c98c90dbf8..3a8fc98966 100644 --- a/actions/oauthappssettings.php +++ b/actions/oauthappssettings.php @@ -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 * diff --git a/actions/oauthconnectionssettings.php b/actions/oauthconnectionssettings.php index cdb73203f0..c173a32230 100644 --- a/actions/oauthconnectionssettings.php +++ b/actions/oauthconnectionssettings.php @@ -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; diff --git a/actions/passwordsettings.php b/actions/passwordsettings.php index 3bb8e3bb9f..c9bd200bd8 100644 --- a/actions/passwordsettings.php +++ b/actions/passwordsettings.php @@ -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 diff --git a/actions/profilesettings.php b/actions/profilesettings.php index 19fbdbd293..1334644e9c 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -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 diff --git a/actions/showstream.php b/actions/showstream.php index 14f629b6a8..1688677d84 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -106,7 +106,7 @@ class ShowstreamAction extends ProfileAction function showLocalNav() { - $nav = new PersonalGroupNav($this); + $nav = new SubGroupNav($this, $this->user); $nav->show(); } diff --git a/actions/smssettings.php b/actions/smssettings.php index 6af1872a0e..217db27888 100644 --- a/actions/smssettings.php +++ b/actions/smssettings.php @@ -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 diff --git a/actions/urlsettings.php b/actions/urlsettings.php index 7b2fc3f554..f8780a7e86 100644 --- a/actions/urlsettings.php +++ b/actions/urlsettings.php @@ -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 diff --git a/lib/accountsettingsaction.php b/lib/accountsettingsaction.php deleted file mode 100644 index 2c519e4abd..0000000000 --- a/lib/accountsettingsaction.php +++ /dev/null @@ -1,159 +0,0 @@ -. - * - * @category Settings - * @package StatusNet - * @author Evan Prodromou - * @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 - * @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 - * @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); - } -} diff --git a/lib/action.php b/lib/action.php index c01a686904..c8f77f79bd 100644 --- a/lib/action.php +++ b/lib/action.php @@ -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'); diff --git a/lib/connectsettingsaction.php b/lib/connectsettingsaction.php deleted file mode 100644 index 0f64fee8ce..0000000000 --- a/lib/connectsettingsaction.php +++ /dev/null @@ -1,139 +0,0 @@ -. - * - * @category Settings - * @package StatusNet - * @author Evan Prodromou - * @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 connection settings actions - * - * @category Settings - * @package StatusNet - * @author Evan Prodromou - * @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 - * - * @category Widget - * @package StatusNet - * @author Evan Prodromou - * @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 ConnectSettingsNav 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('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 (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')); - } - - $menu['oauthconnectionssettings'] = array( - // TRANS: Menu item for OuAth connection settings. - _m('MENU','Connections'), - // TRANS: Tooltip for connected applications (Connections through OAuth) menu item. - _('Authorized connected applications') - ); - - foreach ($menu as $menuaction => $menudesc) { - $this->action->menuItem(common_local_url($menuaction), - $menudesc[0], - $menudesc[1], - $action_name === $menuaction); - } - - Event::handle('EndConnectSettingsNav', array(&$this->action)); - } - - $this->action->elementEnd('ul'); - } -} diff --git a/lib/designsettings.php b/lib/designsettings.php index d0601c5530..eb3a5908e6 100644 --- a/lib/designsettings.php +++ b/lib/designsettings.php @@ -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; diff --git a/lib/personalgroupnav.php b/lib/personalgroupnav.php index 1f543b8974..f57de8e240 100644 --- a/lib/personalgroupnav.php +++ b/lib/personalgroupnav.php @@ -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)); } diff --git a/lib/settingsaction.php b/lib/settingsaction.php index c3669868d4..8c00054dcb 100644 --- a/lib/settingsaction.php +++ b/lib/settingsaction.php @@ -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(); + } } diff --git a/lib/settingsnav.php b/lib/settingsnav.php new file mode 100644 index 0000000000..a73f73f86a --- /dev/null +++ b/lib/settingsnav.php @@ -0,0 +1,132 @@ +. + * + * @category Widget + * @package StatusNet + * @author Evan Prodromou + * @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')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * A widget for showing the settings group local nav menu + * + * @category Widget + * @package StatusNet + * @author Evan Prodromou + * @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 SettingsNav 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() + { + $actionName = $this->action->trimmed('action'); + $this->action->elementStart('ul', array('class' => 'nav')); + + 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')) { + $this->action->menuItem(common_local_url('smssettings'), + _m('SMS'), + _('Updates by SMS'), + $actionName == 'smssettings'); + } + + $this->action->menuItem(common_local_url('oauthconnectionssettings'), + _('Connections'), + _('Authorized connected applications'), + $actionName == 'oauthconnectionsettings'); + + Event::handle('EndConnectSettingsNav', array(&$this->action)); + } + + $this->action->elementEnd('ul'); + } +} diff --git a/lib/subgroupnav.php b/lib/subgroupnav.php index 2748b59e18..be3ba27480 100644 --- a/lib/subgroupnav.php +++ b/lib/subgroupnav.php @@ -76,6 +76,12 @@ class SubGroupNav extends Widget if (Event::handle('StartSubGroupNav', array($this))) { + $this->out->menuItem(common_local_url('showstream', array('nickname' => + $this->user->nickname)), + _('Profile'), + (empty($profile)) ? $this->user->nickname : $profile->getBestName(), + $action == 'showstream', + 'nav_profile'); $this->out->menuItem(common_local_url('subscriptions', array('nickname' => $this->user->nickname)), diff --git a/plugins/Facebook/FBConnectSettings.php b/plugins/Facebook/FBConnectSettings.php index 701994d0d0..4043f666fa 100644 --- a/plugins/Facebook/FBConnectSettings.php +++ b/plugins/Facebook/FBConnectSettings.php @@ -42,7 +42,7 @@ require_once INSTALLDIR.'/lib/connectsettingsaction.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 FBConnectSettingsAction extends ConnectSettingsAction +class FBSettingsAction extends ConnectSettingsAction { /** * Title of the page diff --git a/plugins/Facebook/FacebookPlugin.php b/plugins/Facebook/FacebookPlugin.php index 14af21b516..da55c8a6e2 100644 --- a/plugins/Facebook/FacebookPlugin.php +++ b/plugins/Facebook/FacebookPlugin.php @@ -150,7 +150,7 @@ class FacebookPlugin extends Plugin return false; case 'FBConnectAuthAction': case 'FBConnectLoginAction': - case 'FBConnectSettingsAction': + case 'FBSettingsAction': case 'FBC_XDReceiverAction': include_once INSTALLDIR . '/plugins/Facebook/' . mb_substr($cls, 0, -6) . '.php'; @@ -357,7 +357,7 @@ class FacebookPlugin extends Plugin // List of actions that require FB stuff $needy = array('FBConnectLoginAction', 'FBConnectauthAction', - 'FBConnectSettingsAction'); + 'FBSettingsAction'); if (in_array(get_class($action), $needy)) { return true; diff --git a/plugins/FacebookBridge/actions/facebooksettings.php b/plugins/FacebookBridge/actions/facebooksettings.php index 6576e20411..b9526c1269 100644 --- a/plugins/FacebookBridge/actions/facebooksettings.php +++ b/plugins/FacebookBridge/actions/facebooksettings.php @@ -41,7 +41,7 @@ if (!defined('STATUSNET')) { * * @see SettingsAction */ -class FacebooksettingsAction extends ConnectSettingsAction { +class FacebooksettingsAction extends SettingsAction { private $facebook; // Facebook PHP-SDK client obj private $flink; private $user; diff --git a/plugins/NewMenu/NewMenuPlugin.php b/plugins/NewMenu/NewMenuPlugin.php index cdcea5cd92..4f0843e26c 100644 --- a/plugins/NewMenu/NewMenuPlugin.php +++ b/plugins/NewMenu/NewMenuPlugin.php @@ -22,7 +22,6 @@ * * @category Sample * @package StatusNet - * @author Brion Vibber * @author Evan Prodromou * @copyright 2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 @@ -43,393 +42,17 @@ if (!defined('STATUSNET')) { * * @category NewMenu * @package StatusNet - * @author Brion Vibber * @author Evan Prodromou * @copyright 2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ + class NewMenuPlugin extends Plugin { - public $loadCSS = false; - - /** - * Load related modules when needed - * - * @param string $cls Name of the class to be loaded - * - * @return boolean hook value; true means continue processing, false means stop. - */ - - function onAutoload($cls) - { - $dir = dirname(__FILE__); - - switch ($cls) - { - case 'HelloAction': - include_once $dir . '/' . strtolower(mb_substr($cls, 0, -6)) . '.php'; - return false; - case 'User_greeting_count': - include_once $dir . '/'.$cls.'.php'; - return false; - default: - return true; - } - } - - /** - * Modify the default menu - * - * @param Action $action The current action handler. Use this to - * do any output. - * - * @return boolean hook value; true means continue processing, false means stop. - * - * @see Action - */ - - function onStartPrimaryNav($action) - { - $user = common_current_user(); - - if (!empty($user)) { - $action->menuItem(common_local_url('all', - array('nickname' => $user->nickname)), - _m('Home'), - _m('Friends timeline'), - false, - 'nav_home'); - $action->menuItem(common_local_url('showstream', - array('nickname' => $user->nickname)), - _m('Profile'), - _m('Your profile'), - false, - 'nav_profile'); - $action->menuItem(common_local_url('public'), - _m('Public'), - _m('Everyone on this site'), - false, - 'nav_public'); - $action->menuItem(common_local_url('profilesettings'), - _m('Settings'), - _m('Change your personal settings'), - false, - 'nav_account'); - if ($user->hasRight(Right::CONFIGURESITE)) { - $action->menuItem(common_local_url('siteadminpanel'), - _m('Admin'), - _m('Site configuration'), - false, - 'nav_admin'); - } - $action->menuItem(common_local_url('logout'), - _m('Logout'), - _m('Logout from the site'), - false, - 'nav_logout'); - } else { - $action->menuItem(common_local_url('public'), - _m('Public'), - _m('Everyone on this site'), - false, - 'nav_public'); - $action->menuItem(common_local_url('login'), - _m('Login'), - _m('Login to the site'), - false, - 'nav_login'); - } - - if (!empty($user) || !common_config('site', 'private')) { - $action->menuItem(common_local_url('noticesearch'), - _m('Search'), - _m('Search the site'), - false, - 'nav_search'); - } - - Event::handle('EndPrimaryNav', array($action)); - - return false; - } - - function onStartPersonalGroupNav($menu) - { - $user = null; - - // FIXME: we should probably pass this in - - $action = $menu->action->trimmed('action'); - $nickname = $menu->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; - } - - $menu->out->menuItem(common_local_url('all', array('nickname' => - $nickname)), - _('Home'), - sprintf(_('%s and friends'), $name), - $action == 'all', 'nav_timeline_personal'); - $menu->out->menuItem(common_local_url('replies', array('nickname' => - $nickname)), - _('Replies'), - sprintf(_('Replies to %s'), $name), - $action == 'replies', 'nav_timeline_replies'); - $menu->out->menuItem(common_local_url('showfavorites', array('nickname' => - $nickname)), - _('Favorites'), - sprintf(_('%s\'s favorite notices'), ($user_profile) ? $name : _('User')), - $action == 'showfavorites', 'nav_timeline_favorites'); - - $cur = common_current_user(); - - if ($cur && $cur->id == $user->id && - !common_config('singleuser', 'enabled')) { - - $menu->out->menuItem(common_local_url('inbox', array('nickname' => - $nickname)), - _('Inbox'), - _('Your incoming messages'), - $action == 'inbox'); - $menu->out->menuItem(common_local_url('outbox', array('nickname' => - $nickname)), - _('Outbox'), - _('Your sent messages'), - $action == 'outbox'); - } - Event::handle('EndPersonalGroupNav', array($menu)); - return false; - } - - function onStartSubGroupNav($menu) - { - $cur = common_current_user(); - $action = $menu->action->trimmed('action'); - - $profile = $menu->user->getProfile(); - - $menu->out->menuItem(common_local_url('showstream', array('nickname' => - $menu->user->nickname)), - _('Profile'), - (empty($profile)) ? $menu->user->nickname : $profile->getBestName(), - $action == 'showstream', - 'nav_profile'); - $menu->out->menuItem(common_local_url('subscriptions', - array('nickname' => - $menu->user->nickname)), - _('Subscriptions'), - sprintf(_('People %s subscribes to'), - $menu->user->nickname), - $action == 'subscriptions', - 'nav_subscriptions'); - $menu->out->menuItem(common_local_url('subscribers', - array('nickname' => - $menu->user->nickname)), - _('Subscribers'), - sprintf(_('People subscribed to %s'), - $menu->user->nickname), - $action == 'subscribers', - 'nav_subscribers'); - $menu->out->menuItem(common_local_url('usergroups', - array('nickname' => - $menu->user->nickname)), - _('Groups'), - sprintf(_('Groups %s is a member of'), - $menu->user->nickname), - $action == 'usergroups', - 'nav_usergroups'); - if (common_config('invite', 'enabled') && !is_null($cur) && $menu->user->id === $cur->id) { - $menu->out->menuItem(common_local_url('invite'), - _('Invite'), - sprintf(_('Invite friends and colleagues to join you on %s'), - common_config('site', 'name')), - $action == 'invite', - 'nav_invite'); - } - - Event::handle('EndSubGroupNav', array($menu)); - return false; - } - - function onStartShowLocalNavBlock($action) - { - $actionName = $action->trimmed('action'); - - if ($actionName == 'showstream') { - $action->elementStart('dl', array('id' => 'site_nav_local_views')); - // TRANS: DT element for local views block. String is hidden in default CSS. - $action->element('dt', null, _('Local views')); - $action->elementStart('dd'); - $nav = new SubGroupNav($action, $action->user); - $nav->show(); - $action->elementEnd('dd'); - $action->elementEnd('dl'); - Event::handle('EndShowLocalNavBlock', array($action)); - return false; - } - - return true; - } - - function onStartAccountSettingsNav(&$action) - { - $this->_settingsMenu($action); - return false; - } - - function onStartConnectSettingsNav(&$action) - { - $this->_settingsMenu($action); - return false; - } - - private function _settingsMenu(&$action) - { - $actionName = $action->trimmed('action'); - - $action->menuItem(common_local_url('profilesettings'), - _('Profile'), - _('Change your profile settings'), - $actionName == 'profilesettings'); - - $action->menuItem(common_local_url('avatarsettings'), - _('Avatar'), - _('Upload an avatar'), - $actionName == 'avatarsettings'); - - $action->menuItem(common_local_url('passwordsettings'), - _('Password'), - _('Change your password'), - $actionName == 'passwordsettings'); - - $action->menuItem(common_local_url('emailsettings'), - _('Email'), - _('Change email handling'), - $actionName == 'emailsettings'); - - $action->menuItem(common_local_url('userdesignsettings'), - _('Design'), - _('Design your profile'), - $actionName == 'userdesignsettings'); - - $action->menuItem(common_local_url('othersettings'), - _('Other'), - _('Other options'), - $actionName == 'othersettings'); - - Event::handle('EndAccountSettingsNav', array(&$action)); - - if (common_config('xmpp', 'enabled')) { - $action->menuItem(common_local_url('imsettings'), - _m('IM'), - _('Updates by instant messenger (IM)'), - $actionName == 'imsettings'); - } - - if (common_config('sms', 'enabled')) { - $action->menuItem(common_local_url('smssettings'), - _m('SMS'), - _('Updates by SMS'), - $actionName == 'smssettings'); - } - - $action->menuItem(common_local_url('oauthconnectionssettings'), - _('Connections'), - _('Authorized connected applications'), - $actionName == 'oauthconnectionsettings'); - - Event::handle('EndConnectSettingsNav', array(&$action)); - } - - function onEndShowStyles($action) - { - if (($this->showCSS || - in_array(common_config('site', 'theme'), - array('default', 'identica', 'h4ck3r'))) && - ($action instanceof AccountSettingsAction || - $action instanceof ConnectSettingsAction)) { - $action->cssLink(common_path('plugins/NewMenu/newmenu.css')); - } - return true; - } - - function onStartAddressData($action) - { - if (common_config('singleuser', 'enabled')) { - $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'); - } - - $action->elementStart('a', array('class' => 'url home bookmark', - 'href' => $url)); - - if (StatusNet::isHTTPS()) { - $logoUrl = common_config('site', 'ssllogo'); - if (empty($logoUrl)) { - // if logo is an uploaded file, try to fall back to HTTPS file URL - $httpUrl = common_config('site', 'logo'); - if (!empty($httpUrl)) { - $f = File::staticGet('url', $httpUrl); - if (!empty($f) && !empty($f->filename)) { - // this will handle the HTTPS case - $logoUrl = File::url($f->filename); - } - } - } - } else { - $logoUrl = common_config('site', 'logo'); - } - - if (empty($logoUrl) && file_exists(Theme::file('logo.png'))) { - // This should handle the HTTPS case internally - $logoUrl = Theme::path('logo.png'); - } - - if (!empty($logoUrl)) { - $action->element('img', array('class' => 'logo photo', - 'src' => $logoUrl, - 'alt' => common_config('site', 'name'))); - } - - $action->text(' '); - $action->element('span', array('class' => 'fn org'), common_config('site', 'name')); - $action->elementEnd('a'); - - Event::handle('EndAddressData', array($action)); - return false; - } - - /** - * Return version information for this plugin - * - * @param array &$versions Version info; add to this array - * - * @return boolean hook value - */ - - function onPluginVersion(&$versions) + function __construct() { - $versions[] = array('name' => 'NewMenu', - 'version' => STATUSNET_VERSION, - 'author' => 'Evan Prodromou', - 'homepage' => 'http://status.net/wiki/Plugin:NewMenu', - 'description' => - _m('A preview of the new menu '. - 'layout in StatusNet 1.0.')); - return true; + // NOOP! No hooks, no nothin'. + return; } } diff --git a/plugins/NewMenu/newmenu.css b/plugins/NewMenu/newmenu.css deleted file mode 100644 index f700fdcc45..0000000000 --- a/plugins/NewMenu/newmenu.css +++ /dev/null @@ -1,47 +0,0 @@ -body[id$=settings] #site_nav_local_views { -position:relative; -z-index:9; -float:right; -margin-right:10.65%; -width:22.25%; -} -body[id$=settings] #site_nav_local_views li { -width:100%; -margin-right:0; -margin-bottom:7px; -} -body[id$=settings] #site_nav_local_views a { -display:block; -width:80%; -padding-right:10%; -padding-left:10%; -border-radius-toprleft:0; --moz-border-radius-topleft:0; --webkit-border-top-left-radius:0; -border-radius-topright:4px; --moz-border-radius-topright:4px; --webkit-border-top-right-radius:4px; -border-radius-bottomright:4px; --moz-border-radius-bottomright:4px; --webkit-border-bottom-right-radius:4px; -} -body[id$=settings] #site_nav_local_views li.current { -box-shadow:none; --moz-box-shadow:none; --webkit-box-shadow:none; -} - -body[id$=settings] #content { -border-radius-topleft:7px; -border-radius-topright:7px; --moz-border-radius-topleft:7px; --moz-border-radius-topright:7px; --webkit-border-top-left-radius:7px; --webkit-border-top-right-radius:7px; -border-radius-topright:0; --moz-border-radius-topright:0; --webkit-border-top-right-radius:0; -} -body[id$=settings] #aside_primary { -display:none; -} diff --git a/plugins/OpenID/openidsettings.php b/plugins/OpenID/openidsettings.php index b7d5bd084d..1eb6aadb8c 100644 --- a/plugins/OpenID/openidsettings.php +++ b/plugins/OpenID/openidsettings.php @@ -45,7 +45,7 @@ require_once INSTALLDIR.'/plugins/OpenID/openid.php'; * @link http://status.net/ */ -class OpenidsettingsAction extends AccountSettingsAction +class OpenidsettingsAction extends SettingsAction { /** * Title of the page diff --git a/plugins/SubMirror/actions/mirrorsettings.php b/plugins/SubMirror/actions/mirrorsettings.php index a828b26feb..5151574c56 100644 --- a/plugins/SubMirror/actions/mirrorsettings.php +++ b/plugins/SubMirror/actions/mirrorsettings.php @@ -29,7 +29,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -class MirrorSettingsAction extends AccountSettingsAction +class MirrorSettingsAction extends SettingsAction { /** * Title of the page diff --git a/plugins/TwitterBridge/twittersettings.php b/plugins/TwitterBridge/twittersettings.php index c169172b00..da421cb37a 100644 --- a/plugins/TwitterBridge/twittersettings.php +++ b/plugins/TwitterBridge/twittersettings.php @@ -45,7 +45,7 @@ require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php'; * * @see SettingsAction */ -class TwittersettingsAction extends ConnectSettingsAction +class TwittersettingsAction extends SettingsAction { /** * Title of the page diff --git a/theme/base/css/display.css b/theme/base/css/display.css index d35a8a706e..383b9c6ec2 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -94,6 +94,55 @@ list-style-type:none; form label.submit { display:none; } + +body[id$=settings] #site_nav_local_views { +position:relative; +z-index:9; +float:right; +margin-right:10.65%; +width:22.25%; +} +body[id$=settings] #site_nav_local_views li { +width:100%; +margin-right:0; +margin-bottom:7px; +} +body[id$=settings] #site_nav_local_views a { +display:block; +width:80%; +padding-right:10%; +padding-left:10%; +border-radius-toprleft:0; +-moz-border-radius-topleft:0; +-webkit-border-top-left-radius:0; +border-radius-topright:4px; +-moz-border-radius-topright:4px; +-webkit-border-top-right-radius:4px; +border-radius-bottomright:4px; +-moz-border-radius-bottomright:4px; +-webkit-border-bottom-right-radius:4px; +} +body[id$=settings] #site_nav_local_views li.current { +box-shadow:none; +-moz-box-shadow:none; +-webkit-box-shadow:none; +} + +body[id$=settings] #content { +border-radius-topleft:7px; +border-radius-topright:7px; +-moz-border-radius-topleft:7px; +-moz-border-radius-topright:7px; +-webkit-border-top-left-radius:7px; +-webkit-border-top-right-radius:7px; +border-radius-topright:0; +-moz-border-radius-topright:0; +-webkit-border-top-right-radius:0; +} +body[id$=settings] #aside_primary { +display:none; +} + .form_settings { clear:both; }