require($INC);
}
-// Create a selection box with installed and activated themes
-function generateThemeSelectionBox ($mod, $act, $wht, $result) {
+// Create a selection box with installed and activated themes or all if admin
+function generateThemeSelectionBox () {
+ // Init variables and fill them if set
+ $what = '';
+ $mod = getModule();
+ if (isWhatSet()) {
+ $what = getWhat();
+ } // END - if
+
// Construction URL
- $formAction = "{!URL!}/modules.php?module=".$mod;
- if (!empty($act)) $formAction .= "&action=".$act;
- if (!empty($wht)) $formAction .= "&what=".$wht;
+ $formAction = "{!URL!}/modules.php?module=" . $mod;
+ if (!empty($what)) $formAction .= "&what=" . $what;
// Initialize array
$themesArray = array(
'theme_name' => array() // Title
);
+ // Only activated themes for the user
+ $add = " WHERE `theme_active`='Y'";
+
+ // Do we have admin?
+ if (IS_ADMIN()) $add = '';
+
+ // Select all themes we want
+ $result = SQL_QUERY("SELECT `theme_path`, `theme_name` FROM `{!_MYSQL_PREFIX!}_themes`".$add." ORDER BY `theme_name` ASC", __FILE__, __LINE__);
+
// Load all themes
while ($content = SQL_FETCHARRAY($result)) {
- // Load it's theme.php file
+ // Construct relative include file name
$INC = sprintf("theme/%s/theme.php", SQL_ESCAPE($content['theme_path']));
+
+ // Load it's theme.php file if found
if (isIncludeReadable($INC)) {
// And save all data in array
loadInclude($INC);
} // END - if
} // END - while
- // Sort whole array by title
- array_pk_sort($themesArray, array('theme_name'));
+ // Free the result
+ SQL_FREERESULT($result);
// Construct selection form for the box template
$OUT = '';
if ($num_themes > 1) {
// If more than 1 is installed output selection box
- $act = '';
- if (isActionSet()) $act = getAction();
- $OUT = generateThemeSelectionBox('index', $act, getWhat(), $result_themes);
+ $OUT = generateThemeSelectionBox();
} elseif (($num_themes == 1) || ((!IS_ADMIN()) && ($num_themes == 0))) {
// If there's only one just output it's name
define('__THEME_NAME', getCurrentThemeName());
$OUT = LOAD_TEMPLATE('admin_settings_saved', true, "<div class=\"admin_note\">{--ADMIN_NO_THEME_INSTALLED_WARNING--}</div>");
}
-// Free memory
-SQL_FREERESULT($result_themes);
-
// Load final box template
LOAD_TEMPLATE('theme_select_box', false, $OUT);
if ($num_themes > 1) {
// If more than 1 is installed output selection box
- $act = ''; $wht = '';
- if (isActionSet()) $act = getAction();
- if (isWhatSet()) $wht = getWhat();
- $OUT = generateThemeSelectionBox('login', $act, $wht, $result_themes);
+ $OUT = generateThemeSelectionBox();
} elseif (($num_themes == 1) || ((!IS_ADMIN()) && ($num_themes == 0))) {
// If there's only one just output it's name
define('__THEME_NAME', getCurrentThemeName());
$OUT = LOAD_TEMPLATE('admin_settings_saved', true, "<div class=\"admin_note\">{--ADMIN_NO_THEME_INSTALLED_WARNING--}</div>");
}
-// Free memory
-SQL_FREERESULT($result_themes);
-
// Load final box template
LOAD_TEMPLATE('theme_select_box', false, $OUT);