[ Index ] |
|
Code source de Dotclear 1.2.5 |
1 <?php 2 # ***** BEGIN LICENSE BLOCK ***** 3 # This file is part of DotClear. 4 # Copyright (c) 2004 Olivier Meunier and contributors. All rights 5 # reserved. 6 # 7 # DotClear is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # DotClear is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with DotClear; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 # 21 # ***** END LICENSE BLOCK ***** 22 23 $err = ''; 24 $tool_url = ''; 25 26 # Liste des thèmes 27 $plugins_root = dirname(__FILE__).'/../'; 28 $plugins = new plugins($plugins_root); 29 $plugins->getPlugins(false); 30 $plugins_list = $plugins->getPluginsList(); 31 32 $is_writable = is_writable($plugins_root); 33 34 # Installation d'un thème 35 if ($is_writable && !empty($_GET['tool_url'])) 36 { 37 $tool_url = $_GET['tool_url']; 38 $parsed_url = parse_url($tool_url); 39 40 if (empty($parsed_url['scheme']) || !preg_match('/^http|ftp$/',$parsed_url['scheme']) 41 || empty($parsed_url['host']) || empty($parsed_url['path'])) 42 { 43 $err = __('URL is not valid.'); 44 } 45 else 46 { 47 if (($err = $plugins->install($tool_url)) === true) 48 { 49 header('Location: tools.php?p=toolsmng'); 50 exit; 51 } 52 } 53 } 54 55 # Changement de status d'un plugin 56 $switch = (!empty($_GET['switch'])) ? $_GET['switch'] : ''; 57 58 if ($is_writable && $switch != '' && in_array($switch,array_keys($plugins_list)) && $switch != 'toolsmng') 59 { 60 $plugins->switchStatus($switch); 61 header('Location: tools.php?p=toolsmng'); 62 exit; 63 } 64 65 # Suppression d'un thème 66 $delete = (!empty($_GET['delete'])) ? $_GET['delete'] : ''; 67 68 if ($is_writable && $delete != '' && in_array($delete,array_keys($plugins_list)) && $delete != 'toolsmng') 69 { 70 files::deltree($plugins_root.'/'.$delete); 71 header('Location: tools.php?p=toolsmng'); 72 exit; 73 } 74 75 if($err != '') 76 { 77 buffer::str( 78 '<div class="erreur"><p><strong>'.__('Error(s)').' :</strong></p>'.$err.'</div>' 79 ); 80 } 81 82 buffer::str( 83 '<h2>'.__('Plugins manager').'</h2>'. 84 '<h3>'.__('Install a plugin').'</h3>' 85 ); 86 87 if (!$is_writable) 88 { 89 buffer::str( 90 '<p>'.sprintf(__('The folder %s is not writable, please check its permissions.'), 91 DC_ECRIRE.'/tools/').'</p>' 92 ); 93 } 94 else 95 { 96 buffer::str( 97 '<form action="tools.php" method="get">'. 98 '<p><label for="tool_url">'.__('Please give the URL (http or ftp) of the plugin\'s file').' :</label>'. 99 form::field('tool_url',50,'',$tool_url).'</p>'. 100 '<p><input type="submit" class="submit" value="'.__('install').'" />'. 101 '<input type="hidden" name="p" value="toolsmng" /></p>'. 102 '</form>' 103 ); 104 } 105 106 buffer::str( 107 '<p><a href="http://www.dotclear.net/plugins/">'.__('Install new plugins').'</a></p>' 108 ); 109 110 # Traduction des plugins 111 foreach ($plugins_list as $k => $v) 112 { 113 $plugins->loadl10n($k); 114 115 $plugins_list[$k]['label'] = __($v['label']); 116 $plugins_list[$k]['desc'] = __($v['desc']); 117 } 118 119 # Tri des plugins par leur nom 120 uasort($plugins_list,create_function('$a,$b','return strcmp($a["label"],$b["label"]);')); 121 122 buffer::str( 123 '<h3>'.__('List of installed plugins').'</h3>'. 124 '<dl>' 125 ); 126 127 foreach ($plugins_list as $k => $v) 128 { 129 buffer::str( 130 '<dt>'.__($v['label']).' - '.$k.'</dt>'. 131 '<dd>'.__($v['desc']).' <br />'. 132 'par '.$v['author'].' - '.__('version').' '.$v['version'].' <br />' 133 ); 134 135 if ($k != 'toolsmng') 136 { 137 if (is_writable($plugins_root.$k.'/desc.xml')) { 138 $action = $v['active'] ? 'disable' : 'enable'; 139 buffer::str('<a href="tools.php?p=toolsmng&switch='.$k.'">'.__($action).'</a>'); 140 } else { 141 buffer::str('<em>'.sprintf(__('cannot enable/disable'),'desc.xml').'</em>'); 142 } 143 144 if ($is_writable) 145 { 146 buffer::str( 147 ' - <a href="tools.php?p=toolsmng&delete='.$k.'" '. 148 'onclick="return window.confirm(\''.__('Are you sure you want to delete this plugin ?').'\')">'. 149 __('delete').'</a>' 150 ); 151 } 152 } 153 154 buffer::str('</dd>'); 155 } 156 buffer::str('</dl>'); 157 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Feb 23 21:40:15 2007 | par Balluche grâce à PHPXref 0.7 |