1 |
|
<?php
|
2 |
|
|
3 |
|
// $Id$
|
4 |
|
|
5 |
|
/*
|
6 |
|
|
7 |
|
Website Baker Project <http://www.websitebaker.org/>
|
8 |
|
Copyright (C) 2004-2008, 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 |
|
// get target page_id
|
30 |
|
$table = TABLE_PREFIX.'mod_menu_link';
|
31 |
|
$sql_result = $database->query("SELECT * FROM $table WHERE section_id = '$section_id'");
|
32 |
|
$sql_row = $sql_result->fetchRow();
|
33 |
|
$target_page_id = $sql_row['target_page_id'];
|
34 |
|
$anchor = $sql_row['anchor'];
|
35 |
|
$sel = ' selected';
|
36 |
|
|
37 |
|
// Get list of all visible page-links, except menu_links and actual page
|
38 |
|
$links = array();
|
39 |
|
$table_p = TABLE_PREFIX."pages";
|
40 |
|
$table_s = TABLE_PREFIX."sections";
|
41 |
|
if($query_page = $database->query("SELECT DISTINCT p.* FROM $table_p AS p INNER JOIN $table_s AS s ON p.page_id=s.page_id WHERE s.module != 'menu_link' AND p.page_id != '$page_id' AND parent = '0' ORDER BY position")) {
|
42 |
|
while($page = $query_page->fetchRow()) {
|
43 |
|
if($admin->page_is_visible($page)) {
|
44 |
|
$links[$page['page_id']]='/'.$page['menu_title'];
|
45 |
|
if($query_subpage = $database->query("SELECT DISTINCT p.* FROM $table_p AS p INNER JOIN $table_s AS s ON p.page_id=s.page_id WHERE s.module != 'menu_link' AND p.page_id != '$page_id' AND root_parent = '{$page['page_id']}' ORDER BY level")) {
|
46 |
|
while($sub = $query_subpage->fetchRow()) {
|
47 |
|
if($admin->page_is_visible($sub)) {
|
48 |
|
$parent_link = (array_key_exists($sub['parent'],$links))?$links[$sub['parent']]:"";
|
49 |
|
$links[$sub['page_id']]=$parent_link.'/'.$sub['page_title'];
|
50 |
|
}
|
51 |
|
}
|
52 |
|
}
|
53 |
|
}
|
54 |
|
}
|
55 |
|
}
|
56 |
|
// Get list of targets (id=... or <a name ...>) from pages in $links
|
57 |
|
$targets = array();
|
58 |
|
$table_mw = TABLE_PREFIX."mod_wysiwyg";
|
59 |
|
$table_s = TABLE_PREFIX."sections";
|
60 |
|
foreach($links as $pid=>$l) {
|
61 |
|
if($query_section = $database->query("SELECT section_id, module FROM $table_s WHERE page_id = '$pid' ORDER BY position")) {
|
62 |
|
while($section = $query_section->fetchRow()) {
|
63 |
|
$targets[$pid][] = "wb_section_{$section['section_id']}";
|
64 |
|
if($section['module'] == 'wysiwyg') {
|
65 |
|
if($query_page = $database->query("SELECT content FROM $table_mw WHERE section_id = '{$section['section_id']}' LIMIT 1")) {
|
66 |
|
$page = $query_page->fetchRow();
|
67 |
|
if(preg_match_all('/<(?:[^>]+id|\s*a[^>]+name)\s*=\s*"(.*)"/iuU',$page['content'], $match)) {
|
68 |
|
foreach($match[1] AS $t) {
|
69 |
|
$targets[$pid][] = $t;
|
70 |
|
}
|
71 |
|
}
|
72 |
|
}
|
73 |
|
}
|
74 |
|
}
|
75 |
|
}
|
76 |
|
}
|
77 |
|
// get target-window for actual page
|
78 |
|
$table = TABLE_PREFIX."pages";
|
79 |
|
$query_page = $database->query("SELECT target FROM $table WHERE page_id = '$page_id'");
|
80 |
|
$page = $query_page->fetchRow();
|
81 |
|
$target = $page['target'];
|
82 |
|
|
83 |
|
|
84 |
|
// script for target-select-box
|
85 |
|
?>
|
86 |
|
<script type="text/javascript">
|
87 |
|
function populate()
|
88 |
|
{
|
89 |
|
o=document.getElementById('page_link');
|
90 |
|
d=document.getElementById('page_target');
|
91 |
|
if(!d){return;}
|
92 |
|
var mitems=new Array();
|
93 |
|
mitems['0']=[' ','0'];
|
94 |
|
<?php
|
95 |
|
foreach($links AS $pid=>$link) {
|
96 |
|
$str="mitems['$pid']=[";
|
97 |
|
$str.="' ',";
|
98 |
|
$str.="'0',";
|
99 |
|
if(is_array($targets) && is_array($targets[$pid])) {
|
100 |
|
foreach($targets[$pid] AS $value) {
|
101 |
|
$str.="'#$value',";
|
102 |
|
$str.="'$value',";
|
103 |
|
}
|
104 |
|
$str=rtrim($str, ',');
|
105 |
|
$str.="];\n";
|
106 |
|
}
|
107 |
|
echo $str;
|
108 |
|
}
|
109 |
|
?>
|
110 |
|
d.options.length=0;
|
111 |
|
cur=mitems[o.options[o.selectedIndex].value];
|
112 |
|
if(!cur){return;}
|
113 |
|
d.options.length=cur.length/2;
|
114 |
|
j=0;
|
115 |
|
for(var i=0;i<cur.length;i=i+2)
|
116 |
|
{
|
117 |
|
d.options[j].text=cur[i];
|
118 |
|
d.options[j++].value=cur[i+1];
|
119 |
|
}
|
120 |
|
}
|
121 |
|
</script>
|
122 |
|
|
123 |
|
<form action="<?php echo WB_URL ?>/modules/menu_link/save.php" method="post">
|
124 |
|
<input type="hidden" name="page_id" value="<?php echo $page_id ?>" />
|
125 |
|
<input type="hidden" name="section_id" value="<?php echo $section_id ?>" />
|
126 |
|
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
127 |
|
<tr>
|
128 |
|
<td>
|
129 |
|
<?php echo $TEXT['LINK'].':' ?>
|
130 |
|
</td>
|
131 |
|
<td>
|
132 |
|
<select name="page_link" id="page_link" onchange="populate()" style="width: 50%" />
|
133 |
|
<option value="0"<?php echo $target_page_id=='0'?$sel:''?>><?php echo $TEXT['PLEASE_SELECT']; ?></option>
|
134 |
|
<?php foreach($links AS $pid=>$link) {
|
135 |
|
echo "<option value=\"$pid\" ".($target_page_id==$pid?$sel:'').">$link</option>";
|
136 |
|
} ?>
|
137 |
|
</select>
|
138 |
|
</td>
|
139 |
|
</tr>
|
140 |
|
<tr>
|
141 |
|
<td>
|
142 |
|
<?php echo $TEXT['ANCHOR'].':' ?>
|
143 |
|
</td>
|
144 |
|
<td>
|
145 |
|
<select name="page_target" id="page_target" onfocus="populate()" style="width: 50%" />
|
146 |
|
<option value="<?php echo $anchor ?>" selected><?php echo $anchor=='0'?' ':'#'.$anchor ?></option>
|
147 |
|
</select>
|
148 |
|
</td>
|
149 |
|
</tr>
|
150 |
|
<tr>
|
151 |
|
<td>
|
152 |
|
<?php echo $TEXT['TARGET'].':' ?>
|
153 |
|
</td>
|
154 |
|
<td>
|
155 |
|
<select name="target" style="width: 50%" />
|
156 |
|
<option value="_blank"<?php if($target=='_blank') echo ' selected'; ?>><?php echo $TEXT['NEW_WINDOW'] ?></option>
|
157 |
|
<option value="_self"<?php if($target=='_self') echo ' selected'; ?>><?php echo $TEXT['SAME_WINDOW'] ?></option>
|
158 |
|
<option value="_top"<?php if($target=='_top') echo ' selected'; ?>><?php echo $TEXT['TOP_FRAME'] ?></option>
|
159 |
|
</select>
|
160 |
|
</td>
|
161 |
|
</tr>
|
162 |
|
</table>
|
163 |
|
|
164 |
|
<br />
|
165 |
|
|
166 |
|
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
167 |
|
<tr>
|
168 |
|
<td align="left">
|
169 |
|
<input type="submit" value="<?php echo $TEXT['SAVE'] ?>" style="width: 100px; margin-top: 5px;" />
|
170 |
|
</td>
|
171 |
|
<td align="right">
|
172 |
|
</form>
|
173 |
|
<input type="button" value="<?php echo $TEXT['CANCEL'] ?>" onclick="javascript: window.location = 'index.php';" style="width: 100px; margin-top: 5px;" />
|
174 |
|
</td>
|
175 |
|
</tr>
|
176 |
|
</table>
|
177 |
|
|
178 |
|
</form>
|
179 |
|
|
|
1 |
<?php
|
|
2 |
|
|
3 |
// $Id$
|
|
4 |
|
|
5 |
/*
|
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/>
|
|
8 |
Copyright (C) 2004-2008, 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 |
// get target page_id
|
|
30 |
$table = TABLE_PREFIX.'mod_menu_link';
|
|
31 |
$sql_result = $database->query("SELECT * FROM $table WHERE section_id = '$section_id'");
|
|
32 |
$sql_row = $sql_result->fetchRow();
|
|
33 |
$target_page_id = $sql_row['target_page_id'];
|
|
34 |
$anchor = $sql_row['anchor'];
|
|
35 |
$sel = ' selected';
|
|
36 |
|
|
37 |
// Get list of all visible page-links, except menu_links and actual page
|
|
38 |
$links = array();
|
|
39 |
$table_p = TABLE_PREFIX."pages";
|
|
40 |
$table_s = TABLE_PREFIX."sections";
|
|
41 |
if($query_page = $database->query("SELECT DISTINCT p.* FROM $table_p AS p INNER JOIN $table_s AS s ON p.page_id=s.page_id WHERE s.module != 'menu_link' AND p.page_id != '$page_id' AND parent = '0' ORDER BY position")) {
|
|
42 |
while($page = $query_page->fetchRow()) {
|
|
43 |
if($admin->page_is_visible($page)) {
|
|
44 |
$links[$page['page_id']]='/'.$page['menu_title'];
|
|
45 |
if($query_subpage = $database->query("SELECT DISTINCT p.* FROM $table_p AS p INNER JOIN $table_s AS s ON p.page_id=s.page_id WHERE s.module != 'menu_link' AND p.page_id != '$page_id' AND root_parent = '{$page['page_id']}' ORDER BY level")) {
|
|
46 |
while($sub = $query_subpage->fetchRow()) {
|
|
47 |
if($admin->page_is_visible($sub)) {
|
|
48 |
$parent_link = (array_key_exists($sub['parent'],$links))?$links[$sub['parent']]:"";
|
|
49 |
$links[$sub['page_id']]=$parent_link.'/'.$sub['page_title'];
|
|
50 |
}
|
|
51 |
}
|
|
52 |
}
|
|
53 |
}
|
|
54 |
}
|
|
55 |
}
|
|
56 |
// Get list of targets (id=... or <a name ...>) from pages in $links
|
|
57 |
$targets = array();
|
|
58 |
$table_mw = TABLE_PREFIX."mod_wysiwyg";
|
|
59 |
$table_s = TABLE_PREFIX."sections";
|
|
60 |
foreach($links as $pid=>$l) {
|
|
61 |
if($query_section = $database->query("SELECT section_id, module FROM $table_s WHERE page_id = '$pid' ORDER BY position")) {
|
|
62 |
while($section = $query_section->fetchRow()) {
|
|
63 |
$targets[$pid][] = "wb_section_{$section['section_id']}";
|
|
64 |
if($section['module'] == 'wysiwyg') {
|
|
65 |
if($query_page = $database->query("SELECT content FROM $table_mw WHERE section_id = '{$section['section_id']}' LIMIT 1")) {
|
|
66 |
$page = $query_page->fetchRow();
|
|
67 |
if(preg_match_all('/<(?:[^>]+id|\s*a[^>]+name)\s*=\s*"(.*)"/iuU',$page['content'], $match)) {
|
|
68 |
foreach($match[1] AS $t) {
|
|
69 |
$targets[$pid][] = $t;
|
|
70 |
}
|
|
71 |
}
|
|
72 |
}
|
|
73 |
}
|
|
74 |
}
|
|
75 |
}
|
|
76 |
}
|
|
77 |
// get target-window for actual page
|
|
78 |
$table = TABLE_PREFIX."pages";
|
|
79 |
$query_page = $database->query("SELECT target FROM $table WHERE page_id = '$page_id'");
|
|
80 |
$page = $query_page->fetchRow();
|
|
81 |
$target = $page['target'];
|
|
82 |
|
|
83 |
|
|
84 |
// script for target-select-box
|
|
85 |
?>
|
|
86 |
<script type="text/javascript">
|
|
87 |
function populate()
|
|
88 |
{
|
|
89 |
o=document.getElementById('page_link');
|
|
90 |
d=document.getElementById('page_target');
|
|
91 |
if(!d){return;}
|
|
92 |
var mitems=new Array();
|
|
93 |
mitems['0']=[' ','0'];
|
|
94 |
<?php
|
|
95 |
foreach($links AS $pid=>$link) {
|
|
96 |
$str="mitems['$pid']=[";
|
|
97 |
$str.="' ',";
|
|
98 |
$str.="'0',";
|
|
99 |
if(is_array($targets) && is_array($targets[$pid])) {
|
|
100 |
foreach($targets[$pid] AS $value) {
|
|
101 |
$str.="'#$value',";
|
|
102 |
$str.="'$value',";
|
|
103 |
}
|
|
104 |
$str=rtrim($str, ',');
|
|
105 |
$str.="];\n";
|
|
106 |
}
|
|
107 |
echo $str;
|
|
108 |
}
|
|
109 |
?>
|
|
110 |
d.options.length=0;
|
|
111 |
cur=mitems[o.options[o.selectedIndex].value];
|
|
112 |
if(!cur){return;}
|
|
113 |
d.options.length=cur.length/2;
|
|
114 |
j=0;
|
|
115 |
for(var i=0;i<cur.length;i=i+2)
|
|
116 |
{
|
|
117 |
d.options[j].text=cur[i];
|
|
118 |
d.options[j++].value=cur[i+1];
|
|
119 |
}
|
|
120 |
}
|
|
121 |
</script>
|
|
122 |
|
|
123 |
<form action="<?php echo WB_URL ?>/modules/menu_link/save.php" method="post">
|
|
124 |
<input type="hidden" name="page_id" value="<?php echo $page_id ?>" />
|
|
125 |
<input type="hidden" name="section_id" value="<?php echo $section_id ?>" />
|
|
126 |
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
|
127 |
<tr>
|
|
128 |
<td>
|
|
129 |
<?php echo $TEXT['LINK'].':' ?>
|
|
130 |
</td>
|
|
131 |
<td>
|
|
132 |
<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>
|
|
134 |
<?php foreach($links AS $pid=>$link) {
|
|
135 |
echo "<option value=\"$pid\" ".($target_page_id==$pid?$sel:'').">$link</option>";
|
|
136 |
} ?>
|
|
137 |
</select>
|
|
138 |
</td>
|
|
139 |
</tr>
|
|
140 |
<tr>
|
|
141 |
<td>
|
|
142 |
<?php echo $TEXT['ANCHOR'].':' ?>
|
|
143 |
</td>
|
|
144 |
<td>
|
|
145 |
<select name="page_target" id="page_target" onfocus="populate()" style="width:250px;" />
|
|
146 |
<option value="<?php echo $anchor ?>" selected><?php echo $anchor=='0'?' ':'#'.$anchor ?></option>
|
|
147 |
</select>
|
|
148 |
</td>
|
|
149 |
</tr>
|
|
150 |
<tr>
|
|
151 |
<td>
|
|
152 |
<?php echo $TEXT['TARGET'].':' ?>
|
|
153 |
</td>
|
|
154 |
<td>
|
|
155 |
<select name="target" style="width:250px;" />
|
|
156 |
<option value="_blank"<?php if($target=='_blank') echo ' selected'; ?>><?php echo $TEXT['NEW_WINDOW'] ?></option>
|
|
157 |
<option value="_self"<?php if($target=='_self') echo ' selected'; ?>><?php echo $TEXT['SAME_WINDOW'] ?></option>
|
|
158 |
<option value="_top"<?php if($target=='_top') echo ' selected'; ?>><?php echo $TEXT['TOP_FRAME'] ?></option>
|
|
159 |
</select>
|
|
160 |
</td>
|
|
161 |
</tr>
|
|
162 |
</table>
|
|
163 |
|
|
164 |
<br />
|
|
165 |
|
|
166 |
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
|
167 |
<tr>
|
|
168 |
<td align="left">
|
|
169 |
<input type="submit" value="<?php echo $TEXT['SAVE'] ?>" style="width: 100px; margin-top: 5px;" />
|
|
170 |
</td>
|
|
171 |
<td align="right">
|
|
172 |
</form>
|
|
173 |
<input type="button" value="<?php echo $TEXT['CANCEL'] ?>" onclick="javascript: window.location = 'index.php';" style="width: 100px; margin-top: 5px;" />
|
|
174 |
</td>
|
|
175 |
</tr>
|
|
176 |
</table>
|
|
177 |
|
|
178 |
</form>
|
|
179 |
|
fixed bug in menu_link module (IE 7 did not show the select boxes at all)