Project

General

Profile

1 1386 Luisehahne
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         modules
6 1529 Luisehahne
 * @author          Ryan Djurovich, WebsiteBaker Project
7 1913 Luisehahne
 * @copyright       2009-2013, WebsiteBaker Org. e.V.
8
 * @link            http://www.websitebaker.org/
9 1386 Luisehahne
 * @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$
13 1913 Luisehahne
 * @filesource      $HeadURL$
14 1457 Luisehahne
 * @lastmodified    $Date$
15 1386 Luisehahne
 *
16
 */
17
18
// Include the config file
19
require('../../config.php');
20
require_once(WB_PATH .'/framework/functions.php');
21
require_once(WB_PATH.'/framework/class.admin.php');
22
// No print admin header
23
$admin = new admin('Addons', 'modules_view', false);
24 1457 Luisehahne
if( !$admin->checkFTAN() )
25
{
26 1467 Luisehahne
	$admin->print_header();
27 1457 Luisehahne
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
28
}
29
// After check print the header
30
$admin->print_header();
31 1386 Luisehahne
32 1913 Luisehahne
//$mLang = ModLanguage::getInstance();
33
//$mLang->setLanguage(ADMIN_PATH.'/addons/languages/', LANGUAGE, DEFAULT_LANGUAGE);
34
$mLang = Translate::getinstance();
35
$mLang->enableAddon('admin\addons');
36 1712 Luisehahne
37
if(!isset($_POST['file']) OR $_POST['file'] == "") {
38
	$admin->print_error($MESSAGE['GENERIC_FORGOT_OPTIONS']);
39
} else {
40
	$file = preg_replace('/[^a-z0-9_-]/i', "", $_POST['file']);  // fix secunia 2010-92-2
41
}
42
43
// Check if the template exists
44
if(!is_dir(WB_PATH.'/modules/'.$file)) {
45
	$admin->print_error($MESSAGE['GENERIC_NOT_INSTALLED']);
46
}
47
48
// Check if the template exists
49
if(!is_readable(WB_PATH.'/modules/'.$file)) {
50
	$admin->print_error($MESSAGE['ADMIN_INSUFFICIENT_PRIVELLIGES']);
51
}
52
53
/*
54 1386 Luisehahne
// Get module name
55
if(!isset($_POST['file']) OR $_POST['file'] == "")
56
{
57
	header("Location: index.php");
58
	exit(0);
59
}
60
else
61
{
62 1494 Luisehahne
	$file = preg_replace('/[^a-z0-9_-]/i', "", $_POST['file']);  // fix secunia 2010-92-1
63 1386 Luisehahne
}
64
65
// Check if the module exists
66 1712 Luisehahne
if(!is_readable(WB_PATH.'/modules/'.$file)) {
67 1386 Luisehahne
	header("Location: index.php");
68
	exit(0);
69
}
70 1712 Luisehahne
*/
71 1386 Luisehahne
72 1529 Luisehahne
// Setup template object, parse vars to it, then parse it
73
// Create new template object
74 1712 Luisehahne
$template = new Template(dirname($admin->correct_theme_source('modules_details.htt')),'keep');
75 1529 Luisehahne
// $template->debug = true;
76 1386 Luisehahne
$template->set_file('page', 'modules_details.htt');
77
$template->set_block('page', 'main_block', 'main');
78
79
// Insert values
80
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND directory = '$file'");
81
if($result->numRows() > 0) {
82
	$module = $result->fetchRow();
83
}
84
85 1712 Luisehahne
/*-- insert all needed vars from language files ----------------------------------------*/
86
$template->set_var($mLang->getLangArray());
87
88 1386 Luisehahne
// check if a module description exists for the displayed backend language
89
$tool_description = false;
90
if(function_exists('file_get_contents') && file_exists(WB_PATH.'/modules/'.$file.'/languages/'.LANGUAGE .'.php')) {
91
	// read contents of the module language file into string
92
	$data = @file_get_contents(WB_PATH .'/modules/' .$file .'/languages/' .LANGUAGE .'.php');
93
	// use regular expressions to fetch the content of the variable from the string
94
	$tool_description = get_variable_content('module_description', $data, false, false);
95
	// replace optional placeholder {WB_URL} with value stored in config.php
96
	if($tool_description !== false && strlen(trim($tool_description)) != 0) {
97
		$tool_description = str_replace('{WB_URL}', WB_URL, $tool_description);
98
	} else {
99
		$tool_description = false;
100
	}
101 1712 Luisehahne
}
102 1386 Luisehahne
if($tool_description !== false) {
103
	// Override the module-description with correct desription in users language
104
	$module['description'] = $tool_description;
105
}
106
107
$template->set_var(array(
108
								'NAME' => $module['name'],
109
								'AUTHOR' => $module['author'],
110
								'DESCRIPTION' => $module['description'],
111
								'VERSION' => $module['version'],
112
								'DESIGNED_FOR' => $module['platform'],
113
								'ADMIN_URL' => ADMIN_URL,
114
								'WB_URL' => WB_URL,
115
								'THEME_URL' => THEME_URL
116
								)
117
						);
118 1712 Luisehahne
119 1386 Luisehahne
switch ($module['function']) {
120
	case NULL:
121 1913 Luisehahne
		$type_name = $mLang->TEXT_UNKNOWN;
122 1386 Luisehahne
		break;
123
	case 'page':
124 1913 Luisehahne
		$type_name = $mLang->TEXT_PAGE;
125 1386 Luisehahne
		break;
126
	case 'wysiwyg':
127 1913 Luisehahne
		$type_name = $mLang->TEXT_WYSIWYG_EDITOR;
128 1386 Luisehahne
		break;
129
	case 'tool':
130 1913 Luisehahne
		$type_name = $mLang->TEXT_ADMINISTRATION_TOOL;
131 1386 Luisehahne
		break;
132
	case 'admin':
133 1913 Luisehahne
		$type_name = $mLang->TEXT_ADMIN;
134 1386 Luisehahne
		break;
135
	case 'administration':
136 1913 Luisehahne
		$type_name = $mLang->TEXT_ADMINISTRATION;
137 1386 Luisehahne
		break;
138
	case 'snippet':
139 1913 Luisehahne
		$type_name = $mLang->TEXT_CODE_SNIPPET;
140 1386 Luisehahne
		break;
141
	default:
142 1913 Luisehahne
		$type_name = $mLang->TEXT_UNKNOWN;
143 1386 Luisehahne
}
144
$template->set_var('TYPE', $type_name);
145
146 1913 Luisehahne
147 1386 Luisehahne
// Parse module object
148
$template->parse('main', 'main_block', false);
149
$template->pparse('output', 'page');
150
151
// Print admin footer
152
$admin->print_footer();