|
@@ -17,6 +17,12 @@
|
|
|
if (!defined('SMF'))
|
|
|
die('No direct access...');
|
|
|
|
|
|
+/**
|
|
|
+ * Gets a single theme's info.
|
|
|
+ *
|
|
|
+ * @param int $id The theme ID to get the info from.
|
|
|
+ * @return array The theme info as an array.
|
|
|
+ */
|
|
|
function get_single_theme($id)
|
|
|
{
|
|
|
global $smcFunc, $modSettings;
|
|
@@ -71,6 +77,13 @@ function get_single_theme($id)
|
|
|
return $single;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Loads and returns all installed themes.
|
|
|
+ *
|
|
|
+ * Stores all themes on $context['themes'] for easier use.
|
|
|
+ * @param bool $enable_only false by default for getting all themes. If true the function will return all themes that are currently enable.
|
|
|
+ * @return array With the theme's IDs as key.
|
|
|
+ */
|
|
|
function get_all_themes($enable_only = false)
|
|
|
{
|
|
|
global $modSettings, $context, $smcFunc;
|
|
@@ -132,6 +145,13 @@ function get_all_themes($enable_only = false)
|
|
|
return $context['themes'];
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Reads an .xml file and returns the data as an array
|
|
|
+ *
|
|
|
+ * Removes the entire theme if the .xml file couldn't be found or read.
|
|
|
+ * @param string $path The absolute path to the xml file.
|
|
|
+ * @return array An array with all the info extracted from the xml file.
|
|
|
+ */
|
|
|
function get_theme_info($path)
|
|
|
{
|
|
|
global $sourcedir, $forum_version, $txt, $scripturl, $context;
|
|
@@ -215,6 +235,13 @@ function get_theme_info($path)
|
|
|
return $xml_data;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Inserts a theme's data to the DataBase.
|
|
|
+ *
|
|
|
+ * Ends execution with fatal_lang_error() if an error appears.
|
|
|
+ * @param array $to_install An array containing all values to be stored into the DB.
|
|
|
+ * @return int The newly created theme ID.
|
|
|
+ */
|
|
|
function theme_install($to_install = array())
|
|
|
{
|
|
|
global $smcFunc, $context, $themedir, $themeurl, $modSettings;
|
|
@@ -379,6 +406,13 @@ function theme_install($to_install = array())
|
|
|
return $id_theme;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Removes a directory from the themes dir.
|
|
|
+ *
|
|
|
+ * This is a recursive function, it will call itself if there are subdirs inside the main directory.
|
|
|
+ * @param string $path The absolute path to the directory to be removed
|
|
|
+ * @return bool true when success, false on error.
|
|
|
+ */
|
|
|
function remove_dir($path)
|
|
|
{
|
|
|
if (empty($path))
|
|
@@ -403,6 +437,12 @@ function remove_dir($path)
|
|
|
rmdir($path);
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Removes a theme from the DB, includes all possible places where the theme might be used.
|
|
|
+ *
|
|
|
+ * @param int $themeID The theme ID
|
|
|
+ * @return bool true when success, false on error.
|
|
|
+ */
|
|
|
function remove_theme($themeID)
|
|
|
{
|
|
|
global $smcFunc, $modSetting;
|