Project

General

Profile

« Previous | Next » 

Revision 1457

Added by Dietmar almost 13 years ago

Preparing 2.8.2 stable, last tests

View differences:

modify.php
1
<?php
2
/**
3
 *
4
 * @category        modules
5
 * @package         menu_link
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 5.2.2 and higher
13
 * @version         $Id$
14
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
16
 *
17
*/
18

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

  
22
// check if module language file exists for the language set by the user (e.g. DE, EN)
23
if(!file_exists(WB_PATH .'/modules/menu_link/languages/'.LANGUAGE .'.php')) {
24
	// no module language file exists for the language set by the user, include default module language file EN.php
25
	require_once(WB_PATH .'/modules/menu_link/languages/EN.php');
26
} else {
27
	// a module language file exists for the language defined by the user, load it
28
	require_once(WB_PATH .'/modules/menu_link/languages/'.LANGUAGE .'.php');
29
}
30

  
31
// get target page_id
32
$table = TABLE_PREFIX.'mod_menu_link';
33
$sql_result = $database->query("SELECT * FROM $table WHERE section_id = '$section_id'");
34
$sql_row = $sql_result->fetchRow();
35
$target_page_id = $sql_row['target_page_id'];
36
$r_type = $sql_row['redirect_type'];
37
$extern = $sql_row['extern'];
38
$anchor = $sql_row['anchor'];
39
$sel = ' selected="selected"';
40

  
41
// Get list of all visible pages and build a page-tree
42

  
43
// this function will fetch the page_tree, recursive
44
if(!function_exists('menulink_make_tree')) {
45
function menulink_make_tree($parent, $link_pid, $tree) {
46
	global $database, $admin, $menulink_titles;
47
	$table_p = TABLE_PREFIX."pages";
48
	// get list of page-trails, recursive
49
	if($query_page = $database->query("SELECT * FROM `$table_p` WHERE `parent`=$parent ORDER BY `position`")) {
50
		while($page = $query_page->fetchRow()) {
51
			if($admin->page_is_visible($page) ) {
52
				$pids = explode(',', $page['page_trail']);
53
				$entry = '';
54
				foreach($pids as $pid)
55
					$entry .= $menulink_titles[$pid].' / ';
56
				$tree[$page['page_id']] = rtrim($entry, '/ ');
57
				$tree = menulink_make_tree($page['page_id'], $link_pid, $tree);
58
			}
59
		}
60
	}
61
	return($tree);
62
}
63
}
64

  
65
// get list of all page_ids and page_titles
66
global $menulink_titles;
67
$menulink_titles = array();
68
$table_p = TABLE_PREFIX."pages";
69
if($query_page = $database->query("SELECT `page_id`,`menu_title` FROM `$table_p`")) {
70
	while($page = $query_page->fetchRow())
71
		$menulink_titles[$page['page_id']] = $page['menu_title'];
72
}
73
// now get the tree
74
$links = array();
75
$links = menulink_make_tree(0, $page_id, $links);
76

  
77
// Get list of targets (id=... or <a name ...>) from pages in $links
78
$targets = array();
79
$table_mw = TABLE_PREFIX."mod_wysiwyg";
80
$table_s = TABLE_PREFIX."sections";
81
foreach($links as $pid=>$l) {
82
	if($query_section = $database->query("SELECT section_id, module FROM $table_s WHERE page_id = '$pid' ORDER BY position")) {
83
		while($section = $query_section->fetchRow()) {
84
			// get section-anchor
85
			if(defined('SEC_ANCHOR') && SEC_ANCHOR!='') {
86
				$targets[$pid][] = SEC_ANCHOR.$section['section_id'];
87
			} else {
88
				$targets[$pid] = array();
89
			}
90
			if($section['module'] == 'wysiwyg') {
91
				if($query_page = $database->query("SELECT content FROM $table_mw WHERE section_id = '{$section['section_id']}' LIMIT 1")) {
92
					$page = $query_page->fetchRow();
93
					if(preg_match_all('/<(?:a[^>]+name|[^>]+id)\s*=\s*"([^"]+)"/i',$page['content'], $match)) {
94
						foreach($match[1] AS $t) {
95
							$targets[$pid][$t] = $t;
96
						}
97
					}
98
				}
99
			}
100
		}
101
	}
102
}
103
// get target-window for actual page
104
$table = TABLE_PREFIX."pages";
105
$query_page = $database->query("SELECT target FROM $table WHERE page_id = '$page_id'");
106
$page = $query_page->fetchRow();
107
$target = $page['target'];
108

  
109

  
110
// script for target-select-box
111
?>
112
<script language="JavaScript" type="text/javascript">
113
/*<![CDATA[*/
114
	function populate() {
115
		o=document.getElementById('menu_link');
116
		d=document.getElementById('page_target');
117
		e=document.getElementById('extern');
118
		if(!d){return;}
119
		var mitems=new Array();
120
		mitems['0']=[' ','0'];
121
		mitems['-1']=[' ','0'];
122
		<?php
123
		foreach($links AS $pid=>$link) {
124
			$str="mitems['$pid']=[";
125
			$str.="' ',";
126
			$str.="'0',";
127
			if(is_array($targets) && is_array($targets[$pid])) {
128
				foreach($targets[$pid] AS $value) {
129
					$str.="'#$value',";
130
					$str.="'$value',";
131
				}
132
				$str=rtrim($str, ',');
133
				$str.="];\n";
134
			}
135
			echo $str;
136
		}
137
		?>
138
		d.options.length=0;
139
		cur=mitems[o.options[o.selectedIndex].value];
140
		if(!cur){return;}
141
		d.options.length=cur.length/2;
142
		j=0;
143
		for(var i=0;i<cur.length;i=i+2)
144
		{
145
			d.options[j].text=cur[i];
146
			d.options[j++].value=cur[i+1];
147
		}
148

  
149
		if(o.value=='-1') {
150
			e.disabled = false;
151
		} else {
152
			e.disabled = true;
153
		}
154
	}
