From 2e36369a38facb6ec8d1387a7d60c3ce8395c5e2 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Mon, 10 Apr 2017 15:39:43 +0000 Subject: [PATCH] wip #1336 @1.5 --- inc/ws/Controlleur/class.ws.maintenance.php | 4 +++ inc/ws/DAO/class.ws.dao.book.php | 18 +--------- inc/ws/Util/_common.php | 1 + inc/ws/Util/class.ws.util.php | 36 +++++++++++++++++++ inc/ws/Util/html5/class.ws.html5.compiler.php | 18 +--------- 5 files changed, 43 insertions(+), 34 deletions(-) create mode 100644 inc/ws/Util/class.ws.util.php diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index 90b94df42..a16fa44cc 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -1141,5 +1141,9 @@ class wsMaintenance { echo '
' . print_r($runs, true) . '
'; } + public function excel2array() { + + echo json_encode(wsUtil::excelToArray("/home/wesco/15296.xlsx")); + } } diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index ea17d75fb..90b3dcf36 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -1483,23 +1483,7 @@ class wsDAOBook extends commonDAO { $i++; } } elseif ($ext == 'xlsx') { - include_once ROOT . '/inc/ZendFramework/PHPExcel/PHPExcel.php'; - $objReader = PHPExcel_IOFactory::createReader('Excel2007'); - $objPHPExcel = $objReader->load($referencesFile); - - - foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { - if ($worksheet->getSheetState() != PHPExcel_Worksheet::SHEETSTATE_VISIBLE) { - continue; - } - $title = $worksheet->getTitle(); - if (strlen($title) == 2 && cubeCountry::getCountry($title)) { - $title = cubeCountry::getCountry($title); - } - - $worksheets[$title] = $worksheet->toArray(null, true, true); - } - $flex->addVariable('basketReferences', $worksheets, false, true, "OrderedObject"); + $flex->addVariable('basketReferences', wsUtil::excelToArray($referencesFile), false, true, "OrderedObject"); } } if (isset($xml)) { diff --git a/inc/ws/Util/_common.php b/inc/ws/Util/_common.php index 52079bc31..2a4932716 100644 --- a/inc/ws/Util/_common.php +++ b/inc/ws/Util/_common.php @@ -19,4 +19,5 @@ $__autoload['wsSVN'] = dirname(__FILE__) . '/class.ws.svn.php'; $__autoload['wsLinks'] = dirname(__FILE__) . '/class.ws.links.php'; $__autoload['wsExporter'] = dirname(__FILE__) . '/class.ws.exporter.php'; $__autoload['wsPDFConvert'] = dirname(__FILE__) . '/class.ws.pdf.convert.php'; +$__autoload['wsUtil'] = dirname(__FILE__) . '/class.ws.util.php'; ?> \ No newline at end of file diff --git a/inc/ws/Util/class.ws.util.php b/inc/ws/Util/class.ws.util.php new file mode 100644 index 000000000..d72c850a3 --- /dev/null +++ b/inc/ws/Util/class.ws.util.php @@ -0,0 +1,36 @@ +load($excelFile); + + foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { + if ($worksheet->getSheetState() != PHPExcel_Worksheet::SHEETSTATE_VISIBLE) { + continue; + } + $title = $worksheet->getTitle(); + if (strlen($title) == 2 && cubeCountry::getCountry($title)) { + $title = cubeCountry::getCountry($title); + } + + $worksheets[$title] = $worksheet->toArray(null, true, true); + } + file_put_contents($cacheFile, json_encode($worksheets)); + } + + return $worksheets; + } +} \ No newline at end of file diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index 035abd857..67c9f4182 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -978,23 +978,7 @@ class wsHTML5Compiler { if (file_exists($referencesFile)) { $ext = CubeIT_Files::getExtension($referencesFile); if ($ext == 'xlsx') { - include_once ROOT . '/inc/ZendFramework/PHPExcel/PHPExcel.php'; - $objReader = PHPExcel_IOFactory::createReader('Excel2007'); - $objPHPExcel = $objReader->load($referencesFile); - - - foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { - if ($worksheet->getSheetState() != PHPExcel_Worksheet::SHEETSTATE_VISIBLE) { - continue; - } - $title = $worksheet->getTitle(); - if (strlen($title) == 2 && cubeCountry::getCountry($title)) { - $title = cubeCountry::getCountry($title); - } - - $worksheets[$title] = $worksheet->toArray(null, true, true); - } - $this->config->basketReferences = $worksheets; + $this->config->basketReferences = wsUtil::excelToArray($referencesFile); } } } -- 2.39.5