Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         modules
6
 * @author          Ryan Djurovich, WebsiteBaker Project
7
 * @copyright       2009-2012, WebsiteBaker 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 2070 2014-01-03 01:21:42Z darkviper $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/modules/index.php $
14
 * @lastmodified    $Date: 2014-01-03 02:21:42 +0100 (Fri, 03 Jan 2014) $
15
 *
16
 */
17

    
18
// Print admin header
19
$config_file = realpath('../../config.php');
20
if(file_exists($config_file) && !defined('WB_URL'))
21
{
22
	require_once($config_file);
23
}
24
$oReg = WbAdaptor::getInstance();
25
if(!class_exists('admin', false)){ include($oReg->AppPath.'framework/class.admin.php'); }
26
$admin = new admin('Addons', 'modules');
27
// Make news post access files dir
28
if(!function_exists('get_variable_content')) {require($oReg->AppPath.'framework/functions.php');}
29
$oReg->getWbConstants();
30
$mLang = Translate::getinstance();
31
$mLang->enableAddon('admin\addons');
32

    
33
// Setup template object, parse vars to it, then parse it
34
// Create new template object
35
$template = new Template(dirname($admin->correct_theme_source('modules.htt')),'keep');
36
// $template->debug = true;
37
$template->set_file('page', 'modules.htt');
38
$template->set_block('page', 'main_block', 'main');
39

    
40
// Insert values into module list
41
$template->set_block('main_block', 'module_list_block', 'module_list');
42
$aAddonsList = array();
43
$sql = 'SELECT `directory`,`name` FROM  `'.$database->TablePrefix.'addons` '
44
     . 'WHERE `type` = \'module\' '
45
     . 'ORDER BY `name` ';
46
if($result = $database->query($sql)){
47

    
48
	while ($addon = $result->fetchRow(MYSQL_ASSOC))
49
	{
50
        $aAddonsList[$addon['directory']] = $addon['name'];
51
	}
52
    natcasesort ($aAddonsList);
53
    foreach ($aAddonsList as $sModule => $sModuleName)
54
    {
55
		if ($admin->get_permission($sModule,'module')==false) { continue;}
56
		$template->set_var('VALUE', $sModule);
57
		$template->set_var('NAME', $sModuleName);
58
		$template->parse('module_list', 'module_list_block', true);
59
    }
60

    
61
}
62
$aModuleList = array();
63
// Insert modules which includes a install.php file to install list
64
foreach (glob($oReg->AppPath.'modules/*', GLOB_MARK|GLOB_ONLYDIR) as $sTmp) {
65
    $sModulePath = str_replace('\\','/',$sTmp);
66
    $sModule = basename($sModulePath);
67
// list all module names not directories 
68
    $sModuleName = 'failed';
69
    if(function_exists('file_get_contents') && is_readable($sModulePath.'info.php')) {
70
    	$sData = file_get_contents($sModulePath.'info.php');
71
    	$sModuleName = get_variable_content('module_name', $sData, false, false);
72
    }
73
    $aModuleList[$sModule] = $sModuleName;
74
}
75
natcasesort ($aModuleList);
76
$template->set_block('main_block', 'install_list_block', 'install_list');
77
$template->set_block('main_block', 'upgrade_list_block', 'upgrade_list');
78
$template->set_block('main_block', 'uninstall_list_block', 'uninstall_list');
79
$template->set_var(array('INSTALL_VISIBLE' => 'hide', 'UPGRADE_VISIBLE' => 'hide', 'UNINSTALL_VISIBLE' => 'hide'));
80
$show_block = false;
81
foreach ($aModuleList as $sModule => $sModuleName)
82
{
83
	if ( $admin->get_permission($sModule,'module')==false ) { continue;}
84
	if (is_readable($oReg->AppPath.'modules/'.$sModule.'/install.php')) {
85
		$show_block = true;
86
		$template->set_var('INSTALL_VISIBLE', '');
87
		$template->set_var('VALUE', $sModule);
88
		$template->set_var('NAME', $sModuleName);
89
		$template->parse('install_list', 'install_list_block', true);
90
	}
91

    
92
	if (is_readable($oReg->AppPath.'modules/'.$sModule.'/upgrade.php')) {
93
		$show_block = true;
94
		$template->set_var('UPGRADE_VISIBLE', '');
95
		$template->set_var('VALUE', $sModule);
96
		$template->set_var('NAME', $sModuleName);
97
		$template->parse('upgrade_list', 'upgrade_list_block', true);
98
	}
99

    
100
	if (is_readable($oReg->AppPath.'modules/'.$sModule.'/uninstall.php')) {
101
		$show_block = true;
102
		$template->set_var('UNINSTALL_VISIBLE', '');
103
		$template->set_var('VALUE', $sModule);
104
		$template->set_var('NAME', $sModuleName);
105
		$template->parse('uninstall_list', 'uninstall_list_block', true);
106
	}
107

    
108
}
109
// Insert permissions values
110
if($admin->get_permission('modules_install') != true) {
111
	$template->set_var('DISPLAY_INSTALL', 'hide');
112
}
113
if($admin->get_permission('modules_uninstall') != true) {
114
	$template->set_var('DISPLAY_UNINSTALL', 'hide');
115
}
116
if($admin->get_permission('modules_view') != true) {
117
	$template->set_var('DISPLAY_LIST', 'hide');
118
}
119
// only show block if there is something to show
120
if(!$show_block || count($aModuleList) == 0 || !isset($_GET['advanced']) || $admin->get_permission('settings_advanced') != true) {
121
	$template->set_var('DISPLAY_MANUAL_INSTALL', 'hide');
122
}
123

    
124
/*-- insert all needed vars from language files ----------------------------------------*/
125
$template->set_var($mLang->getLangArray());
126

    
127
// insert urls
128
$template->set_var(array(
129
/** @todo the following 3 rtrims can be removed, after using of WB_PATH/s.o is changed in templates **/
130
					'ADMIN_URL' => rtrim($oReg->AcpUrl, '/'),
131
					'WB_URL' => rtrim($oReg->AppUrl, '/'),
132
					'THEME_URL' => rtrim($oReg->ThemeUrl, '/'),
133
					'FTAN' => $admin->getFTAN()
134
					)
135
				);
136
// Insert language text and messages
137
$template->set_var(array(
138
	'URL_TEMPLATES' => $admin->get_permission('templates')
139
	                   ? '<a href="'.$oReg->AcpUrl.'templates/index.php">'.$mLang->MENU_TEMPLATES.'</a>'
140
	                   : '<b>'.$mLang->MENU_TEMPLATES.'</b>',
141
	'URL_LANGUAGES' => $admin->get_permission('languages') 
142
	                   ? '<a href="'.$oReg->AcpUrl.'languages/index.php">'.$mLang->MENU_LANGUAGES.'</a>'
143
	                   : '<b>'.$mLang->MENU_LANGUAGES.'</b>',
144
	'URL_ADVANCED'  => $admin->get_permission('modules_advanced') 
145
	                   ? '<a href="' . $oReg->AcpUrl.'modules/index.php?advanced">'.$mLang->TEXT_ADVANCED.'</a>'
146
	                   : '<b>'.$mLang->TEXT_ADVANCED.'</b>', 'HEADING_CHANGE_TEMPLATE_NOTICE' => ''
147
	)
148
);
149

    
150
// Parse template object
151
$template->parse('main', 'main_block', false);
152
$template->pparse('output', 'page');
153

    
154
// Print admin footer
155
$admin->print_footer();
(2-2/5)