]> git.mjollnir.org Git - s9y.git/commitdiff
Add new "joinown" and "entryprops" parameters to
authorgarvinhicking <garvinhicking>
Thu, 29 Nov 2007 12:27:50 +0000 (12:27 +0000)
committergarvinhicking <garvinhicking>
Thu, 29 Nov 2007 12:27:50 +0000 (12:27 +0000)
{serendipity_fetchPrintEntries}

docs/NEWS
include/functions_entries.inc.php
include/functions_smarty.inc.php
templates/bulletproof/index.tpl

index b04b5db200bc8c1ed616024942e4c94bba240556..26390e17edd087cbd9b886bee0c75300ae43dffc 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,11 @@
 Version 1.3 ()
 ------------------------------------------------------------------------
 
+    * Added new parameter "joinown" and "entryprops" to {serendipity_
+      fetchPrintEntries} smarty function, to be able to fetch entries
+      according to their entryprops or other custom SQL.
+      (garvinhicking)
+
     * Added LifeType importer (garvinhicking)
 
     * Updated Textile library to 2.0, by Lars Strojny
index 3258f63fa2198252a323f9ed7586b4199440e599..f88c56d3d010d8dd123163dd6e9047a9bdbe99c2 100644 (file)
@@ -206,9 +206,10 @@ function &serendipity_fetchEntryCategories($entryid) {
  * @param   string      If set to "array", the array of entries will be returned. "flat-array" will only return the articles without their entryproperties. "single" will only return a 1-dimensional array. "query" will only return the used SQL.
  * @param   bool        Should an SQL-join be made to the AUTHORS DB table?
  * @param   bool        Should an SQL-join be made to the CATEGORIES DB table?
+ * @param   string      SQL-Parts to add to JOIN
  * @return  array       Holds the super-array of all entries with all additional information
  */
-function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fetchDrafts = false, $modified_since = false, $orderby = 'timestamp DESC', $filter_sql = '', $noCache = false, $noSticky = false, $select_key = null, $group_by = null, $returncode = 'array', $joinauthors = true, $joincategories = true) {
+function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fetchDrafts = false, $modified_since = false, $orderby = 'timestamp DESC', $filter_sql = '', $noCache = false, $noSticky = false, $select_key = null, $group_by = null, $returncode = 'array', $joinauthors = true, $joincategories = true, $joinown = null) {
     global $serendipity;
 
     $cond = array();
@@ -393,6 +394,10 @@ function &serendipity_fetchEntries($range = null, $full = true, $limit = '', $fe
                     LEFT JOIN {$serendipity['dbPrefix']}category c
                         ON ec.categoryid = c.categoryid";
     }
+    
+    if ($joinown) {
+        $cond['joins'] .= $joinown;
+    }
 
     $serendipity['fullCountQuery'] .="
                     {$cond['joins']}
@@ -813,7 +818,14 @@ function serendipity_printEntryFooter($suffix = '.html', $totalEntries = null) {
     if ($totalEntries === null) {
         $totalEntries = serendipity_getTotalEntries();
     }
-    $totalPages   = ceil($totalEntries / $serendipity['fetchLimit']);
+    
+    $limits = explode(',', $serendipity['fetchLimit']);
+    if (!empty($limits[1])) {
+        $limit = (int)$limits[1];
+    } else {
+        $limit = (int)$limits[0];
+    }
+    $totalPages   = ceil($totalEntries / $limit);
 
     if (!isset($serendipity['GET']['page'])) {
         $serendipity['GET']['page'] = 1;
index 4d86fcf7f2172134c18cc7d5dd4dd984c7270ed8..7c71bc954b66267124ea41d3dc23c707831e9d2d 100644 (file)
@@ -146,6 +146,8 @@ function serendipity_ifRemember($name, $value, $isDefault = false, $att = 'check
  *                          returncode       (string)  If set to "array", the array of entries will be returned. "flat-array" will only return the articles without their entryproperties. "single" will only return a 1-dimensional array. "query" will only return the used SQL.
  *                          joinauthors      (bool)    Should an SQL-join be made to the AUTHORS DB table?
  *                          joincategories   (bool)    Should an SQL-join be made to the CATEGORIES DB table?
+ *                          joinown          (string)  SQL-Parts to add to the "JOIN" query
+ *                          entryprops       (string)  Condition list of commaseparated entryproperties that an entry must have to be displayed (example: "ep_CustomField='customVal',ep_CustomField2='customVal2'")
  *
  *                      [PRINTING]
  *                          template:          (string)  Name of the template file to print entries with
@@ -184,6 +186,18 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) {
     if (empty($params['fetchDrafts'])) {
         $params['fetchDrafts'] = false;
     }
+    
+    if (!empty($params['entryprops'])) {
+        if (preg_match_all('@(.*)(!)?=[\'"]*(.*)[\'"]*(,|$)@imsU', $params['entryprops'], $m)) {
+            foreach($m[0] AS $idx => $p) {
+                $params['joinown'] .= "\n JOIN {$serendipity['dbPrefix']}entryproperties 
+                                          AS ep" . $idx . " 
+                                          ON (ep" . $idx . ".entryid = e.id AND 
+                                              ep" . $idx . ".property = '" . serendipity_db_escape_string($m[1][$idx]) . "' AND 
+                                              ep" . $idx . ".value " . $m[2][$idx] . "= '" . serendipity_db_escape_string($m[3][$idx]) . "') \n";
+            }
+        }
+    }
 
     if (empty($params['modified_since'])) {
         $params['modified_since'] = false;
@@ -295,7 +309,8 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) {
             $params['group_by'],
             $params['returncode'],
             $params['joinauthors'],
-            $params['joincategories']
+            $params['joincategories'],
+            $params['joinown']
         );
 
         // Check whether the returned entries shall be grouped specifically
index dc4f7049537b43ed15b55bde88138b90272f961f..5bc046ce003c064647f196f1848d54605f61d203 100644 (file)
 {/if}
 
 {$raw_data}
+
 {serendipity_hookPlugin hook="frontend_footer"}
 {if $is_embedded != true}
     </body>