From 6e2f04583728714ff937eb1fa3ab34e99bcdb6a6 Mon Sep 17 00:00:00 2001 From: Meitar Moscovitz Date: Mon, 9 Feb 2009 00:02:51 +1100 Subject: 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 ++++++++++++++++++++++ 12 files changed, 259 insertions(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/all.php b/actions/all.php index d75d1b946..76b1bbcdf 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 fd5ff413c..367fb6dd6 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 00f43a9f5..2b2bdba93 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 39dc2232b..b0bf7cfc2 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 b553ab26c..d12f3f20a 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 c8d7f2812..043b74edc 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 cc6537f74..25889eee5 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 7eff74a66..5ae99e165 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 31479e1a7..f0297172a 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 7bc68fbc6..7599a8de6 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 28bb8453f..11615ebb0 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 4401f892a..f71f6d342 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); -- cgit v1.2.3-54-g00ecf From b240a1719485b15c4a6497b6053c24e8a40a4e3c Mon Sep 17 00:00:00 2001 From: Meitar Moscovitz Date: Tue, 10 Feb 2009 19:42:01 +1100 Subject: 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(-) (limited to 'actions') diff --git a/actions/all.php b/actions/all.php index 76b1bbcdf..4a625207a 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 367fb6dd6..74920ca7e 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 2b2bdba93..b80f3d90d 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 b0bf7cfc2..e158698de 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 d12f3f20a..7b5cf2d20 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 043b74edc..deef1cc87 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 25889eee5..eb2a4b1b0 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 5ae99e165..7c24b554e 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 f0297172a..585b3b75a 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 7599a8de6..a2b40f994 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 0c8fea182..1779c70f2 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 f71f6d342..2a564a25d 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 8d0fea7af..80a8969fa 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'))); + } + } } -- cgit v1.2.3-54-g00ecf From 1ba3ac9ee3f00472e0b7f8f25955967ab816a3fd Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 8 Mar 2009 08:45:32 +0100 Subject: 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(-) (limited to 'actions') diff --git a/actions/accesstoken.php b/actions/accesstoken.php index 77fdf6aef..bb68d3314 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 eaf57c2d8..6d73ee234 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 c32d8ca94..3e98b3cd5 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 ca253b97a..4e6f92913 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 7dc52fda9..08cb31ae0 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 6a76e3a4c..9eb1e8836 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; } -- cgit v1.2.3-54-g00ecf From e9e75fc9d5f44b2ffe10602a3bd183cccb7da4ec Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 13 Apr 2009 15:49:26 -0400 Subject: isReadOnly() now takes arguments Add an array of arguments to isReadOnly() method of actions, to let them change their results depending on what actions are called. Primarily used by the 'api' action. Ideally in the future that will be multiple actions. But this might still be useful. --- actions/all.php | 2 +- actions/api.php | 13 ++++++------- actions/avatarbynickname.php | 2 +- actions/doc.php | 2 +- actions/favorited.php | 2 +- actions/featured.php | 2 +- actions/foaf.php | 2 +- actions/groupbyid.php | 2 +- actions/groupmembers.php | 2 +- actions/grouprss.php | 2 +- actions/groups.php | 2 +- actions/invite.php | 2 +- actions/login.php | 2 +- actions/logout.php | 2 +- actions/microsummary.php | 2 +- actions/noticesearchrss.php | 2 +- actions/nudge.php | 2 +- actions/opensearch.php | 2 +- actions/public.php | 2 +- actions/publicrss.php | 2 +- actions/publictagcloud.php | 2 +- actions/publicxrds.php | 2 +- actions/replies.php | 2 +- actions/repliesrss.php | 2 +- actions/requesttoken.php | 2 +- actions/showfavorites.php | 2 +- actions/showgroup.php | 2 +- actions/showmessage.php | 2 +- actions/shownotice.php | 2 +- actions/showstream.php | 2 +- actions/subscribers.php | 2 +- actions/sup.php | 2 +- actions/tag.php | 2 +- actions/tagrss.php | 2 +- actions/twitapisearchjson.php | 2 +- actions/userbyid.php | 2 +- actions/usergroups.php | 2 +- actions/userrss.php | 2 +- actions/xrds.php | 2 +- index.php | 2 +- lib/action.php | 5 ++++- lib/error.php | 2 +- lib/galleryaction.php | 2 +- lib/peoplesearchresults.php | 2 +- lib/personal.php | 2 +- lib/searchaction.php | 2 +- 46 files changed, 54 insertions(+), 52 deletions(-) (limited to 'actions') diff --git a/actions/all.php b/actions/all.php index f5bbfe2e3..69890a70c 100644 --- a/actions/all.php +++ b/actions/all.php @@ -25,7 +25,7 @@ require_once INSTALLDIR.'/lib/feedlist.php'; class AllAction extends ProfileAction { - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/api.php b/actions/api.php index c18d551b6..e40a18798 100644 --- a/actions/api.php +++ b/actions/api.php @@ -134,8 +134,8 @@ class ApiAction extends Action 'favorites/favorites'); $fullname = "$this->api_action/$this->api_method"; - - // If the site is "private", all API methods except laconica/config + + // If the site is "private", all API methods except laconica/config // need authentication if (common_config('site', 'private')) { return $fullname != 'laconica/config' || false; @@ -180,11 +180,11 @@ class ApiAction extends Action } } - function isReadOnly() + function isReadOnly($args)($args) { - # NOTE: before handle(), can't use $this->arg - $apiaction = $_REQUEST['apiaction']; - $method = $_REQUEST['method']; + $apiaction = $args['apiaction']; + $method = $args['method']; + list($cmdtext, $fmt) = explode('.', $method); static $write_methods = array( @@ -207,5 +207,4 @@ class ApiAction extends Action return false; } - } diff --git a/actions/avatarbynickname.php b/actions/avatarbynickname.php index ca58c9653..e92a99372 100644 --- a/actions/avatarbynickname.php +++ b/actions/avatarbynickname.php @@ -98,7 +98,7 @@ class AvatarbynicknameAction extends Action common_redirect($url, 302); } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/doc.php b/actions/doc.php index ebffb7c15..e6508030b 100644 --- a/actions/doc.php +++ b/actions/doc.php @@ -108,7 +108,7 @@ class DocAction extends Action return ucfirst($this->title); } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/favorited.php b/actions/favorited.php index 09ab1216a..c902d80f5 100644 --- a/actions/favorited.php +++ b/actions/favorited.php @@ -85,7 +85,7 @@ class FavoritedAction extends Action * @return boolean true */ - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/featured.php b/actions/featured.php index 86fd3f374..79eba2aa6 100644 --- a/actions/featured.php +++ b/actions/featured.php @@ -50,7 +50,7 @@ class FeaturedAction extends Action { var $page = null; - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/foaf.php b/actions/foaf.php index 416935b1b..2d5b78d12 100644 --- a/actions/foaf.php +++ b/actions/foaf.php @@ -25,7 +25,7 @@ define('BOTH', 0); class FoafAction extends Action { - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/groupbyid.php b/actions/groupbyid.php index 678119a94..7d327d56c 100644 --- a/actions/groupbyid.php +++ b/actions/groupbyid.php @@ -59,7 +59,7 @@ class GroupbyidAction extends Action * @return boolean true */ - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/groupmembers.php b/actions/groupmembers.php index 00f43a9f5..a90108e4d 100644 --- a/actions/groupmembers.php +++ b/actions/groupmembers.php @@ -48,7 +48,7 @@ class GroupmembersAction extends Action { var $page = null; - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/grouprss.php b/actions/grouprss.php index de76a5960..a9a2eef87 100644 --- a/actions/grouprss.php +++ b/actions/grouprss.php @@ -57,7 +57,7 @@ class groupRssAction extends Rss10Action * @return boolean true */ - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/groups.php b/actions/groups.php index 39dc2232b..26b52a5fc 100644 --- a/actions/groups.php +++ b/actions/groups.php @@ -51,7 +51,7 @@ class GroupsAction extends Action var $page = null; var $profile = null; - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/invite.php b/actions/invite.php index df6e3b714..7e52cdbcc 100644 --- a/actions/invite.php +++ b/actions/invite.php @@ -27,7 +27,7 @@ class InviteAction extends Action var $subbed = null; var $sent = null; - function isReadOnly() + function isReadOnly($args) { return false; } diff --git a/actions/login.php b/actions/login.php index 59c6b4874..50de83f6f 100644 --- a/actions/login.php +++ b/actions/login.php @@ -55,7 +55,7 @@ class LoginAction extends Action * @return boolean false */ - function isReadOnly() + function isReadOnly($args) { return false; } diff --git a/actions/logout.php b/actions/logout.php index b7681be38..9f3bfe247 100644 --- a/actions/logout.php +++ b/actions/logout.php @@ -52,7 +52,7 @@ class LogoutAction extends Action * * @return boolean true */ - function isReadOnly() + function isReadOnly($args) { return false; } diff --git a/actions/microsummary.php b/actions/microsummary.php index 065a2e0eb..0b408ec95 100644 --- a/actions/microsummary.php +++ b/actions/microsummary.php @@ -74,7 +74,7 @@ class MicrosummaryAction extends Action print $user->nickname . ': ' . $notice->content; } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/noticesearchrss.php b/actions/noticesearchrss.php index ba5276d06..f6da969ee 100644 --- a/actions/noticesearchrss.php +++ b/actions/noticesearchrss.php @@ -92,7 +92,7 @@ class NoticesearchrssAction extends Rss10Action return null; } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/nudge.php b/actions/nudge.php index b4e5e01dd..c23d3e643 100644 --- a/actions/nudge.php +++ b/actions/nudge.php @@ -124,7 +124,7 @@ class NudgeAction extends Action } } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/opensearch.php b/actions/opensearch.php index 2eb818306..d1f4895ce 100644 --- a/actions/opensearch.php +++ b/actions/opensearch.php @@ -84,7 +84,7 @@ class OpensearchAction extends Action $this->endXML(); } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/public.php b/actions/public.php index 5a380de9a..27153f131 100644 --- a/actions/public.php +++ b/actions/public.php @@ -56,7 +56,7 @@ class PublicAction extends Action var $page = null; - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/publicrss.php b/actions/publicrss.php index 77e26e0f4..bc52f2952 100644 --- a/actions/publicrss.php +++ b/actions/publicrss.php @@ -102,7 +102,7 @@ class PublicrssAction extends Rss10Action // nop } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/publictagcloud.php b/actions/publictagcloud.php index 855cfed9b..e9f33d58b 100644 --- a/actions/publictagcloud.php +++ b/actions/publictagcloud.php @@ -47,7 +47,7 @@ define('TAGS_PER_PAGE', 100); class PublictagcloudAction extends Action { - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/publicxrds.php b/actions/publicxrds.php index 2c52f1246..283a932ca 100644 --- a/actions/publicxrds.php +++ b/actions/publicxrds.php @@ -54,7 +54,7 @@ class PublicxrdsAction extends Action * * @return boolean true */ - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/replies.php b/actions/replies.php index 2769cb422..eac4d0a3a 100644 --- a/actions/replies.php +++ b/actions/replies.php @@ -196,7 +196,7 @@ class RepliesAction extends Action $this->elementEnd('div'); } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/repliesrss.php b/actions/repliesrss.php index 985318bf1..2017c4309 100644 --- a/actions/repliesrss.php +++ b/actions/repliesrss.php @@ -83,7 +83,7 @@ class RepliesrssAction extends Rss10Action return ($avatar) ? $avatar->url : null; } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/requesttoken.php b/actions/requesttoken.php index ca253b97a..fb577fdd5 100644 --- a/actions/requesttoken.php +++ b/actions/requesttoken.php @@ -52,7 +52,7 @@ class RequesttokenAction extends Action * * @return boolean false */ - function isReadOnly() + function isReadOnly($args) { return false; } diff --git a/actions/showfavorites.php b/actions/showfavorites.php index 4d4349505..e8cf1cb01 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -58,7 +58,7 @@ class ShowfavoritesAction extends Action * @return boolean true */ - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/showgroup.php b/actions/showgroup.php index 79445851f..7e86a79f1 100644 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@ -60,7 +60,7 @@ class ShowgroupAction extends Action * @return boolean true */ - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/showmessage.php b/actions/showmessage.php index 572a71739..4fcaadbe8 100644 --- a/actions/showmessage.php +++ b/actions/showmessage.php @@ -177,7 +177,7 @@ class ShowmessageAction extends MailboxAction return ''; } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/shownotice.php b/actions/shownotice.php index ccae49bb3..2c469c9de 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -106,7 +106,7 @@ class ShownoticeAction extends Action * @return boolean true */ - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/showstream.php b/actions/showstream.php index ce237dae2..c1a2c337a 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -56,7 +56,7 @@ require_once INSTALLDIR.'/lib/feedlist.php'; class ShowstreamAction extends ProfileAction { - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/subscribers.php b/actions/subscribers.php index 7ebb54d33..d91a7d4fd 100644 --- a/actions/subscribers.php +++ b/actions/subscribers.php @@ -130,7 +130,7 @@ class SubscribersList extends ProfileList $bf->show(); } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/sup.php b/actions/sup.php index 246b3299d..691153d6a 100644 --- a/actions/sup.php +++ b/actions/sup.php @@ -79,7 +79,7 @@ class SupAction extends Action return $updates; } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/tag.php b/actions/tag.php index c413bf8c3..7f82c2a58 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -87,7 +87,7 @@ class TagAction extends Action $this->page, 'tag', array('tag' => $this->tag)); } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/tagrss.php b/actions/tagrss.php index a77fa12c9..83cf3afe2 100644 --- a/actions/tagrss.php +++ b/actions/tagrss.php @@ -65,7 +65,7 @@ class TagrssAction extends Rss10Action return $c; } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/twitapisearchjson.php b/actions/twitapisearchjson.php index 0f9f523a1..b0e3be687 100644 --- a/actions/twitapisearchjson.php +++ b/actions/twitapisearchjson.php @@ -142,7 +142,7 @@ class TwitapisearchjsonAction extends TwitterapiAction * @return boolean true */ - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/userbyid.php b/actions/userbyid.php index 1e30d1aac..4a985fcd7 100644 --- a/actions/userbyid.php +++ b/actions/userbyid.php @@ -50,7 +50,7 @@ class UserbyidAction extends Action * * @return boolean true */ - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/usergroups.php b/actions/usergroups.php index 06b2334bf..e3088dcbd 100644 --- a/actions/usergroups.php +++ b/actions/usergroups.php @@ -52,7 +52,7 @@ class UsergroupsAction extends Action var $page = null; var $profile = null; - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/userrss.php b/actions/userrss.php index d3bf352d8..5861d9ee3 100644 --- a/actions/userrss.php +++ b/actions/userrss.php @@ -96,7 +96,7 @@ class UserrssAction extends Rss10Action parent::initRss($limit); } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/actions/xrds.php b/actions/xrds.php index 075831803..1335b6b80 100644 --- a/actions/xrds.php +++ b/actions/xrds.php @@ -52,7 +52,7 @@ class XrdsAction extends Action * * @return boolean true */ - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/index.php b/index.php index e83d08c13..e24bde917 100644 --- a/index.php +++ b/index.php @@ -128,7 +128,7 @@ function main() // XXX: find somewhere for this little block to live - if (common_config('db', 'mirror') && $action_obj->isReadOnly()) { + if (common_config('db', 'mirror') && $action_obj->isReadOnly($args)) { if (is_array(common_config('db', 'mirror'))) { // "load balancing", ha ha $arr = common_config('db', 'mirror'); diff --git a/lib/action.php b/lib/action.php index cc98d4445..673549246 100644 --- a/lib/action.php +++ b/lib/action.php @@ -791,9 +791,12 @@ class Action extends HTMLOutputter // lawsuit * * MAY override * + * @param array $args other arguments + * * @return boolean is read only action? */ - function isReadOnly() + + function isReadOnly($args)($args) { return false; } diff --git a/lib/error.php b/lib/error.php index 526d9f81b..282682133 100644 --- a/lib/error.php +++ b/lib/error.php @@ -93,7 +93,7 @@ class ErrorAction extends Action return $this->message; } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/lib/galleryaction.php b/lib/galleryaction.php index 8e21d7393..0484918ce 100644 --- a/lib/galleryaction.php +++ b/lib/galleryaction.php @@ -76,7 +76,7 @@ class GalleryAction extends Action return true; } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/lib/peoplesearchresults.php b/lib/peoplesearchresults.php index f8ab7cf3b..d3f840852 100644 --- a/lib/peoplesearchresults.php +++ b/lib/peoplesearchresults.php @@ -67,7 +67,7 @@ class PeopleSearchResults extends ProfileList return preg_replace($this->pattern, '\\1', htmlspecialchars($text)); } - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/lib/personal.php b/lib/personal.php index e46350c63..f92732375 100644 --- a/lib/personal.php +++ b/lib/personal.php @@ -47,7 +47,7 @@ class PersonalAction extends Action var $user = null; - function isReadOnly() + function isReadOnly($args) { return true; } diff --git a/lib/searchaction.php b/lib/searchaction.php index e7ad4affd..e74450e11 100644 --- a/lib/searchaction.php +++ b/lib/searchaction.php @@ -51,7 +51,7 @@ class SearchAction extends Action * * @return boolean true */ - function isReadOnly() + function isReadOnly($args) { return true; } -- cgit v1.2.3-54-g00ecf From 4c9be4d566c4d4b6e846935cbabd951f5d59259d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 13 Apr 2009 15:52:15 -0400 Subject: typo in api.php --- actions/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/api.php b/actions/api.php index e40a18798..d2f0a2eff 100644 --- a/actions/api.php +++ b/actions/api.php @@ -180,7 +180,7 @@ class ApiAction extends Action } } - function isReadOnly($args)($args) + function isReadOnly($args) { $apiaction = $args['apiaction']; $method = $args['method']; -- cgit v1.2.3-54-g00ecf From 20394664957a202cc86cc48ee2d115032e82c58a Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Tue, 14 Apr 2009 23:03:19 +0000 Subject: 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(-) (limited to 'actions') diff --git a/actions/tag.php b/actions/tag.php index d15f64498..cb6572b96 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 0505f0fa9..a8d47ef54 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; -- cgit v1.2.3-54-g00ecf From 64e4b8a20f5ec3fb4f1a4c68337ae40b1b0b0dcf Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 14 Apr 2009 23:32:09 +0000 Subject: Updated remaining files and styles for style separation for themes --- actions/avatarsettings.php | 2 +- actions/designsettings.php | 2 +- theme/base/css/farbtastic.css | 6 +++--- theme/base/images/icons/icon_processing.gif | Bin 0 -> 673 bytes theme/cloudy/css/display.css | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 theme/base/images/icons/icon_processing.gif (limited to 'actions') diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php index 60f69b685..c2bb35a39 100644 --- a/actions/avatarsettings.php +++ b/actions/avatarsettings.php @@ -383,7 +383,7 @@ class AvatarsettingsAction extends AccountSettingsAction { parent::showStylesheets(); $jcropStyle = - common_path('theme/default/base/css/jquery.Jcrop.css?version='.LACONICA_VERSION); + common_path('theme/base/css/jquery.Jcrop.css?version='.LACONICA_VERSION); $this->element('link', array('rel' => 'stylesheet', 'type' => 'text/css', diff --git a/actions/designsettings.php b/actions/designsettings.php index 05293f712..cdd950e78 100644 --- a/actions/designsettings.php +++ b/actions/designsettings.php @@ -196,7 +196,7 @@ class DesignsettingsAction extends AccountSettingsAction { parent::showStylesheets(); $farbtasticStyle = - common_path('theme/default/base/css/farbtastic.css?version='.LACONICA_VERSION); + common_path('theme/base/css/farbtastic.css?version='.LACONICA_VERSION); $this->element('link', array('rel' => 'stylesheet', 'type' => 'text/css', diff --git a/theme/base/css/farbtastic.css b/theme/base/css/farbtastic.css index 3b8fec58f..7efcc73c3 100644 --- a/theme/base/css/farbtastic.css +++ b/theme/base/css/farbtastic.css @@ -16,17 +16,17 @@ height: 101px; } .farbtastic .wheel { - background: url(../../../../js/farbtastic/wheel.png) no-repeat; + background: url(../../../js/farbtastic/wheel.png) no-repeat; width: 195px; height: 195px; } .farbtastic .overlay { - background: url(../../../../js/farbtastic/mask.png) no-repeat; + background: url(../../../js/farbtastic/mask.png) no-repeat; } .farbtastic .marker { width: 17px; height: 17px; margin: -8px 0 0 -8px; overflow: hidden; - background: url(../../../../js/farbtastic/marker.png) no-repeat; + background: url(../../../js/farbtastic/marker.png) no-repeat; } diff --git a/theme/base/images/icons/icon_processing.gif b/theme/base/images/icons/icon_processing.gif new file mode 100644 index 000000000..d0bce1542 Binary files /dev/null and b/theme/base/images/icons/icon_processing.gif differ diff --git a/theme/cloudy/css/display.css b/theme/cloudy/css/display.css index 151758b48..b87722eec 100644 --- a/theme/cloudy/css/display.css +++ b/theme/cloudy/css/display.css @@ -1328,7 +1328,7 @@ color:#333; color:#000; } #form_notice.processing #notice_action-submit { -background:#fff url(../../../base/images/icons/icon_processing.gif) no-repeat 47% 47%; +background:#fff url(../../base/images/icons/icon_processing.gif) no-repeat 47% 47%; cursor:wait; text-indent:-9999px; } -- cgit v1.2.3-54-g00ecf From e8fc34e75c4c9684b8c7e03d471a905e08446618 Mon Sep 17 00:00:00 2001 From: Fil Date: Wed, 15 Apr 2009 10:35:15 +0200 Subject: Use preg_quote to fix http://laconi.ca/trac/ticket/1342 --- actions/noticesearch.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actions') diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 095d0a454..0828e47d7 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); -- cgit v1.2.3-54-g00ecf From 8439477201cd59a6c0dba84ddf48eb86a6154199 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 15 Apr 2009 13:29:52 +0200 Subject: Add escaping of /. --- actions/noticesearch.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'actions') diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 0828e47d7..d996998fc 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); -- cgit v1.2.3-54-g00ecf