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 1923 darkviper
$mLang = Translate::getinstance();
21
$mLang->enableAddon('admin\addons');
22 1386 Luisehahne
require_once(WB_PATH .'/framework/functions.php');
23
require_once(WB_PATH.'/framework/class.admin.php');
24
// No print admin header
25
$admin = new admin('Addons', 'modules_view', false);
26 1457 Luisehahne
if( !$admin->checkFTAN() )
27
{
28 1467 Luisehahne
	$admin->print_header();
29 1923 darkviper
	$admin->print_error($mLang->MESSAGE_GENERIC_SECURITY_ACCESS);
30 1457 Luisehahne
}
31
// After check print the header
32
$admin->print_header();
33 1386 Luisehahne
34 1712 Luisehahne
if(!isset($_POST['file']) OR $_POST['file'] == "") {
35 1923 darkviper
	$admin->print_error($mLang->MESSAGE_GENERIC_FORGOT_OPTIONS);
36 1712 Luisehahne
} else {
37
	$file = preg_replace('/[^a-z0-9_-]/i', "", $_POST['file']);  // fix secunia 2010-92-2
38
}
39
40
// Check if the template exists
41
if(!is_dir(WB_PATH.'/modules/'.$file)) {
42 1992 Luisehahne
	$admin->print_error($file.'::'.$mLang->MESSAGE_GENERIC_NOT_INSTALLED);
43 1712 Luisehahne
}
44
45
// Check if the template exists
46
if(!is_readable(WB_PATH.'/modules/'.$file)) {
47 1923 darkviper
	$admin->print_error($mLang->MESSAGE_ADMIN_INSUFFICIENT_PRIVELLIGES);
48 1712 Luisehahne
}
49 1529 Luisehahne
// Setup template object, parse vars to it, then parse it
50
// Create new template object
51 1712 Luisehahne
$template = new Template(dirname($admin->correct_theme_source('modules_details.htt')),'keep');
52 1529 Luisehahne
// $template->debug = true;
53 1386 Luisehahne
$template->set_file('page', 'modules_details.htt');
54
$template->set_block('page', 'main_block', 'main');
55
56
// Insert values
57 1923 darkviper
$module = false;
58 1992 Luisehahne
$sql = 'SELECT * FROM  `'.TABLE_PREFIX.'addons` '
59
     . 'WHERE `type` = \'module\' '
60
     . 'AND `directory`= \''.$file.'\' ';
61 1923 darkviper
if( ($result = $database->query($sql)) ){
62
	$module = $result->fetchRow(MYSQL_ASSOC);
63 1386 Luisehahne
}
64 1923 darkviper
if(!$module) { $admin->print_error($mLang->MESSAGE_GENERIC_NOT_INSTALLED); }
65 1712 Luisehahne
/*-- insert all needed vars from language files ----------------------------------------*/
66
$template->set_var($mLang->getLangArray());
67
68 1386 Luisehahne
// check if a module description exists for the displayed backend language
69
$tool_description = false;
70
if(function_exists('file_get_contents') && file_exists(WB_PATH.'/modules/'.$file.'/languages/'.LANGUAGE .'.php')) {
71
	// read contents of the module language file into string
72
	$data = @file_get_contents(WB_PATH .'/modules/' .$file .'/languages/' .LANGUAGE .'.php');
73
	// use regular expressions to fetch the content of the variable from the string
74
	$tool_description = get_variable_content('module_description', $data, false, false);
75
	// replace optional placeholder {WB_URL} with value stored in config.php
76
	if($tool_description !== false && strlen(trim($tool_description)) != 0) {
77
		$tool_description = str_replace('{WB_URL}', WB_URL, $tool_description);
78
	} else {
79
		$tool_description = false;
80
	}
81 1712 Luisehahne
}
82 1386 Luisehahne
if($tool_description !== false) {
83
	// Override the module-description with correct desription in users language
84
	$module['description'] = $tool_description;
85
}
86
87
$template->set_var(array(
88
								'NAME' => $module['name'],
89
								'AUTHOR' => $module['author'],
90
								'DESCRIPTION' => $module['description'],
91
								'VERSION' => $module['version'],
92
								'DESIGNED_FOR' => $module['platform'],
93
								'ADMIN_URL' => ADMIN_URL,
94
								'WB_URL' => WB_URL,
95
								'THEME_URL' => THEME_URL
96
								)
97
						);
98 1712 Luisehahne
99 1386 Luisehahne
switch ($module['function']) {
100
	case NULL:
101 1913 Luisehahne
		$type_name = $mLang->TEXT_UNKNOWN;
102 1386 Luisehahne
		break;
103
	case 'page':
104 1913 Luisehahne
		$type_name = $mLang->TEXT_PAGE;
105 1386 Luisehahne
		break;
106
	case 'wysiwyg':
107 1913 Luisehahne
		$type_name = $mLang->TEXT_WYSIWYG_EDITOR;
108 1386 Luisehahne
		break;
109
	case 'tool':
110 1913 Luisehahne
		$type_name = $mLang->TEXT_ADMINISTRATION_TOOL;
111 1386 Luisehahne
		break;
112
	case 'admin':
113 1913 Luisehahne
		$type_name = $mLang->TEXT_ADMIN;
114 1386 Luisehahne
		break;
115
	case 'administration':
116 1913 Luisehahne
		$type_name = $mLang->TEXT_ADMINISTRATION;
117 1386 Luisehahne
		break;
118
	case 'snippet':
119 1913 Luisehahne
		$type_name = $mLang->TEXT_CODE_SNIPPET;
120 1386 Luisehahne
		break;
121
	default:
122 1913 Luisehahne
		$type_name = $mLang->TEXT_UNKNOWN;
123 1386 Luisehahne
}
124
$template->set_var('TYPE', $type_name);
125
126 1913 Luisehahne
127 1386 Luisehahne
// Parse module object
128
$template->parse('main', 'main_block', false);
129
$template->pparse('output', 'page');
130
// Print admin footer
131
$admin->print_footer();