From: vincent@cubedesigners.com Date: Tue, 8 Sep 2020 16:48:17 +0000 (+0000) Subject: wait #3879 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b1f55ede9372f7618c8e9b353e301ce452b6e297;p=cubeextranet.git wait #3879 @0.5 --- diff --git a/inc/commons/class.common.tools.php b/inc/commons/class.common.tools.php index 71f3829ea..157dbc233 100644 --- a/inc/commons/class.common.tools.php +++ b/inc/commons/class.common.tools.php @@ -1420,6 +1420,36 @@ class commonTools die(json_encode($res)); } + public static function convertXlsxToKeyValueJson($args) + { + new PHPExcel(); + + $reader = new PHPExcel_Reader_Excel2007(); + $xls = $reader->load($_FILES['file']['tmp_name']); + + $res = []; + foreach ($xls->getAllSheets() as $sheet) { + $lines = $sheet->toArray(); + foreach ($lines as $line) { + if (null === $line[0]) { + continue; + } + $k = trim($line[0]); + if (!$k) { + continue; + } + $v = trim($line[1]); + $res[$k] = $v; + } + break; + } + + ob_end_clean(); + + header('Content-Type: application/json'); + die(json_encode($res)); + } + public static function excelTranslation($args) { $name = $_REQUEST['name'] ?? 'translations'; @@ -1443,6 +1473,7 @@ class commonTools exit; } + public static function articles($args) { global $core;