]> _ Git - cubeextranet.git/commitdiff
wait #3587 @1
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 14 Apr 2020 12:02:22 +0000 (12:02 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 14 Apr 2020 12:02:22 +0000 (12:02 +0000)
inc/commons/class.common.tools.php

index 27bad914f0a10e4c2b27abe13923576a402e9f53..5029516d366f6f406c730df2521157373986862f 100644 (file)
@@ -1419,6 +1419,29 @@ class commonTools
         die(json_encode($res));
     }
 
+    public static function excelTranslation($args)
+    {
+        $name = $_REQUEST['name'] ?? 'translations';
+
+        $str = json_decode($_REQUEST['str']);
+        $data = [];
+        foreach ($str as $item) {
+            $data[] = [$item, ''];
+        }
+
+        $tmp = CubeIT_Files::tempnam();
+        CubeIT_Excel::simple($name, $data, ['Original text', 'Translation'], $tmp);
+
+        $n = $name . '.xlsx';
+
+        header('Content-Disposition: attachment; filename=' . $n);
+        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+        ob_end_clean();
+        readfile($tmp);
+        unlink($tmp);
+        exit;
+    }
+
     public static function quizUpdater($args)
     {
         global $core;
@@ -1461,7 +1484,7 @@ class commonTools
         $template = new ZipArchive();
         $template->open($temp);
 
-        $data = simplexml_load_string($uploaded->getFromName('data.xml'), "SimpleXMLElement", LIBXML_NOERROR |  LIBXML_ERR_NONE);
+        $data = simplexml_load_string($uploaded->getFromName('data.xml'), "SimpleXMLElement", LIBXML_NOERROR | LIBXML_ERR_NONE);
         $quizTitle = (string)$data->xpath('/quiz/title')[0];
 
         // Replace assets