Changeset 2647

Show
Ignore:
Timestamp:
10/04/08 01:16:49 (5 years ago)
Author:
patdenice
Message:

- Plugins manager now use PEM API.
- WARNING! Need to change PEM_URL constant and utf8 encoding when PEM will be updated.
- Bug in roma/themeconf.inc.php: accordion menu wasn't selected in plugins_new et plugins_update tabs.

Location:
trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/plugins.class.php

    r2299 r2647  
    265265  function get_server_plugins($new=false) 
    266266  { 
     267    // Retrieve PEM versions 
     268    $version = PHPWG_VERSION; 
     269    $versions_to_check = array(); 
     270    $url = PEM_URL . '/api/get_version_list.php?category_id=12&format=php'; 
     271    if ($source = @file_get_contents($url) 
     272      and $pem_versions = @unserialize($source)) 
     273    { 
     274      if (!preg_match('/^\d+\.\d+\.\d+/', $version)) 
     275      { 
     276        $version = $pem_versions[0]['name']; 
     277      } 
     278      $branch = substr($version, 0, strrpos($version, '.')); 
     279      foreach ($pem_versions as $pem_version) 
     280      { 
     281        if (strpos($pem_version['name'], $branch) === 0) 
     282        { 
     283          $versions_to_check[] = $pem_version['id']; 
     284        } 
     285      } 
     286    } 
     287    if (empty($versions_to_check)) 
     288    { 
     289      return false; 
     290    } 
     291 
     292    // Plugins to check 
     293    $plugins_to_check = array(); 
    267294    foreach($this->fs_plugins as $fs_plugin) 
    268295    { 
     
    272299      } 
    273300    } 
    274     $url = PEM_URL . '/uptodate.php?version=' . rawurlencode(PHPWG_VERSION) . '&extensions=' . implode(',', $plugins_to_check); 
    275     $url .= $new ? '&newext=Plugin' : ''; 
    276  
    277     if (!empty($plugins_to_check) and $source = @file_get_contents($url)) 
    278     { 
    279       $this->server_plugins = @unserialize($source); 
     301 
     302    // Retrieve PEM plugins infos 
     303    $url = PEM_URL . '/api/get_revision_list.php?category_id=12&format=php&last_revision_only=true'; 
     304    $url .= '&version=' . implode(',', $versions_to_check); 
     305    if (!empty($plugins_to_check)) 
     306    { 
     307      $url .= $new ? '&extension_exclude=' : '&extension_include='; 
     308      $url .= implode(',', $plugins_to_check); 
     309    } 
     310    if ($source = @file_get_contents($url) 
     311      and $pem_plugins = @unserialize($source)) 
     312    { 
     313      foreach ($pem_plugins as $plugin) 
     314      { 
     315        $this->server_plugins[$plugin['extension_id']] = $plugin; 
     316      } 
     317      return true; 
    280318    } 
    281319  } 
     
    307345   * @param string - install or upgrade 
    308346   *  @param string - archive URL 
    309     * @param string - destination path 
    310    */ 
    311   function extract_plugin_files($action, $source, $dest) 
     347    * @param string - plugin id or extension id 
     348   */ 
     349  function extract_plugin_files($action, $revision, $dest) 
    312350  { 
    313351    if ($archive = tempnam( PHPWG_PLUGINS_PATH, 'zip')) 
    314352    { 
    315       if (@copy(PEM_URL . str_replace(' ', '%20', $source), $archive)) 
     353      $url = PEM_URL . '/download.php?rid=' . $revision; 
     354      $url .= '&origin=piwigo_' . $action; 
     355      if (@copy($url, $archive)) 
    316356      { 
    317357        include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); 
     
    334374            if ($action == 'upgrade') 
    335375            { 
    336               $extract_path = PHPWG_PLUGINS_PATH.$dest; 
     376              $extract_path = PHPWG_PLUGINS_PATH . $dest; 
    337377            } 
    338378            else 
     
    429469    $replacement = array( "'.'.intval('\\1', 36).'.'", '.', ''); 
    430470 
    431     $array = preg_replace($pattern, $replacement, array($a['version'], $b['version'])); 
     471    $array = preg_replace($pattern, $replacement, array($a, $b)); 
    432472 
    433473    return version_compare($array[0], $array[1], '>='); 
     
    436476  function extension_revision_compare($a, $b) 
    437477  { 
    438     if ($a['date'] < $b['date']) return 1; 
     478    if ($a['revision_date'] < $b['revision_date']) return 1; 
    439479    else return -1; 
    440480  } 
     
    442482  function extension_name_compare($a, $b) 
    443483  { 
    444     return strcmp(strtolower($a['ext_name']), strtolower($b['ext_name'])); 
     484    return strcmp(strtolower($a['extension_name']), strtolower($b['extension_name'])); 
    445485  } 
    446486 
    447487  function extension_author_compare($a, $b) 
    448488  { 
    449     $r = strcasecmp($a['author'], $b['author']); 
     489    $r = strcasecmp($a['author_name'], $b['author_name']); 
    450490    if ($r == 0) return $this->extension_name_compare($a, $b); 
    451491    else return $r; 
  • trunk/admin/plugins_new.php

    r2530 r2647  
    3737 
    3838//------------------------------------------------------automatic installation 
    39 if (isset($_GET['install']) and isset($_GET['extension']) and !is_adviser()) 
     39if (isset($_GET['revision']) and isset($_GET['extension']) and !is_adviser()) 
    4040{ 
    41   $install_status = 
    42     $plugins->extract_plugin_files('install', $_GET['install'], $_GET['extension']); 
     41  $install_status = $plugins->extract_plugin_files('install', $_GET['revision'], $_GET['extension']); 
    4342 
    4443  redirect($base_url.'&installstatus='.$install_status); 
     
    9190// |                     start template output                             | 
    9291// +-----------------------------------------------------------------------+ 
    93 $plugins->get_server_plugins(true); 
    94  
    95 if (is_array($plugins->server_plugins)) 
     92if ($plugins->get_server_plugins(true)) 
    9693{ 
    9794  $plugins->sort_server_plugins($order); 
     
    9996  foreach($plugins->server_plugins as $plugin) 
    10097  { 
    101     $ext_desc = nl2br(htmlspecialchars(strip_tags( 
    102                   utf8_encode($plugin['ext_description'])))); 
     98    /* Need to remove this lines for final release : piwigo website will be utf8 only */ 
     99    $plugin['extension_description'] = utf8_encode($plugin['extension_description']); 
     100    $plugin['revision_description'] = utf8_encode($plugin['revision_description']); 
     101 
     102    list($date, ) = explode(' ', $plugin['revision_date']); 
    103103 
    104104    $ver_desc = sprintf(l10n('plugins_description'), 
    105             $plugin['version'], 
    106             date('Y-m-d', $plugin['date']), 
    107             nl2br(htmlspecialchars(strip_tags( 
    108               utf8_encode($plugin['description']))))); 
     105      $plugin['revision_name'], 
     106      $date, 
     107      $plugin['revision_description']); 
    109108 
    110109    $url_auto_install = htmlentities($base_url) 
    111       . '&amp;extension=' . $plugin['id_extension'] 
    112       . '&amp;install=%2Fupload%2Fextension-' . $plugin['id_extension'] 
    113       . '%2Frevision-' . $plugin['id_revision'] . '%2F' 
    114       .  str_replace(' ', '%20',$plugin['url']); 
     110      . '&amp;revision=' . $plugin['revision_id'] 
     111      . '&amp;extension=' . $plugin['extension_id']; 
    115112 
    116     $url_download = PEM_URL .'/upload/extension-'.$plugin['id_extension'] 
    117       . '/revision-' . $plugin['id_revision'] 
    118       . '/' . str_replace(' ', '%20',$plugin['url']); 
    119  
    120     $template->append('plugins', 
    121         array('EXT_NAME' => $plugin['ext_name'], 
    122           'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$plugin['id_extension'], 
    123           'EXT_DESC' => $ext_desc, 
    124           'VERSION' => $plugin['version'], 
    125           'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin['id_revision'], 
    126           'DATE' => date('Y-m-d', $plugin['date']), 
    127           'VER_DESC' => $ver_desc, 
    128           'AUTHOR' => $plugin['author'], 
    129           'URL_INSTALL' => $url_auto_install, 
    130           'URL_DOWNLOAD' => $url_download)); 
     113    $template->append('plugins', array( 
     114      'EXT_NAME' => $plugin['extension_name'], 
     115      'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$plugin['extension_id'], 
     116      'EXT_DESC' => $plugin['extension_description'], 
     117      'VERSION' => $plugin['revision_name'], 
     118      'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin['revision_id'], 
     119      'DATE' => $date, 
     120      'VER_DESC' => $ver_desc, 
     121      'AUTHOR' => $plugin['author_name'], 
     122      'URL_INSTALL' => $url_auto_install, 
     123      'URL_DOWNLOAD' => $plugin['download_url'] . '&amp;origin=piwigo_download')); 
    131124  } 
    132125} 
  • trunk/admin/plugins_update.php

    r2530 r2647  
    3636 
    3737//-----------------------------------------------------------automatic upgrade 
    38 if (isset($_GET['upgrade']) and isset($_GET['plugin']) and !is_adviser()) 
     38if (isset($_GET['plugin']) and isset($_GET['revision']) and !is_adviser()) 
    3939{ 
    4040  $plugin_id = $_GET['plugin']; 
     41  $revision = $_GET['revision']; 
    4142 
    4243  if (isset($plugins->db_plugins_by_id[$plugin_id]) 
     
    4647 
    4748    redirect($base_url 
    48       . '&upgrade=' . $_GET['upgrade'] 
     49      . '&revision=' . $revision 
    4950      . '&plugin=' . $plugin_id 
    5051      . '&reactivate=true'); 
    5152  } 
    5253 
    53   $upgrade_status = 
    54     $plugins->extract_plugin_files('upgrade', $_GET['upgrade'], $plugin_id); 
     54  $upgrade_status = $plugins->extract_plugin_files('upgrade', $revision, $plugin_id); 
    5555 
    5656  if (isset($_GET['reactivate'])) 
     
    9898// |                     start template output                             | 
    9999// +-----------------------------------------------------------------------+ 
    100 $plugins->get_server_plugins(); 
    101  
    102 if (is_array($plugins->server_plugins)) 
     100if ($plugins->get_server_plugins()) 
    103101{ 
    104102  foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) 
     
    109107      $plugin_info = $plugins->server_plugins[$fs_plugin['extension']]; 
    110108 
    111       $ext_desc = nl2br(htmlspecialchars(strip_tags( 
    112                     utf8_encode($plugin_info['ext_description'])))); 
     109      /* Need to remove this lines for final release : piwigo website will be utf8 only */ 
     110      $plugin_info['extension_description'] = utf8_encode($plugin_info['extension_description']); 
     111      $plugin_info['revision_description'] = utf8_encode($plugin_info['revision_description']); 
     112 
     113      list($date, ) = explode(' ', $plugin_info['revision_date']); 
    113114 
    114115      $ver_desc = sprintf(l10n('plugins_description'), 
    115           $plugin_info['version'], 
    116           date('Y-m-d', $plugin_info['date']), 
    117           nl2br(htmlspecialchars(strip_tags( 
    118               utf8_encode($plugin_info['description']))))); 
     116        $plugin_info['revision_name'], 
     117        $date, 
     118        $plugin_info['revision_description']); 
    119119 
    120       if ($plugins->plugin_version_compare($fs_plugin, $plugin_info)) 
     120      if ($plugins->plugin_version_compare($fs_plugin['version'], $plugin_info['revision_name'])) 
    121121      { 
    122122        // Plugin is up to date 
    123         $template->append('plugins_uptodate', 
    124               array('URL' => $fs_plugin['uri'], 
    125                 'NAME' => $fs_plugin['name'], 
    126                 'EXT_DESC' => $ext_desc, 
    127                 'VERSION' => $fs_plugin['version'])); 
     123        $template->append('plugins_uptodate', array( 
     124          'URL' => $fs_plugin['uri'], 
     125          'NAME' => $fs_plugin['name'], 
     126          'EXT_DESC' => $plugin_info['extension_description'], 
     127          'VERSION' => $fs_plugin['version'])); 
    128128      } 
    129129      else 
     
    131131        // Plugin need upgrade 
    132132        $url_auto_update = $base_url 
    133           . '&amp;plugin=' . $plugin_id 
    134           . '&amp;upgrade=%2Fupload%2Fextension-' . $fs_plugin['extension'] 
    135           . '%2Frevision-' . $plugin_info['id_revision'] 
    136           . '%2F' . str_replace(' ', '%20',$plugin_info['url']); 
     133          . '&amp;revision=' . $plugin_info['revision_id'] 
     134          . '&amp;plugin=' . $plugin_id; 
    137135 
    138         $url_download = PEM_URL.'/upload/extension-'. $fs_plugin['extension'] 
    139           . '/revision-' . $plugin_info['id_revision'] 
    140           . '/' . str_replace(' ', '%20',$plugin_info['url']); 
    141  
    142         $template->append('plugins_not_uptodate', 
    143           array('EXT_NAME' => $fs_plugin['name'], 
    144             'EXT_URL' => $fs_plugin['uri'], 
    145             'EXT_DESC' => $ext_desc, 
    146             'VERSION' => $fs_plugin['version'], 
    147             'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin_info['id_revision'], 
    148             'NEW_VERSION' => $plugin_info['version'], 
    149             'NEW_VER_DESC' => $ver_desc, 
    150             'URL_UPDATE' => $url_auto_update, 
    151             'URL_DOWNLOAD' => $url_download)); 
     136        $template->append('plugins_not_uptodate', array( 
     137          'EXT_NAME' => $fs_plugin['name'], 
     138          'EXT_URL' => $fs_plugin['uri'], 
     139          'EXT_DESC' => $plugin_info['extension_description'], 
     140          'VERSION' => $fs_plugin['version'], 
     141          'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin_info['revision_id'], 
     142          'NEW_VERSION' => $plugin_info['revision_name'], 
     143          'NEW_VER_DESC' => $ver_desc, 
     144          'URL_UPDATE' => $url_auto_update, 
     145          'URL_DOWNLOAD' => $plugin_info['download_url'] . '&amp;origin=piwigo_download')); 
    152146      } 
    153147    } 
     
    155149    { 
    156150      // Can't check plugin 
    157       $template->append('plugins_cant_check', 
    158           array('NAME' => $fs_plugin['name'], 
    159             'VERSION' => $fs_plugin['version'])); 
     151      $template->append('plugins_cant_check', array( 
     152        'NAME' => $fs_plugin['name'], 
     153        'VERSION' => $fs_plugin['version'])); 
    160154    } 
    161155  } 
  • trunk/admin/template/goto/plugins_new.tpl

    r2631 r2647  
     1{* $Id$ *} 
    12{known_script id="jquery" src=$ROOT_URL|@cat:"template-common/lib/jquery.packed.js"} 
    23{known_script id="jquery.dimensions" src=$ROOT_URL|@cat:"template-common/lib/plugins/jquery.dimensions.packed.js"} 
     
    3637{foreach from=$plugins item=plugin name=plugins_loop} 
    3738  <tr class="{if $smarty.foreach.plugins_loop.index is odd}row1{else}row2{/if}"> 
    38     <td><a href="{$plugin.EXT_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.EXT_DESC}">{$plugin.EXT_NAME}</a></td> 
    39     <td style="text-align:center;"><a href="{$plugin.VERSION_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.VER_DESC}">{$plugin.VERSION}</a></td> 
     39    <td><a href="{$plugin.EXT_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.EXT_DESC|htmlspecialchars|nl2br}">{$plugin.EXT_NAME}</a></td> 
     40    <td style="text-align:center;"><a href="{$plugin.VERSION_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.VER_DESC|htmlspecialchars|nl2br}">{$plugin.VERSION}</a></td> 
    4041    <td>{$plugin.DATE}</td> 
    4142    <td>{$plugin.AUTHOR}</td> 
  • trunk/admin/template/goto/plugins_update.tpl

    r2631 r2647  
     1{* $Id$ *} 
    12{known_script id="jquery" src=$ROOT_URL|@cat:"template-common/lib/jquery.packed.js"} 
    23{known_script id="jquery.dimensions" src=$ROOT_URL|@cat:"template-common/lib/plugins/jquery.dimensions.packed.js"} 
     
    3031{foreach from=$plugins_not_uptodate item=plugin name=plugins_loop} 
    3132  <tr class="{if $smarty.foreach.plugins_loop.index is odd}row1{else}row2{/if}"> 
    32     <td><a href="{$plugin.EXT_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.EXT_DESC}">{$plugin.EXT_NAME}</a></td> 
     33    <td><a href="{$plugin.EXT_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.EXT_DESC|htmlspecialchars|nl2br}">{$plugin.EXT_NAME}</a></td> 
    3334    <td style="text-align:center;">{$plugin.VERSION}</td> 
    34     <td style="text-align:center;"><a href="{$plugin.VERSION_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.NEW_VER_DESC}">{$plugin.NEW_VERSION}</a></td> 
     35    <td style="text-align:center;"><a href="{$plugin.VERSION_URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.EXT_NAME}|{$plugin.NEW_VER_DESC|htmlspecialchars|nl2br}">{$plugin.NEW_VERSION}</a></td> 
    3536    <td style="text-align:center;"><a href="{$plugin.URL_UPDATE}" onclick="return confirm('{'plugins_confirm_upgrade'|@translate|@escape:javascript}');">{'plugins_auto_update'|@translate}</a> 
    3637      / <a href="{$plugin.URL_DOWNLOAD}">{'plugins_download'|@translate}</a></td> 
     
    5354{foreach from=$plugins_uptodate item=plugin name=plugins_loop} 
    5455  <tr class="{if $smarty.foreach.plugins_loop.index is odd}row1{else}row2{/if}"> 
    55     <td><a href="{$plugin.URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.NAME}|{$plugin.EXT_DESC}">{$plugin.NAME}</a></td> 
     56    <td><a href="{$plugin.URL}" onclick="window.open(this.href); return false;" class="cluetip" title="{$plugin.NAME}|{$plugin.EXT_DESC|htmlspecialchars|nl2br}">{$plugin.NAME}</a></td> 
    5657    <td style="text-align:center;">{$plugin.VERSION}</td> 
    5758  </tr> 
  • trunk/admin/template/goto/theme/roma/themeconf.inc.php

    r2579 r2647  
    4242      case 'advanced_feature': 
    4343      case 'plugins_list': 
     44      case 'plugins_update': 
     45      case 'plugins_new': 
    4446      case 'plugin': 
    4547        return 5; 
  • trunk/include/constants.php

    r2516 r2647  
    2626define('PHPWG_DOMAIN', 'phpwebgallery.net'); 
    2727define('PHPWG_URL', 'http://www.'.PHPWG_DOMAIN); 
    28 define('PEM_URL', 'http://' . PHPWG_DOMAIN . '/ext'); 
     28define('PEM_URL', 'http://' . PHPWG_DOMAIN . '/ext_new'); /* need to be changed on final release */ 
    2929define('PHPWG_DEFAULT_LANGUAGE', 'en_UK'); 
    3030define('PHPWG_DEFAULT_TEMPLATE', 'yoga/clear');