Project

General

Profile

« Previous | Next » 

Revision 698

Added by thorn almost 17 years ago

allow external links in menulink-module

View differences:

trunk/CHANGELOG
12 12

  
13 13
------------------------------------- 2.7.0 -------------------------------------
14 14
13-Feb-2008 Thomas Hornik
15
+	allow externl links in menulink-module
15 16
#	fixed an highlighting-issue: highlighting a page with more than one sections mangled umlauts in the second to last section.
16 17
10-Feb-2008 Matthias Gallas
17 18
#	fixed some errors in standard german language file
trunk/wb/index.php
59 59
if($query_this_module->numRows() == 1) { // This is a menu_link. Get link of target-page and redirect
60 60
	// get target_page_id
61 61
	$table = TABLE_PREFIX.'mod_menu_link';
62
	$query_tpid = $database->query("SELECT target_page_id, anchor FROM $table WHERE page_id = '$this_page_id'");
62
	$query_tpid = $database->query("SELECT target_page_id, anchor, extern FROM $table WHERE page_id = '$this_page_id'");
63 63
	if($query_tpid->numRows() == 1) {
64 64
		$res=$query_tpid->fetchRow();
65 65
		$target_page_id = $res['target_page_id'];
66 66
		$anchor = $res['anchor'];
67
		$extern = $res['extern'];
67 68
		if($anchor != '0') $anchor = ''.$anchor;
68 69
		else $anchor = FALSE;
69
		// get link of target-page
70
		$table = TABLE_PREFIX.'pages';
71
		$query_link = $database->query("SELECT link FROM $table WHERE page_id = '$target_page_id'");
72
		if($query_link->numRows() == 1) {
73
			$res=$query_link->fetchRow();
74
			$target_page_link = $res['link'];
75
			// redirect
76
			header('Location: '.WB_URL.PAGES_DIRECTORY.$target_page_link.PAGE_EXTENSION.($anchor?'#'.$anchor:''));
77
			exit;
70
		if($target_page_id == -1) {
71
			if($extern!='') {
72
				$extern=rtrim($extern, '/');
73
				header("Location: $extern/".($anchor?'#'.$anchor:''));
74
			}
75
		} else {
76
			// get link of target-page
77
			$table = TABLE_PREFIX.'pages';
78
			$query_link = $database->query("SELECT link FROM $table WHERE page_id = '$target_page_id'");
79
			if($query_link->numRows() == 1) {
80
				$res=$query_link->fetchRow();
81
				$target_page_link = $res['link'];
82
				// redirect
83
				header('Location: '.WB_URL.PAGES_DIRECTORY.$target_page_link.PAGE_EXTENSION.($anchor?'#'.$anchor:''));
84
				exit;
85
			}
78 86
		}
79 87
	}
80 88
}
trunk/wb/modules/menu_link/save.php
34 34
	$foreign_page_id = $admin->add_slashes($_POST['page_link']);
35 35
	$page_target = $admin->add_slashes($_POST['page_target']);
36 36
	$url_target = $admin->add_slashes($_POST['target']);
37
	if(isset($_POST['extern']))
38
		$extern = $admin->add_slashes($_POST['extern']);
39
	else
40
		$extern='';
37 41

  
38 42
	$table_pages = TABLE_PREFIX.'pages';
39 43
	$table_mod = TABLE_PREFIX.'mod_menu_link';
40 44
	$database->query("UPDATE $table_pages SET target = '$url_target' WHERE page_id = '$page_id'");
41
	$database->query("UPDATE $table_mod SET target_page_id = '$foreign_page_id', anchor = '$page_target' WHERE page_id = '$page_id'");
45
	$database->query("UPDATE $table_mod SET target_page_id = '$foreign_page_id', anchor = '$page_target', extern = '$extern' WHERE page_id = '$page_id'");
42 46
}
43 47

  
44 48
// Check if there is a database error, otherwise say successful
trunk/wb/modules/menu_link/languages/DE_du.php
31 31

  
32 32
// Ueberschriften und Textausgaben
33 33
$MOD_MENU_LINK['TEXT']				= 'Klicke HIER um zur Startseite zu gelangen';
34
$MOD_MENU_LINK['EXTERNAL_LINK'] = 'Entfernte Adresse';
34 35

  
35 36
?>
trunk/wb/modules/menu_link/languages/EN.php
28 28

  
29 29
// Headings and text outputs
30 30
$MOD_MENU_LINK['TEXT']				= 'Click HERE to go to the main page';
31
$MOD_MENU_LINK['EXTERNAL_LINK'] = 'External Link';
31 32

  
32 33
?>
trunk/wb/modules/menu_link/languages/DE.php
31 31

  
32 32
// Ueberschriften und Textausgaben
33 33
$MOD_MENU_LINK['TEXT']				= 'Klicken Sie HIER um zur Startseite zu gelangen';
34
$MOD_MENU_LINK['EXTERNAL_LINK'] = 'Entfernte Adresse';
34 35

  
35 36
?>
trunk/wb/modules/menu_link/install.php
37 37
		`page_id` INT(11) NOT NULL DEFAULT '0',
