Project

General

Profile

« Previous | Next » 

Revision 1992

Added by Dietmar about 11 years ago

! /admin/modules/index.php : captions of module lists changed from `directory` to real `name` and sorted by name

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12
===============================================================================
13 13

  
14
25 Oct-2013 Build 1992 Dietmar Woellbrink (Luisehahne)
15
! /admin/modules/index.php : captions of module lists changed from `directory` to real `name` and sorted by name
14 16
21 Oct-2013 Build 1991 Manuela v.d.Decken(DarkViper)
15 17
# /news/Reorg::deleteAll() typofix
16 18
! ModuleReorgAbstract::__construct() set to final
branches/2.8.x/wb/admin/interface/version.php
51 51

  
52 52
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
53 53
if(!defined('VERSION')) define('VERSION', '2.8.3');
54
if(!defined('REVISION')) define('REVISION', '1991');
54
if(!defined('REVISION')) define('REVISION', '1992');
55 55
if(!defined('SP')) define('SP', '');
branches/2.8.x/wb/admin/modules/details.php
39 39

  
40 40
// Check if the template exists
41 41
if(!is_dir(WB_PATH.'/modules/'.$file)) {
42
	$admin->print_error($mLang->MESSAGE_GENERIC_NOT_INSTALLED);
42
	$admin->print_error($file.'::'.$mLang->MESSAGE_GENERIC_NOT_INSTALLED);
43 43
}
44 44

  
45 45
// Check if the template exists
......
55 55

  
56 56
// Insert values
57 57
$module = false;
58
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` '
59
     . 'WHERE `type`=\'module\' AND `directory`=\''.$file.'\'';
58
$sql = 'SELECT * FROM  `'.TABLE_PREFIX.'addons` '
59
     . 'WHERE `type` = \'module\' '
60
     . 'AND `directory`= \''.$file.'\' ';
60 61
if( ($result = $database->query($sql)) ){
61 62
	$module = $result->fetchRow(MYSQL_ASSOC);
62 63
}
branches/2.8.x/wb/admin/modules/index.php
16 16
 */
17 17

  
18 18
// Print admin header
19
require('../../config.php');
20
require_once(WB_PATH.'/framework/class.admin.php');
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'); }
21 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');
22 32

  
23 33
// Setup template object, parse vars to it, then parse it
24 34
// Create new template object
......
29 39

  
30 40
// Insert values into module list
31 41
$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())
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))
35 49
	{
36
		if ($admin->get_permission($addon['directory'],'module')==false) { continue;}
37
//echo $addon['directory'].'<br />';
38
		$template->set_var('VALUE', $addon['directory']);
39
		$template->set_var('NAME', $addon['name']);
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);
40 58
		$template->parse('module_list', 'module_list_block', true);
41
	}
59
    }
60

  
42 61
}
43

  
62
$aModuleList = array();
44 63
// Insert modules which includes a install.php file to install list
45
$module_files = glob(WB_PATH . '/modules/*');
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);
46 76
$template->set_block('main_block', 'install_list_block', 'install_list');
47 77
$template->set_block('main_block', 'upgrade_list_block', 'upgrade_list');
48 78
$template->set_block('main_block', 'uninstall_list_block', 'uninstall_list');
49 79
$template->set_var(array('INSTALL_VISIBLE' => 'hide', 'UPGRADE_VISIBLE' => 'hide', 'UNINSTALL_VISIBLE' => 'hide'));
50

  
51 80
$show_block = false;
52
foreach ($module_files as $index => $path)
81
foreach ($aModuleList as $sModule => $sModuleName)
53 82
{
54
	if ( $admin->get_permission(basename($path),'module')==false ) { continue;}
55
	if (is_dir($path)) {
56
//echo basename($path).'<br />';
57
		if (is_readable($path . '/install.php')) {
58
			$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
		}
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
	}
64 91

  
65
		if (is_readable($path . '/upgrade.php')) {
66
			$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
		}
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
	}
72 99

  
73
		if (is_readable($path . '/uninstall.php')) {
74
			$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
		}
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
	}
80 107

  
81
	} else {
82
		unset($module_files[$index]);
83
	}
84 108
}
85

  
86 109
// Insert permissions values
87 110
if($admin->get_permission('modules_install') != true) {
88 111
	$template->set_var('DISPLAY_INSTALL', 'hide');
......
94 117
	$template->set_var('DISPLAY_LIST', 'hide');
95 118
}
96 119
// only show block if there is something to show
97
if(!$show_block || count($module_files) == 0 || !isset($_GET['advanced']) || $admin->get_permission('settings_advanced') != true) {
120
if(!$show_block || count($aModuleList) == 0 || !isset($_GET['advanced']) || $admin->get_permission('settings_advanced') != true) {
98 121
	$template->set_var('DISPLAY_MANUAL_INSTALL', 'hide');
99 122
}
100 123

  
101
//$mLang = ModLanguage::getInstance();
102
//$mLang->setLanguage(ADMIN_PATH.'/addons/languages/', LANGUAGE, DEFAULT_LANGUAGE);
103
$mLang = Translate::getinstance();
104
$mLang->enableAddon('admin\addons');
105

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

  
109 127
// insert urls
110 128
$template->set_var(array(
111
					'ADMIN_URL' => ADMIN_URL,
112
					'WB_URL' => WB_URL,
113
					'THEME_URL' => THEME_URL,
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, '/'),
114 133
					'FTAN' => $admin->getFTAN()
115 134
					)
116 135
				);
117 136
// Insert language text and messages
118 137
$template->set_var(array(
119
	'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
	'URL_ADVANCED' => $admin->get_permission('modules_advanced') ?
124
		'<a href="' . ADMIN_URL . '/modules/index.php?advanced">' . $mLang->TEXT_ADVANCED . '</a>' : '<b>'.$mLang->TEXT_ADVANCED.'</b>' ,
125
	'HEADING_CHANGE_TEMPLATE_NOTICE' => ''
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' => ''
126 147
	)
127 148
);
128 149

  

Also available in: Unified diff