Project

General

Profile

« Previous | Next » 

Revision 1086

Added by Matthias almost 15 years ago

Moved backend.js back from <body> to <head>

Added possibility to add a backend_body.js to modules wich is then called in <body>

View differences:

trunk/CHANGELOG
12 12

  
13 13
------------------------------------- 2.8.0 -------------------------------------
14 14
20-July 2009 Matthias Gallas
15
!	Moved backend.js back from <body> to <head>
16
+	Added possibility to add a backend_body.js to modules wich is then called in <body>
15 17
+	Readded admin/images folder to keep backward compatibility to old modules
16 18
19-July 2009 Matthias Gallas
17 19
#	Fixed display issue of jsadmin in backend themes (Thanks to Argos)
trunk/wb/framework/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()) {
trunk/wb/templates/classic_theme/templates/header.htt
10 10
<link href="{THEME_URL}/theme.css" rel="stylesheet" type="text/css" />
11 11
<link href="{WB_URL}/include/jquery/plugins/jquery-ui.css" rel="stylesheet" type="text/css" />
12 12
{BACKEND_MODULE_CSS}
13
{BACKEND_MODULE_JS}
13 14
<script type="text/javascript" src="{WB_URL}/include/editarea/edit_area_full.js"></script>
14 15
<script language="javascript" type="text/javascript">
15 16
function confirm_link(message, url) {
trunk/wb/templates/classic_theme/templates/footer.htt
36 36
          }
37 37

  
38 38
</script>
39
{BACKEND_MODULE_JS}
39
{BACKEND_BODY_MODULE_JS}
40 40
</body>
41 41
</html>
42 42
<!-- END footer_block -->
trunk/wb/templates/wb_theme/templates/header.htt
10 10
<link href="{THEME_URL}/theme.css" rel="stylesheet" type="text/css" />
11 11
<link href="{WB_URL}/include/jquery/plugins/jquery-ui.css" rel="stylesheet" type="text/css" />
12 12
{BACKEND_MODULE_CSS}
13
{BACKEND_MODULE_JS}
13 14
<script type="text/javascript" src="{WB_URL}/include/editarea/edit_area_full.js"></script>
14 15
<script language="javascript" type="text/javascript">
15 16
function confirm_link(message, url) {
trunk/wb/templates/wb_theme/templates/footer.htt
36 36
          }
37 37

  
38 38
</script>
39
{BACKEND_MODULE_JS}
39
{BACKEND_BODY_MODULE_JS}
40 40
</body>
41 41
</html>
42 42
<!-- END footer_block -->
trunk/wb/templates/argos_theme/templates/footer.htt
37 37
          }
38 38

  
39 39
</script>
40
{BACKEND_MODULE_JS}
40
{BACKEND_BODY_MODULE_JS}
41 41
</body>
42 42
</html>
43 43
<!-- END footer_block -->
trunk/wb/templates/argos_theme/templates/header.htt
10 10
<link href="{THEME_URL}/theme.css" rel="stylesheet" type="text/css" />
11 11
<link href="{WB_URL}/include/jquery/plugins/jquery-ui.css" rel="stylesheet" type="text/css" />
12 12
{BACKEND_MODULE_CSS}
13
{BACKEND_MODULE_JS}
13 14
<script type="text/javascript" src="{WB_URL}/include/editarea/edit_area_full.js"></script>
14 15
<script language="javascript" type="text/javascript">
15 16
function confirm_link(message, url) {

Also available in: Unified diff