diff --git a/module_index.json b/module_index.json index 6e5c45d..6012e4a 100755 --- a/module_index.json +++ b/module_index.json @@ -85,7 +85,7 @@ "version": "0.1.6", "author": "Starbeamrainbowlabs", "description": "The module everyone has been waiting for! Adds a web based gui that lets mods change the wiki settings.", - "lastupdate": 1569768162, + "lastupdate": 1571530165, "optional": false, "extra_data": [] }, @@ -155,7 +155,7 @@ "version": "0.3", "author": "Starbeamrainbowlabs", "description": "Adds a theme gallery page and optional automatic theme updates. Contacts a remote server, where IP addresses are stored in automatic server logs for security and attack mitigation purposes.", - "lastupdate": 1570464845, + "lastupdate": 1571530718, "optional": false, "extra_data": [] }, @@ -267,7 +267,7 @@ "version": "0.9.4", "author": "Starbeamrainbowlabs", "description": "Adds a pair of actions (login and checklogin) that allow users to login. You need this one if you want your users to be able to login.", - "lastupdate": 1557573174, + "lastupdate": 1570468766, "optional": false, "extra_data": [] }, diff --git a/modules/feature-guiconfig.php b/modules/feature-guiconfig.php index 9ebc95f..e914f63 100644 --- a/modules/feature-guiconfig.php +++ b/modules/feature-guiconfig.php @@ -39,7 +39,7 @@ register_module([ if(module_exists("feature-user-table")) $content .= "

Looking to manage $settings->sitename's users? Try the user table instead!

\n"; if(module_exists("feature-theme-gallery")) - $content .= "

Want to change $settings->sitename's theme? Try the theme gallery! ($settings->sitename will make a HTTP request to fetch the theme gallery from a remote location)

"; + $content .= "

Want to change $settings->sitename's theme? Try the theme gallery!

"; $content .= "

You're currently running Pepperminty Wiki $version+" . substr($commit, 0, 7) . ".

\n"; $content .= "

Actions

"; diff --git a/modules/feature-theme-gallery.php b/modules/feature-theme-gallery.php index ede0a1a..7c6fd50 100644 --- a/modules/feature-theme-gallery.php +++ b/modules/feature-theme-gallery.php @@ -68,8 +68,10 @@ register_module([ return $sorter->compare($a->name, $b->name); }); - $content = "

Theme Gallery

+ + $content = "

Theme Gallery

+

$settings->sitename is currently using ".(strlen($settings->css_theme_autoupdate_url) > 0 ? "an external" : "the internal")." theme".(strlen($settings->css_theme_autoupdate_url) > 0 ? " (reset to the internal default theme)" : "").".

\n"; @@ -92,8 +94,16 @@ register_module([ }); + /** + * @api {get} ?action=theme-gallery-select&theme-selector=theme-id Set the site theme + * @apiName ThemeGallerySelect + * @apiGroup Utility + * @apiPermission Moderator + * + * @apiParam {string} theme-selector The id of the theme to switch into, or 'default-internal' to switch back to the internal theme. + */ add_action("theme-gallery-select", function() { - global $env, $settings; + global $env, $settings, $guiConfig; if(!$env->is_admin) { $errorMessage = "

You don't have permission to change $settings->sitename's theme.

\n"; @@ -109,6 +119,15 @@ register_module([ exit(page_renderer::render_main("No theme selected - Error - $settings->sitename", "

Oops! Looks like you didn't select a theme. Try going back and selecting one.

")); } + if($_GET["theme-selector"] === "default-internal") { + $settings->css_theme_gallery_selected_id = $guiConfig->css_theme_gallery_selected_id->default; + $settings->css_theme_gallery_selected_id = $guiConfig->css_theme_gallery_selected_id->default; + $settings->css = $guiConfig->css->default; + + exit(page_renderer::render_main("Theme reset - Theme Gallery - $settings->sitename", "

$settings->sitename's theme has been reset to the internal theme.

+

Go to the homepage.

")); + } + // Set the new theme's id $settings->css_theme_gallery_selected_id = $_GET["theme-selector"]; $gallery_urls = explode(" ", $settings->css_theme_gallery_index_url);