1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category modules
|
5
|
* @package Menu Link
|
6
|
* @author Ryan Djurovich, WebsiteBaker Project, Norbert Heimsath
|
7
|
* @copyright 2009-2012, Website Baker Org. e.V.
|
8
|
* @link http://www.websitebaker2.org/
|
9
|
* @license http://www.gnu.org/licenses/gpl.html
|
10
|
* @platform WebsiteBaker 2.8.x
|
11
|
* @requirements PHP 5.2.2 and higher
|
12
|
* @version $Id: view.php 1696 2012-08-27 11:24:21Z Luisehahne $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/menu_link/view.php $
|
14
|
* @lastmodified $Date: 2012-08-27 13:24:21 +0200 (Mon, 27 Aug 2012) $
|
15
|
*
|
16
|
*/
|
17
|
|
18
|
// Must include code to stop this file being access directly
|
19
|
/* -------------------------------------------------------- */
|
20
|
if(defined('WB_PATH') == false)
|
21
|
{
|
22
|
// Stop this file being access directly
|
23
|
die('<h2 style="color:red;margin:3em auto;text-align:center;">Cannot access this file directly</h2>');
|
24
|
}
|
25
|
/* -------------------------------------------------------- */
|
26
|
|
27
|
// check if module language file exists for the language set by the user (e.g. DE, EN)
|
28
|
if(!file_exists(WB_PATH .'/modules/menu_link/languages/'.LANGUAGE .'.php')) {
|
29
|
// no module language file exists for the language set by the user, include default module language file EN.php
|
30
|
require_once(WB_PATH .'/modules/menu_link/languages/EN.php');
|
31
|
} else {
|
32
|
// a module language file exists for the language defined by the user, load it
|
33
|
require_once(WB_PATH .'/modules/menu_link/languages/'.LANGUAGE .'.php');
|
34
|
}
|
35
|
|
36
|
|
37
|
// redirect menu-link
|
38
|
$this_page_id = PAGE_ID;
|
39
|
|
40
|
$php43 = version_compare(phpversion(), '4.3', '>=');
|
41
|
|
42
|
$sql = 'SELECT `module`, `block` FROM `'.TABLE_PREFIX.'sections` ';
|
43
|
$sql .= 'WHERE `page_id` = '.(int)$this_page_id.' AND `module` = "menu_link"';
|
44
|
$query_this_module = $database->query($sql);
|
45
|
if($query_this_module->numRows() == 1) // This is a menu_link. Get link of target-page and redirect
|
46
|
{
|
47
|
// get target_page_id
|
48
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_menu_link` WHERE `page_id` = '.(int)$this_page_id;
|
49
|
$query_tpid = $database->query($sql);
|
50
|
if($query_tpid->numRows() == 1)
|
51
|
{
|
52
|
$res = $query_tpid->fetchRow();
|
53
|
$target_page_id = $res['target_page_id'];
|
54
|
$redirect_type = $res['redirect_type'];
|
55
|
$anchor = ($res['anchor'] != '0' ? '#'.(string)$res['anchor'] : '');
|
56
|
$extern = $res['extern'];
|
57
|
// set redirect-type
|
58
|
if($redirect_type == 301)
|
59
|
{
|
60
|
if($php43)
|
61
|
{
|
62
|
@header('HTTP/1.1 301 Moved Permanently', TRUE, 301);
|
63
|
}
|
64
|
else
|
65
|
{
|
66
|
@header('HTTP/1.1 301 Moved Permanently');
|
67
|
}
|
68
|
}
|
69
|
if($target_page_id == -1)
|
70
|
{
|
71
|
if($extern != '')
|
72
|
{
|
73
|
$target_url = $extern.$anchor;
|
74
|
header('Location: '.$target_url);
|
75
|
exit;
|
76
|
}
|
77
|
}
|
78
|
else
|
79
|
{
|
80
|
// get link of target-page
|
81
|
$sql = 'SELECT `link` FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$target_page_id;
|
82
|
$target_page_link = $database->get_one($sql);
|
83
|
if($target_page_link != null)
|
84
|
{
|
85
|
$target_url = WB_URL.PAGES_DIRECTORY.$target_page_link.PAGE_EXTENSION.$anchor;
|
86
|
header('Location: '.$target_url);
|
87
|
exit;
|
88
|
}
|
89
|
}
|
90
|
}
|
91
|
} else {
|
92
|
|
93
|
?>
|
94
|
|
95
|
<a href="<?php echo WB_URL; ?>">
|
96
|
<?php echo $MOD_MENU_LINK['TEXT']; ?>
|
97
|
</a>
|
98
|
<?php }
|