56 lines
2.0 KiB
PHP
56 lines
2.0 KiB
PHP
<?php
|
|
class PostRender
|
|
{
|
|
public static function rows($varRows)
|
|
{
|
|
$varUser = UserAuth::getUser();
|
|
$varParsedown = new Parsedown();
|
|
$intRenderedRows = 0;
|
|
?>
|
|
|
|
<div class="post-container">
|
|
<?php foreach ($varRows as $r): ?>
|
|
<?php if (!UserAuth::visible($r["visibility"])) continue; ?>
|
|
|
|
<?php if ($intRenderedRows > 0): ?>
|
|
<hr />
|
|
<?php endif; ?>
|
|
|
|
<div class="post">
|
|
<div class="post-body">
|
|
<?php echo $varParsedown->text($r["content"]); ?>
|
|
</div>
|
|
|
|
<div class="post-footer">
|
|
<div class="post-author">by <?= $r["username"]; ?></div>
|
|
<div class="post-date">on <?= $r["created"]; ?> UTC</div>
|
|
|
|
<div class="post-links">
|
|
<a href="/<?= $r["id"]; ?>">Permalink</a> ·
|
|
<a href="<?= $r["location"]; ?>">Related</a>
|
|
|
|
<?php
|
|
$intOwnership =
|
|
UserAuth::has("is_admin") ||
|
|
$varUser["username"] == $r["username"];
|
|
?>
|
|
|
|
<?php if ($intOwnership): ?>
|
|
· <a href="/post/<?= $r["id"]; ?>">Edit</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php $intRenderedRows++; ?>
|
|
<?php endforeach; ?>
|
|
|
|
<?php if ($intRenderedRows < 1): ?>
|
|
<div>Sorry, there is nothing here to show.</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|