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