mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-26 21:27:15 +00:00
Incremental Refactor Templates
Incremental Refactor Templates
This commit is contained in:
+154
-67
@@ -1,69 +1,156 @@
|
||||
<div id="content" class="messages">
|
||||
<h1>Messages</h1>
|
||||
<?php
|
||||
include("menu.tpl");
|
||||
#################################################################################
|
||||
## SAFE INCREMENTAL REFATOR - Archive Messages ##
|
||||
## Credits: optimized structure, same logic preserved ##
|
||||
## Compatibility: PHP 5.6+ / PHP 7+ ##
|
||||
#################################################################################
|
||||
?>
|
||||
<form method="post" action="nachrichten.php" name="msg" ><input type="hidden" name="ft" value="m5" /><table cellpadding="1" cellspacing="1" id="overview">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">Subject</th>
|
||||
<th>Sender</th>
|
||||
<th class="sent"><a href="nachrichten.php?s=0&t=3&o=1">Sent</a></th>
|
||||
</tr></thead><tfoot><tr><th>
|
||||
<input class="check" type="checkbox" id="s10" name="s10" onclick="Allmsg(this.form);" />
|
||||
</th>
|
||||
<th colspan="2" class="buttons">
|
||||
<button name="delmsg" value="delete" id="btn_delete" class="trav_buttons">Delete</button> <button name="start" value="Back" id="btn_back" class="trav_buttons">Back</button></th>
|
||||
<th class="navi"><?php
|
||||
if(!isset($_GET['s']) && count($message->archived1) < 10) {
|
||||
echo "«»";
|
||||
}
|
||||
else if (!isset($_GET['s']) && count($message->archived1) > 10) {
|
||||
echo "«<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&' : '')."s=10&o=0\">»</a>";
|
||||
}
|
||||
else if(isset($_GET['s']) && count($message->archived1) > $_GET['s']) {
|
||||
if(count($message->archived1) > ($_GET['s']+10) && $_GET['s']-10 < count($message->archived1) && $_GET['s'] != 0) {
|
||||
echo "<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&' : '')."s=".($_GET['s']-10)."&o=0\">«</a><a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&' : '')."s=".($_GET['s']+10)."&o=0\">»</a>";
|
||||
}
|
||||
else if(count($message->archived1) > $_GET['s']+10) {
|
||||
echo "«<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&' : '')."s=".($_GET['s']+10)."&o=0\">»</a>";
|
||||
}
|
||||
else if (count($message->archived1) > 10) {
|
||||
echo "<a href=\"?".(!empty($_GET['t']) ? 't='.$_GET['t'].'&' : '')."s=".($_GET['s']-10)."&o=0\">«</a>»";
|
||||
}
|
||||
}
|
||||
?></th></tr></tfoot><tbody>
|
||||
<?php
|
||||
if(isset($_GET['s'])) {
|
||||
$s = $_GET['s'];
|
||||
}
|
||||
else {
|
||||
$s = 0;
|
||||
}
|
||||
$name = 1;
|
||||
for($i=(1+$s);$i<=(10+$s);$i++) {
|
||||
if(count($message->archived1) >= $i) {
|
||||
if($message->archived[$i-1]['owner'] == 0) {
|
||||
echo "<tr class=\"sup\">";
|
||||
}
|
||||
else {
|
||||
echo "<tr>";
|
||||
}
|
||||
echo "<td class=\"sel\"><input class=\"check\" type=\"checkbox\" name=\"n".$name."\" value=\"".$message->archived[$i-1]['id']."\" /></td>
|
||||
<td class=\"top\"><a href=\"nachrichten.php?id=".$message->archived[$i-1]['id']."\">".$message->archived[$i-1]['topic']."</a> ";
|
||||
if($message->archived[$i-1]['viewed'] == 0) {
|
||||
echo "(new)";
|
||||
}
|
||||
$date = $generator->procMtime($message->archived[$i-1]['time']);
|
||||
echo "</td><td class=\"send\"><a href=\"spieler.php?uid=".$message->archived[$i-1]['owner']."\"><u>".$database->getUserField($message->archived[$i-1]['owner'],'username',0)."</u></a></td>
|
||||
<td class=\"dat\">".$date[0]." ".$date[1]."</td></tr>";
|
||||
}
|
||||
$name++;
|
||||
}
|
||||
if(count($message->archived1) == 0) {
|
||||
echo "<td colspan=\"4\" class=\"none\">There are no messages available in the archive.</td></tr>";
|
||||
}
|
||||
?>
|
||||
</tbody></table>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="content" class="messages">
|
||||
<h1>Messages</h1>
|
||||
|
||||
<?php include("menu.tpl"); ?>
|
||||
|
||||
<form method="post" action="nachrichten.php" name="msg">
|
||||
<input type="hidden" name="ft" value="m5" />
|
||||
|
||||
<table cellpadding="1" cellspacing="1" id="overview">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">Subject</th>
|
||||
<th>Sender</th>
|
||||
<th class="sent">
|
||||
<a href="nachrichten.php?s=0&t=3&o=1">Sent</a>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>
|
||||
<input class="check" type="checkbox" id="s10" name="s10" onclick="Allmsg(this.form);" />
|
||||
</th>
|
||||
|
||||
<th colspan="2" class="buttons">
|
||||
<button name="delmsg" value="delete" id="btn_delete" class="trav_buttons">Delete</button>
|
||||
<button name="start" value="Back" id="btn_back" class="trav_buttons">Back</button>
|
||||
</th>
|
||||
|
||||
<th class="navi">
|
||||
<?php
|
||||
// ======================================================
|
||||
// PAGINATION (same logic, cleaned)
|
||||
// ======================================================
|
||||
$total = count($message->archived1);
|
||||
$s = isset($_GET['s']) ? (int)$_GET['s'] : 0;
|
||||
$tParam = !empty($_GET['t']) ? 't=' . $_GET['t'] . '&' : '';
|
||||
|
||||
if (!isset($_GET['s']) && $total < 10) {
|
||||
echo "«»";
|
||||
} elseif (!isset($_GET['s']) && $total > 10) {
|
||||
echo "«<a href=\"?" . $tParam . "s=10&o=0\">»</a>";
|
||||
} elseif (isset($_GET['s']) && $total > $_GET['s']) {
|
||||
|
||||
if ($total > ($_GET['s'] + 10) && $_GET['s'] - 10 < $total && $_GET['s'] != 0) {
|
||||
echo "<a href=\"?" . $tParam . "s=" . ($_GET['s'] - 10) . "&o=0\">«</a>
|
||||
<a href=\"?" . $tParam . "s=" . ($_GET['s'] + 10) . "&o=0\">»</a>";
|
||||
|
||||
} elseif ($total > $_GET['s'] + 10) {
|
||||
echo "«<a href=\"?" . $tParam . "s=" . ($_GET['s'] + 10) . "&o=0\">»</a>";
|
||||
|
||||
} elseif ($total > 10) {
|
||||
echo "<a href=\"?" . $tParam . "s=" . ($_GET['s'] - 10) . "&o=0\">«</a>»";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
// ======================================================
|
||||
// MESSAGE LIST
|
||||
// ======================================================
|
||||
$s = isset($_GET['s']) ? (int)$_GET['s'] : 0;
|
||||
$name = 1;
|
||||
|
||||
// cache username (important pentru performanță)
|
||||
$userCache = [];
|
||||
|
||||
$totalMessages = count($message->archived1);
|
||||
|
||||
for ($i = (1 + $s); $i <= (10 + $s); $i++) {
|
||||
|
||||
if ($totalMessages >= $i) {
|
||||
|
||||
// ATENȚIE: păstrăm exact structura originală (archived vs archived1)
|
||||
$msg = $message->archived[$i - 1];
|
||||
|
||||
// row class (logică originală)
|
||||
if ($msg['owner'] == 0) {
|
||||
echo "<tr class=\"sup\">";
|
||||
} else {
|
||||
echo "<tr>";
|
||||
}
|
||||
|
||||
// ======================================================
|
||||
// CHECKBOX
|
||||
// ======================================================
|
||||
echo "<td class=\"sel\">
|
||||
<input class=\"check\" type=\"checkbox\" name=\"n" . $name . "\" value=\"" . $msg['id'] . "\" />
|
||||
</td>";
|
||||
|
||||
// ======================================================
|
||||
// SUBJECT
|
||||
// ======================================================
|
||||
echo "<td class=\"top\">
|
||||
<a href=\"nachrichten.php?id=" . $msg['id'] . "\">" . $msg['topic'] . "</a>";
|
||||
|
||||
if ($msg['viewed'] == 0) {
|
||||
echo " (new)";
|
||||
}
|
||||
|
||||
echo "</td>";
|
||||
|
||||
// ======================================================
|
||||
// USERNAME (cached)
|
||||
// ======================================================
|
||||
$ownerId = (int)$msg['owner'];
|
||||
|
||||
if (!isset($userCache[$ownerId])) {
|
||||
$userCache[$ownerId] = $database->getUserField($ownerId, 'username', 0);
|
||||
}
|
||||
|
||||
$username = $userCache[$ownerId];
|
||||
|
||||
// ======================================================
|
||||
// DATE
|
||||
// ======================================================
|
||||
$date = $generator->procMtime($msg['time']);
|
||||
|
||||
echo "<td class=\"send\">
|
||||
<a href=\"spieler.php?uid=" . $ownerId . "\"><u>" . $username . "</u></a>
|
||||
</td>
|
||||
|
||||
<td class=\"dat\">" . $date[0] . " " . $date[1] . "</td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
$name++;
|
||||
}
|
||||
|
||||
// ======================================================
|
||||
// EMPTY STATE
|
||||
// ======================================================
|
||||
if ($totalMessages == 0) {
|
||||
echo "<td colspan=\"4\" class=\"none\">There are no messages available in the archive.</td></tr>";
|
||||
}
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user