Ignore:
Timestamp:
Mar 15, 2011, 6:07:03 PM (13 years ago)
Author:
patdenice
Message:

New version 2.2

File:
1 moved

Legend:

Unmodified
Added
Removed
  • extensions/autoupdate/trunk/admin.php

    r9622 r9707  
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44
    5 include(AUTOUPDATE_PATH.'include/functions.inc.php');
    6 include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php');
     5include_once(AUTOUPDATE_PATH.'include/functions.inc.php');
     6include_once(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php');
     7include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
    78
    8 /*
    9 STEP:
    10 0 = check is needed. If version is latest or check fail, we stay on step 0
    11 1 = new version on same branch AND new branch are available => user may choose upgrade.
    12 2 = upgrade on same branch
    13 3 = upgrade on different branch
    14 */
    15 $step = isset($_GET['step']) ? $_GET['step'] : 0;
    16 $upgrade_to = isset($_GET['to']) ? $_GET['to'] : '';
     9load_language('plugin.lang', AUTOUPDATE_PATH);
    1710
    18 // +-----------------------------------------------------------------------+
    19 // |                                Step 0                                 |
    20 // +-----------------------------------------------------------------------+
    21 if ($step == 0)
    22 {
    23   $template->assign(array(
    24     'CHECK_VERSION' => false,
    25     'DEV_VERSION' => false,
    26     )
    27   );
     11$my_base_url = get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__));
    2812
    29   if (preg_match('/(\d+\.\d+)\.(\d+)/', PHPWG_VERSION, $matches))
    30   {
    31     $url = PHPWG_URL.'/download/all_versions.php';
    32     $url .= '?rand='.md5(uniqid(rand(), true)); // Avoid server cache
     13if (isset($_GET['tab']))
     14  $page['tab'] = $_GET['tab'];
     15else
     16  $page['tab'] = 'pwg';
    3317
    34     if (@fetchRemote($url, $result)
    35       and $all_versions = @explode("\n", $result)
    36       and is_array($all_versions))
    37     {
    38       $template->assign('CHECK_VERSION', true);
     18$tabsheet = new tabsheet();
     19$tabsheet->add('pwg', l10n('Piwigo Upgrade'), $my_base_url.'-pwg');
     20$tabsheet->add('ext', l10n('Extensions Upgrade'), $my_base_url.'-ext');
     21$tabsheet->select($page['tab']);
     22$tabsheet->assign();
    3923
    40       $last_version = trim($all_versions[0]);
    41       $upgrade_to = $last_version;
    42 
    43       if (version_compare(PHPWG_VERSION, $last_version, '<'))
    44       {
    45         $new_branch = preg_replace('/(\d+\.\d+)\.\d+/', '$1', $last_version);
    46         $actual_branch = $matches[1];
    47 
    48         if ($new_branch == $actual_branch)
    49         {
    50           $step = 2;
    51         }
    52         else
    53         {
    54           $step = 3;
    55 
    56           // Check if new version exists in same branch
    57           foreach ($all_versions as $version)
    58           {
    59             $new_branch = preg_replace('/(\d+\.\d+)\.\d+/', '$1', $version);
    60 
    61             if ($new_branch == $actual_branch)
    62             {
    63               if (version_compare(PHPWG_VERSION, $version, '<'))
    64               {
    65                 $step = 1;
    66               }
    67               break;
    68             }
    69           }
    70         }
    71       }
    72     }
    73   }
    74   else
    75   {
    76     $template->assign('DEV_VERSION', true);
    77   }
    78 }
    79 
    80 // +-----------------------------------------------------------------------+
    81 // |                                Step 1                                 |
    82 // +-----------------------------------------------------------------------+
    83 if ($step == 1)
    84 {
    85   $template->assign(array(
    86     'MINOR_VERSION' => $version,
    87     'MAJOR_VERSION' => $last_version,
    88     )
    89   );
    90 }
    91 
    92 // +-----------------------------------------------------------------------+
    93 // |                                Step 2                                 |
    94 // +-----------------------------------------------------------------------+
    95 if ($step == 2 and is_webmaster())
    96 {
    97   if (isset($_POST['submit']) and isset($_POST['upgrade_to']))
    98   {
    99     autoupdate_upgrade_to($_POST['upgrade_to'], $step);
    100   }
    101 }
    102 
    103 // +-----------------------------------------------------------------------+
    104 // |                                Step 3                                 |
    105 // +-----------------------------------------------------------------------+
    106 if ($step == 3 and is_webmaster())
    107 {
    108   if (isset($_POST['saveTemplate']) and version_compare(PHPWG_VERSION, '2.1', '<'))
    109   {
    110     autoupdate_save_template_dir();
    111   }
    112 
    113   if (isset($_POST['dumpDatabase']))
    114   {
    115     autoupdate_dump_database();
    116   }
    117 
    118   if (isset($_POST['submit']) and isset($_POST['upgrade_to']))
    119   {
    120     autoupdate_upgrade_to($_POST['upgrade_to'], $step);
    121   }
    122 }
    123 
    124 // +-----------------------------------------------------------------------+
    125 // |                        Process template                               |
    126 // +-----------------------------------------------------------------------+
    127 
    128 if (!is_webmaster())
    129 {
    130   array_push($page['errors'], l10n('Webmaster status is required.'));
    131 }
    132 
    133 $template->assign(array(
    134   'STEP'          => $step,
    135   'AU_URL'        => get_admin_plugin_menu_link(AUTOUPDATE_PATH . '/autoupdate.php'),
    136   'PHPWG_VERSION' => PHPWG_VERSION,
    137   'UPGRADE_TO'    => $upgrade_to,
    138   'RELEASE_URL'   => PHPWG_URL.'/releases/'.$upgrade_to,
    139   )
    140 );
    141 
    142 $template->set_filename('plugin_admin_content', realpath(AUTOUPDATE_PATH.'template/autoupdate.tpl'));
    143 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
     24include(AUTOUPDATE_PATH.'/update_'.$page['tab'].'.inc.php');
    14425
    14526?>
Note: See TracChangeset for help on using the changeset viewer.