155

  
156
/*]]>*/
157
</script>
158
<form name="menulink" action="<?php echo WB_URL ?>/modules/menu_link/save.php" method="post">
159
<input type="hidden" name="page_id" value="<?php echo $page_id ?>" />
160
<input type="hidden" name="section_id" value="<?php echo $section_id ?>" />
161
<?php echo $admin->getFTAN(); ?>
162
<table cellpadding="0" cellspacing="0" border="0" width="100%">
163
<tr>
164
	<td>
165
		<?php echo $TEXT['LINK'].':' ?>
166
	</td>
167
	<td>
168
		<select name="menu_link" id="menu_link" onchange="populate()" style="width:250px;" >
169
			<option value="0"<?php echo $target_page_id=='0'?$sel:''?>><?php echo $TEXT['PLEASE_SELECT']; ?></option>
170
			<option value="-1"<?php echo $target_page_id=='-1'?$sel:''?>><?php echo $MOD_MENU_LINK['EXTERNAL_LINK']; ?></option>
171
			<?php foreach($links AS $pid=>$link) {
172
				if ($pid == $page_id)  // Display current page with selection disabled
173
					echo "<option value=\"$pid\" disabled=\"disabled\">$link *</option>\n";
174
				else
175
					echo "<option value=\"$pid\" ".($target_page_id==$pid?$sel:'').">$link</option>\n";
176
			} ?>
177
		</select>
178
		&nbsp;
179
		<input type="text" name="extern" id="extern" value="<?php echo $extern; ?>" style="width:250px;" <?php if($target_page_id!='-1') echo 'disabled="disabled"'; ?> />
180
	</td>
181
</tr>
182
<tr>
183
	<td>
184
		<?php echo $TEXT['ANCHOR'].':' ?>
185
	</td>
186
	<td>
