Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         modules
6
 * @author          Ryan Djurovich, WebsiteBaker Project
7
 * @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
 * @requirements    PHP 5.2.2 and higher
12
 * @version         $Id: index.php 1529 2011-11-25 05:03:32Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/modules/index.php $
14
 * @lastmodified    $Date: 2011-11-25 06:03:32 +0100 (Fri, 25 Nov 2011) $
15
 *
16
 */
17

    
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
// 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
$template->set_file('page', 'modules.htt');
29
$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
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' order by name");
34
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
// Insert modules which includes a install.php file to install list
43
$module_files = glob(WB_PATH . '/modules/*');
44
$template->set_block('main_block', 'install_list_block', 'install_list');
45
$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
foreach ($module_files as $index => $path) {
51
	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
	} else {
77
		unset($module_files[$index]);
78
	}
79
}
80

    
81
// 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
// 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
	$template->set_var('DISPLAY_MANUAL_INSTALL', 'hide');
94
}
95

    
96
// Insert language headings
97
$template->set_var(array(
98
					'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
// insert urls
106
$template->set_var(array(
107
					'ADMIN_URL' => ADMIN_URL,
108
					'WB_URL' => WB_URL,
109
					'THEME_URL' => THEME_URL,
110
					'FTAN' => $admin->getFTAN()
111
					)
112
				);
113
// Insert language text and messages
114
$template->set_var(array(
115
	'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
	'URL_ADVANCED' => $admin->get_permission('admintools') ? 
120
		'<a href="' . ADMIN_URL . '/modules/index.php?advanced">' . $TEXT['ADVANCED'] . '</a>' : '',
121
	'TEXT_INSTALL' => $TEXT['INSTALL'],
122
	'TEXT_UNINSTALL' => $TEXT['UNINSTALL'],
123
	'TEXT_VIEW_DETAILS' => $TEXT['VIEW_DETAILS'],
124
	'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
	'TEXT_EXECUTE' => $TEXT['EXECUTE'],
128
	'TEXT_FILE' => $TEXT['FILE']
129
	)
130
);
131

    
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();
(2-2/5)