Skip to content

Commit

Permalink
https://github.com/WWBN/AVideo/issues/9717
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Neto committed Dec 16, 2024
1 parent 5028204 commit 8a78d50
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 64 deletions.
119 changes: 59 additions & 60 deletions install/populateForTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,65 @@
$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;

function createImageWithText($text1, $text2, $filename)
{
// Create a blank image
$width = 640;
$height = 360;
$image = imagecreatetruecolor($width, $height);

// Allocate a color for the background and fill the background
$red = rand(0, 255);
$green = rand(0, 255);
$blue = rand(0, 255);
$backgroundColor = imagecolorallocate($image, $red, $green, $blue);
imagefilledrectangle($image, 0, 0, $width, $height, $backgroundColor);

// Calculate the luminance of the background color
$luminance = (0.299 * $red + 0.587 * $green + 0.114 * $blue) / 255;

// Allocate a color for the text
if ($luminance > 0.5) {
$textColor = imagecolorallocate($image, 0, 0, 0); // Use black text for a light background
} else {
$textColor = imagecolorallocate($image, 255, 255, 255); // Use white text for a dark background
}

// Font size and path
$fontSize = 48;
$fontPath = 'assets/Arial.ttf';

// Calculate x position of the first line of text
$box1 = imagettfbbox($fontSize, 0, $fontPath, $text1);
$textWidth1 = $box1[2] - $box1[0];
$x1 = ($width - $textWidth1) / 2;

// Calculate x position of the second line of text
$box2 = imagettfbbox($fontSize, 0, $fontPath, $text2);
$textWidth2 = $box2[2] - $box2[0];
$x2 = ($width - $textWidth2) / 2;

// Y positions for each line of text
$y1 = ceil($height / 3);
$y2 = $y1 * 2;

// Add the text to the image
imagettftext($image, $fontSize, 0, $x1, $y1, $textColor, $fontPath, $text1);
imagettftext($image, $fontSize, 0, $x2, $y2, $textColor, $fontPath, $text2);

// Save the image
imagejpeg($image, $filename);

// Free up memory
imagedestroy($image);
}

/*
for ($i = 0; $i < $totalCategories; $i++) {
$date = date('Y/m/d H:i:s');
Expand All @@ -43,7 +97,7 @@
echo "pupulating [$totalVideos/$i] subcategory saved [id=$id]" . PHP_EOL;
}
}
*/
echo "pupulating ... ";
$cats = Category::getAllCategories();
echo "pupulating ... ".__LINE__;
Expand All @@ -58,7 +112,6 @@
$id = $video->save(false, true);
echo "[{$total}/{$key}] pupulating video category saved [id=$id catId={$cats[$index]['id']}]" . PHP_EOL;
}
exit;

$newVideosIds = array();

Expand Down Expand Up @@ -103,7 +156,7 @@
$newVideosIds[] = $id;
echo "pupulating [$totalVideos/$i] Video saved [id=$id]" . PHP_EOL;
}
/*
AVideoPlugin::loadPlugin('PlayLists');
Expand All @@ -130,62 +183,8 @@
}
}
die();
function createImageWithText($text1, $text2, $filename)
{
// Create a blank image
$width = 640;
$height = 360;
$image = imagecreatetruecolor($width, $height);
// Allocate a color for the background and fill the background
$red = rand(0, 255);
$green = rand(0, 255);
$blue = rand(0, 255);
$backgroundColor = imagecolorallocate($image, $red, $green, $blue);
imagefilledrectangle($image, 0, 0, $width, $height, $backgroundColor);
// Calculate the luminance of the background color
$luminance = (0.299 * $red + 0.587 * $green + 0.114 * $blue) / 255;
// Allocate a color for the text
if ($luminance > 0.5) {
$textColor = imagecolorallocate($image, 0, 0, 0); // Use black text for a light background
} else {
$textColor = imagecolorallocate($image, 255, 255, 255); // Use white text for a dark background
}
// Font size and path
$fontSize = 48;
$fontPath = 'assets/Arial.ttf';
// Calculate x position of the first line of text
$box1 = imagettfbbox($fontSize, 0, $fontPath, $text1);
$textWidth1 = $box1[2] - $box1[0];
$x1 = ($width - $textWidth1) / 2;
// Calculate x position of the second line of text
$box2 = imagettfbbox($fontSize, 0, $fontPath, $text2);
$textWidth2 = $box2[2] - $box2[0];
$x2 = ($width - $textWidth2) / 2;
// Y positions for each line of text
$y1 = ceil($height / 3);
$y2 = $y1 * 2;
// Add the text to the image
imagettftext($image, $fontSize, 0, $x1, $y1, $textColor, $fontPath, $text1);
imagettftext($image, $fontSize, 0, $x2, $y2, $textColor, $fontPath, $text2);
// Save the image
imagejpeg($image, $filename);
//die();
// Free up memory
imagedestroy($image);
}
*/
/*
AVideoPlugin::loadPlugin('PlayLists');
$pls = PlayList::getAll();
$videos = Video::getAllVideosLight('');
Expand Down
6 changes: 4 additions & 2 deletions objects/functionInfiniteScroll.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ 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();
if ($total < $page) {
$page = $total;
}

//var_dump($page, $total, getCurrentPage());exit;

$isInfiniteScroll = !empty($infinityScrollGetFromSelector) && !empty($infinityScrollAppendIntoSelector);

Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions objects/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -2176,6 +2176,7 @@ public static function getTotalUsersFromUsergroup($users_groups_id, $ignoreAdmin
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;
}
Expand Down
1 change: 1 addition & 0 deletions plugin/Gallery/view/BigVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//unsetCurrentPage();
$videoRows = Video::getAllVideos(Video::SORT_TYPE_VIEWABLE, false, !$obj->hidePrivateVideos, array(), false, false, true, true);
}
resetCurrentPage();
if (empty($videoRows)) {
$videoRows = array($video);
}else{
Expand Down
1 change: 1 addition & 0 deletions plugin/YouPHPFlix2/view/modeFlixBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,5 +524,6 @@
unset($_POST['sort']);
unset($_REQUEST['current']);
unset($_REQUEST['rowCount']);
resetCurrentPage();
?>
</div>
9 changes: 7 additions & 2 deletions view/channelBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
//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']);
Expand Down Expand Up @@ -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();
Expand All @@ -450,6 +451,7 @@ function getChannelTabClass($isTabButton, $isVideoTab = false)
unset($uploadedVideos[0]);
}
}
//var_dump(getCurrentPage());exit;
?>
<div class="row">
<?php
Expand All @@ -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>
Expand Down

0 comments on commit 8a78d50

Please sign in to comment.