opensearch paging
authorChristian Weiske <cweiske@cweiske.de>
Fri, 12 Feb 2016 16:04:42 +0000 (17:04 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Fri, 12 Feb 2016 16:04:42 +0000 (17:04 +0100)
data/templates/opensearch.htm
src/phinde/Html/Pager.php

index a1000f109c29d4bf17b702317c29381b12e913b0..1ba805a15fda62a1c18bd95b8a64116004654dc0 100644 (file)
@@ -1,11 +1,26 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<feed xmlns="http://www.w3.org/2005/Atom" 
+<feed xmlns="http://www.w3.org/2005/Atom"
       xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
-  <title>"{{query}}" search results</title> 
+  <title>"{{query}}" search results</title>
   <link rel="self" href="{{fullUrl}}" type="application/atom+xml"/>
+  {% set fullUrls = pager.getFullUrls() %}
+  {% if fullUrls.first %}
+  <link rel="first" href="{{fullUrls.first}}" type="application/atom+xml"/>
+  {% endif %}
+  {% if fullUrls.prev %}
+  <link rel="prev" href="{{fullUrls.prev}}" type="application/atom+xml"/>
+  {% endif %}
+  {% if fullUrls.next %}
+  <link rel="next" href="{{fullUrls.next}}" type="application/atom+xml"/>
+  {% endif %}
+  {% if fullUrls.last %}
+  <link rel="last" href="{{fullUrls.last}}" type="application/atom+xml"/>
+  {% endif %}
+
   <updated>{{"now"|date("c")}}</updated>
   <id>{{fullUrl}}</id>
   <opensearch:totalResults>{{hitcount}}</opensearch:totalResults>
+  <opensearch:itemsPerPage>10</opensearch:itemsPerPage>
   {% for hit in hits %}
     {% set doc = hit._source %}
     <entry>
index a14a53d659a994ccd4c039f42ba4b49190a51816..9726d958abd7526e2f1180d484d07fd07396059d 100644 (file)
@@ -57,6 +57,21 @@ class Html_Pager
         return $arLinks;
     }
 
+    public function getFullUrls()
+    {
+        $arLinks = $this->pager->getLinks();
+        $arUrls = array();
+        foreach ($arLinks['linkTagsRaw'] as $key => $link) {
+            if (isset($link['url'])) {
+                $arUrls[$key] = str_replace(
+                    '&amp;', '&',
+                    Helper::fullUrl('/'  . $link['url'])
+                );
+            }
+        }
+        return $arUrls;
+    }
+
     public function numPages()
     {
         return $this->pager->numPages();