summaryrefslogtreecommitdiff
path: root/books.php
blob: f1bdcb9806b2039ff5fca2272acd0d6f5fbfc14c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
 * Copyright (c) 2004 bitweaver.org
 * Copyright (c) 2003 tikwiki.org
 * Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
 * All Rights Reserved. See below for details and a complete list of authors.
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
 *
 * @package wiki
 * @subpackage functions
 */

/**
 * required setup
 */
require_once( '../kernel/includes/setup_inc.php' );
include_once( WIKI_PKG_CLASS_PATH.'BitBook.php');

// verify stuff
$gBitSystem->verifyPackage( 'wiki' );
$gBitSystem->verifyPermission( 'p_wiki_list_pages' );

$book = new BitBook();

$listHash = array();
$listHash['content_type_guid'] = BITBOOK_CONTENT_TYPE_GUID;
$channels = $book->getList( $listHash );

$cant_pages = ceil($channels["cant"] / $listHash['max_records']);
$gBitSmarty->assignByRef('cant_pages', $cant_pages);
$gBitSmarty->assign('actual_page', 1 + ($listHash['offset'] / $listHash['max_records']));

if ($channels["cant"] > ($listHash['offset'] + $listHash['max_records'])) {
	$gBitSmarty->assign('next_offset', $listHash['offset'] + $listHash['max_records']);
} else {
	$gBitSmarty->assign('next_offset', -1);
}

// If offset is > 0 then prev_offset
if ($listHash['offset'] > 0) {
	$gBitSmarty->assign('prev_offset', $listHash['offset'] - $listHash['max_records']);
} else {
	$gBitSmarty->assign('prev_offset', -1);
}

$gBitSmarty->assignByRef('channels', $channels["data"]);

$gBitSystem->display( 'bitpackage:wiki/list_books.tpl', NULL, array( 'display_mode' => 'display' ));

?>