From c8d6a77d8ae64d527838ed6691e6eabff4aa12e2 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 05:45:38 -0500 Subject: [PATCH 01/41] common superclass for menu widgets --- lib/menu.php | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 lib/menu.php diff --git a/lib/menu.php b/lib/menu.php new file mode 100644 index 0000000000..b9791d2359 --- /dev/null +++ b/lib/menu.php @@ -0,0 +1,84 @@ +. + * + * @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); + } +} From 903053caec99da4443fa10f045f83239634b1a58 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 05:46:03 -0500 Subject: [PATCH 02/41] primary and secondary nav use menu superclass --- lib/action.php | 104 ++------------------------------------ lib/primarynav.php | 116 +++++++++++++++++++++++++++++++++++++++++++ lib/secondarynav.php | 90 +++++++++++++++++++++++++++++++++ 3 files changed, 210 insertions(+), 100 deletions(-) create mode 100644 lib/primarynav.php create mode 100644 lib/secondarynav.php diff --git a/lib/action.php b/lib/action.php index 3ef9ffa3c8..54bea7c931 100644 --- a/lib/action.php +++ b/lib/action.php @@ -543,69 +543,8 @@ 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'); + $pn = new PrimaryNav($this); + $pn->show(); } /** @@ -850,43 +789,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/primarynav.php b/lib/primarynav.php new file mode 100644 index 0000000000..01517d9429 --- /dev/null +++ b/lib/primarynav.php @@ -0,0 +1,116 @@ +. + * + * @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', + 'id' => 'site_nav_global_primary')); + if (Event::handle('StartPrimaryNav', array($this->action))) { + if (!empty($user)) { + $this->action->menuItem(common_local_url('all', + array('nickname' => $user->nickname)), + _m('Home'), + _m('Friends timeline'), + false, + 'nav_home'); + $this->action->menuItem(common_local_url('showstream', + array('nickname' => $user->nickname)), + _m('Profile'), + _m('Your profile'), + false, + 'nav_profile'); + $this->action->menuItem(common_local_url('public'), + _m('Public'), + _m('Everyone on this site'), + false, + 'nav_public'); + $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('public'), + _m('Public'), + _m('Everyone on this site'), + false, + 'nav_public'); + $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/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 From d6d3dfda81ce60cb511f69a9d890d68e67ebd7d8 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 05:51:00 -0500 Subject: [PATCH 03/41] AdminPanelNav has own module, uses Menu --- lib/adminpanelnav.php | 148 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 lib/adminpanelnav.php 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'); + } +} From a64c6c501555bc70ef617ecb8c4a21b6e1f91518 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 06:00:03 -0500 Subject: [PATCH 04/41] all nav menus use menu superclass --- lib/groupnav.php | 4 +--- lib/logingroupnav.php | 15 +-------------- lib/personalgroupnav.php | 37 ++++++++----------------------------- lib/publicgroupnav.php | 16 +--------------- lib/searchgroupnav.php | 12 ++++-------- lib/settingsnav.php | 19 +++---------------- lib/subgroupnav.php | 6 ++---- 7 files changed, 20 insertions(+), 89 deletions(-) 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/personalgroupnav.php b/lib/personalgroupnav.php index 72d0893af7..d72a865677 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 * 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/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/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; } From d8cbc20a792ed8b04d7257186e571e926a5280ac Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 06:29:24 -0500 Subject: [PATCH 05/41] method to show submenus --- lib/menu.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/menu.php b/lib/menu.php index b9791d2359..7947b4d7e4 100644 --- a/lib/menu.php +++ b/lib/menu.php @@ -81,4 +81,12 @@ class Menu extends Widget { return sprintf('nav_%s', $actionName); } + + function submenu($label, $menu) + { + $this->action->elementStart('li'); + $this->action->text($label); + $menu->show(); + $this->action->elementEnd('li'); + } } From dba2aaa59fece223141809d2f1cdf506c479a8f2 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 06:30:27 -0500 Subject: [PATCH 06/41] new mega-menu for default local navigation --- lib/defaultlocalnav.php | 69 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 lib/defaultlocalnav.php diff --git a/lib/defaultlocalnav.php b/lib/defaultlocalnav.php new file mode 100644 index 0000000000..93eaf73393 --- /dev/null +++ b/lib/defaultlocalnav.php @@ -0,0 +1,69 @@ +. + * + * @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, $user); + $this->submenu(_m('Home'), $pn); + + $sn = new SubGroupNav($this->action, $user); + $this->submenu(_m('Profile'), $sn); + } + + $bn = new PublicGroupNav($this->action); + $this->submenu(_('Public'), $bn); + + $this->action->elementEnd('ul'); + } +} From 7d77bdcc483a223eaa4eef152f6d060c2465499c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 06:30:51 -0500 Subject: [PATCH 07/41] move top-level navigation to default local navigation --- lib/action.php | 3 ++- lib/primarynav.php | 23 +---------------------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/lib/action.php b/lib/action.php index 54bea7c931..9a6a160e3f 100644 --- a/lib/action.php +++ b/lib/action.php @@ -637,7 +637,8 @@ class Action extends HTMLOutputter // lawsuit */ function showLocalNav() { - // does nothing by default + $nav = new DefaultLocalNav($this); + $nav->show(); } /** diff --git a/lib/primarynav.php b/lib/primarynav.php index 01517d9429..296328d8bd 100644 --- a/lib/primarynav.php +++ b/lib/primarynav.php @@ -54,23 +54,6 @@ class PrimaryNav extends Menu 'id' => 'site_nav_global_primary')); if (Event::handle('StartPrimaryNav', array($this->action))) { if (!empty($user)) { - $this->action->menuItem(common_local_url('all', - array('nickname' => $user->nickname)), - _m('Home'), - _m('Friends timeline'), - false, - 'nav_home'); - $this->action->menuItem(common_local_url('showstream', - array('nickname' => $user->nickname)), - _m('Profile'), - _m('Your profile'), - false, - 'nav_profile'); - $this->action->menuItem(common_local_url('public'), - _m('Public'), - _m('Everyone on this site'), - false, - 'nav_public'); $this->action->menuItem(common_local_url('profilesettings'), _m('Settings'), _m('Change your personal settings'), @@ -89,11 +72,6 @@ class PrimaryNav extends Menu false, 'nav_logout'); } else { - $this->action->menuItem(common_local_url('public'), - _m('Public'), - _m('Everyone on this site'), - false, - 'nav_public'); $this->action->menuItem(common_local_url('login'), _m('Login'), _m('Login to the site'), @@ -111,6 +89,7 @@ class PrimaryNav extends Menu Event::handle('EndPrimaryNav', array($this->action)); } + $this->action->elementEnd('ul'); } } From 0e1a22142304c720e2fa6e65f97c135d1f4268e4 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 15:52:46 -0500 Subject: [PATCH 08/41] add object menu to actions, default empty --- lib/action.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/action.php b/lib/action.php index 9a6a160e3f..5917d31b36 100644 --- a/lib/action.php +++ b/lib/action.php @@ -607,6 +607,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)); @@ -641,6 +645,32 @@ class Action extends HTMLOutputter // lawsuit $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. */ + } + /** * Show content block. * From 805d14577d8a7e87d2dcea66aa5d22d801987fa5 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 15:54:32 -0500 Subject: [PATCH 09/41] subscriber actions show the profile menu in object area --- lib/galleryaction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From c925a4d181c13ec5fc5669a23ea95ce6c3659e13 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 15:54:43 -0500 Subject: [PATCH 10/41] search actions show the search menu in object area --- lib/searchaction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From 8c03e8b0b3ef76146fc55cbf2e49ce2a35905806 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 15:59:01 -0500 Subject: [PATCH 11/41] use default local nav for allaction --- actions/all.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/actions/all.php b/actions/all.php index dc08592faf..896c63c7d9 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. From 64ab7b7d07aea1c2082a946d3ea899ac47e92adc Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:00:07 -0500 Subject: [PATCH 12/41] use default local nav for public action --- actions/public.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/actions/public.php b/actions/public.php index 5fc547feaf..cbc753d900 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.') . ' '; From 0fef2cb66d5e19524a6bb253baff48045bf2f84c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:04:36 -0500 Subject: [PATCH 13/41] personal group nav uses current user --- lib/defaultlocalnav.php | 2 +- lib/personalgroupnav.php | 21 +++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/defaultlocalnav.php b/lib/defaultlocalnav.php index 93eaf73393..b42d3a804c 100644 --- a/lib/defaultlocalnav.php +++ b/lib/defaultlocalnav.php @@ -54,7 +54,7 @@ class DefaultLocalNav extends Menu $user = common_current_user(); if (!empty($user)) { - $pn = new PersonalGroupNav($this->action, $user); + $pn = new PersonalGroupNav($this->action); $this->submenu(_m('Home'), $pn); $sn = new SubGroupNav($this->action, $user); diff --git a/lib/personalgroupnav.php b/lib/personalgroupnav.php index d72a865677..6a31358596 100644 --- a/lib/personalgroupnav.php +++ b/lib/personalgroupnav.php @@ -53,23 +53,16 @@ class PersonalGroupNav extends Menu */ 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))) { From 3377bc2ccff0cb83b1022a8f2d1d4c921bc6287c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:06:29 -0500 Subject: [PATCH 14/41] RepliesAction uses default local nav --- actions/replies.php | 12 ------------ 1 file changed, 12 deletions(-) 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 * From efdc85224adedeae8dab0c1ada5f8f117b076f2f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:07:27 -0500 Subject: [PATCH 15/41] user groups show subgroupnav in object menu area --- actions/usergroups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From 85320a7561013f84b9d562b91c7647c59a21b814 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:08:49 -0500 Subject: [PATCH 16/41] show object nav for blocked users in a group --- actions/blockedfromgroup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From 737eb371f83c1059e80cb2d9d907f735283d6e94 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:09:35 -0500 Subject: [PATCH 17/41] show full local nav in public tag cloud --- actions/publictagcloud.php | 6 ------ 1 file changed, 6 deletions(-) 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); From 4561caec1037a84d4b7dbd010e7b5a9b2464a0b7 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:10:40 -0500 Subject: [PATCH 18/41] show default local nav in group edit --- actions/editgroup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From 3c683ad7b54a1cc5decfe8c312b1580113c8eb31 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:11:19 -0500 Subject: [PATCH 19/41] default local nav in popular notices --- actions/favorited.php | 13 ------------- 1 file changed, 13 deletions(-) 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 * From 0850c66a21dac58919ba4e3a8739602dce68b029 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:11:59 -0500 Subject: [PATCH 20/41] default local nav in featured user list --- actions/featured.php | 6 ------ 1 file changed, 6 deletions(-) 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. From 4903c92dcec6d1ea0b7174efd6c15c261606077f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:15:03 -0500 Subject: [PATCH 21/41] show defaultlocalnav in groupdesignsettings --- actions/groupdesignsettings.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 * From 0c877860b51412d54ee876f15f4cdad18a8db274 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:17:01 -0500 Subject: [PATCH 22/41] show defaultlocalnav in grouplogo --- actions/grouplogo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From f29274cd0d44079a602d23607b62616488068709 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:17:42 -0500 Subject: [PATCH 23/41] show defaultlocalnav in groupmembers --- actions/groupmembers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From 6ee77f1302014167fdcccb46b7ea76b368234b41 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:18:33 -0500 Subject: [PATCH 24/41] defaultlocalnav in groups --- actions/groups.php | 6 ------ 1 file changed, 6 deletions(-) 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 = From 55fa14baec295669f3546a35eeb34bb15a841fc8 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:20:14 -0500 Subject: [PATCH 25/41] object menu in inviteaction --- actions/invite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From 374253f0f751e2d0a81035853d5f577c64b07aba Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:21:22 -0500 Subject: [PATCH 26/41] defaultlocalnav for favorites --- actions/showfavorites.php | 11 ----------- 1 file changed, 11 deletions(-) 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()) { From a1a0382d26fdd444bb574081649406980cae383b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:22:19 -0500 Subject: [PATCH 27/41] object menu on showgroup --- actions/showgroup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/showgroup.php b/actions/showgroup.php index 21256294f3..397ca30505 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(); From 64a1c9e3761639c30e5fe33fed9d2cfde201e0bb Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:23:19 -0500 Subject: [PATCH 28/41] object menu for user profile --- actions/showstream.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From c4b53b4aefe5a7d69ce912d0908e55aae8768f35 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:35:25 -0500 Subject: [PATCH 29/41] don't show full profile menu all the time --- lib/defaultlocalnav.php | 3 --- lib/personalgroupnav.php | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/defaultlocalnav.php b/lib/defaultlocalnav.php index b42d3a804c..7af3c9673f 100644 --- a/lib/defaultlocalnav.php +++ b/lib/defaultlocalnav.php @@ -56,9 +56,6 @@ class DefaultLocalNav extends Menu if (!empty($user)) { $pn = new PersonalGroupNav($this->action); $this->submenu(_m('Home'), $pn); - - $sn = new SubGroupNav($this->action, $user); - $this->submenu(_m('Profile'), $sn); } $bn = new PublicGroupNav($this->action); diff --git a/lib/personalgroupnav.php b/lib/personalgroupnav.php index 6a31358596..e428e92e63 100644 --- a/lib/personalgroupnav.php +++ b/lib/personalgroupnav.php @@ -71,6 +71,12 @@ class PersonalGroupNav extends Menu _('Home'), sprintf(_('%s and friends'), $name), $action == 'all', 'nav_timeline_personal'); + $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('replies', array('nickname' => $nickname)), _('Replies'), From 815a9a0c3e634be678aec1dce80a2364f7bd3897 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:37:21 -0500 Subject: [PATCH 30/41] fixup link to your profile --- lib/personalgroupnav.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/personalgroupnav.php b/lib/personalgroupnav.php index e428e92e63..348195a99d 100644 --- a/lib/personalgroupnav.php +++ b/lib/personalgroupnav.php @@ -72,9 +72,9 @@ class PersonalGroupNav extends Menu sprintf(_('%s and friends'), $name), $action == 'all', 'nav_timeline_personal'); $this->out->menuItem(common_local_url('showstream', array('nickname' => - $this->user->nickname)), + $nickname)), _('Profile'), - (empty($profile)) ? $this->user->nickname : $profile->getBestName(), + _('Your profile'), $action == 'showstream', 'nav_profile'); $this->out->menuItem(common_local_url('replies', array('nickname' => From 5bbcededa752133b2e607e8309d381df67f6a250 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 1 Mar 2011 16:48:20 -0500 Subject: [PATCH 31/41] move inbox/outbox to object menu --- lib/mailbox.php | 6 ++++ lib/mailboxmenu.php | 70 ++++++++++++++++++++++++++++++++++++++++ lib/personalgroupnav.php | 8 ++--- 3 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 lib/mailboxmenu.php 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/personalgroupnav.php b/lib/personalgroupnav.php index 348195a99d..9d78857c6d 100644 --- a/lib/personalgroupnav.php +++ b/lib/personalgroupnav.php @@ -95,15 +95,11 @@ class PersonalGroupNav extends Menu $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'); From 53db4c2b85b27db85c8d29f059fe893f5c0b3745 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 2 Mar 2011 22:09:11 -0500 Subject: [PATCH 32/41] move notice form to content block --- lib/action.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/action.php b/lib/action.php index 5917d31b36..dc95b030d2 100644 --- a/lib/action.php +++ b/lib/action.php @@ -464,14 +464,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'); } @@ -679,6 +672,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)); From 85610d0881b9b40171100e4b913f3ff86305db8c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 2 Mar 2011 22:09:26 -0500 Subject: [PATCH 33/41] no notice form on settings pages --- lib/settingsaction.php | 11 +++++++++++ 1 file changed, 11 insertions(+) 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; + } } From 457d76c0ca32350ac600006369ca318a269946fc Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 6 Mar 2011 17:32:26 -0500 Subject: [PATCH 34/41] submenu headers are

