2021-10-15 20:38:36 -04:00
|
|
|
<?php
|
2022-03-14 15:43:01 -04:00
|
|
|
use PonePaste\Models\Paste;
|
|
|
|
|
2021-10-15 20:38:36 -04:00
|
|
|
$public_paste_badges = [
|
2022-04-19 19:36:18 -04:00
|
|
|
50 => '[ProbablyAutistic] Have more than fifty pastes',
|
|
|
|
25 => '[Writefag] Have twenty-five or more pastes',
|
|
|
|
5 => '[NewWritefag] Have five or more pastes',
|
|
|
|
0 => '[NewFriend] Have less than five pastes',
|
2021-10-15 20:38:36 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
$unlisted_paste_badges = [
|
|
|
|
10 => '',
|
|
|
|
5 => ''
|
|
|
|
];
|
|
|
|
|
|
|
|
$paste_view_badges = [
|
|
|
|
50000 => '[HorseAyylmao] Have more than 50,000 total views',
|
2022-04-19 19:36:18 -04:00
|
|
|
10000 => '[HorseIlluminati] Have more than 10,000 total views',
|
2021-10-15 20:38:36 -04:00
|
|
|
5000 => '[HorseMaster] Have more than 5000 total views',
|
2022-04-19 19:36:18 -04:00
|
|
|
3000 => '[HorseIdol] Have more than 3000 total views',
|
2021-10-15 20:38:36 -04:00
|
|
|
2000 => '[HorseFamous] Have more than 2000 total views',
|
|
|
|
1000 => '[HorseWriter] Have more than 1000 total views'
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function outputBadges(array $badgeCandidates, int $actualValue, string $imagePrefix) {
|
|
|
|
foreach ($badgeCandidates as $threshold => $badgeTitle) {
|
|
|
|
if ($actualValue >= $threshold) {
|
|
|
|
echo "<img src=\"/img/badges/${imagePrefix}_${threshold}.png\" title='$badgeTitle' alt='$badgeTitle' style='margin: 5px;' />";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
2021-07-10 19:18:17 +01:00
|
|
|
<main class="bd-main">
|
|
|
|
<div class="bd-side-background"></div>
|
|
|
|
<div class="bd-main-container container">
|
|
|
|
<div class="bd-duo">
|
|
|
|
<div class="bd-lead">
|
2021-10-15 20:38:36 -04:00
|
|
|
<h1 class="title is-5"><?= pp_html_escape($profile_username) ?>'s Pastes</h1>
|
2021-08-26 05:35:21 -04:00
|
|
|
<h1 class="subtitle is-6">joined: <?= $profile_join_date; ?></h1>
|
2021-07-12 09:03:02 -04:00
|
|
|
<!-- Badges system -->
|
2021-07-10 19:18:17 +01:00
|
|
|
<div class="box">
|
|
|
|
<h2 class="title is-5">Badges</h2>
|
2021-07-12 09:03:02 -04:00
|
|
|
<?php
|
2022-04-19 19:36:18 -04:00
|
|
|
if (!empty($profile_join_date)) {
|
|
|
|
if (strtotime($profile_join_date) <= 1604188800) {
|
|
|
|
echo '<img src="/img/badges/adopter.png" title="[EarlyAdopter] Joined during the first wave " style="margin:5px">';
|
|
|
|
} elseif (strtotime($profile_join_date) <= 1608422400) {
|
|
|
|
echo '<img src="/img/badges/pioneer.png" title="[EarlyPioneer] Joined during the second wave " style="margin:5px">';
|
|
|
|
} elseif (strtotime($profile_join_date) <= 1609459200) {
|
|
|
|
echo '<img src="/img/badges/strag.png" title="[EarlyStraggler] Joined after the second wave " style="margin:5px">';
|
|
|
|
}
|
2021-07-12 09:03:02 -04:00
|
|
|
}
|
2022-04-19 19:36:18 -04:00
|
|
|
|
2021-07-26 16:47:00 -04:00
|
|
|
if (!str_contains($profile_badge, '0')) {
|
2021-07-12 09:03:02 -04:00
|
|
|
echo $profile_badge;
|
|
|
|
}
|
|
|
|
|
2021-10-15 20:38:36 -04:00
|
|
|
outputBadges($public_paste_badges, $profile_total_public, 'total_pastes');
|
|
|
|
outputBadges($paste_view_badges, $profile_total_paste_views, 'total_views');
|
2021-07-12 09:03:02 -04:00
|
|
|
|
|
|
|
if (($profile_total_unlisted >= 5) && ($profile_total_unlisted <= 9)) {
|
2022-04-19 19:36:18 -04:00
|
|
|
echo '<img src="/img/badges/pastehidden.png" title="[ShadowWriter] Have more than five unlisted pastes" style="margin:5px">';
|
2021-07-12 09:03:02 -04:00
|
|
|
} elseif ($profile_total_unlisted >= 10) {
|
2022-04-19 19:36:18 -04:00
|
|
|
echo '<img src="/img/badges/pastehidden.png" title="[Ghostwriter] Have more than ten unlisted pastes" style="margin:5px">';
|
2021-07-12 09:03:02 -04:00
|
|
|
}
|
|
|
|
|
2021-07-10 19:18:17 +01:00
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
|
2022-04-20 18:45:29 -04:00
|
|
|
<?php outputFlashes($flashes) ?>
|
2021-07-10 19:18:17 +01:00
|
|
|
|
2021-10-22 21:43:35 -04:00
|
|
|
<?php if ($is_current_user): ?>
|
2021-08-26 05:35:21 -04:00
|
|
|
Some of your statistics:
|
|
|
|
<br />
|
|
|
|
Total pastes: <?= $profile_total_pastes ?> —
|
|
|
|
Total public pastes: <?= $profile_total_public ?> —
|
|
|
|
Total unlisted pastes: <?= $profile_total_unlisted ?> —
|
|
|
|
Total private pastes: <?= $profile_total_private ?> —
|
|
|
|
Total views of all your pastes: <?= $profile_total_paste_views ?>
|
|
|
|
<br />
|
|
|
|
Total favourites of all your pastes: <?= $total_pfav ?> —
|
|
|
|
Total favorites you have given: <?= $total_yfav ?>
|
|
|
|
<br />
|
|
|
|
<br />
|
2021-07-12 09:03:02 -04:00
|
|
|
<div class="tabs">
|
|
|
|
<ul class="tabs-menu">
|
|
|
|
<li class="is-active" data-target="first-tab"><a>My Pastes</a></li>
|
|
|
|
<li data-target="second-tab"><a>Favorites</a></li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2021-10-22 21:43:35 -04:00
|
|
|
<?php endif;?>
|
2021-07-10 19:18:17 +01:00
|
|
|
<div class="tab-content" id="first-tab">
|
2021-07-12 09:03:02 -04:00
|
|
|
<table id="archive" class="table is-fullwidth is-hoverable">
|
|
|
|
<thead>
|
2021-07-10 19:18:17 +01:00
|
|
|
<tr>
|
2022-03-12 13:56:32 -05:00
|
|
|
<th class="td-right">Title</th>
|
|
|
|
<th class="td-center">Paste Time</th>
|
2021-07-17 18:17:29 -04:00
|
|
|
<?php if ($is_current_user) {
|
2022-03-12 13:56:32 -05:00
|
|
|
echo "<th class='td-center'>Visibility</th>";
|
2021-07-10 19:18:17 +01:00
|
|
|
} ?>
|
2022-03-12 13:56:32 -05:00
|
|
|
<th class="td-center">Views</th>
|
|
|
|
<th class="td-center">Tags</th>
|
2021-07-17 18:17:29 -04:00
|
|
|
<?php if ($is_current_user) {
|
2022-03-12 13:56:32 -05:00
|
|
|
echo "<th class='td-center'>Delete</th>";
|
2021-07-10 19:18:17 +01:00
|
|
|
} ?>
|
|
|
|
</tr>
|
2021-07-12 09:03:02 -04:00
|
|
|
</thead>
|
|
|
|
<tbody>
|
2021-10-22 21:43:35 -04:00
|
|
|
<?php foreach ($profile_pastes as $paste): ?>
|
|
|
|
<?php
|
|
|
|
$escaped_title = pp_html_escape(truncate($paste->title, 20, 50));
|
|
|
|
$p_date = new DateTime($paste->created_at);
|
|
|
|
$p_visible = match (intval($paste->visible)) {
|
|
|
|
0 => 'Public',
|
|
|
|
1 => 'Unlisted',
|
|
|
|
2 => 'Private'
|
|
|
|
};
|
2022-03-12 13:56:32 -05:00
|
|
|
$pasteJson = array_merge(
|
2022-04-19 19:36:18 -04:00
|
|
|
$paste->only('id', 'title', 'tags', 'views', 'created_at', 'user_id'),
|
2022-03-12 13:56:32 -05:00
|
|
|
['visibility' => $p_visible]
|
|
|
|
);
|
2021-10-22 21:43:35 -04:00
|
|
|
?>
|
2022-03-14 15:43:01 -04:00
|
|
|
<?php if ($is_current_user || $paste->visible == Paste::VISIBILITY_PUBLIC): ?>
|
2022-03-12 13:56:32 -05:00
|
|
|
<tr data-paste-info="<?= pp_html_escape(json_encode($pasteJson)); ?>">
|
2021-10-22 21:43:35 -04:00
|
|
|
<td><a href="<?= urlForPaste($paste) ?>" title="<?= $escaped_title ?>"><?= $escaped_title ?></a></td>
|
2022-03-26 23:48:19 -04:00
|
|
|
<td data-sort="<?= $p_date->format('U') ?>" class="td-center">
|
|
|
|
<?= $p_date->format('d F Y') ?>
|
|
|
|
</td>
|
2021-10-22 21:43:35 -04:00
|
|
|
<td class="td-center"><?= $p_visible; ?></td>
|
|
|
|
<td class="td-center"><?= $paste->views ?></td>
|
|
|
|
<td class="td-left"><?= tagsToHtmlUser($paste->tags, $profile_username); ?></td>
|
2022-04-19 19:36:18 -04:00
|
|
|
<?php if (can('delete', $paste)): ?>
|
2022-03-14 15:43:01 -04:00
|
|
|
<td class="td-center">
|
|
|
|
<form action="<?= urlForPaste($paste) ?>" method="POST">
|
|
|
|
<input type="hidden" name="delete" value="delete" />
|
|
|
|
<input type="hidden" name="csrf_token" value="<?= $csrf_token ?>" />
|
|
|
|
<input type="submit" value="Delete" />
|
|
|
|
</form>
|
|
|
|
</td>
|
|
|
|
<?php endif; ?>
|
2021-10-22 21:43:35 -04:00
|
|
|
</tr>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endforeach; ?>
|
2021-07-12 09:03:02 -04:00
|
|
|
</tbody>
|
2021-08-26 05:58:37 -04:00
|
|
|
<tfoot>
|
|
|
|
<tr>
|
2022-03-12 13:56:32 -05:00
|
|
|
<th class="td-center">Title</th>
|
|
|
|
<th class="td-center">Paste Time</th>
|
2021-08-26 05:58:37 -04:00
|
|
|
<?php if ($is_current_user) {
|
|
|
|
echo "<td class='td-center'>Visibility</td>";
|
|
|
|
} ?>
|
2022-03-12 13:56:32 -05:00
|
|
|
<th class="td-center">Views</th>
|
|
|
|
<th class="td-center">Tags</th>
|
2021-08-26 05:58:37 -04:00
|
|
|
<?php if ($is_current_user) {
|
|
|
|
echo "<td class='td-center'>Delete</td>";
|
|
|
|
} ?>
|
|
|
|
</tr>
|
|
|
|
</tfoot>
|
2021-07-12 09:03:02 -04:00
|
|
|
</table>
|
2022-03-12 13:56:32 -05:00
|
|
|
<div class="paginator"></div>
|
2021-07-10 19:18:17 +01:00
|
|
|
</div>
|
2021-07-17 18:17:29 -04:00
|
|
|
<?php if ($is_current_user) { ?>
|
2021-07-10 19:18:17 +01:00
|
|
|
<div class="tab-content" id="second-tab">
|
2021-07-12 09:03:02 -04:00
|
|
|
<table id="favs" class="table is-fullwidth is-hoverable">
|
|
|
|
<thead>
|
2021-07-10 19:18:17 +01:00
|
|
|
<tr>
|
2022-03-12 13:56:32 -05:00
|
|
|
<th class="td-right">Title</th>
|
|
|
|
<th class="td-center">Date Favourited</th>
|
|
|
|
<th class="td-center">Status</th>
|
|
|
|
<th class="td-center">Tags</th>
|
2021-07-10 19:18:17 +01:00
|
|
|
</tr>
|
2021-07-12 09:03:02 -04:00
|
|
|
</thead>
|
2021-10-22 21:43:35 -04:00
|
|
|
<tbody>
|
|
|
|
<?php foreach ($profile_favs as $paste): ?>
|
|
|
|
<?php
|
|
|
|
$escaped_title = pp_html_escape(truncate($paste->title, 20, 50));
|
2021-11-01 16:56:17 -04:00
|
|
|
$f_date = new DateTime($paste->pivot->f_time);
|
|
|
|
$update_date = new DateTime($paste->updated_at);
|
|
|
|
$delta = $update_date->diff(new DateTime(), true);
|
2022-03-12 13:56:32 -05:00
|
|
|
$pasteJson = array_merge(
|
|
|
|
$paste->only('id', 'title', 'tags', 'views', 'created_at'),
|
|
|
|
['recently_updated' => ($delta->days <= 2), 'favourited_at' => $f_date->format('d F Y')]
|
|
|
|
);
|
2021-10-22 21:43:35 -04:00
|
|
|
?>
|
|
|
|
<?php if ($is_current_user || $row['visible'] == Paste::VISIBILITY_PUBLIC): ?>
|
2022-03-12 13:56:32 -05:00
|
|
|
<tr data-paste-info="<?= pp_html_escape(json_encode($pasteJson)); ?>">
|
2021-10-22 21:43:35 -04:00
|
|
|
<td><a href="<?= urlForPaste($paste) ?>" title="<?= $escaped_title ?>"><?= $escaped_title ?></a></td>
|
2022-03-12 13:56:32 -05:00
|
|
|
<td data-sort="<?= $p_date->format('U') ?>" class="td-center"><?= $f_date->format('d F Y') ?></td>
|
2021-11-01 16:56:17 -04:00
|
|
|
<td class="td-center">
|
|
|
|
<?php if ($delta->days <= 2): ?>
|
|
|
|
<i class='far fa-check-square fa-lg' aria-hidden='true'></i>
|
|
|
|
<?php else: ?>
|
|
|
|
<i class='far fa-minus-square fa-lg' aria-hidden='true'></i>
|
|
|
|
<?php endif; ?>
|
|
|
|
</td>
|
2021-10-22 21:43:35 -04:00
|
|
|
<td class="td-left"><?= tagsToHtmlUser($paste->tags, $profile_username); ?></td>
|
|
|
|
</tr>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</tbody>
|
|
|
|
<tfoot>
|
|
|
|
<tr>
|
|
|
|
<td class="td-right">Title</td>
|
|
|
|
<td class="td-center">Date Favourited</td>
|
|
|
|
<td class="td-center">Status</td>
|
|
|
|
<td class="td-center">Tags</td>
|
|
|
|
</tr>
|
|
|
|
</tfoot>
|
2021-11-01 16:56:17 -04:00
|
|
|
<?php } ?>
|
2021-07-12 09:03:02 -04:00
|
|
|
</table>
|
2022-03-12 13:56:32 -05:00
|
|
|
<div class="paginator"></div>
|
2021-07-10 19:18:17 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
<script>
|
2021-07-12 09:03:02 -04:00
|
|
|
const tabSystem = {
|
|
|
|
init() {
|
|
|
|
document.querySelectorAll('.tabs-menu').forEach(tabMenu => {
|
|
|
|
Array.from(tabMenu.children).forEach((child, ind) => {
|
|
|
|
child.addEventListener('click', () => {
|
|
|
|
tabSystem.toggle(child.dataset.target);
|
|
|
|
});
|
|
|
|
if (child.className.includes('is-active')) {
|
|
|
|
tabSystem.toggle(child.dataset.target);
|
|
|
|
}
|
2021-07-10 19:18:17 +01:00
|
|
|
});
|
|
|
|
});
|
2021-07-12 09:03:02 -04:00
|
|
|
},
|
|
|
|
toggle(targetId) {
|
|
|
|
document.querySelectorAll('.tab-content').forEach(contentElement => {
|
|
|
|
contentElement.style.display = contentElement.id === targetId ? 'block' : 'none';
|
|
|
|
document.querySelector(`[data-target="${contentElement.id}"]`).classList[contentElement.id === targetId ? 'add' : 'remove']('is-active');
|
|
|
|
})
|
|
|
|
},
|
|
|
|
};
|
|
|
|
// use it
|
|
|
|
tabSystem.init()
|
2021-07-10 19:18:17 +01:00
|
|
|
</script>
|