Changeset 10098
- Timestamp:
- Apr 6, 2011, 11:43:46 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/plugins.class.php
r8728 r10098 27 27 var $db_plugins_by_id = array(); 28 28 var $server_plugins = array(); 29 var $default_plugins = array('LocalFilesEditor', 'language_switch', 'c13y_upgrade', 'admin_multi_view'); 29 30 30 31 /** … … 186 187 break; 187 188 } 189 $query = ' 190 DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\''; 191 pwg_query($query); 188 192 if (!$this->deltree(PHPWG_PLUGINS_PATH . $plugin_id)) 189 193 { … … 284 288 } 285 289 290 // Retrieve PEM versions 291 function get_versions_to_check($version=PHPWG_VERSION) 292 { 293 $versions_to_check = array(); 294 $url = PEM_URL . '/api/get_version_list.php?category=12&format=php'; 295 if (fetchRemote($url, $result) and $pem_versions = @unserialize($result)) 296 { 297 if (!preg_match('/^\d+\.\d+\.\d+/', $version)) 298 { 299 $version = $pem_versions[0]['name']; 300 } 301 $branch = substr($version, 0, strrpos($version, '.')); 302 foreach ($pem_versions as $pem_version) 303 { 304 if (strpos($pem_version['name'], $branch) === 0) 305 { 306 $versions_to_check[] = $pem_version['id']; 307 } 308 } 309 } 310 return $versions_to_check; 311 } 312 286 313 /** 287 314 * Retrieve PEM server datas to $server_plugins … … 291 318 global $user; 292 319 320 $versions_to_check = $this->get_versions_to_check(); 321 if (empty($versions_to_check)) 322 { 323 return false; 324 } 325 326 // Plugins to check 327 $plugins_to_check = array(); 328 foreach($this->fs_plugins as $fs_plugin) 329 { 330 if (isset($fs_plugin['extension'])) 331 { 332 $plugins_to_check[] = $fs_plugin['extension']; 333 } 334 } 335 336 // Retrieve PEM plugins infos 337 $url = PEM_URL . '/api/get_revision_list.php'; 293 338 $get_data = array( 294 339 'category_id' => 12, 295 340 'format' => 'php', 296 );297 298 // Retrieve PEM versions299 $version = PHPWG_VERSION;300 $versions_to_check = array();301 $url = PEM_URL . '/api/get_version_list.php';302 if (fetchRemote($url, $result, $get_data) and $pem_versions = @unserialize($result))303 {304 if (!preg_match('/^\d+\.\d+\.\d+/', $version))305 {306 $version = $pem_versions[0]['name'];307 }308 $branch = substr($version, 0, strrpos($version, '.'));309 foreach ($pem_versions as $pem_version)310 {311 if (strpos($pem_version['name'], $branch) === 0)312 {313 $versions_to_check[] = $pem_version['id'];314 }315 }316 }317 if (empty($versions_to_check))318 {319 return false;320 }321 322 // Plugins to check323 $plugins_to_check = array();324 foreach($this->fs_plugins as $fs_plugin)325 {326 if (isset($fs_plugin['extension']))327 {328 $plugins_to_check[] = $fs_plugin['extension'];329 }330 }331 332 // Retrieve PEM plugins infos333 $url = PEM_URL . '/api/get_revision_list.php';334 $get_data = array_merge($get_data, array(335 341 'last_revision_only' => 'true', 336 342 'version' => implode(',', $versions_to_check), 337 343 'lang' => substr($user['language'], 0, 2), 338 344 'get_nb_downloads' => 'true', 339 )340 345 ); 341 346 … … 363 368 } 364 369 return true; 370 } 371 return false; 372 } 373 374 function get_incompatible_plugins() 375 { 376 if (isset($_SESSION['incompatible_plugins'])) 377 { 378 return $_SESSION['incompatible_plugins']; 379 } 380 381 $_SESSION['incompatible_plugins'] = array(); 382 383 $versions_to_check = $this->get_versions_to_check(); 384 if (empty($versions_to_check)) 385 { 386 return false; 387 } 388 389 // Plugins to check 390 $plugins_to_check = array(); 391 foreach($this->fs_plugins as $fs_plugin) 392 { 393 if (isset($fs_plugin['extension'])) 394 { 395 $plugins_to_check[] = $fs_plugin['extension']; 396 } 397 } 398 399 // Retrieve PEM plugins infos 400 $url = PEM_URL . '/api/get_revision_list.php'; 401 $get_data = array( 402 'category_id' => 12, 403 'format' => 'php', 404 'version' => implode(',', $versions_to_check), 405 'extension_include' => implode(',', $plugins_to_check), 406 ); 407 408 if (fetchRemote($url, $result, $get_data)) 409 { 410 $pem_plugins = @unserialize($result); 411 if (!is_array($pem_plugins)) 412 { 413 return false; 414 } 415 416 $server_plugins = array(); 417 foreach ($pem_plugins as $plugin) 418 { 419 if (!isset($server_plugins[$plugin['extension_id']])) 420 { 421 $server_plugins[$plugin['extension_id']] = array(); 422 } 423 array_push($server_plugins[$plugin['extension_id']], $plugin['revision_name']); 424 } 425 426 foreach ($this->fs_plugins as $plugin_id => $fs_plugin) 427 { 428 if (isset($fs_plugin['extension']) 429 and !in_array($plugin_id, $this->default_plugins) 430 and $fs_plugin['version'] != 'auto' 431 and (!isset($server_plugins[$fs_plugin['extension']]) or !in_array($fs_plugin['version'], $server_plugins[$fs_plugin['extension']]))) 432 { 433 $_SESSION['incompatible_plugins'][$plugin_id] = $fs_plugin['version']; 434 } 435 } 436 return $_SESSION['incompatible_plugins']; 365 437 } 366 438 return false; … … 484 556 return $status; 485 557 } 558 559 function get_merged_extensions($version=PHPWG_VERSION) 560 { 561 if (!isset($_SESSION['merged_extensions'])) 562 { 563 $_SESSION['merged_extensions'] = array(); 564 if (fetchRemote(MERGED_EXTENSIONS_URL, $result)) 565 { 566 $rows = explode("\n", $result); 567 foreach ($rows as $row) 568 { 569 if (preg_match('/^(\d+\.\d+): *(.*)$/', $row, $match)) 570 { 571 if (version_compare($version, $match[1], '>=')) 572 { 573 $extensions = explode(',', trim($match[2])); 574 $_SESSION['merged_extensions'] = array_merge($_SESSION['merged_extensions'], $extensions); 575 } 576 } 577 } 578 } 579 } 580 return $_SESSION['merged_extensions']; 581 } 486 582 487 583 /** -
trunk/admin/plugins_list.php
r9995 r10098 68 68 69 69 $plugins->sort_fs_plugins('name'); 70 $plugins->get_merged_extensions(); 71 $plugins->get_incompatible_plugins(); 72 $merged_plugins = array(); 70 73 71 74 foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) 72 75 { 76 if (isset($_SESSION['incompatible_plugins'][$plugin_id]) 77 and $fs_plugin['version'] != $_SESSION['incompatible_plugins'][$plugin_id]) 78 { 79 // Incompatible plugins must be reinitilized 80 unset($_SESSION['incompatible_plugins']); 81 $plugins->get_incompatible_plugins(); 82 } 83 73 84 $tpl_plugin = array( 74 85 'NAME' => $fs_plugin['name'], … … 78 89 'AUTHOR' => $fs_plugin['author'], 79 90 'AUTHOR_URL' => @$fs_plugin['author uri'], 80 'U_ACTION' => sprintf($action_url, $plugin_id) 91 'U_ACTION' => sprintf($action_url, $plugin_id), 92 'INCOMPATIBLE' => isset($_SESSION['incompatible_plugins'][$plugin_id]), 81 93 ); 94 95 if (isset($fs_plugin['extension']) and in_array($fs_plugin['extension'], $_SESSION['merged_extensions'])) 96 { 97 $tpl_plugin['STATE'] = 'merged'; 98 array_push($merged_plugins, $tpl_plugin); 99 continue; 100 } 82 101 83 102 if (isset($plugins->db_plugins_by_id[$plugin_id])) … … 93 112 } 94 113 114 $template->append('plugin_states', 'active'); 115 $template->append('plugin_states', 'inactive'); 116 $template->append('plugin_states', 'uninstalled'); 117 95 118 $missing_plugin_ids = array_diff( 96 119 array_keys($plugins->db_plugins_by_id), … … 98 121 ); 99 122 100 foreach($missing_plugin_ids as $plugin_id)123 if (count($missing_plugin_ids) > 0) 101 124 { 102 $template->append( 103 'plugins', 104 array( 105 'NAME' => $plugin_id, 106 'VERSION' => $plugins->db_plugins_by_id[$plugin_id]['version'], 107 'DESC' => "ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW !", 108 'U_ACTION' => sprintf($action_url, $plugin_id), 109 'STATE' => 'missing', 110 ) 111 ); 125 foreach($missing_plugin_ids as $plugin_id) 126 { 127 $template->append( 128 'plugins', 129 array( 130 'NAME' => $plugin_id, 131 'VERSION' => $plugins->db_plugins_by_id[$plugin_id]['version'], 132 'DESC' => "ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW !", 133 'U_ACTION' => sprintf($action_url, $plugin_id), 134 'STATE' => 'missing', 135 ) 136 ); 137 } 138 $template->append('plugin_states', 'missing'); 112 139 } 113 140 114 $template->append('plugin_states', 'active'); 115 $template->append('plugin_states', 'inactive'); 116 $template->append('plugin_states', 'uninstalled'); 117 118 if (count($missing_plugin_ids) > 0) 141 if (count($merged_plugins) > 0) 119 142 { 120 $template->append('plugin_states', 'missing'); 143 foreach($merged_plugins as $tpl_plugin) 144 { 145 $tpl_plugin['DESC'] = l10n("THIS PLUGIN IS NOW PART OF PIWIGO CORE. UNINSTALL IT NOW."); 146 $template->append('plugins', $tpl_plugin); 147 } 148 $template->append('plugin_states', 'merged'); 121 149 } 122 150 -
trunk/admin/themes/default/template/plugins_list.tpl
r6363 r10098 1 {footer_script} 2 var incompatible_msg = '{'WARNING! This plugin does not seem to be compatible with this version of Piwigo.'|@translate|@escape:'javascript'}'; 3 incompatible_msg += '\n'; 4 incompatible_msg += '{'Do you want to activate anyway?'|@translate|@escape:'javascript'}'; 5 6 {literal} 7 jQuery(document).ready(function() { 8 jQuery('.incompatible').click(function() { 9 return confirm(incompatible_msg); 10 }); 11 }); 12 {/literal}{/footer_script} 13 1 14 <div class="titrePage"> 2 15 <h2>{'Plugins'|@translate}</h2> … … 20 33 {'Missing Plugins'|@translate} 21 34 35 {elseif $plugin_state == 'merged'} 36 {'Obsolete Plugins'|@translate} 37 22 38 {/if} 23 39 </legend> … … 36 52 37 53 {elseif $plugin_state == 'inactive'} 38 <a href="{$plugin.U_ACTION}&action=activate" >{'Activate'|@translate}</a>54 <a href="{$plugin.U_ACTION}&action=activate" {if $plugin.INCOMPATIBLE}class="incompatible"{/if}>{'Activate'|@translate}</a> 39 55 | <a href="{$plugin.U_ACTION}&action=uninstall" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Uninstall'|@translate}</a> 40 56 … … 43 59 | <a href="{$plugin.U_ACTION}&action=delete" onclick="return confirm('{'Are you sure you want to delete this plugin?'|@translate|@escape:'javascript'}');">{'Delete'|@translate}</a> 44 60 45 {elseif $plugin_state == 'missing' }61 {elseif $plugin_state == 'missing' or $plugin_state == 'merged'} 46 62 <a href="{$plugin.U_ACTION}&action=uninstall" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Uninstall'|@translate}</a> 47 63 -
trunk/include/common.inc.php
r8728 r10098 157 157 define('PEM_URL', 'http://'.PHPWG_DOMAIN.'/ext'); 158 158 } 159 define('MERGED_EXTENSIONS_URL', 'http://'.PHPWG_DOMAIN.'/download/merged_extensions.txt'); 159 160 160 161
Note: See TracChangeset
for help on using the changeset viewer.