From: vincent@cubedesigners.com Date: Tue, 7 Mar 2017 17:20:10 +0000 (+0000) Subject: done #1192 @2.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=66ddd27a75b27108c27a858579820dc64e539f93;p=cubeextranet.git done #1192 @2.5 --- diff --git a/fluidbook/tools/fwstk/.idea/workspace.xml b/fluidbook/tools/fwstk/.idea/workspace.xml index 66c3b0f19..b6a1204be 100644 --- a/fluidbook/tools/fwstk/.idea/workspace.xml +++ b/fluidbook/tools/fwstk/.idea/workspace.xml @@ -6,9 +6,7 @@ - - - + @@ -48,8 +46,8 @@ - - + + @@ -149,6 +147,9 @@ + + + @@ -177,9 +178,6 @@ - - - @@ -932,7 +930,7 @@ - + - + + + + + + + + + - - - - - - - - - - - + + @@ -1267,6 +1266,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1333,8 +1382,8 @@ - - + + diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index 2018b41f4..d4cadc4e8 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -839,6 +839,17 @@ class wsAjax extends cubeAjax { global $core; $book_id = $args[1]; + $fname = $_FILES['file']['name']; + $ext = files::getExtension($fname); + if ($ext == 'xlsx') { + self::_importLinksAsExcel($book_id, $args); + } else if ($ext == 'txt') { + self::_importLinksAsAutobookmarkText($book_id, $args); + } + } + + protected static function _importLinksAsExcel($book_id) { + global $core; $xls = new PHPExcel(); $reader = new PHPExcel_Reader_Excel2007(); $xls = $reader->load($_FILES['file']['tmp_name']); @@ -849,6 +860,15 @@ class wsAjax extends cubeAjax { $dao->setLinksAndRulers($book_id, json_encode($links), json_encode($rulers), 'Import from excel', $core->user->utilisateur_id); } + protected function _importLinksAsAutobookmarkText($book_id) { + global $core; + + wsLinks::getLinksFromAutobookmarkText(file_get_contents($_FILES['file']['tmp_name']), $links, $rulers); + + $dao = new wsDAODocument($core->con); + $dao->setLinksAndRulers($book_id, json_encode($links), json_encode($rulers), 'Import from fwstk text export', $core->user->utilisateur_id); + } + public static function offsetLinks($args, &$x) { global $core; $book_id = $args[1]; diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index b498cc57f..ea17d75fb 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -1231,7 +1231,7 @@ class wsDAOBook extends commonDAO { $assetId = 'link_datas_i_' . md5($link['image']); if (isset($imagesassets[$assetId])) { - + } else { if (file_exists($workingFile)) { if ($link['page'] <= 1) { @@ -1489,6 +1489,9 @@ class wsDAOBook extends commonDAO { 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); diff --git a/inc/ws/Util/class.ws.links.php b/inc/ws/Util/class.ws.links.php index 950f1fe36..fa1f5a5b8 100644 --- a/inc/ws/Util/class.ws.links.php +++ b/inc/ws/Util/class.ws.links.php @@ -317,4 +317,34 @@ class wsLinks { } } + public static function getLinksFromAutobookmarkText($txt, &$links, &$rulers) { + $links = array(); + $rulers = array(); + + $lines = explode("\n", $txt); + + $protocols = array('mailto' => 3, 'custom' => 7, 'cart' => 12, 'pagelabel' => 26); + + foreach ($lines as $line) { + $line = trim($line); + if ($line == '') { + continue; + } + if (strpos('#', $line) === 0) { + continue; + } + $target = $numerotation = ''; + list($page, $left, $top, $width, $height, $type, $to) = explode(';', $line); + if ($type <= 2) { + $target = '_blank'; + } elseif ($type == 5) { + $numerotation = 'physical'; + } + + $links[] = array('page' => $page, + 'left' => $left, 'top' => $top, 'width' => $width, 'height' => $height, 'rot' => '', + 'type' => $type, 'to' => $to, 'target' => $target, + 'infobulle' => '', 'numerotation' => $numerotation, 'display_area' => '1'); + } + } } \ No newline at end of file