Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add paging to RSS results #366

Open
wants to merge 24 commits into
base: 7.x
Choose a base branch
from
Open
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion islandora_solr_config/includes/rss_results.inc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class IslandoraSolrResultsRSS extends IslandoraSolrResults {
$channel = $this->rssChannel($query);
$rss_attributes = array('version' => '2.0');
drupal_alter('islandora_solr_config_rss_root_element_attributes', $rss_attributes, $channel, $items);

dd($channel);
bondjimbond marked this conversation as resolved.
Show resolved Hide resolved
// Give the results clean variable names.
$title = $channel['title'];
$url = $channel['url'];
Expand Down Expand Up @@ -191,7 +191,53 @@ class IslandoraSolrResultsRSS extends IslandoraSolrResults {
$result['url'] = $base_url;
$result['description'] = t('Aggregated search results of: @query', array('@query' => $query));
$result['langcode'] = NULL;

$feed_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
bondjimbond marked this conversation as resolved.
Show resolved Hide resolved
if (strpos($feed_url, '&page') == FALSE) {
bondjimbond marked this conversation as resolved.
Show resolved Hide resolved
$page_number = '1';
}
else {
$arr = explode('&page=', $feed_url);
bondjimbond marked this conversation as resolved.
Show resolved Hide resolved
$page_number = $arr[1];
}
$link_self = $feed_url;
if (isset($arr)) {
$link_first = $arr[0];
}
else {
$link_first = $feed_url;
}
$page_next = $page_number + 1;
if ($page_number > 1) {
$page_prev = $page_number - 1;
}
$link_next = url($link_first . '&page=' . $page_next);
bondjimbond marked this conversation as resolved.
Show resolved Hide resolved
if (isset($page_prev)) {
$link_prev = $link_first . '&page=' . $page_prev;
}

$result['args'] = array(
array(
'key' => 'link',
'attributes' => array(
'rel' => 'next'),
'value' => $link_next,
'encoded' => TRUE,
),
array(
'key' => 'link',
'attributes' => array(
'rel' => 'previous'),
'value' => $link_prev,
'encoded' => TRUE,
),
array(
'key' => 'link',
'attributes' => array(
'rel' => 'first'),
'value' => $link_first,
'encoded' => TRUE,
),
array(
'key' => 'copyright',
'value' => $rss_channel['copyright']),
Expand Down