From 22f6151a1033661c59afbfce3535bb2f00efb3d6 Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Wed, 13 Apr 2011 01:26:56 +0530 Subject: [PATCH 1/4] Annihilate profile_tag_inbox. --- actions/showprofiletag.php | 21 ++++--- classes/Notice.php | 112 +++++----------------------------- classes/Profile_list.php | 45 -------------- classes/Profile_tag_inbox.php | 27 -------- classes/statusnet.ini | 9 --- classes/statusnet.links.ini | 5 +- lib/peopletagnoticestream.php | 48 ++++++++++----- 7 files changed, 63 insertions(+), 204 deletions(-) delete mode 100644 classes/Profile_tag_inbox.php diff --git a/actions/showprofiletag.php b/actions/showprofiletag.php index 29ecf4788f..10ab457861 100644 --- a/actions/showprofiletag.php +++ b/actions/showprofiletag.php @@ -33,7 +33,7 @@ require_once INSTALLDIR.'/lib/feedlist.php'; class ShowprofiletagAction extends Action { - var $notice, $tagger, $peopletag; + var $notice, $tagger, $peopletag, $userProfile; function isReadOnly($args) { @@ -88,7 +88,12 @@ class ShowprofiletagAction extends Action } $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; - $this->notice = $this->peopletag->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); + $this->userProfile = Profile::current(); + + $stream = new PeopletagNoticeStream($this->peopletag, $this->userProfile); + + $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, + NOTICES_PER_PAGE + 1); if ($this->page > 1 && $this->notice->N == 0) { // TRANS: Server error when page not found (404). @@ -239,7 +244,7 @@ class ShowprofiletagAction extends Action function showNotices() { if (Event::handle('StartShowProfileTagContent', array($this))) { - $nl = new NoticeList($this->notice, $this); + $nl = new ThreadedNoticeList($this->notice, $this, $this->userProfile); $cnt = $nl->show(); @@ -247,10 +252,12 @@ class ShowprofiletagAction extends Action $this->showEmptyListMessage(); } - $this->pagination( - $this->page > 1, $cnt > NOTICES_PER_PAGE, - $this->page, 'showprofiletag', array('tag' => $this->peopletag->tag, - 'tagger' => $this->tagger->nickname) + $this->pagination($this->page > 1, + $cnt > NOTICES_PER_PAGE, + $this->page, + 'showprofiletag', + array('tag' => $this->peopletag->tag, + 'tagger' => $this->tagger->nickname) ); Event::handle('EndShowProfileTagContent', array($this)); diff --git a/classes/Notice.php b/classes/Notice.php index 70036fa8fb..ada4d495d2 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -545,12 +545,6 @@ class Notice extends Memcached_DataObject $notice->saveKnownGroups($groups); - if (isset($peopletags)) { - $notice->saveProfileTags($peopletags); - } else { - $notice->saveProfileTags(); - } - if (isset($urls)) { $notice->saveKnownUrls($urls); } else { @@ -596,6 +590,11 @@ class Notice extends Memcached_DataObject if (!empty($profile)) { $profile->blowNoticeCount(); } + + $ptags = $this->getProfileTags(); + foreach ($ptags as $ptag) { + $ptag->blowNoticeStreamCache(); + } } /** @@ -618,6 +617,11 @@ class Notice extends Memcached_DataObject // In case we're the first, will need to calc a new root. self::blow('notice:conversation_root:%d', $this->conversation); } + + $ptags = $this->getProfileTags(); + foreach ($ptags as $ptag) { + $ptag->blowNoticeStreamCache(true); + } } /** save all urls in the notice to the db @@ -1030,34 +1034,14 @@ class Notice extends Memcached_DataObject function getProfileTags() { - // Don't save ptags for repeats, for now. + $profile = $this->getProfile(); + $list = $profile->getOtherTags($profile); + $ptags = array(); - if (!empty($this->repeat_of)) { - return array(); + while($list->fetch()) { + $ptags[] = clone($list); } - // XXX: cache me - - $ptags = array(); - - $ptagi = new Profile_tag_inbox(); - - $ptagi->selectAdd(); - $ptagi->selectAdd('profile_tag_id'); - - $ptagi->notice_id = $this->id; - - if ($ptagi->find()) { - while ($ptagi->fetch()) { - $profile_list = Profile_list::staticGet('id', $ptagi->profile_tag_id); - if ($profile_list) { - $ptags[] = $profile_list; - } - } - } - - $ptagi->free(); - return $ptags; } @@ -1173,72 +1157,6 @@ class Notice extends Memcached_DataObject return true; } - /** - * record targets into profile_tag_inbox. - * @return array of Profile_list objects - */ - function saveProfileTags($known=array()) - { - // Don't save ptags for repeats, for now - - if (!empty($this->repeat_of)) { - return array(); - } - - if (is_array($known)) { - $ptags = $known; - } else { - $ptags = array(); - } - - $ptag = new Profile_tag(); - $ptag->tagged = $this->profile_id; - - if($ptag->find()) { - while($ptag->fetch()) { - $plist = Profile_list::getByTaggerAndTag($ptag->tagger, $ptag->tag); - if (!empty($plist)) { - $ptags[] = clone($plist); - } - } - } - - foreach ($ptags as $target) { - $this->addToProfileTagInbox($target); - } - - return $ptags; - } - - function addToProfileTagInbox($plist) - { - $ptagi = Profile_tag_inbox::pkeyGet(array('profile_tag_id' => $plist->id, - 'notice_id' => $this->id)); - - if (empty($ptagi)) { - - $ptagi = new Profile_tag_inbox(); - - $ptagi->query('BEGIN'); - $ptagi->profile_tag_id = $plist->id; - $ptagi->notice_id = $this->id; - $ptagi->created = $this->created; - - $result = $ptagi->insert(); - if (!$result) { - common_log_db_error($ptagi, 'INSERT', __FILE__); - // TRANS: Server exception thrown when saving profile_tag inbox fails. - throw new ServerException(_('Problem saving profile_tag inbox.')); - } - - $ptagi->query('COMMIT'); - - self::blow('profile_tag:notice_ids:%d', $ptagi->profile_tag_id); - } - - return true; - } - /** * Save reply records indicating that this notice needs to be * delivered to the local users with the given URIs. diff --git a/classes/Profile_list.php b/classes/Profile_list.php index bbe892c0d0..cf0a255e75 100644 --- a/classes/Profile_list.php +++ b/classes/Profile_list.php @@ -170,51 +170,6 @@ class Profile_list extends Memcached_DataObject return $stream->getNotices($offset, $limit, $since_id, $max_id); } - /** - * Query notices by users associated with this tag from the database. - * - * @param integer $offset offset - * @param integer $limit maximum no of results - * @param integer $since_id=null since this id - * @param integer $max_id=null maximum id in result - * - * @return array array of notice ids. - */ - - function _streamDirect($offset, $limit, $since_id, $max_id) - { - $inbox = new Profile_tag_inbox(); - - $inbox->profile_tag_id = $this->id; - - $inbox->selectAdd(); - $inbox->selectAdd('notice_id'); - - if ($since_id != 0) { - $inbox->whereAdd('notice_id > ' . $since_id); - } - - if ($max_id != 0) { - $inbox->whereAdd('notice_id <= ' . $max_id); - } - - $inbox->orderBy('notice_id DESC'); - - if (!is_null($offset)) { - $inbox->limit($offset, $limit); - } - - $ids = array(); - - if ($inbox->find()) { - while ($inbox->fetch()) { - $ids[] = $inbox->notice_id; - } - } - - return $ids; - } - /** * Get subscribers (local and remote) to this people tag * Order by reverse chronology diff --git a/classes/Profile_tag_inbox.php b/classes/Profile_tag_inbox.php deleted file mode 100644 index dd517b3088..0000000000 --- a/classes/Profile_tag_inbox.php +++ /dev/null @@ -1,27 +0,0 @@ -profile_tag = $profile_tag; + $this->profile_list = $profile_list; } + /** + * Query notices by users associated with this tag from the database. + * + * @param integer $offset offset + * @param integer $limit maximum no of results + * @param integer $since_id=null since this id + * @param integer $max_id=null maximum id in result + * + * @return array array of notice ids. + */ + function getNoticeIds($offset, $limit, $since_id, $max_id) { - $inbox = new Profile_tag_inbox(); + $notice = new Notice(); - $inbox->profile_tag_id = $this->profile_tag->id; + $notice->selectAdd(); + $notice->selectAdd('notice.id'); - $inbox->selectAdd(); - $inbox->selectAdd('notice_id'); + $ptag = new Profile_tag(); + $ptag->tag = $this->profile_list->tag; + $ptag->tagger = $this->profile_list->tagger; + $notice->joinAdd($ptag); - Notice::addWhereSinceId($inbox, $since_id, 'notice_id'); - Notice::addWhereMaxId($inbox, $max_id, 'notice_id'); + if ($since_id != 0) { + $notice->whereAdd('notice.id > ' . $since_id); + } - $inbox->orderBy('created DESC, notice_id DESC'); + if ($max_id != 0) { + $notice->whereAdd('notice.id <= ' . $max_id); + } + + $notice->orderBy('notice.id DESC'); if (!is_null($offset)) { - $inbox->limit($offset, $limit); + $notice->limit($offset, $limit); } $ids = array(); - - if ($inbox->find()) { - while ($inbox->fetch()) { - $ids[] = $inbox->notice_id; + if ($notice->find()) { + while ($notice->fetch()) { + $ids[] = $notice->id; } } From 53af608ef882eb03cd924ed630f98d856c11370a Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Wed, 13 Apr 2011 13:45:25 +0530 Subject: [PATCH 2/4] People tags -> Lists (only UI changes, for experimentation) --- actions/editpeopletag.php | 10 +- actions/peopletagged.php | 6 +- actions/peopletagsbyuser.php | 52 +++++---- actions/peopletagsforuser.php | 43 +++----- actions/peopletagsubscriptions.php | 22 +++- actions/showprofiletag.php | 20 ++-- lib/peopletageditform.php | 10 +- lib/peopletaggroupnav.php | 12 +-- lib/peopletaglist.php | 2 +- lib/peopletagnav.php | 106 +++++++++++++++++++ lib/peopletagsbysubssection.php | 2 +- lib/peopletagsection.php | 7 +- lib/peopletagsforusersection.php | 12 ++- lib/peopletagsubscriptionssection.php | 2 +- lib/personalgroupnav.php | 12 --- lib/profileaction.php | 16 --- lib/publicgroupnav.php | 6 -- lib/subgroupnav.php | 8 +- plugins/OStatus/OStatusPlugin.php | 6 +- plugins/OStatus/actions/ostatuspeopletag.php | 2 +- plugins/OStatus/actions/peopletagsalmon.php | 14 +-- 21 files changed, 231 insertions(+), 139 deletions(-) create mode 100644 lib/peopletagnav.php diff --git a/actions/editpeopletag.php b/actions/editpeopletag.php index 9d0548cb94..db34e485cc 100644 --- a/actions/editpeopletag.php +++ b/actions/editpeopletag.php @@ -49,11 +49,11 @@ class EditpeopletagAction extends OwnerDesignAction if ($_SERVER['REQUEST_METHOD'] == 'POST' && $this->boolean('delete')) { // TRANS: Title for edit people tag page after deleting a tag. // TRANS: %s is a tag. - return sprintf(_('Delete %s people tag'), $this->peopletag->tag); + return sprintf(_('Delete %s list'), $this->peopletag->tag); } // TRANS: Title for edit people tag page. // TRANS: %s is a tag. - return sprintf(_('Edit people tag %s'), $this->peopletag->tag); + return sprintf(_('Edit list %s'), $this->peopletag->tag); } /** @@ -106,7 +106,7 @@ class EditpeopletagAction extends OwnerDesignAction if (!$this->peopletag) { // TRANS: Client error displayed when referring to a non-exsting people tag. - $this->clientError(_('No such people tag.'), 404); + $this->clientError(_('No such list.'), 404); return false; } @@ -216,7 +216,7 @@ class EditpeopletagAction extends OwnerDesignAction } else { $this->element('p', 'instructions', // TRANS: Form instruction for edit people tag form. - _('Use this form to edit the people tag.')); + _('Use this form to edit the list.')); } } @@ -294,7 +294,7 @@ class EditpeopletagAction extends OwnerDesignAction if (!$result) { common_log_db_error($this->group, 'UPDATE', __FILE__); // TRANS: TRANS: Server error displayed when updating a people tag fails. - $this->serverError(_('Could not update people tag.')); + $this->serverError(_('Could not update list.')); } $this->peopletag->query('COMMIT'); diff --git a/actions/peopletagged.php b/actions/peopletagged.php index 84356116cc..7ab16b6f87 100644 --- a/actions/peopletagged.php +++ b/actions/peopletagged.php @@ -93,7 +93,7 @@ class PeopletaggedAction extends OwnerDesignAction if (!$this->peopletag) { // TRANS: Client error displayed when referring to non-existing people tag. - $this->clientError(_('No such people tag.'), 404); + $this->clientError(_('No such list.'), 404); return false; } @@ -105,12 +105,12 @@ class PeopletaggedAction extends OwnerDesignAction if ($this->page == 1) { // TRANS: Title for list of people tagged by the user with a tag. // TRANS: %1$s is a tag, %2$s is a username. - return sprintf(_('People tagged %1$s by %2$s'), + return sprintf(_('People listed in %1$s by %2$s'), $this->peopletag->tag, $this->tagger->nickname); } else { // TRANS: Title for list of people tagged by the user with a tag. // TRANS: %1$s is a tag, %2$s is a username, %2$s is a page number. - return sprintf(_('People tagged %1$s by %2$s, page %3$d'), + return sprintf(_('People listed in %1$s by %2$s, page %3$d'), $this->peopletag->tag, $this->user->nickname, $this->page); } diff --git a/actions/peopletagsbyuser.php b/actions/peopletagsbyuser.php index 42b728e1d8..7dc70058b2 100644 --- a/actions/peopletagsbyuser.php +++ b/actions/peopletagsbyuser.php @@ -2,7 +2,7 @@ /** * StatusNet, the distributed open-source microblogging tool * - * People tags by a user + * Lists by a user * * PHP version 5 * @@ -49,22 +49,22 @@ class PeopletagsbyuserAction extends OwnerDesignAction if ($this->page == 1) { if ($this->isOwner()) { if ($this->arg('private')) { - // TRANS: Title for people tags by a user page for a private tag. - return _('Private people tags by you'); + // TRANS: Title for lists by a user page for a private tag. + return _('Private lists by you'); } else if ($this->arg('public')) { - // TRANS: Title for people tags by a user page for a public tag. - return _('Public people tags by you'); + // TRANS: Title for lists by a user page for a public tag. + return _('Public lists by you'); } - // TRANS: Title for people tags by a user page. - return _('People tags by you'); + // TRANS: Title for lists by a user page. + return _('Lists by you'); } - // TRANS: Title for people tags by a user page. + // TRANS: Title for lists by a user page. // TRANS: %s is a user nickname. - return sprintf(_('People tags by %s'), $this->tagger->nickname); + return sprintf(_('Lists by %s'), $this->tagger->nickname); } else { - // TRANS: Title for people tags by a user page. + // TRANS: Title for lists by a user page. // TRANS: %1$s is a user nickname, %2$d is a page number. - return sprintf(_('People tags by %1$s, page %2$d'), $this->tagger->nickname, $this->page); + return sprintf(_('Lists by %1$s, page %2$d'), $this->tagger->nickname, $this->page); } } @@ -124,8 +124,8 @@ class PeopletagsbyuserAction extends OwnerDesignAction if ($this->isOwner()) { $this->tags = $this->tagger->getPrivateTags($offset, $limit); } else { - // TRANS: Client error displayed when trying view another user's private people tags. - $this->clientError(_('You cannot view others\' private people tags'), 403); + // TRANS: Client error displayed when trying view another user's private lists. + $this->clientError(_('You cannot view others\' private lists'), 403); } } else { $this->tags = $this->tagger->getOwnedTags(common_current_user(), $offset, $limit); @@ -160,8 +160,8 @@ class PeopletagsbyuserAction extends OwnerDesignAction array('href' => common_local_url('peopletagsforuser', array('nickname' => $this->user->nickname))), - // TRANS: Link text to show people tags for user %s. - sprintf(_('People tags for %s'), $this->tagger->nickname)); + // TRANS: Link text to show lists for user %s. + sprintf(_('Lists for %s'), $this->tagger->nickname)); $this->elementEnd('li'); if ($this->isOwner()) { @@ -204,11 +204,11 @@ class PeopletagsbyuserAction extends OwnerDesignAction function showAnonymousMessage() { $notice = - // TRANS: Message displayed for anonymous users on page that displays people tags by a user. + // TRANS: Message displayed for anonymous users on page that displays lists by a user. // TRANS: This message contains Markdown links in the form [description](links). // TRANS: %s is a tagger nickname. - sprintf(_('These are people tags created by **%s**. ' . - 'People tags are how you sort similar ' . + sprintf(_('These are lists created by **%s**. ' . + 'Lists are how you sort similar ' . 'people on %%%%site.name%%%%, a [micro-blogging]' . '(http://en.wikipedia.org/wiki/Micro-blogging) service ' . 'based on the Free Software [StatusNet](http://status.net/) tool. ' . @@ -259,17 +259,29 @@ class PeopletagsbyuserAction extends OwnerDesignAction return !empty($user) && $user->id == $this->tagger->id; } + function showObjectNav() + { + $nav = new PeopletagNav($this, $this->tagger); + $nav->show(); + } + function showEmptyListMessage() { - // TRANS: Message displayed on page that displays people tags by a user when there are none. + // TRANS: Message displayed on page that displays lists by a user when there are none. // TRANS: This message contains Markdown links in the form [description](links). // TRANS: %s is a tagger nickname. - $message = sprintf(_('%s has not created any [people tags](%%%%doc.tags%%%%) yet.'), $this->tagger->nickname); + $message = sprintf(_('%s has not created any [lists](%%%%doc.lists%%%%) yet.'), $this->tagger->nickname); $this->elementStart('div', 'guide'); $this->raw(common_markup_to_html($message)); $this->elementEnd('div'); } + function showProfileBlock() + { + $block = new AccountProfileBlock($this, $this->tagger); + $block->show(); + } + function showSections() { #TODO: tags with most subscribers diff --git a/actions/peopletagsforuser.php b/actions/peopletagsforuser.php index 789dcbe921..7f5c216070 100644 --- a/actions/peopletagsforuser.php +++ b/actions/peopletagsforuser.php @@ -47,10 +47,10 @@ class PeopletagsforuserAction extends OwnerDesignAction { if ($this->page == 1) { // Page title. %s is a tagged user's nickname. - return sprintf(_('People tags for %s'), $this->tagged->nickname); + return sprintf(_('Lists with %s in them'), $this->tagged->nickname); } else { // Page title. %1$s is a tagged user's nickname, %2$s is a page number. - return sprintf(_('People tags for %1$s, page %2$d'), $this->tagged->nickname, $this->page); + return sprintf(_('Lists with %1$s, page %2$d'), $this->tagged->nickname, $this->page); } } @@ -105,8 +105,8 @@ class PeopletagsforuserAction extends OwnerDesignAction // TRANS: Message displayed for anonymous users on page that displays people tags for a user. // TRANS: This message contains Markdown links in the form [description](links). // TRANS: %s is a tagger nickname. - sprintf(_('These are people tags for **%s**. ' . - 'People tags are how you sort similar ' . + sprintf(_('These are lists for **%s**. ' . + 'lists are how you sort similar ' . 'people on %%%%site.name%%%%, a [micro-blogging]' . '(http://en.wikipedia.org/wiki/Micro-blogging) service ' . 'based on the Free Software [StatusNet](http://status.net/) tool. ' . @@ -117,27 +117,6 @@ class PeopletagsforuserAction extends OwnerDesignAction $this->elementEnd('div'); } - function showPageNotice() - { - $this->elementStart('dl', 'filter_tags'); - $this->elementStart('dd', array('id' => 'filter_tags_for', - 'class' => 'child_1')); - - $user = common_current_user(); - // TRANS: Page notice. - $text = ($this->tagged->id == @$user->id) ? _('People tags by you') : - // TRANS: Page notice. %s is a tagger's nickname. - sprintf(_('People tags by %s'), $this->tagged->nickname); - $this->element('a', - array('href' => - common_local_url('peopletagsbyuser', - array('nickname' => $this->tagged->nickname))), - $text); - $this->elementEnd('dd'); - $this->elementEnd('dl'); - } - - function showContent() { #TODO: controls here. @@ -162,12 +141,24 @@ class PeopletagsforuserAction extends OwnerDesignAction // TRANS: Message displayed on page that displays people tags for a user when there are none. // TRANS: This message contains Markdown links in the form [description](links). // TRANS: %s is a tagger nickname. - $message = sprintf(_('%s has not been [tagged](%%%%doc.tags%%%%) by anyone yet.'), $this->tagged->nickname); + $message = sprintf(_('%s has not been [listed](%%%%doc.lists%%%%) by anyone yet.'), $this->tagged->nickname); $this->elementStart('div', 'guide'); $this->raw(common_markup_to_html($message)); $this->elementEnd('div'); } + function showObjectNav() + { + $nav = new PeopletagNav($this, $this->tagged); + $nav->show(); + } + + function showProfileBlock() + { + $block = new AccountProfileBlock($this, $this->tagged); + $block->show(); + } + function showSections() { #TODO: tags with most subscribers diff --git a/actions/peopletagsubscriptions.php b/actions/peopletagsubscriptions.php index 5eee82396d..3674cc1e76 100644 --- a/actions/peopletagsubscriptions.php +++ b/actions/peopletagsubscriptions.php @@ -48,11 +48,11 @@ class PeopletagsubscriptionsAction extends OwnerDesignAction if ($this->page == 1) { // TRANS: Title for page that displays people tags subscribed to by a user. // TRANS: %s is a profile nickname. - return sprintf(_('People tags subscriptions by %s'), $this->profile->nickname); + return sprintf(_('Lists subscribed to by %s'), $this->profile->nickname); } else { // TRANS: Title for page that displays people tags subscribed to by a user. // TRANS: %1$s is a profile nickname, %2$d is a page number. - return sprintf(_('People tags subscriptions by %1$s, page %2$d'), $this->profile->nickname, $this->page); + return sprintf(_('Lists subscribed to by %1$s, page %2$d'), $this->profile->nickname, $this->page); } } @@ -107,13 +107,13 @@ class PeopletagsubscriptionsAction extends OwnerDesignAction // TRANS: Message displayed for anonymous users on page that displays people tags subscribed to by a user. // TRANS: This message contains Markdown links in the form [description](links). // TRANS: %s is a profile nickname. - sprintf(_('These are people tags subscribed to by **%s**. ' . - 'People tags are how you sort similar ' . + sprintf(_('These are lists subscribed to by **%s**. ' . + 'Lists are how you sort similar ' . 'people on %%%%site.name%%%%, a [micro-blogging]' . '(http://en.wikipedia.org/wiki/Micro-blogging) service ' . 'based on the Free Software [StatusNet](http://status.net/) tool. ' . 'You can easily keep track of what they ' . - 'are doing by subscribing to the tag\'s timeline.' ), $this->profile->nickname); + 'are doing by subscribing to the list\'s timeline.' ), $this->profile->nickname); $this->elementStart('div', array('id' => 'anon_notice')); $this->raw(common_markup_to_html($notice)); $this->elementEnd('div'); @@ -133,6 +133,18 @@ class PeopletagsubscriptionsAction extends OwnerDesignAction $this->page, 'peopletagsubscriptions', array('nickname' => $this->profile->id)); } + function showObjectNav() + { + $nav = new PeopletagNav($this, $this->profile); + $nav->show(); + } + + function showProfileBlock() + { + $block = new AccountProfileBlock($this, $this->profile); + $block->show(); + } + function showSections() { #TODO: tags with most subscribers diff --git a/actions/showprofiletag.php b/actions/showprofiletag.php index 10ab457861..07603d5a4b 100644 --- a/actions/showprofiletag.php +++ b/actions/showprofiletag.php @@ -122,7 +122,7 @@ class ShowprofiletagAction extends Action if($this->peopletag->private) { // TRANS: Title for private people tag timeline. // TRANS: %1$s is a people tag, %2$s is a page number. - return sprintf(_('Private timeline for people tagged %1$s by you, page %2$d'), + return sprintf(_('Private timeline for %1$s list by you, page %2$d'), $this->peopletag->tag, $this->page); } @@ -130,13 +130,13 @@ class ShowprofiletagAction extends Action if (!empty($current) && $current->id == $this->peopletag->tagger) { // TRANS: Title for public people tag timeline where the viewer is the tagger. // TRANS: %1$s is a people tag, %2$s is a page number. - return sprintf(_('Timeline for people tagged %1$s by you, page %2$d'), + return sprintf(_('Timeline for %1$s list by you, page %2$d'), $this->peopletag->tag, $this->page); } // TRANS: Title for private people tag timeline. // TRANS: %1$s is a people tag, %2$s is the tagger's nickname, %3$d is a page number. - return sprintf(_('Timeline for people tagged %1$s by %2$s, page %3$d'), + return sprintf(_('Timeline for %1$s list by %2$s, page %3$d'), $this->peopletag->tag, $this->tagger->nickname, $this->page @@ -145,7 +145,7 @@ class ShowprofiletagAction extends Action if($this->peopletag->private) { // TRANS: Title for private people tag timeline. // TRANS: %s is a people tag. - return sprintf(_('Private timeline of people tagged %s by you'), + return sprintf(_('Private timeline of %s list by you'), $this->peopletag->tag); } @@ -153,13 +153,13 @@ class ShowprofiletagAction extends Action if (!empty($current) && $current->id == $this->peopletag->tagger) { // TRANS: Title for public people tag timeline where the viewer is the tagger. // TRANS: %s is a people tag. - return sprintf(_('Timeline for people tagged %s by you'), + return sprintf(_('Timeline for %s list by you'), $this->peopletag->tag); } // TRANS: Title for private people tag timeline. // TRANS: %1$s is a people tag, %2$s is the tagger's nickname. - return sprintf(_('Timeline for people tagged %1$s by %2$s'), + return sprintf(_('Timeline for %1$s list by %2$s'), $this->peopletag->tag, $this->tagger->nickname ); @@ -190,7 +190,7 @@ class ShowprofiletagAction extends Action ), // TRANS: Feed title. // TRANS: %1$s is a people tag, %2$s is tagger's nickname. - sprintf(_('Feed for people tagged %1$s by %2$s (Atom)'), + sprintf(_('Feed for %1$s list by %2$s (Atom)'), $this->peopletag->tag, $this->tagger->nickname ) ) @@ -207,7 +207,7 @@ class ShowprofiletagAction extends Action { // TRANS: Empty list message for people tag timeline. // TRANS: %1$s is a people tag, %2$s is a tagger's nickname. - $message = sprintf(_('This is the timeline for people tagged %1$s by %2$s but no one has posted anything yet.'), + $message = sprintf(_('This is the timeline for %1$s list by %2$s but no one has posted anything yet.'), $this->peopletag->tag, $this->tagger->nickname) . ' '; @@ -291,11 +291,11 @@ class ShowprofiletagAction extends Action if(!empty($current) && $this->peopletag->tagger == $current->id) { // TRANS: Header on show profile tag page. // TRANS: %s is a people tag. - $title = sprintf(_('People tagged %s by you'), $this->peopletag->tag); + $title = sprintf(_('Listed'), $this->peopletag->tag); } else { // TRANS: Header on show profile tag page. // TRANS: %1$s is a people tag, %2$s is a tagger's nickname. - $title = sprintf(_('People tagged %1$s by %2$s'), + $title = sprintf(_('Listed'), $this->peopletag->tag, $this->tagger->nickname); } diff --git a/lib/peopletageditform.php b/lib/peopletageditform.php index 27920008a8..9fb824bdbc 100644 --- a/lib/peopletageditform.php +++ b/lib/peopletageditform.php @@ -107,7 +107,7 @@ class PeopletagEditForm extends Form { // TRANS: Form legend for people tag edit form. // TRANS: %s is a people tag. - $this->out->element('legend', null, sprintf(_('Edit people tag %s'), $this->peopletag->tag)); + $this->out->element('legend', null, sprintf(_('Edit list %s'), $this->peopletag->tag)); } /** @@ -138,12 +138,12 @@ class PeopletagEditForm extends Form $desclimit = Profile_list::maxDescription(); if ($desclimit == 0) { // TRANS: Field title for description of people tag. - $descinstr = _('Describe the people tag or topic.'); + $descinstr = _('Describe the list or topic.'); } else { // TRANS: Field title for description of people tag. // TRANS: %d is the maximum number of characters for the description. - $descinstr = sprintf(_m('Describe the people tag or topic in %d character.', - 'Describe the people tag or topic in %d characters.', + $descinstr = sprintf(_m('Describe the list or topic in %d character.', + 'Describe the list or topic in %d characters.', $desclimit), $desclimit); } @@ -172,7 +172,7 @@ class PeopletagEditForm extends Form 'submit', 'delete', // TRANS: Button title to delete a people tag. - _('Delete this people tag.')); + _('Delete this list.')); } function showProfileList() diff --git a/lib/peopletaggroupnav.php b/lib/peopletaggroupnav.php index 5c95487247..a93499ce76 100644 --- a/lib/peopletaggroupnav.php +++ b/lib/peopletaggroupnav.php @@ -104,10 +104,10 @@ class PeopletagGroupNav extends Widget $this->out->menuItem(common_local_url('showprofiletag', array('tagger' => $user_profile->nickname, 'tag' => $tag->tag)), // TRANS: Menu item in people tag navigation panel. - _m('MENU','People tag'), + _m('MENU','List'), // TRANS: Menu item title in people tag navigation panel. // TRANS: %1$s is a tag, %2$s is a nickname. - sprintf(_('%1$s tag by %2$s.'), $tag->tag, + sprintf(_('%1$s list by %2$s.'), $tag->tag, (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)), $action == 'showprofiletag', 'nav_timeline_peopletag'); @@ -115,10 +115,10 @@ class PeopletagGroupNav extends Widget $this->out->menuItem(common_local_url('peopletagged', array('tagger' => $user->nickname, 'tag' => $tag->tag)), // TRANS: Menu item in people tag navigation panel. - _m('MENU','Tagged'), + _m('MENU','Listed'), // TRANS: Menu item title in people tag navigation panel. // TRANS: %1$s is a tag, %2$s is a nickname. - sprintf(_('%1$s tag by %2$s.'), $tag->tag, + sprintf(_('%1$s list by %2$s.'), $tag->tag, (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)), $action == 'peopletagged', 'nav_peopletag_tagged'); @@ -129,7 +129,7 @@ class PeopletagGroupNav extends Widget _m('MENU','Subscribers'), // TRANS: Menu item title in people tag navigation panel. // TRANS: %1$s is a tag, %2$s is a nickname. - sprintf(_('Subscribers to %1$s tag by %2$s.'), $tag->tag, + sprintf(_('Subscribers to %1$s list by %2$s.'), $tag->tag, (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)), $action == 'peopletagsubscribers', 'nav_peopletag_subscribers'); @@ -142,7 +142,7 @@ class PeopletagGroupNav extends Widget _m('MENU','Edit'), // TRANS: Menu item title in people tag navigation panel. // TRANS: %s is a tag. - sprintf(_('Edit %s tag by you.'), $tag->tag, + sprintf(_('Edit %s list by you.'), $tag->tag, (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)), $action == 'editpeopletag', 'nav_peopletag_edit'); } diff --git a/lib/peopletaglist.php b/lib/peopletaglist.php index 729ff8814e..10ebc8cb9e 100644 --- a/lib/peopletaglist.php +++ b/lib/peopletaglist.php @@ -193,7 +193,7 @@ class PeopletagListItem extends Widget common_local_url('editpeopletag', array('tagger' => $this->profile->nickname, 'tag' => $this->peopletag->tag)), // TRANS: Title for link to edit people tag settings. - 'title' => _('Edit people tag settings.')), + 'title' => _('Edit list settings.')), // TRANS: Text for link to edit people tag settings. _('Edit')); $this->out->elementEnd('li'); diff --git a/lib/peopletagnav.php b/lib/peopletagnav.php new file mode 100644 index 0000000000..cc03b59a35 --- /dev/null +++ b/lib/peopletagnav.php @@ -0,0 +1,106 @@ +. + * + * @category Action + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/widget.php'; + +/** + * Tabset for a group + * + * Shows a group of tabs for a particular user group + * + * @category Output + * @package StatusNet + * @author Shashi Gowda + * @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 PeopletagNav extends Menu +{ + var $group = null; + + /** + * Construction + * + * @param Action $action current action, used for output + */ + function __construct($action=null, $profile=null) + { + parent::__construct($action); + $this->profile = $profile; + } + + /** + * Show the menu + * + * @return void + */ + function show() + { + $action_name = $this->action->trimmed('action'); + $nickname = $this->profile->nickname; + + $this->out->elementStart('ul', array('class' => 'nav')); + if (Event::handle('StartPeopletagGroupNav', array($this))) { + $this->out->menuItem(common_local_url('peopletagsubscriptions', array('nickname' => + $nickname)), + // TRANS: Menu item in the group navigation page. + _m('MENU','List Subscriptions'), + // TRANS: Tooltip for menu item in the group navigation page. + // TRANS: %s is the nickname of the group. + sprintf(_m('TOOLTIP','Lists subscribed to by %s'), $nickname), + $action_name == 'peopletagsubscriptions', + 'nav_list_group'); + $this->out->menuItem(common_local_url('peopletagsforuser', array('nickname' => + $nickname)), + // TRANS: Menu item in the group navigation page. + sprintf(_m('MENU','Lists with %s'), $nickname), + // TRANS: Tooltip for menu item in the group navigation page. + // TRANS: %s is the nickname of the group. + sprintf(_m('TOOLTIP','Lists with %s'), $nickname), + $action_name == 'peopletagsforuser', + 'nav_lists_with'); + $this->out->menuItem(common_local_url('peopletagsbyuser', array('nickname' => + $nickname)), + // TRANS: Menu item in the group navigation page. + sprintf(_m('MENU','Lists by %s'), $nickname), + // TRANS: Tooltip for menu item in the group navigation page. + // TRANS: %s is the nickname of the group. + sprintf(_m('TOOLTIP','Lists by %s'), $nickname), + $action_name == 'peopletagsbyuser', + 'nav_lists_by'); + Event::handle('EndGroupGroupNav', array($this)); + } + $this->out->elementEnd('ul'); + } +} diff --git a/lib/peopletagsbysubssection.php b/lib/peopletagsbysubssection.php index d67b7fb88d..e1e3251f84 100644 --- a/lib/peopletagsbysubssection.php +++ b/lib/peopletagsbysubssection.php @@ -66,7 +66,7 @@ class PeopletagsBySubsSection extends PeopletagSection function title() { // TRANS: Title for section contaning people tags with the most subscribers. - return _('People tags with most subscribers'); + return _('Lists with most subscribers'); } function divId() diff --git a/lib/peopletagsection.php b/lib/peopletagsection.php index 20358cb85d..a6c587e04e 100644 --- a/lib/peopletagsection.php +++ b/lib/peopletagsection.php @@ -83,6 +83,7 @@ class PeopletagSection extends Section class PeopletagSectionItem extends PeopletagListItem { + function showStart() { } @@ -104,10 +105,11 @@ class PeopletagSectionItem extends PeopletagListItem common_log(LOG_WARNING, "Trying to show missing peopletag; skipping."); return; } + $mode = ($this->peopletag->private) ? 'private' : 'public'; $this->out->elementStart('tr'); - $this->out->elementStart('td', 'peopletag'); + $this->out->elementStart('td', 'peopletag mode-' . $mode); $this->showPeopletag(); $this->out->elementEnd('td'); @@ -121,11 +123,12 @@ class PeopletagSectionItem extends PeopletagListItem { // TRANS: Tag summary. %1$d is the number of users tagged with the tag, // TRANS: %2$d is the number of subscribers to the tag. - $title = sprintf(_('Tagged: %1$d Subscribers: %2$d'), + $title = sprintf(_('Listed: %1$d Subscribers: %2$d'), $this->peopletag->taggedCount(), $this->peopletag->subscriberCount()); $this->out->elementStart('span', 'entry-title tag'); + $this->out->element('a', array('rel' => 'bookmark', 'href' => $this->url(), diff --git a/lib/peopletagsforusersection.php b/lib/peopletagsforusersection.php index fef469eb8d..9f7879d9e1 100644 --- a/lib/peopletagsforusersection.php +++ b/lib/peopletagsforusersection.php @@ -62,13 +62,15 @@ class PeopletagsForUserSection extends PeopletagSection function title() { - $name = $this->profile->getBestName(); - if ($this->profile->id == common_current_user()->id) { - $name = 'you'; + $user = common_current_user(); + + if (!empty($user) && $this->profile->id == $user->id) { + return sprintf(_('Lists with you')); } - // TRANS: Title for page that displays which people tags a user has been tagged with. + // TRANS: Title for page that displays + // which people tags a user has been tagged with. // TRANS: %s is a profile name. - return sprintf(_('People tags for %s'), $name); + return sprintf(_('Lists with %s'), $this->profile->getBestName()); } function link() diff --git a/lib/peopletagsubscriptionssection.php b/lib/peopletagsubscriptionssection.php index 2182a3d834..616af28d4c 100644 --- a/lib/peopletagsubscriptionssection.php +++ b/lib/peopletagsubscriptionssection.php @@ -62,7 +62,7 @@ class PeopletagSubscriptionsSection extends PeopletagSection function title() { // TRANS: Title for page that displays people tags a user has subscribed to. - return _('People tag subscriptions'); + return _('List subscriptions'); } function link() diff --git a/lib/personalgroupnav.php b/lib/personalgroupnav.php index 3b3a87ff0d..d379dcf528 100644 --- a/lib/personalgroupnav.php +++ b/lib/personalgroupnav.php @@ -103,18 +103,6 @@ class PersonalGroupNav extends Menu // TRANS: Replaces %s in '%s\'s favorite notices'. (Yes, we know we need to fix this.) ($user_profile) ? $name : _m('FIXME','User')), $mine && $action =='showfavorites', 'nav_timeline_favorites'); - $this->out->menuItem(common_local_url('peopletagsbyuser', array('nickname' => - $nickname)), - // TRANS: Menu item in personal group navigation menu. - _m('MENU','People tags'), - // @todo i18n FIXME: Need to make this two messages. - // TRANS: Menu item title in personal group navigation menu. - // TRANS: %s is a username. - sprintf(_('People tags by %s'), - // TRANS: Replaces %s in 'People tags by %s'. (Yes, we know we need to fix this.) - ($user_profile) ? $name : _('User')), - in_array($action, array('peopletagsbyuser', 'peopletagsforuser')), - 'nav_timeline_peopletags'); $cur = common_current_user(); diff --git a/lib/profileaction.php b/lib/profileaction.php index cd3f5bcde5..16592783c9 100644 --- a/lib/profileaction.php +++ b/lib/profileaction.php @@ -97,7 +97,6 @@ class ProfileAction extends OwnerDesignAction $this->showSubscriptions(); $this->showSubscribers(); $this->showGroups(); - $this->showPeopletagSubs(); $this->showPeopletags(); $this->showStatistics(); } @@ -190,21 +189,6 @@ class ProfileAction extends OwnerDesignAction $this->elementEnd('div'); } - function showPeopletagSubs() - { - $user = common_current_user(); - if (!empty($user) && $this->profile->id == $user->id) { - if (Event::handle('StartShowPeopletagSubscriptionsSection', array($this))) { - - $profile = $user->getProfile(); - $section = new PeopletagSubscriptionsSection($this, $profile); - $section->show(); - - Event::handle('EndShowPeopletagSubscriptionsSection', array($this)); - } - } - } - function showPeopletags() { if (Event::handle('StartShowPeopletagsSection', array($this))) { diff --git a/lib/publicgroupnav.php b/lib/publicgroupnav.php index 75aa3dd60f..77243fda7a 100644 --- a/lib/publicgroupnav.php +++ b/lib/publicgroupnav.php @@ -77,12 +77,6 @@ class PublicGroupNav extends Menu // TRANS: Menu item title in search group navigation panel. _('Recent tags'), $this->actionName == 'publictagcloud', 'nav_recent-tags'); - // TRANS: Menu item in search group navigation panel. - $this->out->menuItem(common_local_url('publicpeopletagcloud'), _m('MENU','People tags'), - // TRANS: Menu item title in search group navigation panel. - _('People tags'), in_array($this->actionName, array('publicpeopletagcloud', - 'peopletag', 'selftag')), 'nav_people-tags'); - if (count(common_config('nickname', 'featured')) > 0) { // TRANS: Menu item in search group navigation panel. $this->out->menuItem(common_local_url('featured'), _m('MENU','Featured'), diff --git a/lib/subgroupnav.php b/lib/subgroupnav.php index 6ff3b4609c..49bd357f29 100644 --- a/lib/subgroupnav.php +++ b/lib/subgroupnav.php @@ -128,16 +128,16 @@ class SubGroupNav extends Menu $this->user->nickname), $action == 'usergroups', 'nav_usergroups'); - $this->out->menuItem(common_local_url('peopletagsbyuser', + $this->out->menuItem(common_local_url('peopletagsubscriptions', array('nickname' => $this->user->nickname)), // TRANS: Menu item title in local navigation menu. - _m('MENU','People tags'), + _m('MENU','Lists'), // TRANS: Menu item title in local navigation menu. // TRANS: %s is a user nickname. - sprintf(_('People tags by %s.'), + sprintf(_('List subscriptions by %s.'), $this->user->nickname), - in_array($action, array('peopletagsbyuser', 'peopletagsforuser')), + in_array($action, array('peopletagsbyuser', 'peopletagsubscriptions', 'peopletagsforuser')), 'nav_timeline_peopletags'); if (common_config('invite', 'enabled') && !is_null($cur) && $this->user->id === $cur->id) { diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index a74ce6201b..b0b67569c6 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -855,7 +855,7 @@ class OStatusPlugin extends Plugin if ($oprofile) { if (!$oprofile->subscribe()) { // TRANS: Exception thrown when setup of remote people tag subscription fails. - throw new Exception(_m('Could not set up remote people tag subscription.')); + throw new Exception(_m('Could not set up remote list subscription.')); } $sub = $user->getProfile(); @@ -876,7 +876,7 @@ class OStatusPlugin extends Plugin $act->title = _m('TITLE','Follow list'); // TRANS: Success message for remote list follow through OStatus. // TRANS: %1$s is the subscriber name, %2$s the prople tag, %3$s is the tagger's name. - $act->content = sprintf(_m("%1$s is now following people tagged %2$s by %3$s."), + $act->content = sprintf(_m("%1$s is now following people listed in %2$s by %3$s."), $sub->getBestName(), $oprofile->getBestName(), $tagger->getBestName()); @@ -1000,7 +1000,7 @@ class OStatusPlugin extends Plugin common_date_iso8601(time())); $act->time = time(); $act->title = _m('TITLE','Tag'); - $act->content = sprintf(_m('%1$s tagged %2$s in the list %3$s.'), + $act->content = sprintf(_m('%1$s listed %2$s in the list %3$s.'), $tagger->getBestName(), $tagged->getBestName(), $plist->getBestName()); diff --git a/plugins/OStatus/actions/ostatuspeopletag.php b/plugins/OStatus/actions/ostatuspeopletag.php index 6d6199b811..1a8495ce21 100644 --- a/plugins/OStatus/actions/ostatuspeopletag.php +++ b/plugins/OStatus/actions/ostatuspeopletag.php @@ -169,7 +169,7 @@ class OStatusPeopletagAction extends OStatusSubAction function getInstructions() { - return _m('You can subscribe to people tags from other supported sites. Paste the tag\'s profile URI below:'); + return _m('You can subscribe to lists from other supported sites. Paste the lists\'s URI below:'); } function selfLink() diff --git a/plugins/OStatus/actions/peopletagsalmon.php b/plugins/OStatus/actions/peopletagsalmon.php index 21025f511e..a200ca9eef 100644 --- a/plugins/OStatus/actions/peopletagsalmon.php +++ b/plugins/OStatus/actions/peopletagsalmon.php @@ -42,13 +42,13 @@ class PeopletagsalmonAction extends SalmonAction $this->peopletag = Profile_list::staticGet('id', $id); if (empty($this->peopletag)) { - $this->clientError(_m('No such people tag.')); + $this->clientError(_m('No such list.')); } $oprofile = Ostatus_profile::staticGet('peopletag_id', $id); if (!empty($oprofile)) { - $this->clientError(_m('Cannot accept remote posts for a remote people tag.')); + $this->clientError(_m('Cannot accept remote posts for a remote list.')); } return true; @@ -89,7 +89,7 @@ class PeopletagsalmonAction extends SalmonAction $this->clientError(_m('Cannot read profile to set up profile tag subscription.')); } if ($oprofile->isGroup()) { - $this->clientError(_m('Groups cannot subscribe to people tags.')); + $this->clientError(_m('Groups cannot subscribe to lists.')); } common_log(LOG_INFO, "Remote profile {$oprofile->uri} subscribing to local peopletag ".$this->peopletag->getBestName()); @@ -107,7 +107,7 @@ class PeopletagsalmonAction extends SalmonAction try { Profile_tag_subscription::add($this->peopletag, $profile); } catch (Exception $e) { - $this->serverError(sprintf(_m('Could not subscribe remote user %1$s to people tag %2$s.'), + $this->serverError(sprintf(_m('Could not subscribe remote user %1$s to list %2$s.'), $oprofile->uri, $this->peopletag->getBestName())); } } @@ -120,10 +120,10 @@ class PeopletagsalmonAction extends SalmonAction { $oprofile = $this->ensureProfile(); if (!$oprofile) { - $this->clientError(_m('Cannot read profile to cancel people tag membership.')); + $this->clientError(_m('Cannot read profile to cancel list membership.')); } if ($oprofile->isGroup()) { - $this->clientError(_m('Groups cannot subscribe to people tags.')); + $this->clientError(_m('Groups cannot subscribe to lists.')); } common_log(LOG_INFO, "Remote profile {$oprofile->uri} unsubscribing from local peopletag ".$this->peopletag->getBestName()); @@ -133,7 +133,7 @@ class PeopletagsalmonAction extends SalmonAction Profile_tag_subscription::remove($this->peopletag->tagger, $this->peopletag->tag, $profile->id); } catch (Exception $e) { - $this->serverError(sprintf(_m('Could not remove remote user %1$s from people tag %2$s.'), + $this->serverError(sprintf(_m('Could not remove remote user %1$s from list %2$s.'), $oprofile->uri, $this->peopletag->getBestName())); return; } From 82f90ad75649e4aa0943e2dcf90d2a7bdc7f52c4 Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Thu, 14 Apr 2011 00:38:21 +0530 Subject: [PATCH 3/4] Profile_list::blowNoticeStreamCache --- classes/Profile_list.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/classes/Profile_list.php b/classes/Profile_list.php index cf0a255e75..7de1d15730 100644 --- a/classes/Profile_list.php +++ b/classes/Profile_list.php @@ -470,6 +470,23 @@ class Profile_list extends Memcached_DataObject return $count; } + /** + * get the cached number of profiles subscribed to this + * people tag, re-count if the argument is true. + * + * @param boolean $recount whether to ignore cache + * + * @return integer count + */ + + function blowNoticeStreamCache($all=false) + { + self::blow('profile_list:notice_ids:%d', $this->id); + if ($all) { + self::blow('profile_list:notice_ids:%d;last', $this->id); + } + } + /** * get the Profile_list object by the * given tagger and with given tag From 45952ff164b0f3105a37ddb26e29c112041e6cee Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Thu, 14 Apr 2011 23:35:04 +0530 Subject: [PATCH 4/4] "Lists with you" and "List subscriptions" in the right aside, "Lists" in the left aside --- lib/action.php | 9 ++- lib/defaultlocalnav.php | 8 +++ lib/listsnav.php | 90 +++++++++++++++++++++++++++ lib/peopletagsubscriptionssection.php | 13 ++-- lib/profileaction.php | 20 ++++-- 5 files changed, 127 insertions(+), 13 deletions(-) create mode 100644 lib/listsnav.php diff --git a/lib/action.php b/lib/action.php index f626c04480..0234d2fa23 100644 --- a/lib/action.php +++ b/lib/action.php @@ -1354,13 +1354,16 @@ class Action extends HTMLOutputter // lawsuit * * @return nothing */ - function menuItem($url, $text, $title=null, $is_selected=false, $id=null) + function menuItem($url, $text, $title=null, $is_selected=false, $id=null, $class=null) { // Added @id to li for some control. // XXX: We might want to move this to htmloutputter.php $lattrs = array(); - if ($is_selected) { - $lattrs['class'] = 'current'; + if ($class !== null) { + $lattrs['class'] = $class; + if ($is_selected) { + $lattrs['class'] = trim('current ' . $lattrs['class']); + } } (is_null($id)) ? $lattrs : $lattrs['id'] = $id; diff --git a/lib/defaultlocalnav.php b/lib/defaultlocalnav.php index 84a6267ac9..ffef87480c 100644 --- a/lib/defaultlocalnav.php +++ b/lib/defaultlocalnav.php @@ -72,6 +72,14 @@ class DefaultLocalNav extends Menu } } + if (!empty($user)) { + $sn = new ListsNav($this->action, $user->getProfile()); + if ($sn->hasLists()) { + // TRANS: Menu item in default local navigation panel. + $this->submenu(_m('MENU', 'Lists'), $sn); + } + } + Event::handle('EndDefaultLocalNav', array($this, $user)); } diff --git a/lib/listsnav.php b/lib/listsnav.php new file mode 100644 index 0000000000..67d8941ba3 --- /dev/null +++ b/lib/listsnav.php @@ -0,0 +1,90 @@ +. + * + * @category Widget + * @package StatusNet + * @author Shashi Gowda + * @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); +} + +/** + * Peopletags a user has subscribed to + * + * @category Widget + * @package StatusNet + * @author Shashi Gowda + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ +class ListsNav extends Menu +{ + var $profile=null; + var $lists=null; + + function __construct($out, Profile $profile) + { + parent::__construct($out); + $this->profile = $profile; + + $user = common_current_user(); + + $this->lists = $profile->getOwnedTags($user); + } + + function show() + { + $action = $this->actionName; + + $this->out->elementStart('ul', array('class' => 'nav')); + + if (Event::handle('StartListsNav', array($this))) { + + while ($this->lists->fetch()) { + $mode = $this->lists->private ? 'private' : 'public'; + $this->out->menuItem(($this->lists->mainpage) ? + $this->lists->mainpage : + common_local_url('showprofiletag', + array('tagger' => $this->profile->nickname, + 'tag' => $this->lists->tag)), + $this->lists->tag, + '', + $action == 'showprofiletag' && + $this->action->arg('tagger') == $this->profile->nickname && + $this->action->arg('tag') == $this->lists->tag, + 'nav_timeline_list_'.$this->lists->id, + 'mode-' . $mode); + } + Event::handle('EndListsNav', array($this)); + } + + $this->out->elementEnd('ul'); + } + + function hasLists() + { + return (!empty($this->lists) && $this->lists->N > 0); + } +} diff --git a/lib/peopletagsubscriptionssection.php b/lib/peopletagsubscriptionssection.php index 616af28d4c..ab90f7eb75 100644 --- a/lib/peopletagsubscriptionssection.php +++ b/lib/peopletagsubscriptionssection.php @@ -42,21 +42,22 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { class PeopletagSubscriptionsSection extends PeopletagSection { var $profile=null; + var $ptags=null; function __construct($out, Profile $profile) { parent::__construct($out); $this->profile = $profile; + + $limit = PEOPLETAGS_PER_SECTION+1; + $offset = 0; + + $this->ptags = $this->profile->getTagSubscriptions($offset, $limit); } function getPeopletags() { - $limit = PEOPLETAGS_PER_SECTION+1; - $offset = 0; - - $ptags = $this->profile->getTagSubscriptions($offset, $limit); - - return $ptags; + return $this->ptags; } function title() diff --git a/lib/profileaction.php b/lib/profileaction.php index 16592783c9..ca008739de 100644 --- a/lib/profileaction.php +++ b/lib/profileaction.php @@ -97,7 +97,8 @@ class ProfileAction extends OwnerDesignAction $this->showSubscriptions(); $this->showSubscribers(); $this->showGroups(); - $this->showPeopletags(); + $this->showListsFor(); + $this->showListSubscriptions(); $this->showStatistics(); } @@ -189,14 +190,25 @@ class ProfileAction extends OwnerDesignAction $this->elementEnd('div'); } - function showPeopletags() + function showListsFor() { - if (Event::handle('StartShowPeopletagsSection', array($this))) { + if (Event::handle('StartShowListsForSection', array($this))) { $section = new PeopletagsForUserSection($this, $this->profile); $section->show(); - Event::handle('EndShowPeopletagsSection', array($this)); + Event::handle('EndShowListsForSection', array($this)); + } + } + + function showListSubscriptions() + { + if (Event::handle('StartShowListSubscriptionsSection', array($this))) { + + $section = new PeopletagSubscriptionsSection($this, $this->profile); + $section->show(); + + Event::handle('EndShowListSubscriptionsSection', array($this)); } }