[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/phpbb/help/controller/ -> help.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\help\controller;
  15  
  16  use phpbb\exception\http_exception;
  17  
  18  class help
  19  {
  20      /** @var \phpbb\controller\helper */
  21      protected $helper;
  22  
  23      /** @var \phpbb\event\dispatcher_interface  */
  24      protected $dispatcher;
  25  
  26      /** @var \phpbb\template\template */
  27      protected $template;
  28  
  29      /** @var \phpbb\user */
  30      protected $user;
  31  
  32      /** @var string */
  33      protected $root_path;
  34  
  35      /** @var string */
  36      protected $php_ext;
  37  
  38      /**
  39       * Constructor
  40       *
  41       * @param \phpbb\controller\helper    $helper
  42       * @param \phpbb\event\dispatcher_interface    $dispatcher
  43       * @param \phpbb\template\template    $template
  44       * @param \phpbb\user                $user
  45       * @param string                    $root_path
  46       * @param string                    $php_ext
  47       */
  48  	public function __construct(\phpbb\controller\helper $helper, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\template\template $template, \phpbb\user $user, $root_path, $php_ext)
  49      {
  50          $this->helper = $helper;
  51          $this->dispatcher = $dispatcher;
  52          $this->template = $template;
  53          $this->user = $user;
  54          $this->root_path = $root_path;
  55          $this->php_ext = $php_ext;
  56      }
  57  
  58      /**
  59       * Controller for /help/{mode} routes
  60       *
  61       * @param string        $mode
  62       * @return \Symfony\Component\HttpFoundation\Response A Symfony Response object
  63       * @throws http_exception when the $mode is not known by any extension
  64       */
  65  	public function handle($mode)
  66      {
  67          $template_file = 'faq_body.html';
  68          switch ($mode)
  69          {
  70              case 'faq':
  71              case 'bbcode':
  72                  $page_title = ($mode === 'faq') ? $this->user->lang['FAQ_EXPLAIN'] : $this->user->lang['BBCODE_GUIDE'];
  73                  $this->user->add_lang($mode, false, true);
  74              break;
  75  
  76              default:
  77                  $page_title = $this->user->lang['FAQ_EXPLAIN'];
  78                  $ext_name = $lang_file = '';
  79  
  80                  /**
  81                   * You can use this event display a custom help page
  82                   *
  83                   * @event core.faq_mode_validation
  84                   * @var    string    page_title        Title of the page
  85                   * @var    string    mode            FAQ that is going to be displayed
  86                   * @var    string    lang_file        Language file containing the help data
  87                   * @var    string    ext_name        Vendor and extension name where the help
  88                   *                                language file can be loaded from
  89                   * @var    string    template_file    Template file name
  90                   * @since 3.1.4-RC1
  91                   * @changed 3.1.11-RC1 Added template_file var
  92                   */
  93                  $vars = array(
  94                      'page_title',
  95                      'mode',
  96                      'lang_file',
  97                      'ext_name',
  98                      'template_file',
  99                  );
 100                  extract($this->dispatcher->trigger_event('core.faq_mode_validation', compact($vars)));
 101  
 102                  if ($ext_name === '' || $lang_file === '')
 103                  {
 104                      throw new http_exception(404, 'Not Found');
 105                  }
 106  
 107                  $this->user->add_lang($lang_file, false, true, $ext_name);
 108              break;
 109  
 110          }
 111  
 112          $this->template->assign_vars(array(
 113              'L_FAQ_TITLE'                => $page_title,
 114              'S_IN_FAQ'                    => true,
 115          ));
 116  
 117          $this->assign_to_template($this->user->help);
 118  
 119          make_jumpbox(append_sid("{$this->root_path}viewforum.{$this->php_ext}"));
 120          return $this->helper->render($template_file, $page_title);
 121      }
 122  
 123      /**
 124       * Assigns the help data to the template blocks
 125       *
 126       * @param array $help_data
 127       * @return null
 128       */
 129  	protected function assign_to_template(array $help_data)
 130      {
 131          // Pull the array data from the lang pack
 132          $switch_column = $found_switch = false;
 133          foreach ($help_data as $help_ary)
 134          {
 135              if ($help_ary[0] == '--')
 136              {
 137                  if ($help_ary[1] == '--')
 138                  {
 139                      $switch_column = true;
 140                      $found_switch = true;
 141                      continue;
 142                  }
 143  
 144                  $this->template->assign_block_vars('faq_block', array(
 145                      'BLOCK_TITLE'        => $help_ary[1],
 146                      'SWITCH_COLUMN'        => $switch_column,
 147                  ));
 148  
 149                  if ($switch_column)
 150                  {
 151                      $switch_column = false;
 152                  }
 153                  continue;
 154              }
 155  
 156              $this->template->assign_block_vars('faq_block.faq_row', array(
 157                  'FAQ_QUESTION'        => $help_ary[0],
 158                  'FAQ_ANSWER'        => $help_ary[1],
 159              ));
 160          }
 161  
 162          $this->template->assign_var('SWITCH_COLUMN_MANUALLY', !$found_switch);
 163      }
 164  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1