Browse Source

DO NOT USE!!!!!
fix remove theme

causefx 7 years ago
parent
commit
5117e7c3e7
2 changed files with 43 additions and 11 deletions
  1. 21 10
      api/functions/theme-functions.php
  2. 22 1
      js/functions.js

+ 21 - 10
api/functions/theme-functions.php

@@ -55,16 +55,27 @@ function removeTheme($theme)
 			return false;
 		}
 	}
-	if ($GLOBALS['themeInstalled'] !== '') {
-		$installedTheme = $GLOBALS['themeInstalled'];
-		if ($installedTheme == $name) {
-			updateConfig(
-				array(
-					'themeInstalled' => '',
-					'themeVersion' => '',
-				)
-			);
+	if ($GLOBALS['installedThemes'] !== '') {
+		$installedThemes = explode('|', $GLOBALS['installedThemes']);
+		foreach ($installedThemes as $k => $v) {
+			$themes = explode(':', $v);
+			$installedThemesList[$themes[0]] = $themes[1];
+		}
+		if (isset($installedThemesList[$name])) {
+			$installedThemesNew = '';
+			foreach ($installedThemesList as $k => $v) {
+				if ($k !== $name) {
+					if ($installedThemesNew == '') {
+						$installedThemesNew .= $k . ':' . $v;
+					} else {
+						$installedThemesNew .= '|' . $k . ':' . $v;
+					}
+				}
+			}
 		}
+	} else {
+		$installedThemesNew = '';
 	}
-	return true;
+	updateConfig(array('installedThemes' => $installedThemesNew));
+	return 'Success!@!' . $installedThemesNew;
 }

+ 22 - 1
js/functions.js

@@ -1088,6 +1088,27 @@ function removePlugin(plugin=null){
         console.error("Organizr Function: Connection Failed");
     });
 }
+function removeTheme(theme=null){
+    if(theme == null){
+        return false;
+    }
+    message('Removing Plugin',theme.name,activeInfo.settings.notifications.position,"#FFF","success","5000");
+    theme.downloadList = pluginFileList(theme.files,theme.github_folder,'plugins');
+    organizrAPI('POST','api/?v1/theme/remove',{theme:theme}).success(function(data) {
+        var html = JSON.parse(data);
+        if(html.data.substr(0, 7) == 'Success'){
+            var newThemes = html.data.split('!@!');
+            activeInfo.settings.misc.installedThemes = newThemes[1];
+            loadMarketplace('plugins');
+            message(theme.name+' Removed','Please Click Customize Above to refresh',activeInfo.settings.notifications.position,"#FFF","success","5000");
+        }else{
+            message('Remove Failed',html.data,activeInfo.settings.notifications.position,"#FFF","warning","10000");
+        }
+    }).fail(function(xhr) {
+        message('Remove Failed',theme.name,activeInfo.settings.notifications.position,"#FFF","warning","5000");
+        console.error("Organizr Function: Connection Failed");
+    });
+}
 function installPlugin(plugin=null){
     if(plugin == null){
         return false;
@@ -1127,7 +1148,7 @@ function installTheme(theme=null){
             message('Install Failed',html.data,activeInfo.settings.notifications.position,"#FFF","warning","10000");
         }
     }).fail(function(xhr) {
-        message('Install Failed',plugin.name,activeInfo.settings.notifications.position,"#FFF","warning","5000");
+        message('Install Failed',theme.name,activeInfo.settings.notifications.position,"#FFF","warning","5000");
         console.error("Organizr Function: Connection Failed");
     });
 }