Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

obtain_file_updater_method.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 3.78 KiB


001  <?php
002  /**
003   *
004   * This file is part of the phpBB Forum Software package.
005   *
006   * @copyright (c) phpBB Limited <https://www.phpbb.com>
007   * @license GNU General Public License, version 2 (GPL-2.0)
008   *
009   * For full copyright and license information, please see
010   * the docs/CREDITS.txt file.
011   *
012   */
013   
014  namespace phpbb\install\module\obtain_data\task;
015   
016  use phpbb\install\exception\user_interaction_required_exception;
017  use phpbb\install\helper\config;
018  use phpbb\install\helper\iohandler\iohandler_interface;
019  use phpbb\install\task_base;
020   
021  class obtain_file_updater_method extends task_base
022  {
023      /**
024       * @var array    Supported compression methods
025       *
026       * Note: .tar is assumed to be supported, but not in the list
027       */
028      protected $available_methods;
029   
030      /**
031       * @var \phpbb\install\helper\config
032       */
033      protected $installer_config;
034   
035      /**
036       * @var \phpbb\install\helper\iohandler\iohandler_interface
037       */
038      protected $iohandler;
039   
040      /**
041       * Constructor
042       *
043       * @param config                $installer_config
044       * @param iohandler_interface    $iohandler
045       */
046      public function __construct(config $installer_config, iohandler_interface $iohandler)
047      {
048          $this->installer_config    = $installer_config;
049          $this->iohandler        = $iohandler;
050   
051          $this->available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib');
052   
053          parent::__construct(false);
054      }
055   
056      /**
057       * {@inheritdoc}
058       */
059      public function check_requirements()
060      {
061          return $this->installer_config->get('do_update_files', false);
062      }
063   
064      /**
065       * {@inheritdoc}
066       */
067      public function run()
068      {
069          // Check if data is sent
070          if ($this->iohandler->get_input('submit_update_file', false))
071          {
072              $supported_methods = array('compression', 'ftp', 'direct_file');
073              $method = $this->iohandler->get_input('method', 'compression');
074              $update_method = (in_array($method, $supported_methods, true)) ? $method : 'compression';
075              $this->installer_config->set('file_update_method', $update_method);
076   
077              $compression = $this->iohandler->get_input('compression_method', '.zip');
078              $supported_methods = array_keys($this->available_methods);
079              $supported_methods[] = '.tar';
080              $compression = (in_array($compression, $supported_methods, true)) ? $compression : '.zip';
081              $this->installer_config->set('file_update_compression', $compression);
082          }
083          else
084          {
085              $this->iohandler->add_user_form_group('UPDATE_FILE_METHOD_TITLE', array(
086                  'method' => array(
087                      'label'        => 'UPDATE_FILE_METHOD',
088                      'type'        => 'select',
089                      'options'    => array(
090                          array(
091                              'value'        => 'compression',
092                              'label'        => 'UPDATE_FILE_METHOD_DOWNLOAD',
093                              'selected'    => true,
094                          ),
095                          array(
096                              'value'        => 'ftp',
097                              'label'        => 'UPDATE_FILE_METHOD_FTP',
098                              'selected'    => false,
099                          ),
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  }
168