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

showonFirstpage update

This commit is contained in:
Daniel Neto 2023-08-10 14:39:00 -03:00
parent 7ac7481d5b
commit a6ac9edca0
12 changed files with 262 additions and 98 deletions

View file

@ -4,7 +4,7 @@ if (file_exists("../videos/configuration.php")) {
exit; exit;
} }
$installationVersion = "12.8"; $installationVersion = "12.9";
error_log("Installation: ".__LINE__." ". json_encode($_POST)); error_log("Installation: ".__LINE__." ". json_encode($_POST));
header('Content-Type: application/json'); header('Content-Type: application/json');

View file

@ -501,10 +501,12 @@ CREATE TABLE IF NOT EXISTS `playlists` (
`modified` DATETIME NULL DEFAULT NULL, `modified` DATETIME NULL DEFAULT NULL,
`users_id` INT(11) NOT NULL, `users_id` INT(11) NOT NULL,
`status` ENUM('public', 'private', 'unlisted', 'favorite', 'watch_later') NOT NULL DEFAULT 'public', `status` ENUM('public', 'private', 'unlisted', 'favorite', 'watch_later') NOT NULL DEFAULT 'public',
`showOnTV` TINYINT NULL, `showOnTV` TINYINT NULL,,
`showOnFirstPage` TINYINT(1) UNSIGNED NULL DEFAULT 0,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
INDEX `fk_playlists_users1_idx` (`users_id` ASC), INDEX `fk_playlists_users1_idx` (`users_id` ASC),
INDEX `showOnTVindex3` (`showOnTV` ASC), INDEX `showOnTVindex3` (`showOnTV` ASC),
INDEX `showonFirstpage` (`showOnFirstPage` ASC),
CONSTRAINT `fk_playlists_users1` CONSTRAINT `fk_playlists_users1`
FOREIGN KEY (`users_id`) FOREIGN KEY (`users_id`)
REFERENCES `users` (`id`) REFERENCES `users` (`id`)

View file

@ -11382,7 +11382,9 @@ function modifyURL($url)
'ads_w' => 'ads.w', //player width 'ads_w' => 'ads.w', //player width
'ads_h' => 'ads.h', //player height 'ads_h' => 'ads.h', //player height
'app_store_url' => 'ads.app_store_url', //player height 'app_store_url' => 'ads.app_store_url', //player height
'ads_app_store_url' => 'ads.app_store_url', //player height
'app_name' => 'ads.app_name', //player height 'app_name' => 'ads.app_name', //player height
'ads_app_name' => 'ads.app_name', //player height
'ads_cb' => 'ads.cb', 'ads_cb' => 'ads.cb',
'ads_channel_name' => 'ads.channel_name', 'ads_channel_name' => 'ads.channel_name',
'ads_content_genre' => 'ads.content_genre', 'ads_content_genre' => 'ads.content_genre',

View file

@ -16,6 +16,7 @@ class PlayList extends ObjectYPT {
protected $users_id; protected $users_id;
protected $status; protected $status;
protected $showOnTV; protected $showOnTV;
protected $showOnFirstPage;
protected $modified; protected $modified;
public static $validStatus = ['public', 'private', 'unlisted', 'favorite', 'watch_later']; public static $validStatus = ['public', 'private', 'unlisted', 'favorite', 'watch_later'];
@ -85,9 +86,10 @@ class PlayList extends ObjectYPT {
} }
$videosArrayId = PlayList::getVideosIdFromPlaylist($playlists_id); $videosArrayId = PlayList::getVideosIdFromPlaylist($playlists_id);
$videosP = Video::getAllVideos("viewable", false, true, $videosArrayId, false, true); $videosP = Video::getAllVideos("viewable", false, true, $videosArrayId, false, true);
$videosP = PlayList::sortVideos($videosP, $videosArrayId); //$videosP = PlayList::sortVideos($videosP, $videosArrayId);
foreach ($videosP as $key => $value2) { foreach ($videosP as $key => $value2) {
if (empty($videosP[$key]['type'])) { if (empty($videosP[$key]['type'])) {
//echo 'unset ';var_dump($videosP[$key]);
unset($videosP[$key]); unset($videosP[$key]);
continue; continue;
} }
@ -101,6 +103,8 @@ class PlayList extends ObjectYPT {
if ($videosP[$key]['type'] !== Video::$videoTypeLinkVideo) { if ($videosP[$key]['type'] !== Video::$videoTypeLinkVideo) {
$videosP[$key]['videos'] = Video::getVideosPaths($videosP[$key]['filename'], true); $videosP[$key]['videos'] = Video::getVideosPaths($videosP[$key]['filename'], true);
} }
$videosP[$key]['playlists_id'] = $playlists_id;
$videosP[$key]['playlist_index'] = $key;
} }
return $videosP; return $videosP;
@ -703,25 +707,31 @@ class PlayList extends ObjectYPT {
} }
public static function sortVideos($videosList, $listIdOrder) { public static function sortVideos($videosList, $listIdOrder) {
$list = []; usort($videosList, function($a, $b) use ($listIdOrder) {
foreach ($listIdOrder as $value) { // Get the index of the 'id' from the $listIdOrder array
$found = false; $indexA = array_search($a['id'], $listIdOrder);
foreach ($videosList as $key => $value2) { $indexB = array_search($b['id'], $listIdOrder);
if ($value2['id'] == $value) {
$list[] = $value2; // If both IDs are found in $listIdOrder
unset($videosList[$key]); if ($indexA !== false && $indexB !== false) {
$found = true; return $indexA - $indexB; // Sort based on the order in $listIdOrder
} }
// If $a['id'] is not found, it should come after $b
if ($indexA === false && $indexB !== false) {
return 1;
} }
if (!$found) {
$v = new Video("", "", $value); // If $b['id'] is not found, it should come after $a
if (empty($v->getFilename())) { if ($indexB === false && $indexA !== false) {
continue; return -1;
} }
$list[] = ['id' => $value];
} // If neither ID is found, sort them based on their IDs
} return $a['id'] - $b['id'];
return $list; });
return $videosList;
} }
public function save() { public function save() {
@ -734,6 +744,7 @@ class PlayList extends ObjectYPT {
$this->setUsers_id($users_id); $this->setUsers_id($users_id);
} }
$this->showOnTV = intval($this->showOnTV); $this->showOnTV = intval($this->showOnTV);
$this->showOnFirstPage = intval($this->showOnFirstPage);
$playlists_id = parent::save(); $playlists_id = parent::save();
if (!empty($playlists_id)) { if (!empty($playlists_id)) {
self::deleteCacheDir($playlists_id); self::deleteCacheDir($playlists_id);
@ -894,6 +905,19 @@ class PlayList extends ObjectYPT {
$this->showOnTV = intval($showOnTV); $this->showOnTV = intval($showOnTV);
} }
public function getShowOnFirstPage() {
return intval($this->showOnFirstPage);
}
public function setShowOnFirstPage($showOnFirstPage) {
if (strtolower($showOnFirstPage) === "false") {
$showOnFirstPage = 0;
} elseif (strtolower($showOnFirstPage) === "true") {
$showOnFirstPage = 1;
}
$this->showOnFirstPage = intval($showOnFirstPage);
}
public static function getAllToShowOnTV() { public static function getAllToShowOnTV() {
global $global; global $global;
if (!static::isTableInstalled()) { if (!static::isTableInstalled()) {
@ -921,6 +945,34 @@ class PlayList extends ObjectYPT {
return $rows; return $rows;
} }
public static function getAllToShowOnFirstPage() {
global $global;
if (!static::isTableInstalled()) {
return false;
}
$sql = "SELECT u.*, pl.* FROM playlists pl "
. " LEFT JOIN users u ON users_id = u.id "
. " WHERE showOnFirstPage=1 ";
//$sql .= self::getSqlFromPost();
//echo $sql;exit;
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$rows = [];
if ($res !== false) {
foreach ($fullData as $row) {
$row = cleanUpRowFromDatabase($row);
$rows[] = $row;
}
} else {
//die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
$rows = [];
}
return $rows;
}
public static function showPlayListSelector($playListArray) { public static function showPlayListSelector($playListArray) {
$collections = []; $collections = [];
$videos = []; $videos = [];

View file

@ -0,0 +1,26 @@
<?php
header('Content-Type: application/json');
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/playlist.php';
if (!PlayLists::canManageAllPlaylists()) {
forbiddenPage('Permission denied');
}
if (empty($_REQUEST['playlist_id'])) {
forbiddenPage('playlist_id is empty');
}
$obj = new stdClass();
$obj->playlist_id = $_REQUEST['playlist_id'];
$obj->showOnFirstPage = $_REQUEST['showOnFirstPage'];
$obj->msg = '';
$pl = new PlayList($_POST['playlist_id']);
$pl->setShowOnFirstPage($_REQUEST['showOnFirstPage']);
$obj->saved = $pl->save();
$obj->error = empty($obj->saved);
echo json_encode($obj);

View file

@ -1651,8 +1651,11 @@ if (!class_exists('Video')) {
$sql .= " AND v.status = '{$status}'"; $sql .= " AND v.status = '{$status}'";
} }
*/ */
if (!empty($videosArrayId) && is_array($videosArrayId) && (is_numeric($videosArrayId[0]))) {
$sql .= " ORDER BY FIELD(v.id, '" . implode("', '", $videosArrayId) . "') ";
} else {
$sql .= self::getSQLByStatus($status, $showUnlisted); $sql .= self::getSQLByStatus($status, $showUnlisted);
}
//var_dump($max_duration_in_seconds);echo $sql;exit; //var_dump($max_duration_in_seconds);echo $sql;exit;
if (!empty($_REQUEST['catName'])) { if (!empty($_REQUEST['catName'])) {
$catName = ($_REQUEST['catName']); $catName = ($_REQUEST['catName']);
@ -1711,7 +1714,7 @@ if (!class_exists('Video')) {
} }
$sql .= AVideoPlugin::getVideoWhereClause(); $sql .= AVideoPlugin::getVideoWhereClause();
if (empty($videosArrayId)) {
if ($suggestedOnly) { if ($suggestedOnly) {
$sql .= " AND v.isSuggested = 1 AND v.status = '" . self::$statusActive . "' "; $sql .= " AND v.isSuggested = 1 AND v.status = '" . self::$statusActive . "' ";
$sql .= " ORDER BY RAND() "; $sql .= " ORDER BY RAND() ";
@ -1765,6 +1768,7 @@ if (!class_exists('Video')) {
} }
$sql .= ObjectYPT::getSqlLimit(); $sql .= ObjectYPT::getSqlLimit();
} }
}
if (strpos(mb_strtolower($sql), 'limit') === false) { if (strpos(mb_strtolower($sql), 'limit') === false) {
if (!empty($_GET['limitOnceToOne'])) { if (!empty($_GET['limitOnceToOne'])) {
$sql .= " LIMIT 1"; $sql .= " LIMIT 1";
@ -1785,7 +1789,7 @@ if (!class_exists('Video')) {
} }
} }
//var_dump($max_duration_in_seconds);echo $sql;exit; //var_dump($max_duration_in_seconds);echo $sql; //exit;
//_error_log("getAllVideos($status, $showOnlyLoggedUserVideos , $ignoreGroup , ". json_encode($videosArrayId).")" . $sql); //_error_log("getAllVideos($status, $showOnlyLoggedUserVideos , $ignoreGroup , ". json_encode($videosArrayId).")" . $sql);
$timeLogName = TimeLogStart("video::getAllVideos"); $timeLogName = TimeLogStart("video::getAllVideos");
@ -3221,7 +3225,7 @@ if (!class_exists('Video')) {
$tags = Video::getTags($video_id); $tags = Video::getTags($video_id);
$_getTagsHTMLLabelArray[$video_id] = []; $_getTagsHTMLLabelArray[$video_id] = [];
$valid_tags = [__("Paid Content"), __("Group"), __("Plugin"), __("Rating"),__("Pinned")]; $valid_tags = [__("Paid Content"), __("Group"), __("Plugin"), __("Rating"), __("Pinned")];
foreach ($tags as $value2) { foreach ($tags as $value2) {
if (empty($value2->label) || empty($value2->text)) { if (empty($value2->label) || empty($value2->text)) {
continue; continue;
@ -3326,7 +3330,7 @@ if (!class_exists('Video')) {
$tags = []; $tags = [];
if (empty($type) || $type === VideoTags::$TagTypePinned) { if (empty($type) || $type === VideoTags::$TagTypePinned) {
if($video->getOrder()){ if ($video->getOrder()) {
$objTag = new stdClass(); $objTag = new stdClass();
$objTag->label = __("Pinned"); $objTag->label = __("Pinned");
$objTag->type = "default"; $objTag->type = "default";
@ -6508,8 +6512,18 @@ if (!class_exists('Video')) {
$galleryVideoButtons .= $galleryDropDownMenu . '</div>'; $galleryVideoButtons .= $galleryDropDownMenu . '</div>';
} }
if (!empty($video['playlists_id']) && isset($video['playlist_index'])) {
if (!class_exists('PlayLists')) {
AVideoPlugin::loadPlugin('PlayLists');
}
$href = PlayLists::getLink($video['playlists_id'], false, $video['playlist_index']);
$embed = PlayLists::getLink($video['playlists_id'], true, $video['playlist_index']);
} else {
$href = Video::getLink($video['id'], $video['clean_title']); $href = Video::getLink($video['id'], $video['clean_title']);
$embed = Video::getLink($video['id'], $video['clean_title'], true); $embed = Video::getLink($video['id'], $video['clean_title'], true);
}
$title = safeString($video['title']); $title = safeString($video['title']);
$a = '<a videos_id="' . $videos_id . '" $a = '<a videos_id="' . $videos_id . '"
href="' . $href . '" href="' . $href . '"

View file

@ -84,6 +84,10 @@ class Gallery extends PluginAbstract
$obj->SuggestedRowCount = 12; $obj->SuggestedRowCount = 12;
$obj->SuggestedOrder = 1; $obj->SuggestedOrder = 1;
$obj->PlayLists = true;
$obj->PlayListsRowCount = 12;
$obj->PlayListsOrder = 2;
$obj->Trending = true; $obj->Trending = true;
$obj->TrendingCustomTitle = ""; $obj->TrendingCustomTitle = "";
$obj->TrendingRowCount = 12; $obj->TrendingRowCount = 12;

View file

@ -70,21 +70,53 @@ saveRequestVars();
include $global['systemRootPath'] . 'plugin/Gallery/view/mainAreaCategory.php'; include $global['systemRootPath'] . 'plugin/Gallery/view/mainAreaCategory.php';
} else { } else {
//var_dump($sections);exit;
foreach ($sections as $value) { foreach ($sections as $value) {
if (empty($value['active'])) { if (empty($value['active'])) {
continue; continue;
} }
$countSections++; $countSections++;
if(preg_match('/Channel_([0-9]+)_/', $value['name'], $matches)){ if (preg_match('/Channel_([0-9]+)_/', $value['name'], $matches)) {
$users_id = intval($matches[1]); $users_id = intval($matches[1]);
User::getChannelPanel($users_id); User::getChannelPanel($users_id);
} else } else
if ($value['name'] == 'Shorts' && AVideoPlugin::isEnabledByName('Shorts')) { if ($value['name'] == 'Shorts' && AVideoPlugin::isEnabledByName('Shorts')) {
include $global['systemRootPath'].'plugin/Shorts/row.php'; include $global['systemRootPath'] . 'plugin/Shorts/row.php';
} else } else
if ($value['name'] == 'Suggested') { if ($value['name'] == 'Suggested') {
createGallery(!empty($obj->SuggestedCustomTitle) ? $obj->SuggestedCustomTitle : __("Suggested"), 'suggested', $obj->SuggestedRowCount, 'SuggestedOrder', "", "", $orderString, "ASC", !$obj->hidePrivateVideos, "fas fa-star"); createGallery(!empty($obj->SuggestedCustomTitle) ? $obj->SuggestedCustomTitle : __("Suggested"), 'suggested', $obj->SuggestedRowCount, 'SuggestedOrder', "", "", $orderString, "ASC", !$obj->hidePrivateVideos, "fas fa-star");
} else } else
if($value['name'] == 'PlayLists'){
$objPl = AVideoPlugin::getDataObject('PlayLists');
$plRows = PlayList::getAllToShowOnFirstPage();
//var_dump(count($plRows));exit;
if (!empty($plRows)) {
$rowCount = getRowCount();
setRowCount(12);
foreach ($plRows as $pl) {
?>
<!-- For Playlist -->
<div class="clear clearfix">
<h3 class="galleryTitle">
<a href="<?php echo "{$global['webSiteRootURL']}viewProgram/{$pl['id']}/" . urlencode($pl['name']); ?>">
<i class="fas fa-list"></i> <?php echo __($pl['name']); ?>
</a>
</h3>
<?php
$videos = PlayList::getAllFromPlaylistsID($pl['id']);
// need to add dechex because some times it return an negative value and make it fails on javascript playlists
?>
<div class="gallerySectionContent">
<?php
$countCols = createGallerySection($videos);
?>
</div>
</div>
<?php
}
setRowCount($rowCount);
}
}else
if ($value['name'] == 'Trending') { if ($value['name'] == 'Trending') {
createGallery(!empty($obj->TrendingCustomTitle) ? $obj->TrendingCustomTitle : __("Trending"), 'trending', $obj->TrendingRowCount, 'TrendingOrder', "zyx", "abc", $orderString, "ASC", !$obj->hidePrivateVideos, "fas fa-chart-line"); createGallery(!empty($obj->TrendingCustomTitle) ? $obj->TrendingCustomTitle : __("Trending"), 'trending', $obj->TrendingRowCount, 'TrendingOrder', "zyx", "abc", $orderString, "ASC", !$obj->hidePrivateVideos, "fas fa-chart-line");
} else } else
@ -130,7 +162,7 @@ saveRequestVars();
} }
} }
} else { } else {
echo '<!-- '.basename(__FILE__).' -->'; echo '<!-- ' . basename(__FILE__) . ' -->';
include $global['systemRootPath'] . 'plugin/Gallery/view/modeGalleryCategoryLive.php'; include $global['systemRootPath'] . 'plugin/Gallery/view/modeGalleryCategoryLive.php';
$ob = _ob_get_clean(); $ob = _ob_get_clean();
_ob_start(); _ob_start();
@ -159,9 +191,9 @@ saveRequestVars();
<?php echo __("We have not found any videos or audios to show"); ?>. <?php echo __("We have not found any videos or audios to show"); ?>.
</div> </div>
<?php <?php
_error_log('contentSearchFound NOT FOUND '. json_encode(debug_backtrace())); _error_log('contentSearchFound NOT FOUND ' . json_encode(debug_backtrace()));
_error_log('contentSearchFound NOT FOUND LAST SQL '. $debugLastGetVideoSQL); _error_log('contentSearchFound NOT FOUND LAST SQL ' . $debugLastGetVideoSQL);
_error_log('contentSearchFound NOT FOUND LAST TOTAL SQL '. $lastGetTotalVideos); _error_log('contentSearchFound NOT FOUND LAST TOTAL SQL ' . $lastGetTotalVideos);
include $global['systemRootPath'] . 'view/include/notfound.php'; include $global['systemRootPath'] . 'view/include/notfound.php';
} }
?> ?>

View file

@ -21,6 +21,8 @@ if (empty($isASerie)) {
} else { } else {
$currentSerieVideos_id = $isASerie['id']; $currentSerieVideos_id = $isASerie['id'];
} }
getSharePopupButton(0, "{$global['webSiteRootURL']}viewProgram/{$program['id']}/".urlencode($program['name']), $program['name'], 'btn-xs');
?> ?>
<a href="<?php echo $link; ?>" class="btn btn-xs btn-default playAll hrefLink" data-toggle="tooltip" title="<?php echo __("Play All"); ?>" > <a href="<?php echo $link; ?>" class="btn btn-xs btn-default playAll hrefLink" data-toggle="tooltip" title="<?php echo __("Play All"); ?>" >
<span class="fa fa-play"></span> <span class="hidden-sm hidden-xs"><?php echo __("Play All"); ?></span> <span class="fa fa-play"></span> <span class="hidden-sm hidden-xs"><?php echo __("Play All"); ?></span>
@ -72,7 +74,6 @@ if (PlayLists::canManagePlaylist($playlists_id)) {
echo PlayLists::getShowOnTVSwitch($program['id']); echo PlayLists::getShowOnTVSwitch($program['id']);
if ($program['status'] != "favorite" && $program['status'] != "watch_later") { if ($program['status'] != "favorite" && $program['status'] != "watch_later") {
if (AVideoPlugin::isEnabledByName("PlayLists")) { if (AVideoPlugin::isEnabledByName("PlayLists")) {
getSharePopupButton(0, "{$global['webSiteRootURL']}viewProgram/{$program['id']}/".urlencode($program['name']), $program['name'], 'btn-xs');
?> ?>
<button class="btn btn-xs btn-default" onclick="copyToClipboard($('#playListEmbedCode<?php echo $program['id']; ?>').val()); setTextEmbedCopied();" data-toggle="tooltip" title="<?php echo __("Copy Embed code"); ?>" > <button class="btn btn-xs btn-default" onclick="copyToClipboard($('#playListEmbedCode<?php echo $program['id']; ?>').val()); setTextEmbedCopied();" data-toggle="tooltip" title="<?php echo __("Copy Embed code"); ?>" >
<span class="fa fa-copy"></span> <span id="btnEmbedText" class="hidden-sm hidden-xs"><?php echo __("Embed code"); ?></span> <span class="fa fa-copy"></span> <span id="btnEmbedText" class="hidden-sm hidden-xs"><?php echo __("Embed code"); ?></span>

View file

@ -1,3 +1,5 @@
ALTER TABLE `configurations` ALTER TABLE `playlists`
CHANGE COLUMN `language` `language` VARCHAR(25) NOT NULL DEFAULT 'en_US'; ADD COLUMN `showOnFirstPage` TINYINT(1) UNSIGNED NULL DEFAULT 0,
UPDATE configurations SET version = '12.8', modified = now() WHERE id = 1; ADD INDEX `showonFirstpage` (`showOnFirstPage` ASC);
UPDATE configurations SET version = '12.9', modified = now() WHERE id = 1;

View file

@ -103,7 +103,7 @@ unset($_POST['current']);
@$timesC[__LINE__] += microtime(true) - $startC; @$timesC[__LINE__] += microtime(true) - $startC;
$startC = microtime(true); $startC = microtime(true);
//_error_log("channelPlaylist videosP: ".json_encode($videosP)); //_error_log("channelPlaylist videosP: ".json_encode($videosP));
$videosP = PlayList::sortVideos($videosP, $videosArrayId); //$videosP = PlayList::sortVideos($videosP, $videosArrayId);
@$timesC[__LINE__] += microtime(true) - $startC; @$timesC[__LINE__] += microtime(true) - $startC;
$startC = microtime(true); $startC = microtime(true);
//_error_log("channelPlaylist videosP2: ".json_encode($videosP)); //_error_log("channelPlaylist videosP2: ".json_encode($videosP));
@ -117,7 +117,8 @@ unset($_POST['current']);
<div class="panel-heading clearfix"> <div class="panel-heading clearfix">
<div class="pull-left"> <div class="pull-left">
<strong style="font-size: 1.1em;" class="playlistName"> <strong style="font-size: 1.1em;" class="playlistName">
<?php echo __($playlist['name']); ?> <!-- <?php echo basename(__FILE__); ?> -->
<a href="<?php echo "{$global['webSiteRootURL']}viewProgram/{$playlist['id']}/".urlencode($playlist['name']); ?>"><?php echo __($playlist['name']); ?></a>
</strong><br> </strong><br>
<small class="text-muted"> <small class="text-muted">
<?php echo seconds2human(PlayList::getTotalDurationFromPlaylistInSeconds($playlist['id'])); ?> <?php echo seconds2human(PlayList::getTotalDurationFromPlaylistInSeconds($playlist['id'])); ?>
@ -131,7 +132,6 @@ unset($_POST['current']);
<?php <?php
if (!empty($videosArrayId)) { if (!empty($videosArrayId)) {
?> ?>
<div class="panel-body"> <div class="panel-body">
<?php <?php
$serie = PlayLists::isPlayListASerie($playlist['id']); $serie = PlayLists::isPlayListASerie($playlist['id']);

View file

@ -27,7 +27,7 @@ if (User::isLogged() && $user_id == User::getId()) {
$isMyChannel = true; $isMyChannel = true;
} }
$programs = PlayList::getAllFromUser(empty($_GET['program_id'])?$user_id:0, $publicOnly, false, @$_GET['program_id']); $programs = PlayList::getAllFromUser(empty($_GET['program_id']) ? $user_id : 0, $publicOnly, false, @$_GET['program_id']);
if (empty($programs)) { if (empty($programs)) {
$programs = PlayList::getAllFromUser($user_id, $publicOnly); $programs = PlayList::getAllFromUser($user_id, $publicOnly);
} else { } else {
@ -89,7 +89,7 @@ $playListsObj = AVideoPlugin::getObjectData("PlayLists");
@$timesC[__LINE__] += microtime(true) - $startC; @$timesC[__LINE__] += microtime(true) - $startC;
$startC = microtime(true); $startC = microtime(true);
//_error_log("channelPlaylist videosP: ".json_encode($videosP)); //_error_log("channelPlaylist videosP: ".json_encode($videosP));
$videosP = PlayList::sortVideos($videosP, $videosArrayId); //$videosP = PlayList::sortVideos($videosP, $videosArrayId);
@$timesC[__LINE__] += microtime(true) - $startC; @$timesC[__LINE__] += microtime(true) - $startC;
$startC = microtime(true); $startC = microtime(true);
//_error_log("channelPlaylist videosP2: ".json_encode($videosP)); //_error_log("channelPlaylist videosP2: ".json_encode($videosP));
@ -97,13 +97,19 @@ $playListsObj = AVideoPlugin::getObjectData("PlayLists");
@$timesC[__LINE__] += microtime(true) - $startC; @$timesC[__LINE__] += microtime(true) - $startC;
$startC = microtime(true); $startC = microtime(true);
$totalVideos = count($videosP); $totalVideos = count($videosP);
$checked = '';
if(!empty($program['showOnFirstPage'])){
$checked = ' checked="checked" ';
}
?> ?>
<br> <br>
<div class="panel panel-default program" playListId="<?php echo $program['id']; ?>"> <div class="panel panel-default program" playListId="<?php echo $program['id']; ?>">
<div class="panel-heading clearfix"> <div class="panel-heading clearfix" style="padding-left: 10px;">
<span class="badge pull-right"><?php echo $totalVideos; ?> <?php echo __('Videos'); ?></span> <span class="badge pull-right"><?php echo $totalVideos; ?> <?php echo __('Videos'); ?></span>
<div class="pull-left"> <div class="pull-left">
<strong style="font-size: 1.1em;" class="playlistName"> <strong style="font-size: 1.1em;" class="playlistName">
<!-- <?php echo basename(__FILE__); ?> -->
<?php echo __($program['name']); ?> <?php echo __($program['name']); ?>
</strong><br> </strong><br>
<small class="text-muted"> <small class="text-muted">
@ -112,6 +118,20 @@ $playListsObj = AVideoPlugin::getObjectData("PlayLists");
</div> </div>
<?php <?php
PlayLists::getPLButtons($program['id'], false); PlayLists::getPLButtons($program['id'], false);
if (PlayLists::canManageAllPlaylists()) {
?>
<br>
<div class="pull-right" style="padding: 10px 0 0 0;">
<label for="addOnFirstPage<?php echo $program['id']; ?>">
<span style="margin-right: 10px;"><?php echo __('Add to first page'); ?></span>
</label>
<div class="material-small material-switch pull-right">
<input <?php echo $checked; ?> name="addOnFirstPage" id="addOnFirstPage<?php echo $program['id']; ?>" class="addOnFirstPage" type="checkbox" value="<?php echo $program['id']; ?>">
<label for="addOnFirstPage<?php echo $program['id']; ?>" class="label-success"></label>
</div>
</div>
<?php
}
?> ?>
</div> </div>
@ -318,6 +338,15 @@ $playListsObj = AVideoPlugin::getObjectData("PlayLists");
var currentObject; var currentObject;
$(function() { $(function() {
$('.addOnFirstPage').on('change', function() {
url = webSiteRootURL + 'objects/playlistAddOnFirstPage.json.php';
var playlist_id = $(this).val();
var showOnFirstPage = $(this).prop('checked');
avideoAjax(url, {
playlist_id: playlist_id,
showOnFirstPage: showOnFirstPage
});
});
<?php <?php
if (count($programs) <= 1 || !empty($palyListsObj->expandPlayListOnChannels)) { if (count($programs) <= 1 || !empty($palyListsObj->expandPlayListOnChannels)) {
?> ?>
@ -343,7 +372,7 @@ $playListsObj = AVideoPlugin::getObjectData("PlayLists");
var playlist_id = $(currentObject).attr('playlist_id'); var playlist_id = $(currentObject).attr('playlist_id');
var video_id = $(currentObject).attr('video_id'); var video_id = $(currentObject).attr('video_id');
$.ajax({ $.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>objects/playlistRemoveVideo.php', url: webSiteRootURL + 'objects/playlistRemoveVideo.php',
data: { data: {
"playlist_id": playlist_id, "playlist_id": playlist_id,
"video_id": video_id "video_id": video_id