X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-theme_import.php;h=f0ce2817cf4e141072914e34c9af1b17c67f90f4;hp=cc1cc05f9edc4b1fd40dac9208ecc9f0d577f6e6;hb=e2148142f8b1a8f40fd6e7ca32185569c5a9083e;hpb=cca98f57dff720b174d21d071cee8303462485d7 diff --git a/inc/modules/admin/what-theme_import.php b/inc/modules/admin/what-theme_import.php index cc1cc05f9e..f0ce2817cf 100644 --- a/inc/modules/admin/what-theme_import.php +++ b/inc/modules/admin/what-theme_import.php @@ -1,7 +1,7 @@ "); + loadTemplate('admin_settings_saved', false, $message); } // END - if // Initialize array @@ -91,79 +102,67 @@ $THEMES = array( ); // Read directory "themes" -$handle = opendir(PATH."theme/") or mxchange_die("Cannot read themes dir!"); -while ($dir = readdir($handle)) { - // Construct absolute theme.php file name - $theme = sprintf("%stheme/%s/theme.php", PATH, $dir); - - // Test it... - if (($dir != ".") && ($dir != "..") && (FILE_READABLE($theme))) { - // Found a valid directory so let's load it's theme.php file - require($theme); - - // Add found theme to array - $THEMES['theme_unix'][] = $dir; - $THEMES['theme_name'][] = $THEME_NAME; - $THEMES['theme_author'][] = $THEME_AUTHOR; - $THEMES['theme_email'][] = $THEME_EMAIL; - $THEMES['theme_url'][] = $THEME_URL; - $THEMES['theme_ver'][] = $THEME_VERSION; - } // END - if +$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)); + + // Load include file + loadInclude($inc); + + // Add found theme to array + $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_ver'][] = $GLOBALS['theme_data']['version']; } // END - while -// 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; +$OUT = ''; $SW = 2; foreach ($THEMES['theme_unix'] as $key => $unix) { + // Already installed is default + $formContent = '
' . sprintf(getMessage('ADMIN_THEME_ALREADY_INSTALLED'), $unix) . '
'; + // Check if current theme is already imported or not - if (THEME_CHECK_EXIST($unix)) { - // Already installed - $FOUND = "
".ADMIN_THEME_ALREADY_INSTALLED."
"; - } else { + if (!ifThemeExists($unix)) { // Theme not installed - $FOUND = "
- - -
"; - } + $formContent = loadTemplate('admin_theme_import_form', true, $unix); + } // END - if - // Add row - $OUT .= " - ".$unix." - ".$THEMES['theme_name'][$key]." - - ".$THEMES['theme_author'][$key]." - - - ".$THEMES['theme_url'][$key]." - - v".$THEMES['theme_ver'][$key]." - - ".$FOUND." - -\n"; + // Prepare content + $content = array( + 'sw' => $SW, + 'unix' => $unix, + 'name' => $THEMES['theme_name'][$key], + 'email' => $THEMES['theme_email'][$key], + 'author' => $THEMES['theme_author'][$key], + 'link' => generateDerefererUrl($THEMES['theme_url'][$key]), + 'url' => $THEMES['theme_url'][$key], + 'version' => $THEMES['theme_ver'][$key], + 'form' => $formContent + ); + + // Add row template + $OUT .= loadTemplate('admin_theme_import_row', true, $content); // Switch color $SW = 3 - $SW; -} +} // END - foreach if (empty($OUT)) { // No themes found??? - $OUT .= " - - ".LOAD_TEMPLATE("admin_settings_saved", true, ADMIN_NO_THEMES_FOUND)." - -\n"; + $OUT .= loadTemplate('admin_theme_import_none', true, loadTemplate('admin_settings_saved', true, getMessage('ADMIN_NO_THEMES_FOUND'))); } // END - if -define('__THEME_LIST', $OUT); // Load template -LOAD_TEMPLATE("admin_theme_import"); +loadTemplate('admin_theme_import', false, $OUT); -// +// [EOF] ?>