2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)2004-2009 Blue Static
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.
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
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 \*=====================================================================*/
23 * Fetches, evaluates, and returns the footer template
25 * @return string Footer template code
27 function admin_footer()
29 return BSTemplate
::fetch('footer')->evaluate()->getTemplate();
33 * Displays the login screen and ends execution of the script
35 function admin_login()
37 BSTemplate
::fetch('login')->evaluate()->flush();
42 * Callback function for the Pagination->BitProcessor()
44 * @param string Base link
45 * @param bool Do not show this as a link
46 * @param integer Page number
47 * @param object Page navigator framework
49 * @return string Processed HTML
51 function AdminPageNavigatorBitCallback($baselink, $nolink, $number, $paginator)
55 return '<strong>' . $number . '</strong>' . "\n";
59 return '<a href="' . $baselink . 'p=' . $number . '&pp=' . $paginator->getPerPage() . '">' . $number . '</a>' . "\n";
64 * Callback function for the Pagination->NavigatorProcessor()
66 * @param string Base URL
67 * @param integer Next page number
68 * @param integer Previous page number
69 * @param array Show information
70 * @param string Individual page bits
71 * @param object Page navigator framework
73 * @return string Processed HTML
75 function AdminPageNavigatorCallback($baselink, $nextpage, $prevpage, $show, $pagebits, $paginator)
83 $return .= '<a href="' . $baselink . 'p=1&pp=' . $paginator->getPerPage() . '">' . T('First') . '</a> ...';
87 $return .= '<a href="' . $baselink . 'p=' . $prevpage . '&pp=' . $paginator->getPerPage() . '">' . T('Prev') . '</a> ...';
94 $return .= '... <a href="' . $baselink . 'p=' . $nextpage . '&pp=' . $paginator->getPerPage() . '">' . T('Next') . '</a>';
98 $return .= '... <a href="' . $baselink . 'p=' . $paginator->getPageCount() . '&pp=' . $paginator->getPerPage() . '">' . T('Last') . '</a>';
100 return '<div style="margin-top: 15px; float: ' . $stylevar['right'] . '">' . $return . '</div>';
104 * Redirects the user to a given page and stores the flash message for later display
106 * @param string URL to redireect to
107 * @param string Flash message
108 * @param bool Whether or not this is an error
110 function admin_flash_redirect($url, $message = '', $error = false)
112 $sessionID = BSApp
::$input->inputEscape(COOKIE_PREFIX
. 'adminsession');
120 $msg = '<div class="' . ($error ? 'error' : 'message') . '-box">' . $message . '</div>';
121 BSApp
::$db->query("UPDATE " . TABLE_PREFIX
. "adminsession SET flashmessage = '" . BSApp
::$db->escapeString($msg) . "' WHERE sessionid = '$sessionID'");
124 header("Location
: $url");
128 * Returns the admin flash message and then proceeds o clear it
132 function admin_flash()
134 $sessionID = BSApp
::$input->inputEscape(COOKIE_PREFIX
. 'adminsession');
140 $msg = BSApp
::$db->queryFirst("SELECT flashmessage FROM " . TABLE_PREFIX
. "adminsession WHERE sessionid = '$sessionID'");
141 if (!$msg['flashmessage'])
146 BSApp::$db->query("UPDATE
" . TABLE_PREFIX . "adminsession SET flashmessage
= '' WHERE sessionid
= '$sessionID'");
147 return $msg['flashmessage
'];