Ignore:
Timestamp:
Mar 15, 2010, 2:35:35 PM (14 years ago)
Author:
plg
Message:

feature 1507: ability to install themes directly from piwigo.org/ext.

The theme manager backend for installation is the plugin manager backend,
because they are very close.

thanks to feature:1502, installing a theme and installing a plugin are very
similare operations. The only differences are the installation directory and
the main file to find in the archive.

This is only the very first step, the "add new theme" screen needs many
improvements, to begin with display style.

File:
1 edited

Legend:

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

    r4385 r5143  
    269269   * Retrieve PEM server datas to $server_plugins
    270270   */
    271   function get_server_plugins($new=false)
     271  function get_server_plugins($new=false, $ext_type='plugin')
    272272  {
    273273    global $user;
     274
     275    $pem_category_id = 12;
     276    if ('theme' == $ext_type)
     277    {
     278      $pem_category_id = 10;
     279    }
    274280
    275281    // Retrieve PEM versions
    276282    $version = PHPWG_VERSION;
    277283    $versions_to_check = array();
    278     $url = PEM_URL . '/api/get_version_list.php?category_id=12&format=php';
     284    $url = PEM_URL . '/api/get_version_list.php?category_id='.$pem_category_id.'&format=php';
    279285    if (fetchRemote($url, $result) and $pem_versions = @unserialize($result))
    280286    {
     
    308314
    309315    // Retrieve PEM plugins infos
    310     $url = PEM_URL . '/api/get_revision_list.php?category_id=12&format=php&last_revision_only=true';
     316    $url = PEM_URL . '/api/get_revision_list.php?category_id='.$pem_category_id.'&format=php&last_revision_only=true';
    311317    $url .= '&version=' . implode(',', $versions_to_check);
    312318    $url .= '&lang=' . substr($user['language'], 0, 2);
     
    365371    * @param string - plugin id or extension id
    366372   */
    367   function extract_plugin_files($action, $revision, $dest)
    368   {
    369     if ($archive = tempnam( PHPWG_PLUGINS_PATH, 'zip'))
     373  function extract_plugin_files($action, $revision, $dest, $ext_type = 'plugin')
     374  {
     375    if ('plugin' == $ext_type)
     376    {
     377      $install_basedir = PHPWG_PLUGINS_PATH;
     378      $main_filename = 'main.inc.php';
     379    }
     380    elseif ('theme' == $ext_type)
     381    {
     382      $install_basedir = PHPWG_ROOT_PATH.'themes/';
     383      $main_filename = 'themeconf.inc.php';
     384    }
     385    else
     386    {
     387      fatal_error('unknown extension type "'.$ext_type.'"');
     388    }
     389   
     390    if ($archive = tempnam( $install_basedir, 'zip'))
    370391    {
    371392      $url = PEM_URL . '/download.php?rid=' . $revision;
     
    382403          {
    383404            // we search main.inc.php in archive
    384             if (basename($file['filename']) == 'main.inc.php'
     405            if (basename($file['filename']) == $main_filename
    385406              and (!isset($main_filepath)
    386407              or strlen($file['filename']) < strlen($main_filepath)))
     
    394415            if ($action == 'upgrade')
    395416            {
    396               $extract_path = PHPWG_PLUGINS_PATH . $dest;
     417              $extract_path = $install_basedir . $dest;
    397418            }
    398419            else
    399420            {
    400               $extract_path = PHPWG_PLUGINS_PATH
     421              $extract_path = $install_basedir
    401422                  . ($root == '.' ? 'extension_' . $dest : basename($root));
    402423            }
Note: See TracChangeset for help on using the changeset viewer.