]> git.mjollnir.org Git - s9y.git/commitdiff
Use assign_by_ref in places where it makes sense. Many thanks to Falk for pointing...
authorgarvinhicking <garvinhicking>
Wed, 21 Jun 2006 10:17:02 +0000 (10:17 +0000)
committergarvinhicking <garvinhicking>
Wed, 21 Jun 2006 10:17:02 +0000 (10:17 +0000)
13 files changed:
docs/NEWS
include/functions_comments.inc.php
include/functions_config.inc.php
include/functions_entries.inc.php
include/functions_images.inc.php
include/functions_smarty.inc.php
include/genpage.inc.php
include/plugin_api.inc.php
include/plugin_internal.inc.php
include/template_api.inc.php
index.php
rss.php
serendipity_admin_image_selector.php

index e4cd4cb214a362a6571ffde633eaf50cdea7bf3a..2d85b29361a19e7bbac509573c6396fca7d35d95 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,10 @@
 Version 1.1-alpha7()
 ------------------------------------------------------------------------
 
+    * Replaced core smarty assign() calls to assign_by_ref() where
+      appropriate. (Falk Döring, garvinhicking)
+      TODO: This might introduce oddities! Check thoroughly.
+
     * Fixed not showing entries in the quicksearch that have the
       "no frontpage" entryproperty set (garvinhicking)
 
index c7b24a903cec7a62dc5d5d7b4d8796757fbdf523..d461f1d45675659ed82303e9cd7a46ae56fcd1f6 100644 (file)
@@ -85,8 +85,7 @@ function serendipity_displayCommentForm($id, $url = '', $comments = NULL, $data
         $comments = serendipity_fetchComments($id);
     }
 
