1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00

Let choose ads to not show on videos page

This commit is contained in:
Daniel Neto 2024-06-14 16:43:52 -03:00
parent 10d294e899
commit 33a757da74
7 changed files with 28 additions and 37 deletions

View file

@ -4,7 +4,7 @@ require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
class ADs extends PluginAbstract class ADs extends PluginAbstract
{ {
public static $AdsPositions = [ const AdsPositions = [
['leaderBoardBigVideo', 1], ['leaderBoardBigVideo', 1],
['leaderBoardTop', 0], ['leaderBoardTop', 0],
['leaderBoardTop2', 0], ['leaderBoardTop2', 0],
@ -54,31 +54,16 @@ class ADs extends PluginAbstract
public static function getDataObjectAdvanced() public static function getDataObjectAdvanced()
{ {
return array( $array = array();
'leaderBoardBigVideo',
'leaderBoardBigVideoLabel', foreach (ADS::AdsPositions as $value) {
'leaderBoardTop', $array[] = $value;
'leaderBoardTopLabel', $array[] = "{$value}Label";
'leaderBoardTop2', $array[] = "{$value}ShowOnVideoPlayerPage";
'leaderBoardTop2Label', $array[] = "{$value}AllowUserToModify";
'channelLeaderBoardTop', }
'channelLeaderBoardTopLabel', $array[] = "tags3rdParty";
'leaderBoardMiddle', return $array;
'leaderBoardMiddleLabel',
'sideRectangle',
'sideRectangleLabel',
'leaderBoardBigVideoMobile',
'leaderBoardBigVideoMobileLabel',
'leaderBoardTopMobile',
'leaderBoardTopMobileLabel',
'leaderBoardTopMobile2',
'leaderBoardTopMobile2Label',
'channelLeaderBoardTopMobile',
'channelLeaderBoardTopMobileLabel',
'leaderBoardMiddleMobile',
'leaderBoardMiddleMobileLabel',
'tags3rdParty',
);
} }
public function getEmptyDataObject() public function getEmptyDataObject()
@ -88,7 +73,7 @@ class ADs extends PluginAbstract
$adsense = $config->getAdsense(); $adsense = $config->getAdsense();
foreach (self::$AdsPositions as $value) { foreach (ADS::AdsPositions as $value) {
$size = '728x90'; $size = '728x90';
if (!empty($value[1])) { if (!empty($value[1])) {
$size = '300x250'; $size = '300x250';
@ -110,6 +95,7 @@ class ADs extends PluginAbstract
eval("\$obj->$value[0]Width = {$width};"); eval("\$obj->$value[0]Width = {$width};");
eval("\$obj->$value[0]Height = {$height};"); eval("\$obj->$value[0]Height = {$height};");
eval("\$obj->$value[0]Label = '{$value[0]}';"); eval("\$obj->$value[0]Label = '{$value[0]}';");
eval("\$obj->$value[0]ShowOnVideoPlayerPage = true;");
eval("\$obj->$value[0]AllowUserToModify = true;"); eval("\$obj->$value[0]AllowUserToModify = true;");
} }
@ -210,7 +196,7 @@ class ADs extends PluginAbstract
{ {
global $global; global $global;
$typeFound = false; $typeFound = false;
foreach (ADs::$AdsPositions as $key => $value) { foreach (ADs::AdsPositions as $key => $value) {
if ($type === $value[0]) { if ($type === $value[0]) {
$typeFound = true; $typeFound = true;
break; break;
@ -406,6 +392,11 @@ class ADs extends PluginAbstract
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs'); $ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
$adCode = ''; $adCode = '';
if (!empty($ad)) { if (!empty($ad)) {
$showOnVideoPlayerPage = true;
eval("\$showOnVideoPlayerPage = \$obj->{$type}ShowOnVideoPlayerPage;");
if(!$showOnVideoPlayerPage && isVideo()){
return false;
}
self::debug(__LINE__); self::debug(__LINE__);
if (isMobile()) { if (isMobile()) {
$type = $type . 'Mobile'; $type = $type . 'Mobile';
@ -469,7 +460,7 @@ class ADs extends PluginAbstract
public static function getSize($type) public static function getSize($type)
{ {
$obj = AVideoPlugin::getObjectData("ADs"); $obj = AVideoPlugin::getObjectData("ADs");
foreach (ADs::$AdsPositions as $key => $value) { foreach (ADs::AdsPositions as $key => $value) {
if ($type == $value[0]) { if ($type == $value[0]) {
$width = 0; $width = 0;
$height = 0; $height = 0;

View file

@ -30,7 +30,7 @@ if (empty($type)) {
} }
$typeFound = false; $typeFound = false;
foreach (ADs::$AdsPositions as $key => $value) { foreach (ADs::AdsPositions as $key => $value) {
if ($type === $value[0]) { if ($type === $value[0]) {
$typeFound = true; $typeFound = true;
break; break;

View file

@ -65,7 +65,7 @@ $_page->setExtraScripts(
<ul class="nav nav-tabs nav-pills nav-stacked"> <ul class="nav nav-tabs nav-pills nav-stacked">
<?php <?php
$active = 'active'; $active = 'active';
foreach (ADs::$AdsPositions as $value) { foreach (ADs::AdsPositions as $value) {
$type = $value[0]; $type = $value[0];
eval("\$AllowUserToModify = \$obj->{$type}AllowUserToModify;"); eval("\$AllowUserToModify = \$obj->{$type}AllowUserToModify;");
if ($is_regular_user && empty($AllowUserToModify)) { if ($is_regular_user && empty($AllowUserToModify)) {
@ -87,7 +87,7 @@ $_page->setExtraScripts(
<?php <?php
$active = ' in active'; $active = ' in active';
foreach (ADs::$AdsPositions as $value) { foreach (ADs::AdsPositions as $value) {
$type = $value[0]; $type = $value[0];
eval("\$AllowUserToModify = \$obj->{$type}AllowUserToModify;"); eval("\$AllowUserToModify = \$obj->{$type}AllowUserToModify;");
if ($is_regular_user && empty($AllowUserToModify)) { if ($is_regular_user && empty($AllowUserToModify)) {

View file

@ -20,7 +20,7 @@ if (empty($type)) {
} }
$typeFound = false; $typeFound = false;
foreach (ADs::$AdsPositions as $key => $value) { foreach (ADs::AdsPositions as $key => $value) {
if ($type === $value[0]) { if ($type === $value[0]) {
$typeFound = true; $typeFound = true;
break; break;

View file

@ -32,7 +32,7 @@ if (empty($type)) {
} }
$typeFound = false; $typeFound = false;
foreach (ADs::$AdsPositions as $key => $value) { foreach (ADs::AdsPositions as $key => $value) {
if ($type === $value[0]) { if ($type === $value[0]) {
$typeFound = true; $typeFound = true;
break; break;

View file

@ -26,7 +26,7 @@ if (empty($type)) {
} }
$typeFound = false; $typeFound = false;
foreach (ADs::$AdsPositions as $key => $value) { foreach (ADs::AdsPositions as $key => $value) {
if ($type === $value[0]) { if ($type === $value[0]) {
$typeFound = true; $typeFound = true;
break; break;

View file

@ -223,7 +223,7 @@ class API extends PluginAbstract
} }
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs'); $ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
$array = array('users_id' => $users_id, 'ads' => array()); $array = array('users_id' => $users_id, 'ads' => array());
foreach (ADs::$AdsPositions as $key => $value) { foreach (ADs::AdsPositions as $key => $value) {
$type = $value[0]; $type = $value[0];
$desktopGlobal = false; $desktopGlobal = false;
$mobileGlobal = false; $mobileGlobal = false;
@ -1048,7 +1048,7 @@ class API extends PluginAbstract
} }
$rows[$key]['adsImages'] = array(); $rows[$key]['adsImages'] = array();
if (!empty($objAds)) { if (!empty($objAds)) {
foreach (ADs::$AdsPositions as $value) { foreach (ADs::AdsPositions as $value) {
$type = $value[0]; $type = $value[0];
$rows[$key]['adsImages'][] = array('type' => $type, 'assets' => ADs::getAdsFromVideosId($type, $rows[$key]['id'])); $rows[$key]['adsImages'][] = array('type' => $type, 'assets' => ADs::getAdsFromVideosId($type, $rows[$key]['id']));
} }