Revision 1684
Added by Luisehahne over 13 years ago
| class.admin.php | ||
|---|---|---|
| 4 | 4 |
* @category framewotk |
| 5 | 5 |
* @package backend admin |
| 6 | 6 |
* @author Ryan Djurovich, WebsiteBaker Project |
| 7 |
* @copyright 2009-2011, Website Baker Org. e.V.
|
|
| 7 |
* @copyright 2009-2012, Website Baker Org. e.V.
|
|
| 8 | 8 |
* @link http://www.websitebaker2.org/ |
| 9 | 9 |
* @license http://www.gnu.org/licenses/gpl.html |
| 10 | 10 |
* @platform WebsiteBaker 2.8.x |
| ... | ... | |
| 31 | 31 |
//require_once(WB_PATH . '/framework/SecureForm.php'); |
| 32 | 32 |
|
| 33 | 33 |
|
| 34 |
/** |
|
| 35 |
* admin |
|
| 36 |
* |
|
| 37 |
* @package |
|
| 38 |
* @copyright |
|
| 39 |
* @version 2012 |
|
| 40 |
* @access public |
|
| 41 |
*/ |
|
| 34 | 42 |
class admin extends wb {
|
| 35 | 43 |
// Authenticate user then auto print the header |
| 44 |
/** |
|
| 45 |
* admin::__construct() |
|
| 46 |
* |
|
| 47 |
* @param string $section_name |
|
| 48 |
* @param string $section_permission |
|
| 49 |
* @param bool $auto_header |
|
| 50 |
* @param bool $auto_auth |
|
| 51 |
* @return void |
|
| 52 |
*/ |
|
| 36 | 53 |
public function __construct($section_name= '##skip##', $section_permission = 'start', $auto_header = true, $auto_auth = true) |
| 37 | 54 |
{
|
| 38 | 55 |
parent::__construct(SecureForm::BACKEND); |
| ... | ... | |
| 88 | 105 |
} |
| 89 | 106 |
|
| 90 | 107 |
// Print the admin header |
| 91 |
function print_header($body_tags = '') {
|
|
| 108 |
/** |
|
| 109 |
* admin::print_header() |
|
| 110 |
* |
|
| 111 |
* @param string $body_tags |
|
| 112 |
* @return void |
|
| 113 |
*/ |
|
| 114 |
function print_header($body_tags = '') |
|
| 115 |
{
|
|
| 92 | 116 |
// Get vars from the language file |
| 93 | 117 |
global $MENU, $MESSAGE, $TEXT; |
| 94 | 118 |
// Connect to database and get website title |
| ... | ... | |
| 99 | 123 |
$get_title = $database->query($sql); |
| 100 | 124 |
$title = $get_title->fetchRow(); |
| 101 | 125 |
// Setup template object, parse vars to it, then parse it |
| 102 |
$header_template = new Template(dirname($this->correct_theme_source('header.htt')),'keep');
|
|
| 126 |
$header_template = new Template(dirname($this->correct_theme_source('header.htt')) );
|
|
| 103 | 127 |
$header_template->set_file('page', 'header.htt');
|
| 104 | 128 |
$header_template->set_block('page', 'header_block', 'header');
|
| 105 | 129 |
if(defined('DEFAULT_CHARSET')) {
|
| ... | ... | |
| 121 | 145 |
} |
| 122 | 146 |
|
| 123 | 147 |
$header_template->set_var( array( |
| 124 |
'SECTION_NAME' => $MENU[strtoupper($this->section_name)], |
|
| 148 |
'SECTION_FORGOT' => $MENU['FORGOT'], |
|
| 149 |
'SECTION_NAME' => $MENU['LOGIN'], |
|
| 125 | 150 |
'BODY_TAGS' => $body_tags, |
| 126 | 151 |
'WEBSITE_TITLE' => ($title['value']), |
| 127 | 152 |
'TEXT_ADMINISTRATION' => $TEXT['ADMINISTRATION'], |
| ... | ... | |
| 136 | 161 |
'WB_URL' => WB_URL, |
| 137 | 162 |
'ADMIN_URL' => ADMIN_URL, |
| 138 | 163 |
'THEME_URL' => THEME_URL, |
| 139 |
'TITLE_START' => $MENU['START'], |
|
| 140 |
'TITLE_VIEW' => $MENU['VIEW'], |
|
| 164 |
'START_URL' => ADMIN_URL.'/index.php', |
|
| 165 |
'START_CLASS' => 'start', |
|
| 166 |
'TITLE_START' => $TEXT['READ_MORE'], |
|
| 167 |
'TITLE_VIEW' => $TEXT['WEBSITE'], |
|
| 141 | 168 |
'TITLE_HELP' => $MENU['HELP'], |
| 142 |
'TITLE_LOGOUT' => $MENU['LOGOUT'], |
|
| 143 | 169 |
'URL_VIEW' => $view_url, |
| 144 |
'URL_HELP' => 'http://www.websitebaker2.org/', |
|
| 170 |
'TITLE_LOGOUT' => $MENU['LOGIN'], |
|
| 171 |
'LOGIN_DISPLAY_NONE' => ' display: none; ', |
|
| 172 |
'LOGIN_LINK' => $_SERVER['SCRIPT_NAME'], |
|
| 173 |
'LOGIN_ICON' => 'login', |
|
| 174 |
'START_ICON' => 'blank', |
|
| 175 |
'URL_HELP' => 'http://www.websitebaker.org/', |
|
| 145 | 176 |
'BACKEND_MODULE_CSS' => $this->register_backend_modfiles('css'), // adds backend.css
|
| 146 | 177 |
'BACKEND_MODULE_JS' => $this->register_backend_modfiles('js') // adds backend.js
|
| 147 | 178 |
) |
| 148 | 179 |
); |
| 149 | 180 |
|
| 150 | 181 |
// Create the menu |
| 182 |
if(!$this->is_authenticated()) |
|
| 183 |
{
|
|
| 151 | 184 |
$menu = array( |
| 185 |
// array('http://www.websitebaker.org/', '_blank', 'WebsiteBaker Home', 'help', 0),
|
|
| 186 |
// array($view_url, '_blank', $TEXT['FRONTEND'], '', 0), |
|
| 187 |
// array(ADMIN_URL.'/login/index.php', '', $MENU['LOGIN'], '', 0) |
|
| 188 |
); |
|
| 189 |
} else {
|
|
| 190 |
$header_template->set_var( array( |
|
| 191 |
'SECTION_NAME' => $MENU[strtoupper($this->section_name)], |
|
| 192 |
'TITLE_LOGOUT' => $MENU['LOGOUT'], |
|
| 193 |
'LOGIN_DISPLAY_NONE' => '', |
|
| 194 |
'START_ICON' => 'home', |
|
| 195 |
'LOGIN_ICON' => 'logout', |
|
| 196 |
'LOGIN_LINK' => ADMIN_URL.'/logout/index.php', |
|
| 197 |
'TITLE_START' => $MENU['START'] |
|
| 198 |
) |
|
| 199 |
); |
|
| 200 |
// @array ( $url, $target, $title, $page_permission, $ppermission_required ) |
|
| 201 |
$menu = array( |
|
| 202 |
// array(ADMIN_URL.'/index.php', '', $MENU['START'], 'start', 1 ), |
|
| 152 | 203 |
array(ADMIN_URL.'/pages/index.php', '', $MENU['PAGES'], 'pages', 1), |
| 204 |
// array($view_url, '_blank', $MENU['FRONTEND'], 'pages', 1), |
|
| 153 | 205 |
array(ADMIN_URL.'/media/index.php', '', $MENU['MEDIA'], 'media', 1), |
| 154 | 206 |
array(ADMIN_URL.'/addons/index.php', '', $MENU['ADDONS'], 'addons', 1), |
| 155 | 207 |
array(ADMIN_URL.'/preferences/index.php', '', $MENU['PREFERENCES'], 'preferences', 0), |
| 156 | 208 |
array(ADMIN_URL.'/settings/index.php', '', $MENU['SETTINGS'], 'settings', 1), |
| 157 | 209 |
array(ADMIN_URL.'/admintools/index.php', '', $MENU['ADMINTOOLS'], 'admintools', 1), |
| 158 |
array(ADMIN_URL.'/access/index.php', '', $MENU['ACCESS'], 'access', 1) |
|
| 210 |
array(ADMIN_URL.'/access/index.php', '', $MENU['ACCESS'], 'access', 1), |
|
| 211 |
// array('http://www.websitebaker.org/', '_blank', 'WebsiteBaker Home', '', 0),
|
|
| 212 |
// array(ADMIN_URL.'/logout/index.php', '', $MENU['LOGOUT'], '', 0) |
|
| 213 |
|
|
| 159 | 214 |
); |
| 215 |
} |
|
| 216 |
|
|
| 160 | 217 |
$header_template->set_block('header_block', 'linkBlock', 'link');
|
| 161 | 218 |
foreach($menu AS $menu_item) {
|
| 162 | 219 |
$link = $menu_item[0]; |
| ... | ... | |
| 165 | 222 |
$permission_title = $menu_item[3]; |
| 166 | 223 |
$required = $menu_item[4]; |
| 167 | 224 |
$replace_old = array(ADMIN_URL, WB_URL, '/', 'index.php'); |
| 168 |
if($required == false OR $this->get_link_permission($permission_title)) {
|
|
| 225 |
if($required == false || ($this->is_authenticated() && $this->get_link_permission($permission_title)) ) |
|
| 226 |
{
|
|
| 169 | 227 |
$header_template->set_var('LINK', $link);
|
| 170 | 228 |
$header_template->set_var('TARGET', $target);
|
| 171 | 229 |
// If link is the current section apply a class name |
| ... | ... | |
| 182 | 240 |
$header_template->parse('header', 'header_block', false);
|
| 183 | 241 |
$header_template->pparse('output', 'page');
|
| 184 | 242 |
} |
| 185 |
|
|
| 243 |
|
|
| 186 | 244 |
// Print the admin footer |
| 187 | 245 |
function print_footer($activateJsAdmin = false) {
|
| 188 |
global $database; |
|
| 246 |
global $database,$starttime;
|
|
| 189 | 247 |
// include the required file for Javascript admin |
| 190 | 248 |
if($activateJsAdmin != false) {
|
| 191 | 249 |
if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php')){
|
| ... | ... | |
| 211 | 269 |
// if( $debug && (1 == $this->get_user_id())) |
| 212 | 270 |
if( $bDevInfo ) |
| 213 | 271 |
{
|
| 272 |
|
|
| 214 | 273 |
$footer_template->set_var('MEMORY', number_format(memory_get_peak_usage(), 0, ',', '.').' Byte' );
|
| 215 | 274 |
$footer_template->set_var('QUERIES', $database->getQueryCount );
|
| 216 | 275 |
// $footer_template->set_var('QUERIES', 'disabled' );
|
| ... | ... | |
| 220 | 279 |
$sum_filesize = 0; |
| 221 | 280 |
$footer_template->set_block('show_debug_block', 'show_block_list', 'show_list');
|
| 222 | 281 |
$footer_template->set_block('show_block_list', 'include_block_list', 'include_list');
|
| 223 |
// $debug = true;
|
|
| 282 |
// $bDebug = true; for testing
|
|
| 224 | 283 |
foreach($included_files as $filename) |
| 225 | 284 |
{
|
| 226 | 285 |
if(!is_readable($filename)) { continue; }
|
| ... | ... | |
| 234 | 293 |
} |
| 235 | 294 |
$footer_template->parse('show_list', 'show_block_list', true);
|
| 236 | 295 |
|
| 296 |
$endtime = array_sum(explode(" ",microtime()));
|
|
| 297 |
$iEndTime = $endtime; |
|
| 298 |
$iStartTime = $starttime; |
|
| 237 | 299 |
if(!$bDebug) |
| 238 | 300 |
{
|
| 301 |
$footer_template->parse('show_list', '');
|
|
| 239 | 302 |
$footer_template->parse('include_list', '');
|
| 240 |
$footer_template->parse('show_list', '');
|
|
| 241 | 303 |
} |
| 242 | 304 |
|
| 243 | 305 |
$footer_template->set_var('FILESIZE', ini_get('memory_limit'));
|
| 244 | 306 |
$footer_template->set_var('TXT_SUM_FILESIZE', 'Summary size of included files: ');
|
| 245 | 307 |
$footer_template->set_var('SUM_FILESIZE', number_format($sum_filesize, 0, ',', '.').' Byte');
|
| 308 |
$footer_template->set_var('PAGE_LOAD_TIME', round($iEndTime-$iStartTime,3 ));
|
|
| 309 |
|
|
| 246 | 310 |
$footer_template->parse('show_debug', 'show_debug_block', true);
|
| 247 | 311 |
} else {
|
| 248 | 312 |
$footer_template->parse('show_debug', '');
|
| 313 |
$footer_template->parse('show_list', '');
|
|
| 314 |
|
|
| 249 | 315 |
} |
| 250 | 316 |
$footer_template->parse('header', 'footer_block', false);
|
| 251 | 317 |
$footer_template->pparse('output', 'page');
|
| 252 | 318 |
} |
| 253 |
|
|
| 319 |
|
|
| 254 | 320 |
// Return a system permission |
| 255 | 321 |
function get_permission($name, $type = 'system') {
|
| 256 | 322 |
// Append to permission type |
| ... | ... | |
| 509 | 575 |
} |
| 510 | 576 |
} |
| 511 | 577 |
} |
| 512 |
|
|
| 513 |
?> |
|
Also available in: Unified diff
! update upgrade-script, now don't overwrite existings values in settings
+ add field tooltip to table pages in installer
! change some module tool_icon.png (Tks to Stefek)
! add date_time string to backup_droplets.zip
- search and comment out founded require_once(WB_PATH."/framework/class.database.php");
- this will be never needed anymore and produce errors
! rename class.msg_queue.php in msgQueue.php to work with autokoader
+ add function format_message to class.wb.php