prev/next page buttons

This commit is contained in:
Savetheinternet 2011-02-17 18:37:18 +11:00
parent afcb4703f4
commit 48b6a3867e
3 changed files with 40 additions and 2 deletions

View File

@ -469,6 +469,42 @@
return Array('button'=>$config['button_newtopic'], 'board'=>$board, 'body'=>$body, 'post_url' => $config['post_url'], 'index' => $config['root']);
}
function getPageButtons($pages, $mod=false) {
global $config, $board;
$btn = Array();
$root = ($mod ? '?/' : $config['root']) . $board['dir'];
foreach($pages as $num => $page) {
if(isset($page['selected'])) {
// Previous button
if($num == 0) {
// There is no previous page.
$btn['prev'] = 'Previous';
} else {
$btn['prev'] = '<form action="' . $root .
($num == 1 ?
$config['file_index']
:
sprintf($config['file_page'], $num)
) .
'" method="' . ($mod ? 'post' : 'get') . '"><input type="submit" value="Previous" /></form>';
}
if($num == count($pages) - 1) {
// There is no next page.
$btn['next'] = 'Next';
} else {
$btn['next'] = '<form action="' . $root .
sprintf($config['file_page'], $num + 2) .
'" method="' . ($mod ? 'post' : 'get') . '"><input type="submit" value="Next" /></form>';
}
}
}
return $btn;
}
function getPages($mod=false) {
global $board, $config;
@ -601,6 +637,7 @@
$content['pages'] = $pages;
$content['pages'][$page-1]['selected'] = true;
$content['btn'] = getPageButtons($content['pages']);
@file_put_contents($filename, Element('index.html', $content)) or error("Couldn't write to file.");
if(isset($md5) && $md5 == md5_file($filename)) {

View File

@ -326,6 +326,7 @@
$page['pages'] = getPages(true);
$page['pages'][$page_no-1]['selected'] = true;
$page['btn'] = getPageButtons($page['pages'], true);
$page['mod'] = true;
echo Element('index.html', $page);

View File

@ -102,9 +102,9 @@
<input type="submit" value="Delete" />
</div>
</form>
<div class="pages">Pages: {pages:
<div class="pages">{btn[prev]} {pages:
[<a {pages[selected]?class="selected"}{!pages[selected]?href="{pages[link]}"}>{pages[num]}</a>]{!%last? }
}</div>
} {btn[next]}</div>
<p class="unimportant" style="margin-top:20px;text-align:center;">Tinyboard Software Copyright &copy; 2010-2011 <a href="http://omegasdg.com/">OmegaSDG</a></p>
</body>
</html>