Revision 993
Added by Matthias over 15 years ago
modify.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2009, Ryan Djurovich |
|
9 |
|
|
10 |
Website Baker is free software; you can redistribute it and/or modify |
|
11 |
it under the terms of the GNU General Public License as published by |
|
12 |
the Free Software Foundation; either version 2 of the License, or |
|
13 |
(at your option) any later version. |
|
14 |
|
|
15 |
Website Baker is distributed in the hope that it will be useful, |
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
GNU General Public License for more details. |
|
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
|
21 |
along with Website Baker; if not, write to the Free Software |
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
|
|
24 |
*/ |
|
25 |
|
|
26 |
// Must include code to stop this file being accessed directly |
|
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 |
} |
|
37 |
|
|
38 |
// get target page_id |
|
39 |
$table = TABLE_PREFIX.'mod_menu_link'; |
|
40 |
$sql_result = $database->query("SELECT * FROM $table WHERE section_id = '$section_id'"); |
|
41 |
$sql_row = $sql_result->fetchRow(); |
|
42 |
$target_page_id = $sql_row['target_page_id']; |
|
43 |
$r_type = $sql_row['redirect_type']; |
|
44 |
$extern = $sql_row['extern']; |
|
45 |
$anchor = $sql_row['anchor']; |
|
46 |
$sel = ' selected'; |
|
47 |
|
|
48 |
// Get list of all visible pages, except actual one |
|
49 |
$links = array(); |
|
50 |
$table_p = TABLE_PREFIX."pages"; |
|
51 |
if($query_page = $database->query("SELECT * FROM $table_p WHERE parent = '0' ORDER BY position")) { |
|
52 |
while($page = $query_page->fetchRow()) { |
|
53 |
$all_links[$page['page_id']]='/'.$page['menu_title']; |
|
54 |
if($admin->page_is_visible($page) && $page['page_id']!=$page_id) { |
|
55 |
$links[$page['page_id']]='/'.$page['menu_title']; |
|
56 |
} |
|
57 |
if($query_subpage = $database->query("SELECT * FROM $table_p WHERE page_id != '$page_id' AND root_parent = '{$page['page_id']}' ORDER BY level")) { |
|
58 |
while($sub = $query_subpage->fetchRow()) { |
|
59 |
if($admin->page_is_visible($sub)) { |
|
60 |
$parent_link = (array_key_exists($sub['parent'],$all_links))?$all_links[$sub['parent']]:""; |
|
61 |
$links[$sub['page_id']]=$parent_link.'/'.$sub['menu_title']; |
|
62 |
} |
|
63 |
} |
|
64 |
} |
|
65 |
} |
|
66 |
} |
|
67 |
// Get list of targets (id=... or <a name ...>) from pages in $links |
|
68 |
$targets = array(); |
|
69 |
$table_mw = TABLE_PREFIX."mod_wysiwyg"; |
|
70 |
$table_s = TABLE_PREFIX."sections"; |
|
71 |
foreach($links as $pid=>$l) { |
|
72 |
if($query_section = $database->query("SELECT section_id, module FROM $table_s WHERE page_id = '$pid' ORDER BY position")) { |
|
73 |
while($section = $query_section->fetchRow()) { |
|
74 |
// get section-anchor |
|
75 |
if(defined('SEC_ANCHOR') && SEC_ANCHOR!='') { |
|
76 |
$targets[$pid][] = SEC_ANCHOR.$section['section_id']; |
|
77 |
} else { |
|
78 |
$targets[$pid] = array(); |
|
79 |
} |
|
80 |
if($section['module'] == 'wysiwyg') { |
|
81 |
if($query_page = $database->query("SELECT content FROM $table_mw WHERE section_id = '{$section['section_id']}' LIMIT 1")) { |
|
82 |
$page = $query_page->fetchRow(); |
|
83 |
if(preg_match_all('/<(?:[^>]+id|\s*a[^>]+name)\s*=\s*"([^"]+)"/i',$page['content'], $match)) { |
|
84 |
foreach($match[1] AS $t) { |
|
85 |
$targets[$pid][] = $t; |
|
86 |
} |
|
87 |
} |
|
88 |
} |
|
89 |
} |
|
90 |
} |
|
91 |
} |
|
92 |
} |
|
93 |
// get target-window for actual page |
|
94 |
$table = TABLE_PREFIX."pages"; |
|
95 |
$query_page = $database->query("SELECT target FROM $table WHERE page_id = '$page_id'"); |
|
96 |
$page = $query_page->fetchRow(); |
|
97 |
$target = $page['target']; |
|
98 |
|
|
99 |
|
|
100 |
// script for target-select-box |
|
101 |
?> |
|
102 |
<script type="text/javascript"> |
|
103 |
function populate() { |
|
104 |
o=document.getElementById('page_link'); |
|
105 |
d=document.getElementById('page_target'); |
|
106 |
e=document.getElementById('extern'); |
|
107 |
if(!d){return;} |
|
108 |
var mitems=new Array(); |
|
109 |
mitems['0']=[' ','0']; |
|
110 |
mitems['-1']=[' ','0']; |
|
111 |
<?php |
|
112 |
foreach($links AS $pid=>$link) { |
|
113 |
$str="mitems['$pid']=["; |
|
114 |
$str.="' ',"; |
|
115 |
$str.="'0',"; |
|
116 |
if(is_array($targets) && is_array($targets[$pid])) { |
|
117 |
foreach($targets[$pid] AS $value) { |
|
118 |
$str.="'#$value',"; |
|
119 |
$str.="'$value',"; |
|
120 |
} |
|
121 |
$str=rtrim($str, ','); |
|
122 |
$str.="];\n"; |
|
123 |
} |
|
124 |
echo $str; |
|
125 |
} |
|
126 |
?> |
|
127 |
d.options.length=0; |
|
128 |
cur=mitems[o.options[o.selectedIndex].value]; |
|
129 |
if(!cur){return;} |
|
130 |
d.options.length=cur.length/2; |
|
131 |
j=0; |
|
132 |
for(var i=0;i<cur.length;i=i+2) |
|
133 |
{ |
|
134 |
d.options[j].text=cur[i]; |
|
135 |
d.options[j++].value=cur[i+1]; |
|
136 |
} |
|
137 |
|
|
138 |
if(o.value=='-1') { |
|
139 |
e.disabled = false; |
|
140 |
} else { |
|
141 |
e.disabled = true; |
|
142 |
} |
|
143 |
} |
|
144 |
</script> |
|
145 |
|
|
146 |
<form name="menulink" action="<?php echo WB_URL ?>/modules/menu_link/save.php" method="post"> |
|
147 |
<input type="hidden" name="page_id" value="<?php echo $page_id ?>" /> |
|
148 |
<input type="hidden" name="section_id" value="<?php echo $section_id ?>" /> |
|
149 |
<table cellpadding="0" cellspacing="0" border="0" width="100%"> |
|
150 |
<tr> |
|
151 |
<td> |
|
152 |
<?php echo $TEXT['LINK'].':' ?> |
|
153 |
</td> |
|
154 |
<td> |
|
155 |
<select name="page_link" id="page_link" onchange="populate()" style="width:250px;" /> |
|
156 |
<option value="0"<?php echo $target_page_id=='0'?$sel:''?>><?php echo $TEXT['PLEASE_SELECT']; ?></option> |
|
157 |
<option value="-1"<?php echo $target_page_id=='-1'?$sel:''?>><?php echo $MOD_MENU_LINK['EXTERNAL_LINK']; ?></option> |
|
158 |
<?php foreach($links AS $pid=>$link) { |
|
159 |
echo "<option value=\"$pid\" ".($target_page_id==$pid?$sel:'').">$link</option>"; |
|
160 |
} ?> |
|
161 |
</select> |
|
162 |
|
|
163 |
<input type="text" name="extern" id="extern" value="<?php echo $extern; ?>" style="width:250px;" <?php if($target_page_id!='-1') echo 'disabled="disabled"'; ?> /> |
|
164 |
</td> |
|
165 |
</tr> |
|
166 |
<tr> |
|
167 |
<td> |
|
168 |
<?php echo $TEXT['ANCHOR'].':' ?> |
|
169 |
</td> |
|
170 |
<td> |
|
171 |
<select name="page_target" id="page_target" onfocus="populate()" style="width:250px;" /> |
|
172 |
<option value="<?php echo $anchor ?>" selected><?php echo $anchor=='0'?' ':'#'.$anchor ?></option> |
|
173 |
</select> |
|
174 |
</td> |
|
175 |
</tr> |
|
176 |
<tr> |
|
177 |
<td> |
|
178 |
<?php echo $TEXT['TARGET'].':' ?> |
|
179 |
</td> |
|
180 |
<td> |
|
181 |
<select name="target" style="width:250px;" /> |
|
182 |
<option value="_blank"<?php if($target=='_blank') echo ' selected="selected"'; ?>><?php echo $TEXT['NEW_WINDOW'] ?></option> |
|
183 |
<option value="_self"<?php if($target=='_self') echo ' selected="selected"'; ?>><?php echo $TEXT['SAME_WINDOW'] ?></option> |
|
184 |
<option value="_top"<?php if($target=='_top') echo ' selected="selected"'; ?>><?php echo $TEXT['TOP_FRAME'] ?></option> |
|
185 |
</select> |
|
186 |
</td> |
|
187 |
</tr> |
|
188 |
<tr> |
|
189 |
<td> |
|
190 |
<?php echo $MOD_MENU_LINK['R_TYPE'].':' ?> |
|
191 |
</td> |
|
192 |
<td> |
|
193 |
<select name="r_type" style="width:250px;" /> |
|
194 |
<option value="301"<?php if($r_type=='301') echo ' selected="selected"'; ?>>301</option> |
|
195 |
<option value="302"<?php if($r_type=='302') echo ' selected="selected"'; ?>>302</option> |
|
196 |
</select> |
|
197 |
</td> |
|
198 |
</tr> |
|
199 |
</table> |
|
200 |
|
|
201 |
<br /> |
|
202 |
|
|
203 |
<table cellpadding="0" cellspacing="0" border="0" width="100%"> |
|
204 |
<tr> |
|
205 |
<td align="left"> |
|
206 |
<input type="submit" value="<?php echo $TEXT['SAVE'] ?>" style="width: 100px; margin-top: 5px;" /> |
|
207 |
</td> |
|
208 |
<td align="right"> |
|
209 |
</form> |
|
210 |
<input type="button" value="<?php echo $TEXT['CANCEL'] ?>" onclick="javascript: window.location = 'index.php';" style="width: 100px; margin-top: 5px;" /> |
|
211 |
</td> |
|
212 |
</tr> |
|
213 |
</table> |
|
214 |
|
|
215 |
</form> |
|
216 |
|
|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2009, Ryan Djurovich |
|
9 |
|
|
10 |
Website Baker is free software; you can redistribute it and/or modify |
|
11 |
it under the terms of the GNU General Public License as published by |
|
12 |
the Free Software Foundation; either version 2 of the License, or |
|
13 |
(at your option) any later version. |
|
14 |
|
|
15 |
Website Baker is distributed in the hope that it will be useful, |
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
GNU General Public License for more details. |
|
19 |
|
|
20 |
You should have received a copy of the GNU General Public License |
|
21 |
along with Website Baker; if not, write to the Free Software |
|
22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
|
|
24 |
*/ |
|
25 |
|
|
26 |
// Must include code to stop this file being accessed directly |
|
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 |
} |
|
37 |
|
|
38 |
// get target page_id |
|
39 |
$table = TABLE_PREFIX.'mod_menu_link'; |
|
40 |
$sql_result = $database->query("SELECT * FROM $table WHERE section_id = '$section_id'"); |
|
41 |
$sql_row = $sql_result->fetchRow(); |
|
42 |
$target_page_id = $sql_row['target_page_id']; |
|
43 |
$r_type = $sql_row['redirect_type']; |
|
44 |
$extern = $sql_row['extern']; |
|
45 |
$anchor = $sql_row['anchor']; |
|
46 |
$sel = ' selected'; |
|
47 |
|
|
48 |
// Get list of all visible pages, except actual one, and build a page-tree |
|
49 |
|
|
50 |
// this function will fetch the page_tree, recursive |
|
51 |
if(!function_exists('menulink_make_tree')) { |
|
52 |
function menulink_make_tree($parent, $link_pid, $tree) { |
|
53 |
global $database, $admin, $menulink_titles; |
|
54 |
$table_p = TABLE_PREFIX."pages"; |
|
55 |
// get list of page-trails, recursive |
|
56 |
if($query_page = $database->query("SELECT * FROM `$table_p` WHERE `parent`=$parent ORDER BY `position`")) { |
|
57 |
while($page = $query_page->fetchRow()) { |
|
58 |
if($admin->page_is_visible($page) && $page['page_id']!=$link_pid) { |
|
59 |
$pids = explode(',', $page['page_trail']); |
|
60 |
$entry = ''; |
|
61 |
foreach($pids as $pid) |
|
62 |
$entry .= $menulink_titles[$pid].' / '; |
|
63 |
$tree[$page['page_id']] = rtrim($entry, '/ '); |
|
64 |
$tree = menulink_make_tree($page['page_id'], $link_pid, $tree); |
|
65 |
} |
|
66 |
} |
|
67 |
} |
|
68 |
return($tree); |
|
69 |
} |
|
70 |
} |
|
71 |
// get list of all page_ids and page_titles |
|
72 |
global $menulink_titles; |
|
73 |
$menulink_titles = array(); |
|
74 |
$table_p = TABLE_PREFIX."pages"; |
|
75 |
if($query_page = $database->query("SELECT `page_id`,`page_title` FROM `$table_p`")) { |
|
76 |
while($page = $query_page->fetchRow()) |
|
77 |
$menulink_titles[$page['page_id']] = $page['page_title']; |
|
78 |
} |
|
79 |
// now get the tree |
|
80 |
$links = array(); |
|
81 |
$links = menulink_make_tree(0, $page_id, $links); |
|
82 |
|
|
83 |
// Get list of targets (id=... or <a name ...>) from pages in $links |
|
84 |
$targets = array(); |
|
85 |
$table_mw = TABLE_PREFIX."mod_wysiwyg"; |
|
86 |
$table_s = TABLE_PREFIX."sections"; |
|
87 |
foreach($links as $pid=>$l) { |
|
88 |
if($query_section = $database->query("SELECT section_id, module FROM $table_s WHERE page_id = '$pid' ORDER BY position")) { |
|
89 |
while($section = $query_section->fetchRow()) { |
|
90 |
// get section-anchor |
|
91 |
if(defined('SEC_ANCHOR') && SEC_ANCHOR!='') { |
|
92 |
$targets[$pid][] = SEC_ANCHOR.$section['section_id']; |
|
93 |
} else { |
|
94 |
$targets[$pid] = array(); |
|
95 |
} |
|
96 |
if($section['module'] == 'wysiwyg') { |
|
97 |
if($query_page = $database->query("SELECT content FROM $table_mw WHERE section_id = '{$section['section_id']}' LIMIT 1")) { |
|
98 |
$page = $query_page->fetchRow(); |
|
99 |
if(preg_match_all('/<(?:a[^>]+name|[^>]+id)\s*=\s*"([^"]+)"/i',$page['content'], $match)) { |
|
100 |
foreach($match[1] AS $t) { |
|
101 |
$targets[$pid][$t] = $t; |
|
102 |
} |
|
103 |
} |
|
104 |
} |
|
105 |
} |
|
106 |
} |
|
107 |
} |
|
108 |
} |
|
109 |
// get target-window for actual page |
|
110 |
$table = TABLE_PREFIX."pages"; |
|
111 |
$query_page = $database->query("SELECT target FROM $table WHERE page_id = '$page_id'"); |
|
112 |
$page = $query_page->fetchRow(); |
|
113 |
$target = $page['target']; |
|
114 |
|
|
115 |
|
|
116 |
// script for target-select-box |
|
117 |
?> |
|
118 |
<script type="text/javascript"> |
|
119 |
function populate() { |
|
120 |
o=document.getElementById('page_link'); |
|
121 |
d=document.getElementById('page_target'); |
|
122 |
e=document.getElementById('extern'); |
|
123 |
if(!d){return;} |
|
124 |
var mitems=new Array(); |
|
125 |
mitems['0']=[' ','0']; |
|
126 |
mitems['-1']=[' ','0']; |
|
127 |
<?php |
|
128 |
foreach($links AS $pid=>$link) { |
|
129 |
$str="mitems['$pid']=["; |
|
130 |
$str.="' ',"; |
|
131 |
$str.="'0',"; |
|
132 |
if(is_array($targets) && is_array($targets[$pid])) { |
|
133 |
foreach($targets[$pid] AS $value) { |
|
134 |
$str.="'#$value',"; |
|
135 |
$str.="'$value',"; |
|
136 |
} |
|
137 |
$str=rtrim($str, ','); |
|
138 |
$str.="];\n"; |
|
139 |
} |
|
140 |
echo $str; |
|
141 |
} |
|
142 |
?> |
|
143 |
d.options.length=0; |
|
144 |
cur=mitems[o.options[o.selectedIndex].value]; |
|
145 |
if(!cur){return;} |
|
146 |
d.options.length=cur.length/2; |
|
147 |
j=0; |
|
148 |
for(var i=0;i<cur.length;i=i+2) |
|
149 |
{ |
|
150 |
d.options[j].text=cur[i]; |
|
151 |
d.options[j++].value=cur[i+1]; |
|
152 |
} |
|
153 |
|
|
154 |
if(o.value=='-1') { |
|
155 |
e.disabled = false; |
|
156 |
} else { |
|
157 |
e.disabled = true; |
|
158 |
} |
|
159 |
} |
|
160 |
</script> |
|
161 |
|
|
162 |
<form name="menulink" action="<?php echo WB_URL ?>/modules/menu_link/save.php" method="post"> |
|
163 |
<input type="hidden" name="page_id" value="<?php echo $page_id ?>" /> |
|
164 |
<input type="hidden" name="section_id" value="<?php echo $section_id ?>" /> |
|
165 |
<table cellpadding="0" cellspacing="0" border="0" width="100%"> |
|
166 |
<tr> |
|
167 |
<td> |
|
168 |
<?php echo $TEXT['LINK'].':' ?> |
|
169 |
</td> |
|
170 |
<td> |
|
171 |
<select name="page_link" id="page_link" onchange="populate()" style="width:250px;" /> |
|
172 |
<option value="0"<?php echo $target_page_id=='0'?$sel:''?>><?php echo $TEXT['PLEASE_SELECT']; ?></option> |
|
173 |
<option value="-1"<?php echo $target_page_id=='-1'?$sel:''?>><?php echo $MOD_MENU_LINK['EXTERNAL_LINK']; ?></option> |
|
174 |
<?php foreach($links AS $pid=>$link) { |
|
175 |
echo "<option value=\"$pid\" ".($target_page_id==$pid?$sel:'').">$link</option>"; |
|
176 |
} ?> |
|
177 |
</select> |
|
178 |
|
|
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><?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 |
</form> |
|
226 |
<input type="button" value="<?php echo $TEXT['CANCEL'] ?>" onclick="javascript: window.location = 'index.php';" style="width: 100px; margin-top: 5px;" /> |
|
227 |
</td> |
|
228 |
</tr> |
|
229 |
</table> |
|
230 |
|
|
231 |
</form> |
|
232 |
|
Also available in: Unified diff
Fixed bug in menu_link modul with wrong displayed pages tree (Thanks to thorn)