Project

General

Profile

« Previous | Next » 

Revision 543

Added by thorn almost 17 years ago

module menu_link: fixed page-deleteing-bug and some odd behavior, added table mod_menu_link

View differences:

modify.php
23 23

  
24 24
*/
25 25

  
26
// Setup template object
27
$template = new Template(WB_PATH.'/modules/menu_link');
28
$template->set_file('page', 'modify.html');
29
$template->set_block('page', 'main_block', 'main');
26
// Must include code to stop this file being access directly
27
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
30 28

  
31
// Get page link and target
32
$query_info = "SELECT link,target FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
33
$get_info = $database->query($query_info);
34
$fetch_info = $get_info->fetchRow();
35
$link = ($fetch_info['link']);
36
$target = $fetch_info['target'];
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'];
37 34

  
38
// Insert vars
39
$template->set_var(array(
40
								'PAGE_ID' => $page_id,
41
								'WB_URL' => WB_URL,
42
								'LINK' => $link,
43
								'TEXT_LINK' => $TEXT['LINK'],
44
								'TEXT_TARGET' => $TEXT['TARGET'],
45
								'TEXT_NEW_WINDOW' => $TEXT['NEW_WINDOW'],
46
								'TEXT_SAME_WINDOW' => $TEXT['SAME_WINDOW'],
47
								'TEXT_TOP_FRAME' => $TEXT['TOP_FRAME'],
48
								'TEXT_SAVE' => $TEXT['SAVE'],
49
								'TEXT_CANCEL' => $TEXT['CANCEL'],
50
								'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT']
51
								)
52
						);
53

  
54
// Select what the page target is
55
switch ($target) {
56
	case '_top':
57
		$template->set_var('TOP_SELECTED', ' selected');
58
		break;
59
	case '_self':
60
		$template->set_var('SELF_SELECTED', ' selected');
61
		break;
62
	case '_blank':
63
		$template->set_var('BLANK_SELECTED', ' selected');
64
		break;
35
// 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
						$links[$sub['page_id']]=$links[$sub['parent']].'/'.$sub['menu_title'];
48
					}
49
				}
50
			}
51
		}
52
	}
65 53
}
66 54

  
67
// Parse template object
68
$template->parse('main', 'main_block', false);
69
$template->pparse('output', 'page');
55
// get URL-target for actual page
56
$table = TABLE_PREFIX."pages";
57
$query_page = $database->query("SELECT target FROM $table WHERE page_id = '$page_id'");
58
$page = $query_page->fetchRow();
59
$target = $page['target'];
70 60

  
71
?>
61
?>
62
<form action="<?php echo WB_URL ?>/modules/menu_link/save.php" method="post">
63
<input type="hidden" name="page_id" value="<?php echo $page_id ?>" />
64
<input type="hidden" name="section_id" value="<?php echo $section_id ?>" />
65
<table cellpadding="0" cellspacing="0" border="0" width="100%">
66
<tr>
67
	<td>
68
		<?php echo $TEXT['LINK'].':' ?>
69
	</td>
70
	<td>
71
		<select name="link" style="WIDTH: 100%;" value="<?php echo "" ?>" />
72
		<?php
73
		foreach($links as $id=>$l) { ?>
74
			<option value="<?php echo $id ?>"<?php if($id==$target_page_id) echo ' selected'; ?>><?php echo $l ?></option>
75
		<?php } ?>
76
	</td>
77
</tr>
78
<tr>
79
	<td>
80
		<?php echo $TEXT['TARGET'].':' ?>
81
	</td>
82
	<td>
83
		<select name="target" style="WIDTH: 100%;" value="<?php echo "" ?>" />
84
			<option value="_blank"<?php if($target=='_blank') echo ' selected'; ?>><?php echo $TEXT['NEW_WINDOW'] ?></option>
85
			<option value="_self"<?php if($target=='_self') echo ' selected'; ?>><?php echo $TEXT['SAME_WINDOW'] ?></option>
86
			<option value="_top"<?php if($target=='_top') echo ' selected'; ?>><?php echo $TEXT['TOP_FRAME'] ?></option>
87
		</select>
88
	</td>
89
</tr>
90
</table>
91

  
92
<br />
93

  
94
<table cellpadding="0" cellspacing="0" border="0" width="100%">
95
<tr>
96
	<td align="left">
97
		<input type="submit" value="<?php echo $TEXT['SAVE'] ?>" style="width: 100px; margin-top: 5px;" />
98
	</td>
99
	<td align="right">
100
		</form>
101
		<input type="button" value="<?php echo $TEXT['CANCEL'] ?>" onclick="javascript: window.location = 'index.php';" style="width: 100px; margin-top: 5px;" />
102
	</td>
103
</tr>
104
</table>
105

  
106
</form>
107

  

Also available in: Unified diff