From 59d6d9971582d2b23622d39f6a7c0d8803a3d068 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 11 Apr 2012 17:16:42 +0000 Subject: [PATCH] --- inc/ws/Controlleur/class.ws.maintenance.php | 21 ++++++++++++++++++--- inc/ws/Controlleur/class.ws.services.php | 10 +++++++--- inc/ws/Controlleur/class.ws.url.php | 2 ++ inc/ws/DAO/class.ws.dao.document.php | 18 ++++++++++++------ inc/ws/Util/class.ws.links.php | 20 +++++++++++++++----- 5 files changed, 54 insertions(+), 17 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index 9ecbe623b..01f5edbfa 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -236,6 +236,21 @@ class wsMaintenance { } } + public static function copyLinks($args) { + list($from, $to) = $args; + global $core; + + $dao = new wsDAODocument($core->con); + + $dao->getLinksAndRulers($from, $fromlinks, $fromrulers); + $dao->getLinksAndRulers($to, $tolinks, $torulers); + + $tolinks = array_merge($tolinks, $fromlinks); + $torulers = array_merge($torulers, $fromrulers); + + $dao->setLinksAndRulers($to, $tolinks, $torulers, 'Copy links from #' . $from . ' to #' . $to,$core->user->utilisateur_id); + } + public static function importBooks($oldBooks) { global $core, $allTrads, $signatures; // Importe les fluidbooks @@ -502,9 +517,9 @@ class wsMaintenance { } `rm -rf $f`; } - - if(!file_exists($dir)){ - mkdir($dir,0777,true); + + if (!file_exists($dir)) { + mkdir($dir, 0777, true); } } } diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php index 2342df2ce..581a188c6 100644 --- a/inc/ws/Controlleur/class.ws.services.php +++ b/inc/ws/Controlleur/class.ws.services.php @@ -1,6 +1,7 @@ setPath(CONVERTER_PATH); $pdftk->setManualArg($args); $pdftk->execute(); - // Debug - fb($pdftk->command); - fb($pdftk->output); // Return the url of the resulting pdf http::redirect($destURL); exit; } + public function proxy() { + ob_end_clean(); + fb(netHttp::quickGet($_GET['u'], 'php://output')); + $this->outputXML=false; + } + } ?> \ No newline at end of file diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 697efe73e..63de0c21e 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -556,6 +556,8 @@ html{height:100%}' . "\n"; public static function exportLinksAsExcel($args) { global $core; + cubePHP::neverStop(); + $book_id = $args[1]; $time = $args[2]; diff --git a/inc/ws/DAO/class.ws.dao.document.php b/inc/ws/DAO/class.ws.dao.document.php index c1a6e5a3b..fc147da9b 100644 --- a/inc/ws/DAO/class.ws.dao.document.php +++ b/inc/ws/DAO/class.ws.dao.document.php @@ -33,7 +33,7 @@ class wsDAODocument extends commonDAO { } } - public function restoreLinksVersion($book_id, $update, $user=0) { + public function restoreLinksVersion($book_id, $update, $user = 0) { $daoBook = new wsDAOBook($this->con); $pages = $daoBook->getPagesOfBookAt($book_id, $update); @@ -109,10 +109,16 @@ class wsDAODocument extends commonDAO { return implode("\n", $log); } - public function setLinksAndRulers($book_id, $links, $rulers, $comments='', $user=0) { + public function setLinksAndRulers($book_id, $links, $rulers, $comments = '', $user = 0) { $daoBook = new wsDAOBook($this->con); - $pages = $daoBook->getPagesOfBook($book_id); - + $pages = $daoBook->getPagesOfBook($book_id,false); + + if (is_array($links)) { + $links = json_encode($links); + } + if (is_array($rulers)) { + $rulers = json_encode($rulers); + } $links = json_decode($links, false); $rulers = json_decode($rulers, false); @@ -256,7 +262,7 @@ class wsDAODocument extends commonDAO { krsort($links); - foreach($links as $document_id=>$l){ + foreach ($links as $document_id => $l) { wsLinks::setDocumentLinks($document_id, json_encode($l), json_encode(array()), 0, 'Import from Fluidbook V1', TIME); } @@ -265,7 +271,7 @@ class wsDAODocument extends commonDAO { $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\''); } - public function getLinksAndRulers($book_id, &$links, &$rulers, $time=null) { + public function getLinksAndRulers($book_id, &$links, &$rulers, $time = null) { return wsLinks::getLinksAndRulers($book_id, $links, $rulers, $time); } diff --git a/inc/ws/Util/class.ws.links.php b/inc/ws/Util/class.ws.links.php index 96f24c946..33138201b 100644 --- a/inc/ws/Util/class.ws.links.php +++ b/inc/ws/Util/class.ws.links.php @@ -13,7 +13,7 @@ class wsLinks { public static function linksToExcel($links, $rulers, $pages = null) { - $cols = array('document_id' => __('Document'), 'document_page' => __('Page du document'), + $cols = array( 'page' => __('Page de la publication'), 'left' => __('x'), 'top' => __('y'), 'width' => __('Largeur'), 'height' => __('Hauteur'), 'type' => __('Type'), 'to' => __('Destination'), 'target' => __('Cible'), 'infobulle' => __('Infobulle'), 'numerotation' => __('Numérotation'), @@ -23,9 +23,19 @@ class wsLinks { 'interactive' => __('Interactivité'), 'video_service' => __('Webvideo : service'), 'display_area' => __('Afficher le lien au rollover'), 'extra' => __('Paramètre supplémentaire'), - 'alternative'=>__('Alternative') + 'alternative' => __('Alternative') ); + new PHPExcel(); + + $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_memcache; + $cacheSettings = array('memcacheServer' => 'localhost', + 'memcachePort' => 11211, + 'cacheTime' => 600 + ); + PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings); + + $xls = new PHPExcel(); $s = $xls->setActiveSheetIndex(0); $s->setTitle('Links'); @@ -73,7 +83,7 @@ class wsLinks { $s = $xls->createSheet(); $s->setTitle('Rulers'); - $rcols = array('document_id', 'document_page', 'page', 'type', 'pos'); + $rcols = array( 'page', 'type', 'pos'); $i = 0; // Labels foreach ($rcols as $id) { @@ -143,7 +153,7 @@ class wsLinks { public static function getDocumentVersionLinks($document_id, $time) { global $core; - $r = $core->con->select('SELECT * FROM document_links_versions WHERE document_id=' . $document_id.' AND `update`<='.$time .' ORDER BY `update` DESC LIMIT 1'); + $r = $core->con->select('SELECT * FROM document_links_versions WHERE document_id=' . $document_id . ' AND `update`<=' . $time . ' ORDER BY `update` DESC LIMIT 1'); return self::_recordToLinks($r); } @@ -178,7 +188,7 @@ class wsLinks { $rulers = array(); fb($time); - + foreach ($documents as $d) { if (is_null($time)) { $lr = self::getDocumentLastLinks($d); -- 2.39.5