svrjs-mods-directory/includes/page_mod.php
2024-12-27 15:05:54 +01:00

59 lines
No EOL
3.9 KiB
PHP

<?php
if (!defined('SVRJS_MOD_DIRECTORY')) die;
$pageTitle = $modData['name'];
$pageDescription = $modData['description'] ? shortenDescription(str_replace(["\r\n", "\n", "\r"], " ", $modData['description'])) : 'Download and install the "' . $modData['name'] . '" mod.';
$pageImage = (isset($modData['image_ext']) && $modData['image_ext'] ? 'mods/' . urlencode(str_replace(['/', '\\'], '', $modData['slug'])) . '.' . urlencode(str_replace(['/', '\\'], '', $modData['image_ext'])) : 'mod-missing.png');
include 'header.php';
?>
<main class="content">
<div class="mod-header">
<h1><?php echo htmlspecialchars($modData['name']) ?></h1>
<p class="mod-badges">
<span class="badge"><?php echo $modData['is_paid'] ? 'Paid' : 'Gratis'; ?></span>
</p>
</div>
<img class="mod-cover" src="<?php echo htmlspecialchars(APP_ROOT . 'img/' . (isset($modData['image_ext']) && $modData['image_ext'] ? 'mods/' . urlencode(str_replace(['/', '\\'], '', $modData['slug'])) . '.' . urlencode(str_replace(['/', '\\'], '', $modData['image_ext'])) : 'mod-missing.png')) ?>" alt="<?php echo htmlspecialchars($modData['name']); ?> cover image">
<p class="mod-links button-container">
<a href="<?php echo htmlspecialchars($modData['link']); ?>" class="btn">Download the mod</a>
<?php if ($modData['docs_link']) echo '<a href="' . htmlspecialchars($modData['docs_link']) . '" class="btn btn-secondary">Read the documentation</a>'; ?>
</p>
<p>
<strong>Publisher:</strong> <a href="<?php
echo htmlspecialchars((URL_REWRITTEN ? APP_ROOT : APP_ROOT . APP_FILENAME . '/') . 'user/' . urlencode($modData['user']));
?>"><?php echo htmlspecialchars($modData['user']) ?></a> | <strong>Category:</strong> <?php echo isset($modData['category']) && $modData['category']
? '<a href="' . htmlspecialchars((URL_REWRITTEN ? APP_ROOT : APP_ROOT . APP_FILENAME . '/') . 'category/' . urlencode($modData['category_slug'])) . '">' . htmlspecialchars($modData['category']) . '</a>'
: 'Invalid category';
?><?php if ($_SESSION['user'] == $modData['user_id']) echo ' | <a href="' . htmlspecialchars((URL_REWRITTEN ? APP_ROOT : APP_ROOT . APP_FILENAME . '/') . 'edit-mod/' . urlencode($modData['slug'])) . '">Edit mod</a> | <a href="' . htmlspecialchars((URL_REWRITTEN ? APP_ROOT : APP_ROOT . APP_FILENAME . '/') . 'remove-mod/' . urlencode($modData['slug'])) . '">Remove mod</a>';
?>
</p>
<p>
<?php
if ($modData['rating']) {
$stars = round($modData['rating']);
echo htmlspecialchars(number_format($modData['rating'], 2));
echo ' ';
for ($i = 0; $i < $stars; $i++) {
echo '<span class="rating-star rating-star-higlighted">&starf;</span>';
}
for ($i = $stars; $i < 5; $i++) {
echo '<span class="rating-star">&starf;</span>';
}
echo ' | ';
}
?><strong>Reviews</strong>: <?php echo htmlspecialchars(number_format($modData['reviews'], 0)); ?> | <a href="<?php echo htmlspecialchars((URL_REWRITTEN ? APP_ROOT : APP_ROOT . APP_FILENAME . '/') . 'reviews/' . urlencode($modData['slug'])) ?>">View reviews</a>
</p>
<h2>Description</h2>
<p>
<?php echo isset($modData['description']) && $modData['description']
? str_replace(["\r\n", "\n", "\r"], '<br/>', htmlspecialchars($modData['description']))
: "<i>No description</i>";
?>
</p>
</main>
<?php
include 'footer.php';
?>