1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 19:42:38 +02:00
This commit is contained in:
Daniel Neto 2023-04-25 18:53:00 -03:00
parent 55d555de36
commit 5e092a67d4
4 changed files with 821 additions and 481 deletions

File diff suppressed because it is too large Load diff

View file

@ -660,6 +660,16 @@ class API extends PluginAbstract {
if (empty($parameters['noRelated'])) {
$rows[$key]['relatedVideos'] = Video::getRelatedMovies($rows[$key]['id']);
foreach ($rows[$key]['relatedVideos'] as $key2 => $value2) {
$rows[$key]['relatedVideos'][$key2]['tags'] = Video::getTags($value2['id']);
if (AVideoPlugin::isEnabledByName("VideoTags")) {
$rows[$key]['relatedVideos'][$key2]['videoTags'] = Tags::getAllFromVideosId($value2['id']);
$rows[$key]['relatedVideos'][$key2]['videoTagsObject'] = Tags::getObjectFromVideosId($value2['id']);
}
if ($rows[$key]['relatedVideos'][$key2]['type'] !== 'linkVideo') {
$rows[$key]['relatedVideos'][$key2]['videos'] = Video::getVideosPaths($value2['filename'], true);
}
}
}
$rows[$key]['adsImages'] = array();
if (!empty($objAds)) {

View file

@ -1,71 +1,76 @@
<?php
$global['doNotSearch'] = 1;
$tags = TagsHasVideos::getAllWithVideo();
$global['doNotSearch'] = 0;
?>
<style>
#searchOptionsMenu {
position: relative;
height: 50px;
display: flex;
align-items: center;
z-index: 1029;
}
#searchOptionsMenu {
position: relative;
height: 50px;
display: flex;
align-items: center;
z-index: 1029;
}
#searchOptionsMenu > div {
position: absolute;
left: 50%;
transform: translateX(-50%);
}
#searchOptionsMenu > div {
position: absolute;
left: 50%;
transform: translateX(-50%);
}
#searchFieldsNamesBelowNavbar-dropdown , #catNameBelowNavbar-dropdown {
min-width: 150px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#searchFieldsNamesBelowNavbar-dropdown , #catNameBelowNavbar-dropdown , #tagNameBelowNavbar-dropdown {
min-width: 150px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#searchFieldsNamesBelowNavbar-dropdown {
border-right-width: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
#catNameBelowNavbar-dropdown {
border-left-width: 0;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-right-width: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
#searchOptionsButton {
border-left-width: 0;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
#searchFieldsNamesBelowNavbar-dropdown {
border-right-width: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
#catNameBelowNavbar-dropdown, #tagNameBelowNavbar-dropdown{
border-left-width: 0;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-right-width: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
#searchOptionsButton {
border-left-width: 0;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
#searchOptionsMenu .panel {
margin: 0;
}
#searchOptionsMenu .panel {
margin: 0;
}
#searchOptionsMenu .panel-body {
max-height: 60vh;
overflow: auto;
}
#searchOptionsMenu .panel-body {
max-height: 60vh;
overflow: auto;
}
#searchOptionsMenu .form-check {
white-space: nowrap;
}
#searchOptionsMenu .form-check {
white-space: nowrap;
}
#searchOptionsMenu .form-check-input {
margin-right: 5px;
}
#searchOptionsMenu .form-check-input {
margin-right: 5px;
}
#searchOptionsMenu .form-check-label {
display: inline-block;
margin-bottom: 0;
vertical-align: middle;
}
#searchOptionsMenu .form-check-label {
display: inline-block;
margin-bottom: 0;
vertical-align: middle;
}
#searchOptionsMenu .dropdown-menu-right {
right: 0;
left: auto;
}
#searchOptionsMenu .dropdown-menu-right {
right: 0;
left: auto;
}
</style>
<div class="container" id="searchOptionsMenu">
@ -73,21 +78,22 @@
<div class="btn-group-justified">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"
id="searchFieldsNamesBelowNavbar-dropdown" ><?php echo __('Search in'); ?>: <span class="badge">0</span>
id="searchFieldsNamesBelowNavbar-dropdown" ><?php echo __('Search in'); ?>: <span class="badge">0</span>
<span class="caret"></span></button>
<div class="panel panel-default dropdown-menu dropdown-menu-right">
<div class="panel-body">
<?php
AVideoPlugin::loadPlugin('Layout');
foreach (Layout::$searchOptions as $key => $value) {
?>
?>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="<?php echo $value['value']; ?>" id="filterCheck<?php echo $key; ?>" name="searchFieldsNamesBelowNavbar[]">
<input class="form-check-input" type="checkbox" value="<?php echo $value['value']; ?>"
id="filterCheck<?php echo $key; ?>" name="searchFieldsNamesBelowNavbar[]">
<label class="form-check-label" for="filterCheck<?php echo $key; ?>">
<?php echo $value['text']; ?>
</label>
</div>
<?php
<?php
}
?>
</div>
@ -95,7 +101,7 @@
</div>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" id="catNameBelowNavbar-dropdown">
<i class="fas fa-list"></i> <?php echo __('All Categories'); ?>
<i class="fas fa-list"></i> <?php echo __('All Categories'); ?>
<span class="caret"></span>
</button>
<div class="panel panel-default dropdown-menu dropdown-menu-right">
@ -111,14 +117,43 @@
$categories_edit = Category::getAllCategories(false, true);
$global['doNotSearch'] = 0;
foreach ($categories_edit as $key => $value) {
?>
?>
<div class="form-check">
<input class="form-check-input" type="radio" value="<?php echo $value['clean_name']; ?>" id="catNameBelowNavbar<?php echo $value['id']; ?>" name="catNameBelowNavbar">
<label class="form-check-label" for="catNameBelowNavbar<?php echo $value['id']; ?>">
<span class="content"><i class="<?php echo $value['iconClass']; ?>"></i> <?php echo __($value['hierarchyAndName']); ?></span>
</label>
</div>
<?php
}
?>
</div>
</div>
</div>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" id="tagNameBelowNavbar-dropdown">
<i class="fas fa-tags"></i> <?php echo __('Tags'); ?>
<span class="caret"></span>
</button>
<div class="panel panel-default dropdown-menu dropdown-menu-right">
<div class="panel-body">
<div class="form-check">
<input class="form-check-input" type="radio" value="" id="filterTag0" name="tags_idBelowNavbar">
<label class="form-check-label" for="filterTag0">
<i class="fas fa-tags"></i> <?php echo __('All'); ?>
</label>
</div>
<?php
foreach ($tags as $key => $value) {
?>
<div class="form-check">
<input class="form-check-input" type="radio" value="<?php echo $value['id']; ?>"
id="filterTag<?php echo $value['id']; ?>" name="tags_idBelowNavbar">
<label class="form-check-label" for="filterTag<?php echo $value['id']; ?>">
<i class="fas fa-tag"></i> <?php echo __($value['name']); ?>
</label>
</div>
<?php
}
?>
</div>
@ -132,41 +167,34 @@
</div>
<script>
var searchFieldsNamesBelowNavbarChecked = 'input[name="searchFieldsNamesBelowNavbar[]"]:checked';
var searchFieldsNamesBelowNavbarSearchFieldsNames = 'input[name="searchFieldsNamesBelowNavbar[]"], input[name="searchFieldsNames[]"]';
var searchFieldsNamesBelowNavbarSearchFieldsNames = 'input[name="searchFieldsNamesBelowNavbar[]"], input[name="searchFields[]"]';
var catNameBelowNavbarChecked = 'input[name="catNameBelowNavbar"]:checked';
var catNameBelowNavbarCatName = 'input[name="catNameBelowNavbar"], input.form-check-input[type="radio"][name="catName"]';
$(document).ready(function() {
// Show the default button label for the searchFieldsNamesBelowNavbar dropdown
var defaultText = $('#searchFieldsNamesBelowNavbar-dropdown').text().trim();
var tags_idBelowNavbarChecked = 'input[name="tags_idBelowNavbar"]:checked';
var tags_idBelowNavbar = 'input[name="tags_idBelowNavbar"]';
$(document).ready(function () {
$(searchFieldsNamesBelowNavbarSearchFieldsNames).on('change', function() {
var val = $(this).val();
var $otherCheckbox = $('input[value="' + val + '"]').not($(this));
$otherCheckbox.prop('checked', $(this).prop('checked'));
$('#searchFieldsNamesBelowNavbar-dropdown .badge').text($(searchFieldsNamesBelowNavbarChecked).length);
$(searchFieldsNamesBelowNavbarSearchFieldsNames).on('change', function () {
checkAllSearchFilter('#searchNavItem', $(this).val(), $(this).prop('checked'));
saveSearchFiltersToCookie();
setSearchFilterIcon();
});
$(catNameBelowNavbarCatName).on('change', function() {
var val = $(this).val();
var $otherRadio = $('input[value="' + val + '"]').not($(this));
$otherRadio.prop('checked', $(this).prop('checked'));
var selectedText = $(catNameBelowNavbarChecked).parent().find('span.content').html();
$('#catNameBelowNavbar-dropdown').html(selectedText+' <span class="caret"></span>');
$(catNameBelowNavbarCatName).on('change', function () {
checkAllSearchFilter('#searchNavItem', $(this).val(), $(this).prop('checked'));
saveSearchCategoryToCookie();
setSearchFilterIcon();
});
$(searchFieldsNamesBelowNavbarSearchFieldsNames).on('click', function() {
$(tags_idBelowNavbar).on('change', function () {
checkAllSearchFilter('#searchNavItem', $(this).val(), $(this).prop('checked'));
saveSearchTagToCookie();
});
$(searchFieldsNamesBelowNavbarSearchFieldsNames).on('click', function () {
$(this).trigger('change');
});
$('#searchOptionsMenu label').click(function(e) {
$('#searchOptionsMenu label').click(function (e) {
e.stopPropagation();
});
filterCheckboxes.trigger('change');
categoryRadios.trigger('change');
});
function searchOptionsButton() {
@ -184,4 +212,5 @@
$('#searchForm').submit();
}
</script>

View file

@ -12,17 +12,17 @@ $global['doNotSearch'] = 0;
</button>
</div>
<div class="input-group" id="mysearch">
<form class="navbar-form form-inline input-group" role="search" id="searchForm" method="get" action="<?php echo $global['webSiteRootURL']; ?>" >
<form class="navbar-form form-inline input-group" role="search" id="searchForm" method="get" action="<?php echo $global['webSiteRootURL']; ?>">
<span class="input-group-prepend">
<button type="button" id="filterButton" class="btn btn-default navbar-btn dropdown-toggle faa-parent animated-hover animate__animated animate__bounceIn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-sort-down"></i>
</button>
</span>
<input class="form-control globalsearchfield" type="text" value="<?php
if (!empty($_GET['search'])) {
echo htmlentities($_GET['search']);
}
?>" name="search" placeholder="<?php echo __("Search"); ?>" id="searchFormInput">
if (!empty($_GET['search'])) {
echo htmlentities($_GET['search']);
}
?>" name="search" placeholder="<?php echo __("Search"); ?>" id="searchFormInput">
<span class="input-group-append">
<button class="btn btn-default btn-outline-secondary border-right-0 border py-2 faa-parent animated-hover" type="submit" id="buttonSearch" data-toggle="collapse" data-target="#mysearch">
<i class="fas fa-search faa-shake"></i>
@ -43,14 +43,14 @@ if (!empty($_GET['search'])) {
<?php
AVideoPlugin::loadPlugin('Layout');
foreach (Layout::$searchOptions as $key => $value) {
?>
?>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="<?php echo $value['value']; ?>" id="filterCheck<?php echo $key; ?>" name="searchFieldsNames[]">
<label class="form-check-label" for="filterCheckTitle">
<?php echo $value['text']; ?>
</label>
</div>
<?php
<?php
}
?>
</div>
@ -58,7 +58,7 @@ if (!empty($_GET['search'])) {
<div class="form-check">
<input class="form-check-input" type="radio" id="search_category0" name="catName" checked value="">
<label class="form-check-label" for="search_category0">
<i class="fas fa-list"></i> <?php echo __('All Categories'); ?>
<i class="fas fa-list"></i> <?php echo __('All'); ?>
</label>
</div>
<?php
@ -66,28 +66,34 @@ if (!empty($_GET['search'])) {
$categories_edit = Category::getAllCategories(false, true);
$global['doNotSearch'] = 0;
foreach ($categories_edit as $key => $value) {
?>
?>
<div class="form-check">
<input class="form-check-input" type="radio" value="<?php echo $value['clean_name']; ?>" id="search_category<?php echo $value['id']; ?>" name="catName">
<label class="form-check-label" for="search_category<?php echo $value['id']; ?>">
<i class="<?php echo $value['iconClass']; ?>"></i> <?php echo __($value['hierarchyAndName']); ?>
</label>
</div>
<?php
<?php
}
?>
</div>
<div id="filter-tags-tab" class="tab-pane fade">
<div class="form-check">
<input class="form-check-input" type="radio" value="" id="search_tag0" name="tags_id">
<label class="form-check-label" for="search_tag0">
<i class="fas fa-tags"></i> <?php echo __('All'); ?>
</label>
</div>
<?php
foreach ($tags as $key => $value) {
?>
?>
<div class="form-check">
<input class="form-check-input" type="radio" value="<?php echo $value['id']; ?>" id="search_tag<?php echo $value['id']; ?>" name="tags_id">
<label class="form-check-label" for="search_tag<?php echo $value['id']; ?>">
<i class="fas fa-tag"></i> <?php echo __($value['name']); ?>
</label>
</div>
<?php
<?php
}
?>
</div>
@ -106,37 +112,41 @@ if (!empty($_GET['search'])) {
<script>
var filterCheckboxes;
var categoryRadios;
var tagsRadios;
$(document).ready(function () {
$(document).ready(function() {
// get references to the checkboxes and radio buttons
filterCheckboxes = $('input[name="searchFieldsNames[]"]');
categoryRadios = $('input.form-check-input[type="radio"][name="catName"]');
tagsRadios = $('input.form-check-input[type="radio"][name="tags_id"]');
// add event listeners to the checkboxes and radio buttons
filterCheckboxes.on('change', function () {
console.log('filterCheckboxes.filter change');
filterCheckboxes.on('change', function() {
checkAllSearchFilter('#searchOptionsMenu', $(this).val(), $(this).prop('checked'));
// save the checked values to the cookie
saveSearchFiltersToCookie();
setSearchFilterIcon();
});
categoryRadios.on('change', function () {
// save the checked value to the cookie
categoryRadios.on('change', function() {
checkAllSearchFilter('#searchOptionsMenu', $(this).val(), $(this).prop('checked'));
saveSearchCategoryToCookie();
});
setSearchFilterIcon();
tagsRadios.on('change', function() {
checkAllSearchFilter('#searchOptionsMenu', $(this).val(), $(this).prop('checked'));
saveSearchTagToCookie();
});
// load the saved search filters from the cookies
const savedFilters = Cookies.get('searchFilters');
const savedCategory = Cookies.get('searchCategory');
const savedSearchTag = Cookies.get('searchTag');
if (savedFilters) {
// parse the saved filters from JSON and check the corresponding checkboxes
const checkedValues = JSON.parse(savedFilters);
filterCheckboxes.each(function () {
filterCheckboxes.each(function() {
this.checked = checkedValues.includes(this.value);
});
}
@ -148,17 +158,28 @@ if (!empty($_GET['search'])) {
// check the default radio button
categoryRadios.filter('#search_category0').prop('checked', true);
}
setSearchFilterIcon();
$('#filterButton').click(function () {
if (savedSearchTag) {
// check the corresponding radio button
$('input[name="tags_id"][value="' + savedSearchTag + '"]').prop('checked', true);
}
$('#filterButton').click(function() {
$('#filterDropdown').toggleClass('show');
});
filterCheckboxes.trigger('change');
categoryRadios.trigger('change');
tagsRadios.trigger('change');
});
function saveSearchFiltersToCookie() {
const checkedValues = filterCheckboxes.filter(':checked').map(function () {
const checkedValues = filterCheckboxes.filter(':checked').map(function() {
return this.value;
}).get();
$('#searchFieldsNamesBelowNavbar-dropdown .badge').text(checkedValues.length);
Cookies.set('searchFilters', JSON.stringify(checkedValues), {
expires: 365,
path: '/'
@ -167,15 +188,27 @@ if (!empty($_GET['search'])) {
function saveSearchCategoryToCookie() {
const checkedValue = categoryRadios.filter(':checked').val();
var selectedText = categoryRadios.filter(':checked').parent().find('label').html();
$('#catNameBelowNavbar-dropdown').html(selectedText + ' <span class="caret"></span>');
Cookies.set('searchCategory', checkedValue, {
expires: 365,
path: '/'
});
}
function saveSearchTagToCookie() {
const searchTagValue = $('input[name="tags_id"]:checked').val();
var selectedText = $('input[name="tags_id"]:checked').parent().find('label').html();
$('#tagNameBelowNavbar-dropdown').html(selectedText + ' <span class="caret"></span>');
Cookies.set('searchTag', searchTagValue, {
expires: 365,
path: '/'
});
}
function setSearchFilterIcon() {
// check if no filter checkboxes are checked and search_category0 is checked
if (filterCheckboxes.filter(':checked').length === 0 && $('#search_category0').is(':checked')) {
// check if no filter checkboxes are checked and search_category0 is checked and search_tag0 is checked
if (filterCheckboxes.filter(':checked').length === 0 && $('#search_category0').is(':checked') && $('input[name="tags_id"]:checked').val() == '') {
// add the text-muted icon to the filterButton
$('#filterButton i').removeClass('fa-filter');
$('#filterButton i').addClass('fa-sort-down');
@ -185,4 +218,13 @@ if (!empty($_GET['search'])) {
$('#filterButton i').addClass('fa-filter');
}
}
function checkAllSearchFilter(parentSelector, value, checked) {
$(parentSelector + ' input[type="checkbox"], ' + parentSelector + ' input[type="radio"]').each(function() {
if ($(this).val() === value) {
$(this).prop('checked', checked);
}
});
setSearchFilterIcon();
}
</script>