-    $serendipity['smarty']->assign(
-      array(
+    $commentform_data = array(
         'commentform_action'         => $url,
         'commentform_id'             => $id,
         'commentform_name'           => isset($data['name'])      ? htmlspecialchars($data['name'])       : (isset($serendipity['COOKIE']['name'])     ? htmlspecialchars($serendipity['COOKIE']['name'])     : ''),
@@ -100,9 +99,10 @@ function serendipity_displayCommentForm($id, $url = '', $comments = NULL, $data
         'is_allowSubscriptions'      => $serendipity['allowSubscriptions'],
         'is_moderate_comments'       => $moderate_comments,
         'commentform_entry'          => $entry
-      )
     );
 
+    $serendipity['smarty']->assign($commentform_data);
+
     serendipity_smarty_fetch('COMMENTFORM', 'commentform.tpl');
 }
 
@@ -284,7 +284,7 @@ function serendipity_printComments($comments, $parentid = 0, $depth = 0, $trace
         return true;
     }
 
-    $serendipity['smarty']->assign('comments', $_smartyComments);
+    $serendipity['smarty']->assign_by_ref('comments', $_smartyComments);
     unset($_smartyComments);
 
     return serendipity_smarty_fetch('COMMENTS', 'comments.tpl');
index fc6a4b9deb187ead804705644ef993de3849b256..c285334481b7efc8e16a7c7d95ac9095d4d0b65d 100644 (file)
@@ -667,7 +667,7 @@ function serendipity_iframe(&$entry, $mode = null, $use_smarty = true) {
     if ($use_smarty) {
         $preview = ob_get_contents();
         ob_end_clean();
-        $serendipity['smarty']->assign('preview', $preview);
+        $serendipity['smarty']->assign_by_ref('preview', $preview);
         $serendipity['smarty']->display(serendipity_getTemplateFile('preview_iframe.tpl', 'serendipityPath'));
     }
 
index 120345900f25fcf509fe00039390d9e54d63aa26..3070f98c4c30c3bd62ab7798478f840cac03d55c 100644 (file)
@@ -994,14 +994,14 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm
 
             /* IF WE ARE DISPLAYING A FULL ENTRY */
             if (isset($serendipity['GET']['id'])) {
-                $serendipity['smarty']->assign(
-                    array(
-                        'comments_messagestack' => (isset($serendipity['messagestack']['comments']) ? (array)$serendipity['messagestack']['comments'] : array()),
-                        'is_comment_added'      => (isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'true' ? true: false),
-                        'is_comment_moderate'   => (isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'moderate' ? true: false)
-                    )
+                $comment_add_data = array(
+                    'comments_messagestack' => (isset($serendipity['messagestack']['comments']) ? (array)$serendipity['messagestack']['comments'] : array()),
+                    'is_comment_added'      => (isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'true' ? true: false),
+                    'is_comment_moderate'   => (isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'moderate' ? true: false)
                 );
 
+                $serendipity['smarty']->assign($comment_add_data);
+
                 serendipity_displayCommentForm(
                     $entry['id'],
                     $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $entry['commURL'],
@@ -1022,7 +1022,7 @@ function serendipity_printEntries($entries, $extended = 0, $preview = false, $sm
         serendipity_printEntryFooter();
     }
 
-    $serendipity['smarty']->assign('entries', $dategroup);
+    $serendipity['smarty']->assign_by_ref('entries', $dategroup);
     unset($entries, $dategroup);
 
     if (isset($serendipity['short_archives']) && $serendipity['short_archives']) {
@@ -1442,8 +1442,9 @@ function serendipity_printArchives() {
             $output[$y]['months'][] = $data;
         }
     }
-    $serendipity['smarty']->assign(array('archives' => $output,
-                                         'max_entries' => $max));
+    
+    $serendipity['smarty']->assign_by_ref('archives', $output);
+    $serendipity['smarty']->assign_by_ref('max_entries', $max);
 
     serendipity_smarty_fetch('ARCHIVES', 'entries_archives.tpl', true);
 }
index 1d0b29c2d607b0254ce07f4a5499479c6193b5bb..0cb0d835be79bc701965dcff3a0d141f6876cb70 100644 (file)
@@ -2664,7 +2664,7 @@ function serendipity_showMedia(&$file, &$paths, $url = '', $manage = false, $lin
         $media['paths'] =& serendipity_getMediaPaths();
     }
 
-    $serendipity['smarty']->assign('media', $media);
+    $serendipity['smarty']->assign_by_ref('media', $media);
 
     if ($enclose) {
         serendipity_smarty_fetch('MEDIA_ITEMS', 'admin/media_items.tpl');
index 5a58ade6e0ab992f85c26dcbb19688b223b9743b..be1e332097b8878f67740520266e86ddf120de48 100644 (file)
@@ -16,7 +16,7 @@ if (defined('S9Y_FRAMEWORK_SMARTY')) {
  * @param   boolean If true, also non-approved trackbacks will be shown
  * @return
  */
-function serendipity_fetchTrackbacks($id, $limit = null, $showAll = false) {
+function &serendipity_fetchTrackbacks($id, $limit = null, $showAll = false) {
     global $serendipity;
 
     if (!$showAll) {
@@ -46,10 +46,10 @@ function serendipity_fetchTrackbacks($id, $limit = null, $showAll = false) {
  * @param   array       The superarray of trackbacks to display
  * @return
  */
-function serendipity_printTrackbacks($trackbacks) {
+function &serendipity_printTrackbacks(&$trackbacks) {
     global $serendipity;
 
-    $serendipity['smarty']->assign('trackbacks', $trackbacks);
+    $serendipity['smarty']->assign_by_ref('trackbacks', $trackbacks);
 
     return serendipity_smarty_fetch('TRACKBACKS', 'trackbacks.tpl');
 }
@@ -66,8 +66,8 @@ function serendipity_printTrackbacks($trackbacks) {
 function &serendipity_smarty_fetch($block, $file, $echo = false) {
     global $serendipity;
 
-    $output = $serendipity['smarty']->fetch('file:'. serendipity_getTemplateFile($file, 'serendipityPath'), null, null, ($echo === true && $serendipity['smarty_raw_mode']));
-    $serendipity['smarty']->assign($block, $output);
+    $output =& $serendipity['smarty']->fetch('file:'. serendipity_getTemplateFile($file, 'serendipityPath'), null, null, ($echo === true && $serendipity['smarty_raw_mode']));
+    $serendipity['smarty']->assign_by_ref($block, $output);
 
     return $output;
 }
@@ -584,13 +584,14 @@ function &serendipity_smarty_printComments($params, &$smarty) {
  * @param   object  Smarty object
  * @return
  */
-function serendipity_smarty_printTrackbacks($params, &$smarty) {
+function &serendipity_smarty_printTrackbacks($params, &$smarty) {
     if ( !isset($params['entry']) ) {
         $smarty->trigger_error(__FUNCTION__ .": missing 'entry' parameter");
         return;
     }
 
-    return serendipity_printTrackbacks(serendipity_fetchTrackbacks($params['entry']));
+    $tb =& serendipity_fetchTrackbacks($params['entry']);
+    return serendipity_printTrackbacks($tb);
 }
 
 /**
@@ -748,7 +749,7 @@ function serendipity_smarty_init($vars = array()) {
 
     if (is_array($template_config)) {
         $template_vars =& serendipity_loadThemeOptions($template_config);
-        $serendipity['smarty']->assign('template_option', $template_vars);
+        $serendipity['smarty']->assign_by_ref('template_option', $template_vars);
     }
 
     return true;
@@ -795,7 +796,7 @@ global $serendipity;
     chdir($serendipity_directory);
     $raw_data = ob_get_contents();
     ob_end_clean();
-    $serendipity['smarty']->assign('content_message', $raw_data);
+    $serendipity['smarty']->assign_by_ref('content_message', $raw_data);
 
     serendipity_smarty_fetch('CONTENT', 'content.tpl');
     $serendipity['smarty']->assign('ENTRIES', '');
index 72147da001e037b8e48c7e5e774610f335b29774..8a5cd2ae0f6b0ce8e36258534e7d0a087c6ecc5f 100644 (file)
@@ -27,12 +27,10 @@ $serendipity['plugindata']['smartyvars'] = $uri_addData; // Plugins can change t
 serendipity_plugin_api::hook_event('genpage', $uri, $uri_addData);
 serendipity_smarty_init($serendipity['plugindata']['smartyvars']);
 
-$serendipity['smarty']->assign(
-    array(
-        'leftSidebarElements'       => serendipity_plugin_api::count_plugins('left'),
-        'rightSidebarElements'      => serendipity_plugin_api::count_plugins('right')
-    )
-);
+$leftSidebarElements  = serendipity_plugin_api::count_plugins('left');
+$rightSidebarElements = serendipity_plugin_api::count_plugins('right');
+$serendipity['smarty']->assign_by_ref('leftSidebarElements', $leftSidebarElements);
+$serendipity['smarty']->assign_by_ref('rightSidebarElements', $rightSidebarElements);
 
 if ($serendipity['smarty_raw_mode']) {
     /* For BC reasons, we have to ask for layout.php */
index 0dc1a5bb7653bedd983cc623cddd17861394362f..b55889e0edbee488241e88d73dd99ee5c3b9227d 100644 (file)
@@ -842,13 +842,8 @@ class serendipity_plugin_api {
             }
         }
 
-        $serendipity['smarty']->assign(
-            array(
-                'plugindata' => $pluginData,
-                'pluginside' => ucfirst($side)
-            )
-        );
-
+        $serendipity['smarty']->assign_by_ref('plugindata', $pluginData);
+        $serendipity['smarty']->assign('pluginside', ucfirst($side));
 
         return serendipity_smarty_fetch('sidebar_'. $side, 'sidebar.tpl', true);
     }
index 4dc4a32c866a8a0c62f48bfd996cb4430f3e7874..78d6b42425d4069cf1e401fd0247487c9153cd98 100644 (file)
@@ -306,20 +306,21 @@ class serendipity_calendar_plugin extends serendipity_plugin {
             } // end for
         } // end for
 
-        $serendipity['smarty']->assign('plugin_calendar_weeks', $smartyRows);
+        $serendipity['smarty']->assign_by_ref('plugin_calendar_weeks', $smartyRows);
 
         $dow = array();
         for ($i = 1; $i <= 7; $i++) {
             $dow[] = array('date' => mktime(0, 0, 0, 3, $bow + $i - 1, 2004));
         }
-        $serendipity['smarty']->assign('plugin_calendar_dow', $dow);
+        $serendipity['smarty']->assign_by_ref('plugin_calendar_dow', $dow);
 
-        $serendipity['smarty']->assign('plugin_calendar_head', array('month_date'   => $ts,
+        $plugin_calendar_data = array('month_date'   => $ts,
             'uri_previous' => serendipity_archiveDateUrl(sprintf('%04d/%02d', $previousYear, $previousMonth). $add_query),
             'uri_month'    => serendipity_archiveDateUrl(sprintf('%04d/%02d', $year, $month) . $add_query),
             'uri_next'     => serendipity_archiveDateUrl(sprintf('%04d/%02d',$nextYear, $nextMonth) . $add_query),
             'minScroll'    => $minmax[0]['min'],
-            'maxScroll'    => $minmax[0]['max']));
+            'maxScroll'    => $minmax[0]['max']);
+        $serendipity['smarty']->assign_by_ref('plugin_calendar_head', $plugin_calendar_data);
         echo serendipity_smarty_fetch('CALENDAR', 'plugin_calendar.tpl');
 
     } // end function
@@ -1547,12 +1548,13 @@ class serendipity_categories_plugin extends serendipity_plugin {
         if (!$smarty) {
             echo $html;
         } else {
-            $serendipity['smarty']->assign(array(
+            $plugin_categories_data = array(
                 'is_form'           => $is_form,
                 'category_image'    => $image,
                 'form_url'          => $serendipity['baseURL'] . $serendipity['indexFile'],
                 'categories'        => is_array($categories) ? $categories : array()
-            ));
+            );
+            $serendipity['smarty']->assign($plugin_categories_data);
             echo serendipity_smarty_fetch('CATEGORIES', 'plugin_categories.tpl');
         }
     }
index 1439ea6be86a246405380c87c699d14201c2b005..78bd3184773b89f76a00cb84af8e54540c60e9cd 100644 (file)
@@ -284,7 +284,7 @@ class serendipity_smarty_emulator_xml extends serendipity_smarty_emulator {
             $openkey  = 'item index="' . $key . '"';
             $closekey = 'item';
         } else {
-            $openkey = $closekey = $key;
+            $openkey = $closekey = str_replace(':', '_', $key);
         }
 
         if (is_array($val)) {
index f617a0682a3beaebd1b2d5d0e4e430a273e5a403..166ef83f5411d43840a4f6383cfcd25dfaf2a21b 100644 (file)
--- a/index.php
+++ b/index.php
@@ -482,7 +482,7 @@ if ($track_referer) {
 if (!defined('NO_EXIT')) {
     $raw_data = ob_get_contents();
     ob_end_clean();
-    $serendipity['smarty']->assign('raw_data', $raw_data);
+    $serendipity['smarty']->assign_by_ref('raw_data', $raw_data);
     if (empty($serendipity['smarty_file'])) {
         $serendipity['smarty_file'] = '404.tpl';
     }
diff --git a/rss.php b/rss.php
index 78ce887cae5f19a2acb608caa81b94ba00833fde..1bb96a9cfdd65ce4fedb06f67bb8627db6b03971 100644 (file)
--- a/rss.php
+++ b/rss.php
@@ -225,15 +225,16 @@ serendipity_plugin_api::hook_event($namespace_hook, $entries);
 $namespace_display_dat = $entries['display_dat'];
 unset($entries['display_dat']);
 
+$serendipity['smarty']->assign_by_ref('metadata', $metadata);
+$serendipity['smarty']->assign_by_ref('entries', $entries);
+$serendipity['smarty']->assign_by_ref('namespace_display_dat', $namespace_display_dat);
+$serendipity['smarty']->assign_by_ref('once_display_dat', $once_display_dat);
+
 $serendipity['smarty']->assign(
     array(
-        'metadata'              => $metadata,
-        'entries'               => $entries,
         'is_comments'           => $comments,
         'last_modified'         => $gm_modified,
         'self_url'              => $self_url,
-        'namespace_display_dat' => $namespace_display_dat,
-        'once_display_dat'      => $once_display_dat
     )
 );
 $serendipity['smarty']->display($template_file);
index 1d1be8bc5402d9d1528734604e79fb60dc004a33..dfdcfb895deab4b062d0e91cff083d11032158ab 100644 (file)
@@ -32,7 +32,7 @@ if (empty($serendipity['GET']['step']) && $serendipity['GET']['page'] < 1) {
         'GET_STRING' => serendipity_build_query($_GET),
         'frameset'   => true
     );
-    $serendipity['smarty']->assign('media', $media);
+    $serendipity['smarty']->assign_by_ref('media', $media);
     $serendipity['smarty']->display(serendipity_getTemplateFile('admin/media_choose.tpl', 'serendipityPath'));
     return;
 }
@@ -296,7 +296,7 @@ switch ($serendipity['GET']['step']) {
 }
 
 $media = array_merge($serendipity['GET'], $media);
-$serendipity['smarty']->assign('media', $media);
+$serendipity['smarty']->assign_by_ref('media', $media);
 $serendipity['smarty']->display(serendipity_getTemplateFile($showFile, 'serendipityPath'));
 
 /* vim: set sts=4 ts=4 expandtab : */
\ No newline at end of file