Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         modules
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 *  * @requirements    PHP 5.2.2 and higher
13
 * @version         $Id: index.php 1373 2011-01-10 12:14:10Z Luisehahne $
14
 * @filesource		$HeadURL: http://svn.websitebaker2.org/branches/2.8.x/wb/admin/modules/install.php $
15
 * @lastmodified    $Date: 2010-12-21 23:00:08 +0100 (Di, 21. Dez 2010) $
16
 *
17
 */
18

    
19
// Print admin header
20
require('../../config.php');
21
require_once(WB_PATH.'/framework/class.admin.php');
22
$admin = new admin('Addons', 'modules');
23

    
24
// Setup template object
25
$template = new Template(THEME_PATH.'/templates');
26
$template->set_file('page', 'modules.htt');
27
$template->set_block('page', 'main_block', 'main');
28

    
29
// Insert values into module list
30
$template->set_block('main_block', 'module_list_block', 'module_list');
31
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' order by name");
32
if($result->numRows() > 0) {
33
	while ($addon = $result->fetchRow()) {
34
		$template->set_var('VALUE', $addon['directory']);
35
		$template->set_var('NAME', $addon['name']);
36
		$template->parse('module_list', 'module_list_block', true);
37
	}
38
}
39

    
40
// Insert modules which includes a install.php file to install list
41
$module_files = glob(WB_PATH . '/modules/*');
42
$template->set_block('main_block', 'install_list_block', 'install_list');
43
$template->set_block('main_block', 'upgrade_list_block', 'upgrade_list');
44
$template->set_block('main_block', 'uninstall_list_block', 'uninstall_list');
45
$template->set_var(array('INSTALL_VISIBLE' => 'hide', 'UPGRADE_VISIBLE' => 'hide', 'UNINSTALL_VISIBLE' => 'hide'));
46

    
47
$show_block = false;
48
foreach ($module_files as $index => $path) {
49
	if (is_dir($path)) {
50
		if (file_exists($path . '/install.php')) {
51
			$show_block = true;
52
			$template->set_var('INSTALL_VISIBLE', '');
53
			$template->set_var('VALUE', basename($path));
54
			$template->set_var('NAME', basename($path));
55
			$template->parse('install_list', 'install_list_block', true);
56
		}
57

    
58
		if (file_exists($path . '/upgrade.php')) {
59
			$show_block = true;
60
			$template->set_var('UPGRADE_VISIBLE', '');
61
			$template->set_var('VALUE', basename($path));
62
			$template->set_var('NAME', basename($path));
63
			$template->parse('upgrade_list', 'upgrade_list_block', true);
64
		} 
65
		
66
		if (file_exists($path . '/uninstall.php')) {
67
			$show_block = true;
68
			$template->set_var('UNINSTALL_VISIBLE', '');
69
			$template->set_var('VALUE', basename($path));
70
			$template->set_var('NAME', basename($path));
71
			$template->parse('uninstall_list', 'uninstall_list_block', true);
72
		}
73

    
74
	} else {
75
		unset($module_files[$index]);
76
	}
77
}
78

    
79
// Insert permissions values
80
if($admin->get_permission('modules_install') != true) {
81
	$template->set_var('DISPLAY_INSTALL', 'hide');
82
}
83
if($admin->get_permission('modules_uninstall') != true) {
84
	$template->set_var('DISPLAY_UNINSTALL', 'hide');
85
}
86
if($admin->get_permission('modules_view') != true) {
87
	$template->set_var('DISPLAY_LIST', 'hide');
88
}
89
// only show block if there is something to show
90
if(!$show_block || count($module_files) == 0 || !isset($_GET['advanced']) || $admin->get_permission('admintools') != true) {
91
	$template->set_var('DISPLAY_MANUAL_INSTALL', 'hide');
92
}
93

    
94
// Insert language headings
95
$template->set_var(array(
96
								'HEADING_INSTALL_MODULE' => $HEADING['INSTALL_MODULE'],
97
								'HEADING_UNINSTALL_MODULE' => $HEADING['UNINSTALL_MODULE'],
98
								'OVERWRITE_NEWER_FILES' => $MESSAGE['ADDON_OVERWRITE_NEWER_FILES'],
99
								'HEADING_MODULE_DETAILS' => $HEADING['MODULE_DETAILS'],
100
								'HEADING_INVOKE_MODULE_FILES' => $HEADING['INVOKE_MODULE_FILES']
101
								)
102
						);
103
// insert urls
104
$template->set_var(array(
105
								'ADMIN_URL' => ADMIN_URL,
106
								'WB_URL' => WB_URL,
107
								'WB_PATH' => WB_PATH,
108
								'THEME_URL' => THEME_URL
109
								)
110
						);
111
// Insert language text and messages
112
$template->set_var(array(
113
	'URL_TEMPLATES' => $admin->get_permission('templates') ? 
114
		'<a href="' . ADMIN_URL . '/templates/index.php">' . $MENU['TEMPLATES'] . '</a>' : '',
115
	'URL_LANGUAGES' => $admin->get_permission('languages') ? 
116
		'<a href="' . ADMIN_URL . '/languages/index.php">' . $MENU['LANGUAGES'] . '</a>' : '',
117
	'URL_ADVANCED' => $admin->get_permission('admintools') ? 
118
		'<a href="' . ADMIN_URL . '/modules/index.php?advanced">' . $TEXT['ADVANCED'] . '</a>' : '',
119
	'TEXT_INSTALL' => $TEXT['INSTALL'],
120
	'TEXT_UNINSTALL' => $TEXT['UNINSTALL'],
121
	'TEXT_VIEW_DETAILS' => $TEXT['VIEW_DETAILS'],
122
	'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
123
	'TEXT_MANUAL_INSTALLATION' => $MESSAGE['ADDON']['MANUAL_INSTALLATION'],
124
	'TEXT_MANUAL_INSTALLATION_WARNING' => $MESSAGE['ADDON']['MANUAL_INSTALLATION_WARNING'],
125
	'TEXT_EXECUTE' => $TEXT['EXECUTE'],
126
	'TEXT_FILE' => $TEXT['FILE']
127
	)
128
);
129

    
130
// Parse template object
131
$template->parse('main', 'main_block', false);
132
$template->pparse('output', 'page');
133

    
134
// Print admin footer
135
$admin->print_footer();
136

    
137
?>
(2-2/5)