187
		<select name="page_target" id="page_target" onfocus="populate()" style="width:250px;" >
188
			<option value="<?php echo $anchor ?>" selected="selected"><?php echo $anchor=='0'?' ':'#'.$anchor ?></option>
189
		</select>
190
	</td>
191
</tr>
192
<tr>
193
	<td>
194
		<?php echo $TEXT['TARGET'].':' ?>
195
	</td>
196
	<td>
197
		<select name="target" style="width:250px;" >
198
			<option value="_blank"<?php if($target=='_blank') echo ' selected="selected"'; ?>><?php echo $TEXT['NEW_WINDOW'] ?></option>
199
			<option value="_self"<?php if($target=='_self') echo ' selected="selected"'; ?>><?php echo $TEXT['SAME_WINDOW'] ?></option>
200
			<option value="_top"<?php if($target=='_top') echo ' selected="selected"'; ?>><?php echo $TEXT['TOP_FRAME'] ?></option>
201
		</select>
202
	</td>
203
</tr>
204
<tr>
205
	<td>
206
		<?php echo $MOD_MENU_LINK['R_TYPE'].':' ?>
207
	</td>
208
	<td>
209
		<select name="r_type" style="width:250px;" >
210
			<option value="301"<?php if($r_type=='301') echo ' selected="selected"'; ?>>301</option>
211
			<option value="302"<?php if($r_type=='302') echo ' selected="selected"'; ?>>302</option>
212
		</select>
213
	</td>
214
</tr>
215
</table>
216

  
217
<br />
218

  
219
<table cellpadding="0" cellspacing="0" border="0" width="100%">
220
<tr>
221
	<td align="left">
222
		<input type="submit" value="<?php echo $TEXT['SAVE'] ?>" style="width: 100px; margin-top: 5px;" />
223
	</td>
224
	<td align="right">
225
		<input type="button" value="<?php echo $TEXT['CANCEL'] ?>" onclick="javascript: window.location = 'index.php';" style="width: 100px; margin-top: 5px;" />
226
	</td>
