Project

General

Profile

1 238 stefan
<?php
2 1361 Luisehahne
/**
3
 *
4
 * @category        admin
5
 * @package         modules
6 1529 Luisehahne
 * @author          Ryan Djurovich, WebsiteBaker Project
7 1361 Luisehahne
 * @copyright       2009-2011, 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 1374 Luisehahne
 * @requirements    PHP 5.2.2 and higher
12 1361 Luisehahne
 * @version         $Id$
13 1457 Luisehahne
 * @filesource		$HeadURL$
14
 * @lastmodified    $Date$
15 1361 Luisehahne
 *
16
 */
17 238 stefan
18
// Print admin header
19
require('../../config.php');
20
require_once(WB_PATH.'/framework/class.admin.php');
21
$admin = new admin('Addons', 'modules');
22
23 1529 Luisehahne
// Setup template object, parse vars to it, then parse it
24
// Create new template object
25 1625 Luisehahne
$template = new Template(dirname($admin->correct_theme_source('modules.htt')));
26 1529 Luisehahne
// $template->debug = true;
27 944 Ruebenwurz
$template->set_file('page', 'modules.htt');
28 238 stefan
$template->set_block('page', 'main_block', 'main');
29
30
// Insert values into module list
31
$template->set_block('main_block', 'module_list_block', 'module_list');
32 384 Ruebenwurz
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' order by name");
33 238 stefan
if($result->numRows() > 0) {
34
	while ($addon = $result->fetchRow()) {
35
		$template->set_var('VALUE', $addon['directory']);
36
		$template->set_var('NAME', $addon['name']);
37
		$template->parse('module_list', 'module_list_block', true);
38
	}
39
}
40
41 934 doc
// Insert modules which includes a install.php file to install list
42 938 doc
$module_files = glob(WB_PATH . '/modules/*');
43 934 doc
$template->set_block('main_block', 'install_list_block', 'install_list');
44 938 doc
$template->set_block('main_block', 'upgrade_list_block', 'upgrade_list');
45
$template->set_block('main_block', 'uninstall_list_block', 'uninstall_list');
46
$template->set_var(array('INSTALL_VISIBLE' => 'hide', 'UPGRADE_VISIBLE' => 'hide', 'UNINSTALL_VISIBLE' => 'hide'));
47
48
$show_block = false;
49 934 doc
foreach ($module_files as $index => $path) {
50 938 doc
	if (is_dir($path)) {
51
		if (file_exists($path . '/install.php')) {
52
			$show_block = true;
53
			$template->set_var('INSTALL_VISIBLE', '');
54
			$template->set_var('VALUE', basename($path));
55
			$template->set_var('NAME', basename($path));
56
			$template->parse('install_list', 'install_list_block', true);
57
		}
58
59
		if (file_exists($path . '/upgrade.php')) {
60
			$show_block = true;
61
			$template->set_var('UPGRADE_VISIBLE', '');
62
			$template->set_var('VALUE', basename($path));
63
			$template->set_var('NAME', basename($path));
64
			$template->parse('upgrade_list', 'upgrade_list_block', true);
65
		}
66
67
		if (file_exists($path . '/uninstall.php')) {
68
			$show_block = true;
69
			$template->set_var('UNINSTALL_VISIBLE', '');
70
			$template->set_var('VALUE', basename($path));
71
			$template->set_var('NAME', basename($path));
72
			$template->parse('uninstall_list', 'uninstall_list_block', true);
73
		}
74
75 934 doc
	} else {
76
		unset($module_files[$index]);
77
	}
78
}
79
80 238 stefan
// Insert permissions values
81
if($admin->get_permission('modules_install') != true) {
82
	$template->set_var('DISPLAY_INSTALL', 'hide');
83
}
84
if($admin->get_permission('modules_uninstall') != true) {
85
	$template->set_var('DISPLAY_UNINSTALL', 'hide');
86
}
87
if($admin->get_permission('modules_view') != true) {
88
	$template->set_var('DISPLAY_LIST', 'hide');
89
}
90 938 doc
// only show block if there is something to show
91
if(!$show_block || count($module_files) == 0 || !isset($_GET['advanced']) || $admin->get_permission('admintools') != true) {
92 934 doc
	$template->set_var('DISPLAY_MANUAL_INSTALL', 'hide');
93
}
94 238 stefan
95
// Insert language headings
96
$template->set_var(array(
97 1381 Luisehahne
					'HEADING_INSTALL_MODULE' => $HEADING['INSTALL_MODULE'],
98
					'HEADING_UNINSTALL_MODULE' => $HEADING['UNINSTALL_MODULE'],
99
					'OVERWRITE_NEWER_FILES' => $MESSAGE['ADDON_OVERWRITE_NEWER_FILES'],
100
					'HEADING_MODULE_DETAILS' => $HEADING['MODULE_DETAILS'],
101
					'HEADING_INVOKE_MODULE_FILES' => $HEADING['INVOKE_MODULE_FILES']
102
					)
103
				);
104 1112 Ruebenwurz
// insert urls
105
$template->set_var(array(
106 1381 Luisehahne
					'ADMIN_URL' => ADMIN_URL,
107
					'WB_URL' => WB_URL,
108 1457 Luisehahne
					'THEME_URL' => THEME_URL,
109
					'FTAN' => $admin->getFTAN()
110 1381 Luisehahne
					)
111
				);
112 238 stefan
// Insert language text and messages
113
$template->set_var(array(
114 928 doc
	'URL_TEMPLATES' => $admin->get_permission('templates') ?
115
		'<a href="' . ADMIN_URL . '/templates/index.php">' . $MENU['TEMPLATES'] . '</a>' : '',
116
	'URL_LANGUAGES' => $admin->get_permission('languages') ?
117
		'<a href="' . ADMIN_URL . '/languages/index.php">' . $MENU['LANGUAGES'] . '</a>' : '',
118 934 doc
	'URL_ADVANCED' => $admin->get_permission('admintools') ?
119
		'<a href="' . ADMIN_URL . '/modules/index.php?advanced">' . $TEXT['ADVANCED'] . '</a>' : '',
120 928 doc
	'TEXT_INSTALL' => $TEXT['INSTALL'],
121
	'TEXT_UNINSTALL' => $TEXT['UNINSTALL'],
122
	'TEXT_VIEW_DETAILS' => $TEXT['VIEW_DETAILS'],
123 934 doc
	'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
124
	'TEXT_MANUAL_INSTALLATION' => $MESSAGE['ADDON']['MANUAL_INSTALLATION'],
125
	'TEXT_MANUAL_INSTALLATION_WARNING' => $MESSAGE['ADDON']['MANUAL_INSTALLATION_WARNING'],
126 938 doc
	'TEXT_EXECUTE' => $TEXT['EXECUTE'],
127
	'TEXT_FILE' => $TEXT['FILE']
128 928 doc
	)
129
);
130 238 stefan
131
// Parse template object
132
$template->parse('main', 'main_block', false);
133
$template->pparse('output', 'page');
134
135
// Print admin footer
136
$admin->print_footer();