- Timestamp:
- Mar 7, 2008, 11:42:51 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin.php
r2239 r2263 115 115 array( 116 116 'NAME' => l10n('admin'), 117 'URL' => $link_start.'plugins '117 'URL' => $link_start.'plugins_list' 118 118 ) 119 119 ); -
trunk/admin/include/functions_plugins.inc.php
r2255 r2263 25 25 // +-----------------------------------------------------------------------+ 26 26 27 /* Returns an array of plugins defined in the plugin directory28 */29 function get_fs_plugins()30 {31 $plugins = array();32 33 $dir = opendir(PHPWG_PLUGINS_PATH);34 while ($file = readdir($dir))35 {36 if ($file!='.' and $file!='..')37 {38 $path = PHPWG_PLUGINS_PATH.$file;39 if (is_dir($path) and !is_link($path)40 and preg_match('/^[a-zA-Z0-9-_]+$/', $file )41 and file_exists($path.'/main.inc.php')42 )43 {44 $plugin = array(45 'name'=>$file,46 'version'=>'0',47 'uri'=>'',48 'description'=>'',49 'author'=>'',50 );51 $plg_data = implode( '', file($path.'/main.inc.php') );52 53 if ( preg_match("|Plugin Name: (.*)|", $plg_data, $val) )54 {55 $plugin['name'] = trim( $val[1] );56 }57 if (preg_match("|Version: (.*)|", $plg_data, $val))58 {59 $plugin['version'] = trim($val[1]);60 }61 if ( preg_match("|Plugin URI: (.*)|", $plg_data, $val) )62 {63 $plugin['uri'] = trim($val[1]);64 }65 if ( preg_match("|Description: (.*)|", $plg_data, $val) )66 {67 $plugin['description'] = trim($val[1]);68 }69 if ( preg_match("|Author: (.*)|", $plg_data, $val) )70 {71 $plugin['author'] = trim($val[1]);72 }73 if ( preg_match("|Author URI: (.*)|", $plg_data, $val) )74 {75 $plugin['author uri'] = trim($val[1]);76 }77 // IMPORTANT SECURITY !78 $plugin = array_map('htmlspecialchars', $plugin);79 $plugins[$file] = $plugin;80 }81 }82 }83 closedir($dir);84 return $plugins;85 }86 87 /**88 * Activates a plugin. It will be loaded only on the next page ...89 * @param string $plugin_id the plugin to activate90 * @param array $errors errors to be returned91 */92 function activate_plugin($plugin_id, &$errors)93 {94 // the plugin_id must exist in the DB as inactive95 $db_plugins = get_db_plugins('', $plugin_id);96 if (!empty($db_plugins))97 {98 $crt_db_plugin = $db_plugins[0];99 if ($crt_db_plugin['state'] != 'inactive')100 {101 array_push($errors, 'CANNOT ACTIVATE - INVALID CURRENT STATE ' . $crt_db_plugin['state']);102 return false;103 }104 }105 else106 {107 array_push($errors, 'CANNOT ACTIVATE - NOT INSTALLED');108 return false;109 }110 111 // now try to activate it112 $file_to_include = PHPWG_PLUGINS_PATH . $plugin_id . '/maintain.inc.php';113 if (file_exists($file_to_include))114 {115 include_once($file_to_include);116 if (function_exists('plugin_activate'))117 {118 plugin_activate($plugin_id, $crt_db_plugin['version'], $errors);119 }120 }121 if (empty($errors))122 {123 $query = '124 UPDATE ' . PLUGINS_TABLE . ' SET state="active" WHERE id="' . $plugin_id . '"';125 pwg_query($query);126 return true;127 }128 return false;129 }130 131 132 /**133 * Deactivates a plugin. It will be unloaded only on the next page ...134 * @param string $plugin_id the plugin to activate135 * @param array $errors errors to be returned136 */137 function deactivate_plugin($plugin_id, &$errors)138 {139 // the plugin_id must exist in the DB as inactive140 $db_plugins = get_db_plugins('', $plugin_id);141 if (!empty($db_plugins))142 {143 $crt_db_plugin = $db_plugins[0];144 if ($crt_db_plugin['state'] != 'active')145 {146 array_push($errors, 'CANNOT DEACTIVATE - INVALID CURRENT STATE ' . $crt_db_plugin['state']);147 return false;148 }149 }150 else151 {152 array_push($errors, 'CANNOT DEACTIVATE - NOT INSTALLED');153 return false;154 }155 156 // now try to deactivate it157 $query = '158 UPDATE ' . PLUGINS_TABLE . ' SET state="inactive" WHERE id="' . $plugin_id . '"';159 pwg_query($query);160 161 $file_to_include = PHPWG_PLUGINS_PATH . $plugin_id . '/maintain.inc.php';162 if (file_exists($file_to_include))163 {164 include_once($file_to_include);165 if (function_exists('plugin_deactivate'))166 {167 plugin_deactivate($plugin_id);168 }169 }170 return true;171 }172 173 174 27 /** 175 28 * Retrieves an url for a plugin page. … … 194 47 return $url; 195 48 } 196 197 /**198 * Sort plugins by status199 */200 function sort_plugins_by_state($plugins, $db_plugins_by_id)201 {202 $active_plugins = array();203 $inactive_plugins = array();204 $not_installed = array();205 206 foreach($plugins as $plugin_id => $plugin)207 {208 if (isset($db_plugins_by_id[$plugin_id]))209 {210 $db_plugins_by_id[$plugin_id]['state'] == 'active' ?211 $active_plugins[$plugin_id] = $plugin : $inactive_plugins[$plugin_id] = $plugin;212 }213 else214 {215 $not_installed[$plugin_id] = $plugin;216 }217 }218 return $active_plugins + $inactive_plugins + $not_installed;219 }220 221 222 /**223 * Retrieve PEM server datas224 * @param bool (true for retrieve new extensions)225 */226 function check_server_plugins(& $fs_plugins, $newext=false)227 {228 foreach($fs_plugins as $plugin_id => $fs_plugin)229 {230 if (!empty($fs_plugin['uri']) and strpos($fs_plugin['uri'] , 'extension_view.php?eid='))231 {232 list( , $extension) = explode('extension_view.php?eid=', $fs_plugin['uri']);233 if (!is_numeric($extension)) continue;234 $plugins_to_check[] = $extension;235 $fs_plugins[$plugin_id]['extension'] = $extension;236 }237 }238 239 $url = PEM_URL . '/uptodate.php?version=' . rawurlencode(PHPWG_VERSION) . '&extensions=' . implode(',', $plugins_to_check);240 $url .= $newext ? '&newext=Plugin' : '';241 242 if (!empty($plugins_to_check) and $source = @file_get_contents($url))243 {244 return @unserialize($source);245 }246 return false;247 }248 249 250 /**251 * Extract plugin files from archive252 * @param string - install or upgrade253 * @param string - archive URL254 * @param string - destination path255 */256 function extract_plugin_files($action, $source, $dest)257 {258 if ($archive = tempnam( PHPWG_PLUGINS_PATH, 'zip'))259 {260 if (@copy(PEM_URL . str_replace(' ', '%20', $source), $archive))261 {262 $zip = new PclZip($archive);263 if ($list = $zip->listContent())264 {265 foreach ($list as $file)266 {267 // we search main.inc.php in archive268 if (basename($file['filename']) == 'main.inc.php'269 and (!isset($main_filepath)270 or strlen($file['filename']) < strlen($main_filepath)))271 {272 $main_filepath = $file['filename'];273 }274 }275 if (isset($main_filepath))276 {277 $root = dirname($main_filepath); // main.inc.php path in archive278 if ($action == 'upgrade')279 {280 $extract_path = PHPWG_PLUGINS_PATH.$dest;281 }282 else283 {284 $extract_path = PHPWG_PLUGINS_PATH285 . ($root == '.' ? 'extension_' . $dest : basename($root));286 }287 if($result = $zip->extract(PCLZIP_OPT_PATH, $extract_path,288 PCLZIP_OPT_REMOVE_PATH, $root,289 PCLZIP_OPT_REPLACE_NEWER))290 {291 foreach ($result as $file)292 {293 if ($file['stored_filename'] == $main_filepath)294 {295 $status = $file['status'];296 break;297 }298 }299 }300 else $status = 'extract_error';301 }302 else $status = 'archive_error';303 }304 else $status = 'archive_error';305 }306 else $status = 'dl_archive_error';307 }308 else $status = 'temp_path_error';309 310 @unlink($archive);311 return $status;312 }313 314 315 /**316 * delete $path directory317 * @param string - path318 */319 function deltree($path)320 {321 if (is_dir($path))322 {323 $fh = opendir($path);324 while ($file = readdir($fh))325 {326 if ($file != '.' and $file != '..')327 {328 $pathfile = $path . '/' . $file;329 if (is_dir($pathfile))330 {331 deltree($pathfile);332 }333 else334 {335 @unlink($pathfile);336 }337 }338 }339 closedir($fh);340 return @rmdir($path);341 }342 }343 344 345 /**346 * send $path to trash directory347 * @param string - path348 */349 function send_to_trash($path)350 {351 $trash_path = PHPWG_PLUGINS_PATH . 'trash';352 if (!is_dir($trash_path))353 {354 @mkdir($trash_path);355 $file = @fopen($trash_path . '/.htaccess', 'w');356 @fwrite($file, 'deny from all');357 @fclose($file);358 }359 while ($r = $trash_path . '/' . md5(uniqid(rand(), true)))360 {361 if (!is_dir($r))362 {363 @rename($path, $r);364 break;365 }366 }367 }368 369 370 /**371 * Sort functions372 */373 function extension_name_compare($a, $b)374 {375 return strcmp(strtolower($a['ext_name']), strtolower($b['ext_name']));376 }377 378 function extension_author_compare($a, $b)379 {380 $r = strcmp(strtolower($a['author']), strtolower($b['author']));381 if ($r == 0) return extension_name_compare($a, $b);382 else return $r;383 }384 385 function plugin_author_compare($a, $b)386 {387 return strcasecmp( $a['author'], $b['author']);388 }389 390 function plugin_version_compare($a, $b)391 {392 return version_compare( $a['version'], $b['version']);393 }394 395 49 ?> -
trunk/admin/plugins_list.php
r2256 r2263 2 2 // +-----------------------------------------------------------------------+ 3 3 // | PhpWebGallery - a PHP based picture gallery | 4 // | Copyright (C) 2003-200 8PhpWebGallery Team - http://phpwebgallery.net |4 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | 5 5 // +-----------------------------------------------------------------------+ 6 6 // | file : $Id$ … … 29 29 } 30 30 31 include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php'); 31 32 32 // +-----------------------------------------------------------------------+ 33 // | perform requested actions | 34 // +-----------------------------------------------------------------------+ 33 $template->set_filenames(array('plugins' => 'admin/plugins_list.tpl')); 34 35 $order = isset($_GET['order']) ? $_GET['order'] : 'name'; 36 $plugins = new plugins($page['page'], $order); 37 38 //--------------------------------------------------perform requested actions 35 39 if (isset($_GET['action']) and isset($_GET['plugin']) and !is_adviser()) 36 40 { 37 $plugin_id = $_GET['plugin']; 38 $crt_db_plugin = get_db_plugins('', $plugin_id); 39 if (!empty($crt_db_plugin)) 40 { 41 $crt_db_plugin = $crt_db_plugin[0]; 42 } 43 else 44 { 45 unset($crt_db_plugin); 46 } 47 48 $errors = array(); 49 $file_to_include = PHPWG_PLUGINS_PATH . $plugin_id . '/maintain.inc.php'; 50 51 switch ($_GET['action']) 52 { 53 case 'install': 54 if (!empty($crt_db_plugin)) 55 { 56 array_push($errors, 'CANNOT install - ALREADY INSTALLED'); 57 break; 58 } 59 $fs_plugins = get_fs_plugins(); 60 if (!isset($fs_plugins[$plugin_id])) 61 { 62 array_push($errors, 'CANNOT install - NO SUCH PLUGIN'); 63 break; 64 } 65 if (file_exists($file_to_include)) 66 { 67 include_once($file_to_include); 68 if (function_exists('plugin_install')) 69 { 70 plugin_install($plugin_id, $fs_plugins[$plugin_id]['version'], $errors); 71 } 72 } 73 if (empty($errors)) 74 { 75 $query = ' 76 INSERT INTO ' . PLUGINS_TABLE . ' (id,version) VALUES ("' 77 . $plugin_id . '","' . $fs_plugins[$plugin_id]['version'] . '" 78 )'; 79 pwg_query($query); 80 } 81 break; 82 83 case 'activate': 84 activate_plugin($plugin_id, $errors); 85 break; 86 case 'deactivate': 87 deactivate_plugin($plugin_id, $errors); 88 break; 89 90 case 'uninstall': 91 if (!isset($crt_db_plugin)) 92 { 93 die ('CANNOT ' . $_GET['action'] . ' - NOT INSTALLED'); 94 } 95 $query = ' 96 DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"'; 97 pwg_query($query); 98 if (file_exists($file_to_include)) 99 { 100 include_once($file_to_include); 101 if (function_exists('plugin_uninstall')) 102 { 103 plugin_uninstall($plugin_id); 104 } 105 } 106 break; 107 108 case 'delete': 109 if (!empty($crt_db_plugin)) 110 { 111 array_push($errors, 'CANNOT delete - PLUGIN IS INSTALLED'); 112 } 113 elseif (!deltree(PHPWG_PLUGINS_PATH . $plugin_id)) 114 { 115 send_to_trash(PHPWG_PLUGINS_PATH . $plugin_id); 116 } 117 break; 118 } 119 if (empty($errors)) 120 { 121 redirect( 122 get_root_url() 123 .'admin.php' 124 .get_query_string_diff( array('action', 'plugin') ) 125 ); 126 } 127 else 128 { 129 $page['errors'] = array_merge($page['errors'], $errors); 130 } 41 $page['errors'] = 42 $plugins->perform_action($_GET['action'], $_GET['plugin'], $page['errors']); 43 44 if (empty($page['errors'])) redirect($plugins->my_base_url); 131 45 } 132 133 134 $fs_plugins = get_fs_plugins();135 $db_plugins = get_db_plugins();136 $db_plugins_by_id = array();137 foreach ($db_plugins as $db_plugin)138 {139 $db_plugins_by_id[$db_plugin['id']] = $db_plugin;140 }141 142 46 143 47 // +-----------------------------------------------------------------------+ 144 48 // | start template output | 145 49 // +-----------------------------------------------------------------------+ 146 147 $template->set_filenames(array('plugins' => 'admin/plugins_list.tpl')); 148 149 $base_url = get_root_url().'admin.php'; 150 151 //----------------------------------------------------------------sort options 152 $selected_order = isset($_GET['order']) ? $_GET['order'] : 'name'; 153 154 $url = $base_url.get_query_string_diff( array('action', 'plugin', 'order')); 155 156 $template->assign('order', 157 array( 158 $url.'&order=name' => l10n('Name'), 159 $url.'&order=status' => l10n('Status'), 160 $url.'&order=author' => l10n('Author'), 161 $url.'&order=id' => 'Id', 162 ) 163 ); 164 165 $template->assign('selected', $url.'&order='.$selected_order); 166 167 switch ($selected_order) 168 { 169 case 'name': 170 uasort($fs_plugins, 'name_compare'); 171 break; 172 case 'id': 173 uksort($fs_plugins, 'strcasecmp'); 174 break; 175 case 'author': 176 uasort($fs_plugins, 'plugin_author_compare'); 177 break; 178 case 'status': 179 $fs_plugins = sort_plugins_by_state($fs_plugins, $db_plugins_by_id); 180 break; 181 } 182 183 184 //--------------------------------------------------------------display plugins 185 186 $url = $base_url.get_query_string_diff( array('action', 'plugin') ); 187 188 foreach($fs_plugins as $plugin_id => $fs_plugin) 50 $plugins->tabsheet(); 51 $plugins->sort_fs_plugins(); 52 $plugins->set_order_options(array( 53 'name' => l10n('Name'), 54 'status' => l10n('Status'), 55 'author' => l10n('Author'), 56 'id' => 'Id')); 57 58 foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) 189 59 { 190 60 $display_name = $fs_plugin['name']; … … 215 85 'DESCRIPTION' => $desc); 216 86 217 $action_url = $ url.'&plugin='.$plugin_id;87 $action_url = $plugins->html_base_url . '&plugin=' . $plugin_id; 218 88 219 if (isset($ db_plugins_by_id[$plugin_id]))220 { 221 switch ($ db_plugins_by_id[$plugin_id]['state'])89 if (isset($plugins->db_plugins_by_id[$plugin_id])) 90 { 91 switch ($plugins->db_plugins_by_id[$plugin_id]['state']) 222 92 { 223 93 case 'active': … … 246 116 $tpl_plugin['actions'][] = 247 117 array('U_ACTION' => $action_url . '&action=delete', 248 249 118 'L_ACTION' => l10n('plugins_delete'), 119 'CONFIRM' => l10n('plugins_confirm_delete')); 250 120 } 251 121 $template->append('plugins', $tpl_plugin); … … 253 123 254 124 $missing_plugin_ids = array_diff( 255 array_keys($ db_plugins_by_id), array_keys($fs_plugins)125 array_keys($plugins->db_plugins_by_id), array_keys($plugins->fs_plugins) 256 126 ); 257 127 258 128 foreach($missing_plugin_ids as $plugin_id) 259 129 { 260 $action_url = $ url.'&plugin='.$plugin_id;130 $action_url = $plugins->html_base_url.'&plugin='.$plugin_id; 261 131 262 132 $template->append( 'plugins', 263 133 array( 264 134 'NAME' => $plugin_id, 265 'VERSION' => $ db_plugins_by_id[$plugin_id]['version'],135 'VERSION' => $plugins->db_plugins_by_id[$plugin_id]['version'], 266 136 'DESCRIPTION' => "ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW !", 267 137 'actions' => array ( array ( -
trunk/admin/plugins_new.php
r2255 r2263 2 2 // +-----------------------------------------------------------------------+ 3 3 // | PhpWebGallery - a PHP based picture gallery | 4 // | Copyright (C) 2003-200 8PhpWebGallery Team - http://phpwebgallery.net |4 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | 5 5 // +-----------------------------------------------------------------------+ 6 6 // | file : $Id$ … … 29 29 } 30 30 31 32 $fs_plugins = get_fs_plugins(); 33 $my_base_url= get_root_url().'admin.php'.get_query_string_diff( array('install', 'extension', 'installstatus', 'order') ); 34 31 include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php'); 35 32 36 33 $template->set_filenames(array('plugins' => 'admin/plugins_new.tpl')); 37 34 35 $order = isset($_GET['order']) ? $_GET['order'] : 'date'; 36 37 $plugins = new plugins($page['page'], $order); 38 38 39 39 //------------------------------------------------------automatic installation 40 40 if (isset($_GET['install']) and isset($_GET['extension']) and !is_adviser()) 41 41 { 42 include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); 43 44 $install_status = extract_plugin_files('install', 45 $_GET['install'], 46 $_GET['extension']); 47 48 redirect($my_base_url . '&installstatus=' . $install_status); 42 $plugins->install($_GET['install'], $_GET['extension']); 49 43 } 50 51 44 52 45 //--------------------------------------------------------------install result 53 46 if (isset($_GET['installstatus'])) 54 47 { 55 switch ($_GET['installstatus']) 56 { 57 case 'ok': 58 array_push($page['infos'], l10n('plugins_install_ok'), l10n('plugins_install_need_activate')); 59 break; 60 61 case 'temp_path_error': 62 array_push($page['errors'], l10n('plugins_temp_path_error')); 63 break; 64 65 case 'dl_archive_error': 66 array_push($page['errors'], l10n('plugins_dl_archive_error')); 67 break; 68 69 case 'archive_error': 70 array_push($page['errors'], l10n('plugins_archive_error')); 71 break; 72 73 default: 74 array_push($page['errors'], sprintf(l10n('plugins_extract_error'), $_GET['installstatus']), l10n('plugins_check_chmod')); 75 } 48 $plugins->get_result($_GET['installstatus']); 76 49 } 77 78 79 //----------------------------------------------------------------sort options80 $order = isset($_GET['order']) ? $_GET['order'] : 'date';81 82 $template->assign('order',83 array($my_base_url.'&order=date' => l10n('Post date'),84 $my_base_url.'&order=name' => l10n('Name'),85 $my_base_url.'&order=author' => l10n('Author')));86 87 $template->assign('selected', $my_base_url.'&order='.$order);88 89 50 90 51 // +-----------------------------------------------------------------------+ 91 52 // | start template output | 92 53 // +-----------------------------------------------------------------------+ 93 $plugins_infos = check_server_plugins($fs_plugins, true); 94 if ($plugins_infos !== false) 54 $plugins->tabsheet(); 55 $plugins->check_server_plugins(); 56 $plugins->set_order_options(array( 57 'date' => l10n('Post date'), 58 'name' => l10n('Name'), 59 'author' => l10n('Author'))); 60 61 if ($plugins->server_plugins !== false) 95 62 { 96 if ($order == 'date') krsort($plugins_infos); 97 else uasort($plugins_infos, 'extension_'.$order.'_compare'); 98 99 foreach($plugins_infos as $plugin) 63 foreach($plugins->server_plugins as $plugin) 100 64 { 101 65 $ext_desc = nl2br(htmlspecialchars(strip_tags( … … 108 72 utf8_encode($plugin['description']))))); 109 73 110 $url_auto_install = $ my_base_url111 112 113 114 74 $url_auto_install = $plugins->html_base_url 75 . '&extension=' . $plugin['id_extension'] 76 . '&install=%2Fupload%2Fextension-' . $plugin['id_extension'] 77 . '%2Frevision-' . $plugin['id_revision'] . '%2F' 78 . str_replace(' ', '%20',$plugin['url']); 115 79 116 80 $url_download = PEM_URL .'/upload/extension-'.$plugin['id_extension'] 117 118 . '/' . $plugin['url'];81 . '/revision-' . $plugin['id_revision'] 82 . '/' . str_replace(' ', '%20',$plugin['url']); 119 83 120 84 $template->append('plugins', -
trunk/admin/plugins_update.php
r2255 r2263 2 2 // +-----------------------------------------------------------------------+ 3 3 // | PhpWebGallery - a PHP based picture gallery | 4 // | Copyright (C) 2003-200 8PhpWebGallery Team - http://phpwebgallery.net |4 // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | 5 5 // +-----------------------------------------------------------------------+ 6 6 // | file : $Id$ … … 29 29 } 30 30 31 $fs_plugins = get_fs_plugins(); 32 $my_base_url= get_root_url().'admin.php'.get_query_string_diff( array('upgrade', 'plugin', 'reactivate', 'action', 'upgradestatus') ); 33 34 $db_plugins = get_db_plugins(); 35 $db_plugins_by_id = array(); 36 foreach ($db_plugins as $db_plugin) 37 { 38 $db_plugins_by_id[$db_plugin['id']] = $db_plugin; 39 } 31 include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php'); 40 32 41 33 $template->set_filenames(array('plugins' => 'admin/plugins_update.tpl')); 42 34 35 $plugins = new plugins($page['page']); 43 36 44 37 //-----------------------------------------------------------automatic upgrade 45 38 if (isset($_GET['upgrade']) and isset($_GET['plugin']) and !is_adviser()) 46 39 { 47 include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); 48 49 $upgrade_status = extract_plugin_files('upgrade', 50 $_GET['upgrade'], 51 $_GET['plugin']); 52 53 $my_base_url .= isset($_GET['reactivate']) ? '&action=activate' : ''; 54 55 redirect($my_base_url.'&plugin='.$_GET['plugin'].'&upgradestatus='.$upgrade_status); 40 $plugins->upgrade($_GET['upgrade'], $_GET['plugin']); 56 41 } 57 58 42 59 43 //--------------------------------------------------------------upgrade result 60 44 if (isset($_GET['upgradestatus']) and isset($_GET['plugin'])) 61 45 { 62 switch ($_GET['upgradestatus']) 63 { 64 case 'ok': 65 array_push($page['infos'], 66 sprintf(l10n('plugins_upgrade_ok'), 67 $fs_plugins[$_GET['plugin']]['name'])); 68 break; 69 70 case 'temp_path_error': 71 array_push($page['errors'], l10n('plugins_temp_path_error')); 72 break; 73 74 case 'dl_archive_error': 75 array_push($page['errors'], l10n('plugins_dl_archive_error')); 76 break; 77 78 case 'archive_error': 79 array_push($page['errors'], l10n('plugins_archive_error')); 80 break; 81 82 default: 83 array_push($page['errors'], 84 sprintf(l10n('plugins_extract_error'), 85 $_GET['upgradestatus'])); 86 } 46 $plugins->get_result($_GET['upgradestatus'], $_GET['plugin']); 87 47 } 88 89 48 90 49 // +-----------------------------------------------------------------------+ 91 50 // | start template output | 92 51 // +-----------------------------------------------------------------------+ 93 $plugins_infos = check_server_plugins($fs_plugins); 52 $plugins->tabsheet(); 53 $plugins->check_server_plugins(); 94 54 95 if ($plugins _infos !== false)55 if ($plugins->server_plugins !== false) 96 56 { 97 foreach($ fs_plugins as $plugin_id => $fs_plugin)57 foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) 98 58 { 99 59 if (isset($fs_plugin['extension']) 100 and isset($plugins _infos[$fs_plugin['extension']]))60 and isset($plugins->server_plugins[$fs_plugin['extension']])) 101 61 { 102 $plugin_info = $plugins _infos[$fs_plugin['extension']];62 $plugin_info = $plugins->server_plugins[$fs_plugin['extension']]; 103 63 104 64 $ext_desc = nl2br(htmlspecialchars(strip_tags( … … 106 66 107 67 $ver_desc = sprintf(l10n('plugins_description'), 108 109 110 111 68 $plugin_info['version'], 69 date('Y-m-d', $plugin_info['date']), 70 nl2br(htmlspecialchars(strip_tags( 71 utf8_encode($plugin_info['description']))))); 112 72 113 if ($plugin _info['version'] == $fs_plugin['version'])73 if ($plugins->plugin_version_compare($fs_plugin, $plugin_info) >= 0) 114 74 { 115 75 // Plugin is up to date … … 118 78 'NAME' => $fs_plugin['name'], 119 79 'EXT_DESC' => $ext_desc, 120 'VERSION' => $fs_plugin['version'], 121 'VER_DESC' => $ver_desc)); 80 'VERSION' => $fs_plugin['version'])); 122 81 } 123 82 else 124 83 { 125 84 // Plugin need upgrade 126 $url_auto_update = $ my_base_url85 $url_auto_update = $plugins->html_base_url 127 86 . '&plugin=' . $plugin_id 128 . (129 (isset($db_plugins_by_id[$plugin_id])130 and $db_plugins_by_id[$plugin_id]['state'] == 'active') ?131 '&action=deactivate' : ''132 )133 87 . '&upgrade=%2Fupload%2Fextension-' . $fs_plugin['extension'] 134 88 . '%2Frevision-' . $plugin_info['id_revision'] 135 . '%2F' . $plugin_info['url'];89 . '%2F' . str_replace(' ', '%20',$plugin_info['url']); 136 90 137 91 $url_download = PEM_URL.'/upload/extension-'. $fs_plugin['extension'] 138 139 . '/' . $plugin_info['url'];92 . '/revision-' . $plugin_info['id_revision'] 93 . '/' . str_replace(' ', '%20',$plugin_info['url']); 140 94 141 95 $template->append('plugins_not_uptodate', -
trunk/template/yoga/admin/plugins_list.tpl
r2243 r2263 6 6 {'Sort order'|@translate} : 7 7 <select onchange="document.location = this.options[this.selectedIndex].value;" style="width:100px"> 8 {html_options options=$order selected=$selected}8 {html_options options=$order_options selected=$order_selected} 9 9 </select> 10 10 -
trunk/template/yoga/admin/plugins_new.tpl
r2243 r2263 6 6 {'Sort order'|@translate} : 7 7 <select onchange="document.location = this.options[this.selectedIndex].value;" style="width:120px"> 8 {html_options options=$order selected=$selected}8 {html_options options=$order_options selected=$order_selected} 9 9 </select> 10 10 -
trunk/template/yoga/admin/plugins_update.tpl
r2245 r2263 45 45 <td><a href="{$plugin.URL}" onclick="window.open(this.href); return false;" class="tooltip">{$plugin.NAME} 46 46 <span>{$plugin.EXT_DESC}</span></a></td> 47 <td style="text-align:center;"> <span class="tooltip">{$plugin.VERSION}<span>{$plugin.VER_DESC}</span></span></td>47 <td style="text-align:center;">{$plugin.VERSION}</td> 48 48 </tr> 49 49 {/foreach}
Note: See TracChangeset
for help on using the changeset viewer.