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 1625 2012-02-29 00:50:57Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/modules/index.php $
14
 * @lastmodified    $Date: 2012-02-29 01:50:57 +0100 (Wed, 29 Feb 2012) $
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
// Create new template object
25
$template = new Template(dirname($admin->correct_theme_source('modules.htt')));
26
// $template->debug = true;
27
$template->set_file('page', 'modules.htt');
28
$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
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' order by name");
33
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
// Insert modules which includes a install.php file to install list
42
$module_files = glob(WB_PATH . '/modules/*');
43
$template->set_block('main_block', 'install_list_block', 'install_list');
44
$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
foreach ($module_files as $index => $path) {
50
	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
	} else {
76
		unset($module_files[$index]);
77
	}
78
}
79

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

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

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