mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 19:42:38 +02:00
Updates
This commit is contained in:
parent
55d555de36
commit
5e092a67d4
4 changed files with 821 additions and 481 deletions
File diff suppressed because it is too large
Load diff
|
@ -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)) {
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
<?php
|
||||
$global['doNotSearch'] = 1;
|
||||
$tags = TagsHasVideos::getAllWithVideo();
|
||||
$global['doNotSearch'] = 0;
|
||||
?>
|
||||
<style>
|
||||
#searchOptionsMenu {
|
||||
position: relative;
|
||||
|
@ -13,7 +18,7 @@
|
|||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
#searchFieldsNamesBelowNavbar-dropdown , #catNameBelowNavbar-dropdown {
|
||||
#searchFieldsNamesBelowNavbar-dropdown , #catNameBelowNavbar-dropdown , #tagNameBelowNavbar-dropdown {
|
||||
min-width: 150px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
|
@ -25,7 +30,7 @@
|
|||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
#catNameBelowNavbar-dropdown {
|
||||
#catNameBelowNavbar-dropdown, #tagNameBelowNavbar-dropdown{
|
||||
border-left-width: 0;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
|
@ -82,7 +87,8 @@
|
|||
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>
|
||||
|
@ -124,6 +130,35 @@
|
|||
</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>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-default btn-outline-secondary border-right-0 faa-parent animated-hover" type="button" id="searchOptionsButton" onclick="searchOptionsButton();" >
|
||||
<i class="fas fa-search faa-shake"></i>
|
||||
</button>
|
||||
|
@ -132,30 +167,26 @@
|
|||
</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"]';
|
||||
var tags_idBelowNavbarChecked = 'input[name="tags_idBelowNavbar"]:checked';
|
||||
var tags_idBelowNavbar = 'input[name="tags_idBelowNavbar"]';
|
||||
$(document).ready(function () {
|
||||
// Show the default button label for the searchFieldsNamesBelowNavbar dropdown
|
||||
var defaultText = $('#searchFieldsNamesBelowNavbar-dropdown').text().trim();
|
||||
|
||||
$(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);
|
||||
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>');
|
||||
checkAllSearchFilter('#searchNavItem', $(this).val(), $(this).prop('checked'));
|
||||
saveSearchCategoryToCookie();
|
||||
setSearchFilterIcon();
|
||||
});
|
||||
|
||||
$(tags_idBelowNavbar).on('change', function () {
|
||||
checkAllSearchFilter('#searchNavItem', $(this).val(), $(this).prop('checked'));
|
||||
saveSearchTagToCookie();
|
||||
});
|
||||
|
||||
$(searchFieldsNamesBelowNavbarSearchFieldsNames).on('click', function () {
|
||||
|
@ -164,9 +195,6 @@
|
|||
$('#searchOptionsMenu label').click(function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
filterCheckboxes.trigger('change');
|
||||
categoryRadios.trigger('change');
|
||||
});
|
||||
|
||||
function searchOptionsButton() {
|
||||
|
@ -184,4 +212,5 @@
|
|||
|
||||
$('#searchForm').submit();
|
||||
}
|
||||
|
||||
</script>
|
|
@ -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
|
||||
|
@ -78,6 +78,12 @@ if (!empty($_GET['search'])) {
|
|||
?>
|
||||
</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) {
|
||||
?>
|
||||
|
@ -106,31 +112,35 @@ if (!empty($_GET['search'])) {
|
|||
<script>
|
||||
var filterCheckboxes;
|
||||
var categoryRadios;
|
||||
var tagsRadios;
|
||||
|
||||
$(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');
|
||||
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
|
||||
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
|
||||
|
@ -148,17 +158,28 @@ if (!empty($_GET['search'])) {
|
|||
// check the default radio button
|
||||
categoryRadios.filter('#search_category0').prop('checked', true);
|
||||
}
|
||||
setSearchFilterIcon();
|
||||
|
||||
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() {
|
||||
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>
|
Loading…
Add table
Add a link
Reference in a new issue