Better looking page number list
This commit is contained in:
parent
3b3e696427
commit
1063372de1
@ -73,6 +73,7 @@
|
|||||||
$config['threads_per_page'] = 10;
|
$config['threads_per_page'] = 10;
|
||||||
$config['max_pages'] = 10;
|
$config['max_pages'] = 10;
|
||||||
$config['threads_preview'] = 5;
|
$config['threads_preview'] = 5;
|
||||||
|
$config['threads_preview_sticky'] = 1;
|
||||||
|
|
||||||
// For development purposes. Turns 'display_errors' on. Not recommended for production.
|
// For development purposes. Turns 'display_errors' on. Not recommended for production.
|
||||||
$config['verbose_errors'] = true;
|
$config['verbose_errors'] = true;
|
||||||
|
@ -437,16 +437,16 @@
|
|||||||
|
|
||||||
$posts = prepare(sprintf("SELECT `id`, `subject`, `email`, `name`, `trip`, `body`, `time`, `thumb`, `thumbwidth`, `thumbheight`, `file`, `filewidth`, `fileheight`, `filesize`, `filename`,`ip` FROM `posts_%s` WHERE `thread` = ? ORDER BY `id` DESC LIMIT ?", $board['uri']));
|
$posts = prepare(sprintf("SELECT `id`, `subject`, `email`, `name`, `trip`, `body`, `time`, `thumb`, `thumbwidth`, `thumbheight`, `file`, `filewidth`, `fileheight`, `filesize`, `filename`,`ip` FROM `posts_%s` WHERE `thread` = ? ORDER BY `id` DESC LIMIT ?", $board['uri']));
|
||||||
$posts->bindValue(1, $th['id']);
|
$posts->bindValue(1, $th['id']);
|
||||||
$posts->bindValue(2, $config['threads_preview'], PDO::PARAM_INT);
|
$posts->bindValue(2, ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview']), PDO::PARAM_INT);
|
||||||
$posts->execute() or error(db_error($posts));
|
$posts->execute() or error(db_error($posts));
|
||||||
|
|
||||||
if($posts->rowCount() == $config['threads_preview']) {
|
if($posts->rowCount() == ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'])) {
|
||||||
$count = prepare(sprintf("SELECT COUNT(`id`) as `num` FROM `posts_%s` WHERE `thread` = ?", $board['uri']));
|
$count = prepare(sprintf("SELECT COUNT(`id`) as `num` FROM `posts_%s` WHERE `thread` = ?", $board['uri']));
|
||||||
$count->bindValue(1, $th['id']);
|
$count->bindValue(1, $th['id']);
|
||||||
$count->execute() or error(db_error($count));
|
$count->execute() or error(db_error($count));
|
||||||
|
|
||||||
$count = $count->fetch();
|
$count = $count->fetch();
|
||||||
$omitted = $count['num'] - $config['threads_preview'];
|
$omitted = $count['num'] - ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview']);
|
||||||
$thread->omitted = $omitted;
|
$thread->omitted = $omitted;
|
||||||
unset($count);
|
unset($count);
|
||||||
unset($omitted);
|
unset($omitted);
|
||||||
@ -474,7 +474,10 @@
|
|||||||
|
|
||||||
$pages = Array();
|
$pages = Array();
|
||||||
for($x=0;$x<$count && $x<$config['max_pages'];$x++) {
|
for($x=0;$x<$count && $x<$config['max_pages'];$x++) {
|
||||||
$pages[] = Array('num' => $x+1, 'link' => $x==0 ? ($mod ? '?/' : $config['root']) . $board['dir'] . $config['file_index'] : ($mod ? '?/' : $config['root']) . $board['dir'] . sprintf($config['file_page'], $x+1));
|
$pages[] = Array(
|
||||||
|
'num' => $x+1,
|
||||||
|
'link' => $x==0 ? ($mod ? '?/' : $config['root']) . $board['dir'] . $config['file_index'] : ($mod ? '?/' : $config['root']) . $board['dir'] . sprintf($config['file_page'], $x+1)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $pages;
|
return $pages;
|
||||||
@ -589,6 +592,7 @@
|
|||||||
if(file_exists($filename)) $md5 = md5_file($filename);
|
if(file_exists($filename)) $md5 = md5_file($filename);
|
||||||
|
|
||||||
$content['pages'] = $pages;
|
$content['pages'] = $pages;
|
||||||
|
$content['pages'][$page-1]['selected'] = true;
|
||||||
@file_put_contents($filename, Element('index.html', $content)) or error("Couldn't write to file.");
|
@file_put_contents($filename, Element('index.html', $content)) or error("Couldn't write to file.");
|
||||||
|
|
||||||
if(isset($md5) && $md5 == md5_file($filename)) {
|
if(isset($md5) && $md5 == md5_file($filename)) {
|
||||||
|
6
mod.php
6
mod.php
@ -318,10 +318,14 @@
|
|||||||
if(!openBoard($boardName))
|
if(!openBoard($boardName))
|
||||||
error($config['error']['noboard']);
|
error($config['error']['noboard']);
|
||||||
|
|
||||||
if(!$page = index(empty($matches[2]) || $matches[2] == $config['file_index'] ? 1 : $matches[2], $mod)) {
|
$page_no = empty($matches[2]) || $matches[2] == $config['file_index'] ? 1 : $matches[2];
|
||||||
|
|
||||||
|
if(!$page = index($page_no, $mod)) {
|
||||||
error($config['error']['404']);
|
error($config['error']['404']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$page['pages'] = getPages(true);
|
$page['pages'] = getPages(true);
|
||||||
|
$page['pages'][$page_no-1]['selected'] = true;
|
||||||
$page['mod'] = true;
|
$page['mod'] = true;
|
||||||
|
|
||||||
echo Element('index.html', $page);
|
echo Element('index.html', $page);
|
||||||
|
15
style.css
15
style.css
@ -270,4 +270,19 @@ table.test td img {
|
|||||||
}
|
}
|
||||||
fieldset label {
|
fieldset label {
|
||||||
display: block;
|
display: block;
|
||||||
|
}
|
||||||
|
div.pages {
|
||||||
|
color: #89A;
|
||||||
|
background: #D6DAF0;
|
||||||
|
display: inline;
|
||||||
|
padding: 8px;
|
||||||
|
border-right: 1px solid #B7C5D9;
|
||||||
|
border-bottom: 1px solid #B7C5D9;
|
||||||
|
}
|
||||||
|
div.pages a.selected {
|
||||||
|
color: black;
|
||||||
|
font-weight: bolder;
|
||||||
|
}
|
||||||
|
div.pages a:link {
|
||||||
|
text-decoration: none;
|
||||||
}
|
}
|
@ -102,9 +102,9 @@
|
|||||||
<input type="submit" value="Delete" />
|
<input type="submit" value="Delete" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
Pages: {pages:
|
<div class="pages">Pages: {pages:
|
||||||
[<a href="{pages[link]}">{pages[num]}</a>]{!%last? }
|
[<a {pages[selected]?class="selected"}{!pages[selected]?href="{pages[link]}"}>{pages[num]}</a>]{!%last? }
|
||||||
}
|
}</div>
|
||||||
<p class="unimportant" style="text-align:center;">Tinyboard Software Copyright © 2010-2011 <a href="http://omegasdg.com/">OmegaSDG</a></p>
|
<p class="unimportant" style="margin-top:20px;text-align:center;">Tinyboard Software Copyright © 2010-2011 <a href="http://omegasdg.com/">OmegaSDG</a></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -37,4 +37,11 @@ div.ban {
|
|||||||
}
|
}
|
||||||
div.ban p {
|
div.ban p {
|
||||||
color: black;
|
color: black;
|
||||||
|
}
|
||||||
|
div.pages {
|
||||||
|
background: #F0E0D6;
|
||||||
|
border-color: #D9BFB7;
|
||||||
|
}
|
||||||
|
div.pages a.selected {
|
||||||
|
color: #800;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user