1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00

Creating a plugin for replace configurations->adsense

This commit is contained in:
daniel 2019-08-30 16:18:21 -03:00
parent c3dc469ccc
commit f5be6d3579
16 changed files with 342 additions and 237 deletions

View file

@ -1973,3 +1973,47 @@ function ddosProtection() {
return true; return true;
} }
function getAdsLeaderBoardTop(){
$ad = YouPHPTubePlugin::getObjectDataIfEnabled('ADs');
if(!empty($ad)){
if(isMobile()){
return $ad->leaderBoardTopMobile->value;
}else{
return $ad->leaderBoardTop->value;
}
}
}
function getAdsLeaderBoardMiddle(){
$ad = YouPHPTubePlugin::getObjectDataIfEnabled('ADs');
if(!empty($ad)){
if(isMobile()){
return $ad->leaderBoardMiddleMobile->value;
}else{
return $ad->leaderBoardMiddle->value;
}
}
}
function getAdsLeaderBoardFooter(){
$ad = YouPHPTubePlugin::getObjectDataIfEnabled('ADs');
if(!empty($ad)){
if(isMobile()){
return $ad->leaderBoardFooterMobile->value;
}else{
return $ad->leaderBoardFooter->value;
}
}
}
function getAdsSideRectangle(){
$ad = YouPHPTubePlugin::getObjectDataIfEnabled('ADs');
if(!empty($ad)){
if(isMobile()){
return $ad->sideRectangle->value;
}else{
return $ad->sideRectangle->value;
}
}
}

77
plugin/ADs/ADs.php Normal file
View file

