From 979ab9a013acd0c1e468dde134d28420935e3e40 Mon Sep 17 00:00:00 2001 From: shish Date: Sun, 17 Feb 2008 09:25:49 +0000 Subject: [PATCH] don't load custom themes without base themes git-svn-id: file:///home/shish/svn/shimmie2/trunk@722 7f39781d-f577-437e-ae19-be835c7a54ca --- core/util.inc.php | 9 +++++++++ index.php | 13 +++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/core/util.inc.php b/core/util.inc.php index a2a0aaa6..34aa782a 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -308,6 +308,15 @@ function array_add($array, $element) { return $array; } +function array_contains($array, $target) { + foreach($array as $element) { + if($target == $element) { + return true; + } + } + return false; +} + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * Event API * diff --git a/index.php b/index.php index ed60063c..6684ba38 100644 --- a/index.php +++ b/index.php @@ -49,12 +49,21 @@ require_once "themes/$_theme/layout.class.php"; require_once "themes/$_theme/themelet.class.php"; $themelets = glob("ext/*/theme.php"); -$custom_themelets = glob("themes/$_theme/*.theme.php"); -if($custom_themelets) $themelets = array_merge($themelets, $custom_themelets); foreach($themelets as $filename) { require_once $filename; } +$custom_themelets = glob("themes/$_theme/*.theme.php"); +if($custom_themelets) { + foreach($custom_themelets as $filename) { + $basename = str_replace($filename, "themes/$_theme/", ""); + $basename = str_replace($basename, ".theme.php", ""); + if(array_contains($themelets, "ext/$basename/theme.php")) { + require_once $filename; + } + } +} + // start the page generation waterfall $page = new Page();