Subversion Repositories Sites.tela-botanica.org

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
420 florian 1
<?php
2
 
3
// Vérification de sécurité
4
if (!defined("TOOLS_MANAGER"))
5
{
6
        die ("acc&egrave;s direct interdit");
7
}
8
 
9
 
10
$err = '';
11
$tool_url = '';
12
 
13
# Liste des thèmes
14
$plugins_root = dirname(__FILE__).'/../';
15
$plugins = new plugins($plugins_root);
16
$plugins->getPlugins(false);
17
$plugins_list = $plugins->getPluginsList();
18
 
19
$is_writable = is_writable($plugins_root);
20
 
21
# Installation d'un thème
22
if ($is_writable && !empty($_GET['tool_url']))
23
{
24
	$tool_url = $_GET['tool_url'];
25
	$parsed_url = parse_url($tool_url);
26
 
27
	if (empty($parsed_url['scheme']) || !preg_match('/^http|ftp$/',$parsed_url['scheme'])
28
	|| empty($parsed_url['host']) || empty($parsed_url['path']))
29
	{
30
		$err = __('URL is not valid.');
31
	}
32
	else
33
	{
34
		if (($err = $plugins->install($tool_url)) === true)
35
		{
36
			header('Location: tools.php?p=toolsmng');
37
			exit;
38
		}
39
	}
40
}
41
 
42
# Changement de status d'un plugin
43
$switch = (!empty($_GET['switch'])) ? $_GET['switch'] : '';
44
 
45
if ($is_writable && $switch != '' && in_array($switch,array_keys($plugins_list)) && $switch != 'toolsmng')
46
{
47
	$plugins->switchStatus($switch);
48
	header('Location: tools.php?p=toolsmng');
49
	exit;
50
}
51
 
52
# Suppression d'un thème
53
$delete = (!empty($_GET['delete'])) ? $_GET['delete'] : '';
54
 
55
if ($is_writable && $delete != '' && in_array($delete,array_keys($plugins_list)) && $delete != 'toolsmng')
56
{
57
	files::deltree($plugins_root.'/'.$delete);
58
	header('Location: tools.php?p=toolsmng');
59
	exit;
60
}
61
 
62
if($err != '')
63
{
64
	buffer::str(
65
	'<div class="erreur"><p><strong>'.__('Error(s)').' :</strong></p>'.$err.'</div>'
66
	);
67
}
68
 
69
buffer::str(
70
'<h2>'.__('Plugins manager').'</h2>'.
71
'<h3>'.__('Install a plugin').'</h3>'
72
);
73
 
74
if (!$is_writable)
75
{
76
	buffer::str(
77
	'<p>'.sprintf(__('The folder %s is not writable, please check its permissions.'),
78
	DC_ECRIRE.'/tools/').'</p>'
79
	);
80
}
81
else
82
{
83
	buffer::str(
84
	'<form action="tools.php" method="get">'.
85
	'<p><label for="tool_url">'.__('Please give the URL (http or ftp) of the plugin\'s file').' :</label>'.
86
	form::field('tool_url',50,'',$tool_url).'</p>'.
87
	'<p><input type="submit" class="submit" value="'.__('install').'" />'.
88
	'<input type="hidden" name="p" value="toolsmng" /></p>'.
89
	'</form>'
90
	);
91
}
92
 
93
buffer::str(
94
'<p><a href="http://www.wikini.net">'.__('Install new plugins').'</a></p>'
95
);
96
 
97
# Traduction des plugins
98
foreach ($plugins_list as $k => $v)
99
{
100
	$plugins->loadl10n($k);
101
 
102
	$plugins_list[$k]['label'] = __($v['label']);
103
	$plugins_list[$k]['desc'] = __($v['desc']);
104
}
105
 
106
# Tri des plugins par leur nom
107
uasort($plugins_list,create_function('$a,$b','return strcmp($a["label"],$b["label"]);'));
108
 
109
buffer::str(
110
'<h3>'.__('List of installed plugins').'</h3>'.
111
'<dl>'
112
);
113
 
114
foreach ($plugins_list as $k => $v)
115
{
116
	buffer::str(
117
	'<dt>'.__($v['label']).' - '.$k.'</dt>'.
118
	'<dd>'.__($v['desc']).' <br />'.
119
	'par '.$v['author'].' - '.__('version').' '.$v['version'].' <br />'
120
	);
121
 
122
 	if ($k != 'toolsmng')
123
	{
124
		if (is_writable($plugins_root.$k.'/desc.xml')) {
125
			$action = $v['active'] ? 'disable' : 'enable';
126
			buffer::str('<a href="tools.php?p=toolsmng&switch='.$k.'">'.__($action).'</a>');
127
		} else {
128
			buffer::str('<em>'.sprintf(__('cannot enable/disable'),'desc.xml').'</em>');
129
		}
130
 
131
		if ($is_writable)
132
		{
133
			buffer::str(
134
			' - <a href="tools.php?p=toolsmng&amp;delete='.$k.'" '.
135
			'onclick="return window.confirm(\''.__('Are you sure you want to delete this plugin ?').'\')">'.
136
			__('delete').'</a>'
137
			);
138
		}
139
 	}
140
 
141
	buffer::str('</dd>');
142
}
143
buffer::str('</dl>');
144
?>