Define and use the footer template
[bugdar.git] / admin / global.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2004-2008 Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 chdir('./../');
23
24 require_once('./includes/init.php');
25 require_once('./includes/functions.php');
26
27 // ###################################################################
28 // setup admin templates
29
30 require_once ISSO . '/Template.php';
31 // BSTemplate::$dbCacheTable = TABLE_PREFIX . 'admintemplate';
32 BSTemplate::$templatePath = 'admin/templates/%s.html';
33 BSTemplate::$globalVars = array(
34 'templates' => array(
35 'doctype' => BSTemplate::fetch('doctype')->evaluate()->getTemplate(),
36 'nav' => BSTemplate::fetch('nav')->evaluate()->getTemplate(),
37 'headinclude' => BSTemplate::fetch('headinclude')->evaluate()->getTemplate(),
38 'title' => T('Bugdar Administration'),
39 'footer' => BSTemplate::fetch('footer')->evaluate()->getTemplate()
40 )
41 );
42
43 // ###################################################################
44
45 function admin_login()
46 {
47 BSTemplate::fetch('login')->evaluate()->flush();
48 exit;
49 }
50
51 // ###################################################################
52
53 if (can_perform('canadminpanel'))
54 {
55 $session = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "adminsession WHERE sessionid = '" . $input->inputEscape(COOKIE_PREFIX . 'adminsession') . "'");
56 if ($session AND $session['userid'] == bugdar::$userinfo['userid'] AND $session['dateline'] >= (TIMENOW - 3600))
57 {
58 // renew the cookie
59 BSFunctions::cookie(COOKIE_PREFIX . 'adminsession', $session['sessionid'], false);
60 }
61 else
62 {
63 BSFunctions::cookie(COOKIE_PREFIX . 'adminsession', false);
64 admin_login();
65 }
66 }
67 else
68 {
69 BSFunctions::cookie(COOKIE_PREFIX . 'adminsession', false);
70 admin_login();
71 }
72
73 // ###################################################################
74
75 // ###################################################################
76 /**
77 * Callback function for the Pagination->BitProcessor()
78 *
79 * @param string Base link
80 * @param bool Do not show this as a link
81 * @param integer Page number
82 * @param object Page navigator framework
83 *
84 * @return string Processed HTML
85 */
86 function AdminPageNavigatorBitCallback($baselink, $nolink, $number, $paginator)
87 {
88 if ($nolink)
89 {
90 return '<strong>' . $number . '</strong>' . "\n";
91 }
92 else
93 {
94 return '<a href="' . $baselink . 'p=' . $number . '&amp;pp=' . $paginator->getPerPage() . '">' . $number . '</a>' . "\n";
95 }
96 }
97
98 // ###################################################################
99 /**
100 * Callback function for the Pagination->NavigatorProcessor()
101 *
102 * @param string Base URL
103 * @param integer Next page number
104 * @param integer Previous page number
105 * @param array Show information
106 * @param string Individual page bits
107 * @param object Page navigator framework
108 *
109 * @return string Processed HTML
110 */
111 function AdminPageNavigatorCallback($baselink, $nextpage, $prevpage, $show, $pagebits, $paginator)
112 {
113 global $stylevar;
114
115 $return = '';
116
117 if ($show['first'])
118 {
119 $return .= '<a href="' . $baselink . 'p=1&amp;pp=' . $paginator->getPerPage() . '">' . T('First') . '</a> ...';
120 }
121 if ($show['prev'])
122 {
123 $return .= '<a href="' . $baselink . 'p=' . $prevpage . '&amp;pp=' . $paginator->getPerPage() . '">' . T('Prev') . '</a> ...';
124 }
125
126 $return .= $pagebits;
127
128 if ($show['next'])
129 {
130 $return .= '... <a href="' . $baselink . 'p=' . $nextpage . '&amp;pp=' . $paginator->getPerPage() . '">' . T('Next') . '</a>';
131 }
132 if ($show['last'])
133 {
134 $return .= '... <a href="' . $baselink . 'p=' . $paginator->getPageCount() . '&amp;pp=' . $paginator->getPerPage() . '">' . T('Last') . '</a>';
135 }
136 return '<div style="margin-top: 15px; float: ' . $stylevar['right'] . '">' . $return . '</div>';
137 }
138
139 ?>