summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorMeitar Moscovitz <meitarm@gmail.com>2009-02-10 19:42:01 +1100
committerMeitar Moscovitz <meitarm@gmail.com>2009-02-10 20:25:44 +1100
commitb240a1719485b15c4a6497b6053c24e8a40a4e3c (patch)
treecb3ab3fa2e76c971c70bffaf37984d079cee7185 /actions
parent3585012380bd8352b8e7bbb605bed05a9148fe11 (diff)
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 `<link>` elements need to be output inside of `showHead()`, before `showContent()`, which is where `pagination()` is, gets called.
Diffstat (limited to 'actions')
-rw-r--r--actions/all.php15
-rw-r--r--actions/favorited.php13
-rw-r--r--actions/groupmembers.php15
-rw-r--r--actions/groups.php13
-rw-r--r--actions/inbox.php15
-rw-r--r--actions/outbox.php15
-rw-r--r--actions/public.php25
-rw-r--r--actions/replies.php15
-rw-r--r--actions/showfavorites.php16
-rw-r--r--actions/showgroup.php15
-rw-r--r--actions/showstream.php15
-rw-r--r--actions/tag.php15
12 files changed, 37 insertions, 150 deletions
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()