Просмотр исходного кода

Ticket #4515 - Export/Import tools: Settings.

AntonLV 3 лет назад
Родитель
Сommit
4e4c1b8b71

+ 3 - 1
studio/classes/BxDolStudioOptions.php

@@ -219,7 +219,9 @@ class BxDolStudioOptions extends BxDol
                 'version' => bx_get_ver(),
                 'date' => date('D, d M Y H:i:s', $iNow)
             ],
-            'types' => $aListTypes
+            'date' => [
+                'types' => $aListTypes
+            ]
     	]);
 
     	header("Cache-Control: must-revalidate, post-check=0, pre-check=0");

+ 19 - 12
studio/js/options.js

@@ -46,15 +46,15 @@ BxDolStudioOptions.prototype.onSubmitted = function(sFormId, sTocken, oData) {
 };
 
 BxDolStudioOptions.prototype.import = function(oButton) {
-    this.mixActionWithValue(oButton, 'import');
+    this.mixAction(oButton, 'import');
 };
 
 BxDolStudioOptions.prototype.onImport = function(oData) {
     document.location.href = document.location.href;
 };
 
-BxDolStudioOptions.prototype.export = function(oButton, iId) {
-    this.mixActionWithValue(oButton, 'export', iId);
+BxDolStudioOptions.prototype.export = function(oButton) {
+    this.mixAction(oButton, 'export');
 };
 
 BxDolStudioOptions.prototype.onExport = function(oData) {
@@ -117,7 +117,7 @@ BxDolStudioOptions.prototype.onMixDelete = function(oData) {
     document.location.href = document.location.href;
 };
 
-BxDolStudioOptions.prototype.mixAction = function(oSource, sAction) {
+BxDolStudioOptions.prototype.mixAction = function(oSource, sAction, bConfirm) {
     var $this = this;
     var oDate = new Date();
     var aParams = {
@@ -127,14 +127,21 @@ BxDolStudioOptions.prototype.mixAction = function(oSource, sAction) {
     };
     aParams[this.sParamPrefix + '_action'] = sAction;
 
-    $.post(
-        this.sActionsUrl,
-        aParams,
-        function (oData) {
-            processJsonData(oData);
-        },
-        'json'
-    );
+    var oPerform = function() {
+        $.post(
+            this.sActionsUrl,
+            aParams,
+            function (oData) {
+                processJsonData(oData);
+            },
+            'json'
+        );
+    };
+
+    if(bConfirm != undefined && parseInt(bConfirm) == 1)
+	bx_confirm('', oPerform);
+    else
+        oPerform();
 };
 
 BxDolStudioOptions.prototype.mixActionWithValue = function(oSource, sAction, mixedValue, bConfirm) {

+ 2 - 2
studio/template/scripts/BxBaseStudioOptions.php

@@ -295,10 +295,10 @@ class BxBaseStudioOptions extends BxDolStudioOptions
             fclose($rHandle);
 
             $aContent = json_decode($sContents, true);
-            if(!is_array($aContent) || empty($aContent['meta']) || empty($aContent['types']))
+            if(!is_array($aContent) || empty($aContent['meta']) || empty($aContent['data']))
                 return ['code' => '3', 'message' => $sError];
 
-            foreach($aContent['types'] as $aType) {
+            foreach($aContent['data']['types'] as $aType) {
                 if(empty($aType['categories']) || !is_array($aType['categories']))
                     continue;