-// Load all active designs (or all if admin)
-$whereStatement = ''; $OUT = '';
-if (!IS_ADMIN()) $whereStatement = " WHERE theme_active='Y'";
-$result_themes = SQL_QUERY("SELECT theme_path FROM `{!_MYSQL_PREFIX!}_themes`".$whereStatement, __FILE__, __LINE__);
-$num_themes = SQL_NUMROWS($result_themes);
+if ((!isExtensionActive('theme')) && (!isAdmin())) {
+ loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('theme'));
+ return;
+} // END - if
+
+// Get total num
+if (isAdmin()) {
+ // Load only active designs for user
+ $num_themes = countSumTotalData('Y', 'themes', 'id', 'theme_active', true);
+} else {
+ // Load all themes for admin
+ $num_themes = countSumTotalData('', 'themes', 'id', '', true);
+}