X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fmember%2Fwhat-themes.php;h=53b047c7669687bbb78f19effa9eaa79baf8db2b;hp=95188d411442cb2193bc81e97983f8c2a652f775;hb=6c0abc9f643c69610fe87be0ddb1a5dab95c6d39;hpb=5071030af40e69ca4284642f44758964e18f5be8 diff --git a/inc/modules/member/what-themes.php b/inc/modules/member/what-themes.php index 95188d4114..53b047c766 100644 --- a/inc/modules/member/what-themes.php +++ b/inc/modules/member/what-themes.php @@ -1,7 +1,7 @@ array(), // Unix name from filesystem - 'theme_name' => array(), // Title - 'theme_author' => array(), // Theme author's name - 'theme_email' => array(), // Author's email address - 'theme_url' => array(), // URL were you can download it from - 'theme_ver' => array(), // Version number of theme + 'theme_unix' => array(), // Unix name from filesystem + 'theme_name' => array(), // Title + 'theme_author' => array(), // Theme author's name + 'theme_email' => array(), // Author's email address + 'theme_url' => array(), // URL were you can download it from + 'theme_version' => array(), // Version number of theme ); // 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')); + +// Walk through all entries and add it +foreach ($includes as $inc) { + // Get directory from it + $dir = basename(dirname($inc)); - if ((!isDirectory($entry)) && (isIncludeReadable($INC)) && (isThemeActive($entry))) { + // 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); + loadInclude($inc); // Add found theme to array - $THEMES['theme_unix'][] = $entry; - $THEMES['theme_name'][] = $GLOBALS['theme_data']['name']; - $THEMES['theme_author'][] = $GLOBALS['theme_data']['author']; - $THEMES['theme_email'][] = $GLOBALS['theme_data']['email']; - $THEMES['theme_url'][] = $GLOBALS['theme_data']['url']; - $THEMES['theme_ver'][] = $GLOBALS['theme_data']['version']; + $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']; + $THEMES['theme_url'][] = $GLOBALS['theme_data']['url']; + $THEMES['theme_version'][] = $GLOBALS['theme_data']['version']; } // END - if } // END - while -// Close directory -closedir($handle); +// Remove last theme data +unset($GLOBALS['theme_data']); // 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; +$OUT = ''; foreach ($THEMES['theme_unix'] as $key => $unix) { $default = ''; - if (getSession('mxchange_theme') == $unix) $default = ' selected="selected"'; - - // Add row - $OUT .= " - - - - ".$THEMES['theme_name'][$key]." - - ".$THEMES['theme_author'][$key]." - - - ".$THEMES['theme_url'][$key]." - - v".$THEMES['theme_ver'][$key]." -\n"; - $SW = 3 - $SW; -} + if (getCurrentTheme() == $unix) $default = ' selected="selected"'; + + // Prepare content + $content = array( + 'unix' => $unix, + 'default' => $default, + 'theme_name' => $THEMES['theme_name'][$key], + 'theme_email' => $THEMES['theme_email'][$key], + 'theme_author' => $THEMES['theme_author'][$key], + 'theme_url' => $THEMES['theme_url'][$key], + 'theme_version' => $THEMES['theme_version'][$key] + ); + + // Load row template + $OUT .= loadTemplate('member_themes_row', true, $content); +} // END - foreach if (empty($OUT)) { // No themes found??? - $OUT = " - - ".LOAD_TEMPLATE('admin_settings_saved', true, getMessage('MEMBER_NO_THEMES_FOUND'))." + $OUT = ' + + ' . loadTemplate('admin_settings_saved', true, '{--MEMBER_NO_THEMES_FOUND--}') . ' -\n"; -} -define('__THEME_LIST', $OUT); +'; +} // END - if // Load template -LOAD_TEMPLATE("member_themes"); +loadTemplate('member_themes', false, $OUT); -// +// [EOF] ?>