+// Get version from name
+function THEME_GET_VERSION ($name) {
+ global $cacheArray, $_CONFIG;
+
+ // Default version "number"
+ $cver = "-.-";
+
+ // Is the cache entry there?
+ if (isset($cacheArray['themes']['theme_ver'][$name])) {
+ // Get the version from cache
+ $cver = $cacheArray['themes']['theme_ver'][$name];
+
+ // Count up
+ $_CONFIG['cache_hits']++;
+ } elseif (GET_EXT_VERSION("cache") != "0.1.8") {
+ // Load version from database
+ $result = SQL_QUERY_ESC("SELECT theme_ver FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' LIMIT 1",
+ array($name), __FILE__, __LINE__);
+
+ // Entry found?
+ if (SQL_NUMROWS($result) == 1) {
+ // Fetch data
+ list($cver) = SQL_FETCHROW($result);
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+ }
+
+ // Return version
+ return $cver;
+}
+
+// Get id from theme
+function THEME_GET_ID ($name) {
+ global $cacheArray, $_CONFIG;
+
+ // Default id
+ $id = 0;
+
+ // Is the cache entry there?
+ if (isset($cacheArray['themes']['id'][$name])) {
+ // Get the version from cache
+ $id = $cacheArray['themes']['id'][$name];
+
+ // Count up
+ $_CONFIG['cache_hits']++;
+ } elseif (GET_EXT_VERSION("cache") != "0.1.8") {
+ // 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($name), __FILE__, __LINE__);
+
+ // Entry found?
+ if (SQL_NUMROWS($result) == 1) {
+ // Fetch data
+ list($id) = SQL_FETCHROW($result);
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+ }
+
+ // Return id
+ return $id;
+}
+
+// Checks wether a theme is found in db
+function THEME_CHECK_EXIST ($name) {
+ // Get theme and is it not nul?
+ return (THEME_GET_ID($name) > 0);
+}
+
+// Checks if a theme is active
+function THEME_IS_ACTIVE ($name) {
+ global $cacheArray, $_CONFIG;
+
+ // Default is nothing active
+ $active = false;
+
+ // Is the cache entry there?
+ if (isset($cacheArray['themes']['theme_active'][$name])) {
+ // Get the version from cache
+ $active = ($cacheArray['themes']['theme_active'][$name] == "Y");
+
+ // Count up
+ $_CONFIG['cache_hits']++;
+ } elseif (GET_EXT_VERSION("cache") != "0.1.8") {
+ // Check if current theme is already imported or not
+ $result = SQL_QUERY_ESC("SELECT theme_active FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' AND theme_active='Y' LIMIT 1",
+ array($name), __FILE__, __LINE__);
+
+ // Is the theme active and installed?
+ $active = (SQL_NUMROWS($result) == 1);
+
+ // Free result
+ SQL_FREERESULT($result);
+ }
+
+ // Return result
+ return $active;
+}
+
+// Gets current human-readable theme name
+function GET_CURR_THEME_NAME () {
+ global $cacheArray, $_CONFIG;
+
+ // Get the Uni* name
+ $name = GET_CURR_THEME();
+
+ // Is the cache entry there?
+ if (isset($cacheArray['themes']['theme_name'][$name])) {
+ // Get the version from cache
+ $name = $cacheArray['themes']['theme_name'][$name];
+
+ // Count up
+ $_CONFIG['cache_hits']++;
+ } elseif (GET_EXT_VERSION("cache") != "0.1.8") {
+ // Check if current theme is already imported or not
+ $result = SQL_QUERY_ESC("SELECT theme_name FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' AND theme_name='Y' LIMIT 1",
+ array($name), __FILE__, __LINE__);
+
+ // Is the theme active and installed?
+ $name = (SQL_NUMROWS($result) == 1);
+
+ // Free result
+ SQL_FREERESULT($result);
+ }
+
+ // Return name
+ return $name;
+}
+