Revision 1086
Added by Matthias over 16 years ago
| class.admin.php | ||
|---|---|---|
| 201 | 201 |
$footer_template->set_file('page', 'footer.htt');
|
| 202 | 202 |
$footer_template->set_block('page', 'footer_block', 'header');
|
| 203 | 203 |
$footer_template->set_var(array( |
| 204 |
'BACKEND_MODULE_JS' => $this->register_backend_modfiles('js'),
|
|
| 204 |
'BACKEND_BODY_MODULE_JS' => $this->register_backend_modfiles_body('js'),
|
|
| 205 | 205 |
'WB_URL' => WB_URL, |
| 206 | 206 |
'WB_PATH' => WB_PATH, |
| 207 | 207 |
'ADMIN_URL' => ADMIN_URL, |
| ... | ... | |
| 323 | 323 |
} |
| 324 | 324 |
} |
| 325 | 325 |
|
| 326 |
// Function to add optional module Javascript or CSS stylesheets into the <body> section of the backend |
|
| 327 |
function register_backend_modfiles_body($file_id="js") |
|
| 328 |
{
|
|
| 329 |
// sanity check of parameter passed to the function |
|
| 330 |
$file_id = strtolower($file_id); |
|
| 331 |
if($file_id !== "javascript" && $file_id !== "js") |
|
| 332 |
{
|
|
| 333 |
return; |
|
| 334 |
} |
|
| 335 |
global $database; |
|
| 336 |
$body_links = ""; |
|
| 337 |
// define default baselink and filename for optional module javascript and stylesheet files |
|
| 338 |
if($file_id == "js") {
|
|
| 339 |
$base_link = '<script type="text/javascript" src="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend_body.js"></script>';
|
|
| 340 |
$base_file = "backend_body.js"; |
|
| 341 |
} |
|
| 342 |
// check if backend_body.js files needs to be included to the <body></body> section of the backend |
|
| 343 |
if(isset($_GET['tool'])) |
|
| 344 |
{
|
|
| 345 |
// check if displayed page contains a installed admin tool |
|
| 346 |
$result = $database->query("SELECT * FROM " .TABLE_PREFIX ."addons
|
|
| 347 |
WHERE type = 'module' AND function = 'tool' AND directory = '".addslashes($_GET['tool'])."'"); |
|
| 348 |
if($result->numRows()) |
|
| 349 |
{
|
|
| 350 |
// check if admin tool directory contains a backend_body.js file to include |
|
| 351 |
$tool = $result->fetchRow(); |
|
| 352 |
if(file_exists(WB_PATH ."/modules/" .$tool['directory'] ."/$base_file")) |
|
| 353 |
{
|
|
| 354 |
// return link to the backend_body.js file |
|
| 355 |
return str_replace("{MODULE_DIRECTORY}", $tool['directory'], $base_link);
|
|
| 356 |
} |
|
| 357 |
} |
|
| 358 |
} elseif(isset($_GET['page_id']) or isset($_POST['page_id'])) |
|
| 359 |
{
|
|
| 360 |
// check if displayed page in the backend contains a page module |
|
| 361 |
if (isset($_GET['page_id'])) |
|
| 362 |
{
|
|
| 363 |
$page_id = (int) addslashes($_GET['page_id']); |
|
| 364 |
} else {
|
|
| 365 |
$page_id = (int) addslashes($_POST['page_id']); |
|
| 366 |
} |
|
| 367 |
// gather information for all models embedded on actual page |
|
| 368 |
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections
|
|
| 369 |
WHERE page_id=$page_id"); |
|
| 370 |
while($row = $query_modules->fetchRow()) {
|
|
| 371 |
// check if page module directory contains a backend_body.js file |
|
| 372 |
if(file_exists(WB_PATH ."/modules/" .$row['module'] ."/$base_file")) {
|
|
| 373 |
// create link with backend_body.js source for the current module |
|
| 374 |
$tmp_link = str_replace("{MODULE_DIRECTORY}", $row['module'], $base_link);
|
|
| 375 |
// ensure that backend_body.js is only added once per module type |
|
| 376 |
if(strpos($body_links, $tmp_link) === false) {
|
|
| 377 |
$body_links .= $tmp_link ."\n"; |
|
| 378 |
} |
|
| 379 |
} |
|
| 380 |
} |
|
| 381 |
// write out links with all external module javascript/CSS files, remove last line feed |
|
| 382 |
return rtrim($body_links); |
|
| 383 |
} |
|
| 384 |
} |
|
| 385 |
|
|
| 386 |
|
|
| 326 | 387 |
// Function to add optional module Javascript or CSS stylesheets into the <head> section of the backend |
| 327 | 388 |
function register_backend_modfiles($file_id="css") {
|
| 328 | 389 |
// sanity check of parameter passed to the function |
| 329 | 390 |
$file_id = strtolower($file_id); |
| 330 |
if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js") {
|
|
| 391 |
if($file_id !== "css" && $file_id !== "javascript" && $file_id !== "js") {
|
|
| 331 | 392 |
return; |
| 332 | 393 |
} |
| 333 | 394 |
|
| ... | ... | |
| 335 | 396 |
// define default baselink and filename for optional module javascript and stylesheet files |
| 336 | 397 |
$head_links = ""; |
| 337 | 398 |
if($file_id == "css") {
|
| 338 |
$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend.css"';
|
|
| 399 |
$base_link = '<link href="'.WB_URL.'/modules/{MODULE_DIRECTORY}/backend.css"';
|
|
| 339 | 400 |
$base_link.= ' rel="stylesheet" type="text/css" media="screen" />'; |
| 340 | 401 |
$base_file = "backend.css"; |
| 341 | 402 |
} else {
|
| ... | ... | |
| 346 | 407 |
// check if backend.js or backend.css files needs to be included to the <head></head> section of the backend |
| 347 | 408 |
if(isset($_GET['tool'])) {
|
| 348 | 409 |
// check if displayed page contains a installed admin tool |
| 349 |
$result = $database->query("SELECT * FROM " .TABLE_PREFIX ."addons
|
|
| 410 |
$result = $database->query("SELECT * FROM " .TABLE_PREFIX ."addons
|
|
| 350 | 411 |
WHERE type = 'module' AND function = 'tool' AND directory = '".addslashes($_GET['tool'])."'"); |
| 351 | 412 |
|
| 352 | 413 |
if($result->numRows()) {
|
| ... | ... | |
| 366 | 427 |
} |
| 367 | 428 |
|
| 368 | 429 |
// gather information for all models embedded on actual page |
| 369 |
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections
|
|
| 430 |
$query_modules = $database->query("SELECT module FROM " .TABLE_PREFIX ."sections
|
|
| 370 | 431 |
WHERE page_id=$page_id"); |
| 371 | 432 |
|
| 372 | 433 |
while($row = $query_modules->fetchRow()) {
|
Also available in: Unified diff
Moved backend.js back from <body> to <head>
Added possibility to add a backend_body.js to modules wich is then called in <body>