Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@AmauryCarrade
Last active September 13, 2016 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmauryCarrade/66a44ac117eb35c22a1f2076ff07c41f to your computer and use it in GitHub Desktop.
Save AmauryCarrade/66a44ac117eb35c22a1f2076ff07c41f to your computer and use it in GitHub Desktop.
Changes to display the last message of the previous page on FluxBB
diff --git a/style/Air.css b/style/Air.css
index 043112a..003d23b 100755
--- a/style/Air.css
+++ b/style/Air.css
@@ -1516,6 +1516,10 @@ html, body, .pun {
border-color: #dfe6ee;
}
+.pun .backpost .postbody, .pun .backpost .postfoot {
+ background: #f6f9fc;
+}
+
.pun .blockpost .postfootright li {
color: #fcfdfe;
}
diff --git a/style/Air2.css b/style/Air2.css
index 170420b..bd8e1ab 100644
--- a/style/Air2.css
+++ b/style/Air2.css
@@ -1520,6 +1520,10 @@ html, body, .pun {
border-color: #dfe6ee;
}
+.pun .backpost .postbody, .pun .backpost .postfoot {
+ background: #f6f9fc;
+}
+
.pun .blockpost .postfootright li {
color: #fcfdfe;
}
@@ -1717,4 +1721,4 @@ html, body, .pun {
.pun .blockpost .postleft, .pun .blockpost .postfootleft {
width: 100px;
}
-}
\ No newline at end of file
+}
diff --git a/style/Cobalt.css b/style/Cobalt.css
index 52fde75..1d9fc49 100755
--- a/style/Cobalt.css
+++ b/style/Cobalt.css
@@ -982,6 +982,10 @@ body {
background-color: #424242
}
+.pun .backpost .postright, .pun .backpost .inbox, .pun .backpost .postfootright {
+ background-color: #424242;
+ }
+
.pun .blockpost h2 {
background-color: #565656
}
diff --git a/style/Earth.css b/style/Earth.css
index 23f60df..9afd0ec 100755
--- a/style/Earth.css
+++ b/style/Earth.css
@@ -1470,6 +1470,11 @@ html, body, .pun {
border-color: #dce6d8;
}
+.pun .backpost .postbody, .pun .backpost .postfoot {
+ background: #f6f6ea;
+}
+
+
.pun .blockpost .postfootright li {
color: #fcfcf4;
}
diff --git a/style/Fire.css b/style/Fire.css
index 803980d..0028ea7 100755
--- a/style/Fire.css
+++ b/style/Fire.css
@@ -1470,6 +1470,11 @@ html, body, .pun {
border-color: #ebe0dc;
}
+.pun .backpost .postbody, .pun .backpost .postfoot {
+ background: #faf2ed;
+}
+
+
.pun .blockpost .postfootright li {
color: #fbfaf5;
}
diff --git a/style/Lithium.css b/style/Lithium.css
index 96f75a0..cb17089 100755
--- a/style/Lithium.css
+++ b/style/Lithium.css
@@ -976,6 +976,9 @@ body {
.pun .postleft, .pun .postfootleft, .pun .blockpost label, .pun .codebox, .pun .quotebox {
background-color: #f1f1f1
}
+.pun .backpost .postright, .pun .backpost .inbox, .pun .backpost .postfootright {
+ background-color: #f1f1f1;
+ }
#punhelp .codebox, #punhelp .quotebox {
background-color: #f9f9f9;
diff --git a/style/Mercury.css b/style/Mercury.css
index 708bde6..dfbe1d1 100755
--- a/style/Mercury.css
+++ b/style/Mercury.css
@@ -982,6 +982,10 @@ body {
background-color: #424242
}
+.pun .backpost .postright, .pun .backpost .inbox, .pun .backpost .postfootright {
+ background-color: #424242;
+ }
+
.pun .blockpost h2 {
background-color: #565656
}
diff --git a/style/Oxygen.css b/style/Oxygen.css
index 4d0fe79..de45591 100755
--- a/style/Oxygen.css
+++ b/style/Oxygen.css
@@ -978,6 +978,10 @@ body {
background-color: #f1f1f1
}
+.pun .backpost .postright, .pun .backpost .inbox, .pun .backpost .postfootright {
+ background-color: #f1f1f1;
+ }
+
#punhelp .codebox, #punhelp .quotebox {
background-color: #f9f9f9;
}
diff --git a/style/Radium.css b/style/Radium.css
index 505c92e..fc949f6 100755
--- a/style/Radium.css
+++ b/style/Radium.css
@@ -982,6 +982,10 @@ body {
background-color: #424242
}
+.pun .backpost .postright, .pun .backpost .inbox, .pun .backpost .postfootright {
+ background-color: #424242;
+ }
+
.pun .blockpost h2 {
background-color: #565656
}
diff --git a/style/Sulfur.css b/style/Sulfur.css
index 49b3e2d..671e765 100755
--- a/style/Sulfur.css
+++ b/style/Sulfur.css
@@ -977,6 +977,10 @@ body {
background-color: #f1f1f1
}
+.pun .backpost .postright, .pun .backpost .inbox, .pun .backpost .postfootright {
+ background-color: #f1f1f1;
+ }
+
#punhelp .codebox, #punhelp .quotebox {
background-color: #f9f9f9;
}
diff --git a/style/Technetium.css b/style/Technetium.css
index 6afd693..6396fc4 100755
--- a/style/Technetium.css
+++ b/style/Technetium.css
@@ -1176,6 +1176,10 @@ body {
background-color: #F0F5FA
}
+.pun .backpost .postright, .pun .backpost .inbox, .pun .backpost .postfootright {
+ background-color: #F0F5FA;
+ }
+
#punhelp .codebox, #punhelp .quotebox {
background-color: #f9f9f9;
}
diff --git a/style/Zcraft.css b/style/Zcraft.css
index 99f23bf..3be465b 100755
--- a/style/Zcraft.css
+++ b/style/Zcraft.css
@@ -1507,6 +1507,11 @@ html, body, .pun {
border-color: #dfe6ee;
}
+.pun .backpost .postbody, .pun .backpost .postfoot {
+ background: #f6f9fc;
+}
+
+
.pun .blockpost .postfootright li {
color: #fcfdfe;
}
@@ -1685,4 +1690,4 @@ html, body, .pun {
/*
END
Modifications Cyril pour icones minecraft 10/11/2010
-*/
\ No newline at end of file
+*/
diff --git a/viewtopic.php b/viewtopic.php
index 508e6de..9369330 100755
--- a/viewtopic.php
+++ b/viewtopic.php
@@ -105,7 +105,7 @@ $is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_moderator'] == '1'
if ($cur_topic['closed'] == '0')
{
if (($cur_topic['post_replies'] == '' && $pun_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1' || $is_admmod)
- $post_link = "\t\t\t".'<p class="postlink conr"><a href="post.php?tid='.$id.'">'.$lang_topic['Post reply'].'</a></p>'."\n";
+ $post_link = '<a href="post.php?tid='.$id.'">'.$lang_topic['Post reply'].'</a>';
else
$post_link = '';
}
@@ -135,6 +135,9 @@ $num_pages = ceil(($cur_topic['num_replies'] + 1) / $pun_user['disp_posts']);
$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']);
$start_from = $pun_user['disp_posts'] * ($p - 1);
+// If we're not on the first page, we also load the previous message, hidden at the top, to be able to display the last message of the previos page
+if ($p > 1) $start_from -= 1;
+
// Generate paging links
$paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'viewtopic.php?id='.$id);
@@ -176,6 +179,19 @@ require PUN_ROOT.'header.php';
?>
+<!-- Backposts style & script -->
+
+<style type="text/css">
+#backpost-display-link {
+ font-weight: normal;
+ margin-right: 1em;
+}
+.backpost {
+ display: none;
+ margin-bottom: 10px !important;
+}
+</style>
+
<div class="linkst">
<div class="inbox crumbsplus">
@@ -186,12 +202,44 @@ require PUN_ROOT.'header.php';
</ul>
<div class="pagepost">
<p class="pagelink conl"><?php echo $paging_links ?></p>
-<?php echo $post_link ?>
+ <p class="postlink conr">
+ <?php if ($p > 1): ?>
+ <a href="#" id="backpost-display-link">Voir le message précédent</a>
+ <?php endif; ?>
+ <?php echo $post_link ?>
+ </p>
</div>
<div class="clearer"></div>
</div>
</div>
+<?php if ($p > 1): ?>
+<script type="text/javascript">
+ 'use strict';
+
+ var backpost = undefined;
+ var backpost_link = document.getElementById('backpost-display-link');
+
+ backpost_link.onclick = function(e)
+ {
+ if (!backpost) backpost = document.getElementsByClassName('backpost')[0];
+ var display = backpost.currentStyle ? backpost.currentStyle.display : getComputedStyle(backpost, null).display;
+
+ if (display == 'none')
+ {
+ backpost.style.display = 'block';
+ backpost_link.innerHTML = 'Masquer le message précédent';
+ }
+ else
+ {
+ backpost.style.display = 'none';
+ backpost_link.innerHTML = 'Afficher le message précédent';
+ }
+ return false;
+ };
+</script>
+<?php endif; ?>
+
<?php
// ------ DISPLAYED RANKS ON THE FORUMS - CONFIG
@@ -240,13 +288,12 @@ $zcraft_ranks_excluded = array('Admin1');
<?php
// ------ END RANKS CONFIG
-
require PUN_ROOT.'include/parser.php';
$post_count = 0; // Keep track of post numbers
// Retrieve a list of post IDs, LIMIT is (really) expensive so we only fetch the IDs here then later fetch the remaining data
-$result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$id.' ORDER BY id LIMIT '.$start_from.','.$pun_user['disp_posts']) or error('Unable to fetch post IDs', __FILE__, __LINE__, $db->error());
+$result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$id.' ORDER BY id LIMIT '.$start_from.','.($pun_user['disp_posts'] + ($p > 1 ? 1 : 0))) or error('Unable to fetch post IDs', __FILE__, __LINE__, $db->error());
$post_ids = array();
for ($i = 0;$cur_post_id = $db->result($result, $i);$i++)
@@ -392,7 +439,7 @@ while ($cur_post = $db->fetch_assoc($result))
}
?>
-<div id="p<?php echo $cur_post['id'] ?>" class="blockpost<?php echo ($post_count % 2 == 0) ? ' roweven' : ' rowodd' ?><?php if ($cur_post['id'] == $cur_topic['first_post_id']) echo ' firstpost'; ?><?php if ($post_count == 1) echo ' blockpost1'; ?>">
+<div id="p<?php echo $cur_post['id'] ?>" class="blockpost<?php echo ($post_count % 2 == 0) ? ' roweven' : ' rowodd' ?><?php if ($cur_post['id'] == $cur_topic['first_post_id']) echo ' firstpost'; ?><?php if (($p > 1 && $post_count == 2) || $post_count == 1) echo ' blockpost1'; ?><?php if ($p > 1 && $post_count == 1) echo ' backpost'; ?>">
<h2><span><span class="conr">#<?php echo ($start_from + $post_count) ?></span> <a href="viewtopic.php?pid=<?php echo $cur_post['id'].'#p'.$cur_post['id'] ?>"><?php echo format_time($cur_post['posted']) ?></a></span></h2>
<div class="box">
<div class="inbox">
@@ -439,7 +486,7 @@ while ($cur_post = $db->fetch_assoc($result))
<div class="inbox crumbsplus">
<div class="pagepost">
<p class="pagelink conl"><?php echo $paging_links ?></p>
-<?php echo $post_link ?>
+ <p class="postlink conr"><?php echo $post_link ?></p>
</div>
<ul class="crumbs">
<li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment