X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-theme_import.php;h=c3665f9881913dd9487e66fb3db205dca33b5389;hp=d075327bfec9d4ec9a051f00afbc4add61b7ed84;hb=0f3a135204757cc8750262871c8e62c42300acb4;hpb=143e78d4231adddd9e706cbf55ec5dd8c1651890 diff --git a/inc/modules/admin/what-theme_import.php b/inc/modules/admin/what-theme_import.php index d075327bfe..c3665f9881 100644 --- a/inc/modules/admin/what-theme_import.php +++ b/inc/modules/admin/what-theme_import.php @@ -1,7 +1,7 @@ "); + displayMessage($message); } // END - if // Initialize array -$THEMES = array( - '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_ver' => array(), // Version number of theme +$themes = array( + '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(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 - include($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_version'][] = $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; -foreach ($THEMES['theme_unix'] as $key => $unix) { +$OUT = ''; +foreach ($themes['theme_unix'] as $key => $unix) { + // Already installed is default + $formContent = '
{%message,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_import_theme_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"; - - // Switch color - $SW = 3 - $SW; -} + // Prepare content + $content = array( + 'unix' => $unix, + '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], + 'form_content' => $formContent + ); + + // Add row template + $OUT .= loadTemplate('admin_import_theme_row', true, $content); +} // END - foreach if (empty($OUT)) { // No themes found??? - $OUT .= " - - ".LOAD_TEMPLATE("admin_settings_saved", true, ADMIN_NO_THEMES_FOUND)." - -\n"; + $OUT .= loadTemplate('admin_import_theme_none', true, displayMessage('{--ADMIN_NO_THEMES_FOUND--}', true)); } // END - if -define('__THEME_LIST', $OUT); // Load template -LOAD_TEMPLATE("admin_theme_import"); +loadTemplate('admin_import_theme', false, $OUT); -// +// [EOF] ?>