From aa4a8e50511a61039fc158a6bc5fa0a853eb79c4 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 17 Jan 2011 18:04:10 -0500 Subject: [PATCH 1/8] wrap account actions in a section --- actions/profilesettings.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/actions/profilesettings.php b/actions/profilesettings.php index 19fbdbd293..303bb0ad9b 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -458,6 +458,9 @@ class ProfilesettingsAction extends AccountSettingsAction $this->elementStart('div', array('id' => 'aside_primary', 'class' => 'aside')); + + $this->elementStart('div', array('id' => 'account_actions', + 'class' => 'section')); $this->elementStart('ul'); if (Event::handle('StartProfileSettingsActions', array($this))) { if ($user->hasRight(Right::BACKUPACCOUNT)) { @@ -485,5 +488,6 @@ class ProfilesettingsAction extends AccountSettingsAction } $this->elementEnd('ul'); $this->elementEnd('div'); + $this->elementEnd('div'); } } From d0d1257d9928f9a282874bec0423885839d84a20 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 18 Jan 2011 12:34:04 -0800 Subject: [PATCH 2/8] SubMirror: switch the mirror setup tab from account settings to subscriptions/groups/invites area --- plugins/SubMirror/SubMirrorPlugin.php | 7 ++++--- plugins/SubMirror/actions/mirrorsettings.php | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/SubMirror/SubMirrorPlugin.php b/plugins/SubMirror/SubMirrorPlugin.php index 578ef6607c..0f2fc24787 100644 --- a/plugins/SubMirror/SubMirrorPlugin.php +++ b/plugins/SubMirror/SubMirrorPlugin.php @@ -93,15 +93,16 @@ class SubMirrorPlugin extends Plugin } /** - * Menu item for settings + * Menu item for personal subscriptions/groups area * - * @param Action &$action Action being executed + * @param Widget $widget Widget being executed * * @return boolean hook return */ - function onEndAccountSettingsNav(&$action) + function onEndSubGroupNav($widget) { + $action = $widget->out; $action_name = $action->trimmed('action'); $action->menuItem(common_local_url('mirrorsettings'), diff --git a/plugins/SubMirror/actions/mirrorsettings.php b/plugins/SubMirror/actions/mirrorsettings.php index a828b26feb..20e1807b3d 100644 --- a/plugins/SubMirror/actions/mirrorsettings.php +++ b/plugins/SubMirror/actions/mirrorsettings.php @@ -102,4 +102,10 @@ class MirrorSettingsAction extends AccountSettingsAction function handlePost() { } + + function showLocalNav() + { + $nav = new SubGroupNav($this, common_current_user()); + $nav->show(); + } } From 56e2bc10d97a0241d3ce9e8abadd3d42658701ec Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 18 Jan 2011 12:34:27 -0800 Subject: [PATCH 3/8] Cleanup stray PHP 4-style references in hook calls for navigation bars. We can't replace the live action from here, and don't need a reference to keep the object mutable. Dumping the references helps ensure we don't end up getting errors when things calling the hooks might forget to use the reference and the PHP error reporting settings expose this fact at us. --- lib/accountsettingsaction.php | 4 ++-- lib/connectsettingsaction.php | 4 ++-- lib/logingroupnav.php | 4 ++-- lib/userprofile.php | 12 ++++++------ .../CasAuthentication/CasAuthenticationPlugin.php | 2 +- plugins/Facebook/FacebookPlugin.php | 8 ++++---- plugins/FacebookBridge/FacebookBridgePlugin.php | 8 ++++---- plugins/NewMenu/NewMenuPlugin.php | 10 +++++----- plugins/OpenID/OpenIDPlugin.php | 12 ++++++------ plugins/TwitterBridge/TwitterBridgePlugin.php | 8 ++++---- plugins/UserFlag/UserFlagPlugin.php | 4 ++-- 11 files changed, 38 insertions(+), 38 deletions(-) diff --git a/lib/accountsettingsaction.php b/lib/accountsettingsaction.php index 7991c9002c..b1ea998bfa 100644 --- a/lib/accountsettingsaction.php +++ b/lib/accountsettingsaction.php @@ -96,7 +96,7 @@ class AccountSettingsNav extends Widget $action_name = $this->action->trimmed('action'); $this->action->elementStart('ul', array('class' => 'nav')); - if (Event::handle('StartAccountSettingsNav', array(&$this->action))) { + if (Event::handle('StartAccountSettingsNav', array($this->action))) { $user = common_current_user(); if(Event::handle('StartAccountSettingsProfileMenuItem', array($this, &$menu))){ @@ -142,7 +142,7 @@ class AccountSettingsNav extends Widget Event::handle('EndAccountSettingsOtherMenuItem', array($this, &$menu)); } - Event::handle('EndAccountSettingsNav', array(&$this->action)); + Event::handle('EndAccountSettingsNav', array($this->action)); } $this->action->elementEnd('ul'); diff --git a/lib/connectsettingsaction.php b/lib/connectsettingsaction.php index 325276c5fc..20f18ef0d9 100644 --- a/lib/connectsettingsaction.php +++ b/lib/connectsettingsaction.php @@ -96,7 +96,7 @@ class ConnectSettingsNav extends Widget $action_name = $this->action->trimmed('action'); $this->action->elementStart('ul', array('class' => 'nav')); - if (Event::handle('StartConnectSettingsNav', array(&$this->action))) { + if (Event::handle('StartConnectSettingsNav', array($this->action))) { # action => array('prompt', 'title') $menu = array(); @@ -129,7 +129,7 @@ class ConnectSettingsNav extends Widget $action_name === $menuaction); } - Event::handle('EndConnectSettingsNav', array(&$this->action)); + Event::handle('EndConnectSettingsNav', array($this->action)); } $this->action->elementEnd('ul'); diff --git a/lib/logingroupnav.php b/lib/logingroupnav.php index b545fbf269..0fd0f45c7d 100644 --- a/lib/logingroupnav.php +++ b/lib/logingroupnav.php @@ -73,7 +73,7 @@ class LoginGroupNav extends Widget $this->action->elementStart('ul', array('class' => 'nav')); - if (Event::handle('StartLoginGroupNav', array(&$this->action))) { + if (Event::handle('StartLoginGroupNav', array($this->action))) { $this->action->menuItem(common_local_url('login'), _('Login'), @@ -87,7 +87,7 @@ class LoginGroupNav extends Widget $action_name === 'register'); } - Event::handle('EndLoginGroupNav', array(&$this->action)); + Event::handle('EndLoginGroupNav', array($this->action)); } $this->action->elementEnd('ul'); diff --git a/lib/userprofile.php b/lib/userprofile.php index 2813f735ea..91c5fb413a 100644 --- a/lib/userprofile.php +++ b/lib/userprofile.php @@ -242,7 +242,7 @@ class UserProfile extends Widget $this->out->elementEnd('div'); return; } - if (Event::handle('StartProfilePageActionsSection', array(&$this->out, $this->profile))) { + if (Event::handle('StartProfilePageActionsSection', array($this->out, $this->profile))) { $cur = common_current_user(); @@ -250,13 +250,13 @@ class UserProfile extends Widget $this->out->element('h2', null, _('User actions')); $this->out->elementStart('ul'); - if (Event::handle('StartProfilePageActionsElements', array(&$this->out, $this->profile))) { + if (Event::handle('StartProfilePageActionsElements', array($this->out, $this->profile))) { if (empty($cur)) { // not logged in - if (Event::handle('StartProfileRemoteSubscribe', array(&$this->out, $this->profile))) { + if (Event::handle('StartProfileRemoteSubscribe', array($this->out, $this->profile))) { $this->out->elementStart('li', 'entity_subscribe'); $this->showRemoteSubscribeLink(); $this->out->elementEnd('li'); - Event::handle('EndProfileRemoteSubscribe', array(&$this->out, $this->profile)); + Event::handle('EndProfileRemoteSubscribe', array($this->out, $this->profile)); } } else { if ($cur->id == $this->profile->id) { // your own page @@ -376,13 +376,13 @@ class UserProfile extends Widget } } - Event::handle('EndProfilePageActionsElements', array(&$this->out, $this->profile)); + Event::handle('EndProfilePageActionsElements', array($this->out, $this->profile)); } $this->out->elementEnd('ul'); $this->out->elementEnd('div'); - Event::handle('EndProfilePageActionsSection', array(&$this->out, $this->profile)); + Event::handle('EndProfilePageActionsSection', array($this->out, $this->profile)); } } diff --git a/plugins/CasAuthentication/CasAuthenticationPlugin.php b/plugins/CasAuthentication/CasAuthenticationPlugin.php index 71e54d41f9..3196bd94a7 100644 --- a/plugins/CasAuthentication/CasAuthenticationPlugin.php +++ b/plugins/CasAuthentication/CasAuthenticationPlugin.php @@ -74,7 +74,7 @@ class CasAuthenticationPlugin extends AuthenticationPlugin return true; } - function onEndLoginGroupNav(&$action) + function onEndLoginGroupNav($action) { $action_name = $action->trimmed('action'); diff --git a/plugins/Facebook/FacebookPlugin.php b/plugins/Facebook/FacebookPlugin.php index 798009817c..e877d300b6 100644 --- a/plugins/Facebook/FacebookPlugin.php +++ b/plugins/Facebook/FacebookPlugin.php @@ -446,11 +446,11 @@ class FacebookPlugin extends Plugin /* * Add a login tab for Facebook Connect * - * @param Action &action the current action + * @param Action $action the current action * * @return void */ - function onEndLoginGroupNav(&$action) + function onEndLoginGroupNav($action) { if (self::hasKeys()) { $action_name = $action->trimmed('action'); @@ -470,11 +470,11 @@ class FacebookPlugin extends Plugin /* * Add a tab for managing Facebook Connect settings * - * @param Action &action the current action + * @param Action $action the current action * * @return void */ - function onEndConnectSettingsNav(&$action) + function onEndConnectSettingsNav($action) { if (self::hasKeys()) { $action_name = $action->trimmed('action'); diff --git a/plugins/FacebookBridge/FacebookBridgePlugin.php b/plugins/FacebookBridge/FacebookBridgePlugin.php index 8b5d05e983..000b214ff4 100644 --- a/plugins/FacebookBridge/FacebookBridgePlugin.php +++ b/plugins/FacebookBridge/FacebookBridgePlugin.php @@ -186,11 +186,11 @@ class FacebookBridgePlugin extends Plugin * Add a login tab for Facebook, but only if there's a Facebook * application defined for the plugin to use. * - * @param Action &action the current action + * @param Action $action the current action * * @return void */ - function onEndLoginGroupNav(&$action) + function onEndLoginGroupNav($action) { $action_name = $action->trimmed('action'); @@ -252,11 +252,11 @@ class FacebookBridgePlugin extends Plugin * Add a tab for user-level Facebook settings if the user * has a link to Facebook * - * @param Action &action the current action + * @param Action $action the current action * * @return void */ - function onEndConnectSettingsNav(&$action) + function onEndConnectSettingsNav($action) { if ($this->hasApplication()) { $action_name = $action->trimmed('action'); diff --git a/plugins/NewMenu/NewMenuPlugin.php b/plugins/NewMenu/NewMenuPlugin.php index cdcea5cd92..14950ab079 100644 --- a/plugins/NewMenu/NewMenuPlugin.php +++ b/plugins/NewMenu/NewMenuPlugin.php @@ -279,19 +279,19 @@ class NewMenuPlugin extends Plugin return true; } - function onStartAccountSettingsNav(&$action) + function onStartAccountSettingsNav($action) { $this->_settingsMenu($action); return false; } - function onStartConnectSettingsNav(&$action) + function onStartConnectSettingsNav($action) { $this->_settingsMenu($action); return false; } - private function _settingsMenu(&$action) + private function _settingsMenu($action) { $actionName = $action->trimmed('action'); @@ -325,7 +325,7 @@ class NewMenuPlugin extends Plugin _('Other options'), $actionName == 'othersettings'); - Event::handle('EndAccountSettingsNav', array(&$action)); + Event::handle('EndAccountSettingsNav', array($action)); if (common_config('xmpp', 'enabled')) { $action->menuItem(common_local_url('imsettings'), @@ -346,7 +346,7 @@ class NewMenuPlugin extends Plugin _('Authorized connected applications'), $actionName == 'oauthconnectionsettings'); - Event::handle('EndConnectSettingsNav', array(&$action)); + Event::handle('EndConnectSettingsNav', array($action)); } function onEndShowStyles($action) diff --git a/plugins/OpenID/OpenIDPlugin.php b/plugins/OpenID/OpenIDPlugin.php index d5a8c1bf02..2635cb7c9d 100644 --- a/plugins/OpenID/OpenIDPlugin.php +++ b/plugins/OpenID/OpenIDPlugin.php @@ -248,11 +248,11 @@ class OpenIDPlugin extends Plugin * * If we're in openidOnly mode, we disable the menu for all other login. * - * @param Action &$action Action being executed + * @param Action $action Action being executed * * @return boolean hook return */ - function onStartLoginGroupNav(&$action) + function onStartLoginGroupNav($action) { if (common_config('site', 'openidonly')) { $this->showOpenIDLoginTab($action); @@ -268,11 +268,11 @@ class OpenIDPlugin extends Plugin /** * Menu item for login * - * @param Action &$action Action being executed + * @param Action $action Action being executed * * @return boolean hook return */ - function onEndLoginGroupNav(&$action) + function onEndLoginGroupNav($action) { $this->showOpenIDLoginTab($action); @@ -318,11 +318,11 @@ class OpenIDPlugin extends Plugin /** * Menu item for OpenID settings * - * @param Action &$action Action being executed + * @param Action $action Action being executed * * @return boolean hook return */ - function onEndAccountSettingsNav(&$action) + function onEndAccountSettingsNav($action) { $action_name = $action->trimmed('action'); diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php index b2dce6f1c0..048daad98f 100644 --- a/plugins/TwitterBridge/TwitterBridgePlugin.php +++ b/plugins/TwitterBridge/TwitterBridgePlugin.php @@ -137,11 +137,11 @@ class TwitterBridgePlugin extends Plugin /* * Add a login tab for 'Sign in with Twitter' * - * @param Action &action the current action + * @param Action $action the current action * * @return void */ - function onEndLoginGroupNav(&$action) + function onEndLoginGroupNav($action) { $action_name = $action->trimmed('action'); @@ -160,11 +160,11 @@ class TwitterBridgePlugin extends Plugin /** * Add the Twitter Settings page to the Connect Settings menu * - * @param Action &$action The calling page + * @param Action $action The calling page * * @return boolean hook return */ - function onEndConnectSettingsNav(&$action) + function onEndConnectSettingsNav($action) { if (self::hasKeys()) { $action_name = $action->trimmed('action'); diff --git a/plugins/UserFlag/UserFlagPlugin.php b/plugins/UserFlag/UserFlagPlugin.php index fc7698841e..a375717ccd 100644 --- a/plugins/UserFlag/UserFlagPlugin.php +++ b/plugins/UserFlag/UserFlagPlugin.php @@ -121,12 +121,12 @@ class UserFlagPlugin extends Plugin /** * Add a 'flag' button to profile page * - * @param Action &$action The action being called + * @param Action $action The action being called * @param Profile $profile Profile being shown * * @return boolean hook result */ - function onEndProfilePageActionsElements(&$action, $profile) + function onEndProfilePageActionsElements($action, $profile) { $this->showFlagButton($action, $profile, array('action' => 'showstream', From 9be770e60995679997e689ffbb4038e18d6c894e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 18 Jan 2011 12:52:38 -0800 Subject: [PATCH 4/8] Start cleaning up profile sidebar: link the header text on subscription/subscriber/groups sections to the tabs so users don't have to dance around looking for the link if they don't have enough to trigger a 'more' link. Consolidated some of that link generation; sooooo much more dupe code to kill in this section! --- lib/profileaction.php | 54 ++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/lib/profileaction.php b/lib/profileaction.php index 4bfc4d48d9..fd2b73f6f2 100644 --- a/lib/profileaction.php +++ b/lib/profileaction.php @@ -99,6 +99,21 @@ class ProfileAction extends OwnerDesignAction $this->showStatistics(); } + /** + * Convenience function for common pattern of links to subscription/groups sections. + * + * @param string $actionClass + * @param string $title + * @param string $cssClass + */ + private function statsSectionLink($actionClass, $title, $cssClass='') + { + $this->element('a', array('href' => common_local_url($actionClass, + array('nickname' => $this->profile->nickname)), + 'class' => $cssClass), + $title); + } + function showSubscriptions() { $profile = $this->profile->getSubscriptions(0, PROFILES_PER_MINILIST + 1); @@ -106,7 +121,9 @@ class ProfileAction extends OwnerDesignAction $this->elementStart('div', array('id' => 'entity_subscriptions', 'class' => 'section')); if (Event::handle('StartShowSubscriptionsMiniList', array($this))) { - $this->element('h2', null, _('Subscriptions')); + $this->elementStart('h2'); + $this->statsSectionLink('subscriptions', _('Subscriptions')); + $this->elementEnd('h2'); $cnt = 0; @@ -120,10 +137,7 @@ class ProfileAction extends OwnerDesignAction if ($cnt > PROFILES_PER_MINILIST) { $this->elementStart('p'); - $this->element('a', array('href' => common_local_url('subscriptions', - array('nickname' => $this->profile->nickname)), - 'class' => 'more'), - _('All subscriptions')); + $this->statsSectionLink('subscriptions', _('All subscriptions'), 'more'); $this->elementEnd('p'); } @@ -141,7 +155,9 @@ class ProfileAction extends OwnerDesignAction if (Event::handle('StartShowSubscribersMiniList', array($this))) { - $this->element('h2', null, _('Subscribers')); + $this->elementStart('h2'); + $this->statsSectionLink('subscribers', _('Subscribers')); + $this->elementEnd('h2'); $cnt = 0; @@ -155,10 +171,7 @@ class ProfileAction extends OwnerDesignAction if ($cnt > PROFILES_PER_MINILIST) { $this->elementStart('p'); - $this->element('a', array('href' => common_local_url('subscribers', - array('nickname' => $this->profile->nickname)), - 'class' => 'more'), - _('All subscribers')); + $this->statsSectionLink('subscribers', _('All subscribers'), 'more'); $this->elementEnd('p'); } @@ -200,27 +213,21 @@ class ProfileAction extends OwnerDesignAction $this->elementStart('dl', 'entity_subscriptions'); $this->elementStart('dt'); - $this->element('a', array('href' => common_local_url('subscriptions', - array('nickname' => $this->profile->nickname))), - _('Subscriptions')); + $this->statsSectionLink('subscriptions', _('Subscriptions')); $this->elementEnd('dt'); $this->element('dd', null, $subs_count); $this->elementEnd('dl'); $this->elementStart('dl', 'entity_subscribers'); $this->elementStart('dt'); - $this->element('a', array('href' => common_local_url('subscribers', - array('nickname' => $this->profile->nickname))), - _('Subscribers')); + $this->statsSectionLink('subscribers', _('Subscribers')); $this->elementEnd('dt'); $this->element('dd', 'subscribers', $subbed_count); $this->elementEnd('dl'); $this->elementStart('dl', 'entity_groups'); $this->elementStart('dt'); - $this->element('a', array('href' => common_local_url('usergroups', - array('nickname' => $this->profile->nickname))), - _('Groups')); + $this->statsSectionLink('usergroups', _('Groups')); $this->elementEnd('dt'); $this->element('dd', 'groups', $group_count); $this->elementEnd('dl'); @@ -246,7 +253,9 @@ class ProfileAction extends OwnerDesignAction $this->elementStart('div', array('id' => 'entity_groups', 'class' => 'section')); if (Event::handle('StartShowGroupsMiniList', array($this))) { - $this->element('h2', null, _('Groups')); + $this->elementStart('h2'); + $this->statsSectionLink('usergroups', _('Groups')); + $this->elementEnd('h2'); if ($groups) { $gml = new GroupMiniList($groups, $this->profile, $this); @@ -258,10 +267,7 @@ class ProfileAction extends OwnerDesignAction if ($cnt > GROUPS_PER_MINILIST) { $this->elementStart('p'); - $this->element('a', array('href' => common_local_url('usergroups', - array('nickname' => $this->profile->nickname)), - 'class' => 'more'), - _('All groups')); + $this->statsSectionLink('usergroups', _('All groups'), 'more'); $this->elementEnd('p'); } From ff6df8061b1b1cdd2685246ed238818ed46c959f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 18 Jan 2011 13:12:08 -0800 Subject: [PATCH 5/8] Refactor profile sidebar stats generation: factor out giant chunk of repeated method calls --- lib/profileaction.php | 55 +++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/lib/profileaction.php b/lib/profileaction.php index fd2b73f6f2..ae70ad560b 100644 --- a/lib/profileaction.php +++ b/lib/profileaction.php @@ -200,52 +200,39 @@ class ProfileAction extends OwnerDesignAction $this->element('h2', null, _('Statistics')); // Other stats...? - $this->elementStart('dl', 'entity_user-id'); - $this->element('dt', null, _('User ID')); - $this->element('dd', null, $this->profile->id); - $this->elementEnd('dl'); + $this->showStatsRow('user-id', _('User ID'), $this->profile->id); - $this->elementStart('dl', 'entity_member-since'); - $this->element('dt', null, _('Member since')); - $this->element('dd', null, date('j M Y', + $this->showStatsRow('member-since', _('Member since'), date('j M Y', strtotime($this->profile->created))); - $this->elementEnd('dl'); - $this->elementStart('dl', 'entity_subscriptions'); - $this->elementStart('dt'); - $this->statsSectionLink('subscriptions', _('Subscriptions')); - $this->elementEnd('dt'); - $this->element('dd', null, $subs_count); - $this->elementEnd('dl'); + $this->showStatsRow('subscriptions', _('Subscriptions'), $subs_count, 'subscriptions'); - $this->elementStart('dl', 'entity_subscribers'); - $this->elementStart('dt'); - $this->statsSectionLink('subscribers', _('Subscribers')); - $this->elementEnd('dt'); - $this->element('dd', 'subscribers', $subbed_count); - $this->elementEnd('dl'); + $this->showStatsRow('subscribers', _('Subscribers'), $subbed_count, 'subscribed'); - $this->elementStart('dl', 'entity_groups'); - $this->elementStart('dt'); - $this->statsSectionLink('usergroups', _('Groups')); - $this->elementEnd('dt'); - $this->element('dd', 'groups', $group_count); - $this->elementEnd('dl'); + $this->showStatsRow('groups', _('Groups'), $group_count, 'usergroup'); - $this->elementStart('dl', 'entity_notices'); - $this->element('dt', null, _('Notices')); - $this->element('dd', null, $notice_count); - $this->elementEnd('dl'); + $this->showStatsRow('notices', _('Notices'), $notice_count); - $this->elementStart('dl', 'entity_daily_notices'); // TRANS: Average count of posts made per day since account registration - $this->element('dt', null, _('Daily average')); - $this->element('dd', null, $daily_count); - $this->elementEnd('dl'); + $this->showStatsRow('daily_notices', _('Daily average'), $daily_count); $this->elementEnd('div'); } + function showStatsRow($id, $label, $content, $labelAction=false) + { + $this->elementStart('dl', 'entity_' . $id); + $this->elementStart('dt'); + if ($labelAction) { + $this->statsSectionLink($labelAction, $label); + } else { + $this->text($label); + } + $this->elementEnd('dt'); + $this->element('dd', null, $content); + $this->elementEnd('dl'); + } + function showGroups() { $groups = $this->profile->getGroups(0, GROUPS_PER_MINILIST + 1); From 397f7cd0d86cc6819e99ca44727396ea4c98118b Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 18 Jan 2011 13:21:59 -0800 Subject: [PATCH 6/8] Refactor profile sidebar statistics output so plugins can hook it and add entries. --- lib/profileaction.php | 78 ++++++++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 24 deletions(-) diff --git a/lib/profileaction.php b/lib/profileaction.php index ae70ad560b..5e4e0f52a0 100644 --- a/lib/profileaction.php +++ b/lib/profileaction.php @@ -183,10 +183,7 @@ class ProfileAction extends OwnerDesignAction function showStatistics() { - $subs_count = $this->profile->subscriptionCount(); - $subbed_count = $this->profile->subscriberCount(); $notice_count = $this->profile->noticeCount(); - $group_count = $this->profile->getGroups()->N; $age_days = (time() - strtotime($this->profile->created)) / 86400; if ($age_days < 1) { // Rather than extrapolating out to a bajillion... @@ -199,37 +196,70 @@ class ProfileAction extends OwnerDesignAction $this->element('h2', null, _('Statistics')); - // Other stats...? - $this->showStatsRow('user-id', _('User ID'), $this->profile->id); + $profile = $this->profile; + $actionParams = array('nickname' => $profile->nickname); + $stats = array( + array( + 'id' => 'user-id', + 'label' => _('User ID'), + 'value' => $profile->id, + ), + array( + 'id' => 'member-since', + 'label' => _('Member since'), + 'value' => date('j M Y', strtotime($profile->created)) + ), + array( + 'id' => 'subscriptions', + 'label' => _('Subscriptions'), + 'link' => common_local_url('subscriptions', $actionParams), + 'value' => $profile->subscriptionCount(), + ), + array( + 'id' => 'subscribers', + 'label' => _('Subscribers'), + 'link' => common_local_url('subscribers', $actionParams), + 'value' => $profile->subscriberCount(), + ), + array( + 'id' => 'groups', + 'label' => _('Groups'), + 'link' => common_local_url('usergroups', $actionParams), + 'value' => $profile->getGroups()->N, + ), + array( + 'id' => 'notices', + 'label' => _('Notices'), + 'value' => $notice_count, + ), + array( + 'id' => 'daily_notices', + // TRANS: Average count of posts made per day since account registration + 'label' => _('Daily average'), + 'value' => $daily_count + ) + ); - $this->showStatsRow('member-since', _('Member since'), date('j M Y', - strtotime($this->profile->created))); - - $this->showStatsRow('subscriptions', _('Subscriptions'), $subs_count, 'subscriptions'); - - $this->showStatsRow('subscribers', _('Subscribers'), $subbed_count, 'subscribed'); - - $this->showStatsRow('groups', _('Groups'), $group_count, 'usergroup'); - - $this->showStatsRow('notices', _('Notices'), $notice_count); - - // TRANS: Average count of posts made per day since account registration - $this->showStatsRow('daily_notices', _('Daily average'), $daily_count); + // Give plugins a chance to add stats entries + Event::handle('ProfileStats', array($profile, &$stats)); + foreach ($stats as $row) { + $this->showStatsRow($row); + } $this->elementEnd('div'); } - function showStatsRow($id, $label, $content, $labelAction=false) + private function showStatsRow($row) { - $this->elementStart('dl', 'entity_' . $id); + $this->elementStart('dl', 'entity_' . $row['id']); $this->elementStart('dt'); - if ($labelAction) { - $this->statsSectionLink($labelAction, $label); + if (!empty($row['link'])) { + $this->element('a', array('href' => $row['link']), $row['label']); } else { - $this->text($label); + $this->text($row['label']); } $this->elementEnd('dt'); - $this->element('dd', null, $content); + $this->element('dd', null, $row['value']); $this->elementEnd('dl'); } From b5027559780355e3b58c6fbcaed0db220eaf82c1 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 18 Jan 2011 13:32:12 -0800 Subject: [PATCH 7/8] SubMirror: add mirrored feeds count & management link to stats section when showing your own profile sidebar. --- plugins/SubMirror/SubMirrorPlugin.php | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/plugins/SubMirror/SubMirrorPlugin.php b/plugins/SubMirror/SubMirrorPlugin.php index 0f2fc24787..38a4c40d48 100644 --- a/plugins/SubMirror/SubMirrorPlugin.php +++ b/plugins/SubMirror/SubMirrorPlugin.php @@ -164,4 +164,37 @@ class SubMirrorPlugin extends Plugin } return true; } + + /** + * Add a count of mirrored feeds into a user's profile sidebar stats. + * + * @param Profile $profile + * @param array $stats + * @return boolean hook return value + */ + function onProfileStats($profile, &$stats) + { + $cur = common_current_user(); + if (!empty($cur) && $cur->id == $profile->id) { + $mirror = new SubMirror(); + $mirror->subscriber = $profile->id; + $entry = array( + 'id' => 'mirrors', + 'label' => _m('Mirrored feeds'), + 'link' => common_local_url('mirrorsettings'), + 'value' => $mirror->count(), + ); + + $insertAt = count($stats); + foreach ($stats as $i => $row) { + if ($row['id'] == 'groups') { + // Slip us in after them. + $insertAt = $i + 1; + break; + } + } + array_splice($stats, $insertAt, 0, array($entry)); + } + return true; + } } From 1d24ece32e11fb482b67b54d630ac14decdaae39 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 18 Jan 2011 15:18:55 -0800 Subject: [PATCH 8/8] add rss.me to notice_source defaults --- db/notice_source.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/notice_source.sql b/db/notice_source.sql index 82074077b4..b13cfb3e3b 100644 --- a/db/notice_source.sql +++ b/db/notice_source.sql @@ -77,4 +77,5 @@ VALUES ('twitvim','TwitVim','http://vim.sourceforge.net/scripts/script.php?script_id=2204', now()), ('Updating.Me','Updating.Me','http://updating.me/', now()), ('urfastr','urfastr','http://urfastr.net/', now()), - ('yatca','Yatca','http://www.yatca.com/', now()); + ('yatca','Yatca','http://www.yatca.com/', now()), + ('rss.me', 'rss.me', 'http://rss.me/', now());