]> git.mjollnir.org Git - s9y.git/commitdiff
fetch entryproperties in search results
authorgarvinhicking <garvinhicking>
Wed, 19 Oct 2005 13:24:01 +0000 (13:24 +0000)
committergarvinhicking <garvinhicking>
Wed, 19 Oct 2005 13:24:01 +0000 (13:24 +0000)
docs/NEWS
include/functions_entries.inc.php

index c86bbe7a102debc84538a05dba3a1b832911a613..a92642c1172a098412efe322ae53d8cf18f0463e 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,9 @@
 Version 0.9-beta3 ()
 ------------------------------------------------------------------------
 
+    * Also fetch and display entryproperties in the results of a search.
+      Fixes bug #1329379 (garvinhicking)
+     
     * Fix some dreaded "only variables can be returned by referenced"
       PHP 4.4 notices on some minor occasions (garvinhicking)
 
index 7080b3195414050ad2e6351e97b80031a8fb0400..1233fdc13dc44ab65a2449872f877bffb701ee68 100644 (file)
@@ -286,39 +286,48 @@ function serendipity_fetchEntries($range = null, $full = true, $limit = '', $fet
         // First code for this was sending 15 queries for 15 fetched entries,
         // this is now limited to just one query per fetched articles group
 
-        $search_ids = array(); // An array to hold all ids of the entry we want to fetch.
-        $assoc_ids  = array(); // A temporary key association container to not have to loop through the return array once again.
+        serendipity_fetchEntryData($ret);
+    }
 
-        foreach($ret AS $i => $entry) {
-            $search_ids[]            = $entry['id'];
-            $ret[$i]['categories']   = array();        // make sure every article gets its category association
-            $assoc_ids[$entry['id']] = $i;             // store temporary reference
-        }
+    return $ret;
+}
 
-        serendipity_plugin_api::hook_event('frontend_entryproperties', $ret, $assoc_ids);
+/**
+ * Attach special entry data to entry
+ */
+function serendipity_fetchEntryData(&$ret) {
+    global $serendipity;
 
-        $query = "SELECT
-                         ec.entryid,
-                         c.categoryid,
-                         c.category_name,
-                         c.category_description,
-                         c.category_icon,
-                         c.parentid
-                    FROM {$serendipity['dbPrefix']}category AS c
-               LEFT JOIN {$serendipity['dbPrefix']}entrycat AS ec
-                      ON ec.categoryid = c.categoryid
-                   WHERE " . serendipity_db_in_sql('ec.entryid', $search_ids);
+    $search_ids = array(); // An array to hold all ids of the entry we want to fetch.
+    $assoc_ids  = array(); // A temporary key association container to not have to loop through the return array once again.
+
+    foreach($ret AS $i => $entry) {
+        $search_ids[]            = $entry['id'];
+        $ret[$i]['categories']   = array();        // make sure every article gets its category association
+        $assoc_ids[$entry['id']] = $i;             // store temporary reference
+    }
 
-        $search_ret = serendipity_db_query($query, false, 'assoc');
+    serendipity_plugin_api::hook_event('frontend_entryproperties', $ret, $assoc_ids);
 
-        if (is_array($search_ret)) {
-            foreach($search_ret AS $i => $entry) {
-                $ret[$assoc_ids[$entry['entryid']]]['categories'][] = $entry;
-            }
+    $query = "SELECT
+                     ec.entryid,
+                     c.categoryid,
+                     c.category_name,
+                     c.category_description,
+                     c.category_icon,
+                     c.parentid
+                FROM {$serendipity['dbPrefix']}category AS c
+           LEFT JOIN {$serendipity['dbPrefix']}entrycat AS ec
+                  ON ec.categoryid = c.categoryid
+               WHERE " . serendipity_db_in_sql('ec.entryid', $search_ids);
+
+    $search_ret = serendipity_db_query($query, false, 'assoc');
+
+    if (is_array($search_ret)) {
+        foreach($search_ret AS $i => $entry) {
+            $ret[$assoc_ids[$entry['entryid']]]['categories'][] = $entry;
         }
     }
-
-    return $ret;
 }
 
 /**
@@ -573,6 +582,11 @@ function serendipity_searchEntries($term, $limit = '') {
                     $limit";
 
     $search = serendipity_db_query($querystring);
+
+    if (is_array($search)) {
+        serendipity_fetchEntryData($search);
+    }
+
     return $search;
 }