forked from GNUsocial/gnu-social
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.
This commit is contained in:
@@ -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 <link> 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')));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user