38 38
		`target_page_id` INT(11) NOT NULL DEFAULT '0',
39 39
		`anchor` VARCHAR(255) NOT NULL DEFAULT '0' ,
40
		`extern` VARCHAR(255) NOT NULL DEFAULT '' ,
40 41
		PRIMARY KEY (`section_id`)
41 42
	)
42 43
");
trunk/wb/modules/menu_link/modify.php
25 25

  
26 26
// Must include code to stop this file being accessed directly
27 27
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
28

  
29
// check if module language file exists for the language set by the user (e.g. DE, EN)
30
if(!file_exists(WB_PATH .'/modules/menu_link/languages/'.LANGUAGE .'.php')) {
31
	// no module language file exists for the language set by the user, include default module language file EN.php
32
	require_once(WB_PATH .'/modules/menu_link/languages/EN.php');
33
} else {
34
	// a module language file exists for the language defined by the user, load it
35
	require_once(WB_PATH .'/modules/menu_link/languages/'.LANGUAGE .'.php');
36
}
28 37

  
29 38
// get target page_id
30 39
$table = TABLE_PREFIX.'mod_menu_link';
31 40
$sql_result = $database->query("SELECT * FROM $table WHERE section_id = '$section_id'");
32 41
$sql_row = $sql_result->fetchRow();
33
$target_page_id = $sql_row['target_page_id'];
42
$target_page_id = $sql_row['target_page_id'];
43
$extern = $sql_row['extern'];
34 44
$anchor = $sql_row['anchor'];
35 45
$sel = ' selected';
36 46

  
......
84 94
// script for target-select-box
85 95
?>
86 96
<script type="text/javascript">
87
	function populate()
88
	{
97
	function populate() {
89 98
		o=document.getElementById('page_link');
90
		d=document.getElementById('page_target');
99
		d=document.getElementById('page_target');
100
		e=document.getElementById('extern');
91 101
		if(!d){return;}			
92 102
		var mitems=new Array();
93 103
		mitems['0']=[' ','0'];
104
		mitems['-1']=[' ','0'];
94 105
		<?php
95 106
		foreach($links AS $pid=>$link) {
96 107
			$str="mitems['$pid']=[";
......
116 127
		{
117 128
			d.options[j].text=cur[i];
118 129
			d.options[j++].value=cur[i+1];
119
		}
120
	}
130
		}
131
		
132
		if(o.value=='-1') {
133
			e.disabled = false;
134
		} else {
135
			e.disabled = true;
136
		}
137
	}
121 138
</script>
122 139

  
123
<form action="<?php echo WB_URL ?>/modules/menu_link/save.php" method="post">
140
<form name="menulink" action="<?php echo WB_URL ?>/modules/menu_link/save.php" method="post">
124 141
<input type="hidden" name="page_id" value="<?php echo $page_id ?>" />
125 142
<input type="hidden" name="section_id" value="<?php echo $section_id ?>" />
126 143
<table cellpadding="0" cellspacing="0" border="0" width="100%">
......
130 147
	</td>
131 148
	<td>
132 149
		<select name="page_link" id="page_link" onchange="populate()" style="width:250px;" />
133
			<option value="0"<?php echo $target_page_id=='0'?$sel:''?>><?php echo $TEXT['PLEASE_SELECT']; ?></option>
150
			<option value="0"<?php echo $target_page_id=='0'?$sel:''?>><?php echo $TEXT['PLEASE_SELECT']; ?></option>
151
			<option value="-1"<?php echo $target_page_id=='-1'?$sel:''?>><?php echo $MOD_MENU_LINK['EXTERNAL_LINK']; ?></option>
134 152
			<?php foreach($links AS $pid=>$link) {
135 153
				echo "<option value=\"$pid\" ".($target_page_id==$pid?$sel:'').">$link</option>";
136 154
			} ?>
137
		</select>
155
		</select>
156
		&nbsp;
157
		<input type="text" name="extern" id="extern" value="<?php echo $extern; ?>" style="width:250px;" <?php if($target_page_id!='-1') echo 'disabled="disabled"'; ?> />
138 158
	</td>
139 159
</tr>
140 160
<tr>
trunk/wb/modules/menu_link/add.php
29 29
}
30 30

  
31 31
$table = TABLE_PREFIX ."mod_menu_link";
32
$database->query("INSERT INTO `$table` (`page_id`, `section_id`, target_page_id, anchor) VALUES ('$page_id', '$section_id', '0', '0')");
32
$database->query("INSERT INTO `$table` (`page_id`, `section_id`, `target_page_id`, `type`, `anchor`, `extern`) VALUES ('$page_id', '$section_id', '0', '0', '0', '')");
33 33

  
34 34
?>

Also available in: Unified diff