X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-theme_import.php;h=fd04a906852bc0ab7962e1408d913f10a8abfc65;hp=0e3ec8ebdf00ebdc71830dfe519cda755855ae45;hb=20741b93fd58620af677a7f1039ffd16ea6ec689;hpb=8a9324b2d931f54f54f4319fd7234910af77012c diff --git a/inc/modules/admin/what-theme_import.php b/inc/modules/admin/what-theme_import.php index 0e3ec8ebdf..fd04a90685 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 = PATH."theme/".$dir."/"."theme.php"; - - // Test it... - if (($dir != ".") && ($dir != "..") && (file_exists($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; - } -} -closedir($handle); +$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 // 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 - $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' LIMIT 1", - array($unix), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { - // Free memory - SQL_FREERESULT($result); - - // Already installed - $FOUND = "".ADMIN_THEME_ALREADY_INSTALLED.""; - } - else - { + if (!ifThemeExists($unix)) { // Theme not installed - $FOUND = "
- - -
"; - } - - // Add row - $OUT .= " - ".$unix." - ".$THEMES['theme_name'][$key]." - - ".$THEMES['theme_author'][$key]." - - - ".$THEMES['theme_url'][$key]." - - v".$THEMES['theme_ver'][$key]." - - ".$FOUND." - -\n"; - $SW = 3 - $SW; -} -if (empty($OUT)) -{ - // No themes found??? - $OUT .= " - - ".LOAD_TEMPLATE("admin_settings_saved", true, ADMIN_NO_THEMES_FOUND)." - -\n"; -} -define('__THEME_LIST', $OUT); + $formContent = loadTemplate('admin_import_theme_form', true, $unix); + } // END - if + + // 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 .= loadTemplate('admin_import_theme_none', true, displayMessage('{--ADMIN_NO_THEMES_FOUND--}', true)); +} // END - if // Load template -LOAD_TEMPLATE("admin_theme_import"); +loadTemplate('admin_import_theme', false, $OUT); -// +// [EOF] ?>