Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 96 lines (84 sloc) 2.485 kb
0a6d8ae @gecampbell Initial commit of Siteframe Beaumont (Version 5.x)
authored
1 <?php
2 // $Id: folder.php,v 1.28 2006/05/03 01:31:48 glen Exp $
3 // Copyright (c)2005, Glen Campbell. All rights reserved.
4
5 require_once 'siteframe.inc';
6
7 $select = <<<ENDSELECT
8 SELECT page_id
9 FROM %s
10 WHERE page_folder_id=%d
11 AND page_hidden=0
12 ORDER BY %s
13 ENDSELECT;
14
15 // retrieve tag
16 $f = new Folder;
17 $q = sprintf(
18 "SELECT folder_id FROM %s WHERE folder_name='%s'",
19 $f->table_name(),
20 $_GET['tag']
21 );
22
23 $DB = Database::getReader();
24 $result = $DB->query($q);
25 if ($DB->errno)
26 abort(lang('err_db'), $DB->error);
27 list($id) = $result->fetch_row();
28 $f = new Folder($id);
29
30 if (!$f->id())
31 {
32 $_GET['template'] = 'error.php';
33 $_GET['code'] = 404;
34 include('error.php');
35 exit;
36 }
37 else {
38 if (config('allow_folder_theme', TRUE))
39 {
40 $arr = load_template_ini(config('dir_templates').'/'.$f->get('folder_theme'));
41 if (count($arr))
42 $TEMPLATES = $arr;
43 $PAGE->load_new($f->get('folder_theme'));
44 }
45
46 // assign all folder properties to the page
47 $PAGE->assign($f->get_all());
48
49 // get pagination info
50 // select page
51 if (isset($_GET['page']))
52 $page = $_GET['page'];
53 else
54 $page = 1;
55
56 // find the total number of pages
57 $p = new Page;
58 $q = sprintf(
59 "SELECT COUNT(*) FROM %s WHERE page_folder_id=%d",
60 $p->table_name(),
61 $f->id());
62 $result = $DB->query($q);
63 check_db($DB);
64 list($total) = $result->fetch_row();
65
66 // determine start and end
67 if (is_object($_SESSION['user']))
68 $rpp = $_SESSION['user']->get('rows_per_page');
69 if (!$rpp)
70 $rpp = config('rows_per_page');
71 $start = ($page-1)*$rpp;
72
73 // fetch all the pages for the time period selected
74 $items = array();
75 $q = sprintf($select,
76 $p->table_name(),
77 $f->get('folder_id'),
78 $f->get('folder_orderby') ? $f->get('folder_orderby') : 'page_id DESC');
79 $myquery = new Query('Page', $q, $start, $rpp);
80 while($obj = $myquery->get_all())
81 $items[] = $obj;
82 $PAGE->assign('items', $items);
83 $PAGE->assign('page', $page);
84 $PAGE->assign('num_pages', intval($total/$rpp)+(($total%$rpp)?1:0));
85 $PAGE->assign('url', $f->get_url());
86 if (config('url_rewriting'))
87 $PAGE->assign('sep', '?');
88 else
89 $PAGE->assign('sep', '&amp;');
90 }
91
92 $PAGE->assign('item_template', $TEMPLATES['index_item']);
93 $PAGE->assign('page_title', $f->get_title());
94 $PAGE->display($f->get('alt_template'));
95 ?>
Something went wrong with that request. Please try again.