1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00
I will let the admin select what channels he wants to put on the first page.
then I it will show the channels videos sorted by date DESC
This commit is contained in:
Daniel 2022-03-10 19:45:50 -03:00
parent f87403db12
commit fa6be4f09e
10 changed files with 155 additions and 4 deletions

View file

@ -373,6 +373,22 @@ class AVideoPlugin
{
return self::getDataObject($name);
}
public static function setObjectData($name, $object){
$p = static::loadPlugin($name);
if ($p) {
return $p->setDataObject($object);
}
return false;
}
public static function setObjectDataParameter($name, $parameterName, $value){
$p = static::loadPlugin($name);
if ($p) {
return $p->setDataObjectParameter($parameterName, $value);
}
return false;
}
public static function getDataObject($name)
{

View file

@ -185,6 +185,7 @@ class Gallery extends PluginAbstract {
$js .= '<script src="' . getCDN() . 'plugin/Gallery/fullscreen.js"></script>';
$js .= '<script>var playVideoOnBrowserFullscreen = 1;</script>';
}
$js .= '<script src="'.getURL('plugin/Gallery/script.js').'" type="text/javascript"></script>';
return $js;
}
@ -227,5 +228,47 @@ class Gallery extends PluginAbstract {
global $global;
return '<button onclick="avideoModalIframeSmall(webSiteRootURL+\'plugin/Gallery/view/sections.php\')" class="btn btn-primary btn-sm btn-xs btn-block"><i class="fas fa-sort-numeric-down"></i> ' . __('Sort Sections') . '</button>';
}
public static function getAddChannelToGalleryButton($users_id){
global $global, $config;
$variable = ob_get_clean();
ob_start();
include $global['systemRootPath'] . 'plugin/Gallery/buttonChannelToGallery.php';
$button = ob_get_clean();
ob_start();
echo $variable;
return $button;
}
public static function setAddChannelToGallery($users_id, $add){
global $global, $config;
$users_id = intval($users_id);
$add = intval($add);
$obj = AVideoPlugin::getObjectData('Gallery');
$parameterName = "Channel_{$users_id}_";
if(!empty($add)){
$obj->{$parameterName} = true;
$obj->{"{$parameterName}CustomTitle"} = User::getNameIdentificationById($users_id);
$obj->{"{$parameterName}RowCount"} = 12;
$obj->{"{$parameterName}Order"} = 1;
}else{
unset($obj->{$parameterName});
unset($obj->{"{$parameterName}CustomTitle"});
unset($obj->{"{$parameterName}RowCount"});
unset($obj->{"{$parameterName}Order"});
}
return AVideoPlugin::setObjectData('Gallery', $obj);
}
public static function isChannelToGallery($users_id){
$obj = AVideoPlugin::getObjectData('Gallery');
$parameterName = "Channel_{$users_id}_";
return !empty($obj->{$parameterName});
}
}

View file

@ -0,0 +1,23 @@
<?php
$titleBtn1 = __('Add to first page');
$titleBtn2 = __('Remove first page');
$class = '';
if(Gallery::isChannelToGallery($users_id)){
$class = 'isChannelToGallery';
}
?>
<div class="ChannelToGallery<?php echo $users_id; ?> <?php echo $class; ?>" style="display: inline-block;">
<button class="btn btn-primary btn-xs addChannelToGallery" onclick="channelToGallery(<?php echo $users_id; ?>, 1);" data-toggle="tooltip" title="<?php echo $titleBtn1; ?>" >
<i class="fas fa-plus"></i> <small><?php echo $titleBtn1; ?></small>
</button>
<button class="btn btn-danger btn-xs removeChannelFromGallery" onclick="channelToGallery(<?php echo $users_id; ?>, 0);" data-toggle="tooltip" title="<?php echo $titleBtn2; ?>" >
<i class="fas fa-trash"></i> <small><?php echo $titleBtn2; ?></small>
</button>
</div>
<script>
$(document).ready(function () {
});
</script>

View file

@ -0,0 +1,32 @@
<?php
require_once '../../videos/configuration.php';
header('Content-Type: application/json');
$resp = new stdClass();
$resp->error = true;
$resp->msg = "";
$resp->users_id = intval($_REQUEST['users_id']);
$resp->add = intval($_REQUEST['add']);
if (empty($resp->users_id)) {
forbiddenPage('User is empty');
}
if (!User::isAdmin()) {
forbiddenPage('Admin only');
}
$plugin = AVideoPlugin::loadPluginIfEnabled('Gallery');
if (empty($plugin)) {
forbiddenPage('Gallery not enabled');
}
$resp->response = Gallery::setAddChannelToGallery($resp->users_id, $resp->add);
$resp->error = empty($resp->response);
die(json_encode($resp));

View file

@ -1,2 +1,17 @@
var tmpPId;
var tmpSave;
function channelToGallery(users_id, add) {
$.ajax({
url: webSiteRootURL + 'plugin/Gallery/channelToGallery.json.php',
method: 'POST',
data: {'users_id': users_id, 'add': add},
success: function (response) {
avideoResponse(response);
if(!response.error){
if(response.add){
$('.ChannelToGallery'+response.users_id).addClass('isChannelToGallery');
}else{
$('.ChannelToGallery'+response.users_id).removeClass('isChannelToGallery');
}
}
}
});
}

View file

@ -209,4 +209,12 @@ a.h6{
}
.galleryTags{
margin: 0 !important;
}
.isChannelToGallery .addChannelToGallery, .removeChannelFromGallery{
display: none;
}
.isChannelToGallery .removeChannelFromGallery {
display: inline-block;
}

View file

@ -1,4 +1,3 @@
<script src="<?php echo getCDN(); ?>plugin/Gallery/script.js" type="text/javascript"></script>
<?php include $global['systemRootPath'] . 'view/include/footer.php'; ?>
<script>
function showTrailer(iframe) {

View file

@ -70,6 +70,10 @@
continue;
}
$countSections++;
if(preg_match('/Channel_([0-9]+)_/', $value['name'], $matches)){
$users_id = intval($matches[1]);
User::getChannelPanel($users_id);
} else
if ($value['name'] == 'Suggested') {
createGallery(!empty($obj->SuggestedCustomTitle) ? $obj->SuggestedCustomTitle : __("Suggested"), 'suggested', $obj->SuggestedRowCount, 'SuggestedOrder', "", "", $orderString, "ASC", !$obj->hidePrivateVideos, "fas fa-star");
} else

View file

@ -31,9 +31,19 @@ AVideoPlugin::loadPlugin("Gallery");
if (empty($value['active'])) {
$checked = '';
}
$name = $value['name'];
if(preg_match('/Channel_([0-9]+)_/', $name, $matches)){
$users_id = intval($matches[1]);
$u = new User($users_id);
if(!empty($u->getChannelName())){
$name = '<i class="fas fa-play-circle"></i> '.$u->getChannelName();
}
}
?>
<li class="list-group-item" id="<?php echo $value['name']; ?>" >
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span><?php echo $value['name']; ?>
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span><?php echo $name; ?>
<div class="material-small material-switch pull-right">
<input name="<?php echo $value['name']; ?>" id="enable<?php echo $value['name']; ?>" class="sectionsCheckbox" type="checkbox" value="0" <?php echo $checked; ?>>
<label for="enable<?php echo $value['name']; ?>" class="label-success"></label>