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

add_languages.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 3.05 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\install_data\task;
015   
016  class add_languages extends \phpbb\install\task_base
017  {
018      /**
019       * @var \phpbb\db\driver\driver_interface
020       */
021      protected $db;
022   
023      /**
024       * @var \phpbb\install\helper\iohandler\iohandler_interface
025       */
026      protected $iohandler;
027   
028      /**
029       * @var \phpbb\language\language_file_helper
030       */
031      protected $language_helper;
032   
033      /**
034       * Constructor
035       *
036       * @param \phpbb\install\helper\iohandler\iohandler_interface    $iohandler            Installer's input-output handler
037       * @param \phpbb\install\helper\container_factory                $container            Installer's DI container
038       * @param \phpbb\language\language_file_helper                    $language_helper    Language file helper service
039       */
040      public function __construct(\phpbb\install\helper\iohandler\iohandler_interface $iohandler,
041                                  \phpbb\install\helper\container_factory $container,
042                                  \phpbb\language\language_file_helper $language_helper)
043      {
044          $this->db                = $container->get('dbal.conn');
045          $this->iohandler        = $iohandler;
046          $this->language_helper    = $language_helper;
047   
048          parent::__construct(true);
049      }
050   
051      /**
052       * {@inheritdoc}
053       */
054      public function run()
055      {
056          $this->db->sql_return_on_error(true);
057   
058          $languages = $this->language_helper->get_available_languages();
059          $installed_languages = array();
060   
061          foreach ($languages as $lang_info)
062          {
063              $lang_pack = array(
064                  'lang_iso'            => $lang_info['iso'],
065                  'lang_dir'            => $lang_info['iso'],
066                  'lang_english_name'    => htmlspecialchars($lang_info['name']),
067                  'lang_local_name'    => htmlspecialchars($lang_info['local_name'], ENT_COMPAT, 'UTF-8'),
068                  'lang_author'        => htmlspecialchars($lang_info['author'], ENT_COMPAT, 'UTF-8'),
069              );
070   
071              $this->db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $this->db->sql_build_array('INSERT', $lang_pack));
072   
073              $installed_languages[] = (int) $this->db->sql_nextid();
074              if ($this->db->get_sql_error_triggered())
075              {
076                  $error = $this->db->sql_error($this->db->get_sql_error_sql());
077                  $this->iohandler->add_error_message($error['message']);
078              }
079          }
080   
081          $sql = 'SELECT * FROM ' . PROFILE_FIELDS_TABLE;
082          $result = $this->db->sql_query($sql);
083   
084          $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE);
085          while ($row = $this->db->sql_fetchrow($result))
086          {
087              foreach ($installed_languages as $lang_id)
088              {
089                  $insert_buffer->insert(array(
090                      'field_id'                => $row['field_id'],
091                      'lang_id'                => $lang_id,
092   
093                      // Remove phpbb_ from field name
094                      'lang_name'                => strtoupper(substr($row['field_name'], 6)),
095                      'lang_explain'            => '',
096                      'lang_default_value'    => '',
097                  ));
098              }
099          }
100   
101          $this->db->sql_freeresult($result);
102   
103          $insert_buffer->flush();
104      }
105   
106      /**
107       * {@inheritdoc}
108       */
109      static public function get_step_count()
110      {
111          return 1;
112      }
113   
114      /**
115       * {@inheritdoc}
116       */
117      public function get_task_lang_name()
118      {
119          return 'TASK_ADD_LANGUAGES';
120      }
121  }
122