From 6e2f04583728714ff937eb1fa3ab34e99bcdb6a6 Mon Sep 17 00:00:00 2001 From: Meitar Moscovitz Date: Mon, 9 Feb 2009 00:02:51 +1100 Subject: [PATCH 1/7] Add machine-readable pagination using HTML4.01 ``, etc. These extra `` elements only appear on pages where pagination makes sense. They trigger functionality in some user agents, such as Opera's Navigation Bar for more easily navigating forward and backwards across a paged set of notices, messages, or group lists, etc. --- actions/all.php | 22 ++++++++++++++++++++++ actions/favorited.php | 20 ++++++++++++++++++++ actions/groupmembers.php | 24 +++++++++++++++++++++++- actions/groups.php | 20 ++++++++++++++++++++ actions/inbox.php | 22 ++++++++++++++++++++++ actions/outbox.php | 22 ++++++++++++++++++++++ actions/public.php | 20 ++++++++++++++++++++ actions/replies.php | 22 ++++++++++++++++++++++ actions/showfavorites.php | 22 ++++++++++++++++++++++ actions/showgroup.php | 22 ++++++++++++++++++++++ actions/showstream.php | 22 ++++++++++++++++++++++ actions/tag.php | 22 ++++++++++++++++++++++ lib/action.php | 14 ++++++++++++++ 13 files changed, 273 insertions(+), 1 deletion(-) diff --git a/actions/all.php b/actions/all.php index d75d1b9461..76b1bbcdf8 100644 --- a/actions/all.php +++ b/actions/all.php @@ -78,6 +78,28 @@ class AllAction extends Action 'title' => sprintf(_('Feed for friends of %s'), $this->user->nickname))); } + /** + * Output document relationship links + * + * @return void + */ + function showRelationshipLinks() + { + // Machine-readable pagination + if ($this->page > 1) { + $this->element('link', array('rel' => 'next', + 'href' => common_local_url('all', + array('nickname' => $this->user->nickname, + 'page' => $this->page - 1)), + 'title' => _('Next Notices'))); + } + $this->element('link', array('rel' => 'prev', + 'href' => common_local_url('all', + array('nickname' => $this->user->nickname, + 'page' => $this->page + 1)), + 'title' => _('Previous Notices'))); + } + function showLocalNav() { $nav = new PersonalGroupNav($this); diff --git a/actions/favorited.php b/actions/favorited.php index fd5ff413cb..367fb6dd69 100644 --- a/actions/favorited.php +++ b/actions/favorited.php @@ -195,4 +195,24 @@ class FavoritedAction extends Action $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, $this->page, 'favorited'); } + + /** + * Output document relationship links + * + * @return void + */ + function showRelationshipLinks() + { + // Machine-readable pagination + if ($this->page > 1) { + $this->element('link', array('rel' => 'next', + 'href' => common_local_url('favorited', + array('page' => $this->page - 1)), + 'title' => _('Next Notices'))); + } + $this->element('link', array('rel' => 'prev', + 'href' => common_local_url('favorited', + array('page' => $this->page + 1)), + 'title' => _('Previous Notices'))); + } } diff --git a/actions/groupmembers.php b/actions/groupmembers.php index 00f43a9f55..2b2bdba93d 100644 --- a/actions/groupmembers.php +++ b/actions/groupmembers.php @@ -137,4 +137,26 @@ class GroupmembersAction extends Action $this->page, 'groupmembers', array('nickname' => $this->group->nickname)); } -} \ No newline at end of file + + /** + * Output document relationship links + * + * @return void + */ + function showRelationshipLinks() + { + // Machine-readable pagination + if ($this->page > 1) { + $this->element('link', array('rel' => 'next', + 'href' => common_local_url('groupmembers', + array('nickname' => $this->group->nickname, + 'page' => $this->page - 1)), + 'title' => _('Next Group Members'))); + } + $this->element('link', array('rel' => 'prev', + 'href' => common_local_url('groupmembers', + array('nickname' => $this->group->nickname, + 'page' => $this->page + 1)), + 'title' => _('Previous Group Members'))); + } +} diff --git a/actions/groups.php b/actions/groups.php index 39dc2232bc..b0bf7cfc2a 100644 --- a/actions/groups.php +++ b/actions/groups.php @@ -129,4 +129,24 @@ class GroupsAction extends Action $gbm = new GroupsByMembersSection($this); $gbm->show(); } + + /** + * Output document relationship links + * + * @return void + */ + function showRelationshipLinks() + { + // Machine-readable pagination + if ($this->page > 1) { + $this->element('link', array('rel' => 'next', + 'href' => common_local_url('groups', + array('page' => $this->page - 1)), + 'title' => _('Next Groups'))); + } + $this->element('link', array('rel' => 'prev', + 'href' => common_local_url('groups', + array('page' => $this->page + 1)), + 'title' => _('Previous Groups'))); + } } diff --git a/actions/inbox.php b/actions/inbox.php index b553ab26ca..d12f3f20ae 100644 --- a/actions/inbox.php +++ b/actions/inbox.php @@ -63,6 +63,28 @@ class InboxAction extends MailboxAction } } + /** + * Output document relationship links + * + * @return void + */ + function showRelationshipLinks() + { + // Machine-readable pagination + if ($this->page > 1) { + $this->element('link', array('rel' => 'next', + 'href' => common_local_url('inbox', + array('nickname' => $this->user->nickname, + 'page' => $this->page - 1)), + 'title' => _('Next Messages'))); + } + $this->element('link', array('rel' => 'prev', + 'href' => common_local_url('inbox', + array('nickname' => $this->user->nickname, + 'page' => $this->page + 1)), + 'title' => _('Previous Messages'))); + } + /** * Retrieve the messages for this user and this page * diff --git a/actions/outbox.php b/actions/outbox.php index c8d7f28125..043b74edc4 100644 --- a/actions/outbox.php +++ b/actions/outbox.php @@ -62,6 +62,28 @@ class OutboxAction extends MailboxAction } } + /** + * Output document relationship links + * + * @return void + */ + function showRelationshipLinks() + { + // Machine-readable pagination + if ($this->page > 1) { + $this->element('link', array('rel' => 'next', + 'href' => common_local_url('outbox', + array('nickname' => $this->user->nickname, + 'page' => $this->page - 1)), + 'title' => _('Next Messages'))); + } + $this->element('link', array('rel' => 'prev', + 'href' => common_local_url('outbox', + array('nickname' => $this->user->nickname, + 'page' => $this->page + 1)), + 'title' => _('Previous Messages'))); + } + /** * retrieve the messages for this user and this page * diff --git a/actions/public.php b/actions/public.php index cc6537f74f..25889eee5a 100644 --- a/actions/public.php +++ b/actions/public.php @@ -127,6 +127,26 @@ class PublicAction extends Action 'title' => _('Public Stream Feed'))); } + /** + * Output document relationship links + * + * @return void + */ + function showRelationshipLinks() + { + // Machine-readable pagination + if ($this->page > 1) { + $this->element('link', array('rel' => 'next', + 'href' => common_local_url('public', + array('page' => $this->page - 1)), + 'title' => _('Next Notices'))); + } + $this->element('link', array('rel' => 'prev', + 'href' => common_local_url('public', + array('page' => $this->page + 1)), + 'title' => _('Previous Notices'))); + } + /** * Extra head elements * diff --git a/actions/replies.php b/actions/replies.php index 7eff74a669..5ae99e1652 100644 --- a/actions/replies.php +++ b/actions/replies.php @@ -141,6 +141,28 @@ class RepliesAction extends Action 'title' => $rsstitle)); } + /** + * Output document relationship links + * + * @return void + */ + function showRelationshipLinks() + { + // Machine-readable pagination + if ($this->page > 1) { + $this->element('link', array('rel' => 'next', + 'href' => common_local_url('replies', + array('nickname' => $this->user->nickname, + 'page' => $this->page - 1)), + 'title' => _('Next Notices'))); + } + $this->element('link', array('rel' => 'prev', + 'href' => common_local_url('replies', + array('nickname' => $this->user->nickname, + 'page' => $this->page + 1)), + 'title' => _('Previous Notices'))); + } + /** * show the personal group nav * diff --git a/actions/showfavorites.php b/actions/showfavorites.php index 31479e1a78..f0297172a6 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -153,6 +153,28 @@ class ShowfavoritesAction extends Action 'title' => $feedtitle)); } + /** + * Output document relationship links + * + * @return void + */ + function showRelationshipLinks() + { + // Machine-readable pagination + if ($this->page > 1) { + $this->element('link', array('rel' => 'next', + 'href' => common_local_url('showfavorites', + array('nickname' => $this->user->nickname, + 'page' => $this->page - 1)), + 'title' => _('Next Favorite Notices'))); + } + $this->element('link', array('rel' => 'prev', + 'href' => common_local_url('showfavorites', + array('nickname' => $this->user->nickname, + 'page' => $this->page + 1)), + 'title' => _('Previous Favorite Notices'))); + } + /** * show the personal group nav * diff --git a/actions/showgroup.php b/actions/showgroup.php index 7bc68fbc64..7599a8de6e 100644 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@ -326,6 +326,28 @@ class ShowgroupAction extends Action $this->group->nickname))); } + /** + * Output document relationship links + * + * @return void + */ + function showRelationshipLinks() + { + // Machine-readable pagination + if ($this->page > 1) { + $this->element('link', array('rel' => 'next', + 'href' => common_local_url('showgroup', + array('nickname' => $this->group->nickname, + 'page' => $this->page - 1)), + 'title' => _('Next Notices'))); + } + $this->element('link', array('rel' => 'prev', + 'href' => common_local_url('showgroup', + array('nickname' => $this->group->nickname, + 'page' => $this->page + 1)), + 'title' => _('Previous Notices'))); + } + /** * Fill in the sidebar. * diff --git a/actions/showstream.php b/actions/showstream.php index 28bb8453f8..11615ebb0d 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -195,6 +195,28 @@ class ShowstreamAction extends Action $this->user->nickname))); } + /** + * Output document relationship links + * + * @return void + */ + function showRelationshipLinks() + { + // Machine-readable pagination + if ($this->page > 1) { + $this->element('link', array('rel' => 'next', + 'href' => common_local_url('showstream', + array('nickname' => $this->user->nickname, + 'page' => $this->page - 1)), + 'title' => _('Next Notices'))); + } + $this->element('link', array('rel' => 'prev', + 'href' => common_local_url('showstream', + array('nickname' => $this->user->nickname, + 'page' => $this->page + 1)), + 'title' => _('Previous Notices'))); + } + function extraHead() { // FOAF diff --git a/actions/tag.php b/actions/tag.php index 4401f892a9..f71f6d342f 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -69,6 +69,28 @@ class TagAction extends Action 'title' => sprintf(_('Feed for tag %s'), $this->tag))); } + /** + * Output document relationship links + * + * @return void + */ + function showRelationshipLinks() + { + // Machine-readable pagination + if ($this->page > 1) { + $this->element('link', array('rel' => 'next', + 'href' => common_local_url('tag', + array('tag' => $this->tag, + 'page' => $this->page - 1)), + 'title' => _('Next Notices'))); + } + $this->element('link', array('rel' => 'prev', + 'href' => common_local_url('tag', + array('tag' => $this->tag, + 'page' => $this->page + 1)), + 'title' => _('Previous Notices'))); + } + function showPageNotice() { return sprintf(_('Messages tagged "%s", most recent first'), $this->tag); diff --git a/lib/action.php b/lib/action.php index c4172ada11..ab51d0252c 100644 --- a/lib/action.php +++ b/lib/action.php @@ -111,6 +111,7 @@ class Action extends HTMLOutputter // lawsuit $this->showTitle(); $this->showStylesheets(); $this->showScripts(); + $this->showRelationshipLinks(); $this->showOpenSearch(); $this->showFeeds(); $this->showDescription(); @@ -193,6 +194,19 @@ class Action extends HTMLOutputter // lawsuit ' '); } + /** + * Show document relationship links + * + * SHOULD overload + * + * @return nothing + */ + function showRelationshipLinks() + { + // output elements with appropriate HTML4.01 link types: + // http://www.w3.org/TR/html401/types.html#type-links + } + /** * Show OpenSearch headers * From b240a1719485b15c4a6497b6053c24e8a40a4e3c Mon Sep 17 00:00:00 2001 From: Meitar Moscovitz Date: Tue, 10 Feb 2009 19:42:01 +1100 Subject: [PATCH 2/7] Beginning to refactor document relationship links to reduce common code. My attempts here are to mimic the `pagination()` method shared by actions. I'm tentatively adding the `$count` property to actions so that we can query the number of notices ''being displayed'' per page prior to calling the actual `pagination()` method itself, since document relationship `` elements need to be output inside of `showHead()`, before `showContent()`, which is where `pagination()` is, gets called. --- actions/all.php | 15 ++------------- actions/favorited.php | 13 ++----------- actions/groupmembers.php | 15 ++------------- actions/groups.php | 13 ++----------- actions/inbox.php | 15 ++------------- actions/outbox.php | 15 ++------------- actions/public.php | 25 ++++++++++++++----------- actions/replies.php | 15 ++------------- actions/showfavorites.php | 16 +++------------- actions/showgroup.php | 15 ++------------- actions/showstream.php | 15 ++------------- actions/tag.php | 15 ++------------- lib/action.php | 34 ++++++++++++++++++++++++++++++++++ 13 files changed, 71 insertions(+), 150 deletions(-) diff --git a/actions/all.php b/actions/all.php index 76b1bbcdf8..4a625207a4 100644 --- a/actions/all.php +++ b/actions/all.php @@ -85,19 +85,8 @@ class AllAction extends Action */ function showRelationshipLinks() { - // Machine-readable pagination - if ($this->page > 1) { - $this->element('link', array('rel' => 'next', - 'href' => common_local_url('all', - array('nickname' => $this->user->nickname, - 'page' => $this->page - 1)), - 'title' => _('Next Notices'))); - } - $this->element('link', array('rel' => 'prev', - 'href' => common_local_url('all', - array('nickname' => $this->user->nickname, - 'page' => $this->page + 1)), - 'title' => _('Previous Notices'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'all', array('nickname' => $this->user->nickname)); } function showLocalNav() diff --git a/actions/favorited.php b/actions/favorited.php index 367fb6dd69..74920ca7e4 100644 --- a/actions/favorited.php +++ b/actions/favorited.php @@ -203,16 +203,7 @@ class FavoritedAction extends Action */ function showRelationshipLinks() { - // Machine-readable pagination - if ($this->page > 1) { - $this->element('link', array('rel' => 'next', - 'href' => common_local_url('favorited', - array('page' => $this->page - 1)), - 'title' => _('Next Notices'))); - } - $this->element('link', array('rel' => 'prev', - 'href' => common_local_url('favorited', - array('page' => $this->page + 1)), - 'title' => _('Previous Notices'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'favorited'); } } diff --git a/actions/groupmembers.php b/actions/groupmembers.php index 2b2bdba93d..b80f3d90d1 100644 --- a/actions/groupmembers.php +++ b/actions/groupmembers.php @@ -145,18 +145,7 @@ class GroupmembersAction extends Action */ function showRelationshipLinks() { - // Machine-readable pagination - if ($this->page > 1) { - $this->element('link', array('rel' => 'next', - 'href' => common_local_url('groupmembers', - array('nickname' => $this->group->nickname, - 'page' => $this->page - 1)), - 'title' => _('Next Group Members'))); - } - $this->element('link', array('rel' => 'prev', - 'href' => common_local_url('groupmembers', - array('nickname' => $this->group->nickname, - 'page' => $this->page + 1)), - 'title' => _('Previous Group Members'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'groupmembers', array('nickname' => $this->group->nickname)); } } diff --git a/actions/groups.php b/actions/groups.php index b0bf7cfc2a..e158698de2 100644 --- a/actions/groups.php +++ b/actions/groups.php @@ -137,16 +137,7 @@ class GroupsAction extends Action */ function showRelationshipLinks() { - // Machine-readable pagination - if ($this->page > 1) { - $this->element('link', array('rel' => 'next', - 'href' => common_local_url('groups', - array('page' => $this->page - 1)), - 'title' => _('Next Groups'))); - } - $this->element('link', array('rel' => 'prev', - 'href' => common_local_url('groups', - array('page' => $this->page + 1)), - 'title' => _('Previous Groups'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'groups', array('nickname' => $this->group->nickname)); } } diff --git a/actions/inbox.php b/actions/inbox.php index d12f3f20ae..7b5cf2d203 100644 --- a/actions/inbox.php +++ b/actions/inbox.php @@ -70,19 +70,8 @@ class InboxAction extends MailboxAction */ function showRelationshipLinks() { - // Machine-readable pagination - if ($this->page > 1) { - $this->element('link', array('rel' => 'next', - 'href' => common_local_url('inbox', - array('nickname' => $this->user->nickname, - 'page' => $this->page - 1)), - 'title' => _('Next Messages'))); - } - $this->element('link', array('rel' => 'prev', - 'href' => common_local_url('inbox', - array('nickname' => $this->user->nickname, - 'page' => $this->page + 1)), - 'title' => _('Previous Messages'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'inbox', array('nickname' => $this->user->nickname)); } /** diff --git a/actions/outbox.php b/actions/outbox.php index 043b74edc4..deef1cc870 100644 --- a/actions/outbox.php +++ b/actions/outbox.php @@ -69,19 +69,8 @@ class OutboxAction extends MailboxAction */ function showRelationshipLinks() { - // Machine-readable pagination - if ($this->page > 1) { - $this->element('link', array('rel' => 'next', - 'href' => common_local_url('outbox', - array('nickname' => $this->user->nickname, - 'page' => $this->page - 1)), - 'title' => _('Next Messages'))); - } - $this->element('link', array('rel' => 'prev', - 'href' => common_local_url('outbox', - array('nickname' => $this->user->nickname, - 'page' => $this->page + 1)), - 'title' => _('Previous Messages'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'outbox', array('nickname' => $this->user->nickname)); } /** diff --git a/actions/public.php b/actions/public.php index 25889eee5a..eb2a4b1b00 100644 --- a/actions/public.php +++ b/actions/public.php @@ -56,6 +56,18 @@ class PublicAction extends Action var $page = null; + /** + * Number of notices being shown on this page. + */ + // Does this need to be here? Should it be? + // If it does, this property needs to be + // added to other actions as well, like $page. + // I'm trying to find a way to capture the + // output of the $cnt variable from this + // action's showContent() method but need + // to do so earlier, I think...? + var $count = null; + function isReadOnly() { return true; @@ -134,17 +146,8 @@ class PublicAction extends Action */ function showRelationshipLinks() { - // Machine-readable pagination - if ($this->page > 1) { - $this->element('link', array('rel' => 'next', - 'href' => common_local_url('public', - array('page' => $this->page - 1)), - 'title' => _('Next Notices'))); - } - $this->element('link', array('rel' => 'prev', - 'href' => common_local_url('public', - array('page' => $this->page + 1)), - 'title' => _('Previous Notices'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'public'); } /** diff --git a/actions/replies.php b/actions/replies.php index 5ae99e1652..7c24b554e0 100644 --- a/actions/replies.php +++ b/actions/replies.php @@ -148,19 +148,8 @@ class RepliesAction extends Action */ function showRelationshipLinks() { - // Machine-readable pagination - if ($this->page > 1) { - $this->element('link', array('rel' => 'next', - 'href' => common_local_url('replies', - array('nickname' => $this->user->nickname, - 'page' => $this->page - 1)), - 'title' => _('Next Notices'))); - } - $this->element('link', array('rel' => 'prev', - 'href' => common_local_url('replies', - array('nickname' => $this->user->nickname, - 'page' => $this->page + 1)), - 'title' => _('Previous Notices'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'replies', array('nickname' => $this->user->nickname)); } /** diff --git a/actions/showfavorites.php b/actions/showfavorites.php index f0297172a6..585b3b75ab 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -160,21 +160,11 @@ class ShowfavoritesAction extends Action */ function showRelationshipLinks() { - // Machine-readable pagination - if ($this->page > 1) { - $this->element('link', array('rel' => 'next', - 'href' => common_local_url('showfavorites', - array('nickname' => $this->user->nickname, - 'page' => $this->page - 1)), - 'title' => _('Next Favorite Notices'))); - } - $this->element('link', array('rel' => 'prev', - 'href' => common_local_url('showfavorites', - array('nickname' => $this->user->nickname, - 'page' => $this->page + 1)), - 'title' => _('Previous Favorite Notices'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'showfavorites', array('nickname' => $this->user->nickname)); } + /** * show the personal group nav * diff --git a/actions/showgroup.php b/actions/showgroup.php index 7599a8de6e..a2b40f9948 100644 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@ -333,19 +333,8 @@ class ShowgroupAction extends Action */ function showRelationshipLinks() { - // Machine-readable pagination - if ($this->page > 1) { - $this->element('link', array('rel' => 'next', - 'href' => common_local_url('showgroup', - array('nickname' => $this->group->nickname, - 'page' => $this->page - 1)), - 'title' => _('Next Notices'))); - } - $this->element('link', array('rel' => 'prev', - 'href' => common_local_url('showgroup', - array('nickname' => $this->group->nickname, - 'page' => $this->page + 1)), - 'title' => _('Previous Notices'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'showgroup', array('nickname' => $this->group->nickname)); } /** diff --git a/actions/showstream.php b/actions/showstream.php index 0c8fea1821..1779c70f2c 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -202,19 +202,8 @@ class ShowstreamAction extends Action */ function showRelationshipLinks() { - // Machine-readable pagination - if ($this->page > 1) { - $this->element('link', array('rel' => 'next', - 'href' => common_local_url('showstream', - array('nickname' => $this->user->nickname, - 'page' => $this->page - 1)), - 'title' => _('Next Notices'))); - } - $this->element('link', array('rel' => 'prev', - 'href' => common_local_url('showstream', - array('nickname' => $this->user->nickname, - 'page' => $this->page + 1)), - 'title' => _('Previous Notices'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'showstream', array('nickname' => $this->user->nickname)); } function extraHead() diff --git a/actions/tag.php b/actions/tag.php index f71f6d342f..2a564a25d4 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -76,19 +76,8 @@ class TagAction extends Action */ function showRelationshipLinks() { - // Machine-readable pagination - if ($this->page > 1) { - $this->element('link', array('rel' => 'next', - 'href' => common_local_url('tag', - array('tag' => $this->tag, - 'page' => $this->page - 1)), - 'title' => _('Next Notices'))); - } - $this->element('link', array('rel' => 'prev', - 'href' => common_local_url('tag', - array('tag' => $this->tag, - 'page' => $this->page + 1)), - 'title' => _('Previous Notices'))); + $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME + $this->page, 'tag', array('tag' => $this->tag)); } function showPageNotice() diff --git a/lib/action.php b/lib/action.php index 8d0fea7afd..80a8969fa2 100644 --- a/lib/action.php +++ b/lib/action.php @@ -938,4 +938,38 @@ class Action extends HTMLOutputter // lawsuit $this->elementEnd('div'); } } + + /** + * Generate document metadata for sequential navigation + * + * @param boolean $have_before is there something before? + * @param boolean $have_after is there something after? + * @param integer $page current page + * @param string $action current action + * @param array $args rest of query arguments + * + * @return nothing + */ + function sequenceRelationships($have_next, $have_previous, $page, $action, $args=null) + { + // Outputs machine-readable pagination in elements. + // Pattern taken from $this->pagination() method. + + // "next" is equivalent to "after" + if ($have_next) { + $pargs = array('page' => $page-1); + $newargs = $args ? array_merge($args, $pargs) : $pargs; + $this->element('link', array('rel' => 'next', + 'href' => common_local_url($action, $newargs), + 'title' => _('Next'))); + } + // "previous" is equivalent to "before" + if ($have_previous=true) { // FIXME + $pargs = array('page' => $page+1); + $newargs = $args ? array_merge($args, $pargs) : $pargs; + $this->element('link', array('rel' => 'prev', + 'href' => common_local_url($action, $newargs), + 'title' => _('Previous'))); + } + } } From 1ba3ac9ee3f00472e0b7f8f25955967ab816a3fd Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 8 Mar 2009 08:45:32 +0100 Subject: [PATCH 3/7] Make OMB work if the configured domain name does not exclusively contain lower case letters. If the configured domain is mixed-case OAuth throws invalidsignature errors. The current URL is part of the signated parts; since the consumer does not pass the current URL, the service has to get it itself and add it to the other OAuth params for signature rebuilding. OAuth.php uses $_SERVER for this, however, the domain is lcased in $_SERVER. Hence we pass the complete current URL as generated by common_local_url to OAuthRequest. --- actions/accesstoken.php | 2 +- actions/finishremotesubscribe.php | 2 +- actions/postnotice.php | 2 +- actions/requesttoken.php | 2 +- actions/updateprofile.php | 2 +- actions/userauthorization.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/actions/accesstoken.php b/actions/accesstoken.php index 77fdf6aefa..bb68d3314d 100644 --- a/actions/accesstoken.php +++ b/actions/accesstoken.php @@ -59,7 +59,7 @@ class AccesstokenAction extends Action try { common_debug('getting request from env variables', __FILE__); common_remove_magic_from_request(); - $req = OAuthRequest::from_request(); + $req = OAuthRequest::from_request('POST', common_locale_url('accesstoken')); common_debug('getting a server', __FILE__); $server = omb_oauth_server(); common_debug('fetching the access token', __FILE__); diff --git a/actions/finishremotesubscribe.php b/actions/finishremotesubscribe.php index eaf57c2d8f..6d73ee2348 100644 --- a/actions/finishremotesubscribe.php +++ b/actions/finishremotesubscribe.php @@ -44,7 +44,7 @@ class FinishremotesubscribeAction extends Action common_debug('stored request: '.print_r($omb,true), __FILE__); common_remove_magic_from_request(); - $req = OAuthRequest::from_request(); + $req = OAuthRequest::from_request('POST', common_local_url('finishuserauthorization')); $token = $req->get_parameter('oauth_token'); diff --git a/actions/postnotice.php b/actions/postnotice.php index c32d8ca94b..3e98b3cd55 100644 --- a/actions/postnotice.php +++ b/actions/postnotice.php @@ -28,7 +28,7 @@ class PostnoticeAction extends Action parent::handle($args); try { common_remove_magic_from_request(); - $req = OAuthRequest::from_request(); + $req = OAuthRequest::from_request('POST', common_local_url('postnotice')); # Note: server-to-server function! $server = omb_oauth_server(); list($consumer, $token) = $server->verify_request($req); diff --git a/actions/requesttoken.php b/actions/requesttoken.php index ca253b97aa..4e6f92913a 100644 --- a/actions/requesttoken.php +++ b/actions/requesttoken.php @@ -69,7 +69,7 @@ class RequesttokenAction extends Action parent::handle($args); try { common_remove_magic_from_request(); - $req = OAuthRequest::from_request(); + $req = OAuthRequest::from_request('POST', common_local_url('requesttoken')); $server = omb_oauth_server(); $token = $server->fetch_request_token($req); print $token; diff --git a/actions/updateprofile.php b/actions/updateprofile.php index 7dc52fda9e..08cb31ae03 100644 --- a/actions/updateprofile.php +++ b/actions/updateprofile.php @@ -29,7 +29,7 @@ class UpdateprofileAction extends Action parent::handle($args); try { common_remove_magic_from_request(); - $req = OAuthRequest::from_request(); + $req = OAuthRequest::from_request('POST', common_local_url('updateprofile')); # Note: server-to-server function! $server = omb_oauth_server(); list($consumer, $token) = $server->verify_request($req); diff --git a/actions/userauthorization.php b/actions/userauthorization.php index 6a76e3a4c2..9eb1e8836f 100644 --- a/actions/userauthorization.php +++ b/actions/userauthorization.php @@ -382,7 +382,7 @@ class UserauthorizationAction extends Action function getNewRequest() { common_remove_magic_from_request(); - $req = OAuthRequest::from_request(); + $req = OAuthRequest::from_request('GET', common_local_url('userauthorization')); return $req; } From 20394664957a202cc86cc48ee2d115032e82c58a Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Tue, 14 Apr 2009 23:03:19 +0000 Subject: [PATCH 4/7] trac#1223 Show most popular notices per tag in the tag page sidebar. --- actions/tag.php | 7 +++++++ lib/popularnoticesection.php | 25 +++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/actions/tag.php b/actions/tag.php index d15f64498d..cb6572b962 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -45,6 +45,13 @@ class TagAction extends Action return true; } + function showSections() + { + $pop = new PopularNoticeSection($this); + $pop->show(); + } + + function title() { if ($this->page == 1) { diff --git a/lib/popularnoticesection.php b/lib/popularnoticesection.php index 0505f0fa9a..a8d47ef542 100644 --- a/lib/popularnoticesection.php +++ b/lib/popularnoticesection.php @@ -50,17 +50,26 @@ class PopularNoticeSection extends NoticeSection { if (common_config('db', 'type') == 'pgsql') { $weightexpr='sum(exp(-extract(epoch from (now() - fave.modified)) / %s))'; + if (!empty($this->out->tag)) { + $tag = pg_escape_string($this->tag); + } } else { $weightexpr='sum(exp(-(now() - fave.modified) / %s))'; + if (!empty($this->out->tag)) { + $tag = mysql_escape_string($this->out->tag); + } } - - $qry = 'SELECT notice.*, '. - $weightexpr . ' as weight ' . - 'FROM notice JOIN fave ON notice.id = fave.notice_id ' . - 'GROUP BY notice.id,notice.profile_id,notice.content,notice.uri,' . - 'notice.rendered,notice.url,notice.created,notice.modified,' . - 'notice.reply_to,notice.is_local,notice.source ' . - 'ORDER BY weight DESC'; + $qry = "SELECT notice.*, $weightexpr as weight "; + if(isset($tag)) { + $qry .= 'FROM notice_tag, notice JOIN fave ON notice.id = fave.notice_id ' . + "WHERE notice.id = notice_tag.notice_id and '$tag' = notice_tag.tag"; + } else { + $qry .= 'FROM notice JOIN fave ON notice.id = fave.notice_id'; + } + $qry .= ' GROUP BY notice.id,notice.profile_id,notice.content,notice.uri,' . + 'notice.rendered,notice.url,notice.created,notice.modified,' . + 'notice.reply_to,notice.is_local,notice.source ' . + 'ORDER BY weight DESC'; $offset = 0; $limit = NOTICES_PER_SECTION + 1; From e876b74e8ba7e80edcb9a13bff15deff4aa6ff15 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 15 Apr 2009 08:38:05 +0200 Subject: [PATCH 5/7] Add license notice to install.php, replace short and asp style tags by more portable long tag form. --- install.php | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/install.php b/install.php index 0240349bb1..87a99a6508 100644 --- a/install.php +++ b/install.php @@ -1,4 +1,22 @@ -. + */ + define('INSTALLDIR', dirname(__FILE__)); function main() @@ -19,12 +37,12 @@ function checkPrereqs() { if (file_exists(INSTALLDIR.'/config.php')) { ?>

Config file "config.php" already exists.

-

Require PHP version 5 or greater.

Require PHP version 5 or greater.

Cannot load required extension "".

Cannot load required extension "".

Cannot write config file to "".

+ ?>

Cannot write config file to "".

On your server, try this command:

-
chmod a+w
- chmod a+w +

Cannot write avatar directory "/avatar/".

+ ?>

Cannot write avatar directory "/avatar/".

On your server, try this command:

-
chmod a+w /avatar/
+
chmod a+w /avatar/

Install Laconica

- +
- \ No newline at end of file + From e8fc34e75c4c9684b8c7e03d471a905e08446618 Mon Sep 17 00:00:00 2001 From: Fil Date: Wed, 15 Apr 2009 10:35:15 +0200 Subject: [PATCH 6/7] Use preg_quote to fix http://laconi.ca/trac/ticket/1342 --- actions/noticesearch.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 095d0a454a..0828e47d77 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -184,11 +184,11 @@ class SearchNoticeListItem extends NoticeListItem { function highlight($text, $terms) { /* Highligh search terms */ - $pattern = '/('.implode('|', array_map('htmlspecialchars', $terms)).')/i'; + $pattern = '/('.implode('|', array_map('preg_quote', array_map('htmlspecialchars', $terms))).')/i'; $result = preg_replace($pattern, '\\1', $text); /* Remove highlighting from inside links, loop incase multiple highlights in links */ - $pattern = '/(href="[^"]*)('.implode('|', array_map('htmlspecialchars', $terms)).')<\/strong>([^"]*")/iU'; + $pattern = '/(href="[^"]*)('.implode('|', array_map('preg_quote', array_map('htmlspecialchars', $terms))).')<\/strong>([^"]*")/iU'; do { $result = preg_replace($pattern, '\\1\\2\\3', $result, -1, $count); } while ($count); From 8439477201cd59a6c0dba84ddf48eb86a6154199 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 15 Apr 2009 13:29:52 +0200 Subject: [PATCH 7/7] Add escaping of /. --- actions/noticesearch.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 0828e47d77..d996998fc6 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -184,11 +184,13 @@ class SearchNoticeListItem extends NoticeListItem { function highlight($text, $terms) { /* Highligh search terms */ - $pattern = '/('.implode('|', array_map('preg_quote', array_map('htmlspecialchars', $terms))).')/i'; + $options = implode('|', array_map('preg_quote', array_map('htmlspecialchars', $terms), + array_fill(0, sizeof($terms), '/'))); + $pattern = "/($options)/i"; $result = preg_replace($pattern, '\\1', $text); /* Remove highlighting from inside links, loop incase multiple highlights in links */ - $pattern = '/(href="[^"]*)('.implode('|', array_map('preg_quote', array_map('htmlspecialchars', $terms))).')<\/strong>([^"]*")/iU'; + $pattern = '/(href="[^"]*)('.$options.')<\/strong>([^"]*")/iU'; do { $result = preg_replace($pattern, '\\1\\2\\3', $result, -1, $count); } while ($count);