Project

General

Profile

1 4 ryan
<?php
2
3 36 stefan
// $Id$
4 4 ryan
5
/*
6
7
 Website Baker Project <http://www.websitebaker.org/>
8 519 Ruebenwurz
 Copyright (C) 2004-2008, Ryan Djurovich
9 4 ryan
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 545 thorn
// Must include code to stop this file being accessed directly
27 543 thorn
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
28 4 ryan
29 543 thorn
// 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 4 ryan
35 543 thorn
// Get list of all visible page-links, except menu_links and actual page
36
$table_p = TABLE_PREFIX."pages";
37
$table_s = TABLE_PREFIX."sections";
38
$query_page = $database->query("SELECT DISTINCT p.* FROM $table_p AS p, $table_s AS s WHERE p.page_id=s.page_id AND s.module != 'menu_link' AND p.page_id != '$page_id' AND parent = '0' ORDER BY position");
39
if($query_page->numRows() > 0) {
40
	while($page = $query_page->fetchRow()) {
41
		if($admin->page_is_visible($page)) {
42
			$links[$page['page_id']]='/'.$page['menu_title'];
43
			$query_subpage = $database->query("SELECT DISTINCT p.* FROM $table_p AS p, $table_s AS s WHERE p.page_id=s.page_id AND s.module != 'menu_link' AND p.page_id != '$page_id' AND root_parent = '{$page['page_id']}' ORDER BY level");
44
			if($query_subpage->numRows() > 0) {
45
				while($sub = $query_subpage->fetchRow()) {
46
					if($admin->page_is_visible($sub)) {
47 545 thorn
						$parent_link = (array_key_exists($sub['parent'],$links))?$links[$sub['parent']]:"";
48
						$links[$sub['page_id']]=$parent_link.'/'.$sub['menu_title'];
49 543 thorn
					}
50
				}
51
			}
52
		}
53
	}
54 4 ryan
}
55
56 543 thorn
// get URL-target for actual page
57
$table = TABLE_PREFIX."pages";
58
$query_page = $database->query("SELECT target FROM $table WHERE page_id = '$page_id'");
59
$page = $query_page->fetchRow();
60
$target = $page['target'];
61 4 ryan
62 543 thorn
?>
63
<form action="<?php echo WB_URL ?>/modules/menu_link/save.php" method="post">
64
<input type="hidden" name="page_id" value="<?php echo $page_id ?>" />
65
<input type="hidden" name="section_id" value="<?php echo $section_id ?>" />
66
<table cellpadding="0" cellspacing="0" border="0" width="100%">
67
<tr>
68
	<td>
69
		<?php echo $TEXT['LINK'].':' ?>
70
	</td>
71
	<td>
72
		<select name="link" style="WIDTH: 100%;" value="<?php echo "" ?>" />
73
		<?php
74
		foreach($links as $id=>$l) { ?>
75
			<option value="<?php echo $id ?>"<?php if($id==$target_page_id) echo ' selected'; ?>><?php echo $l ?></option>
76
		<?php } ?>
77
	</td>
78
</tr>
79
<tr>
80
	<td>
81
		<?php echo $TEXT['TARGET'].':' ?>
82
	</td>
83
	<td>
84
		<select name="target" style="WIDTH: 100%;" value="<?php echo "" ?>" />
85
			<option value="_blank"<?php if($target=='_blank') echo ' selected'; ?>><?php echo $TEXT['NEW_WINDOW'] ?></option>
86
			<option value="_self"<?php if($target=='_self') echo ' selected'; ?>><?php echo $TEXT['SAME_WINDOW'] ?></option>
87
			<option value="_top"<?php if($target=='_top') echo ' selected'; ?>><?php echo $TEXT['TOP_FRAME'] ?></option>
88
		</select>
89
	</td>
90
</tr>
91
</table>
92
93
<br />
94
95
<table cellpadding="0" cellspacing="0" border="0" width="100%">
96
<tr>
97
	<td align="left">
98
		<input type="submit" value="<?php echo $TEXT['SAVE'] ?>" style="width: 100px; margin-top: 5px;" />
99
	</td>
100
	<td align="right">
101
		</form>
102
		<input type="button" value="<?php echo $TEXT['CANCEL'] ?>" onclick="javascript: window.location = 'index.php';" style="width: 100px; margin-top: 5px;" />
103
	</td>
104
</tr>
105
</table>
106
107
</form>