From c211b1a38ee88e94f35465c001e5739480360d50 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 16 Mar 2011 12:28:26 -0700 Subject: [PATCH 1/4] Work in progress: adding link for managing tag subscriptions. Needs the action still to be functional. --- plugins/TagSub/TagSubPlugin.php | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/plugins/TagSub/TagSubPlugin.php b/plugins/TagSub/TagSubPlugin.php index e51a7a8b39..e3c11ac1ef 100644 --- a/plugins/TagSub/TagSubPlugin.php +++ b/plugins/TagSub/TagSubPlugin.php @@ -179,4 +179,60 @@ class TagSubPlugin extends Plugin } return true; } + + /** + * Menu item for personal subscriptions/groups area + * + * @param Widget $widget Widget being executed + * + * @return boolean hook return + */ + + function onEndSubGroupNav($widget) + { + $action = $widget->out; + $action_name = $action->trimmed('action'); + + $widget->item('tagsubs', + array(), + // TRANS: SubMirror plugin menu item on user settings page. + _m('MENU', 'Tags'), + // TRANS: SubMirror plugin tooltip for user settings menu item. + _m('Configure tag subscriptions')); + + 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) { + $tagsub = new TagSub(); + $tagsub->profile_id = $profile->id; + $entry = array( + 'id' => 'tagsubs', + 'label' => _m('Tag subscriptions'), + 'link' => common_local_url('tagsubs'), + 'value' => $tagsub->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 7785407c65274fac632b52acc84c3a045f7dfeeb Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 16 Mar 2011 14:49:27 -0700 Subject: [PATCH 2/4] Work in progress: tagsub editing ui --- plugins/TagSub/TagSubPlugin.php | 3 + plugins/TagSub/tagsubsaction.php | 173 +++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 plugins/TagSub/tagsubsaction.php diff --git a/plugins/TagSub/TagSubPlugin.php b/plugins/TagSub/TagSubPlugin.php index e3c11ac1ef..ff6c038bc3 100644 --- a/plugins/TagSub/TagSubPlugin.php +++ b/plugins/TagSub/TagSubPlugin.php @@ -103,6 +103,9 @@ class TagSubPlugin extends Plugin array('action' => 'tagunsub'), array('tag' => Router::REGEX_TAG)); + $m->connect(':nickname/tag-subscriptions', + array('action' => 'tagsubs'), + array('nickname' => Nickname::DISPLAY_FMT)); return true; } diff --git a/plugins/TagSub/tagsubsaction.php b/plugins/TagSub/tagsubsaction.php new file mode 100644 index 0000000000..78156fa7b0 --- /dev/null +++ b/plugins/TagSub/tagsubsaction.php @@ -0,0 +1,173 @@ +. + * + * @category Social + * @package StatusNet + * @author Evan Prodromou + * @author Sarven Capadisli + * @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); +} + +/** + * A list of the user's subscriptions + * + * @category Social + * @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/ + */ +class TagSubsAction extends GalleryAction +{ + function title() + { + if ($this->page == 1) { + // TRANS: Header for subscriptions overview for a user (first page). + // TRANS: %s is a user nickname. + return sprintf(_m('%s\'s tag subscriptions'), $this->user->nickname); + } else { + // TRANS: Header for subscriptions overview for a user (not first page). + // TRANS: %1$s is a user nickname, %2$d is the page number. + return sprintf(_m('%1$s\'s tag subscriptions, page %2$d'), + $this->user->nickname, + $this->page); + } + } + + function showPageNotice() + { + $user = common_current_user(); + if ($user && ($user->id == $this->profile->id)) { + $this->element('p', null, + // TRANS: Page notice for page with an overview of all tag subscriptions + // TRANS: of the logged in user's own profile. + _m('You have subscribed to receive all notices on this site containing the following tags.')); + } else { + $this->element('p', null, + // TRANS: Page notice for page with an overview of all subscriptions of a user other + // TRANS: than the logged in user. %s is the user nickname. + sprintf(_m('%s has subscribed to receive all notices on this site containing the following tags.'), + $this->profile->nickname)); + } + } + + function showContent() + { + if (Event::handle('StartShowTagSubscriptionsContent', array($this))) { + parent::showContent(); + + $offset = ($this->page-1) * PROFILES_PER_PAGE; + $limit = PROFILES_PER_PAGE + 1; + + $cnt = 0; + + $tagsub = new TagSub(); + $tagsub->profile_id = $this->user->id; + $tagsub->limit($limit); + $tagsub->offset($offset); + $tagsub->find(); + + if ($tagsub->N) { + $list = new TagSubscriptionsList($tagsub, $this->user, $this); + $cnt = $list->show(); + if (0 == $cnt) { + $this->showEmptyListMessage(); + } + } + + $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, + $this->page, 'tagsubs', + array('nickname' => $this->user->nickname)); + + + Event::handle('EndShowTagSubscriptionsContent', array($this)); + } + } + + function showEmptyListMessage() + { + if (common_logged_in()) { + $current_user = common_current_user(); + if ($this->user->id === $current_user->id) { + // TRANS: Subscription list text when the logged in user has no subscriptions. + // TRANS: This message contains Markdown URLs. The link description is between + // TRANS: square brackets, and the link between parentheses. Do not separate "](" + // TRANS: and do not change the URL part. + $message = _('You\'re not listening to anyone\'s notices right now, try subscribing to people you know. '. + 'Try [people search](%%action.peoplesearch%%), look for members in groups you\'re interested '. + 'in and in our [featured users](%%action.featured%%). '. + 'If you\'re a [Twitter user](%%action.twittersettings%%), you can automatically subscribe to '. + 'people you already follow there.'); + } else { + // TRANS: Subscription list text when looking at the subscriptions for a of a user other + // TRANS: than the logged in user that has no subscriptions. %s is the user nickname. + $message = sprintf(_('%s is not listening to any tags.'), $this->user->nickname); + } + } + else { + // TRANS: Subscription list text when looking at the subscriptions for a of a user that has none + // TRANS: as an anonymous user. %s is the user nickname. + $message = sprintf(_m('%s is not listening to any tags.'), $this->user->nickname); + } + + $this->elementStart('div', 'guide'); + $this->raw(common_markup_to_html($message)); + $this->elementEnd('div'); + } +} + +// XXX SubscriptionsList and SubscriptionList are dangerously close + +class TagSubscriptionsList extends SubscriptionList +{ + function newListItem($tagsub) + { + return new TagSubscriptionsListItem($tagsub, $this->owner, $this->action); + } +} + +class TagSubscriptionsListItem extends SubscriptionListItem +{ + function showProfile() + { + $this->startProfile(); + // Relevant portion! + $cur = common_current_user(); + if (!empty($cur) && $cur->id == $this->owner->id) { + $this->showOwnerControls(); + } + $this->endProfile(); + } + + function showOwnerControls() + { + $tagsub = $this->profile; // ? + $form = new TagSubForm($this->out, $tagsub->tag); + $form->show(); + return; + } +} From 09a4cebd477d0531bba2d1fb9234d01ddba29bfa Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 16 Mar 2011 15:01:58 -0700 Subject: [PATCH 3/4] fix flushrouter.php -- tried to call Cache::delete statically --- scripts/flushrouter.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/flushrouter.php b/scripts/flushrouter.php index 79493eae49..51178a725c 100644 --- a/scripts/flushrouter.php +++ b/scripts/flushrouter.php @@ -28,6 +28,7 @@ END_OF_FLUSHROUTER_HELP; require_once INSTALLDIR.'/scripts/commandline.inc'; -Cache::delete(Router::cacheKey()); +$cache = Cache::instance(); +$cache->delete(Router::cacheKey()); print "OK.\n"; \ No newline at end of file From f8859aa3aa30bc5f9cce62675cf4a94e9c8a3dad Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 16 Mar 2011 15:55:40 -0700 Subject: [PATCH 4/4] Tag subscriptions management UI for TagSub plugin --- plugins/TagSub/TagSubPlugin.php | 15 +++++---- plugins/TagSub/tagsubsaction.php | 57 ++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 25 deletions(-) diff --git a/plugins/TagSub/TagSubPlugin.php b/plugins/TagSub/TagSubPlugin.php index ff6c038bc3..53a06ab5bf 100644 --- a/plugins/TagSub/TagSubPlugin.php +++ b/plugins/TagSub/TagSubPlugin.php @@ -78,6 +78,7 @@ class TagSubPlugin extends Plugin return false; case 'TagsubAction': case 'TagunsubAction': + case 'TagsubsAction': case 'TagSubForm': case 'TagUnsubForm': include_once $dir.'/'.strtolower($cls).'.php'; @@ -196,12 +197,12 @@ class TagSubPlugin extends Plugin $action = $widget->out; $action_name = $action->trimmed('action'); - $widget->item('tagsubs', - array(), - // TRANS: SubMirror plugin menu item on user settings page. - _m('MENU', 'Tags'), - // TRANS: SubMirror plugin tooltip for user settings menu item. - _m('Configure tag subscriptions')); + $action->menuItem(common_local_url('tagsubs', array('nickname' => $action->user->nickname)), + // TRANS: SubMirror plugin menu item on user settings page. + _m('MENU', 'Tags'), + // TRANS: SubMirror plugin tooltip for user settings menu item. + _m('Configure tag subscriptions'), + $action_name == 'tagsubs' && $action->arg('nickname') == $action->user->nickname); return true; } @@ -222,7 +223,7 @@ class TagSubPlugin extends Plugin $entry = array( 'id' => 'tagsubs', 'label' => _m('Tag subscriptions'), - 'link' => common_local_url('tagsubs'), + 'link' => common_local_url('tagsubs', array('nickname' => $profile->nickname)), 'value' => $tagsub->count(), ); diff --git a/plugins/TagSub/tagsubsaction.php b/plugins/TagSub/tagsubsaction.php index 78156fa7b0..f11935229b 100644 --- a/plugins/TagSub/tagsubsaction.php +++ b/plugins/TagSub/tagsubsaction.php @@ -65,12 +65,12 @@ class TagSubsAction extends GalleryAction $this->element('p', null, // TRANS: Page notice for page with an overview of all tag subscriptions // TRANS: of the logged in user's own profile. - _m('You have subscribed to receive all notices on this site containing the following tags.')); + _m('You have subscribed to receive all notices on this site containing the following tags:')); } else { $this->element('p', null, // TRANS: Page notice for page with an overview of all subscriptions of a user other // TRANS: than the logged in user. %s is the user nickname. - sprintf(_m('%s has subscribed to receive all notices on this site containing the following tags.'), + sprintf(_m('%s has subscribed to receive all notices on this site containing the following tags:'), $this->profile->nickname)); } } @@ -87,8 +87,7 @@ class TagSubsAction extends GalleryAction $tagsub = new TagSub(); $tagsub->profile_id = $this->user->id; - $tagsub->limit($limit); - $tagsub->offset($offset); + $tagsub->limit($limit, $offset); $tagsub->find(); if ($tagsub->N) { @@ -97,6 +96,8 @@ class TagSubsAction extends GalleryAction if (0 == $cnt) { $this->showEmptyListMessage(); } + } else { + $this->showEmptyListMessage(); } $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, @@ -113,18 +114,13 @@ class TagSubsAction extends GalleryAction if (common_logged_in()) { $current_user = common_current_user(); if ($this->user->id === $current_user->id) { - // TRANS: Subscription list text when the logged in user has no subscriptions. - // TRANS: This message contains Markdown URLs. The link description is between - // TRANS: square brackets, and the link between parentheses. Do not separate "](" - // TRANS: and do not change the URL part. - $message = _('You\'re not listening to anyone\'s notices right now, try subscribing to people you know. '. - 'Try [people search](%%action.peoplesearch%%), look for members in groups you\'re interested '. - 'in and in our [featured users](%%action.featured%%). '. - 'If you\'re a [Twitter user](%%action.twittersettings%%), you can automatically subscribe to '. - 'people you already follow there.'); + // TRANS: Tag subscription list text when the logged in user has no tag subscriptions. + $message = _('You\'re not listening to any hash tags right now. You can push the "Subscribe" button ' . + 'on any hashtag page to automatically receive any public messages on this site that use that ' . + 'tag, even if you\'re not subscribed to the poster.'); } else { - // TRANS: Subscription list text when looking at the subscriptions for a of a user other - // TRANS: than the logged in user that has no subscriptions. %s is the user nickname. + // TRANS: Tag subscription list text when looking at the subscriptions for a of a user other + // TRANS: than the logged in user that has no tag subscriptions. %s is the user nickname. $message = sprintf(_('%s is not listening to any tags.'), $this->user->nickname); } } @@ -152,22 +148,47 @@ class TagSubscriptionsList extends SubscriptionList class TagSubscriptionsListItem extends SubscriptionListItem { + function startItem() + { + $this->out->elementStart('li', array('class' => 'tagsub')); + } + function showProfile() { - $this->startProfile(); + $tagsub = $this->profile; + $tag = $tagsub->tag; + // Relevant portion! $cur = common_current_user(); if (!empty($cur) && $cur->id == $this->owner->id) { $this->showOwnerControls(); } - $this->endProfile(); + + $url = common_local_url('tag', array('tag' => $tag)); + $linkline = sprintf(_m('#%s since %s'), + htmlspecialchars($url), + htmlspecialchars($tag), + common_date_string($tagsub->created)); + + $this->out->elementStart('div', 'tagsub-item'); + $this->out->raw($linkline); + $this->out->element('div', array('style' => 'clear: both')); + $this->out->elementEnd('div'); + } + + function showActions() + { } function showOwnerControls() { + $this->out->elementStart('div', 'entity_actions'); + $tagsub = $this->profile; // ? - $form = new TagSubForm($this->out, $tagsub->tag); + $form = new TagUnsubForm($this->out, $tagsub->tag); $form->show(); + + $this->out->elementEnd('div'); return; } }