コード例 #1
0
ファイル: _show.php プロジェクト: rajveer4155/vidmgr
}
?>

    </video>
    <div class="overlays" style="display: none;">
        <?php 
if (!empty($model->top_image)) {
    $onClick = '';
    $cursor = 'move';
    if (!empty($model->top_image_url)) {
        $onClick = " ondblclick=\"window.open('" . $model->top_image_url . "', '_blank');\"";
        $cursor = 'pointer';
    } else {
        $cursor = 'move';
    }
    $imgPath = poa('application');
    list($imgWidth, $imgHeight, $imgType, $imgAttr) = getimagesize($imgPath . '/../files/' . uid() . '/thumb/' . $model->top_image);
    $imagePos = explode(',', $model->top_image_pos);
    echo '<div id="top-image-panel"' . $onClick . ' style="cursor:' . $cursor . ';top: 0px; left: 0px; height: ' . ($imagePos[3] == "" || $imagePos[3] == 0 ? $imgHeight : $imagePos[3]) . 'px; width: ' . ($imagePos[2] == "" || $imagePos[2] == 0 ? $imgHeight : $imagePos[2]) . 'px; display: block;" class="custom-overlays" data-top="' . $imagePos[1] . '" data-left="' . $imagePos[0] . '">';
    echo '<img src="' . Yii::app()->request->baseUrl . '/files/' . uid() . '/thumb/' . $model->top_image . '?rand=' . rand(100000, 999999) . '" style="position: absolute; left: 0px; top: 0px; height: ' . ($imagePos[3] == "" || $imagePos[3] == 0 ? $imgHeight : $imagePos[3]) . 'px; width: ' . ($imagePos[2] == "" || $imagePos[2] == 0 ? $imgHeight : $imagePos[2]) . 'px;" />';
    echo '</div>';
}
?>
        <?php 
