Changeset 11043


Ignore:
Timestamp:
May 25, 2011, 11:57:56 AM (13 years ago)
Author:
patdenice
Message:

feature:2250
Add obsolete_extensions.list file in install directory.
Incompatible plugins is checked through ajax.

Location:
branches/2.2
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/admin/include/plugins.class.php

    r10131 r11043  
    557557  function get_merged_extensions($version=PHPWG_VERSION)
    558558  {
    559     if (isset($_SESSION['merged_extensions']) and $_SESSION['merged_extensions']['~~expire~~'] > time())
    560     {
    561       return $_SESSION['merged_extensions'];
    562     }
    563 
    564     $_SESSION['merged_extensions'] = array('~~expire~~' => time() + 600);
    565 
    566     if (fetchRemote(PHPWG_URL.'/download/merged_extensions.txt', $result))
    567     {
    568       $rows = explode("\n", $result);
    569       foreach ($rows as $row)
    570       {
    571         if (preg_match('/^(\d+\.\d+): *(.*)$/', $row, $match))
    572         {
    573           if (version_compare($version, $match[1], '>='))
    574           {
    575             $extensions = explode(',', trim($match[2]));
    576             $_SESSION['merged_extensions'] = array_merge($_SESSION['merged_extensions'], $extensions);
    577           }
    578         }
    579       }
    580     }
    581 
    582     return $_SESSION['merged_extensions'];
     559    $file = PHPWG_ROOT_PATH.'install/obsolete_extensions.list';
     560    $merged_extensions = array();
     561
     562    if (file_exists($file) and $obsolete_ext = file($file, FILE_IGNORE_NEW_LINES) and !empty($obsolete_ext))
     563    {
     564      foreach ($obsolete_ext as $ext)
     565      {
     566        if (preg_match('/^(\d+) ?: ?(.*?)$/', $ext, $matches))
     567        {
     568          $merged_extensions[$matches[1]] = $matches[2];
     569        }
     570      }
     571    }
     572    return $merged_extensions;
    583573  }
    584574 
  • branches/2.2/admin/plugins_list.php

    r10131 r11043  
    6363$plugins->set_tabsheet($page['page']);
    6464
     65//--------------------------------------------------------Incompatible Plugins
     66if (isset($_GET['incompatible_plugins']))
     67{
     68  $incompatible_plugins = array();
     69  foreach ($plugins->get_incompatible_plugins() as $plugin => $version)
     70  {
     71    if ($plugin == '~~expire~~') continue;
     72    array_push($incompatible_plugins, $plugin);
     73   
     74  }
     75  echo json_encode($incompatible_plugins);
     76  exit;
     77}
     78
    6579// +-----------------------------------------------------------------------+
    6680// |                     start template output                             |
     
    6882
    6983$plugins->sort_fs_plugins('name');
    70 $plugins->get_merged_extensions();
    71 $plugins->get_incompatible_plugins();
     84$merged_extensions = $plugins->get_merged_extensions();
     85$incompatible_plugins = $plugins->get_incompatible_plugins();
    7286$merged_plugins = false;
    7387
    7488foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
    7589{
    76   if (isset($_SESSION['incompatible_plugins'][$plugin_id])
    77     and $fs_plugin['version'] != $_SESSION['incompatible_plugins'][$plugin_id])
     90  if (isset($incompatible_plugins[$plugin_id])
     91    and $fs_plugin['version'] != $incompatible_plugins[$plugin_id])
    7892  {
    7993    // Incompatible plugins must be reinitilized
    80     $plugins->get_incompatible_plugins(true);
     94    unset($_SESSION['incompatible_plugins']);
    8195  }
    8296
    8397  $tpl_plugin = array(
     98    'ID' => $plugin_id,
    8499    'NAME' => $fs_plugin['name'],
    85100    'VISIT_URL' => $fs_plugin['uri'],
     
    89104    'AUTHOR_URL' => @$fs_plugin['author uri'],
    90105    'U_ACTION' => sprintf($action_url, $plugin_id),
    91     'INCOMPATIBLE' => isset($_SESSION['incompatible_plugins'][$plugin_id]),
    92106    );
    93107
     
    101115  }
    102116
    103   if (isset($fs_plugin['extension']) and in_array($fs_plugin['extension'], $_SESSION['merged_extensions']))
     117  if (isset($fs_plugin['extension']) and isset($merged_extensions[$fs_plugin['extension']]))
    104118  {
    105119    switch($tpl_plugin['STATE'])
  • branches/2.2/admin/themes/default/template/plugins_list.tpl

    r10131 r11043  
    11{footer_script}
    22var 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'}';
     3var activate_msg = '\n{'Do you want to activate anyway?'|@translate|@escape:'javascript'}';
    54
    65{literal}
     
    98    return confirm(incompatible_msg);
    109  });
    11   jQuery('.warning').tipTip({
    12     'delay' : 0,
    13     'fadeIn' : 200,
    14     'fadeOut' : 200
     10  jQuery.ajax({
     11    method: 'GET',
     12    url: 'admin.php',
     13    data: { page: 'plugins_list', incompatible_plugins: true },
     14    dataType: 'json',
     15    success: function(data) {
     16      for (i=0;i<data.length;i++) {
     17        jQuery('#plugin_'+data[i]+' .pluginBoxNameCell')
     18          .addClass('warning')
     19          .attr('title', incompatible_msg)
     20          .tipTip({'delay' : 0, 'fadeIn' : 200, 'fadeOut' : 200});
     21        jQuery('#plugin_'+data[i]+' .activate').attr('onClick', 'return confirm(incompatible_msg + activate_msg);');
     22      }
     23    } 
    1524  });
    1625});
     
    4554  {foreach from=$plugins item=plugin name=plugins_loop}
    4655    {if $plugin.STATE == $plugin_state}
    47   <div class="pluginBox">
     56  <div class="pluginBox" id="plugin_{$plugin.ID}">
    4857    <table>
    4958      <tr>
    50         <td class="pluginBoxNameCell{if $plugin.INCOMPATIBLE} warning" title="{'WARNING! This plugin does not seem to be compatible with this version of Piwigo.'|@translate|@escape:'html'}{/if}">
     59        <td class="pluginBoxNameCell">
    5160          {$plugin.NAME}
    5261        </td>
     
    5968
    6069    {elseif $plugin_state == 'inactive'}
    61           <a href="{$plugin.U_ACTION}&amp;action=activate" {if $plugin.INCOMPATIBLE}class="incompatible"{/if}>{'Activate'|@translate}</a>
     70          <a href="{$plugin.U_ACTION}&amp;action=activate" class="activate">{'Activate'|@translate}</a>
    6271          | <a href="{$plugin.U_ACTION}&amp;action=uninstall" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Uninstall'|@translate}</a>
    6372
Note: See TracChangeset for help on using the changeset viewer.