Changeset 2264
- Timestamp:
- Mar 7, 2008, 6:15:46 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/plugins.class.php
r2263 r2264 27 27 class plugins 28 28 { 29 var $page = '';30 var $order = '';31 var $my_base_url = '';32 var $html_base_url = '';33 29 var $fs_plugins = array(); 34 30 var $db_plugins_by_id = array(); 35 31 var $server_plugins = array(); 36 32 37 function plugins($page='', $order='') 38 { 39 $this->page = $page; 40 $this->order = $order; 41 42 $this->my_base_url = get_root_url().'admin.php?page='.$this->page; 43 if (!empty($this->order)) 44 { 45 $this->my_base_url .= '&order=' . $this->order; 46 } 47 $this->html_base_url = htmlentities($this->my_base_url); 48 33 /** 34 * Initialize $fs_plugins and $db_plugins_by_id 35 */ 36 function plugins() 37 { 49 38 $this->get_fs_plugins(); 39 50 40 foreach (get_db_plugins() as $db_plugin) 51 41 { … … 54 44 } 55 45 56 /**57 * Assign tabsheet58 */59 function tabsheet()60 {61 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');62 $link = PHPWG_ROOT_PATH.'admin.php?page=';63 64 $tabsheet = new tabsheet();65 $tabsheet->add('plugins_list', l10n('plugins_tab_list'), $link.'plugins_list');66 $tabsheet->add('plugins_update', l10n('plugins_tab_update'), $link.'plugins_update');67 $tabsheet->add('plugins_new', l10n('plugins_tab_new'), $link.'plugins_new');68 $tabsheet->select($this->page);69 $tabsheet->assign();70 }71 72 /**73 * Set order74 * @param array - order options75 */76 function set_order_options($options)77 {78 global $template;79 80 $link = get_root_url().'admin.php?page='.$this->page.'&order=';81 foreach($options as $key => $value)82 {83 $tpl_options[$link . $key] = $value;84 }85 $template->assign('order_options', $tpl_options);86 $template->assign('order_selected', $link . $this->order);87 }88 89 46 /** 90 47 * Perform requested actions 91 48 * @param string - action 92 49 * @param string - plugin id 93 * @param string- errors50 * @param array - errors 94 51 */ 95 52 function perform_action($action, $plugin_id, $errors=array()) … … 220 177 221 178 /** 222 * Returns an array ofplugins defined in the plugin directory179 * Get plugins defined in the plugin directory 223 180 */ 224 181 function get_fs_plugins() … … 283 240 284 241 /** 285 * sort fs_plugins 286 */ 287 function sort_fs_plugins() 288 { 289 switch ($this->order) 290 { 242 * Sort fs_plugins 243 */ 244 function sort_fs_plugins($order='name') 245 { 246 switch ($order) 247 { 248 case 'name': 249 uasort($this->fs_plugins, 'name_compare'); 250 break; 291 251 case 'status': 292 252 $this->sort_plugins_by_state(); … … 298 258 uksort($this->fs_plugins, 'strcasecmp'); 299 259 break; 300 default: //sort by plugin name 301 uasort($this->fs_plugins, 'name_compare'); 302 } 303 } 304 305 /** 306 * Retrieve PEM server datas 307 */ 308 function check_server_plugins() 309 { 310 foreach($this->fs_plugins as $plugin_id => $fs_plugin) 260 } 261 } 262 263 /** 264 * Retrieve PEM server datas to $server_plugins 265 */ 266 function get_server_plugins($new=false) 267 { 268 foreach($this->fs_plugins as $fs_plugin) 311 269 { 312 270 if (isset($fs_plugin['extension'])) … … 316 274 } 317 275 $url = PEM_URL . '/uptodate.php?version=' . rawurlencode(PHPWG_VERSION) . '&extensions=' . implode(',', $plugins_to_check); 318 $url .= $ this->page == 'plugins_new'? '&newext=Plugin' : '';276 $url .= $new ? '&newext=Plugin' : ''; 319 277 320 278 if (!empty($plugins_to_check) and $source = @file_get_contents($url)) 321 279 { 322 280 $this->server_plugins = @unserialize($source); 323 switch ($this->order)324 {325 case 'name':326 uasort($this->server_plugins, array($this, 'extension_name_compare'));327 break;328 case 'author':329 uasort($this->server_plugins, array($this, 'extension_author_compare'));330 break;331 default: // sort by id desc332 krsort($this->server_plugins);333 }334 281 } 335 282 else … … 338 285 } 339 286 } 340 341 /** 342 * Upgrade plugin 343 * @param string - archive URL 344 * @param string - plugin id 345 */ 346 function upgrade($source, $plugin_id) 347 { 348 if (isset($this->db_plugins_by_id[$plugin_id]) 349 and $this->db_plugins_by_id[$plugin_id]['state'] == 'active') 350 { 351 $this->perform_action('deactivate', $plugin_id); 352 353 redirect( 354 $this->my_base_url 355 . '&upgrade=' . $source 356 . '&plugin=' . $plugin_id 357 . '&reactivate=true'); 358 } 359 360 include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); 361 $upgrade_status = $this->extract_plugin_files('upgrade', $source, $plugin_id); 362 363 if (isset($_GET['reactivate'])) 364 { 365 $this->perform_action('activate', $plugin_id); 366 } 367 redirect($this->my_base_url.'&plugin='.$plugin_id.'&upgradestatus='.$upgrade_status); 368 } 369 370 371 /** 372 * Install plugin 373 * @param string - archive URL 374 * @param string - extension id 375 */ 376 function install($source, $extension) 377 { 378 include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); 379 $install_status = $this->extract_plugin_files('install', $source, $extension); 380 381 redirect($this->my_base_url.'&installstatus='.$install_status); 382 } 383 287 288 /** 289 * Sort $server_plugins 290 */ 291 function sort_server_plugins($order='date') 292 { 293 switch ($order) 294 { 295 case 'date': 296 krsort($this->server_plugins); 297 break; 298 case 'name': 299 uasort($this->server_plugins, array($this, 'extension_name_compare')); 300 break; 301 case 'author': 302 uasort($this->server_plugins, array($this, 'extension_author_compare')); 303 break; 304 } 305 } 384 306 385 307 /** … … 395 317 if (@copy(PEM_URL . str_replace(' ', '%20', $source), $archive)) 396 318 { 319 include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); 397 320 $zip = new PclZip($archive); 398 321 if ($list = $zip->listContent()) … … 448 371 449 372 /** 450 * get install or upgrade result451 */452 function get_result($result, $plugin='')453 {454 global $page;455 456 switch ($result)457 {458 case 'ok':459 if ($this->page == 'plugins_update')460 {461 array_push($page['infos'],462 sprintf(463 l10n('plugins_upgrade_ok'),464 $this->fs_plugins[$plugin]['name']));465 }466 else467 {468 array_push($page['infos'],469 l10n('plugins_install_ok'),470 l10n('plugins_install_need_activate'));471 }472 break;473 474 case 'temp_path_error':475 array_push($page['errors'], l10n('plugins_temp_path_error'));476 break;477 478 case 'dl_archive_error':479 array_push($page['errors'], l10n('plugins_dl_archive_error'));480 break;481 482 case 'archive_error':483 array_push($page['errors'], l10n('plugins_archive_error'));484 break;485 486 default:487 array_push($page['errors'],488 sprintf(l10n('plugins_extract_error'), $result),489 l10n('plugins_check_chmod'));490 }491 }492 493 /**494 373 * delete $path directory 495 374 * @param string - path … … 522 401 /** 523 402 * send $path to trash directory 524 403 * @param string - path 525 404 */ 526 405 function send_to_trash($path) -
trunk/admin/plugins_list.php
r2263 r2264 34 34 35 35 $order = isset($_GET['order']) ? $_GET['order'] : 'name'; 36 $plugins = new plugins($page['page'], $order); 36 $base_url = get_root_url().'admin.php?page='.$page['page'].'&order='.$order; 37 38 $plugins = new plugins(); 37 39 38 40 //--------------------------------------------------perform requested actions … … 41 43 $page['errors'] = 42 44 $plugins->perform_action($_GET['action'], $_GET['plugin'], $page['errors']); 43 44 if (empty($page['errors'])) redirect($ plugins->my_base_url);45 46 if (empty($page['errors'])) redirect($base_url); 45 47 } 48 49 //--------------------------------------------------------------------Tabsheet 50 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 51 $link = get_root_url().'admin.php?page='; 52 $tabsheet = new tabsheet(); 53 $tabsheet->add('plugins_list', l10n('plugins_tab_list'), $link.'plugins_list'); 54 $tabsheet->add('plugins_update', l10n('plugins_tab_update'), $link.'plugins_update'); 55 $tabsheet->add('plugins_new', l10n('plugins_tab_new'), $link.'plugins_new'); 56 $tabsheet->select($page['page']); 57 $tabsheet->assign(); 58 59 //---------------------------------------------------------------Order options 60 $link .= $page['page'].'&order='; 61 $template->assign('order_options', 62 array( 63 $link.'name' => l10n('Name'), 64 $link.'status' => l10n('Status'), 65 $link.'author' => l10n('Author'), 66 $link.'id' => 'Id')); 67 $template->assign('order_selected', $link.$order); 46 68 47 69 // +-----------------------------------------------------------------------+ 48 70 // | start template output | 49 71 // +-----------------------------------------------------------------------+ 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 72 $plugins->sort_fs_plugins($order); 73 58 74 foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) 59 75 { … … 85 101 'DESCRIPTION' => $desc); 86 102 87 $action_url = $plugins->html_base_url . '&plugin=' .$plugin_id;103 $action_url = htmlentities($base_url).'&plugin='.$plugin_id; 88 104 89 105 if (isset($plugins->db_plugins_by_id[$plugin_id])) … … 128 144 foreach($missing_plugin_ids as $plugin_id) 129 145 { 130 $action_url = $plugins->html_base_url.'&plugin='.$plugin_id;146 $action_url = htmlentities($base_url).'&plugin='.$plugin_id; 131 147 132 148 $template->append( 'plugins', -
trunk/admin/plugins_new.php
r2263 r2264 34 34 35 35 $order = isset($_GET['order']) ? $_GET['order'] : 'date'; 36 $base_url = get_root_url().'admin.php?page='.$page['page'].'&order='.$order; 36 37 37 $plugins = new plugins( $page['page'], $order);38 $plugins = new plugins(); 38 39 39 40 //------------------------------------------------------automatic installation 40 41 if (isset($_GET['install']) and isset($_GET['extension']) and !is_adviser()) 41 42 { 42 $plugins->install($_GET['install'], $_GET['extension']); 43 $install_status = 44 $plugins->extract_plugin_files('install', $_GET['install'], $_GET['extension']); 45 46 redirect($base_url.'&installstatus='.$install_status); 43 47 } 44 48 … … 46 50 if (isset($_GET['installstatus'])) 47 51 { 48 $plugins->get_result($_GET['installstatus']); 52 switch ($_GET['installstatus']) 53 { 54 case 'ok': 55 array_push($page['infos'], 56 l10n('plugins_install_ok'), 57 l10n('plugins_install_need_activate')); 58 break; 59 60 case 'temp_path_error': 61 array_push($page['errors'], l10n('plugins_temp_path_error')); 62 break; 63 64 case 'dl_archive_error': 65 array_push($page['errors'], l10n('plugins_dl_archive_error')); 66 break; 67 68 case 'archive_error': 69 array_push($page['errors'], l10n('plugins_archive_error')); 70 break; 71 72 default: 73 array_push($page['errors'], 74 sprintf(l10n('plugins_extract_error'), $_GET['installstatus']), 75 l10n('plugins_check_chmod')); 76 } 49 77 } 78 79 //--------------------------------------------------------------------Tabsheet 80 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 81 $link = get_root_url().'admin.php?page='; 82 $tabsheet = new tabsheet(); 83 $tabsheet->add('plugins_list', l10n('plugins_tab_list'), $link.'plugins_list'); 84 $tabsheet->add('plugins_update', l10n('plugins_tab_update'), $link.'plugins_update'); 85 $tabsheet->add('plugins_new', l10n('plugins_tab_new'), $link.'plugins_new'); 86 $tabsheet->select($page['page']); 87 $tabsheet->assign(); 88 89 //---------------------------------------------------------------Order options 90 $link .= $page['page'].'&order='; 91 $template->assign('order_options', 92 array( 93 $link.'date' => l10n('Post date'), 94 $link.'name' => l10n('Name'), 95 $link.'author' => l10n('Author'))); 96 $template->assign('order_selected', $link.$order); 50 97 51 98 // +-----------------------------------------------------------------------+ 52 99 // | start template output | 53 100 // +-----------------------------------------------------------------------+ 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'))); 101 $plugins->get_server_plugins(true); 102 $plugins->sort_server_plugins($order); 60 103 61 104 if ($plugins->server_plugins !== false) … … 72 115 utf8_encode($plugin['description']))))); 73 116 74 $url_auto_install = $plugins->html_base_url117 $url_auto_install = htmlentities($base_url) 75 118 . '&extension=' . $plugin['id_extension'] 76 119 . '&install=%2Fupload%2Fextension-' . $plugin['id_extension'] -
trunk/admin/plugins_update.php
r2263 r2264 33 33 $template->set_filenames(array('plugins' => 'admin/plugins_update.tpl')); 34 34 35 $plugins = new plugins($page['page']); 35 $base_url = get_root_url().'admin.php?page='.$page['page']; 36 37 $plugins = new plugins(); 36 38 37 39 //-----------------------------------------------------------automatic upgrade 38 40 if (isset($_GET['upgrade']) and isset($_GET['plugin']) and !is_adviser()) 39 41 { 40 $plugins->upgrade($_GET['upgrade'], $_GET['plugin']); 42 $plugin_id = $_GET['plugin']; 43 44 if (isset($plugins->db_plugins_by_id[$plugin_id]) 45 and $plugins->db_plugins_by_id[$plugin_id]['state'] == 'active') 46 { 47 $plugins->perform_action('deactivate', $plugin_id); 48 49 redirect($base_url 50 . '&upgrade=' . $_GET['upgrade'] 51 . '&plugin=' . $plugin_id 52 . '&reactivate=true'); 53 } 54 55 $upgrade_status = 56 $plugins->extract_plugin_files('upgrade', $_GET['upgrade'], $plugin_id); 57 58 if (isset($_GET['reactivate'])) 59 { 60 $plugins->perform_action('activate', $plugin_id); 61 } 62 redirect($base_url.'&plugin='.$plugin_id.'&upgradestatus='.$upgrade_status); 41 63 } 42 64 … … 44 66 if (isset($_GET['upgradestatus']) and isset($_GET['plugin'])) 45 67 { 46 $plugins->get_result($_GET['upgradestatus'], $_GET['plugin']); 68 switch ($_GET['upgradestatus']) 69 { 70 case 'ok': 71 array_push($page['infos'], 72 sprintf( 73 l10n('plugins_upgrade_ok'), 74 $plugins->fs_plugins[$_GET['plugin']]['name'])); 75 break; 76 77 case 'temp_path_error': 78 array_push($page['errors'], l10n('plugins_temp_path_error')); 79 break; 80 81 case 'dl_archive_error': 82 array_push($page['errors'], l10n('plugins_dl_archive_error')); 83 break; 84 85 case 'archive_error': 86 array_push($page['errors'], l10n('plugins_archive_error')); 87 break; 88 89 default: 90 array_push($page['errors'], 91 sprintf(l10n('plugins_extract_error'), $_GET['installstatus']), 92 l10n('plugins_check_chmod')); 93 } 47 94 } 95 96 //--------------------------------------------------------------------Tabsheet 97 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 98 $link = get_root_url().'admin.php?page='; 99 $tabsheet = new tabsheet(); 100 $tabsheet->add('plugins_list', l10n('plugins_tab_list'), $link.'plugins_list'); 101 $tabsheet->add('plugins_update', l10n('plugins_tab_update'), $link.'plugins_update'); 102 $tabsheet->add('plugins_new', l10n('plugins_tab_new'), $link.'plugins_new'); 103 $tabsheet->select($page['page']); 104 $tabsheet->assign(); 48 105 49 106 // +-----------------------------------------------------------------------+ 50 107 // | start template output | 51 108 // +-----------------------------------------------------------------------+ 52 $plugins->tabsheet(); 53 $plugins->check_server_plugins(); 109 $plugins->get_server_plugins(); 54 110 55 111 if ($plugins->server_plugins !== false) … … 83 139 { 84 140 // Plugin need upgrade 85 $url_auto_update = $ plugins->html_base_url141 $url_auto_update = $base_url 86 142 . '&plugin=' . $plugin_id 87 143 . '&upgrade=%2Fupload%2Fextension-' . $fs_plugin['extension'] -
trunk/include/constants.php
r2242 r2264 29 29 define('PHPWG_DOMAIN', 'phpwebgallery.net'); 30 30 define('PHPWG_URL', 'http://www.'.PHPWG_DOMAIN); 31 define('PEM_URL', PHPWG_URL. '/ext');31 define('PEM_URL', 'http://' . PHPWG_DOMAIN . '/ext'); 32 32 define('PHPWG_DEFAULT_LANGUAGE', 'en_UK'); 33 33 define('PHPWG_DEFAULT_TEMPLATE', 'yoga/clear');
Note: See TracChangeset
for help on using the changeset viewer.