]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 13 Mar 2012 18:57:00 +0000 (18:57 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 13 Mar 2012 18:57:00 +0000 (18:57 +0000)
inc/commons/class.common.tools.php
inc/ws/Controlleur/class.ws.url.php
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Metier/class.ws.book.parametres.php
inc/ws/Util/html5/class.ws.html5.compiler.php
inc/ws/Util/html5/class.ws.html5.links.php
js/tube.js

index f2de47cadfcb1a70619075b25fc7106148a77eeb..b34dc5db2424d6065e477cfd8340f763b5330cd9 100644 (file)
@@ -118,7 +118,7 @@ class commonTools {
                        $video.=' onended="this.play();"';
                }
                if ($autoplay) {
-                       $video.=' data-autoplay="autoplay"';
+                       $video.=' autoplay="autoplay"';
                }
                if (($displayPoster || $ios) && isset($poster)) {
                        $video.=' poster="' . $web . 'video.jpg"';
index 959978fe1fb9428fda2b9ff2f3bfecf5f9bc93c8..5a97c0e3306d7289136c6ad6802cd82c970d231d 100644 (file)
@@ -704,10 +704,6 @@ html{height:100%}' . "\n";
 \r
                $e = explode('_', $args[0]);\r
 \r
-\r
-\r
-\r
-\r
                $newurl = null;\r
                if (count($e) == 2 || $e[2] < TIME - 10) {\r
                        $e[2] = TIME;\r
@@ -715,13 +711,8 @@ html{height:100%}' . "\n";
                        exit;\r
                }\r
 \r
-\r
-\r
                $book_id = $e[0];\r
 \r
-\r
-\r
-\r
                $wmode = $wmode != '' ? $wmode : 'default';\r
 \r
                echo self::commonViewer($book_id, $e[1], false, $wmode, $newurl, '1');\r
@@ -777,8 +768,18 @@ html{height:100%}' . "\n";
                cubePage::swfobject(2);\r
 \r
                $dao = new wsDAOBook($core->con);\r
-\r
                $book = $dao->selectById($book_id);\r
+\r
+               if(!wsDroits::admin()){\r
+               if ($book->parametres->redirectDemo != '') {\r
+                       http::redirect($book->parametres->redirectDemo);\r
+                       exit; \r
+               }\r
+               if ($book->parametres->disableDemo) {\r
+                       commonDroits::error();\r
+               }\r
+               }\r
+\r
                if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) {\r
                        commonDroits::error();\r
                }\r
index 92040871b0dcc18700025be3678095474812e414..228ef89dd9353c397fe49529c51e9813d94100f3 100644 (file)
@@ -434,8 +434,8 @@ class wsDAOBook extends commonDAO {
 \r
        public function setStatus($book_id, $status) {\r
                $c = $this->con->openCursor('books');\r
-               if($status<2){\r
-                       $c->tache=0;\r
+               if ($status < 2) {\r
+                       $c->tache = 0;\r
                }\r
                $c->status = $status;\r
                $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
@@ -715,10 +715,11 @@ class wsDAOBook extends commonDAO {
        }\r
 \r
        public function compile($book_id, $version = 3, $complete = false) {\r
-               $this->compile3($book_id, $complete);\r
+               $res=$this->compile3($book_id, $complete);\r
                $this->compile1($book_id);\r
 \r
                $this->touchCompile($book_id);\r
+               return $res;\r
        }\r
 \r
        public function compile1($book_id) {\r
@@ -1272,12 +1273,20 @@ class wsDAOBook extends commonDAO {
                        $args .= '-' . $range['end'];\r
                }\r
 \r
+               $hash = sha1($args);\r
+\r
                $args .= ' output ' . $finalPDF;\r
 \r
-               $pdftk = new cubeCommandLine('pdftk');\r
-               $pdftk->setPath(CONVERTER_PATH);\r
-               $pdftk->setManualArg($args);\r
-               $pdftk->execute();\r
+               $cached = WS_BOOKS . '/pdf/' . $hash . '.pdf';\r
+               if (file_exists($cached)) {\r
+                       copy($cached, $finalPDF);\r
+               } else {\r
+                       $pdftk = new cubeCommandLine('pdftk');\r
+                       $pdftk->setPath(CONVERTER_PATH);\r
+                       $pdftk->setManualArg($args);\r
+                       $pdftk->execute();\r
+                       copy($finalPDF, $cached);\r
+               }\r
        }\r
 \r
 }\r
index 1f71ea14379c1619ba2b1909bbaeb4fb66df1b8f..76169f43613d317a03cda505fac0f8e95e82377a 100644 (file)
@@ -105,7 +105,7 @@ class wsBookParametres extends wsParametres {
                $this->fields['pdfComplex'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Téchargement de PDF avancé'), "hint" => __("Permet à l'utilisateur de sélectionner les pages qu'il souhaite télécharger"), 'grade' => 3);\r
                $this->fields['offlineExport'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Téléchargement des versions offline'), "hint" => __('Valable si le téléchargement avancé est activé'), 'grade' => 3);\r
                $this->forms['pdf'] = array('label' => __('Fonction de téléchargement'),\r
-                       'fieldsnames' => array('pdf','pdfName', 'pdfComplex', 'offlineExport'));\r
+                       'fieldsnames' => array('pdf', 'pdfName', 'pdfComplex', 'offlineExport'));\r
                // .\r
                $this->fields['zoomMode'] = array('type' => 'combo', 'default' => '0', 'editable' => true, 'label' => __("Mode de zoom"), 'grade' => 5,\r
                        'datas' => array(__('Normal') => '0',\r
@@ -230,11 +230,16 @@ class wsBookParametres extends wsParametres {
                $this->forms['widget'] = array('label' => __('Widget') . ' (' . __('Mini Fluidbook') . ')',\r
                        'fieldsnames' => array('widget', 'widgetCover', 'widgetSize', 'widgetQuality', 'widgetStart', 'widgetEnd'));\r
 \r
-               $this->fields['extras'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Extras'), 'grade' => 5);\r
+               $this->fields['extras'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Extras'), 'grade' => 3);\r
                $this->fields['v1SWF'] = array('type' => 'freefile', 'default' => '', 'editable' => true,\r
                        'label' => __('Index.swf spécifique'), 'grade' => 5, 'fileFilter' => $swfFilter);\r
                $this->forms['v1'] = array('label' => __('Options spécifiques au fluidbook version 1'),\r
                        'fieldsnames' => array('extras', 'v1SWF'));\r
+\r
+               $this->fields['disableDemo'] =  array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Désactiver le lien de démo'), 'grade' => 5);\r
+               $this->fields['redirectDemo'] =  array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Rediriger le lien de démo vers'), 'grade' => 5);\r
+               $this->forms['demo'] = array('label' => __('Lien de démo'),\r
+                       'fieldsnames' => array('disableDemo', 'redirectDemo'));\r
        }\r
 \r
 }\r
index f267c8a34432d818edf5009c73ffb983d9817e9d..220347d933925bae4bba8bbd4ba609632e9d047e 100644 (file)
@@ -7,6 +7,7 @@ class wsHTML5Compiler {
        protected static $jsFiles = array(
                'js/libs/cube/fb.js',
                'js/libs/modernizr.js',
+               'js/libs/flashdetect.js',
                'js/libs/jquery/jquery.js',
                'js/libs/jquery/jquery.transform.js',
                'js/libs/jquery/jquery.mousewheel.js',
@@ -418,12 +419,23 @@ class wsHTML5Compiler {
                }
                foreach ($this->pages as $page => $infos) {
                        foreach (self::$resolutions as $r) {
-                               copy(WS_DOCS . '/' . $infos['document_id'] . '/html/h' . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/p' . $page . '.jpg');
-                               copy(WS_DOCS . '/' . $infos['document_id'] . '/html/t' . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/t' . $page . '.jpg');
+                               $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/h' . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/p' . $page . '.jpg');
+                               $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/t' . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/t' . $page . '.jpg');
                        }
-                       copy(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', $this->vdir . '/data/thumbnails/p' . $page . '.jpg');
+                       $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', $this->vdir . '/data/thumbnails/p' . $page . '.jpg');
                }
        }
+       
+       protected function copy($s,$t){
+               if(!file_exists($s)){
+                       return;
+               }
+               if(file_exists($t) && filemtime($t)>=filemtime($s) && filesize($s)==filesize($t)){
+                       return;
+               }
+               
+               copy($s,$t);
+       }
 
        protected function writePage($page) {
                $res = '';
@@ -1023,7 +1035,7 @@ class wsHTML5Compiler {
 
        public function copyLinkFile($source, $dest, $video = false) {
                $origDir = WS_BOOKS . '/working/' . $this->book_id . '/';
-               $types = array('mp4', 'ogv', 'webm', 'jpg');
+               $types = array('flv', 'mp4', 'ogv', 'webm', 'jpg');
                if ($video) {
                        wsTools::encodeWebVideos($origDir . $source, null, true);
                        $e = explode('.', $source);
@@ -1046,6 +1058,9 @@ class wsHTML5Compiler {
                                if (!file_exists(dirname($d))) {
                                        mkdir(dirname($d), 0777, true);
                                }
+                               if(file_exists($d) && filemtime($d)>=filemetime($s) && filesize($d)==$filesize($s)){
+                                       continue;
+                               }
                                copy($s, $d);
                        }
                }
index 25cf6880634663e62c06b05456f35a63d1698525..4abb2296cd4561426e95fb76f144e9fc8f237b16 100644 (file)
@@ -85,7 +85,7 @@ class wsHTML5Link {
                return '';
        }
 
-       public function copyExternalFile($file, $video=false) {
+       public function copyExternalFile($file, $video = false) {
                $this->compiler->copyLinkFile($file, 'data/links/', $video);
        }
 
@@ -102,7 +102,7 @@ class wsHTML5Link {
                return '';
        }
 
-       public static function getUniversalLocation($loc, $css=false) {
+       public static function getUniversalLocation($loc, $css = false) {
                $datas = parse_url($loc);
 
                if (isset($datas['scheme']) && !is_null($datas['scheme'])) {
@@ -197,27 +197,26 @@ class videoLink extends wsHTML5Link {
                $e = explode('.', $file);
                $ext = array_pop($e);
                $basename = implode('.', $e);
-               $w = round($this->width*$this->compiler->getCssScale());
-               $h = round($this->height*$this->compiler->getCssScale());
+               $w = round($this->width * $this->compiler->getCssScale());
+               $h = round($this->height * $this->compiler->getCssScale());
 
-               $res = '<video width="' . $w . '" height="' . $h . '"';
+               $res = '<div class="videoContainer">';
+               $res.='<video width="' . $w . '" height="' . $h . '"';
                if ($this->video_auto_start) {
                        $res.=' autoplay="autoplay"';
                }
-               if ($this->video_controls) {
-                       $res.=' controls="controls"';
+               $res.=' controls="controls"';
+               if (!$this->video_controls) {
+                       $res.=' onplay="hideControls(this)"';
                }
                if ($this->video_loop) {
-                       $res.=' loop="loop"';
+                       $res.=' onended="this.play();"';
                }
                if (!$this->video_sound_on) {
                        $res.=' audio="muted"';
                }
                $res.=' poster="data/links/' . $basename . '.jpg"';
                $res.='>';
-
-
-
                $this->copyExternalFile($this->to, true);
                $types = array('webm' => 'video/webm; codecs="vp8, vorbis"', 'ogv' => 'video/ogg; codecs="theora, vorbis"', 'mp4' => '');
                foreach ($types as $ext => $type) {
@@ -226,13 +225,13 @@ class videoLink extends wsHTML5Link {
                        }
                        $res.='<source src="' . wsHTML5Link::getUniversalLocation($basename . '.' . $ext) . '"' . $type . ' />';
                }
-               $flashvars = array('video' => wsHTML5Link::getUniversalLocation($basename . '.mp4'),
+               $flashvars = array('video' => '../'.wsHTML5Link::getUniversalLocation($file),
                        'poster' => wsHTML5Link::getUniversalLocation($basename . '.jpg'),
                        'controls' => $this->video_controls == '1',
                        'autoPlay' => $this->video_auto_start == '1',
                        'loop' => $this->video_loop);
-               $res.=cubeMedia::flashObject('swf/video.swf', $w, $h, $flashvars, 'swfplayer-' . $basename, '', 9, '#ffffff', '', 'true', 'noscale', 'normal');
                $res.='</video>';
+               $res.=cubeMedia::flashObject('swf/video.swf', $w, $h, $flashvars, 'swfplayer-' . $basename, '', 9, '#ffffff', '', 'true', 'noscale', 'normal');
                return $res;
        }
 
@@ -245,7 +244,7 @@ class webVideoLink extends videoLink {
        }
 
        public function getEmbed() {
-               return '<iframe width="' . $this->width*$this->compiler->getCssScale() . '" height="' . $this->height*$this->compiler->getCssScale() . '" src="' . $this->getEmbedURL() . '" frameborder="0" allowfullscreen></iframe>';
+               return '<iframe width="' . $this->width * $this->compiler->getCssScale() . '" height="' . $this->height * $this->compiler->getCssScale() . '" src="' . $this->getEmbedURL() . '" frameborder="0" allowfullscreen></iframe>';
        }
 
        public function getEmbedURL() {
@@ -304,7 +303,7 @@ class fileLink extends normalLink {
 class multimediaLink extends wsHTML5Link {
 
        public function getHTMLContent() {
-               return cubeMedia::flashObject(wsHTML5Link::getUniversalLocation($this->to), $this->width*$this->compiler->getCssScale(), $this->height*$this->compiler->getCssScale(), array(), '', '', 9, '#ffffff', '', 'true', 'noscale', 'transparent');
+               return cubeMedia::flashObject(wsHTML5Link::getUniversalLocation($this->to), $this->width * $this->compiler->getCssScale(), $this->height * $this->compiler->getCssScale(), array(), '', '', 9, '#ffffff', '', 'true', 'noscale', 'transparent');
        }
 
 }
index 3eb1215d726c1d9e24d759b7833cb01ad62e9788..555842bd22dab0eccae7ff5d58fe8ee082294c53 100644 (file)
@@ -38,6 +38,11 @@ function initHTML5Video(){
        }
        $("#videohtml").show();
        
+       if($("#videohtml").attr('autoplay')=='autoplay'){
+               var video=$("#videohtml").get(0);
+               video.play();
+       }
+       
        $(document).one('click','video',function(){
                $('video').each(function(){
                        this.play();