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_board_data.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 4.22 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   
 018  /**
 019   * This class obtains default data from the user related to board (Board name, Board descritpion, etc...)
 020   */
 021  class obtain_board_data extends \phpbb\install\task_base implements \phpbb\install\task_interface
 022  {
 023      /**
 024       * @var \phpbb\install\helper\config
 025       */
 026      protected $install_config;
 027   
 028      /**
 029       * @var \phpbb\install\helper\iohandler\iohandler_interface
 030       */
 031      protected $io_handler;
 032   
 033      /**
 034       * @var \phpbb\language\language_file_helper
 035       */
 036      protected $language_helper;
 037   
 038      /**
 039       * Constructor
 040       *
 041       * @param \phpbb\install\helper\config                            $config            Installer's config
 042       * @param \phpbb\install\helper\iohandler\iohandler_interface    $iohandler        Installer's input-output handler
 043       * @param \phpbb\language\language_file_helper                    $lang_helper    Language file helper
 044       */
 045      public function __construct(\phpbb\install\helper\config $config,
 046                                  \phpbb\install\helper\iohandler\iohandler_interface $iohandler,
 047                                  \phpbb\language\language_file_helper $lang_helper)
 048      {
 049          $this->install_config    = $config;
 050          $this->io_handler        = $iohandler;
 051          $this->language_helper    = $lang_helper;
 052   
 053          parent::__construct(true);
 054      }
 055   
 056      /**
 057       * {@inheritdoc}
 058       */
 059      public function run()
 060      {
 061          // Check if data is sent
 062          if ($this->io_handler->get_input('submit_board', false))
 063          {
 064              $this->process_form();
 065          }
 066          else
 067          {
 068              $this->request_form_data();
 069          }
 070      }
 071   
 072      /**
 073       * Process form data
 074       */
 075      protected function process_form()
 076      {
 077          // Board data
 078          $default_lang    = $this->io_handler->get_input('default_lang', '');
 079          $board_name        = $this->io_handler->get_input('board_name', '', true);
 080          $board_desc        = $this->io_handler->get_input('board_description', '', true);
 081   
 082          // Check default lang
 083          $langs = $this->language_helper->get_available_languages();
 084          $lang_valid = false;
 085   
 086          foreach ($langs as $lang)
 087          {
 088              if ($lang['iso'] === $default_lang)
 089              {
 090                  $lang_valid = true;
 091                  break;
 092              }
 093          }
 094   
 095          $this->install_config->set('board_name', $board_name);
 096          $this->install_config->set('board_description', $board_desc);
 097   
 098          if ($lang_valid)
 099          {
 100              $this->install_config->set('default_lang', $default_lang);
 101          }
 102          else
 103          {
 104              $this->request_form_data(true);
 105          }
 106      }
 107   
 108      /**
 109       * Request data from the user
 110       *
 111       * @param bool $use_request_data Whether to use submited data
 112       *
 113       * @throws \phpbb\install\exception\user_interaction_required_exception When the user is required to provide data
 114       */
 115      protected function request_form_data($use_request_data = false)
 116      {
 117          if ($use_request_data)
 118          {
 119              $board_name        = $this->io_handler->get_input('board_name', '', true);
 120              $board_desc        = $this->io_handler->get_input('board_description', '', true);
 121          }
 122          else
 123          {
 124              $board_name        = '{L_CONFIG_SITENAME}';
 125              $board_desc        = '{L_CONFIG_SITE_DESC}';
 126          }
 127   
 128          // Use language because we only check this to be valid
 129          $default_lang    = $this->install_config->get('user_language', 'en');
 130   
 131          $langs = $this->language_helper->get_available_languages();
 132          $lang_options = array();
 133   
 134          foreach ($langs as $lang)
 135          {
 136              $lang_options[] = array(
 137                  'value'        => $lang['iso'],
 138                  'label'        => $lang['local_name'],
 139                  'selected'    => ($default_lang === $lang['iso']),
 140              );
 141          }
 142   
 143          $board_form = array(
 144              'default_lang' => array(
 145                  'label'        => 'DEFAULT_LANGUAGE',
 146                  'type'        => 'select',
 147                  'options'    => $lang_options,
 148              ),
 149              'board_name' => array(
 150                  'label'        => 'BOARD_NAME',
 151                  'type'        => 'text',
 152                  'default'    => $board_name,
 153              ),
 154              'board_description' => array(
 155                  'label'        => 'BOARD_DESCRIPTION',
 156                  'type'        => 'text',
 157                  'default'    => $board_desc,
 158              ),
 159              'submit_board'    => array(
 160                  'label'    => 'SUBMIT',
 161                  'type'    => 'submit',
 162              ),
 163          );
 164   
 165          $this->io_handler->add_user_form_group('BOARD_CONFIG', $board_form);
 166   
 167          throw new user_interaction_required_exception();
 168      }
 169   
 170      /**
 171       * {@inheritdoc}
 172       */
 173      static public function get_step_count()
 174      {
 175          return 0;
 176      }
 177   
 178      /**
 179       * {@inheritdoc}
 180       */
 181      public function get_task_lang_name()
 182      {
 183          return '';
 184      }
 185  }
 186