Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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

helper.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 5.97 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\controller;
 015   
 016  use Symfony\Component\HttpFoundation\Response;
 017  use Symfony\Component\Routing\Generator\UrlGenerator;
 018  use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
 019  use Symfony\Component\Routing\RequestContext;
 020   
 021  /**
 022  * Controller helper class, contains methods that do things for controllers
 023  */
 024  class helper
 025  {
 026      /**
 027      * Template object
 028      * @var \phpbb\template\template
 029      */
 030      protected $template;
 031   
 032      /**
 033      * User object
 034      * @var \phpbb\user
 035      */
 036      protected $user;
 037   
 038      /**
 039      * config object
 040      * @var \phpbb\config\config
 041      */
 042      protected $config;
 043   
 044      /* @var \phpbb\symfony_request */
 045      protected $symfony_request;
 046   
 047      /**
 048      * @var \phpbb\filesystem The filesystem object
 049      */
 050      protected $filesystem;
 051   
 052      /**
 053      * phpBB root path
 054      * @var string
 055      */
 056      protected $phpbb_root_path;
 057   
 058      /**
 059      * PHP file extension
 060      * @var string
 061      */
 062      protected $php_ext;
 063   
 064      /**
 065      * Constructor
 066      *
 067      * @param \phpbb\template\template $template Template object
 068      * @param \phpbb\user $user User object
 069      * @param \phpbb\config\config $config Config object
 070      * @param \phpbb\controller\provider $provider Path provider
 071      * @param \phpbb\extension\manager $manager Extension manager object
 072      * @param \phpbb\symfony_request $symfony_request Symfony Request object
 073      * @param \phpbb\filesystem $filesystem The filesystem object
 074      * @param string $phpbb_root_path phpBB root path
 075      * @param string $php_ext PHP file extension
 076      */
 077      public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext)
 078      {
 079          $this->template = $template;
 080          $this->user = $user;
 081          $this->config = $config;
 082          $this->symfony_request = $symfony_request;
 083          $this->filesystem = $filesystem;
 084          $this->phpbb_root_path = $phpbb_root_path;
 085          $this->php_ext = $php_ext;
 086          $provider->find_routing_files($manager->get_finder());
 087          $this->route_collection = $provider->find($phpbb_root_path)->get_routes();
 088      }
 089   
 090      /**
 091      * Automate setting up the page and creating the response object.
 092      *
 093      * @param string $template_file The template handle to render
 094      * @param string $page_title The title of the page to output
 095      * @param int $status_code The status code to be sent to the page header
 096      * @param bool $display_online_list Do we display online users list
 097      *
 098      * @return Response object containing rendered page
 099      */
 100      public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false)
 101      {
 102          page_header($page_title, $display_online_list);
 103   
 104          $this->template->set_filenames(array(
 105              'body'    => $template_file,
 106          ));
 107   
 108          page_footer(true, false, false);
 109   
 110          return new Response($this->template->assign_display('body'), $status_code);
 111      }
 112   
 113      /**
 114      * Generate a URL to a route
 115      *
 116      * @param string    $route        Name of the route to travel
 117      * @param array    $params        String or array of additional url parameters
 118      * @param bool    $is_amp        Is url using &amp; (true) or & (false)
 119      * @param string|bool        $session_id    Possibility to use a custom session id instead of the global one
 120      * @param bool|string        $reference_type The type of reference to be generated (one of the constants)
 121      * @return string The URL already passed through append_sid()
 122      */
 123      public function route($route, array $params = array(), $is_amp = true, $session_id = false, $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH)
 124      {
 125          $anchor = '';
 126          if (isset($params['#']))
 127          {
 128              $anchor = '#' . $params['#'];
 129              unset($params['#']);
 130          }
 131   
 132          $context = new RequestContext();
 133          $context->fromRequest($this->symfony_request);
 134   
 135          $script_name = $this->symfony_request->getScriptName();
 136          $page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name);
 137   
 138          $base_url = $context->getBaseUrl();
 139   
 140          // If enable_mod_rewrite is false we need to replace the current front-end by app.php, otherwise we need to remove it.
 141          $base_url = str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $base_url);
 142   
 143          // We need to update the base url to move to the directory of the app.php file if the current script is not app.php
 144          if ($page_name !== 'app.php')
 145          {
 146              if (empty($this->config['enable_mod_rewrite']))
 147              {
 148                  $base_url = str_replace('/app.' . $this->php_ext, '/' . $this->phpbb_root_path . 'app.' . $this->php_ext, $base_url);
 149              }
 150              else
 151              {
 152                  $base_url .= preg_replace(get_preg_expression('path_remove_dot_trailing_slash'), '$2', $this->phpbb_root_path);
 153              }
 154          }
 155   
 156          $base_url = $this->filesystem->clean_path($base_url);
 157   
 158          $context->setBaseUrl($base_url);
 159   
 160          $url_generator = new UrlGenerator($this->route_collection, $context);
 161          $route_url = $url_generator->generate($route, $params, $reference_type);
 162   
 163          if ($is_amp)
 164          {
 165              $route_url = str_replace(array('&amp;', '&'), array('&', '&amp;'), $route_url);
 166          }
 167   
 168          if ($reference_type === UrlGeneratorInterface::RELATIVE_PATH && empty($this->config['enable_mod_rewrite']))
 169          {
 170              $route_url = 'app.' . $this->php_ext . '/' . $route_url;
 171          }
 172   
 173          return append_sid($route_url . $anchor, false, $is_amp, $session_id, true);
 174      }
 175   
 176      /**
 177      * Output an error, effectively the same thing as trigger_error
 178      *
 179      * @param string $message The error message
 180      * @param int $code The error code (e.g. 404, 500, 503, etc.)
 181      * @return Response A Response instance
 182      */
 183      public function error($message, $code = 500)
 184      {
 185          $this->template->assign_vars(array(
 186              'MESSAGE_TEXT'    => $message,
 187              'MESSAGE_TITLE'    => $this->user->lang('INFORMATION'),
 188          ));
 189   
 190          return $this->render('message_body.html', $this->user->lang('INFORMATION'), $code);
 191      }
 192   
 193      /**
 194      * Return the current url
 195      *
 196      * @return string
 197      */
 198      public function get_current_url()
 199      {
 200          return generate_board_url(true) . $this->symfony_request->getRequestUri();
 201      }
 202  }
 203