[ Index ]

PHP Cross Reference of phpBB-3.2.8-deutsch

title

Body

[close]

/phpbb/install/module/obtain_data/task/ -> obtain_file_updater_method.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\obtain_data\task;
  15  
  16  use phpbb\install\exception\user_interaction_required_exception;
  17  use phpbb\install\helper\config;
  18  use phpbb\install\helper\iohandler\iohandler_interface;
  19  use phpbb\install\task_base;
  20  
  21  class obtain_file_updater_method extends task_base
  22  {
  23      /**
  24       * @var array    Supported compression methods
  25       *
  26       * Note: .tar is assumed to be supported, but not in the list
  27       */
  28      protected $available_methods;
  29  
  30      /**
  31       * @var \phpbb\install\helper\config
  32       */
  33      protected $installer_config;
  34  
  35      /**
  36       * @var \phpbb\install\helper\iohandler\iohandler_interface
  37       */
  38      protected $iohandler;
  39  
  40      /**
  41       * Constructor
  42       *
  43       * @param config                $installer_config
  44       * @param iohandler_interface    $iohandler
  45       */
  46  	public function __construct(config $installer_config, iohandler_interface $iohandler)
  47      {
  48          $this->installer_config    = $installer_config;
  49          $this->iohandler        = $iohandler;
  50  
  51          $this->available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib');
  52  
  53          parent::__construct(false);
  54      }
  55  
  56      /**
  57       * {@inheritdoc}
  58       */
  59  	public function check_requirements()
  60      {
  61          return $this->installer_config->get('do_update_files', false);
  62      }
  63  
  64      /**
  65       * {@inheritdoc}
  66       */
  67  	public function run()
  68      {
  69          // Check if data is sent
  70          if ($this->iohandler->get_input('submit_update_file', false))
  71          {
  72              $supported_methods = array('compression', 'ftp', 'direct_file');
  73              $method = $this->iohandler->get_input('method', 'compression');
  74              $update_method = (in_array($method, $supported_methods, true)) ? $method : 'compression';
  75              $this->installer_config->set('file_update_method', $update_method);
  76  
  77              $compression = $this->iohandler->get_input('compression_method', '.zip');
  78              $supported_methods = array_keys($this->available_methods);
  79              $supported_methods[] = '.tar';
  80              $compression = (in_array($compression, $supported_methods, true)) ? $compression : '.zip';
  81              $this->installer_config->set('file_update_compression', $compression);
  82          }
  83          else
  84          {
  85              $this->iohandler->add_user_form_group('UPDATE_FILE_METHOD_TITLE', array(
  86                  'method' => array(
  87                      'label'        => 'UPDATE_FILE_METHOD',
  88                      'type'        => 'select',
  89                      'options'    => array(
  90                          array(
  91                              'value'        => 'compression',
  92                              'label'        => 'UPDATE_FILE_METHOD_DOWNLOAD',
  93                              'selected'    => true,
  94                          ),
  95                          array(
  96                              'value'        => 'ftp',
  97                              'label'        => 'UPDATE_FILE_METHOD_FTP',
  98                              'selected'    => false,
  99                          ),
 100                          array(
 101                              'value'        => 'direct_file',
 102                              'label'        => 'UPDATE_FILE_METHOD_FILESYSTEM',
 103                              'selected'    => false,
 104                          ),
 105                      ),
 106                  ),
 107                  'compression_method' => array(
 108                      'label'        => 'SELECT_DOWNLOAD_FORMAT',
 109                      'type'        => 'select',
 110                      'options'    => $this->get_available_compression_methods(),
 111                  ),
 112                  'submit_update_file' => array(
 113                      'label'    => 'SUBMIT',
 114                      'type'    => 'submit',
 115                  ),
 116              ));
 117  
 118              throw new user_interaction_required_exception();
 119          }
 120      }
 121  
 122      /**
 123       * Returns form elements in an array of available compression methods
 124       *
 125       * @return array
 126       */
 127  	protected function get_available_compression_methods()
 128      {
 129          $methods[] = array(
 130              'value'        => '.tar',
 131              'label'        => '.tar',
 132              'selected'    => true,
 133          );
 134  
 135          foreach ($this->available_methods as $type => $module)
 136          {
 137              if (!@extension_loaded($module))
 138              {
 139                  continue;
 140              }
 141  
 142              $methods[] = array(
 143                  'value'        => $type,
 144                  'label'        => $type,
 145                  'selected'    => false,
 146              );
 147          }
 148  
 149          return $methods;
 150      }
 151  
 152      /**
 153       * {@inheritdoc}
 154       */
 155  	static public function get_step_count()
 156      {
 157          return 0;
 158      }
 159  
 160      /**
 161       * {@inheritdoc}
 162       */
 163  	public function get_task_lang_name()
 164      {
 165          return '';
 166      }
 167  }


Generated: Tue Apr 7 19:42:26 2020 Cross-referenced by PHPXref 0.7.1