227
</tr>
228
</table>
229

  
230
</form>
1
<?php
2
/**
3
 *
4
 * @category        modules
5
 * @package         menu_link
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 5.2.2 and higher
13
 * @version         $Id$
14
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
16
 *
17
*/
18

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

  
22
// check if module language file exists for the language set by the user (e.g. DE, EN)
23
if(!file_exists(WB_PATH .'/modules/menu_link/languages/'.LANGUAGE .'.php')) {
24
	// no module language file exists for the language set by the user, include default module language file EN.php
25
	require_once(WB_PATH .'/modules/menu_link/languages/EN.php');
26
} else {
27
	// a module language file exists for the language defined by the user, load it
28
	require_once(WB_PATH .'/modules/menu_link/languages/'.LANGUAGE .'.php');
29
}
30

  
31
// get target page_id
32
$table = TABLE_PREFIX.'mod_menu_link';
33
$sql_result = $database->query("SELECT * FROM $table WHERE section_id = '$section_id'");
34
$sql_row = $sql_result->fetchRow();
35
$target_page_id = $sql_row['target_page_id'];
36
$r_type = $sql_row['redirect_type'];
37
$extern = $sql_row['extern'];
38
$anchor = $sql_row['anchor'];
39
$sel = ' selected="selected"';
40

  
41
// Get list of all visible pages and build a page-tree
42

  
43
// this function will fetch the page_tree, recursive
44
if(!function_exists('menulink_make_tree')) {
45
function menulink_make_tree($parent, $link_pid, $tree) {
46
	global $database, $admin, $menulink_titles;
47
	$table_p = TABLE_PREFIX."pages";
48
	// get list of page-trails, recursive
49
	if($query_page = $database->query("SELECT * FROM `$table_p` WHERE `parent`=$parent ORDER BY `position`")) {
50
		while($page = $query_page->fetchRow()) {
51
			if($admin->page_is_visible($page) ) {
52
				$pids = explode(',', $page['page_trail']);
53
				$entry = '';
54
				foreach($pids as $pid)
55
					$entry .= $menulink_titles[$pid].' / ';
56
				$tree[$page['page_id']] = rtrim($entry, '/ ');
57
				$tree = menulink_make_tree($page['page_id'], $link_pid, $tree);
58
			}
59
		}
60
	}
61
	return($tree);
62
}
63
}
64

  
65
// get list of all page_ids and page_titles
66
global $menulink_titles;
67
$menulink_titles = array();
68
$table_p = TABLE_PREFIX."pages";
69
if($query_page = $database->query("SELECT `page_id`,`menu_title` FROM `$table_p`")) {
70
	while($page = $query_page->fetchRow())
71
		$menulink_titles[$page['page_id']] = $page['menu_title'];
72
}
73
// now get the tree
74
$links = array();
75
$links = menulink_make_tree(0, $page_id, $links);
76

  
77
// Get list of targets (id=... or <a name ...>) from pages in $links
78
$targets = array();
79
$table_mw = TABLE_PREFIX."mod_wysiwyg";
80
$table_s = TABLE_PREFIX."sections";
81
foreach($links as $pid=>$l) {
82
	if($query_section = $database->query("SELECT section_id, module FROM $table_s WHERE page_id = '$pid' ORDER BY position")) {
83
		while($section = $query_section->fetchRow()) {
84
			// get section-anchor
85
			if(defined('SEC_ANCHOR') && SEC_ANCHOR!='') {
86
				$targets[$pid][] = SEC_ANCHOR.$section['section_id'];
87
			} else {
88
				$targets[$pid] = array();
89
			}
90
			if($section['module'] == 'wysiwyg') {
91
				if($query_page = $database->query("SELECT content FROM $table_mw WHERE section_id = '{$section['section_id']}' LIMIT 1")) {
92
					$page = $query_page->fetchRow();
93
					if(preg_match_all('/<(?:a[^>]+name|[^>]+id)\s*=\s*"([^"]+)"/i',$page['content'], $match)) {
94
						foreach($match[1] AS $t) {
95
							$targets[$pid][$t] = $t;
96
						}
97
					}
98
				}
99
			}
100
		}
101
	}
102
}
103
// get target-window for actual page
104
$table = TABLE_PREFIX."pages";
105
$query_page = $database->query("SELECT target FROM $table WHERE page_id = '$page_id'");
106
$page = $query_page->fetchRow();
107
$target = $page['target'];
108

  
109

  
110
// script for target-select-box
111
?>
112
<script language="JavaScript" type="text/javascript">
113
/*<![CDATA[*/
114
	function populate() {
115
		o=document.getElementById('menu_link');
116
		d=document.getElementById('page_target');
117
		e=document.getElementById('extern');
118
		if(!d){return;}
119
		var mitems=new Array();
120
		mitems['0']=[' ','0'];
121
		mitems['-1']=[' ','0'];
122
		<?php
123
		foreach($links AS $pid=>$link) {
124
			$str="mitems['$pid']=[";
125
			$str.="' ',";
126
			$str.="'0',";
127
			if(is_array($targets) && is_array($targets[$pid])) {
128
				foreach($targets[$pid] AS $value) {
129
					$str.="'#$value',";
130
					$str.="'$value',";
131
				}
132
				$str=rtrim($str, ',');
133
				$str.="];\n";
134
			}
135
			echo $str;
136
		}
137
		?>
138
		d.options.length=0;
139
		cur=mitems[o.options[o.selectedIndex].value];
140
		if(!cur){return;}
141
		d.options.length=cur.length/2;
142
		j=0;
143
		for(var i=0;i<cur.length;i=i+2)
144
		{
145
			d.options[j].text=cur[i];
146
			d.options[j++].value=cur[i+1];
147
		}
148

  
149
		if(o.value=='-1') {
150
			e.disabled = false;
151
		} else {
152
			e.disabled = true;
153
		}
154
	}
