Adding the initial templates for the admin section and set up the template system
[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::$preParseHook = 'isso_pre_parse_hook';
32 // BSTemplate::$dbCacheTable = TABLE_PREFIX . 'admintemplate';
33 BSTemplate::$langcall = 'T';
34 BSTemplate::$templatePath = 'templates/%s.tpl';
35
36 // ###################################################################
37
38 function admin_login()
39 {
40 global $admin, $bugsys;
41
42 define('ISSO_PRINTER_NO_NAVIGATION', 1);
43
44 $admin->page_start(T('Login'), null, '', 'document.cplogin.' . (bugdar::$userinfo['email'] ? 'password' : 'email') . '.focus();');
45
46 $admin->form_start('../login.php', 'cplogin', false, 'cplogin');
47 $admin->table_start(true, '425');
48 $admin->table_head(T('Login to Bugdar'));
49 $admin->row_input(T('Email'), 'email', bugdar::$userinfo['email'], 2, 35, false, false, 'middle');
50 $admin->row_input(T('Password'), 'password', '', 2, 35, false, true, 'middle');
51 $admin->row_submit('', T('Login'));
52 $admin->table_end();
53 $admin->form_end();
54
55 $admin->page_end();
56 }
57
58 // ###################################################################
59
60 if (can_perform('canadminpanel'))
61 {
62 $session = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "adminsession WHERE sessionid = '" . $bugsys->input_escape(COOKIE_PREFIX . 'adminsession') . "'");
63 if ($session AND $session['userid'] == bugdar::$userinfo['userid'] AND $session['dateline'] >= (TIMENOW - 3600))
64 {
65 // renew the cookie
66 BSFunctions::cookie(COOKIE_PREFIX . 'adminsession', $session['sessionid'], false);
67 }
68 else
69 {
70 BSFunctions::cookie(COOKIE_PREFIX . 'adminsession', false);
71 admin_login();
72 // do we need this message?
73 $admin->error(T('Invalid admin session has been terminated.'));
74 }
75 }
76 else
77 {
78 BSFunctions::cookie(COOKIE_PREFIX . 'adminsession', false);
79 admin_login();
80 }
81
82 // ###################################################################
83
84 // ###################################################################
85 /**
86 * Callback function for the Pagination->BitProcessor()
87 *
88 * @param string Base link
89 * @param bool Do not show this as a link
90 * @param integer Page number
91 * @param object Page navigator framework
92 *
93 * @return string Processed HTML
94 */
95 function AdminPageNavigatorBitCallback($baselink, $nolink, $number, $paginator)
96 {
97 if ($nolink)
98 {
99 return '<strong>' . $number . '</strong>' . "\n";
100 }
101 else
102 {
103 return '<a href="' . $baselink . 'p=' . $number . '&amp;pp=' . $paginator->getPerPage() . '">' . $number . '</a>' . "\n";
104 }
105 }
106
107 // ###################################################################
108 /**
109 * Callback function for the Pagination->NavigatorProcessor()
110 *
111 * @param string Base URL
112 * @param integer Next page number
113 * @param integer Previous page number
114 * @param array Show information
115 * @param string Individual page bits
116 * @param object Page navigator framework
117 *
118 * @return string Processed HTML
119 */
120 function AdminPageNavigatorCallback($baselink, $nextpage, $prevpage, $show, $pagebits, $paginator)
121 {
122 global $stylevar;
123
124 $return = '';
125
126 if ($show['first'])
127 {
128 $return .= '<a href="' . $baselink . 'p=1&amp;pp=' . $paginator->getPerPage() . '">' . T('First') . '</a> ...';
129 }
130 if ($show['prev'])
131 {
132 $return .= '<a href="' . $baselink . 'p=' . $prevpage . '&amp;pp=' . $paginator->getPerPage() . '">' . T('Prev') . '</a> ...';
133 }
134
135 $return .= $pagebits;
136
137 if ($show['next'])
138 {
139 $return .= '... <a href="' . $baselink . 'p=' . $nextpage . '&amp;pp=' . $paginator->getPerPage() . '">' . T('Next') . '</a>';
140 }
141 if ($show['last'])
142 {
143 $return .= '... <a href="' . $baselink . 'p=' . $paginator->getPageCount() . '&amp;pp=' . $paginator->getPerPage() . '">' . T('Last') . '</a>';
144 }
145 return '<div style="margin-top: 15px; float: ' . $stylevar['right'] . '">' . $return . '</div>';
146 }
147
148 ?>