elements --- lib/menu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/menu.php b/lib/menu.php index 7947b4d7e4..2713b44d50 100644 --- a/lib/menu.php +++ b/lib/menu.php @@ -85,7 +85,7 @@ class Menu extends Widget function submenu($label, $menu) { $this->action->elementStart('li'); - $this->action->text($label); + $this->action->element('h3', null, $label); $menu->show(); $this->action->elementEnd('li'); } From 876c7a42c835273b71a0a2a10c9e79e1660ebe47 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 7 Mar 2011 12:36:04 -0500 Subject: [PATCH 35/41] remove adminpanelnav from adminpanelaction module --- lib/adminpanelaction.php | 126 --------------------------------------- 1 file changed, 126 deletions(-) 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'); - } -} From b4f1281799766570ff68580e13c588ea8c8ce1f1 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 7 Mar 2011 12:36:45 -0500 Subject: [PATCH 36/41] abstraction for starting and ending a menu --- lib/menu.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/menu.php b/lib/menu.php index 2713b44d50..751f8e1b7d 100644 --- a/lib/menu.php +++ b/lib/menu.php @@ -62,6 +62,23 @@ class Menu extends Widget $this->actionName = $action->trimmed('action'); } + function id() + { + return 'unknown_menu'; + } + + function menuStart() + { + $this->action->elementStart('div', array('id' => $this->id())); + $this->action->elementStart('ul', array('class' => 'nav')); + } + + function menuEnd() + { + $this->action->elementEnd('ul'); + $this->action->elementEnd('div'); + } + function item($actionName, $args, $label, $description, $id=null) { if (empty($id)) { From 8e03c83a57e29a0e840b44b1e5cb04e1422a845f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 7 Mar 2011 12:37:07 -0500 Subject: [PATCH 37/41] primarynav uses menustart and menuend --- lib/primarynav.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/primarynav.php b/lib/primarynav.php index 296328d8bd..de3ea2641f 100644 --- a/lib/primarynav.php +++ b/lib/primarynav.php @@ -50,8 +50,7 @@ class PrimaryNav extends Menu function show() { $user = common_current_user(); - $this->action->elementStart('ul', array('class' => 'nav', - 'id' => 'site_nav_global_primary')); + $this->menuStart(); if (Event::handle('StartPrimaryNav', array($this->action))) { if (!empty($user)) { $this->action->menuItem(common_local_url('profilesettings'), @@ -89,7 +88,12 @@ class PrimaryNav extends Menu Event::handle('EndPrimaryNav', array($this->action)); } - + $this->menuEnd(); $this->action->elementEnd('ul'); } + + function id() + { + return 'site_nav_global_primary'; + } } From 6ab7329e85b1878b40165bc2475151a6e78195b4 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 7 Mar 2011 12:39:31 -0500 Subject: [PATCH 38/41] Revert "primarynav uses menustart and menuend" This reverts commit 8e03c83a57e29a0e840b44b1e5cb04e1422a845f. --- lib/primarynav.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/primarynav.php b/lib/primarynav.php index de3ea2641f..296328d8bd 100644 --- a/lib/primarynav.php +++ b/lib/primarynav.php @@ -50,7 +50,8 @@ class PrimaryNav extends Menu function show() { $user = common_current_user(); - $this->menuStart(); + $this->action->elementStart('ul', array('class' => 'nav', + 'id' => 'site_nav_global_primary')); if (Event::handle('StartPrimaryNav', array($this->action))) { if (!empty($user)) { $this->action->menuItem(common_local_url('profilesettings'), @@ -88,12 +89,7 @@ class PrimaryNav extends Menu Event::handle('EndPrimaryNav', array($this->action)); } - $this->menuEnd(); + $this->action->elementEnd('ul'); } - - function id() - { - return 'site_nav_global_primary'; - } } From b751ab70fb4f9f7ad807e29b5716f2100aeb0de8 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 7 Mar 2011 12:39:52 -0500 Subject: [PATCH 39/41] Revert "abstraction for starting and ending a menu" This reverts commit b4f1281799766570ff68580e13c588ea8c8ce1f1. --- lib/menu.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/lib/menu.php b/lib/menu.php index 751f8e1b7d..2713b44d50 100644 --- a/lib/menu.php +++ b/lib/menu.php @@ -62,23 +62,6 @@ class Menu extends Widget $this->actionName = $action->trimmed('action'); } - function id() - { - return 'unknown_menu'; - } - - function menuStart() - { - $this->action->elementStart('div', array('id' => $this->id())); - $this->action->elementStart('ul', array('class' => 'nav')); - } - - function menuEnd() - { - $this->action->elementEnd('ul'); - $this->action->elementEnd('div'); - } - function item($actionName, $args, $label, $description, $id=null) { if (empty($id)) { From 2272044ad1c8bcde9d79aeaf1b135dc7b47784da Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 7 Mar 2011 12:42:51 -0500 Subject: [PATCH 40/41] wrapper div for primary nav --- lib/action.php | 2 ++ lib/primarynav.php | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/action.php b/lib/action.php index dc95b030d2..7ef959bc4e 100644 --- a/lib/action.php +++ b/lib/action.php @@ -536,8 +536,10 @@ class Action extends HTMLOutputter // lawsuit */ function showPrimaryNav() { + $this->elementStart('div', array('id' => 'site_nav_global_primary')); $pn = new PrimaryNav($this); $pn->show(); + $this->elementEnd('div'); } /** diff --git a/lib/primarynav.php b/lib/primarynav.php index 296328d8bd..7748d7a1c7 100644 --- a/lib/primarynav.php +++ b/lib/primarynav.php @@ -50,8 +50,7 @@ class PrimaryNav extends Menu function show() { $user = common_current_user(); - $this->action->elementStart('ul', array('class' => 'nav', - 'id' => 'site_nav_global_primary')); + $this->action->elementStart('ul', array('class' => 'nav')); if (Event::handle('StartPrimaryNav', array($this->action))) { if (!empty($user)) { $this->action->menuItem(common_local_url('profilesettings'), From 998733cdd44143b1a3ded13f28ff5e848516b1c6 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 7 Mar 2011 12:49:20 -0500 Subject: [PATCH 41/41] UR FACE --- lib/userprofile.php | 4 ++++ 1 file changed, 4 insertions(+) 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()