From 0dac346c476ccf5a56e4c1208055a4763e086a38 Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Wed, 21 Jun 2006 09:06:52 +0000 Subject: [PATCH] - Fix a template API problem with empty XML elements - Fix entryproperty no_frontpage bug - Added assign_by_ref template API calls --- docs/NEWS | 3 ++ include/template_api.inc.php | 46 +++++++++++++++++-- .../serendipity_event_entryproperties.php | 4 +- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index 078ee17..e4cd4cb 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,9 @@ Version 1.1-alpha7() ------------------------------------------------------------------------ + * Fixed not showing entries in the quicksearch that have the + "no frontpage" entryproperty set (garvinhicking) + * Fixed sidebar category plugin to show proper category listing for permission-based restrictions, when "current autho" mode is selected (garvinhicking) diff --git a/include/template_api.inc.php b/include/template_api.inc.php index f9983b5..1439ea6 100644 --- a/include/template_api.inc.php +++ b/include/template_api.inc.php @@ -65,7 +65,6 @@ class serendipity_smarty_emulator { /** * Assign one or multiple template variable - * @TODO: Why can't this function accept references. This sucks. * * @param mixed Either a variable name, or an array of variables * @param mixed Either null or the variable content. @@ -86,6 +85,20 @@ class serendipity_smarty_emulator { return true; } +/** + * Assign one or multiple template variable by reference + * + * @param string Variable name + * @param mixed Referenced variable + * @access public + * @return null + */ + function assign_by_ref($tpl_var, &$value) { + $GLOBALS['tpl'][$tpl_var] =& $value; + + return true; + } + /** * Helper function to call a 'serendipity_smarty_xx' function with less parameters. * @@ -230,9 +243,7 @@ class serendipity_smarty_emulator_xml extends serendipity_smarty_emulator { function assign($tpl_var, $value = null, $level = 0) { if (is_array($tpl_var)) { foreach ($tpl_var as $key => $val) { - if ($key != '') { - $this->createXML($level, $key, $val); - } + $this->createXML($level, $key, $val); } } else { $this->createXML($level, $tpl_var, $value); @@ -241,6 +252,33 @@ class serendipity_smarty_emulator_xml extends serendipity_smarty_emulator { return true; } +/** + * Assign one or multiple template variable by reference + * + * @param string Variable name + * @param mixed Referenced variable + * @access public + * @return null + */ + function assign_by_ref($tpl_var, &$value) { + if (is_array($value)) { + foreach ($value as $key => $val) { + $this->createXML($level, $key, $val); + } + } else { + $this->createXML($level, $tpl_var, $value); + } + + return true; + } + +/** + * Create the XML output for an element + * + * @param int The intend level + * @param mixed The XML element name + * @param mixed The XML element value + */ function createXML(&$level, &$key, &$val) { if (is_numeric($key)) { $openkey = 'item index="' . $key . '"'; diff --git a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php index 20ab2b3..31b7708 100644 --- a/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php +++ b/plugins/serendipity_event_entryproperties/serendipity_event_entryproperties.php @@ -21,7 +21,7 @@ class serendipity_event_entryproperties extends serendipity_event $propbag->add('description', PLUGIN_EVENT_ENTRYPROPERTIES_DESC); $propbag->add('stackable', false); $propbag->add('author', 'Garvin Hicking'); - $propbag->add('version', '1.9'); + $propbag->add('version', '1.10'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', @@ -607,7 +607,7 @@ class serendipity_event_entryproperties extends serendipity_event $conds[] = " (ep_access.property IS NULL OR ep_access.value = 'public')"; } - if (!isset($serendipity['GET']['category']) && !isset($serendipity['GET']['adminModule']) && $event == 'frontend_fetchentries') { + if (!isset($serendipity['GET']['category']) && !isset($serendipity['GET']['adminModule']) && $event == 'frontend_fetchentries' && $addData['source'] != 'search') { $conds[] = " (ep_no_frontpage.property IS NULL OR ep_no_frontpage.value != 'true') "; $joins[] = " LEFT OUTER JOIN {$serendipity['dbPrefix']}entryproperties ep_no_frontpage ON (e.id = ep_no_frontpage.entryid AND ep_no_frontpage.property = 'ep_no_frontpage')"; -- 2.39.5