From 28d1affe0bb8086112744f8008ea232a7d631dc5 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 27 Jan 2012 18:44:16 +0000 Subject: [PATCH] --- .htaccess | 4 ++ inc/ws/Controlleur/class.ws.ajax.php | 14 ++++- inc/ws/Controlleur/class.ws.url.php | 51 ++++++++++++++++--- inc/ws/DAO/class.ws.dao.book.php | 21 ++++++-- inc/ws/Metier/class.ws.book.parametres.php | 9 +++- .../Util/packager/class.ws.packager.html.php | 7 ++- inc/ws/Util/packager/class.ws.packager.php | 17 +++++-- inc/ws/Util/packager/class.ws.packager.v1.php | 8 +-- inc/ws/prepend.php | 1 + 9 files changed, 108 insertions(+), 24 deletions(-) diff --git a/.htaccess b/.htaccess index 5f9dff0ad..004b8e3c1 100644 --- a/.htaccess +++ b/.htaccess @@ -40,6 +40,10 @@ AddCharset UTF-8 log RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/fluidbook.js$ fluidbook/compile/fluidbook.js [L] RewriteRule ^viewer/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/final/$1/$4 [L] + RewriteRule ^viewer1/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.html$ viewer1/$1_$2_$3/index [L] + RewriteRule ^viewer1/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/fluidbook.js$ fluidbook/compile/fluidbook.js [L] + RewriteRule ^viewer1/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/finalv1/$1/$4 [L] + RewriteRule ^vieweru/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.html$ vieweru/$1_$2_$3/index [L] RewriteRule ^vieweru/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.swf$ fluidbook/compile/_unprotected/index.swf [L] RewriteRule ^vieweru/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/player.swf$ fluidbook/compile/_unprotected/player.swf [L] diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index 6bd3efdb6..ac06a442d 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -41,7 +41,7 @@ class wsAjax extends cubeAjax { $data['code_postal'] = $entreprise->code_postal; $data['ville'] = $entreprise->ville; $data['pays'] = $entreprise->pays; - $data['site']=$entreprise->site; + $data['site'] = $entreprise->site; $data['grade'] = 0; $daoClient = new commonDAOClient($core->con); try { @@ -206,6 +206,16 @@ class wsAjax extends cubeAjax { $book = $dao->setStatus($book_id, 1); } + if ($version == 'v2') { + $version = 'html'; + } else if ($version == 'online') { + if ($book->parametres->version == '1') { + $version = 'v1'; + } elseif ($book->parametres->version == '2') { + $version = 'html'; + } + } + if (!wsDroits::admin()) { if ($book->status < 1) { $popup = commonAjax::form('downbook/' . $book_id . '/' . $version, __('Téléchargement du Fluidbook'), wsUrl::valideDownload($book_id, $version), __('Télécharger'), 2, '', '', true); @@ -411,7 +421,7 @@ class wsAjax extends cubeAjax { $datas['code_postal'] = $_POST['code_postal']; $datas['ville'] = $_POST['ville']; $datas['pays'] = $_POST['pays']; - $datas['site']=$_POST['site']; + $datas['site'] = $_POST['site']; if ($_POST['rs'] == '') { $datas['nom'] = $_POST['prenom'] . ' ' . $_POST['nom']; } else { diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index abe198ad7..96a073ff2 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -163,10 +163,19 @@ class wsUrl { public static function contextBookDownload($id, $droits) { global $core; + $chooseVersion = wsDroits::admin(); + + if ($chooseVersion) { + $default = ' (' . __('Default') . ')'; + } else { + $default = ''; + } + $versions = array(); - $versions['html'] = array('title' => __('Version online'), 'icon' => cubeMedia::silk('page_world.png')); - if (wsDroits::admin()) { + $versions['online'] = array('title' => __('Version online') . $default, 'icon' => cubeMedia::silk('page_world.png')); + if ($chooseVersion) { $versions['v1'] = array('title' => __('Version online') . ' - V1', 'icon' => cubeMedia::silk('page_white_world.png')); + $versions['v2'] = array('title' => __('Version online') . ' - V2', 'icon' => cubeMedia::silk('page_white_world.png')); } $versions['win-exe'] = array('title' => __('Version offline') . ' - ' . __('Executable Windows'), 'icon' => cubeMedia::silk('application_view_tile.png')); $versions['win-ins'] = array('title' => __('Version offline') . ' - ' . __('Installeur Auto-executable Windows'), 'icon' => cubeMedia::silk('application_view_tile.png')); @@ -220,9 +229,11 @@ class wsUrl { if (wsDroits::admin()) { $viewers = array('viewer' => array('title' => __('Version Flash'), 'icon' => cubeMedia::image(IMG . '/flash.png')), - 'viewerh' => array('title' => __('Version HTML5'), 'icon' => cubeMedia::image(IMG . '/html5.png')), - 'vieweru' => array('title' => __('Version Flash') . ' (' . __('debuggage') . ')', 'icon' => cubeMedia::image(IMG . '/flashbug.png')), - 'viewerhu' => array('title' => __('Version HTML5') . ' (' . __('debuggage') . ')', 'icon' => cubeMedia::image(IMG . '/html5bug.png'))); + 'viewerh' => array('title' => __('Version HTML5'), 'icon' => cubeMedia::image(IMG . '/html5.png')), + 'vieweru' => array('title' => __('Version Flash') . ' (' . __('debuggage') . ')', 'icon' => cubeMedia::image(IMG . '/flashbug.png')), + 'viewerhu' => array('title' => __('Version HTML5') . ' (' . __('debuggage') . ')', 'icon' => cubeMedia::image(IMG . '/html5bug.png')), + 'viewer1' => array('title' => __('Version 1'), 'icon' => cubeMedia::image(IMG . '/flash.png')) + ); } $res = '
'; @@ -681,6 +692,26 @@ html{height:100%}' . "\n"; exit; } + public static function viewer1($args) { + $args = cubePage::getArgs($args); + + $wmode = isset($args[1]) ? $args[1] : ''; + + $e = explode('_', $args[0]); + $newurl = null; + if (count($e) == 2 || $e[2] < TIME - 10) { + $e[2] = TIME; + http::redirect(SITE_PATH . 'viewer1/' . implode('_', $e) . '/' . $wmode); + exit; + } + + $book_id = $e[0]; + + $wmode = $wmode != '' ? $wmode : 'default'; + + echo self::commonViewer($book_id, $e[1], false, $wmode, $newurl, '1'); + } + public static function viewer($args) { $args = cubePage::getArgs($args); @@ -704,7 +735,7 @@ html{height:100%}' . "\n"; echo self::commonViewer($book_id, $e[1], false, $wmode, $newurl); } - public static function commonViewer($book_id, $hash, $standalone = false, $wmode = 'default', $fps = false) { + public static function commonViewer($book_id, $hash, $standalone = false, $wmode = 'default', $fps = false, $version = 2) { if (!defined('MINIMIZE_JS')) { define('MINIMIZE_JS', false); } @@ -722,6 +753,12 @@ html{height:100%}' . "\n"; global $meta; global $jsvar; + if ($version == 2) { + $flashVersion = '10.0.22'; + } else { + $flashVersion = '8'; + } + cubePage::swfobject(2); $dao = new wsDAOBook($core->con); @@ -783,7 +820,7 @@ html{height:100%}' . "\n"; $res.='} else if(isBadMobile()) {' . "\n"; $res.="\t" . $redirectPDF . "\n"; $res.='} else {' . "\n"; - $res .= "\t" . 'swfobject.embedSWF("index.swf", "fluidbook", "100%", "100%", "10.0.22",'; + $res .= "\t" . 'swfobject.embedSWF("index.swf", "fluidbook", "100%", "100%", "' . $flashVersion . '",'; $res .= '"", ' . json_encode($fv) . ','; $res .= '{"allowScriptAccess":"always","quality":"high","scale":"noscale","wmode":getWmode(),"allowFullScreen":"true"},{"bgcolor":"#' . $theme->parametres->loadingBackColor . '"}'; $res .= ');' . "\n"; diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 9d66d59e0..29493c3ab 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -698,12 +698,23 @@ class wsDAOBook extends commonDAO { } public function compile($book_id, $version = 3, $complete = false) { - if ($version == 3) { - return $this->compile3($book_id, $complete); - } + + $this->compile3($book_id, $complete); + $this->compile1($book_id); + $this->touchCompile($book_id); } + public function compile1($book_id) { + $finalDir = WS_BOOKS . '/finalv1/' . $book_id . '/'; + $packager = new wsPackagerV1($book_id, $finalDir, false); + $packager->makePackage(false); + + mkdir($finalDir,0777,true); + + fb('compile1'); + } + public function compile3($book_id, $complete) { $res = ''; @@ -896,8 +907,8 @@ class wsDAOBook extends commonDAO { $flexLight->addVariable('fwidth', round($size[0], 4), false, true, 'Number'); $flexLight->addVariable('fheight', round($size[1], 4), false, true, 'Number'); $flexLight->addVariable('pagesInDatas', $complete, false, true, 'Boolean'); - $flex->addVariable('index', $index, false, true, 'JSONObject', false,false); - $flex->addVariable('textes', $textes, false, true, 'JSONObject', false,false); + $flex->addVariable('index', $index, false, true, 'JSONObject', false, false); + $flex->addVariable('textes', $textes, false, true, 'JSONObject', false, false); $rasterized = array(); $sizes = array(); diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index b389d7552..3f4886574 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -16,11 +16,12 @@ class wsBookParametres extends wsParametres { if (is_null($this->parent)) { return; } + $this->fields['version'] = array('type' => 'combo', 'default' => '2', 'editable' => true, 'label' => __('Version'), 'datas' => array('1' => '1', '2' => '2'), 'grade' => 3); $this->fields['title'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __("Titre de la publication")); $this->fields['url_link'] = array('type' => 'text', 'default' => 'http://', 'editable' => true, 'label' => __("URL du lien de retour au site")); $this->fields['signature'] = array('type' => 'combo', 'default' => '1', 'editable' => true, 'label' => __('Signature'), 'grade' => 3, 'datas' => wsDroits::getSignatures()); $this->forms['important'] = array('label' => __('Description de la publication'), - 'fieldsnames' => array('title', 'url_link', 'signature')); + 'fieldsnames' => array('version', 'title', 'url_link', 'signature')); // . // . $this->fields['friend'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Envoyer à un ami')); @@ -217,6 +218,12 @@ class wsBookParametres extends wsParametres { $this->fields['widgetEnd'] = array('type' => 'integer', 'default' => 8, 'editable' => true, 'label' => __('Page de fin'), 'grade' => 3); $this->forms['widget'] = array('label' => __('Widget') . ' (' . __('Mini Fluidbook') . ')', 'fieldsnames' => array('widget', 'widgetCover', 'widgetSize', 'widgetQuality', 'widgetStart', 'widgetEnd')); + + $this->fields['extras'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Extras'), 'grade' => 5); + $this->fields['v1SWF'] = array('type' => 'freefile', 'default' => '', 'editable' => true, + 'label' => __('Index.swf spécifique'), 'grade' => 5, 'fileFilter' => $swfFilter); + $this->forms['v1'] = array('label' => __('Options spécifiques au fluidbook version 1'), + 'fieldsnames' => array('extras', 'v1SWF')); } } diff --git a/inc/ws/Util/packager/class.ws.packager.html.php b/inc/ws/Util/packager/class.ws.packager.html.php index 63a26b99c..c4623b4ca 100644 --- a/inc/ws/Util/packager/class.ws.packager.html.php +++ b/inc/ws/Util/packager/class.ws.packager.html.php @@ -4,8 +4,8 @@ class wsPackagerHTML extends wsPackager { protected $origHTML; - public function __construct($book_id) { - parent::__construct($book_id); + public function __construct($book_id, $vdir, $whole) { + parent::__construct($book_id, $vdir, $whole); $this->version = 'html'; } @@ -152,6 +152,9 @@ class wsPackagerHTML extends wsPackager { } public function prepareHTML5() { + if (!$this->whole) { + return; + } $dest = $this->vdir . 'm'; mkdir($dest, 0777, true); diff --git a/inc/ws/Util/packager/class.ws.packager.php b/inc/ws/Util/packager/class.ws.packager.php index e6a15a508..9cccaa660 100644 --- a/inc/ws/Util/packager/class.ws.packager.php +++ b/inc/ws/Util/packager/class.ws.packager.php @@ -13,6 +13,7 @@ class wsPackager { protected $daoBook; protected $zip; protected $workingDir; + protected $whole = true; public static function package($book_id, $version, $zip = true) { global $packager; @@ -35,12 +36,14 @@ class wsPackager { return $packager->makePackage($zip); } - public function __construct($book_id) { + public function __construct($book_id, $vdir = null, $whole = true) { global $core; $this->book_id = $book_id; + $this->vdir = $vdir; $this->dir = WS_SHM . '/packager/' . $book_id . '/'; + $this->whole = $whole; if (!file_exists($this->dir)) { mkdir($this->dir, 0777, true); @@ -135,6 +138,9 @@ class wsPackager { } protected function zip($zipfile = null) { + if (!$this->whole) { + return; + } $url = $this->getURLBase('zip'); $final = $this->getPathBase('zip'); $rename = false; @@ -161,7 +167,10 @@ class wsPackager { } protected function initTempDir() { - $this->vdir = $this->dir . $this->version . '/'; + if (is_null($this->vdir)) { + $this->vdir = $this->dir . $this->version . '/'; + } + fb($this->vdir); $this->cleanVdir(); mkdir($this->vdir . '/data', 0777, true); } @@ -191,7 +200,9 @@ class wsPackager { } public function __destruct() { - $this->cleanVdir(); + if ($this->whole) { + $this->cleanVdir(); + } } } diff --git a/inc/ws/Util/packager/class.ws.packager.v1.php b/inc/ws/Util/packager/class.ws.packager.v1.php index 14fc72112..4f0d7c839 100644 --- a/inc/ws/Util/packager/class.ws.packager.v1.php +++ b/inc/ws/Util/packager/class.ws.packager.v1.php @@ -2,8 +2,8 @@ class wsPackagerV1 extends wsPackagerHTML { - public function __construct($book_id) { - parent::__construct($book_id); + public function __construct($book_id,$vdir,$whole) { + parent::__construct($book_id,$vdir,$whole); $this->version = 'v1'; } @@ -87,8 +87,8 @@ class wsPackagerV1 extends wsPackagerHTML { } $one->addChild('page', $link['page']); - $one->addChild('linkTo', $link['to']); $one->addChild('linkType', $link['type']); + $one->addChild('linkTo', $link['to']); $one->addChild('startX', $link['left']); $one->addChild('endX', $link['left'] + $link['width']); $one->addChild('startY', $link['top']); @@ -249,7 +249,7 @@ class wsPackagerV1 extends wsPackagerHTML { $n = explode(',', $this->book->numerotation); $keys = array_keys($n, $page); if (count($keys)) { - return $keys[0]; + return $keys[0]+1; } return $default; } diff --git a/inc/ws/prepend.php b/inc/ws/prepend.php index 2df598ad6..0e6ea5844 100644 --- a/inc/ws/prepend.php +++ b/inc/ws/prepend.php @@ -6,6 +6,7 @@ $core->url->register('maintenance', 'maintenance', '^maintenance(.*)$', array('w $core->url->register('editor', 'editor', '^editor/(.*)$', array('wsUrl', 'editor')); $core->url->register('restoreLinks', 'restoreLinks', '^restoreLinks/(.*)$', array('wsUrl', 'restoreLinks')); $core->url->register('viewer', 'viewer', '^viewer/(.*)$', array('wsUrl', 'viewer')); +$core->url->register('viewer1', 'viewer1', '^viewer1/(.*)$', array('wsUrl', 'viewer1')); $core->url->register('vieweru', 'vieweru', '^vieweru/(.*)$', array('wsUrl', 'vieweru')); $core->url->register('viewerp', 'viewerp', '^viewerp/(.*)$', array('wsUrl', 'viewerp')); $core->url->register('viewerh', 'viewerh', '^viewerh/(.*)$', array('wsUrl', 'viewerh')); -- 2.39.5