summaryrefslogtreecommitdiff
path: root/inc/functions.php
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@n0v4.com>2011-02-17 18:37:18 +1100
committerSavetheinternet <savetheinternet@n0v4.com>2011-02-17 18:37:18 +1100
commit48b6a3867e9691b28f5e932c68e198527f403506 (patch)
tree7abb7f193920acd8b203c7b8b8450102136fd4dc /inc/functions.php
parentafcb4703f42792496f4174a69f49d82bb7249582 (diff)
prev/next page buttons
Diffstat (limited to 'inc/functions.php')
-rw-r--r--inc/functions.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/inc/functions.php b/inc/functions.php
index c5b8f9b6..eccdc4ee 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -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)) {