Ejemplo n.º 1
0
 public function init()
 {
     $assets = dirname(__FILE__) . '/assets';
     $this->assetsPath = Yii::app()->assetManager->publish($assets, false, 1, YII_DEBUG);
     if (empty($this->imageAds)) {
         $this->imageAds = '/web/images/bg_default.png';
     }
     if (empty($this->data)) {
         $data[] = array('file' => 'https://s3.amazonaws.com/jomedia-jwplayer/samples/tears-of-steel.mp4', 'label' => '128K');
         $data[] = array('file' => 'https://s3.amazonaws.com/jomedia-jwplayer/samples/tears-of-steel.mp4', 'label' => '320K VIP');
         $source = json_encode($data);
     }
     $video = VideoModel::model()->findByPk($this->videoId);
     //check xem co phai iphone 3G khong
     $device = Yii::app()->session['device'];
     /*if(!empty($device) && $device['os'] == 'iOS' && (int) Yii::app()->session['deviceOS'] <= 6 ){
           $source = VideoModel::model()->builDataPlayerVideo($this->videoId,null, Yii::app()->params['video.profile.default']['iphone'][0]);
       }else {
           $source = VideoModel::model()->builDataPlayerVideo($this->videoId);
       }*/
     $source = VideoModel::model()->builDataPlayerVideo($this->videoId);
     $image = AvatarHelper::getAvatar("video", $this->videoId, 640);
     $cs = Yii::app()->clientScript;
     $cs->registerScriptFile($this->assetsPath . '/jwplayer.js', CClientScript::POS_END);
     $cs->registerScript('play_video' . $this->id, "\n            jwplayer('" . $this->id . "').setup({\n                width: '" . $this->width . "',\n                height: " . $this->height . ",\n                image: '" . $image . "',\n                sources: {$source},\n                autostart: " . $this->autostart . ",\n                expand: '" . $this->expand . "',\n                primary: '" . $this->primary . "',\n                /*plugins: {\n                    '" . $this->assetsPath . "/vast.js': {\n                      client:'vast',\n                      schedule:{\n                        overlay: { offset: " . $this->offset . ", tag: '" . Yii::app()->createUrl('/player/banner') . "', type:'nonlinear' }\n                      }\n                    }\n                  }*/\n            });\n        ", CClientScript::POS_END);
     if ($this->expand) {
         $cs->registerScript('play_video_expand' . $this->id, "\n            function onPlayerExpandCollapse() {\n\n                if(jwplayer('" . $this->id . "').getFullscreen) {\n                    jwplayer('" . $this->id . "').setFullscreen(false);\n                }\n                if(\$('.video_player').width() <= 745){\n                    \$('.colum2').css({'margin-top':'20px'});\n                    \$('.video_player').css({'height':'540px'});\n                    \$('.video_player').css({'width':'960px'});\n                    \$('#player-holder').removeClass('watch-normal-mode');\n                    \$('#player-holder').addClass('watch-large-mode');\n                    \$('.video_player .colum2').css({'margin-top':'-370px'});\n                    onPlayerExpand();\n                }else{\n                    onPlayerCollapse();\n                    \$('.colum2').css({'margin-top':''});\n                    \$('.video_player').css({'height':'390px'});\n                    \$('.video_player').css({'width':'745px'});\n                    \$('#player-holder').removeClass('watch-large-mode');\n                    \$('#player-holder').addClass('watch-normal-mode');\n                }\n            }\n\n            function onPlayerExpand() {\n              jwplayer('" . $this->id . "').resize(960,540);\n            }\n\n            function onPlayerCollapse() {\n              jwplayer('" . $this->id . "').resize(745,390);\n            }\n            ;\n        ", CClientScript::POS_END);
     }
     //track and log
     $deviceType = 'mobile';
     $isUserLogin = Yii::app()->user->isGuest ? 'false' : 'true';
     $cs->registerScript('play_video_current' . $this->id, "\n        var device_type = '" . $deviceType . "';\n        var listPlayed =Array();\n        var playVideoFlag = true;\n        var logedin = " . $isUserLogin . ";\n        jwplayer().onPlay(function(){\n            console.log(JSON.stringify(check_video_quality()));\n            if(!check_video_quality()){\n             jwplayer('" . $this->id . "').pause();\n            }\n\n        });\n        jwplayer().onBeforePlay(function() {\n\n            playVideoFlag = false;\n        });\n        jwplayer().onTime(function(event) {\n            if(Math.round(event.position) >=5){\n                if(playVideoFlag) {\n                    playVideoFlag = false;\n                    var action = 'Play Video';\n                    if(in_array_item(listPlayed,'video_" . $video->id . "')){\n                        var action = 'Replay Video';\n                    }\n                    var item = 'video_" . $video->id . "';\n                    if(!in_array_item(listPlayed,item)){\n                        listPlayed.push(item);\n                    }\n                    console.log(device_type+'-'+action);\n                    ga('send', 'event', device_type, action,'" . CHtml::encode($video->name . "-" . $video->artist_name . "-" . $video->id) . "');\n                    ajax_load('/player/logVideo',{'id':" . $video->id . "});\n                }\n            }\n        });\n        ", CClientScript::POS_END);
     //check login 720p
     $obj = array("obj_type" => 'video', 'name' => $video->name, 'id' => $video->id, 'artist' => $video->artist_name);
     $urlDetail = URLHelper::makeUrl($obj);
     $lac = Yii::app()->user->getState('last_action');
     $lurl = Yii::app()->user->getState('last_url');
     Yii::app()->user->setState('last_url', null);
     $register_url = Yii::app()->createUrl("account/package");
     $login_url = Yii::app()->createUrl("account/login");
     $js = '';
     if ($lac == '720p' && $lurl == $urlDetail && !Yii::app()->user->isGuest) {
         $js = 'jwplayer().setCurrentQuality(0);';
     }
     $js = 'jwplayer().setCurrentQuality(0);';
     $cs->registerScript('play_video_current_changeQ' . $this->id, "\n\n                jwplayer().onQualityLevels(function(event){\n                    var currQIndex = jwplayer().getCurrentQuality();\n                    var currQL = jwplayer().getQualityLevels();\n                    var bitrate = currQL[currQIndex].label;\n                    if(logedin==false && bitrate=='720p'){\n                        jwplayer().setCurrentQuality(currQIndex+1);\n                    }\n                    jwplayer().setCurrentQuality(currQIndex+1);\n                });\n                jwplayer().onQualityChange(function(event){\n                    var logedin = false;\n\n                    \$.ajax({\n                        url: '/ajax/isAuthenticate',\n                        type: 'post',\n                        data: {fa:'720p',url_return:'" . $urlDetail . "'},\n                        async: false,\n                        dataType: 'json',\n                        success: function(data){\n                            if(data.errorCode==0){\n                                logedin = true;\n                            }\n                        }\n                    })\n                    var currEQIndex = jwplayer().getCurrentQuality();\n                    var currQL = jwplayer().getQualityLevels();\n                    var bitrate = currQL[currEQIndex].label;\n\n                    if(logedin==false && bitrate=='720p'){\n                         var html = 'Quý khách vui lòng đăng ký để nghe miễn phí nội dung chất lượng cao.';\n                            html += '<div class=\"clb ovh\">';\n                            html += '<div class=\"btn-popup btn-popup-green\" style=\"width: 45%; float: left;\">';\n                            html += '<a href=\"  {$register_url} \" class=\"show\" style=\"color: #FFF\">Đăng ký</a>';\n                            html += '</div>';\n                            html += '<div class=\"btn-popup btn-popup-green\" style=\"width: 45%; float: right;\">';\n                            html += '<a href=\"javascript::void();\" onclick=\"Popup.close()\" class=\"show\" style=\"color: #FFF\">Hủy</a>';\n                            html += '</div>';\n                            html += '</div>';\n                            html += '</div>';\n                         Popup.alert(html);\n\n\n                    }\n                });\n            ", CClientScript::POS_END);
     $cs->registerScript('check_current_video' . $this->id, "\n        function check_video_quality(){\n            var anable_play = true;\n            var currEQIndex = jwplayer().getCurrentQuality();\n            var currQL = jwplayer().getQualityLevels();\n            var bitrate = currQL[currEQIndex].label;\n            if(!userSubs){\n                console.log(JSON.stringify(bitrate));\n                if(userPhone && bitrate == '720p'){\n                   return false;\n                }else{\n                }\n            }\n        }\n            ", CClientScript::POS_END);
     parent::init();
 }
        ?>
	<?php 
        if ($i == 1) {
            ?>
		<li>
			<div class="chart-index chart-1st"><b>1</b></div>
			<div class="chart-content-1st">
				<a href="<?php 
            echo $link;
            ?>
" title="<?php 
            echo CHtml::encode($album->name) . ' - ' . CHtml::encode($album->artist_name);
            ?>
">
					<img width="50" src="<?php 
            echo AvatarHelper::getAvatar("album", $album->id, 150);
            ?>
" alt="<?php 
            echo CHtml::encode($album->name) . ' - ' . CHtml::encode($album->artist_name);
            ?>
" />
				</a>
				<h3>
					<a href="<?php 
            echo $link;
            ?>
" class="song_name"  title="<?php 
            echo CHtml::encode($album->name);
            ?>
">
		                    <?php 
Ejemplo n.º 3
0
<div class="home_slide" style="margin-bottom: 10px;" >
    <?php 
$newsEvent = NewsEventModel::model()->getEventByChannel('web');
$data = array();
$i = 0;
foreach ($newsEvent as $value) {
    $data[$i]['avatar'] = AvatarHelper::getAvatar('newsEvent', $value->id, 's1');
    $data[$i]['link'] = NewsEventModel::model()->getEventLink($value);
    $data[$i]['title'] = $value->name;
    $data[$i]['desc'] = '';
    $i++;
}
$this->widget('application.widgets.touch.slideshow.SlideshowWidget', array('data' => $data));
?>
</div>

<div class="item-box">
    <a href='<?php 
echo Yii::app()->createUrl('/videoplaylist');
?>
' class='wrap-head mr-t-15' title='<?php 
echo Yii::t("wap", "Video Playlist");
?>
'>
        <div class='head-label clearfix'>
            <span class='text'><?php 
echo Yii::t("wap", "Video Playlist");
?>
</span>
            <span class='title'></span>
        </div><!-- End .head-label -->
Ejemplo n.º 4
0
echo CHtml::encode($album->artist_name);
?>
</a></p>
    </div>
</div>


<ul class="bxh_album_list song_detail_list mart20">
    <?php 
foreach ($songs as $song) {
    $urlKey = Common::makeFriendlyUrl(trim($song->song->name));
    $artist_name = Common::makeFriendlyUrl($song->artist_name);
    $link = Yii::app()->createUrl("song/view", array("id" => $song->song_id, "title" => $urlKey, 'artist' => $artist_name));
    $artistLink = Yii::app()->createUrl("/search") . "?" . http_build_query(array("q" => CHtml::encode($song->song->artist_name)));
    $artistId = SongArtistModel::model()->findByAttributes(array('song_id' => $song->song->id))->artist_id;
    $image = AvatarHelper::getAvatar("artist", $artistId, 640);
    ?>
        <li>
            <a href="<?php 
    echo $link;
    ?>
">
                <img src="<?php 
    echo $image;
    ?>
" alt="<?php 
    echo CHtml::encode($song->song->artist_name);
    ?>
">
            </a>
            <h3><a title="<?php 
Ejemplo n.º 5
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['AdminRadioModel'])) {
         //echo '<pre>';print_r($_POST);exit;
         $model->attributes = $_POST['AdminRadioModel'];
         if (isset($_POST['AdminRadioModel']['time_point'])) {
             $time_point = implode(',', $_POST['AdminRadioModel']['time_point']);
             $model->setAttribute('time_point', $time_point);
         } else {
             $model->setAttribute('time_point', 1);
         }
         if (isset($_POST['AdminRadioModel']['day_week'])) {
             $day_week = implode(',', $_POST['AdminRadioModel']['day_week']);
             $model->setAttribute('day_week', $day_week);
         } else {
             $model->setAttribute('day_week', 1);
         }
         if (isset($_POST['AdminRadioModel']['weather_code'])) {
             $weather_code = implode(',', $_POST['AdminRadioModel']['weather_code']);
             $model->setAttribute('weather_code', $weather_code);
         } else {
             $model->setAttribute('weather_code', '');
         }
         if (isset($_POST['AdminRadioModel']['daytotime'])) {
             $dayToTime = json_encode($_POST['AdminRadioModel']['daytotime']);
             $model->setAttribute('day_to_time', $dayToTime);
         } else {
             $model->setAttribute('day_to_time', '');
         }
         if ($model->save()) {
             $res = Yii::app()->db->createCommand("DELETE FROM radio_weather WHERE radio_id=" . intval($model->id))->execute();
             if (isset($_POST['AdminRadioModel']['weather_id'])) {
                 $radioWModel = new AdminRadioWeatherModel();
                 $sql = "INSERT INTO radio_weather(radio_id, weather_id) VALUES";
                 foreach ($_POST['AdminRadioModel']['weather_id'] as $w) {
                     $radioId = $model->id;
                     $sqlArr[] = "('{$radioId}','{$w}')";
                 }
                 $sql .= implode(',', $sqlArr);
                 $sql .= "ON DUPLICATE KEY UPDATE radio_id = '{$radioId}'";
                 $res = Yii::app()->db->createCommand($sql)->execute();
             }
             if (isset($_POST['tmp_file_path']) && $_POST['tmp_file_path'] != '') {
                 $tmpFile = _APP_PATH_ . DS . "data" . DS . "tmp" . DS . $_POST['tmp_file_path'];
                 if (file_exists($tmpFile)) {
                     //$this->moveFile($model->id, $model->type, $tmpFile);
                     $res = AvatarHelper::processAvatar($model, $tmpFile);
                 }
             }
             if (isset($_POST['yt0']) && ($_POST['yt0'] = 'Save')) {
                 $this->redirect(array('view', 'id' => $model->id));
             } else {
                 $this->redirect(array('update', 'id' => $model->id));
             }
         }
     }
     $this->render('update', array('model' => $model));
 }
        ?>
	<?php 
        if ($i == 1) {
            ?>
		<li>
			<div class="chart-index chart-1st"><b>1</b></div>
			<div class="chart-content-1st">
				<a href="<?php 
            echo $link;
            ?>
" title="<?php 
            echo CHtml::encode($song->name) . ' - ' . CHtml::encode($song->artist_name);
            ?>
">
					<img width="50" src="<?php 
            echo AvatarHelper::getAvatar("artist", $song->song_artist[0]->artist_id, 150);
            ?>
" alt="<?php 
            echo CHtml::encode($song->name) . ' - ' . CHtml::encode($song->artist_name);
            ?>
" />
				</a>
				<h3>
					<a href="<?php 
            echo $link;
            ?>
" class="song_name"  title="<?php 
            echo CHtml::encode($song->name);
            ?>
">
		                    <?php 
Ejemplo n.º 7
0
<?php

foreach ($songs as $song) {
    $artist_name = Common::makeFriendlyUrl($song->artist_name);
    $link = Yii::app()->createUrl("song/view", array("id" => $song['id'], "title" => Common::makeFriendlyUrl(CHtml::encode($song['name'])), 'artist' => $artist_name));
    ?>
<li>
	<a href="<?php 
    echo $link;
    ?>
" title="<?php 
    echo CHtml::encode($song['name']) . ' - ' . CHtml::encode($song['artist_name']);
    ?>
"><img src="<?php 
    echo AvatarHelper::getAvatar("artist", $song['artist_id'], 50);
    ?>
" alt="<?php 
    echo $song['name'];
    ?>
" width="50" height="50" /></a>
	<h3><a href="<?php 
    echo $link;
    ?>
" class="song_name"><?php 
    echo Formatter::smartCut(CHtml::encode($song['name']), 24);
    ?>
</a></h3>
	<?php 
    $linkArtist = Yii::app()->createUrl("/search") . "?" . http_build_query(array("q" => CHtml::encode(CHtml::encode($song['artist_name']))));
    ?>
	<h4 class="song_aritis"><a href="<?php 
Ejemplo n.º 8
0
    ?>
                <li><a rel="<?php 
    echo Yii::app()->createUrl("user/loginPopup", array('class' => 'top'));
    ?>
" class="has-ajax-pop">Đăng nhập</a></li>
                <li>|</li>
                <li><a rel="nofollow" href="<?php 
    echo Yii::app()->createUrl("user/register");
    ?>
">Đăng ký</a></li>
            <?php 
} else {
    ?>
            	<li class="sub_hover user-menu">
            	<img class="user-avatar" src="<?php 
    echo AvatarHelper::getAvatar("user", Yii::app()->user->id, 50);
    ?>
" width="25" height="25" />
            		<a href="<?php 
    echo Yii::app()->createUrl("/user/detail");
    ?>
">
            			<span><?php 
    echo Formatter::smartCut(Yii::app()->user->username, 12);
    ?>
</span>
            		</a>
            		<ul class="sub_nav">
	            		<li><a href="<?php 
    echo Yii::app()->createUrl("/user/detail", array('id' => $userId, 'tab' => 'playlist'));
    ?>
Ejemplo n.º 9
0
<?php

header("Content-type: text/javascript");
// LOAD LANGUAGE AND FUNCTION FOR JAVASCRIPT
echo "var LANG = [] ;\n";
if (!empty($data)) {
    foreach ($data as $key => $val) {
        $key = addslashes($key);
        $val = addslashes($val);
        echo "LANG['{$key}']='{$val}';";
    }
}
echo "\n";
$script = "function __t(key) { if(LANG[key]){ return LANG[key]; }return key;}\n";
echo $script;
echo "\n";
echo AvatarHelper::getAvatarJs();
echo "\n";
// DEFINE URL FOR JAVASCRIPT
echo "var base_url = '" . Yii::app()->homeUrl . "'\n";
echo "var ajax_url = '" . Yii::app()->createUrl("ajax") . "'\n";
echo "var user_url = '" . Yii::app()->createUrl("user/detail") . "'\n";
echo "var popup_login_url = '" . Yii::app()->createUrl("user/loginPopup") . "'\n";
echo "var popup_promotion = '" . Yii::app()->createUrl("user/promotion") . "'\n";
echo "var popup_subscribe = '" . Yii::app()->createUrl("user/package") . "'\n";
echo "var is_vip = '" . $user_sub . "'\n";
echo "var ajax_loading='" . Yii::app()->request->baseUrl . "/web/images/content_loading.gif'\n";
echo "var time_play_loging='10000'\n";
//10 giây
Ejemplo n.º 10
0
 public function getAvatarUrl($id = null, $size = "150", $cacheBrowser = false)
 {
     if (!isset($id)) {
         $id = $this->id;
     }
     $path = AvatarHelper::getAvatar("newsEvent", $id, $size);
     return $path . "?v=" . time();
 }
Ejemplo n.º 11
0
        $link = Yii::app()->createUrl("artist/view", array("id" => $artist->id));
        ?>
                <li class="<?php 
        if ($i % 2 == 1) {
            echo 'marr_0';
        } else {
            echo '';
        }
        ?>
">
                    <a href="<?php 
        echo $link;
        ?>
">
                        <img style="width: 120px;" src="<?php 
        echo AvatarHelper::getAvatar("artist", $artist->id, 120);
        ?>
" alt="<?php 
        echo $artist->name;
        ?>
" />
                    </a>
                    <p><a href="<?php 
        echo $link;
        ?>
" title="<?php 
        echo $artist->name;
        ?>
"><?php 
        echo Formatter::substring(CHtml::encode($artist->name), " ", 3, 12);
        ?>
Ejemplo n.º 12
0
  <div class="m-carousel-inner">			    
    <?php 
$i = 1;
foreach ($slideVideos as $video) {
    $link = Yii::app()->createUrl('video/view', array('id' => $video['object_id'], 'url_key' => Common::makeFriendlyUrl($video['name']), "artist" => Common::makeFriendlyUrl(trim($video['artist_name']))));
    ?>
		<a href="<?php 
    echo $link;
    ?>
">
		<div class="m-item <?php 
    echo $i == 1 ? 'm-active' : '';
    ?>
 ">
	      	<img src="<?php 
    echo AvatarHelper::getAvatar('newsEvent', $video['id'], 's1');
    ?>
" />
	    </div>
	    </a>
		<?php 
    $i++;
}
?>
								  
  </div>
  <!-- the controls -->
  <div class="m-carousel-controls m-carousel-bulleted">
  	<?php 
if (count($slideVideos) > 0) {
    ?>