From fd533eeeac73931f155e019245984deba3f4b594 Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Wed, 3 Aug 2005 14:18:10 +0000 Subject: [PATCH] Allow to link additionel_themes to templates directory, iterating multiple subdirectories. --- docs/NEWS | 5 +++++ include/functions.inc.php | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index 67d83dd..2b938ec 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,11 @@ Version 0.9 () ------------------------------------------------------------------------ + * Make template directory allow to contain subdirectories with more + templates. This allows you to symbolically link the "additional_themes" + CVS directory within your templates path, just like you can do + with the "additional_plugins" directory already (garvinhicking) + * Allow UTF-8 recoding using mb_* functions (Tadashi Jokagi) * Allow to switch charsets ("Native" / "UTF-8"). (garvinhicking) diff --git a/include/functions.inc.php b/include/functions.inc.php index d061672..d926ff3 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -84,14 +84,24 @@ function serendipity_formatTime($format, $time, $useOffset = true) { return serendipity_mb('ucfirst', serendipity_strftime($cache[$format], (int)$time, $useOffset)); } -function serendipity_fetchTemplates() { +function serendipity_fetchTemplates($dir = '') { global $serendipity; - $dir = opendir($serendipity['serendipityPath'] . $serendipity['templatePath']); - while (($file = readdir($dir)) !== false) { - if (is_dir($serendipity['serendipityPath'] . $serendipity['templatePath'] . $file) && !ereg('^(\.|CVS)', $file) && !file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $file . '/inactive.txt') && file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $file . '/info.txt')) { - $rv[] = $file; + + $cdir = opendir($serendipity['serendipityPath'] . $serendipity['templatePath'] . $dir); + $rv = array(); + while (($file = readdir($cdir)) !== false) { + if (is_dir($serendipity['serendipityPath'] . $serendipity['templatePath'] . $dir . $file) && !ereg('^(\.|CVS)', $file) && !file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $dir . $file . '/inactive.txt')) { + if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $dir . $file . '/info.txt')) { + $rv[] = $dir . $file; + } else { + $temp = serendipity_fetchTemplates($dir . $file . '/'); + if (count($temp) > 0) { + $rv = array_merge($rv, $temp); + } + } } } + closedir($cdir); natcasesort($rv); return $rv; } -- 2.39.5