155

  
156
/*]]>*/
157
</script>
158
<form name="menulink" action="<?php echo WB_URL ?>/modules/menu_link/save.php" method="post">
159
<input type="hidden" name="page_id" value="<?php echo $page_id ?>" />
160
<input type="hidden" name="section_id" value="<?php echo $section_id ?>" />
161
<?php echo $admin->getFTAN(); ?>
162
<table cellpadding="0" cellspacing="0" border="0" width="100%">
163
<tr>
164
	<td>
165
		<?php echo $TEXT['LINK'].':' ?>
166
	</td>
167
	<td>
168
		<select name="menu_link" id="menu_link" onchange="populate()" style="width:250px;" >
169
			<option value="0"<?php echo $target_page_id=='0'?$sel:''?>><?php echo $TEXT['PLEASE_SELECT']; ?></option>
170
			<option value="-1"<?php echo $target_page_id=='-1'?$sel:''?>><?php echo $MOD_MENU_LINK['EXTERNAL_LINK']; ?></option>
171
			<?php foreach($links AS $pid=>$link) {
172
				if ($pid == $page_id)  // Display current page with selection disabled
173
					echo "<option value=\"$pid\" disabled=\"disabled\">$link *</option>\n";
174
				else
175
					echo "<option value=\"$pid\" ".($target_page_id==$pid?$sel:'').">$link</option>\n";
176
			} ?>
177
		</select>
178
		&nbsp;
179
		<input type="text" name="extern" id="extern" value="<?php echo $extern; ?>" style="width:250px;" <?php if($target_page_id!='-1') echo 'disabled="disabled"'; ?> />
180
	</td>
181
</tr>
182
<tr>
183
	<td>
184
		<?php echo $TEXT['ANCHOR'].':' ?>
185
	</td>
186
	<td>
187
		<select name="page_target" id="page_target" onfocus="populate()" style="width:250px;" >
188
			<option value="<?php echo $anchor ?>" selected="selected"><?php echo $anchor=='0'?' ':'#'.$anchor ?></option>
189
		</select>
190
	</td>
191
</tr>
192
<tr>
193
	<td>
194
		<?php echo $TEXT['TARGET'].':' ?>
195
	</td>
196
	<td>
197
		<select name="target" style="width:250px;" >
198
			<option value="_blank"<?php if($target=='_blank') echo ' selected="selected"'; ?>><?php echo $TEXT['NEW_WINDOW'] ?></option>
199
			<option value="_self"<?php if($target=='_self') echo ' selected="selected"'; ?>><?php echo $TEXT['SAME_WINDOW'] ?></option>
200
			<option value="_top"<?php if($target=='_top') echo ' selected="selected"'; ?>><?php echo $TEXT['TOP_FRAME'] ?></option>
201
		</select>
202
	</td>
203
</tr>
204
<tr>
205
	<td>
206
		<?php echo $MOD_MENU_LINK['R_TYPE'].':' ?>
207
	</td>
208
	<td>
209
		<select name="r_type" style="width:250px;" >
210
			<option value="301"<?php if($r_type=='301') echo ' selected="selected"'; ?>>301</option>
211
			<option value="302"<?php if($r_type=='302') echo ' selected="selected"'; ?>>302</option>
212
		</select>
213
	</td>
214
</tr>
215
</table>
216

  
217
<br />
218

  
219
<table cellpadding="0" cellspacing="0" border="0" width="100%">
220
<tr>
221
	<td align="left">
222
		<input type="submit" value="<?php echo $TEXT['SAVE'] ?>" style="width: 100px; margin-top: 5px;" />
223
	</td>
224
	<td align="right">
225
		<input type="button" value="<?php echo $TEXT['CANCEL'] ?>" onclick="javascript: window.location = 'index.php';" style="width: 100px; margin-top: 5px;" />
226
	</td>
227
</tr>
228
</table>
229

  
230
</form>

Also available in: Unified diff