    <h1><?php print _("Upgrading the Gallery Core Module") ?></h1>

    <p>
      <?php print _("The Gallery Core Module is the heart of the Gallery application.  You can upgrade most other modules using the Site Administration interface, but this module must be handled separately in order for the upgrade to go smoothly.") ?>
    </p>

    <table>
      <tr>
	<td width="175">
	  <?php print _("Currently installed") ?>
	</td>
	<td>
	  <b>
	    <?php print $templateData['installed']['core'] ?>
	  </b>
	</td>
      </tr>
      <tr>
	<td>
	  <?php print _("New version") ?>
	</td>
	<td>
	  <b>
	    <?php print $templateData['coreVersion'] ?>
	  </b>
	</td>
      </tr>
      <?php if ($templateData['isConfigUpgradeRequired'] && !isset($templateData['isTryingToDowngrade'])): ?>
      <tr>
	<td>
	  <?php print _("Config.php upgrade") ?>
	</td>
	<td>
	  <b> <?php print _("Required") ?> </b>
	</td>
      </tr>
      <?php if (!$templateData['isConfigWriteable']): ?>
      <tr>
	<td colspan="2" class="error">
	  <?php printf(_("Unable to write to config.php in your %s directory.  Please change its permissions."), basename(GALLERY_CONFIG_DIR)) ?>
	  <?php if ($templateData['canChmod']) print _("You can do <i>chmod 666 config.php</i> to fix this.") ?>
	</td>
      </tr>
      <?php endif; ?>
      <?php endif; ?>
    </table>

    <?php if (isset($templateData['isTryingToDowngrade'])): ?>
    <p class="error">
      <?php print _("The installed version is newer than the version you are trying to upgrade to. You cannot downgrade G2. Please replace the gallery2 files with files from the currently installed version or later.") ?>
    </p>
    <?php elseif (isset($templateData['brokenPlugins'])): ?>
    <?php $galleryWebsiteLink = sprintf('<a href="http://codex.gallery2.org/index.php/Gallery2:Download">%s</a>', _("the Gallery website")); ?>
    <p class="error">
      <?php printf(_("Your upgrade cannot begin because some of your active modules/themes are incompatible or missing.  You must either locate more recent versions of these modules or themes, or revert to your original version of Gallery.  No changes have been made so it's safe to revert.  If you have many incompatible modules listed below, it's possible that you downloaded a smaller distribution of Gallery than what you originally installed.  You can download a larger distribution from %s."), $galleryWebsiteLink) ?>
    </p>
    <div class="error">
      <ul>
	<?php foreach ($templateData['brokenPlugins'] as $pluginType => $pluginList): ?>
	<?php foreach ($pluginList as $pluginId => $status): ?>
	<li>
	  <?php if (!empty($status['missing'])): ?>
	  <?php if ($pluginType == 'module'): ?>
	  <?php printf("Module %s is missing", $pluginId) ?>
	  <?php else: ?>
	  <?php printf("Theme %s is missing", $pluginId) ?>
	  <?php endif ?>
	  <?php else: ?>
	  <?php if ($pluginType == 'module'): ?>
	  <?php printf("Module %s is incompatible", $pluginId) ?>
	  <?php else: ?>
	  <?php printf("Theme %s is incompatible", $pluginId) ?>
	  <?php endif; ?>
	  <?php endif; ?>
	</li>
	<?php endforeach; ?>
	<?php endforeach; ?>
      </ul>
    </div>
    <p class="error">
      <?php printf(_('Download replacement modules from %s'), $galleryWebsiteLink); ?>
    </p>
    <?php else: ?>
    <p>
      <?php print _("Before you upgrade, we <b>strongly recommend</b> that you make a backup of your database!  If you fail to make a backup and something goes wrong, there is a strong possibility that we will not be able to help you recover your data!  Refer to the following examples:") ?>
    </p>

    <div class="example">
      <h3> <?php print _("MySQL") ?> </h3>
      <?php printf(_("mysqldump -u%s -p -h %s --opt %s > %s.sql"),
		   $templateData['storeConfig']['username'],
		   $templateData['storeConfig']['hostname'],
		   $templateData['storeConfig']['database'],
		   $templateData['storeConfig']['database']) ?>
    </div>

    <div class="example">
      <h3> <?php print _("PostgreSQL") ?> </h3>
      <?php printf(_("pg_dump -h %s --format=t %s > %s.sql"),
		   $templateData['storeConfig']['hostname'],
		   $templateData['storeConfig']['database'],
		   $templateData['storeConfig']['database']) ?>
    </div>

    <p>
      <form method="post" action="<?php generateUrl('index.php?step=' . $stepNumber) ?>">
	<input type="hidden" name="confirm" value="1"/>
      </form>

      <?php print _("Once the upgrade has begun, please be patient.  If you cancel or reload the page, you may interfere with the upgrade process.") ?>
    </p>

    <div class="go">
	  <div class="btn btn-continue"><span><span><span><span>
	<?php if (!$templateData['isConfigUpgradeRequired']
		  || $templateData['isConfigWriteable']): ?>
	  <a href="javascript:document.forms[0].submit()"><?php print _('Begin Upgrade') ?></a>
	<?php else: ?>
	  <a href="<?php generateUrl('index.php?step=' . $stepNumber) ?>"><?php print _('Recheck config.php') ?></a>
	<?php endif; ?>
	  </span></span></span></span></div>
    </div>
    <?php endif; ?>