@ -0,0 +1,77 @@
<?php
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
class ADs extends PluginAbstract {
public function getDescription() {
$txt = "Handle the ads system, like Adsense or similar";
//$help = "<br><small><a href='https://github.com/DanielnetoDotCom/YouPHPTube/wiki/AD_Overlay-Plugin' target='__blank'><i class='fas fa-question-circle'></i> Help</a></small>";
$help = "";
return $txt . $help;
}
public function getName() {
return "ADs";
}
public function getUUID() {
return "ADs73225-3807-4167-ba81-0509dd280e06";
}
public function getPluginVersion() {
return "1.0";
}
public function getEmptyDataObject() {
global $global,$config;
$obj = new stdClass();
$adsense = $config->getAdsense();
$o = new stdClass();
$o->type = "textarea";
$o->value = empty($adsense)?"<img src='{$global['webSiteRootURL']}plugin/ADs/sample728x90.jpg'>":$adsense;
$obj->leaderBoardTop = $o;
$o = new stdClass();
$o->type = "textarea";
$o->value = empty($adsense)?"<img src='{$global['webSiteRootURL']}plugin/ADs/sample728x90.jpg'>":$adsense;;
$obj->leaderBoardMiddle = $o;
/*
$o = new stdClass();
$o->type = "textarea";
$o->value = empty($adsense)?"<img src='{$global['webSiteRootURL']}plugin/ADs/sample728x90.jpg'>":$adsense;;
$obj->leaderBoardFooter = $o;
*
*/
$o = new stdClass();
$o->type = "textarea";
$o->value = empty($adsense)?"<img src='{$global['webSiteRootURL']}plugin/ADs/sample300x250.jpg'>":$adsense;;
$obj->sideRectangle = $o;
$o = new stdClass();
$o->type = "textarea";
$o->value = empty($adsense)?"<img src='{$global['webSiteRootURL']}plugin/ADs/sample300x250.jpg'>":$adsense;;
$obj->leaderBoardTopMobile = $o;
$o = new stdClass();
$o->type = "textarea";
$o->value = empty($adsense)?"<img src='{$global['webSiteRootURL']}plugin/ADs/sample300x250.jpg'>":$adsense;;
$obj->leaderBoardMiddleMobile = $o;
/*
$o = new stdClass();
$o->type = "textarea";
$o->value = empty($adsense)?"<img src='{$global['webSiteRootURL']}plugin/ADs/sample300x250.jpg'>":$adsense;;
$obj->leaderBoardFooterMobile = $o;
*
*/
return $obj;
}
public function getTags() {
return array('free');
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
plugin/ADs/sample728x90.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View file

@ -54,8 +54,6 @@ class CustomizeAdvanced extends PluginAbstract {
$obj->doNotUseXsendFile = false; $obj->doNotUseXsendFile = false;
$obj->makeVideosInactiveAfterEncode = false; $obj->makeVideosInactiveAfterEncode = false;
$obj->usePermalinks = false; $obj->usePermalinks = false;
$obj->showAdsenseBannerOnTop = false;
$obj->showAdsenseBannerOnLeft = true;
$obj->disableAnimatedGif = false; $obj->disableAnimatedGif = false;
$obj->removeBrowserChannelLinkFromMenu = false; $obj->removeBrowserChannelLinkFromMenu = false;
$obj->EnableWavesurfer = false; $obj->EnableWavesurfer = false;

View file

@ -42,7 +42,7 @@ if(!isset($global['systemRootPath'])){
<div data-spy="affix" style="margin-right: 10vw;" > <div data-spy="affix" style="margin-right: 10vw;" >
<div class="list-group-item "> <div class="list-group-item ">
<?php <?php
echo $config->getAdsense(); echo getAdsSideRectangle();
?> ?>
</div> </div>
</div> </div>

View file

@ -72,7 +72,6 @@ class Gallery extends PluginAbstract {
$obj->screenColsMedium = 3; $obj->screenColsMedium = 3;
$obj->screenColsSmall = 2; $obj->screenColsSmall = 2;
$obj->screenColsXSmall = 1; $obj->screenColsXSmall = 1;
$obj->showTopBannerOnMobile = false;
return $obj; return $obj;
} }

View file

@ -10,7 +10,7 @@ function showThis($who) {
return false; return false;
} }
function createGallery($title, $sort, $rowCount, $getName, $mostWord, $lessWord, $orderString, $defaultSort = "ASC", $ignoreGroup=false) { function createGallery($title, $sort, $rowCount, $getName, $mostWord, $lessWord, $orderString, $defaultSort = "ASC", $ignoreGroup = false) {
if (!showThis($getName)) { if (!showThis($getName)) {
return ""; return "";
} }
@ -141,7 +141,7 @@ function createGallerySection($videos, $crc = "", $get = array()) {
$startG = microtime(true); $startG = microtime(true);
$images = Video::getImageFromFilename($value['filename'], $value['type']); $images = Video::getImageFromFilename($value['filename'], $value['type']);
@$timesG[__LINE__] += microtime(true) - $startG; @$timesG[__LINE__] += microtime(true) - $startG;
if(!is_object($images)){ if (!is_object($images)) {
$images = new stdClass(); $images = new stdClass();
$images->thumbsGif = ""; $images->thumbsGif = "";
$images->poster = "{$global['webSiteRootURL']}view/img/notfound.jpg"; $images->poster = "{$global['webSiteRootURL']}view/img/notfound.jpg";
@ -164,7 +164,7 @@ function createGallerySection($videos, $crc = "", $get = array()) {
?> ?>
</div> </div>
<?php <?php
if($value['type']!=='pdf' && $value['type']!=='article'){ if ($value['type'] !== 'pdf' && $value['type'] !== 'article') {
?> ?>
<span class="duration"><?php echo Video::getCleanDuration($value['duration']); ?></span> <span class="duration"><?php echo Video::getCleanDuration($value['duration']); ?></span>
<div class="progress" style="height: 3px; margin-bottom: 2px;"> <div class="progress" style="height: 3px; margin-bottom: 2px;">
@ -291,8 +291,12 @@ function createGallerySection($videos, $crc = "", $get = array()) {
?> ?>
</div> </div>
<?php } ?> <?php
}
?>
<div class="row text-center" style="padding: 10px;">
<?php echo getAdsLeaderBoardMiddle(); ?>
</div>
<!-- <!--
createGallerySection createGallerySection
<?php <?php

View file

@ -80,15 +80,9 @@ $contentSearchFound = false;
<body class="<?php echo $global['bodyClass']; ?>"> <body class="<?php echo $global['bodyClass']; ?>">
<?php include $global['systemRootPath'] . 'view/include/navbar.php'; ?> <?php include $global['systemRootPath'] . 'view/include/navbar.php'; ?>
<div class="container-fluid gallery" itemscope itemtype="http://schema.org/VideoObject"> <div class="container-fluid gallery" itemscope itemtype="http://schema.org/VideoObject">
<?php
if (!empty($obj->showTopBannerOnMobile) || !isMobile()) {
?>
<div class="row text-center" style="padding: 10px;"> <div class="row text-center" style="padding: 10px;">
<?php echo $config->getAdsense(); ?> <?php echo getAdsLeaderBoardTop(); ?>
</div> </div>
<?php
}
?>
<div class="col-sm-10 col-sm-offset-1 list-group-item"> <div class="col-sm-10 col-sm-offset-1 list-group-item">
<div class="row mainArea"> <div class="row mainArea">

View file

@ -76,7 +76,7 @@ $liveDO = YouPHPTubePlugin::getObjectData("Live");
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<?php <?php
echo $config->getAdsense(); echo getAdsSideRectangle();
?> ?>
</div> </div>
</div> </div>

View file

@ -77,7 +77,7 @@ if(!empty($objSecure)){
<div class="container"> <div class="container">
<div class="col-md-9 col-sm-9 col-xs-9" style="margin: 0; padding: 0;" id="embedVideo-content"> <div class="col-md-9 col-sm-9 col-xs-9" style="margin: 0; padding: 0;" id="embedVideo-content">
<?php <?php
echo $config->getAdsense(); echo getAdsLeaderBoardTop();
?> ?>
<div class="embed-responsive embed-responsive-16by9" > <div class="embed-responsive embed-responsive-16by9" >
<video poster="<?php echo $global['webSiteRootURL']; ?>plugin/Live/view/OnAir.jpg" controls autoplay="autoplay" <video poster="<?php echo $global['webSiteRootURL']; ?>plugin/Live/view/OnAir.jpg" controls autoplay="autoplay"
@ -106,7 +106,7 @@ if(!empty($objSecure)){
</div> </div>
<?php <?php
echo $config->getAdsense(); echo getAdsLeaderBoardFooter();
?> ?>
</div> </div>
<div class="col-md-3 col-sm-3 col-xs-3" style="margin: 0; padding: 0;"> <div class="col-md-3 col-sm-3 col-xs-3" style="margin: 0; padding: 0;">

View file

@ -87,7 +87,7 @@ if(!empty($_GET['embed'])){
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<?php <?php
echo $config->getAdsense(); echo getAdsSideRectangle();
?> ?>
</div> </div>
</div> </div>

View file

@ -17,10 +17,10 @@ $playList = PlayList::getVideosFromPlaylist($_GET['playlists_id']);
$playListData = array(); $playListData = array();
$videoStartSeconds = array(); $videoStartSeconds = array();
foreach ($playList as $value) { foreach ($playList as $value) {
if($value['type'] === 'embed'){ if ($value['type'] === 'embed') {
$sources[0]['type'] = 'video'; $sources[0]['type'] = 'video';
$sources[0]['url'] = $value["videoLink"]; $sources[0]['url'] = $value["videoLink"];
}else{ } else {
$sources = getVideosURL($value['filename']); $sources = getVideosURL($value['filename']);
} }
$images = Video::getImageFromFilename($value['filename'], $value['type']); $images = Video::getImageFromFilename($value['filename'], $value['type']);
@ -99,7 +99,7 @@ foreach ($playList as $value) {
<div class="col-lg-12 col-sm-12 col-xs-12"> <div class="col-lg-12 col-sm-12 col-xs-12">
<center style="margin:5px;"> <center style="margin:5px;">
<?php <?php
echo $config->getAdsense(); echo getAdsLeaderBoardTop();
?> ?>
</center> </center>
</div> </div>
@ -158,15 +158,9 @@ foreach ($playList as $value) {
<div class="col-sm-8 col-md-8" id="modeYoutubeBottomContent"> <div class="col-sm-8 col-md-8" id="modeYoutubeBottomContent">
</div> </div>
<div class="col-sm-2 col-md-2 bgWhite list-group-item rightBar"> <div class="col-sm-2 col-md-2 bgWhite list-group-item rightBar">
<?php
if (!empty($advancedCustom->showAdsenseBannerOnLeft)) {
?>
<div class="col-lg-12 col-sm-12 col-xs-12"> <div class="col-lg-12 col-sm-12 col-xs-12">
<?php echo $config->getAdsense(); ?> <?php echo getAdsSideRectangle(); ?>
</div> </div>
<?php
}
?>
<input type="search" id="playListSearch" class="form-control" placeholder=" <?php echo __("Search"); ?>"/> <input type="search" id="playListSearch" class="form-control" placeholder=" <?php echo __("Search"); ?>"/>
<select class="form-control" id="embededSortBy" > <select class="form-control" id="embededSortBy" >
<option value="default"> <?php echo __("Default"); ?></option> <option value="default"> <?php echo __("Default"); ?></option>

View file

@ -82,7 +82,7 @@ $contentSearchFound = false;
<?php include $global['systemRootPath'] . 'view/include/navbar.php'; ?> <?php include $global['systemRootPath'] . 'view/include/navbar.php'; ?>
<div class="container YouTube" itemscope itemtype="http://schema.org/VideoObject"> <div class="container YouTube" itemscope itemtype="http://schema.org/VideoObject">
<div class="row text-center" style="padding: 10px;"> <div class="row text-center" style="padding: 10px;">
<?php echo $config->getAdsense(); ?> <?php echo getAdsLeaderBoardTop(); ?>
</div> </div>
<div class=""> <div class="">

View file

@ -519,9 +519,10 @@ if (User::isAdmin()) {
<div class="form-group"> <div class="form-group">
<label class="col-md-2"><?php echo __("Google Ad Sense"); ?></label> <label class="col-md-2"><?php echo __("Google Ad Sense"); ?></label>
<div class="col-md-10"> <div class="col-md-10">
<textarea id="adsense" class="form-control" type="text" rows="20" ><?php echo $config->getAdsense(); ?></textarea> <input type="hidden" value="" id="adsense"/>
<small>For Google AdSense code: <a href='https://www.google.com/adsense' target="_blank">https://www.google.com/adsense</a></small><br> <div class="alert alert-info">
<small>Leave blank for native code</small> Google AD Sense and any other Ads provider are moved to the <a href='<?php echo $global['webSiteRootURL']; ?>plugins'>ADs plugin </a>
</div>
</div> </div>
</div> </div>

View file

@ -177,7 +177,7 @@ if (!empty($video)) {
$data = getimgsize($source['path']); $data = getimgsize($source['path']);
$imgw = $data[0]; $imgw = $data[0];
$imgh = $data[1]; $imgh = $data[1];
}else{ } else {
$img = $images->poster; $img = $images->poster;
} }
} else { } else {
@ -246,7 +246,6 @@ YouPHPTubePlugin::getModeYouTube($v['id']);
$video['type'] = "video"; $video['type'] = "video";
} }
$img_portrait = ($video['rotation'] === "90" || $video['rotation'] === "270") ? "img-portrait" : ""; $img_portrait = ($video['rotation'] === "90" || $video['rotation'] === "270") ? "img-portrait" : "";
if (!empty($advancedCustom->showAdsenseBannerOnTop)) {
?> ?>
<style> <style>
.compress { .compress {
@ -257,13 +256,12 @@ YouPHPTubePlugin::getModeYouTube($v['id']);
<div class="col-lg-12 col-sm-12 col-xs-12"> <div class="col-lg-12 col-sm-12 col-xs-12">
<center style="margin:5px;"> <center style="margin:5px;">
<?php <?php
echo $config->getAdsense(); echo getAdsLeaderBoardTop();
?> ?>
</center> </center>
</div> </div>
</div> </div>
<?php <?php
}
$vType = $video['type']; $vType = $video['type'];
if ($vType == "linkVideo") { if ($vType == "linkVideo") {
$vType = "video"; $vType = "video";
@ -276,7 +274,7 @@ YouPHPTubePlugin::getModeYouTube($v['id']);
?> ?>
<div class="row" id="modeYoutubeBottom"> <div class="row" id="modeYoutubeBottom">
<div class="col-sm-1 col-md-1"></div> <div class="col-sm-1 col-md-1"></div>
<div class="col-sm-6 col-md-6" id="modeYoutubeBottomContent"> <div class="col-sm-6 col-md-6" id="modeYoutubeBottomContent">
<?php <?php
@ -284,14 +282,10 @@ YouPHPTubePlugin::getModeYouTube($v['id']);
?> ?>
</div> </div>
<div class="col-sm-4 col-md-4 bgWhite list-group-item rightBar"> <div class="col-sm-4 col-md-4 bgWhite list-group-item rightBar">
<?php <div class="col-lg-12 col-sm-12 col-xs-12 text-center">
if (!empty($advancedCustom->showAdsenseBannerOnLeft)) { <?php echo getAdsSideRectangle(); ?>
?>
<div class="col-lg-12 col-sm-12 col-xs-12">
<?php echo $config->getAdsense(); ?>
</div> </div>
<?php <?php
}
if (!empty($playlist_id)) { if (!empty($playlist_id)) {
include $global['systemRootPath'] . 'view/include/playlist.php'; include $global['systemRootPath'] . 'view/include/playlist.php';
?> ?>
@ -445,7 +439,7 @@ YouPHPTubePlugin::getModeYouTube($v['id']);
</script> </script>
</div> </div>
<div class="col-sm-1 col-md-1"></div> <div class="col-sm-1 col-md-1"></div>
</div> </div>
<?php <?php
} else { } else {
@ -457,7 +451,7 @@ YouPHPTubePlugin::getModeYouTube($v['id']);
<div class="alert alert-warning"> <div class="alert alert-warning">
<span class="glyphicon glyphicon-facetime-video"></span> <strong><?php echo __("Attention"); ?>!</strong> <?php echo empty($advancedCustom->videoNotFoundText->value) ? __("We have not found any videos or audios to show") : $advancedCustom->videoNotFoundText->value; ?>. <span class="glyphicon glyphicon-facetime-video"></span> <strong><?php echo __("Attention"); ?>!</strong> <?php echo empty($advancedCustom->videoNotFoundText->value) ? __("We have not found any videos or audios to show") : $advancedCustom->videoNotFoundText->value; ?>.
</div> </div>
<?php } ?> <?php } ?>
</div> </div>
<script src="<?php echo $global['webSiteRootURL']; ?>view/js/jquery-ui/jquery-ui.min.js" type="text/javascript"></script> <script src="<?php echo $global['webSiteRootURL']; ?>view/js/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script> <script>