]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-themes.php
Huge rewrite:
[mailer.git] / inc / modules / member / what-themes.php
index 1c52abe930cdc2f4ac5c313e7148baaaca7baa35..e485499aa361b7f0bb374b7b695fdeb7976d8938 100644 (file)
@@ -76,17 +76,20 @@ $THEMES = array(
 );
 
 // Read directory "themes"
-$handle = opendir(constant('PATH')."theme/") or app_die(__FILE__, __LINE__, "Cannot read themes dir!");
-while ($entry = readdir($handle)) {
-       // Construct absolute theme.php file name
-       $INC = sprintf("theme/%s/theme.php", $entry);
+$includes = getArrayFromDirectory('theme/', '', false, true, array('css', 'images'));
 
-       if ((!isDirectory($entry)) && (isIncludeReadable($INC)) && (isThemeActive($entry))) {
+// Walk through all entries and add it
+foreach ($includes as $INC) {
+       // Get directory from it
+       $dir = basename(dirname($INC));
+
+       // Is the theme active, then include it
+       if (isThemeActive($dir)) {
                // Found a valid directory so let's load it's theme.php file
                loadInclude($INC);
 
                // Add found theme to array
-               $THEMES['theme_unix'][]   = $entry;
+               $THEMES['theme_unix'][]   = $dir;
                $THEMES['theme_name'][]   = $GLOBALS['theme_data']['name'];
                $THEMES['theme_author'][] = $GLOBALS['theme_data']['author'];
                $THEMES['theme_email'][]  = $GLOBALS['theme_data']['email'];
@@ -98,11 +101,8 @@ while ($entry = readdir($handle)) {
 // Remove last theme data
 unset($GLOBALS['theme_data']);
 
-// Close directory
-closedir($handle);
-
 // Sort array by Uni* name
-array_pk_sort($THEMES, array("theme_name"));
+array_pk_sort($THEMES, array('theme_name'));
 
 // Generate output lines for the template
 $OUT = ''; $SW = 2;