]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 13 Mar 2012 16:07:43 +0000 (16:07 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 13 Mar 2012 16:07:43 +0000 (16:07 +0000)
inc/commons/class.common.page.php
inc/commons/class.common.tools.php
js/browserInfos.js
js/flashdetect.js [new file with mode: 0644]
js/tube.js

index 63371a951601c0e15895f81726401e8b3b53c70c..58fd503bfd0353f3194aafbccc61d1fba1618062 100644 (file)
@@ -43,9 +43,13 @@ class commonPage {
        public static function search($args) {\r
                global $core;\r
 \r
+               if(!isset($args[0])){\r
+                       return;\r
+               }\r
                if (!commonDroits::recherche($args[0])) {\r
                        return;\r
                }\r
+               \r
                cubePage::emptyfield();\r
                $settings = $core->user->getSettings($args[0]);\r
                $action = 'search' . ucfirst($args[0]);\r
@@ -78,8 +82,9 @@ class commonPage {
 \r
                $res = '<div id="nav">';\r
                foreach ($onglets as $titre => $url) {\r
+\r
                        // Si cet onglet correspond à la page active, on le place actif\r
-                       $active = ($args[0] == $url || (isset($supp[$args[0]]) && $supp[$args[0]] == $url)) ? ' active' : '';\r
+                       $active =isset($args[0]) && ($args[0] == $url || (isset($supp[$args[0]]) && $supp[$args[0]] == $url)) ? ' active' : '';\r
                        $res .= '<a href="' . SITE_PATH . $url . '" class="onglet ' . $active . '">' . $titre . '</a>';\r
                }\r
                $res .= '</div>';\r
index 08a9edc8b270f44ff784142f6aaf68e144b9cff7..f2de47cadfcb1a70619075b25fc7106148a77eeb 100644 (file)
@@ -44,28 +44,37 @@ class commonTools {
        }
 
        public static function tube($args) {
-               global $css, $js;
+               global $css, $js, $jsnomerge, $jsvar;
 
                $css = array();
                $js[] = JS_PATH . '/tube.js';
+               $jsnomerge[] = JS_PATH . '/flashdetect.js';
                $js[] = JS_PATH . '/modernizr.js';
 
                $url = $_GET['u'];
                $hash = sha1($url);
 
-               $web = '/tube/' . $hash . '/';
-               $dir = ROOT . $web;
-               if (!file_exists($dir)) {
+               $onlyplayer = isset($_GET['onlyplayer']) && $onlyplayer;
 
-                       mkdir($dir, 0777, true);
-                       $ext = files::getExtension($url);
-                       $original = $dir . 'video.' . $ext;
-                       copy($url, $original);
+               if (!$onlyplayer) {
+                       $web = '/tube/' . $hash . '/';
+                       $dir = ROOT . $web;
+                       if (!file_exists($dir)) {
+                               mkdir($dir, 0777, true);
+                               $ext = files::getExtension($url);
+                               $original = $dir . 'video.' . $ext;
+                               copy($url, $original);
 
-                       require_once ROOT . '/inc/ws/Util/class.ws.tools.php';
-                       wsTools::encodeWebVideos($original);
+                               require_once ROOT . '/inc/ws/Util/class.ws.tools.php';
+                               wsTools::encodeWebVideos($original);
+                       }
+               } else {
+                       $e = explode('/', $url);
+                       array_pop($e);
+                       $dir = $web = implode('/', $e);
                }
 
+               $jsvar['priority'] = isset($_GET['html5']) && $_GET['html5'] ? 'html5' : 'flash';
 
                $loop = isset($_GET['loop']) ? $_GET['loop'] : 0;
                $autoplay = isset($_GET['autoplay']) ? $_GET['autoplay'] : 0;
@@ -76,45 +85,51 @@ class commonTools {
                $fv = array('video' => $url,
                        'autoPlay' => $autoplay == 1,
                        'controls' => $controls == 1,
-                       'loop' => $loop == 1);
+                       'loop' => $loop == 1,
+                       'background' => trim($background, '#'));
+
 
-               if ($displayPoster && file_exists($dir . 'video.jpg')) {
-                       $poster = $web . 'video.jpg';
-                       $fv['poster'] = 'http://' . $_SERVER['HTTP_HOST'] . $poster;
+               if (file_exists($dir . 'video.jpg')) {
+                       if ($displayPoster) {
+                               $poster = $web . 'video.jpg';
+                               $fv['poster'] = $web . $poster;
+                       }
+                       $dim = getimagesize($dir . 'video.jpg');
                }
 
                $res = '<style type="text/css">';
                $res.='html, body {margin: 0;padding: 0;height: 100%;color:#fff;overflow:hidden;}';
                $res.='body,video{background:' . $background . ';}';
-               $res.='video{width:100%;height:100%;}';
-               $res.='#header{display:none;}';
+               $res.='video{width:100%;height:100%;display:none;}';
+               $res.='#header,#videoflash,#videohtml{display:none;}';
                $res.='</style>';
 
-               $alt = '<video width="100%" height="100%" data-src="' . $web . '"';
-               if ($controls) {
-                       $alt.=' controls="controls"';
+               $video = '<video id="videohtml" width="100%" height="100%" data-src="' . $web . '"';
+               if (isset($dim)) {
+                       $video.=' data-width="' . $dim[0] . '" data-height="' . $dim[1] . '"';
+               }
+
+               $ios = stristr($_SERVER['HTTP_USER_AGENT'], 'ipad') || stristr($_SERVER['HTTP_USER_AGENT'], 'iphone') || stristr($_SERVER['HTTP_USER_AGENT'], 'ipod');
+               $video.=' controls="controls"';
+               if (!$controls) {
+                       $video.=' onplay="tubeHideControls(this);"';
                }
                if ($loop) {
-                       $alt.=' onended="this.play();"';
-                       //$alt.=' loop="loop"';
+                       $video.=' onended="this.play();"';
                }
                if ($autoplay) {
-                       $alt.=' autoplay="autoplay"';
+                       $video.=' data-autoplay="autoplay"';
                }
-               if ($displayPoster && isset($poster)) {
-                       $alt.=' poster="' . $web . 'video.jpg"';
-               }
-               $alt .= '>';
-               $alt .= '</video>';
-
-
-               if (isset($_GET['html5']) && $_GET['html5']) {
-                       $res.='<div id="video">' . $alt . '</div>';
-               } else {
-                       $res .= cubeMedia::flash2('/swf/video.swf', '100%', '100%', $fv, 'video', '', 10, '#000000', $alt, true);
+               if (($displayPoster || $ios) && isset($poster)) {
+                       $video.=' poster="' . $web . 'video.jpg"';
                }
+               $video .= '>';
+               $video .= '</video>';
 
+               $flash = cubeMedia::flashObject('/swf/video.swf', '100%', '100%', $fv, 'videoflash', '', 10, $background, '', 'true', 'noscale', 'opaque');
 
+               $res.=$video;
+               $res.=$flash;
                //ob_end_clean();
                echo $res;
                //exit;
@@ -126,8 +141,9 @@ class commonTools {
                global $js;
                global $jsvar;
 
-               $jsnomerge[] = 'http://www.featureblend.com/flash_detect_1-0-4/flash_detect_min.js';
+               $jsnomerge[] = JS_PATH . '/flashdetect.js';
                $js[] = JS_PATH . '/browserInfos.js';
+               $js[] = JS_PATH . '/modernizr.js';
                $jsvar['NO_FLASH'] = __("Adobe Flash Player non détecté");
                $res = commonPage::barre();
                $res .= commonPage::tMain();
@@ -137,6 +153,11 @@ class commonTools {
                $res.='<tr><td>' . __('Navigateur') . '</td><td>' . $_SERVER['HTTP_USER_AGENT'] . '</td></tr>';
                $res.='<tr><td>' . __('Adresse IP') . '</td><td>' . $_SERVER['REMOTE_ADDR'] . '</td></tr>';
                $res.='<tr><td>' . __('Adobe Flash Player') . '</td><td class="flashversion"></td></tr>';
+               $res.='<tr><td>' . __('Support de la video') . '</td><td><strong class="f" data-feature="video"></strong><br />';
+               $res.='OGV : <span class="f" data-feature="video.ogg"></span><br />';
+               $res.='H264 : <span class="f" data-feature="video.h264"></span><br />';
+               $res.='WEBM : <span class="f" data-feature="video.webm"></span><br />';
+               $res.='</td></tr>';
                $res.='</table>';
                $res .= '</div>';
                $res .= commonPage::bf();
index d08aaeae77e622cd059522fe26bcdd6d4e7eb5fb..a218e26c11100da0efae6b9d8d3ec39de71c2776 100644 (file)
@@ -7,4 +7,18 @@ function load_browser_infos(){
                        $(this).html(FlashDetect.major+"."+FlashDetect.minor+"."+FlashDetect.revision);
                }
        });
+       
+       $('.f').each(function(){
+               $(this).html(getModernizrValue($(this).attr('data-feature')));
+       });
+}
+
+function getModernizrValue(f){
+       eval('var r=Modernizr.'+f);
+       if(r==true){
+               r='true';
+       }else if(r==false){
+               r='false';
+       }
+       return r;
 }
\ No newline at end of file
diff --git a/js/flashdetect.js b/js/flashdetect.js
new file mode 100644 (file)
index 0000000..ebdff92
--- /dev/null
@@ -0,0 +1,5 @@
+//http://www.featureblend.com/license.txt
+var FlashDetect=new function(){var self=this;self.installed=false;self.raw="";self.major=-1;self.minor=-1;self.revision=-1;self.revisionStr="";var activeXDetectRules=[{"name":"ShockwaveFlash.ShockwaveFlash.7","version":function(obj){return getActiveXVersion(obj);}},{"name":"ShockwaveFlash.ShockwaveFlash.6","version":function(obj){var version="6,0,21";try{obj.AllowScriptAccess="always";version=getActiveXVersion(obj);}catch(err){}
+return version;}},{"name":"ShockwaveFlash.ShockwaveFlash","version":function(obj){return getActiveXVersion(obj);}}];var getActiveXVersion=function(activeXObj){var version=-1;try{version=activeXObj.GetVariable("$version");}catch(err){}
+return version;};var getActiveXObject=function(name){var obj=-1;try{obj=new ActiveXObject(name);}catch(err){obj={activeXError:true};}
+return obj;};var parseActiveXVersion=function(str){var versionArray=str.split(",");return{"raw":str,"major":parseInt(versionArray[0].split(" ")[1],10),"minor":parseInt(versionArray[1],10),"revision":parseInt(versionArray[2],10),"revisionStr":versionArray[2]};};var parseStandardVersion=function(str){var descParts=str.split(/ +/);var majorMinor=descParts[2].split(/\./);var revisionStr=descParts[3];return{"raw":str,"major":parseInt(majorMinor[0],10),"minor":parseInt(majorMinor[1],10),"revisionStr":revisionStr,"revision":parseRevisionStrToInt(revisionStr)};};var parseRevisionStrToInt=function(str){return parseInt(str.replace(/[a-zA-Z]/g,""),10)||self.revision;};self.majorAtLeast=function(version){return self.major>=version;};self.minorAtLeast=function(version){return self.minor>=version;};self.revisionAtLeast=function(version){return self.revision>=version;};self.versionAtLeast=function(major){var properties=[self.major,self.minor,self.revision];var len=Math.min(properties.length,arguments.length);for(i=0;i<len;i++){if(properties[i]>=arguments[i]){if(i+1<len&&properties[i]==arguments[i]){continue;}else{return true;}}else{return false;}}};self.FlashDetect=function(){if(navigator.plugins&&navigator.plugins.length>0){var type='application/x-shockwave-flash';var mimeTypes=navigator.mimeTypes;if(mimeTypes&&mimeTypes[type]&&mimeTypes[type].enabledPlugin&&mimeTypes[type].enabledPlugin.description){var version=mimeTypes[type].enabledPlugin.description;var versionObj=parseStandardVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revisionStr=versionObj.revisionStr;self.revision=versionObj.revision;self.installed=true;}}else if(navigator.appVersion.indexOf("Mac")==-1&&window.execScript){var version=-1;for(var i=0;i<activeXDetectRules.length&&version==-1;i++){var obj=getActiveXObject(activeXDetectRules[i].name);if(!obj.activeXError){self.installed=true;version=activeXDetectRules[i].version(obj);if(version!=-1){var versionObj=parseActiveXVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revision=versionObj.revision;self.revisionStr=versionObj.revisionStr;}}}}}();};FlashDetect.JS_RELEASE="1.0.4";
\ No newline at end of file
index ea196efb28d99b8340825f58881b3cfd7af11677..3eb1215d726c1d9e24d759b7833cb01ad62e9788 100644 (file)
@@ -1,28 +1,82 @@
 TO_LOAD[TO_LOAD.length]='load_tube();';
 
 function load_tube(){
-       $('video').each(function(){
-               var template=$(this).attr('data-src');
-               if($(this).attr('src')==undefined){
-                       if(Modernizr.video.ogg){
-                               $(this).attr('src',template+'video.ogv');
-                       }else if(Modernizr.video.webm){
-                               $(this).attr('src',template+'video.webm');
-                       }else if(Modernizr.video.h264){
-                               $(this).attr('src',template+'video.mp4');
-                       }
+       var html5support=(Modernizr.video && (Modernizr.video.ogg || Modernizr.video.webm || Modernizr.video.h264))!=false;
+       var flashsupport=FlashDetect.installed && FlashDetect.major>=10;
+       
+       
+       if(priority=='html5'){
+               if(html5support){
+                       initHTML5Video();
+               }else{
+                       initFlashVideo();
                }
-       });
+       }else{
+               if(flashsupport){
+                       initFlashVideo();
+               }else{
+                       initHTML5Video();
+               }
+       }
        
        $(window).resize(resizeTube);
        resizeTube();
 }
 
+
+function initHTML5Video(){
+       
+       var template=$("#videohtml").attr('data-src');
+       if($("#videohtml").attr('src')==undefined){
+               if(Modernizr.video.ogg){
+                       $("#videohtml").attr('src',template+'video.ogv');
+               }else if(Modernizr.video.webm){
+                       $("#videohtml").attr('src',template+'video.webm');
+               }else if(Modernizr.video.h264){
+                       $("#videohtml").attr('src',template+'video.mp4');
+               }       
+       }
+       $("#videohtml").show();
+       
+       $(document).one('click','video',function(){
+               $('video').each(function(){
+                       this.play();
+               });
+               return true;
+       })
+}
+
+function initFlashVideo(){
+       $("#videoflash").css('display','block');
+}
+
+function tubeHideControls(video){
+       
+       $(video).removeAttr('controls');
+}
+
 function resizeTube(){
-       $('video').css('width',$(window).width());
-       $('video').css('height',$(window).height());
+       $('video').each(function(){
+               var vw=parseInt($(this).attr('data-width'));
+               var vh=parseInt($(this).attr('data-height'));
+               var ww=$(window).width();
+               var hh=$(window).height();
+               var s=Math.min(ww/vw,hh/vh);
+               var w=vw*s;
+               var h=vh*s;
                
-       $('video').attr('width',$(window).width());
-       $('video').attr('height',$(window).height());
-       
+               $('video').css({
+                       width:w,
+                       height:h,
+                       left:(ww-w)/2,
+                       top:(hh-h)/2,
+                       position:'absolute'
+               });
+               
+               $('video').each(function(){
+                       if($(this).attr('src')!=undefined){
+                               $("video").show();
+                       }
+               })
+       });
 }
\ No newline at end of file