mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 10:49:36 +02:00
This commit is contained in:
parent
5028204f33
commit
8a78d50550
6 changed files with 125 additions and 116 deletions
|
@ -17,120 +17,11 @@ $audioFile = 'assets/testMP3.mp3';
|
|||
$spritFile = 'assets/thumbsSprit.jpg';
|
||||
$subtitleSRT = 'assets/subtitle.srt';
|
||||
$subtitleVTT = 'assets/subtitle.vtt';
|
||||
$totalVideos = 50;
|
||||
$totalPlaylists = 60;
|
||||
$totalVideos = 400;
|
||||
$totalPlaylists = 3;
|
||||
$totalVideosPerPlaylist = 30;
|
||||
$totalCategories = 10;
|
||||
$totalSubCategories = 5;
|
||||
/*
|
||||
for ($i = 0; $i < $totalCategories; $i++) {
|
||||
$date = date('Y/m/d H:i:s');
|
||||
$catTitle = "$i Auto Category $date";
|
||||
$catCleanTitle = "{$i}-Auto-Category-".date('YmdHis');
|
||||
$cat = new Category(0);
|
||||
$cat->setName($catTitle);
|
||||
$cat->setClean_name($catCleanTitle);
|
||||
$parentId = $cat->save(true);
|
||||
echo "pupulating [$totalVideos/$i] category saved [id=$parentId]" . PHP_EOL;
|
||||
for ($j = 0; $j < $totalSubCategories; $j++) {
|
||||
$catTitle = "$i Auto SubCategory $date";
|
||||
$catCleanTitle = "{$i}-Auto-SubCategory-".date('YmdHis');
|
||||
$cat = new Category(0);
|
||||
$cat->setName($catTitle);
|
||||
$cat->setClean_name($catCleanTitle);
|
||||
$cat->setParentId($parentId);
|
||||
$id = $cat->save(true);
|
||||
echo "pupulating [$totalVideos/$i] subcategory saved [id=$id]" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
echo "pupulating ... ";
|
||||
$cats = Category::getAllCategories();
|
||||
echo "pupulating ... ".__LINE__;
|
||||
$videos = Video::getAllVideosLight('');
|
||||
echo "pupulating ... ".__LINE__;
|
||||
$total = count($videos);
|
||||
echo "[{$total}/{$key}] pupulating video start ";
|
||||
foreach ($videos as $key => $value) {
|
||||
$video = new Video('', '', $value['id']);
|
||||
$index = array_rand($cats);
|
||||
$video->setCategories_id($cats[$index]['id']);
|
||||
$id = $video->save(false, true);
|
||||
echo "[{$total}/{$key}] pupulating video category saved [id=$id catId={$cats[$index]['id']}]" . PHP_EOL;
|
||||
}
|
||||
exit;
|
||||
|
||||
$newVideosIds = array();
|
||||
|
||||
// create videos
|
||||
for ($i = 0; $i < $totalVideos; $i++) {
|
||||
$date = date('Y/m/d H:i:s');
|
||||
$title = "[$i] Auto {$date}";
|
||||
$filename = "testvideo{$i}_" . uniqid();
|
||||
$video = new Video($title, $filename);
|
||||
|
||||
$video->setDuration("00:00:45");
|
||||
$video->setType('video');
|
||||
$video->setDuration_in_seconds(45);
|
||||
$video->setDescription($title);
|
||||
$video->setUsers_id(1);
|
||||
|
||||
$index = array_rand($cats);
|
||||
|
||||
$video->setCategories_id($cats[$index]['id']);
|
||||
$video->setStatus(Video::$statusActive);
|
||||
$video->setFilesize(2858747);
|
||||
$video->setLikes(rand(0, 1000));
|
||||
$video->setDislikes(rand(0, 1000));
|
||||
|
||||
$path = Video::getPathToFile($filename, true);
|
||||
|
||||
$mp4Filename = "{$path}_480.mp4";
|
||||
$mp3Filename = "{$path}.mp3";
|
||||
$jpgFilename = "{$path}.jpg";
|
||||
$spritFilename = "{$path}_thumbsSprit.jpg";
|
||||
$subtitleSRTFilename = "{$path}.srt";
|
||||
$subtitleVTTFilename = "{$path}.vtt";
|
||||
|
||||
createImageWithText("[$i] Auto Pupulated", $date, $jpgFilename);
|
||||
copy($videoFile, $mp4Filename);
|
||||
copy($audioFile, $mp3Filename);
|
||||
copy($spritFile, $spritFilename);
|
||||
copy($subtitleSRT, $subtitleSRTFilename);
|
||||
copy($subtitleVTT, $subtitleVTTFilename);
|
||||
|
||||
$id = $video->save(false, true);
|
||||
$newVideosIds[] = $id;
|
||||
echo "pupulating [$totalVideos/$i] Video saved [id=$id]" . PHP_EOL;
|
||||
}
|
||||
|
||||
AVideoPlugin::loadPlugin('PlayLists');
|
||||
|
||||
|
||||
if(empty($newVideosIds)){
|
||||
$global['rowCount'] = 99999;
|
||||
$videos = Video::getAllVideosLight("", false, true, false);
|
||||
$newVideosIds = array();
|
||||
foreach ($videos as $key => $video) {
|
||||
$newVideosIds[] = $video['id'];
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $totalPlaylists; $i++) {
|
||||
$name = "Playlist test autogenerated $i " . date('Y/m/d H:i:s');
|
||||
$playlist = new PlayList(0);
|
||||
$playlist->setName($name);
|
||||
$playlist->setStatus('a');
|
||||
$id = $playlist->save();
|
||||
echo "pupulating [$totalPlaylists/$i] Playlist saved [id=$id]" . PHP_EOL;
|
||||
for ($j = 0; $j < $totalVideosPerPlaylist; $j++) {
|
||||
$playList = new PlayList($id);
|
||||
$playList->addVideo($newVideosIds[array_rand($newVideosIds)], 1);
|
||||
echo "pupulating [$totalVideosPerPlaylist/$j] Video added in a Playlist" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
die();
|
||||
|
||||
function createImageWithText($text1, $text2, $filename)
|
||||
{
|
||||
|
@ -184,8 +75,116 @@ function createImageWithText($text1, $text2, $filename)
|
|||
// Free up memory
|
||||
imagedestroy($image);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
for ($i = 0; $i < $totalCategories; $i++) {
|
||||
$date = date('Y/m/d H:i:s');
|
||||
$catTitle = "$i Auto Category $date";
|
||||
$catCleanTitle = "{$i}-Auto-Category-".date('YmdHis');
|
||||
$cat = new Category(0);
|
||||
$cat->setName($catTitle);
|
||||
$cat->setClean_name($catCleanTitle);
|
||||
$parentId = $cat->save(true);
|
||||
echo "pupulating [$totalVideos/$i] category saved [id=$parentId]" . PHP_EOL;
|
||||
for ($j = 0; $j < $totalSubCategories; $j++) {
|
||||
$catTitle = "$i Auto SubCategory $date";
|
||||
$catCleanTitle = "{$i}-Auto-SubCategory-".date('YmdHis');
|
||||
$cat = new Category(0);
|
||||
$cat->setName($catTitle);
|
||||
$cat->setClean_name($catCleanTitle);
|
||||
$cat->setParentId($parentId);
|
||||
$id = $cat->save(true);
|
||||
echo "pupulating [$totalVideos/$i] subcategory saved [id=$id]" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
*/
|
||||
echo "pupulating ... ";
|
||||
$cats = Category::getAllCategories();
|
||||
echo "pupulating ... ".__LINE__;
|
||||
$videos = Video::getAllVideosLight('');
|
||||
echo "pupulating ... ".__LINE__;
|
||||
$total = count($videos);
|
||||
echo "[{$total}/{$key}] pupulating video start ";
|
||||
foreach ($videos as $key => $value) {
|
||||
$video = new Video('', '', $value['id']);
|
||||
$index = array_rand($cats);
|
||||
$video->setCategories_id($cats[$index]['id']);
|
||||
$id = $video->save(false, true);
|
||||
echo "[{$total}/{$key}] pupulating video category saved [id=$id catId={$cats[$index]['id']}]" . PHP_EOL;
|
||||
}
|
||||
|
||||
$newVideosIds = array();
|
||||
|
||||
// create videos
|
||||
for ($i = 0; $i < $totalVideos; $i++) {
|
||||
$date = date('Y/m/d H:i:s');
|
||||
$title = "[$i] Auto {$date}";
|
||||
$filename = "testvideo{$i}_" . uniqid();
|
||||
$video = new Video($title, $filename);
|
||||
|
||||
$video->setDuration("00:00:45");
|
||||
$video->setType('video');
|
||||
$video->setDuration_in_seconds(45);
|
||||
$video->setDescription($title);
|
||||
$video->setUsers_id(1);
|
||||
|
||||
$index = array_rand($cats);
|
||||
|
||||
$video->setCategories_id($cats[$index]['id']);
|
||||
$video->setStatus(Video::$statusActive);
|
||||
$video->setFilesize(2858747);
|
||||
$video->setLikes(rand(0, 1000));
|
||||
$video->setDislikes(rand(0, 1000));
|
||||
|
||||
$path = Video::getPathToFile($filename, true);
|
||||
|
||||
$mp4Filename = "{$path}_480.mp4";
|
||||
$mp3Filename = "{$path}.mp3";
|
||||
$jpgFilename = "{$path}.jpg";
|
||||
$spritFilename = "{$path}_thumbsSprit.jpg";
|
||||
$subtitleSRTFilename = "{$path}.srt";
|
||||
$subtitleVTTFilename = "{$path}.vtt";
|
||||
|
||||
createImageWithText("[$i] Auto Pupulated", $date, $jpgFilename);
|
||||
copy($videoFile, $mp4Filename);
|
||||
copy($audioFile, $mp3Filename);
|
||||
copy($spritFile, $spritFilename);
|
||||
copy($subtitleSRT, $subtitleSRTFilename);
|
||||
copy($subtitleVTT, $subtitleVTTFilename);
|
||||
|
||||
$id = $video->save(false, true);
|
||||
$newVideosIds[] = $id;
|
||||
echo "pupulating [$totalVideos/$i] Video saved [id=$id]" . PHP_EOL;
|
||||
}
|
||||
/*
|
||||
AVideoPlugin::loadPlugin('PlayLists');
|
||||
|
||||
|
||||
if(empty($newVideosIds)){
|
||||
$global['rowCount'] = 99999;
|
||||
$videos = Video::getAllVideosLight("", false, true, false);
|
||||
$newVideosIds = array();
|
||||
foreach ($videos as $key => $video) {
|
||||
$newVideosIds[] = $video['id'];
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $totalPlaylists; $i++) {
|
||||
$name = "Playlist test autogenerated $i " . date('Y/m/d H:i:s');
|
||||
$playlist = new PlayList(0);
|
||||
$playlist->setName($name);
|
||||
$playlist->setStatus('a');
|
||||
$id = $playlist->save();
|
||||
echo "pupulating [$totalPlaylists/$i] Playlist saved [id=$id]" . PHP_EOL;
|
||||
for ($j = 0; $j < $totalVideosPerPlaylist; $j++) {
|
||||
$playList = new PlayList($id);
|
||||
$playList->addVideo($newVideosIds[array_rand($newVideosIds)], 1);
|
||||
echo "pupulating [$totalVideosPerPlaylist/$j] Video added in a Playlist" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
//die();
|
||||
|
||||
AVideoPlugin::loadPlugin('PlayLists');
|
||||
$pls = PlayList::getAll();
|
||||
$videos = Video::getAllVideosLight('');
|
||||
|
|
|
@ -47,7 +47,7 @@ function getPagination($total, $link = "", $maxVisible = 10, $infinityScrollGetF
|
|||
{
|
||||
global $global, $advancedCustom;
|
||||
if ($total < 2) {
|
||||
return '<!-- getPagination total < 2 (' . json_encode($total) . ') -->';
|
||||
return '<!-- getPagination total < 2 (' . json_encode(array('total'=>$total, 'maxVisible'=>$maxVisible, 'total'=>$total, )) . ') -->';
|
||||
}
|
||||
|
||||
$page = getCurrentPage();
|
||||
|
@ -55,6 +55,8 @@ function getPagination($total, $link = "", $maxVisible = 10, $infinityScrollGetF
|
|||
$page = $total;
|
||||
}
|
||||
|
||||
//var_dump($page, $total, getCurrentPage());exit;
|
||||
|
||||
$isInfiniteScroll = !empty($infinityScrollGetFromSelector) && !empty($infinityScrollAppendIntoSelector);
|
||||
|
||||
$uid = uniqid();
|
||||
|
@ -87,7 +89,7 @@ function getPagination($total, $link = "", $maxVisible = 10, $infinityScrollGetF
|
|||
. _getPageItem($link, $page, $uid, true)
|
||||
. "</ul></nav>";
|
||||
}
|
||||
$pag = '<nav aria-label="Page navigation" class="text-center ' . $class . '"><ul class="pagination"><!-- page ' . $page . ' maxVisible = ' . $maxVisible . ' ' . $link . ' -->';
|
||||
$pag = '<nav aria-label="Page navigation" class="text-center ' . $class . '"><ul class="pagination"><!-- ' . json_encode(array('total'=>$total, 'maxVisible'=>$maxVisible, 'page'=>$page, 'link'=>$link, )) . ' -->';
|
||||
$start = 1;
|
||||
$end = $maxVisible;
|
||||
|
||||
|
|
|
@ -2176,6 +2176,7 @@ if (typeof gtag !== \"function\") {
|
|||
public static function getAllUsers($ignoreAdmin = false, $searchFields = ['name', 'email', 'user', 'channelName', 'about'], $status = "", $isAdmin = null, $isCompany = null, $canUpload = null)
|
||||
{
|
||||
if (!Permissions::canAdminUsers() && !$ignoreAdmin) {
|
||||
_error_log('You are not admin and cannot list all users');
|
||||
//echo __LINE__;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ if ($obj->BigVideo && empty($_GET['showOnly'])) {
|
|||
//unsetCurrentPage();
|
||||
$videoRows = Video::getAllVideos(Video::SORT_TYPE_VIEWABLE, false, !$obj->hidePrivateVideos, array(), false, false, true, true);
|
||||
}
|
||||
resetCurrentPage();
|
||||
if (empty($videoRows)) {
|
||||
$videoRows = array($video);
|
||||
}else{
|
||||
|
|
|
@ -524,5 +524,6 @@ background: -moz-linear-gradient(to top, rgba({$obj->backgroundRGB},1) {$percent
|
|||
unset($_POST['sort']);
|
||||
unset($_REQUEST['current']);
|
||||
unset($_REQUEST['rowCount']);
|
||||
resetCurrentPage();
|
||||
?>
|
||||
</div>
|
|
@ -68,7 +68,7 @@ if ($ownerCanUplaodVideos) {
|
|||
//var_dump($ownerCanUplaodVideos, $uploadedTotalVideos, $uploadedVideos, $lastGetTotalVideos, $user->getCanUpload(), $user->getIsAdmin(), $user_id, $user->getUser());exit;
|
||||
TimeLogEnd($timeLog, __LINE__);
|
||||
$totalPages = ceil($uploadedTotalVideos / $rowCount);
|
||||
|
||||
//var_dump($totalPages, $uploadedTotalVideos, $rowCount);exit;
|
||||
unset($_POST['sort']);
|
||||
unset($_POST['rowCount']);
|
||||
unset($_POST['current']);
|
||||
|
@ -440,6 +440,7 @@ function getChannelTabClass($isTabButton, $isVideoTab = false)
|
|||
<div class="panel-body">
|
||||
<?php
|
||||
$video = false;
|
||||
//var_dump(getCurrentPage());
|
||||
if ($advancedCustomUser->showBigVideoOnChannelVideosTab && !empty($uploadedVideos[0])) {
|
||||
$video = $uploadedVideos[0];
|
||||
$obj = new stdClass();
|
||||
|
@ -450,6 +451,7 @@ function getChannelTabClass($isTabButton, $isVideoTab = false)
|
|||
unset($uploadedVideos[0]);
|
||||
}
|
||||
}
|
||||
//var_dump(getCurrentPage());exit;
|
||||
?>
|
||||
<div class="row">
|
||||
<?php
|
||||
|
@ -461,7 +463,10 @@ function getChannelTabClass($isTabButton, $isVideoTab = false)
|
|||
</div>
|
||||
|
||||
<div class="panel-footer">
|
||||
<?php echo getPagination($totalPages, "{$global['webSiteRootURL']}channel/{$_GET['channelName']}?current=_pageNum_"); ?>
|
||||
<?php
|
||||
//var_dump($totalPages);
|
||||
echo getPagination($totalPages, "{$global['webSiteRootURL']}channel/{$_GET['channelName']}?current=_pageNum_");
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue