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 |
1923
|
darkviper
|
$admin->print_error($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 |
|
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` '
|
59 |
|
|
. 'WHERE `type`=\'module\' AND `directory`=\''.$file.'\'';
|
60 |
|
|
if( ($result = $database->query($sql)) ){
|
61 |
|
|
$module = $result->fetchRow(MYSQL_ASSOC);
|
62 |
1386
|
Luisehahne
|
}
|
63 |
1923
|
darkviper
|
if(!$module) { $admin->print_error($mLang->MESSAGE_GENERIC_NOT_INSTALLED); }
|
64 |
1712
|
Luisehahne
|
/*-- insert all needed vars from language files ----------------------------------------*/
|
65 |
|
|
$template->set_var($mLang->getLangArray());
|
66 |
|
|
|
67 |
1386
|
Luisehahne
|
// check if a module description exists for the displayed backend language
|
68 |
|
|
$tool_description = false;
|
69 |
|
|
if(function_exists('file_get_contents') && file_exists(WB_PATH.'/modules/'.$file.'/languages/'.LANGUAGE .'.php')) {
|
70 |
|
|
// read contents of the module language file into string
|
71 |
|
|
$data = @file_get_contents(WB_PATH .'/modules/' .$file .'/languages/' .LANGUAGE .'.php');
|
72 |
|
|
// use regular expressions to fetch the content of the variable from the string
|
73 |
|
|
$tool_description = get_variable_content('module_description', $data, false, false);
|
74 |
|
|
// replace optional placeholder {WB_URL} with value stored in config.php
|
75 |
|
|
if($tool_description !== false && strlen(trim($tool_description)) != 0) {
|
76 |
|
|
$tool_description = str_replace('{WB_URL}', WB_URL, $tool_description);
|
77 |
|
|
} else {
|
78 |
|
|
$tool_description = false;
|
79 |
|
|
}
|
80 |
1712
|
Luisehahne
|
}
|
81 |
1386
|
Luisehahne
|
if($tool_description !== false) {
|
82 |
|
|
// Override the module-description with correct desription in users language
|
83 |
|
|
$module['description'] = $tool_description;
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
$template->set_var(array(
|
87 |
|
|
'NAME' => $module['name'],
|
88 |
|
|
'AUTHOR' => $module['author'],
|
89 |
|
|
'DESCRIPTION' => $module['description'],
|
90 |
|
|
'VERSION' => $module['version'],
|
91 |
|
|
'DESIGNED_FOR' => $module['platform'],
|
92 |
|
|
'ADMIN_URL' => ADMIN_URL,
|
93 |
|
|
'WB_URL' => WB_URL,
|
94 |
|
|
'THEME_URL' => THEME_URL
|
95 |
|
|
)
|
96 |
|
|
);
|
97 |
1712
|
Luisehahne
|
|
98 |
1386
|
Luisehahne
|
switch ($module['function']) {
|
99 |
|
|
case NULL:
|
100 |
1913
|
Luisehahne
|
$type_name = $mLang->TEXT_UNKNOWN;
|
101 |
1386
|
Luisehahne
|
break;
|
102 |
|
|
case 'page':
|
103 |
1913
|
Luisehahne
|
$type_name = $mLang->TEXT_PAGE;
|
104 |
1386
|
Luisehahne
|
break;
|
105 |
|
|
case 'wysiwyg':
|
106 |
1913
|
Luisehahne
|
$type_name = $mLang->TEXT_WYSIWYG_EDITOR;
|
107 |
1386
|
Luisehahne
|
break;
|
108 |
|
|
case 'tool':
|
109 |
1913
|
Luisehahne
|
$type_name = $mLang->TEXT_ADMINISTRATION_TOOL;
|
110 |
1386
|
Luisehahne
|
break;
|
111 |
|
|
case 'admin':
|
112 |
1913
|
Luisehahne
|
$type_name = $mLang->TEXT_ADMIN;
|
113 |
1386
|
Luisehahne
|
break;
|
114 |
|
|
case 'administration':
|
115 |
1913
|
Luisehahne
|
$type_name = $mLang->TEXT_ADMINISTRATION;
|
116 |
1386
|
Luisehahne
|
break;
|
117 |
|
|
case 'snippet':
|
118 |
1913
|
Luisehahne
|
$type_name = $mLang->TEXT_CODE_SNIPPET;
|
119 |
1386
|
Luisehahne
|
break;
|
120 |
|
|
default:
|
121 |
1913
|
Luisehahne
|
$type_name = $mLang->TEXT_UNKNOWN;
|
122 |
1386
|
Luisehahne
|
}
|
123 |
|
|
$template->set_var('TYPE', $type_name);
|
124 |
|
|
|
125 |
1913
|
Luisehahne
|
|
126 |
1386
|
Luisehahne
|
// Parse module object
|
127 |
|
|
$template->parse('main', 'main_block', false);
|
128 |
|
|
$template->pparse('output', 'page');
|
129 |
|
|
// Print admin footer
|
130 |
|
|
$admin->print_footer();
|