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 1712 Luisehahne
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
8 1361 Luisehahne
 * @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 1712 Luisehahne
$template = new Template(dirname($admin->correct_theme_source('modules.htt')),'keep');
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 1712 Luisehahne
	while ($addon = $result->fetchRow())
35
	{
36
		if ($admin->get_permission($addon['directory'],'module')==false) { continue;}
37
//echo $addon['directory'].'<br />';
38 238 stefan
		$template->set_var('VALUE', $addon['directory']);
39
		$template->set_var('NAME', $addon['name']);
40
		$template->parse('module_list', 'module_list_block', true);
41
	}
42
}
43
44 934 doc
// Insert modules which includes a install.php file to install list
45 938 doc
$module_files = glob(WB_PATH . '/modules/*');
46 934 doc
$template->set_block('main_block', 'install_list_block', 'install_list');
47 938 doc
$template->set_block('main_block', 'upgrade_list_block', 'upgrade_list');
48
$template->set_block('main_block', 'uninstall_list_block', 'uninstall_list');
49
$template->set_var(array('INSTALL_VISIBLE' => 'hide', 'UPGRADE_VISIBLE' => 'hide', 'UNINSTALL_VISIBLE' => 'hide'));
50
51
$show_block = false;
52 1712 Luisehahne
foreach ($module_files as $index => $path)
53
{
54
	if ( $admin->get_permission(basename($path),'module')==false ) { continue;}
55 938 doc
	if (is_dir($path)) {
56 1712 Luisehahne
//echo basename($path).'<br />';
57
		if (is_readable($path . '/install.php')) {
58 938 doc
			$show_block = true;
59
			$template->set_var('INSTALL_VISIBLE', '');
60
			$template->set_var('VALUE', basename($path));
61
			$template->set_var('NAME', basename($path));
62
			$template->parse('install_list', 'install_list_block', true);
63
		}
64
65 1712 Luisehahne
		if (is_readable($path . '/upgrade.php')) {
66 938 doc
			$show_block = true;
67
			$template->set_var('UPGRADE_VISIBLE', '');
68
			$template->set_var('VALUE', basename($path));
69
			$template->set_var('NAME', basename($path));
70
			$template->parse('upgrade_list', 'upgrade_list_block', true);
71 1712 Luisehahne
		}
72
73
		if (is_readable($path . '/uninstall.php')) {
74 938 doc
			$show_block = true;
75
			$template->set_var('UNINSTALL_VISIBLE', '');
76
			$template->set_var('VALUE', basename($path));
77
			$template->set_var('NAME', basename($path));
78
			$template->parse('uninstall_list', 'uninstall_list_block', true);
79
		}
80
81 934 doc
	} else {
82
		unset($module_files[$index]);
83
	}
84
}
85
86 238 stefan
// Insert permissions values
87
if($admin->get_permission('modules_install') != true) {
88
	$template->set_var('DISPLAY_INSTALL', 'hide');
89
}
90
if($admin->get_permission('modules_uninstall') != true) {
91
	$template->set_var('DISPLAY_UNINSTALL', 'hide');
92
}
93
if($admin->get_permission('modules_view') != true) {
94
	$template->set_var('DISPLAY_LIST', 'hide');
95
}
96 938 doc
// only show block if there is something to show
97 1712 Luisehahne
if(!$show_block || count($module_files) == 0 || !isset($_GET['advanced']) || $admin->get_permission('settings_advanced') != true) {
98 934 doc
	$template->set_var('DISPLAY_MANUAL_INSTALL', 'hide');
99
}
100 238 stefan
101 1913 Luisehahne
//$mLang = ModLanguage::getInstance();
102
//$mLang->setLanguage(ADMIN_PATH.'/addons/languages/', LANGUAGE, DEFAULT_LANGUAGE);
103
$mLang = Translate::getinstance();
104
$mLang->enableAddon('admin\addons');
105 1712 Luisehahne
106
/*-- insert all needed vars from language files ----------------------------------------*/
107
$template->set_var($mLang->getLangArray());
108
109 1112 Ruebenwurz
// insert urls
110
$template->set_var(array(
111 1381 Luisehahne
					'ADMIN_URL' => ADMIN_URL,
112
					'WB_URL' => WB_URL,
113 1457 Luisehahne
					'THEME_URL' => THEME_URL,
114
					'FTAN' => $admin->getFTAN()
115 1381 Luisehahne
					)
116
				);
117 238 stefan
// Insert language text and messages
118
$template->set_var(array(
119 1712 Luisehahne
	'URL_TEMPLATES' => $admin->get_permission('templates') ?
120
		'<a href="' . ADMIN_URL . '/templates/index.php">' . $mLang->MENU_TEMPLATES . '</a>' : '<b>'.$mLang->MENU_TEMPLATES.'</b>',
121
	'URL_LANGUAGES' => $admin->get_permission('languages') ?
122
		'<a href="' . ADMIN_URL . '/languages/index.php">' . $mLang->MENU_LANGUAGES . '</a>' : '<b>'.$mLang->MENU_LANGUAGES.'</b>',
123 1789 Luisehahne
	'URL_ADVANCED' => $admin->get_permission('modules_advanced') ?
124 1712 Luisehahne
		'<a href="' . ADMIN_URL . '/modules/index.php?advanced">' . $mLang->TEXT_ADVANCED . '</a>' : '<b>'.$mLang->TEXT_ADVANCED.'</b>' ,
125
	'HEADING_CHANGE_TEMPLATE_NOTICE' => ''
126 928 doc
	)
127
);
128 238 stefan
129
// Parse template object
130
$template->parse('main', 'main_block', false);
131
$template->pparse('output', 'page');
132
133
// Print admin footer
134
$admin->print_footer();