[ Index ]

PHP Cross Reference of phpBB-3.3.7-deutsch

title

Body

[close]

/phpbb/install/helper/iohandler/ -> iohandler_base.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\helper\iohandler;
  15  
  16  /**
  17   * Base class for installer input-output handlers
  18   */
  19  abstract class iohandler_base implements iohandler_interface
  20  {
  21      /**
  22       * Array of errors
  23       *
  24       * Errors should be added, when the installation cannot continue without
  25       * user interaction. If the aim is to notify the user about something, please
  26       * use a warning instead.
  27       *
  28       * @var array
  29       */
  30      protected $errors;
  31  
  32      /**
  33       * Array of warnings
  34       *
  35       * @var array
  36       */
  37      protected $warnings;
  38  
  39      /**
  40       * Array of logs
  41       *
  42       * @var array
  43       */
  44      protected $logs;
  45  
  46      /**
  47       * Array of success messages
  48       *
  49       * @var array
  50       */
  51      protected $success;
  52  
  53      /**
  54       * @var \phpbb\language\language
  55       */
  56      protected $language;
  57  
  58      /**
  59       * @var int
  60       */
  61      protected $task_progress_count;
  62  
  63      /**
  64       * @var int
  65       */
  66      protected $current_task_progress;
  67  
  68      /**
  69       * @var string
  70       */
  71      protected $current_task_name;
  72  
  73      /**
  74       * @var bool
  75       */
  76      protected $restart_progress_bar;
  77  
  78      /**
  79       * Constructor
  80       */
  81  	public function __construct()
  82      {
  83          $this->errors    = array();
  84          $this->warnings    = array();
  85          $this->logs        = array();
  86          $this->success    = array();
  87  
  88          $this->restart_progress_bar        = false;
  89          $this->task_progress_count        = 0;
  90          $this->current_task_progress    = 0;
  91          $this->current_task_name        = '';
  92      }
  93  
  94      /**
  95       * Set language service
  96       *
  97       * @param \phpbb\language\language $language
  98       */
  99  	public function set_language(\phpbb\language\language $language)
 100      {
 101          $this->language = $language;
 102      }
 103  
 104      /**
 105       * {@inheritdoc}
 106       */
 107  	public function add_error_message($error_title, $error_description = false)
 108      {
 109          if (!is_array($error_title) && strpos($error_title, '<br />') !== false)
 110          {
 111              $error_title = strip_tags(htmlspecialchars_decode($error_title, ENT_COMPAT));
 112          }
 113          $this->errors[] = $this->translate_message($error_title, $error_description);
 114      }
 115  
 116      /**
 117       * {@inheritdoc}
 118       */
 119  	public function add_warning_message($warning_title, $warning_description = false)
 120      {
 121          $this->warnings[] = $this->translate_message($warning_title, $warning_description);
 122      }
 123  
 124      /**
 125       * {@inheritdoc}
 126       */
 127  	public function add_log_message($log_title, $log_description = false)
 128      {
 129          $this->logs[] = $this->translate_message($log_title, $log_description);
 130      }
 131  
 132      /**
 133       * {@inheritdoc}
 134       */
 135  	public function add_success_message($success_title, $success_description = false)
 136      {
 137          $this->success[] = $this->translate_message($success_title, $success_description);
 138      }
 139  
 140      /**
 141       * {@inheritdoc}
 142       */
 143  	public function set_task_count($task_count, $restart = false)
 144      {
 145          $this->task_progress_count = $task_count;
 146          $this->restart_progress_bar = $restart;
 147      }
 148  
 149      /**
 150       * {@inheritdoc}
 151       */
 152  	public function set_progress($task_lang_key, $task_number)
 153      {
 154          $this->current_task_name = '';
 155  
 156          if (!empty($task_lang_key))
 157          {
 158              $this->current_task_name = $this->language->lang($task_lang_key);
 159          }
 160  
 161          $this->current_task_progress = $task_number;
 162      }
 163  
 164      /**
 165       * {@inheritdoc}
 166       */
 167  	public function finish_progress($message_lang_key)
 168      {
 169          if (!empty($message_lang_key))
 170          {
 171              $this->current_task_name = $this->language->lang($message_lang_key);
 172          }
 173  
 174          $this->current_task_progress = $this->task_progress_count;
 175      }
 176  
 177      /**
 178       * {@inheritdoc}
 179       */
 180  	public function generate_form_render_data($title, $form)
 181      {
 182          return '';
 183      }
 184  
 185      /**
 186       * Localize message.
 187       *
 188       * Note: When an array is passed into the parameters below, it will be
 189       * resolved as printf($param[0], $param[1], ...).
 190       *
 191       * @param array|string        $title            Title of the message
 192       * @param array|string|bool    $description    Description of the message
 193       *
 194       * @return array    Localized message in an array
 195       */
 196  	protected function translate_message($title, $description)
 197      {
 198          $message_array = array();
 199  
 200          $message_array['title'] = call_user_func_array(array($this->language, 'lang'), (array) $title);
 201  
 202          if ($description !== false)
 203          {
 204              $message_array['description'] = call_user_func_array(array($this->language, 'lang'), (array) $description);
 205          }
 206  
 207          return $message_array;
 208      }
 209  }


Generated: Thu Mar 24 21:31:15 2022 Cross-referenced by PHPXref 0.7.1