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