$start = array();
$end = array();
$oIds = array();
$overlay_link_counter = 1;
$overlay_cc_counter = 1;
foreach ($model->overlays as $ovr) {
    //$title=true;
コード例 #2
0
    public function actionGetCode($id, $code, $ovr = 0)
    {
        $base = Yii::app()->getBaseUrl(true);
        //"http://mfvideomgr.com/html5";
        $model = Video::model()->findByPk($id);
        if (!$this->checkRepeats($id)) {
            app()->end();
        }
        if (!$this->checkTiming($id)) {
            app()->end();
        }
        if (!$this->checkLocation($id)) {
            app()->end();
        }
        $bookmarkAllowed = !empty($model->hotspots_bookmark);
        $randId = md5(time() . rand(0, 999));
        $xr = Yii::app()->request->getQuery('xr');
        $code = "\n\tvar opt, player;\n\tif(typeof(\$) == \"undefined\" && typeof(jQuery) == \"undefined\")\n\t{\n\t\tjq = document.createElement('script');\n\t\tjq.src='//code.jquery.com/jquery-latest.min.js';\n\t\tjq.type='text/javascript';\n\t\tjq.onload = vidmgr_startup;\n\t\th = document.getElementsByTagName('head')[0];\n\t\th.appendChild(jq);\n\t}\n\telse\n\t\tjQuery(function(){vidmgr_startup()}); \n\tfunction vidmgr_startup()\n\t{\n\tif(typeof(\$) == 'undefined')\n\t\t\$ = jQuery;\n\tfunction startVjs(){\n\t\topt = {controls: false, autoplay: false, preload: false,plugins : { enlarge : {} }};\n";
        if ($model->theme != 0) {
            $code .= "\t\topt.controls = true;\n";
        }
        if ($model->buffer != 0) {
            $code .= "\t\topt.buffer = true;\n";
        }
        if ($model->autoplay != 0) {
            $code .= "\t\topt.autoplay = true;\n";
        }
        if ($model->height) {
            $code .= "\t\topt.height = {$model->height};\n";
        }
        if ($model->width) {
            $code .= "\t\topt.width = {$model->width};\n";
        }
        $source = '';
        $isEx = substr($model->file, 0, 4) == 'http';
        if ($isEx) {
            $source = $model->file;
        } else {
            $source = $this->createAbsoluteUrl("videosr/rcv", array('name' => $model->file, 'id' => $model->user_id));
        }
        // showVideo1
        $video_source = "<source src=\"" . $source . "\" type=\"videosr/mp4\"></source>";
        $media_data = '';
        if ($model->isExternal()) {
            if (preg_match("/^(?:https?:\\/\\/)?(?:www\\.)?(?:youtu\\.be\\/|youtube\\.com\\/(?:embed\\/|v\\/|watch\\?v=|watch\\?.+&v=))((\\w|-){11})(?:\\S+)?\$/", $model->fileUrl)) {
                $media_data = " width=\"{$model->width}\" height=\"{$model->height}\"   data-setup=\\'{ \"techOrder\": [\"youtube\"], \"src\": \"{$model->fileUrl}\",\"controls\": true, \"autoplay\": true }\\'";
            } elseif (preg_match("/^.*(vimeo\\.com\\/)((channels\\/[A-z]+\\/)|(groups\\/[A-z]+\\/videos\\/))?([0-9]+)/", $model->fileUrl)) {
                $media_data = " width=\"{$model->width}\" height=\"{$model->height}\"  data-setup=\\'{ \"techOrder\": [\"vimeo\"], \"src\": \"{$model->fileUrl}\" ,\"controls\": true, \"autoplay\": true }\\'";
            } else {
                $media_data = '';
            }
        }
        if ($media_data != '') {
            $video_source = '';
        }
        $code .= "\n        \tvar vcl = '<video id=\"{$randId}\" class=\"video-js vjs-theme-{$model->theme}\" {$media_data} >{$video_source}</video>';\n\t\tvar vc2 = '<div class=\"overlays\">";
        if (!empty($model->top_image)) {
            $onClick = '';
            if (!empty($model->top_image_url)) {
                $onClick = " onclick=\"window.open(\\'" . $model->top_image_url . "\\', \\'_blank\\')\"";
            }
            $imgPath = poa('webroot');
            list($imgWidth, $imgHeight, $imgType, $imgAttr) = getimagesize($imgPath . '/files/' . $model->user_id . '/thumb/' . $model->top_image);
            $imagePos = explode(',', $model->top_image_pos);
            $code .= '		<div id="top-image-panel"' . $onClick . ' style="position: absolute; top: ' . ($imagePos[1] == "" ? "0" : $imagePos[1]) . 'px; left: ' . ($imagePos[0] == "" ? "0" : $imagePos[0]) . 'px; height: ' . ($imagePos[2] == "" ? $imgHeight : $imagePos[2]) . 'px; width: ' . ($imagePos[3] == "" ? $imgWidth : $imagePos[3]) . 'px; display: block; ' . ($model->top_image_url != "" ? "cursor: pointer;" : "") . ' class="custom-overlays" data-top="' . $imagePos[1] . '" data-left="' . $imagePos[0] . '">';
            $code .= '		<img src="' . $base . '/files/' . $model->user_id . '/thumb/' . $model->top_image . '?rand=' . rand(100000, 999999) . '" style="left: 0px; top: 0px; width:' . ($imagePos[3] == "" ? $imgWidth : $imagePos[3]) . 'px; height:' . ($imagePos[2] == "" ? $imgHeight : $imagePos[2]) . 'px;" />';
            $code .= '		</div>';
        }
        $start = array();
        $end = array();
        $oIds = array();
        $hotspoted = '';
        $background_opacity = 0;
        if ($bookmarkAllowed) {
            foreach ($model->overlays as $ovr) {
                $points = explode(",", $ovr->points);
                $start[] = $ovr->startTime;
                $end[] = $ovr->endTime;
                $oIds[] = $ovr->id;
                $borderRadius = '';
                if ($ovr->shape == 'cir') {
                    $borderRadius = ' border-radius: ' . $points[3] / 2 . 'px;';
                }
                $overlayimage = '';
                if ($ovr->image != '' && $ovr->show_image_on_area == 1) {
                    $image_opacity = (int) $ovr->image_opacity / 100;
                    $file_path = Yii::app()->getBaseUrl(true) . '/files/' . $model->user_id . '/' . $ovr->image . '?rand=' . rand(100000, 999999);
                    $overlayimage = "<img src=\"{$file_path}\" style=\"opacity:{$image_opacity};height:{$points[2]}px;width:{$points[3]}px;{$borderRadius};position: absolute;left:0px;\" >";
                }
                $time_point_function = '';
                if ($ovr->go_to_time_point == 1) {
                    $time_point_function = 'player.currentTime(' . $ovr->time_point . ');';
                    if ($ovr->play_auto == 1) {
                        $time_point_function .= 'player.play();';
                    } else {
                        $time_point_function .= 'player.pause();';
                    }
                }
                $click_preference = 'onclick';
                if ($ovr->click_preference == 1) {
                    $click_preference = 'ondblclick';
                } else {
                    $click_preference = 'onclick';
                }
                $background_opacity = (double) $ovr->overlay_opacity / 100;
                $code .= "\t\t<div itemprop=\"offers\" id=\"overlayS_{$ovr->id}\" data-left=\"{$points[0]}\" data-top=\"{$points[1]}\" class=\"custom-overlays\" style=\"height:{$points[2]}px; width:{$points[3]}px;cursor:pointer;background-color:{$ovr->overlay_color};opacity:{$background_opacity};{$borderRadius}\" {{$click_preference}}=\"return addBM(\\'{$ovr->url}\\', {$ovr->id});{$time_point_function}\"> " . $overlayimage . " </div>";
                $hotspoted .= "\t\t<li style=\"display:none\" id=\"hotspoti{$ovr->id}\"><a href=\"{$ovr->url}\" target=\"_blank\">{$ovr->url}</a></li>";
            }
        } else {
            foreach ($model->overlays as $ovr) {
                $points = explode(",", $ovr->points);
                $start[] = $ovr->startTime;
                $end[] = $ovr->endTime;
                $oIds[] = $ovr->id;
                $borderRadius = '';
                if ($ovr->shape == 'cir') {
                    $borderRadius = ' border-radius: ' . $points[3] / 2 . 'px;';
                }
                $time_point_function = '';
                $open_link = "window.open(\\'{$ovr->url}\\', \\'_blank\\');";
                if ($ovr->go_to_time_point == 1) {
                    $time_point_function = 'player.currentTime(' . $ovr->time_point . ');';
                    if ($ovr->play_auto == 1) {
                        $time_point_function .= 'player.play();';
                    } else {
                        $time_point_function .= 'player.pause();';
                    }
                    $open_link = "";
                }
                $click_preference = 'onclick';
                if ($ovr->click_preference == 1) {
                    $click_preference = 'ondblclick';
                } else {
                    $click_preference = 'onclick';
                }
                $font_style = '';
                if ($ovr->font_size != '' && $ovr->font_size > 0) {
                    $font_style .= 'font-size:' . $ovr->font_size . 'px;';
                } else {
                    $font_style .= 'font-size: 12px;';
                }
                if ($ovr->font_family != '') {
                    $font_style .= 'font-family:' . $ovr->font_family . ';';
                }
                if ($ovr->font_color != '') {
                    $font_style .= 'color:' . $ovr->font_color . ';';
                }
                if ($ovr->font_is_bold == 1) {
                    $font_style .= 'font-weight:bold;';
                }
                if ($ovr->font_is_underline == 1) {
                    $font_style .= 'text-decoration:underline;';
                }
                if ($ovr->font_is_italic == 1) {
                    $font_style .= 'font-style:italic;';
                }
                if ($ovr->text_opacity != '') {
                    $text_opacity = (int) $ovr->text_opacity / 100;
                    $font_style .= 'opacity:' . $text_opacity . ';';
                }
                $overlay_color = '';
                if ($ovr->show_text == '1' && $ovr->overlay_text != '' && $ovr->text_background_is_transparent == 1) {
                    $overlay_color = 'transparent';
                } else {
                    $overlay_color = $ovr->overlay_color;
                }
                $overlayimage = '';
                if ($ovr->image != '' && $ovr->show_image_on_area == 1) {
                    $image_opacity = (int) $ovr->image_opacity / 100;
                    $file_path = Yii::app()->getBaseUrl(true) . '/files/' . $model->user_id . '/' . $ovr->image . '?rand=' . rand(100000, 999999);
                    $overlayimage = "<img src=\"{$file_path}\" style=\"opacity:{$image_opacity};height:{$points[2]}px;width:{$points[3]}px;{$borderRadius};position: absolute;left:0px;\" >";
                }
                $background_opacity = (double) $ovr->overlay_opacity / 100;
                $text = '';
                if ($ovr->show_text == '1') {
                    $ovr->overlay_text = str_replace("'", "\\'", $ovr->overlay_text);
                    $text = "<input style=\"height:{$points[2]}px;width:{$points[3]}px;position:absolute;border:none;background:transparent;{$font_style}\" disabled=\"disabled\" value=\"{$ovr->overlay_text}\">";
                } else {
                    $text = '';
                }
                $code .= "\t\t<div itemprop=\"offers\" id=\"overlayS_{$ovr->id}\" data-left=\"{$points[0]}\" data-top=\"{$points[1]}\" class=\"custom-overlays\" style=\"height:{$points[2]}px; width:{$points[3]}px; cursor:pointer;background-color:{$overlay_color};opacity:{$background_opacity};{$borderRadius}\" {$click_preference}=\"player.pause(); {$open_link}{$time_point_function}\"> " . $overlayimage . " {$text} </div>";
            }
        }
        $start = implode(",", $start);
        $end = implode(",", $end);
        $oIds = implode(",", $oIds);
        $video_title = $model->title;
        $video_description = str_replace("'", "", html_entity_decode($model->description, ENT_QUOTES));
        $video_description = str_replace('"', '', $video_description);
        $code .= "\t\t</div>'";
        $code .= "\n\t\tif(\$('#videoBox-{$xr}').length ==0)\n\t\t{\n\t\t\tvar scr = \$('script[src *= {$xr}]')[0];\n\t\t\t\$(scr).before('<div id=\"videoBox-{$xr}\" class=\"videoBox\" itemprop=\"video\" itemscope itemtype=\"http://schema.org/VideoObject\"><h1 itemprop=\"name\" style=\"display:none\">{$video_title}</h1><meta itemprop=\"title\" content=\"{$video_title}\" /><meta itemprop=\"description\" content=\"{$video_description}\" /></div>');\n\t\t}\n\t\t\$('#videoBox-{$xr}').append(vcl);\n\t\t\$('#videoBox-{$xr}').append(vc2);\n\t \t";
        $bmFunc = '';
        $playerEnded = '';
        if ($bookmarkAllowed) {
            $code .= "\n        \t\tvar vc3 = '<div class=\"mfbookmark\" style=\"float:left\" id=\"mfbookmark-{$xr}\"><label title=\"By checking this box you will be able to select any clickable hotspot for viewing after the video completes. Video will not pause during play.\"><input type=\"checkbox\" id=\"mfbookmark-chk-{$xr}\" value=\"1\" /> Bookmark Hotspots</label></div>';\n\t\t\t\$('#videoBox-{$xr}').append(vc3);\n\t\t\tvar vc4 = '<div class=\"hotspoted\" id=\"hotspoted-{$xr}\"><p>Bookmarked Hotspots</p><ul>{$hotspoted}</ul></div>';\n\t\t\t\$('#videoBox-{$xr}').append(vc4);\n        \t";
            $playerEnded = "\n        \t\tplayer.on('ended', function(){\n\t\t\tvar hcx = 0;\n\t\t\t\$('#hotspoted-{$xr} li').each(function(i,o){\n\t\t\t\tif(\$(o).css('display')!='none')\n\t\t\t\t\thcx++;\n\t\t\t});\n\t\t\tif(hcx>0)\n\t\t\t{\n\t\t\t\t\$('#hotspoted-{$xr}').show();\n\t\t\t\t\$('#hotspoted-{$xr}').css('position','absolute');\n\t\t\t\t\n\t\t\t\t//\$('#hotspoted-{$xr}').css('background','#ffffff');\n\t\t\t\t\$('#hotspoted-{$xr}').css('top','10px');\n\t\t\t\t\$('#hotspoted-{$xr}').css('left','10px');\n\t\t\t\t\t\n\t\t\t}\n\t\t});\n        \t";
            $bmFunc = '
        		function addBM(url,id){
        			$(\'#bmnoti-' . $xr . '\').remove();
        			var sx = $(\'#mfbookmark-chk-' . $xr . '\').prop(\'checked\').toString();
		        	if(sx!="false" && sx!="undefined"){
		        		$(\'#hotspoti\'+id).css(\'display\', \'\');
		        		$(\'#videoBox-' . $xr . '\').append(\'<div class="bmnoti" style="float:left; color:#ff0000" id="bmnoti-' . $xr . '">&nbsp;&nbsp;&nbsp;Hotspot bookmarked!</div>\');
		        		setTimeout(function(){
		        			$(\'#bmnoti-' . $xr . '\').fadeOut(300).remove();
        				}, 2000);
		        	}else{
		        		$(\'#hotspoti\'+id).css(\'display\', \'none\');
					player.pause();
		        		window.open(url, \'_blank\');
		    		}
		    		return false;
	    		}
        	';
        }
        $code .= '$("#' . $randId . '").addClass("vjs-theme-' . $model->theme . '"); console.log($("#videoBox-' . $xr . '").height());';
        if ($model->overlay == "1") {
            $code .= "\n\t \t\$.colorbox({inline:true,scrolling:false, href:'#videoBox-{$xr}',intialHeight:" . ($model->height + 30) . ", innerWidth: " . $model->width . ", innerHeight:  " . ($model->height + 30) . ", onCleanup:function(){player.pause();},onClose:function(){player.pause();}, onComplete: function(){\n\t\t\t";
        }
        if ($model->overlay == "2") {
            $code .= "\n\t \t\$.colorbox({inline:true,scrolling:false,overlayClose:false, opacity:0, innerWidth: " . $model->width . ", innerHeight:  " . ($model->height + 18) . ",\n\t\t";
            if (!empty($model->X)) {
                $code .= "top:\"" . $model->X . $model->Xdrop . "\", ";
            }
            if (!empty($model->Y)) {
                $code .= "left:\"" . $model->Y . $model->Ydrop . "\", ";
            }
            $code .= "\n\t \tfixed:true,href:'#videoBox-{$xr}', onCleanup:function(){player.pause();},\n\t \tonClose:function(){player.pause();}, onComplete: function(){\n\t\t\t";
        }
        if ($model->overlay == "3") {
            $code .= "\n\t \t\$.colorbox({inline:true,scrolling:false,overlayClose:false, opacity:0, innerWidth: " . $model->width . ", innerHeight:  " . $model->height . ",\n\t \tfixed:true,href:'#videoBox-{$xr}', onCleanup:function(){player.pause();},\n\t \tonClose:function(){player.pause();}, onComplete: function(){\n\t\t\t";
        }
        $code .= "\n      videojs.Enlarge = videojs.Button.extend({\n      /** @constructor */\n        init: function(player, options){\n          videojs.Button.call(this, player, options);\n          this.on('click', this.onClick);\n        }\n      });\n\n      videojs.Enlarge.prototype.onClick = function() {\n\t\tif(player.width() <= " . $model->width . ") {\n\t\t\tplayer.width(player.width() * 1.5);\n\t\t\tplayer.height(player.height() * 1.5);\n\t\t\tparent.\$.colorbox.resize({innerWidth:player.width(), innerHeight:player.height()});\n\t\t\t\$('.vjs-enlarge-button').addClass('enlarged');\n\t\t} else {\n\t\t\tplayer.width(player.width() / 1.5);\n\t\t\tplayer.height(player.height() / 1.5);\n\t\t\tparent.\$.colorbox.resize({innerWidth:player.width(), innerHeight:player.height()});\n\t\t\t\$('.vjs-enlarge-button').removeClass('enlarged');\n\t\t}\n      };\n\n      // Note that we're not doing this in prototype.createEl() because\n      // it won't be called by Component.init (due to name obfuscation).\n      var createEnlargeButton = function() {\n        var props = {\n            className: 'vjs-enlarge-button vjs-control',\n            innerHTML: '<div class=\"vjs-control-content\"><span class=\"vjs-control-text\">' + ('Enlarge') + '</span></div>',\n            role: 'button',\n            'aria-live': 'polite', // let the screen reader user know that the text of the button may change\n            tabIndex: 0\n          };\n        return videojs.Component.prototype.createEl(null, props);\n      };\n\n      var enlarge;\n      videojs.plugin('enlarge', function() {\n        var options = { 'el' : createEnlargeButton() };\n        enlarge = new videojs.Enlarge(this, options);\n        this.controlBar.el().appendChild(enlarge.el());\n      });\n\n\t \t\tvideojs('{$randId}', opt).ready(function(){\n\t \t\tplayer = this;\n\t \t\tplayer.on('play', posOverlays);\n\t\t\tplayer.on('resize', posOverlays);\n\t\t\tplayer.on('timeupdate', function(){showOvs(player);});\n\t\t\t//\$('#mfbookmark label').popover();\n\t\t\t{$playerEnded}\n\t\t\t\n\t\t\tvideoTitle = '" . $model->title . "';\n\t\t\t//\$.getScript('" . $base . "/js/video-ga.js');\n\t \t\t";
        $code .= "});";
        if ($model->overlay >= "1") {
            $code .= "}});";
        }
        $code .= "};\n\t\t\n\t\tvar start = '" . $start . "';\n\t\tvar end = '" . $end . "';\n\t\tvar oIds = '" . $oIds . "';\n\t\tstart = start.split(',');\n\t\tend = end.split(',');\n\t\toIds = oIds.split(',');";
        $code .= '
		function showOvs(player){
			var len = start.length;
			var t = player.currentTime();
			for(var i = 0; i < len ; i++){
				if((t) >= parseInt(start[i]) && (t) <= parseInt(end[i])){
					if(!$("#overlayS_"+oIds[i]).is(":visible"))
					{
						$("#overlayS_"+oIds[i]).show();
						posOverlays();
					}
				} else {
						$("#overlayS_"+oIds[i]).hide();
				}
			}
		}
		function posOverlays(){
			$(".overlays").show();
			$("#hotspoted-' . $xr . '").hide();
			var off = $("#' . $randId . '").offset();
			$(".custom-overlays").each(function(){
				$(this).css({top: $(this).data("top"), left: $(this).data("left") });
			});
		}
		
		var custu_css = ".custom-overlays{opacity: 0.3; position: absolute; line-height: 9; z-index: 10000; } .black_overlay{   position: absolute;top: 0%;left: 0%;width: 100%;height: 100%;background-color: black;z-index:1001;-moz-opacity: 0.8;opacity:.80;filter: alpha(opacity=80);        }        .white_content {position: absolute;top: 25%;left: 25%;width: 50%;height: 50%;padding: 16px;border: 16px solid orange;background-color: white;z-index:1002;overflow: auto; }    ";';
        $code .= "\n\t\t\$(function(){\n\t\t\t\$.ajax({url:'http://vjs.zencdn.net/4.2.1/video.js', dataType: 'script', success: function(){\n\t\t\t\$.ajax({url:'" . $base . "/js/videojs.custom.min.js', dataType: 'script', success: function(){\n\t\t\t\$.ajax({url:'" . $base . "/js/youtube.js', dataType: 'script', success: function(){}});\n            \$.ajax({url:'" . $base . "/js/media.vimeo.js', dataType: 'script', success: function(){}});\n\t\t\t \$.get('" . $base . "/videosr/rcvitem?item=" . urlencode('video-js.css') . "', function(css)\n\t\t\t {\n   \t\t\t \t\$('<style type=\"text/css\"></style>')\n      \t\t\t.html(css)\n      \t\t\t.appendTo('head');\n\t\t\t\t\t\n\t\t\t\t\$('<style type=\"text/css\"></style>')\n\t\t\t\t.html(custu_css)\n\t\t\t\t.appendTo('head');\n\t\t\t\t";
        $code .= "\n                \$.get('" . $base . "/video-themes/theme-" . $model->theme . "/css/main.css', function(css2){\n                    \$('<style type=\"text/css\"></style>')\n                    .html(css2)\n                    .appendTo('head');\n                });\n                ";
        if ($model->overlay == "1") {
            $code .= "\$.ajax({url:'" . $base . "/videosr/rcvitem?item=" . urlencode("jquery.colorbox-min.js") . "', dataType: 'script', success: function(){\n\t\t\t\t\t \t\$.get('" . $base . "/videosr/rcvitem?item=" . urlencode("colorbox.css") . "', function(css)\n\t\t\t\t\t \t{\n\t\t\t   \t\t\t \t\$('<style type=\"text/css\"></style>')\n\t\t\t      \t\t\t.html(css)\n\t\t\t      \t\t\t.appendTo('head');\n\t\t\t\t\t\t";
        }
        if ($model->overlay == "2") {
            $code .= "\$.ajax({url:'" . $base . "/videosr/rcvitem?item=" . urlencode("jquery.colorbox-min.js") . "', dataType: 'script', success: function(){\n\t\t\t\t\t \t\$.get('" . $base . "/videosr/rcvitem?item=" . urlencode("colorbox.css") . "', function(css)\n\t\t\t\t\t \t{\n\t\t\t   \t\t\t \t\$('<style type=\"text/css\"></style>')\n\t\t\t      \t\t\t.html(css)\n\t\t\t      \t\t\t.appendTo('head');\n\t\t\t\t\t\t";
        }
        $code .= "startVjs();";
        if ($model->overlay == "0") {
            $code .= "\n\n                \n                var ov_off = \$('#{$randId}').offset();\n                var ov_h = \$('#{$randId}').height();\n                var ov_w = \$('#{$randId}').width();\n                console.log(ov_off);\n                \$('.overlays').css({top: ov_off.top , left: ov_off.left, height: ov_h-30, width: ov_w});\n                \$('.overlays').css('position','absolute');\n\n                ";
        }
        if ($model->overlay >= "1") {
            $code .= "});\n\t\t\t\t\t}});";
        }
        $code .= "\n\t\t\t });\n\t\t\t}});\n\n\n\t\t}});\n\t\t});\n\t}\n\t" . $bmFunc . "\n\t";
        header("application/x-javascript");
        header("Content-Type: application/javascript");
        header("X-Content-Type-Options: nosniff");
        header("Access-Control-Allow-Origin: *");
        echo $code;
    }
コード例 #3
0
    public function actionGetCode($id, $code, $ovr = 0)
    {
        //return 'currently on maintainence';
        $base = Yii::app()->getBaseUrl(true);
        //"http://mfvideomgr.com/html5";
        $model = Video::model()->findByPk($id);
        if (!$this->checkRepeats($id)) {
            app()->end();
        }
        if (!$this->checkTiming($id)) {
            app()->end();
        }
        if (!empty($model->geolocations)) {
            if (!$this->checkLocation($id)) {
                app()->end();
            }
        }
        $bookmarkAllowed = !empty($model->hotspots_bookmark);
        $randId = md5(time() . rand(0, 999));
        $xr = Yii::app()->request->getQuery('xr');
        $loop = "false";
        if ($model->enable_loop == 1) {
            $loop = "true";
        } else {
            $loop = "false";
        }
        $code = "\n\tvar opt, player;\n\tif(typeof(\$) == \"undefined\" && typeof(jQuery) == \"undefined\")\n\t{\n\t\tjq = document.createElement('script');\n\t\tjq.src='//code.jquery.com/jquery-latest.min.js';\n\t\tjq.type='text/javascript';\n\t\tjq.onload = vidmgr_startup;\n\t\th = document.getElementsByTagName('head')[0];\n\t\th.appendChild(jq);\n\t}\n\telse\n\t\tjQuery(function(){vidmgr_startup()}); \n\tfunction vidmgr_startup()\n\t{\n\tif(typeof(\$) == 'undefined')\n\t\t\$ = jQuery;\n\tfunction startVjs(){\n\t\topt = {controls: false, autoplay: false, preload : 'auto' ,loop:{$loop} ,customControlsOnMobile: true,nativeControlsForTouch:false,plugins : { enlarge : {} }};\n";
        if ($model->theme != 0) {
            $code .= "\t\topt.controls = true;\n";
        }
        if ($model->buffer != 0) {
            $code .= "\t\topt.buffer = true;\n";
        }
        if ($model->autoplay != 0) {
            $code .= "\t\topt.autoplay = true;\n";
        }
        if ($model->height) {
            $code .= "\t\topt.height = {$model->height};\n";
        }
        if ($model->width) {
            $code .= "\t\topt.width = {$model->width};\n";
        }
        $poster = "";
        if ($model->shopableimage != "") {
            $poster = Yii::app()->getBaseUrl(true) . '/files/' . $model->user_id . '/' . $model->shopableimage . '?rand=' . rand(100000, 999999);
            $code .= "      opt.poster = '{$poster}';\n";
        }
        $source = '';
        $isEx = substr($model->file, 0, 4) == 'http';
        if ($isEx) {
            $source = $model->file;
        } else {
            $source = $this->createAbsoluteUrl("video/rcv", array('name' => $model->file, 'id' => $model->user_id));
        }
        // showVideo1
        $shopable_image = '';
        if ($model->shopableimage != '' && $model->enable_shopableimage == 1) {
            $shopable_image = "<img class=\"vigmgr_main_img\" src=\"" . Yii::app()->getBaseUrl(true) . '/files/' . $model->user_id . '/' . $model->shopableimage . '?rand=' . rand(100000, 999999) . "\"/><style>#{$randId}{display:none !important;}</style>";
            $model->fileUrl = '';
            $model->file = '';
            $source = '';
        }
        $video_source = "<source src=\"" . $source . "\" type=\"video/mp4\"></source>";
        $media_data = '';
        $plugin = '';
        $shared_js_code = "";
        $youtube_js = "";
        $vimeo_js = "";
        if ($model->isExternal()) {
            if (preg_match("/^(?:https?:\\/\\/)?(?:www\\.)?(?:youtu\\.be\\/|youtube\\.com\\/(?:embed\\/|v\\/|watch\\?v=|watch\\?.+&v=))((\\w|-){11})(?:\\S+)?\$/", $model->fileUrl)) {
                $code .= "console.log('youtube link: {{$model->fileUrl}}')";
                $media_data = " width=\"{$model->width}\" height=\"{$model->height}\"   data-setup=\\'{ \"techOrder\": [\"youtube\"], \"src\": \"{$model->fileUrl}\",\"controls\": true, \"autoplay\": true }\\'";
            } elseif (preg_match("/^.*(vimeo\\.com\\/)((channels\\/[A-z]+\\/)|(groups\\/[A-z]+\\/videos\\/))?([0-9]+)/", $model->fileUrl)) {
                $code .= "console.log('vimeo link: {{$model->fileUrl}}')";
                $media_data = " width=\"{$model->width}\" height=\"{$model->height}\"  data-setup=\\'{ \"techOrder\": [\"vimeo\"], \"src\": \"{$model->fileUrl}\" ,\"controls\": true, \"autoplay\": true }\\'";
            } else {
                $media_data = '';
                if ($model->share == 1) {
                    // $plugin = " data-setup=\'{\"plugins\":{\"addThis\":{\"website_url\": false,\"reddit\":false,\"delicious\":false}}}\'";
                }
            }
        } else {
            if ($model->share == 1) {
                //$plugin = " data-setup=\'{\"plugins\":{\"addThis\":{\"website_url\": false,\"reddit\":false,\"delicious\":false}}}\'";
            }
        }
        if ($media_data != '') {
            $video_source = '';
        }
        $track = '';
        if ($model->enable_cc == 1 && $model->cc_file != "") {
            $track = "<track kind=\"captions\" src=\"" . $this->createAbsoluteUrl("video/rcvtrack", array('name' => $model->cc_file, 'id' => $model->user_id)) . "\"  label=\"English\" default >";
        }
        $video_poster_data = "";
        if ($model->shopableimage != "") {
            $video_poster_data = " poster=\"" . Yii::app()->getBaseUrl(true) . '/files/' . $model->user_id . '/' . $model->shopableimage . '?rand=' . rand(100000, 999999) . "\" data-poster=\"" . Yii::app()->getBaseUrl(true) . '/files/' . $model->user_id . '/' . $model->shopableimage . '?rand=' . rand(100000, 999999) . "\"";
        }
        $code .= "\n        \tvar vcl = '<video  id=\"{$randId}\" class=\"video-js vjs-theme-{$model->theme}\" {$media_data} {$plugin} {$video_poster_data}  >{$video_source} {$track}</video>';\n\t\tvar vc2 = '<div class=\"overlays\" style=\"display:none;\">{$shopable_image}";
        if (!empty($model->top_image)) {
            $onClick = '';
            if (!empty($model->top_image_url)) {
                $onClick = " onclick=\"window.open(\\'" . $model->top_image_url . "\\', \\'_blank\\')\"";
            }
            $imgPath = poa('webroot');
            list($imgWidth, $imgHeight, $imgType, $imgAttr) = getimagesize($imgPath . '/files/' . $model->user_id . '/thumb/' . $model->top_image);
            $imagePos = explode(',', $model->top_image_pos);
            $code .= '		<div id="top-image-panel"' . $onClick . ' style="position: absolute; top: ' . ($imagePos[1] == "" ? "0" : $imagePos[1]) . 'px; left: ' . ($imagePos[0] == "" ? "0" : $imagePos[0]) . 'px; height: ' . ($imagePos[2] == "" ? $imgHeight : $imagePos[2]) . 'px; width: ' . ($imagePos[3] == "" ? $imgWidth : $imagePos[3]) . 'px; display: block; ' . ($model->top_image_url != "" ? "cursor: pointer;" : "") . ' class="custom-overlays" data-top="' . $imagePos[1] . '" data-left="' . $imagePos[0] . '">';
            $code .= '		<img src="' . $base . '/files/' . $model->user_id . '/thumb/' . $model->top_image . '?rand=' . rand(100000, 999999) . '" style="left: 0px; top: 0px; width:' . ($imagePos[3] == "" ? $imgWidth : $imagePos[3]) . 'px; height:' . ($imagePos[2] == "" ? $imgHeight : $imagePos[2]) . 'px;" />';
            $code .= '		</div>';
        }
        $start = array();
        $end = array();
        $oIds = array();
        $hotspoted = '';
        $background_opacity = 0;
        $commands = "var commands = {";
        $popup = "";
        if ($bookmarkAllowed) {
            foreach ($model->overlays as $ovr) {
                $points = explode(",", $ovr->points);
                $start[] = $ovr->startTime;
                $end[] = $ovr->endTime;
                $oIds[] = $ovr->id;
                $borderRadius = '';
                if ($ovr->shape == 'cir') {
                    $borderRadius = ' border-radius: ' . $points[3] / 2 . 'px;';
                }
                $time_point_function = '';
                $open_link = "";
                if ($ovr->url != "" && $ovr->is_link == '1') {
                    $open_link = "window.open(\\'{$ovr->url}\\', \\'_blank\\');";
                }
                if ($ovr->go_to_time_point == 1) {
                    $time_point_function = 'player.currentTime(' . $ovr->time_point . ');';
                    if ($ovr->play_auto == 1) {
                        $time_point_function .= 'player.play();';
                    } else {
                        $time_point_function .= 'player.pause();';
                    }
                    $open_link = "";
                }
                $click_preference = 'onclick';
                if ($ovr->click_preference == 1) {
                    $click_preference = 'ondblclick';
                } else {
                    $click_preference = 'onclick';
                }
                $font_style = '';
                if ($ovr->font_size != '' && $ovr->font_size > 0) {
                    $font_style .= 'font-size:' . $ovr->font_size . 'px;';
                } else {
                    $font_style .= 'font-size: 12px;';
                }
                if ($ovr->font_family != '') {
                    $font_style .= 'font-family:' . $ovr->font_family . ';';
                }
                if ($ovr->font_color != '') {
                    $font_style .= 'color:' . $ovr->font_color . ';';
                }
                if ($ovr->font_is_bold == 1) {
                    $font_style .= 'font-weight:bold;';
                }
                if ($ovr->font_is_underline == 1) {
                    $font_style .= 'text-decoration:underline;';
                }
                if ($ovr->font_is_italic == 1) {
                    $font_style .= 'font-style:italic;';
                }
                if ($ovr->text_opacity != '') {
                    $text_opacity = (int) $ovr->text_opacity / 100;
                    $font_style .= 'opacity:' . $text_opacity . ';';
                }
                $overlay_color = '';
                if ($ovr->show_text == '1' && $ovr->overlay_text != '' && $ovr->text_background_is_transparent == 1) {
                    $overlay_color = 'transparent';
                } else {
                    $overlay_color = $ovr->overlay_color;
                }
                $overlayimage = '';
                if ($ovr->image != '' && $ovr->show_image_on_area == 1) {
                    $image_opacity = (int) $ovr->image_opacity / 100;
                    $file_path = Yii::app()->getBaseUrl(true) . '/files/' . $model->user_id . '/' . $ovr->image . '?rand=' . rand(100000, 999999);
                    $overlayimage = "<img src=\"{$file_path}\" style=\"opacity:{$image_opacity};height:{$points[2]}px;width:{$points[3]}px;{$borderRadius};position: absolute;left:0px;\" >";
                }
                $background_opacity = (double) $ovr->overlay_opacity / 100;
                $text = '';
                if ($ovr->show_text == '1') {
                    $ovr->overlay_text = str_replace("'", "\\'", $ovr->overlay_text);
                    $text = "<input style=\"height:{$points[2]}px;width:{$points[3]}px;position:absolute;border:none;background:transparent;cursor:pointer;{$font_style}\" readonly=\"readonly\" value=\"{$ovr->overlay_text}\">";
                } else {
                    $text = '';
                }
                if ($ovr->speech_text_to_match != '' && $ovr->enable_voice_recohnition == 1) {
                    $commands .= "'{$ovr->speech_text_to_match}': function() {\n                        \$('#overlayS_{$ovr->id}').trigger('click');\n                        new jBox('Notice', {\n                              content: 'Processing Voice Command: {$ovr->speech_text_to_match}'\n                          });\n                    },";
                }
                if ($ovr->enable_popup) {
                    $pop_up_height = $ovr->pop_up_height;
                    $pop_up_opacity = $ovr->pop_up_opacity;
                    $height_code = '';
                    $opacity_code = '';
                    if ($pop_up_height != '') {
                        $pop_up_height = (int) $pop_up_height;
                        $height_code = "height:{$pop_up_height},";
                    }
                    if ($pop_up_opacity != '') {
                        $pop_up_opacity = (double) $pop_up_opacity / 100;
                        $opacity_code = "\$('#jBoxT_ovrly_{$ovr->id}  .jBox-container').css('opacity','{$pop_up_opacity}');";
                    }
                    $popup_content = "";
                    $popup_content = str_replace("'", "\\'", $ovr->popup_content);
                    $popup_content = str_replace('"', "\\'", $ovr->popup_content);
                    $popup_content = str_replace("/uploads", Yii::app()->getBaseUrl(true) . "/uploads", $ovr->popup_content);
                    $popup_content = preg_replace('#\\R+#', '\\r\\n', $popup_content);
                    if ($ovr->pop_up_preference == 'click') {
                        $popup .= "new jBox('Tooltip', {\n                        id: 'jBoxT_ovrly_{$ovr->id}',\n                        theme: 'TooltipBorder',\n                        trigger: 'click',\n                        adjustDistance: {\n                            top: 55,\n                            right: 5,\n                            bottom: 5,\n                            left: 5\n                        },\n                        adjustTracker: true,\n                        {$height_code}\n                        closeOnClick: 'body',\n                        closeButton: 'box',\n                        animation: 'move',\n                        adjustPosition:true,\n                        attach: jQuery('#overlayS_{$ovr->id}'),\n                        target: jQuery('#overlayS_{$ovr->id}'),\n                        zIndex: 800000000,\n                        position: {\n                            x: '{$ovr->pop_up_position_x}',\n                            y: '{$ovr->pop_up_position_y}'\n                        },\n                        reposition:true,\n                        outside: '{$ovr->pop_up_outside_position}',\n                        pointer: 'left:0',\n                        offset: {\n                            x: 25\n                        },\n                        content: '{$popup_content}',\n                        onOpen: function() {},\n                        onOpen: function() {\n                            {$opacity_code}\n                            \$('#jBoxT_ovrly_{$ovr->id}  .jBox-content').css('background','{$ovr->pop_up_color}');\n                            \$('head').append('<style>#jBoxT_ovrly_{$ovr->id} .jBox-pointer:after{background: {$ovr->pop_up_color} }</style>');\n                            \n                        },\n                        onClose: function() {\n                            \n                        }\n                    });";
                    } else {
                        $popup .= "new jBox('Tooltip', {\n                  id: 'jBoxT_ovrly_{$ovr->id}',\n                  closeOnMouseleave: true,\n                   position: {\n                            x: '{$ovr->pop_up_position_x}',\n                            y: '{$ovr->pop_up_position_y}'\n                        },\n\n                        reposition:false,\n                        adjustPosition:true,\n                        outside: '{$ovr->pop_up_outside_position}',\n                  animation: 'zoomIn',\n                  {$height_code}\n                  attach: jQuery('#overlayS_{$ovr->id}'),\n                  zIndex: 800000000,\n                  content: '{$popup_content}',\n                  onOpen: function() {\n                             {$opacity_code}\n                            \$('#jBoxT_ovrly_{$ovr->id}  .jBox-content').css('background','{$ovr->pop_up_color}');\n                            \$('head').append('<style>#jBoxT_ovrly_{$ovr->id} .jBox-pointer:after{background: {$ovr->pop_up_color} }</style>');\n                        },\n              });";
                    }
                }
                $background_opacity = (double) $ovr->overlay_opacity / 100;
                $code .= "     <div itemprop=\"offers\" id=\"overlayS_{$ovr->id}\" data-left=\"{$points[0]}\" data-top=\"{$points[1]}\" class=\"custom-overlays\" style=\"display:none;height:{$points[2]}px; width:{$points[3]}px; cursor:pointer;background-color:{$overlay_color};opacity:{$background_opacity};{$borderRadius}\" onclick=\"return addBM(\\'{$ovr->url}\\', {$ovr->id})\"> " . $overlayimage . " {$text} </div>";
                $hotspoted .= "\t\t<li style=\"display:none\" id=\"hotspoti{$ovr->id}\"><a href=\"{$ovr->url}\" target=\"_blank\">{$ovr->url}</a></li>";
            }
        } else {
            foreach ($model->overlays as $ovr) {
                $points = explode(",", $ovr->points);
                $start[] = $ovr->startTime;
                $end[] = $ovr->endTime;
                $oIds[] = $ovr->id;
                $borderRadius = '';
                if ($ovr->shape == 'cir') {
                    $borderRadius = ' border-radius: ' . $points[3] / 2 . 'px;';
                }
                $time_point_function = '';
                $open_link = "";
                if ($ovr->url != "" && $ovr->is_link == '1') {
                    $open_link = "window.open(\\'{$ovr->url}\\', \\'_blank\\');";
                }
                $pause_video = 'player.pause();';
                if ($ovr->go_to_time_point == 1) {
                    $time_point_function = 'player.currentTime(' . $ovr->time_point . ');';
                    if ($ovr->play_auto == 1) {
                        $time_point_function .= 'player.play();';
                    } else {
                        $time_point_function .= 'player.pause();';
                    }
                    $open_link = "";
                    $pause_video = "";
                }
                $click_preference = 'onclick';
                if ($ovr->click_preference == 1) {
                    $click_preference = 'ondblclick';
                } else {
                    $click_preference = 'onclick';
                }
                $font_style = '';
                if ($ovr->font_size != '' && $ovr->font_size > 0) {
                    $font_style .= 'font-size:' . $ovr->font_size . 'px;';
                } else {
                    $font_style .= 'font-size: 12px;';
                }
                if ($ovr->font_family != '') {
                    $font_style .= 'font-family:' . $ovr->font_family . ';';
                }
                if ($ovr->font_color != '') {
                    $font_style .= 'color:' . $ovr->font_color . ';';
                }
                if ($ovr->font_is_bold == 1) {
                    $font_style .= 'font-weight:bold;';
                }
                if ($ovr->font_is_underline == 1) {
                    $font_style .= 'text-decoration:underline;';
                }
                if ($ovr->font_is_italic == 1) {
                    $font_style .= 'font-style:italic;';
                }
                if ($ovr->text_opacity != '') {
                    $text_opacity = (int) $ovr->text_opacity / 100;
                    $font_style .= 'opacity:' . $text_opacity . ';';
                }
                $overlay_color = '';
                if ($ovr->show_text == '1' && $ovr->overlay_text != '' && $ovr->text_background_is_transparent == 1) {
                    $overlay_color = 'transparent';
                } else {
                    $overlay_color = $ovr->overlay_color;
                }
                $overlayimage = '';
                if ($ovr->image != '' && $ovr->show_image_on_area == 1) {
                    $image_opacity = (int) $ovr->image_opacity / 100;
                    $file_path = Yii::app()->getBaseUrl(true) . '/files/' . $model->user_id . '/' . $ovr->image . '?rand=' . rand(100000, 999999);
                    $overlayimage = "<img src=\"{$file_path}\" style=\"opacity:{$image_opacity};height:{$points[2]}px;width:{$points[3]}px;{$borderRadius};position: absolute;left:0px;\" >";
                }
                $background_opacity = (double) $ovr->overlay_opacity / 100;
                $text = '';
                if ($ovr->show_text == '1') {
                    $ovr->overlay_text = str_replace("'", "\\'", $ovr->overlay_text);
                    $text = "<input style=\"height:{$points[2]}px;width:{$points[3]}px;position:absolute;border:none;background:transparent;cursor:pointer;{$font_style}\" readonly=\"readonly\" value=\"{$ovr->overlay_text}\">";
                } else {
                    $text = '';
                }
                if ($ovr->speech_text_to_match != '' && $ovr->enable_voice_recohnition == 1) {
                    $commands .= "'{$ovr->speech_text_to_match}': function() {\n                     new jBox('Notice', {\n                              content: 'Processing Voice Command: {$ovr->speech_text_to_match}'\n                          });\n\n                        \$('#overlayS_{$ovr->id}').trigger('{$click_preference}');\n\n                    },";
                }
                if ($ovr->cc_enabled == 1) {
                    $ovr->overlay_text = str_replace("'", "\\'", $ovr->overlay_text);
                    $ovr->overlay_text = preg_replace('#\\R+#', '\\r\\n\\n', $ovr->overlay_text);
                    //$ovr->overlay_text  =nl2br($ovr->overlay_text);
                    $text = "<textarea  style=\"height:{$points[2]}px;width:{$points[3]}px;position:absolute;border:none;background:transparent;resize: none;overflow:hidden;cursor:pointer;{$font_style}\" readonly=\"readonly\" >{$ovr->overlay_text}</textarea>";
                    $pause_video = '';
                    $open_link = '';
                    $time_point_function = '';
                }
                $visibility = '';
                if ($ovr->cc_enabled == 1 && $ovr->show_text == 0) {
                    $visibility = 'visibility:hidden;';
                } else {
                    $visibility = '';
                }
                $mouseOver = "";
                if ($ovr->enable_popup) {
                    $mouseOver = "";
                    $pop_up_height = $ovr->pop_up_height;
                    $pop_up_opacity = $ovr->pop_up_opacity;
                    $height_code = '';
                    $opacity_code = '';
                    if ($pop_up_height != '') {
                        $pop_up_height = (int) $pop_up_height;
                        $height_code = "height:{$pop_up_height},";
                    }
                    if ($pop_up_opacity != '') {
                        $pop_up_opacity = (double) $pop_up_opacity / 100;
                        $opacity_code = "\$('#jBoxT_ovrly_{$ovr->id}  .jBox-container').css('opacity','{$pop_up_opacity}');";
                    }
                    $popup_content = "";
                    //$popup_content = str_replace("'","\'", $ovr->popup_content);
                    // $popup_content = str_replace('"',"\'", $ovr->popup_content);
                    $popup_content = str_replace("/uploads", Yii::app()->getBaseUrl(true) . "/uploads", $ovr->popup_content);
                    $popup_content = preg_replace('#\\R+#', '\\r\\n', $popup_content);
                    $popup_content = preg_replace("/[\"\\']/", "\\'", $popup_content);
                    if ($ovr->pop_up_preference == 'click') {
                        $popup .= "new jBox('Tooltip', {\n                        id: 'jBoxT_ovrly_{$ovr->id}',\n                        theme: 'TooltipBorder',\n                        {$height_code}\n                        trigger: 'click',\n                        adjustDistance: {\n                            top: 55,\n                            right: 5,\n                            bottom: 5,\n                            left: 5\n                        },\n                        adjustTracker: true,\n                        adjustPosition:true,\n                        closeOnClick: 'body',\n                        closeButton: 'box',\n                        animation: 'move',\n                        attach: jQuery('#overlayS_{$ovr->id}'),\n                        target: jQuery('#overlayS_{$ovr->id}'),\n                        zIndex: 800000000,\n                        position: {\n                            x: '{$ovr->pop_up_position_x}',\n                            y: '{$ovr->pop_up_position_y}'\n                        },\n                        reposition:true,\n                        outside: '{$ovr->pop_up_outside_position}',\n                        pointer: 'left:0',\n                        offset: {\n                            x: 25\n                        },\n                        content: '{$popup_content}',\n                        onOpen: function() {\n                            {$opacity_code}\n                            \$('#jBoxT_ovrly_{$ovr->id}  .jBox-content').css('background','{$ovr->pop_up_color}');\n                            \$('head').append('<style>#jBoxT_ovrly_{$ovr->id} .jBox-pointer:after{background: {$ovr->pop_up_color} }</style>');\n                            \n                        },\n                        onClose: function() {\n                            \n                        }\n                    });";
                    } else {
                        $popup .= "new jBox('Tooltip', {\n                  id: 'jBoxT_ovrly_{$ovr->id}',\n                  closeOnMouseleave: true,\n                   position: {\n                            x: '{$ovr->pop_up_position_x}',\n                            y: '{$ovr->pop_up_position_y}'\n                        },\n\n                        reposition:true,\n                        repositionOnOpen:true,\n                        adjustPosition:true,\n                        adjustTracker: true,\n                        {$height_code}\n                        outside: '{$ovr->pop_up_outside_position}',\n                  animation: 'zoomIn',\n                  attach: jQuery('#overlayS_{$ovr->id}'),\n                  zIndex: 800000000,\n                  content: '{$popup_content}',\n                  onOpen: function() {\n                            {$opacity_code}\n                            \$('#jBoxT_ovrly_{$ovr->id}  .jBox-content').css('background','{$ovr->pop_up_color}');\n                            \$('head').append('<style>#jBoxT_ovrly_{$ovr->id} .jBox-pointer:after{background: {$ovr->pop_up_color} }</style>');\n                        },\n              });";
                    }
                }
                $code .= "\t\t<div itemprop=\"offers\" id=\"overlayS_{$ovr->id}\" data-left=\"{$points[0]}\" data-top=\"{$points[1]}\" class=\"custom-overlays\" style=\"{$visibility}display:none;height:{$points[2]}px; width:{$points[3]}px; cursor:pointer;background-color:{$overlay_color};opacity:{$background_opacity};{$borderRadius}\" {$click_preference}=\"{$open_link}{$pause_video} {$time_point_function}\" onMouseover=\"{$mouseOver}\"> " . $overlayimage . " {$text} </div>";
            }
        }
        $start = implode(",", $start);
        $end = implode(",", $end);
        $oIds = implode(",", $oIds);
        $video_title = $model->title;
        $video_description = str_replace("'", "", html_entity_decode($model->description, ENT_QUOTES));
        $video_description = str_replace('"', '', $video_description);
        $code .= "\t\t</div>'";
        $code .= "\n\t\tif(\$('#videoBox-{$xr}').length ==0)\n\t\t{\n\t\t\tvar scr = \$('script[src *= {$xr}]')[0];\n\t\t\t\$(scr).before('<div id=\"videoBox-{$xr}\" class=\"videoBox\" itemprop=\"video\" itemscope itemtype=\"http://schema.org/VideoObject\"><h1 itemprop=\"name\" style=\"display:none\">{$video_title}</h1><meta itemprop=\"title\" content=\"{$video_title}\" /><meta itemprop=\"description\" content=\"{$video_description}\" /></div>');\n\t\t}\n\t\t\$('#videoBox-{$xr}').append(vcl);\n\t\t\$('#videoBox-{$xr}').append(vc2);\n\t \t";
        $bmFunc = '';
        $playerEnded = '';
        if ($model->hotspots_bookmark == '1') {
            $code .= "\n        \t\tvar vc3 = '<div class=\"mfbookmark\" style=\"float:left\" id=\"mfbookmark-{$xr}\"><label title=\"By checking this box you will be able to select any clickable hotspot for viewing after the video completes. Video will not pause during play.\"><input type=\"checkbox\" id=\"mfbookmark-chk-{$xr}\" value=\"1\" /> Bookmark Hotspots</label></div>';\n             console.log(vc3);   \n\t\t\t\$('#videoBox-{$xr}').append(vc3);\n\t\t\tvar vc4 = '<div class=\"hotspoted\" id=\"hotspoted-{$xr}\" style=\"background:white;opacity:0.80;width:100%;height:auto;margin-top:20px;z-index:999999999999999999;\"><p>Bookmarked Hotspots</p><ul>{$hotspoted}</ul></div>';\n\t\t\t\$('#videoBox-{$xr}').append(vc4);\n        \t";
            $playerEnded = "\n        \t\tplayer.on('ended', function(){\n\t\t\tvar hcx = 0;\n\t\t\t\$('#hotspoted-{$xr} li').each(function(i,o){\n\t\t\t\tif(\$(o).css('display')!='none')\n\t\t\t\t\thcx++;\n\t\t\t});\n\t\t\tif(hcx>0)\n\t\t\t{\n\t\t\t\t\$('#hotspoted-{$xr}').show();\n\t\t\t\t\$('#hotspoted-{$xr}').css('position','absolute');\n\t\t\t\t\n\t\t\t\t//\$('#hotspoted-{$xr}').css('background','#ffffff');\n\t\t\t\t\$('#hotspoted-{$xr}').css('top','10px');\n\t\t\t\t\$('#hotspoted-{$xr}').css('left','10px');\n\t\t\t\t\t\n\t\t\t}\n\t\t});\n        \t";
            $bmFunc = '
        		function addBM(url,id){
        			$(\'#bmnoti-' . $xr . '\').remove();
        			var sx = $(\'#mfbookmark-chk-' . $xr . '\').prop(\'checked\').toString();
		        	if(sx!="false" && sx!="undefined"){
		        		$(\'#hotspoti\'+id).css(\'display\', \'\');
		        		$(\'#videoBox-' . $xr . '\').append(\'<div class="bmnoti" style="float:left; color:#ff0000" id="bmnoti-' . $xr . '">&nbsp;&nbsp;&nbsp;Hotspot bookmarked!</div>\');
		        		setTimeout(function(){
		        			$(\'#bmnoti-' . $xr . '\').fadeOut(300).remove();
        				}, 2000);
		        	}else{
		        		$(\'#hotspoti\'+id).css(\'display\', \'none\');
					player.pause();
		        		window.open(url, \'_blank\');
		    		}
		    		return false;
	    		}
        	';
        }
        $code .= '$("#' . $randId . '").addClass("vjs-theme-' . $model->theme . '"); console.log($("#videoBox-' . $xr . '").height());';
        if ($model->overlay == "1") {
            if ($model->hotspots_bookmark == '1') {
                $model->height = $model->height + 30;
            }
            $code .= "\n\t \t\$.colorbox({inline:true,scrolling:false, href:'#videoBox-{$xr}',intialHeight:" . $model->height . ", innerWidth: " . $model->width . ", innerHeight:  " . $model->height . ", onCleanup:function(){player.pause();},onClose:function(){player.pause();}, onComplete: function(){\n\t\t\t";
        }
        if ($model->overlay == "2") {
            if ($model->hotspots_bookmark == '1') {
                $model->height = $model->height + 30;
            }
            $code .= "\n\t \t\$.colorbox({inline:true,scrolling:false,overlayClose:false, opacity:0, innerWidth: " . $model->width . ", innerHeight:  " . $model->height . ",\n\t\t";
            if (!empty($model->X)) {
                $code .= "top:\"" . $model->X . $model->Xdrop . "\", ";
            }
            if (!empty($model->Y)) {
                $code .= "left:\"" . $model->Y . $model->Ydrop . "\", ";
            }
            $extra_code = "";
            if ($model->show_overlay_border == 0) {
                $extra_code = "\n                 console.log('modal 2 initiated');\n                  \$('#cboxTopLeft').hide();\n                \$('#cboxTopRight').hide();\n                \$('#cboxBottomLeft').hide();\n                \$('#cboxBottomRight').hide();\n                \$('#cboxMiddleLeft').hide();\n                \$('#cboxMiddleRight').hide();\n                \$('#cboxTopCenter').hide();\n                \$('#cboxBottomCenter').hide();";
            }
            $code .= "\n\t \tfixed:true,href:'#videoBox-{$xr}', onCleanup:function(){player.pause();},\n\t \tonClose:function(){player.pause();}, onComplete: function(){\n            \n            {$extra_code}\n\t\t\t";
        }
        if ($model->overlay == "3") {
            $code .= "\n\t \t\$.colorbox({inline:true,scrolling:false,overlayClose:false, opacity:0, innerWidth: " . $model->width . ", innerHeight:  " . $model->height . ",\n\t \tfixed:true,href:'#videoBox-{$xr}', onCleanup:function(){player.pause();},\n\t \tonClose:function(){player.pause();}, onComplete: function(){\n            console.log('modal initiated');\n\n\t\t\t";
        }
        $code .= "\n      videojs.Enlarge = videojs.Button.extend({\n      /** @constructor */\n        init: function(player, options){\n          videojs.Button.call(this, player, options);\n          this.on('click', this.onClick);\n        }\n      });\n\n      videojs.Enlarge.prototype.onClick = function() {\n\t\tif(player.width() <= " . $model->width . ") {\n\t\t\tplayer.width(player.width() * 1.5);\n\t\t\tplayer.height(player.height() * 1.5);\n\t\t\tparent.\$.colorbox.resize({innerWidth:player.width(), innerHeight:player.height()});\n\t\t\t\$('.vjs-enlarge-button').addClass('enlarged');\n\t\t} else {\n\t\t\tplayer.width(player.width() / 1.5);\n\t\t\tplayer.height(player.height() / 1.5);\n\t\t\tparent.\$.colorbox.resize({innerWidth:player.width(), innerHeight:player.height()});\n\t\t\t\$('.vjs-enlarge-button').removeClass('enlarged');\n\t\t}\n      };\n\n      // Note that we're not doing this in prototype.createEl() because\n      // it won't be called by Component.init (due to name obfuscation).\n      var createEnlargeButton = function() {\n        var props = {\n            className: 'vjs-enlarge-button vjs-control',\n            innerHTML: '<div class=\"vjs-control-content\"><span class=\"vjs-control-text\">' + ('Enlarge') + '</span></div>',\n            role: 'button',\n            'aria-live': 'polite', // let the screen reader user know that the text of the button may change\n            tabIndex: 0\n          };\n        return videojs.Component.prototype.createEl(null, props);\n      };\n\n      var enlarge;\n      videojs.plugin('enlarge', function() {\n        var options = { 'el' : createEnlargeButton() };\n        enlarge = new videojs.Enlarge(this, options);\n        this.controlBar.el().appendChild(enlarge.el());\n      });\n\n\t \t\tvideojs('{$randId}', opt).ready(function(){\n\t \t\tplayer = this;\n            \n\t \t\tplayer.on('play', posOverlays);\n\t\t\tplayer.on('resize', posOverlays);\n\t\t\tplayer.on('timeupdate', function(){showOvs(player);});\n\t\t\t//\$('#mfbookmark label').popover();\n\n            \n\t\t\t{$playerEnded}\n\t\t\t\n\t\t\tvideoTitle = '" . $model->title . "';\n\t\t\t//\$.getScript('" . $base . "/js/video-ga.js');\n            \n            poster_data = '{$poster}';\n            if(poster_data!=''){\n            \$('video').attr('poster','" . $poster . "');\n            console.log('check poster: " . $poster . "');\n            }\n            \n\t \t\t";
        if ($model->enable_marker == 1) {
            $model->marker_code = preg_replace('#\\R+#', '', $model->marker_code);
            //$model->marker_code  =nl2br($model->marker_code);
            $marker = "player.markers({" . $model->marker_code . "});";
            $code .= $marker;
        }
        $code .= "});";
        if ($model->overlay >= "1") {
            $code .= "}});";
        }
        $code .= "};\n\t\t\n\t\tvar start = '" . $start . "';\n\t\tvar end = '" . $end . "';\n\t\tvar oIds = '" . $oIds . "';\n\t\tstart = start.split(',');\n\t\tend = end.split(',');\n\t\toIds = oIds.split(',');";
        $fullscreen = "hidden";
        if ($model->fullscreen_enabled == 1) {
            $fullscreen = "visible";
        }
        $code .= '
		function showOvs(player){
			var len = start.length;
			var t = player.currentTime();
			for(var i = 0; i < len ; i++){
				if((t) >= parseInt(start[i]) && (t) <= parseInt(end[i])){
					if(!$("#overlayS_"+oIds[i]).is(":visible"))
					{
						$("#overlayS_"+oIds[i]).show();
						posOverlays();
					}
				} else {
						$("#overlayS_"+oIds[i]).hide();
				}
			}
		}
		function posOverlays(){
            $("li.vjs-menu-item").eq(2).trigger("click");
			$(".overlays").show();
			$("#hotspoted-' . $xr . '").hide();
			var off = $("#' . $randId . '").offset();
			$(".custom-overlays").each(function(){
				$(this).css({top: $(this).data("top"), left: $(this).data("left") });
			});
		}
		
		var custu_css = ".vjs-fullscreen-control{visibility:' . $fullscreen . '}.custom-overlays{opacity: 0.3; position: absolute; line-height: 0; z-index: 10000; } .black_overlay{   position: absolute;top: 0%;left: 0%;width: 100%;height: 100%;background-color: black;z-index:1001;-moz-opacity: 0.8;opacity:.80;filter: alpha(opacity=80);        }        .white_content {position: absolute;top: 25%;left: 25%;width: 50%;height: 50%;padding: 16px;border: 16px solid orange;background-color: white;z-index:1002;overflow: auto; }    ";';
        $share_js = "";
        if ($model->share == 1) {
            $share_js = "\$.ajax({url:'" . $base . "/js/videojs.addThis.js', dataType: 'script', success: function(){}});\n                        \$.get('" . $base . "/video/rcvitem?item=" . urlencode('videojs.addThis.css') . "', function(css){\n                    \$('<style type=\"text/css\"></style>')\n                    .html(css)\n                    .appendTo('head');\n                });";
        }
        $marker_js = "";
        if ($model->enable_marker == 1) {
            $marker_js = "\$.ajax({url:'" . $base . "/js/videojs.markers.js', dataType: 'script', success: function(){}});";
        }
        $commands .= "'play':function(){\n                     new jBox('Notice', {\n                          content: 'Processing Voice Command: play'\n                      });\n                      player.play();\n                    },\n                    'start':function(){\n                       new jBox('Notice', {\n                          content: 'Processing Voice Command: start'\n                      });\n\n                      player.play();\n                    },\n\n                     'pause':function(){\n                       new jBox('Notice', {\n                          content: 'Processing Voice Command: pause'\n                      });\n\n                      player.pause();\n                    },\n\n                    'stop':function(){\n                       new jBox('Notice', {\n                          content: 'Processing Voice Command: stop'\n                      });\n                      player.currentTime(0);\n                      player.pause();\n                    },\n\n                    'refresh':function(){\n                       new jBox('Notice', {\n                          content: 'Processing Voice Command: refresh'\n                      });\n                      location.reload();\n                    },\n\n                    'reload':function(){\n                       new jBox('Notice', {\n                          content: 'Processing Voice Command: reload'\n                      });\n                      location.reload();\n                    },\n\n                 '*term':function(term){\n     \n                       new jBox('Notice', {\n                          content: 'Processing Voice Command: '+term\n                      });\n                    },\n\n\n                ";
        $commands .= "}";
        $code .= $commands;
        $code .= "\n\t\t\$(function(){\n\t\t\t\$.ajax({url:'" . $base . "/video-themes/video-js/video.js', dataType: 'script', success: function(){\n            \$.ajax({url:'" . $base . "/js/videojs.custom.min.js', dataType: 'script', success: function(){\n            \$.ajax({url:'" . $base . "/js/youtube.js', dataType: 'script', success: function(){}});\n            \$.ajax({url:'" . $base . "/js/media.vimeo.js', dataType: 'script', success: function(){}});\n            \$.ajax({url:'" . $base . "/js/annyang.min.js', dataType: 'script', success: function(){\n                \n                 \n                 \n                 \$.get('" . $base . "/video/rcvitem?item=" . urlencode('jBox.css') . "', function(css)\n             {\n                 \$('<style type=\"text/css\"></style>')\n                    .html(css)\n                    .appendTo('head');\n\n                \$.ajax({url:'" . $base . "/js/jbox/jBox.js', dataType: 'script', success: function(){\n\n                 {$popup} \n\n                 setTimeout(function(){\n\n                    \$('.custom-overlays').mouseover();\n                    \$('.custom-overlays').mouseout();\n                 },1000);\n\n\n\n\n                \$.get('" . $base . "/video/rcvitem?item=" . urlencode('froala_content.min.css') . "', function(css){\n                    \$('<style type=\"text/css\"></style>')\n                    .html(css)\n                    .appendTo('head');\n                });\n\n                \$.get('" . $base . "/video/rcvitem?item=" . urlencode('froala_style.min.css') . "', function(css){\n                    \$('<style type=\"text/css\"></style>')\n                    .html(css)\n                    .appendTo('head');\n                });\n    \n                var voice_recognition = '{$ovr->enable_voice_recohnition}';\n\n                if(annyang && voice_recognition=='1') {\n                 annyang.addCommands(commands);\n                 annyang.start();\n                    }\n\n                }});\n\n\n             });\n\n\n\n            }});\n            " . $marker_js . "\n            \n\n            \$.get('" . $base . "/video/rcvitem?item=" . urlencode('videojs.markers.css') . "', function(css){\n                    \$('<style type=\"text/css\"></style>')\n                    .html(css)\n                    .appendTo('head');\n                });\n\n\n\n\t\t\t \$.get('" . $base . "/video/rcvitem?item=" . urlencode('video-js.css') . "', function(css)\n\t\t\t {\n   \t\t\t \t\$('<style type=\"text/css\"></style>')\n      \t\t\t.html(css)\n      \t\t\t.appendTo('head');\n\t\t\t\t\t\n\t\t\t\t\$('<style type=\"text/css\"></style>')\n\t\t\t\t.html(custu_css)\n\t\t\t\t.appendTo('head');\n\t\t\t\t";
        $main_css = $base . "/video-themes/theme-" . $model->theme . "/css/main.css";
        $code .= "\n\n                \$.get('" . $base . "/video/RcvThemecss?path=" . urlencode($main_css) . "', function(css2){\n                    \$('<style type=\"text/css\"></style>')\n                    .html(css2)\n                    .appendTo('head');\n                });\n                ";
        if ($model->overlay == "1") {
            $code .= "\$.ajax({url:'" . $base . "/video/rcvitem?item=" . urlencode("jquery.colorbox-min.js") . "', dataType: 'script', success: function(){\n\t\t\t\t\t \t\$.get('" . $base . "/video/rcvitem?item=" . urlencode("colorbox.css") . "', function(css)\n\t\t\t\t\t \t{\n\t\t\t   \t\t\t \t\$('<style type=\"text/css\"></style>')\n\t\t\t      \t\t\t.html(css)\n\t\t\t      \t\t\t.appendTo('head');\n\t\t\t\t\t\t";
        }
        if ($model->overlay == "2") {
            $code .= "\$.ajax({url:'" . $base . "/video/rcvitem?item=" . urlencode("jquery.colorbox-min.js") . "', dataType: 'script', success: function(){\n\t\t\t\t\t \t\$.get('" . $base . "/video/rcvitem?item=" . urlencode("colorbox.css") . "', function(css)\n\t\t\t\t\t \t{\n\t\t\t   \t\t\t \t\$('<style type=\"text/css\"></style>')\n\t\t\t      \t\t\t.html(css)\n\t\t\t      \t\t\t.appendTo('head');\n\t\t\t\t\t\t";
        }
        $code .= "startVjs();";
        $shopablejs = "";
        $temp_js = '';
        if ($model->shopableimage != '' && $model->enable_shopableimage == 1) {
            $shopablejs = "\n             \$('.overlays').css({top: ov_off.top , left: ov_off.left, height: ov_h, width: ov_w});\n            \$('.overlays').find('.vigmgr_main_img').css({top: ov_off.top , left: ov_off.left, height: ov_h, width: ov_w,position:'absolute'});\n           \n            \$('.custom-overlays').show();\n            player.pause(0);\n            player.volume(0);\n            \n            \n             setInterval(function(){\n\n                 \$('.custom-overlays').show();\n            },0);\n            \n            ";
            $ov1 = "var ov_off = \$('#{$randId}').offset();\n                var ov_h = '{$model->height}px';\n                var ov_w = '{$model->width}px';\n                console.log(ov_off);\n                \$('.overlays').css({top: ov_off.top , left: ov_off.left, height: ov_h-30, width: ov_w});\n                \$('.overlays').find('.vigmgr_main_img').css({top: ov_off.top , left: ov_off.left, height: ov_h, width: ov_w,position:'absolute'});\n                \$('.custom-overlays').show();\n                \$('.vjs-control-bar').hide().css('visibility','hidden');\n\n                \n                setInterval(function(){\n\n                 \$('.custom-overlays').show();\n                 \$('.vjs-control-bar').hide().css('visibility','hidden').remove();\n                 //player.pause();\n\n                 \n               },0);\n\n            setTimeout(function(){\n\n                player.pause();\n            },1000);\n\n                    ";
        }
        if ($model->overlay == "0") {
            $code .= "\n\n                \n               \n                setTimeout(function(){\n\n                      setTimeout(function(){\n\n                var ov_off = \$('#{$randId}').offset();\n                var ov_h = \$('#{$randId}').height();\n                var ov_w = \$('#{$randId}').width();\n                console.log('developer');\n                console.log(ov_off);\n                console.log(\$('#{$randId}').position());\n             \n\n               \$('.overlays').css({top: ov_off.top , left: ov_off.left, height: ov_h-30, width: ov_w,position:'fixed'});\n               \n               \$( window ).resize(function() {\n                var ov_off = \$('#{$randId}').offset();\n                var ov_h = \$('#{$randId}').height();\n                var ov_w = \$('#{$randId}').width();\n                console.log('developer');\n                console.log(ov_off);\n                console.log(\$('#{$randId}').position());\n                \$('.overlays').css({top: ov_off.top , left: ov_off.left, height: ov_h-30, width: ov_w,position:'fixed'});\n\n                calculated_top =  ov_off.top - \$(window).scrollTop();\n                \$('.overlays').css({top: calculated_top});\n                        \n                });\n\n                \$(window).scroll(function() { //when window is scrolled\n                        ov_off = \$('#{$randId}').offset();\n                       calculated_top =  ov_off.top - \$(window).scrollTop();\n                       calculated_left = ov_off.left - \$(window).scrollLeft();\n                         \$('.overlays').css({top: calculated_top,left:calculated_left});\n                      });\n\n            },10);\n\n\n                \n\n\n            },1000);\n\n                {$shopablejs}\n               \n\n\n                ";
        }
        if ($model->overlay == "1" || $model->overlay == "2") {
            $code .= "{$ov1}";
        }
        if ($model->overlay >= "1") {
            $code .= "});\n\t\t\t\t\t}});";
        }
        $code .= "\n\t\t\t });\n\t\t\t}});\n\n\n\t\t}});\n\t\t});\n\t}\n\t" . $bmFunc . "\n\t";
        // header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
        //header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
        header('Cache-Control: no-cache, must-revalidate');
        //header( 'Pragma: no-cache' );
        header("application/x-javascript");
        header("Content-Type: application/javascript");
        header("X-Content-Type-Options: nosniff");
        header("Access-Control-Allow-Origin: *");
        echo $code;
    }
コード例 #4
0
ファイル: Utils.php プロジェクト: rajveer4155/vidmgr
 /**
  * Get path to a specific upload folder
  * @param string $subPath
  */
 public static function uploadPath($subPath = null)
 {
     $path = poa('www') . '/../common/upload/';
     return empty($subPath) ? $path : $path . $subPath;
 }