[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/phpbb/install/module/update_filesystem/task/ -> show_file_status.php (source)

   1  <?php
   2  /**
   3   *
   4   * This file is part of the phpBB Forum Software package.
   5   *
   6   * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7   * @license GNU General Public License, version 2 (GPL-2.0)
   8   *
   9   * For full copyright and license information, please see
  10   * the docs/CREDITS.txt file.
  11   *
  12   */
  13  
  14  namespace phpbb\install\module\update_filesystem\task;
  15  
  16  use phpbb\filesystem\filesystem;
  17  use phpbb\install\exception\user_interaction_required_exception;
  18  use phpbb\install\helper\config;
  19  use phpbb\install\helper\container_factory;
  20  use phpbb\install\helper\file_updater\factory;
  21  use phpbb\install\helper\iohandler\iohandler_interface;
  22  use phpbb\install\task_base;
  23  
  24  class show_file_status extends task_base
  25  {
  26      /**
  27       * @var \phpbb\cache\driver\driver_interface
  28       */
  29      protected $cache;
  30  
  31      /**
  32       * @var filesystem
  33       */
  34      protected $filesystem;
  35  
  36      /**
  37       * @var config
  38       */
  39      protected $installer_config;
  40  
  41      /**
  42       * @var iohandler_interface
  43       */
  44      protected $iohandler;
  45  
  46      /**
  47       * @var \phpbb\install\helper\file_updater\compression_file_updater
  48       */
  49      protected $file_updater;
  50  
  51      /**
  52       * Constructor
  53       *
  54       * @param container_factory        $container
  55       * @param config                $config
  56       * @param iohandler_interface    $iohandler
  57       * @param filesystem            $filesystem
  58       * @param factory                $file_updater_factory
  59       */
  60  	public function __construct(container_factory $container, config $config, iohandler_interface $iohandler, filesystem $filesystem, factory $file_updater_factory)
  61      {
  62          $this->installer_config    = $config;
  63          $this->iohandler        = $iohandler;
  64          $this->filesystem        = $filesystem;
  65  
  66          $this->cache = $container->get('cache.driver');
  67  
  68          // Initialize compression file updater
  69          $this->file_updater = $file_updater_factory->get('compression');
  70  
  71          parent::__construct(false);
  72      }
  73  
  74      /**
  75       * {@inheritdoc}
  76       */
  77  	public function check_requirements()
  78      {
  79          return $this->installer_config->get('do_update_files', false);
  80      }
  81  
  82      /**
  83       * {@inheritdoc}
  84       */
  85  	public function run()
  86      {
  87          if (!$this->iohandler->get_input('submit_continue_file_update', false))
  88          {
  89              // Handle merge conflicts
  90              $merge_conflicts = $this->installer_config->get('merge_conflict_list', array());
  91  
  92              // Create archive for merge conflicts
  93              if (!empty($merge_conflicts))
  94              {
  95                  $compression_method = $this->installer_config->get('file_update_compression', '');
  96                  $conflict_archive = $this->file_updater->init($compression_method);
  97                  $this->installer_config->set('update_file_conflict_archive', $conflict_archive);
  98  
  99                  foreach ($merge_conflicts as $filename)
 100                  {
 101                      $this->file_updater->create_new_file(
 102                          $filename,
 103                          base64_decode($this->cache->get('_file_' . md5($filename))),
 104                          true
 105                      );
 106                  }
 107  
 108                  // Render download box
 109                  $this->iohandler->add_download_link(
 110                      'phpbb_installer_update_conflict_download',
 111                      'DOWNLOAD_CONFLICTS',
 112                      'DOWNLOAD_CONFLICTS_EXPLAIN'
 113                  );
 114  
 115                  $this->file_updater->close();
 116              }
 117  
 118              // Render update file statuses
 119              $file_update_info = $this->installer_config->get('update_files', array());
 120              $file_status = array(
 121                  'deleted'        => (!isset($file_update_info['delete'])) ? array() : $file_update_info['delete'],
 122                  'new'            => (!isset($file_update_info['new'])) ? array() : $file_update_info['new'],
 123                  'conflict'        => $this->installer_config->get('merge_conflict_list', array()),
 124                  'modified'        => (!isset($file_update_info['update_with_diff'])) ? array() : $file_update_info['update_with_diff'],
 125                  'not_modified'    => (!isset($file_update_info['update_without_diff'])) ? array() : $file_update_info['update_without_diff'],
 126              );
 127  
 128              $this->iohandler->render_update_file_status($file_status);
 129  
 130              // Add form to continue update
 131              $this->iohandler->add_user_form_group('UPDATE_CONTINUE_FILE_UPDATE', array(
 132                  'submit_continue_file_update' => array(
 133                      'label' => 'UPDATE_CONTINUE_FILE_UPDATE',
 134                      'type' => 'submit',
 135                  ),
 136              ));
 137  
 138              // Show results to the user
 139              throw new user_interaction_required_exception();
 140          }
 141          else
 142          {
 143              $conflict_archive_path = $this->installer_config->get('update_file_conflict_archive', null);
 144  
 145              // Remove archive
 146              if ($conflict_archive_path !== null && $this->filesystem->exists($conflict_archive_path))
 147              {
 148                  $this->filesystem->remove($conflict_archive_path);
 149              }
 150  
 151              $this->installer_config->set('update_file_conflict_archive', null);
 152          }
 153      }
 154  
 155      /**
 156       * {@inheritdoc}
 157       */
 158  	static public function get_step_count()
 159      {
 160          return 0;
 161      }
 162  
 163      /**
 164       * {@inheritdoc}
 165       */
 166  	public function get_task_lang_name()
 167      {
 168          return '';
 169      }
 170  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1