]> git.mjollnir.org Git - s9y.git/commitdiff
Fix a bug that might prevent {serendipity_fetchPrintEntries} from
authorgarvinhicking <garvinhicking>
Fri, 31 Mar 2006 18:35:18 +0000 (18:35 +0000)
committergarvinhicking <garvinhicking>
Fri, 31 Mar 2006 18:35:18 +0000 (18:35 +0000)
correctly showing output, and maybe duplicating entry list.

include/functions_smarty.inc.php

index 0b4c73a0016c4f901e44a4bc06fea7c9bde2e685..c40beb7035ba40dcc0fac7d9fa5fbde96746273a 100644 (file)
@@ -2,6 +2,11 @@
 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
 # All rights reserved.  See LICENSE file for licensing details
 
+if (defined('S9Y_FRAMEWORK_SMARTY')) {
+    return;
+}
+@define('S9Y_FRAMEWORK_SMARTY', true);
+
 /**
  * Fetch a list of trackbacks for an entry
  *
@@ -117,6 +122,7 @@ function serendipity_emptyPrefix($string, $prefix = ': ') {
  *                          groupmode          (string   Indicates whether the input $entries array is already grouped in preparation for the smarty $entries output array [TRUE], or if it shall be grouped by date [FALSE]
  *                          skip_smarty_hooks  (boolean) If TRUE, no plugins will be executed at all
  *                          skip_smarty_hook   (mixed)   Can be set to an array of plugin hooks to NOT execute
+ *                          prevent_reset      (boolean) If set to TRUE, the smarty $entries array will NOT be cleared. (to prevent possible duplicate output of entries)
  * @param   object      Smarty object
  * @return  string      The Smarty HTML response
  */
@@ -189,6 +195,10 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) {
         $params['skip_smarty_hook'] = array();
     }
 
+    if (empty($params['prevent_reset'])) {
+        $params['prevent_reset'] = false;
+    }
+
     // Some functions deal with the $serendipity array. To modify them, we need to store
     // their original contents.
     $old_var = array();
@@ -257,10 +267,11 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) {
         $entry,                                 // Entry data
         (!empty($params['id']) ? true : false), // Extended data?
         $params['preview'],                     // Entry preview?
+        'ENTRIES',
         false,                                  // Prevent Smarty parsing
         $params['use_hooks'],
         $params['use_footer'],
-        ($params['groupmode'] == 'date' ? true : false) // Grouping of $entry
+        ($params['groupmode'] == 'date' ? false : true) // Grouping of $entry
     );
 
     // Restore the $serendipity array after our modifications.
@@ -275,7 +286,10 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) {
     }
 
     $out = serendipity_smarty_fetch($params['block'], $params['template']);
-
+    // Reset array list, because we might be in a nested code call.
+    if ($params['prevent_reset'] == false) {
+        $serendipity['smarty']->assign('entries', array());
+    }
     $serendipity['skip_smarty_hook']  = $old_var['skip_smarty_hook'];
     $serendipity['skip_smarty_hooks'] = $old_var['skip_smarty_hooks'];
 
@@ -528,7 +542,9 @@ function serendipity_smarty_init($vars = array()) {
 
     if (!isset($serendipity['smarty'])) {
         @define('SMARTY_DIR', S9Y_PEAR_PATH . 'Smarty/libs/');
-        require_once SMARTY_DIR . 'Smarty.class.php';
+        if (!class_exists('Smarty')) {
+            require SMARTY_DIR . 'Smarty.class.php';
+        }
         $serendipity['smarty'] = new Smarty;
         if ($serendipity['production'] === 'debug') {
             $serendipity['smarty']->force_compile   = true;
@@ -640,7 +656,7 @@ function serendipity_smarty_init($vars = array()) {
 
     // For advanced usage, we allow template authors to create a file 'config.inc.php' where they can
     // setup custom smarty variables, modifiers etc. to use in their templates.
-    @include_once $serendipity['smarty']->config_dir . '/config.inc.php';
+    @include $serendipity['smarty']->config_dir . '/config.inc.php';
 
     return true;
 }