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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
helper.php
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\JsonResponse;
017 use Symfony\Component\HttpFoundation\Response;
018 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
019
020 /**
021 * Controller helper class, contains methods that do things for controllers
022 */
023 class helper
024 {
025 /**
026 * Template object
027 * @var \phpbb\template\template
028 */
029 protected $template;
030
031 /**
032 * User object
033 * @var \phpbb\user
034 */
035 protected $user;
036
037 /**
038 * config object
039 * @var \phpbb\config\config
040 */
041 protected $config;
042
043 /* @var \phpbb\symfony_request */
044 protected $symfony_request;
045
046 /* @var \phpbb\request\request_interface */
047 protected $request;
048
049 /**
050 * @var \phpbb\routing\helper
051 */
052 protected $routing_helper;
053
054 /**
055 * Constructor
056 *
057 * @param \phpbb\template\template $template Template object
058 * @param \phpbb\user $user User object
059 * @param \phpbb\config\config $config Config object
060 * @param \phpbb\symfony_request $symfony_request Symfony Request object
061 * @param \phpbb\request\request_interface $request phpBB request object
062 * @param \phpbb\routing\helper $routing_helper Helper to generate the routes
063 */
064 public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\routing\helper $routing_helper)
065 {
066 $this->template = $template;
067 $this->user = $user;
068 $this->config = $config;
069 $this->symfony_request = $symfony_request;
070 $this->request = $request;
071 $this->routing_helper = $routing_helper;
072 }
073
074 /**
075 * Automate setting up the page and creating the response object.
076 *
077 * @param string $template_file The template handle to render
078 * @param string $page_title The title of the page to output
079 * @param int $status_code The status code to be sent to the page header
080 * @param bool $display_online_list Do we display online users list
081 * @param int $item_id Restrict online users to item id
082 * @param string $item Restrict online users to a certain session item, e.g. forum for session_forum_id
083 * @param bool $send_headers Whether headers should be sent by page_header(). Defaults to false for controllers.
084 *
085 * @return Response object containing rendered page
086 */
087 public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false, $item_id = 0, $item = 'forum', $send_headers = false)
088 {
089 page_header($page_title, $display_online_list, $item_id, $item, $send_headers);
090
091 $this->template->set_filenames(array(
092 'body' => $template_file,
093 ));
094
095 page_footer(true, false, false);
096
097 $headers = !empty($this->user->data['is_bot']) ? array('X-PHPBB-IS-BOT' => 'yes') : array();
098
099 return new Response($this->template->assign_display('body'), $status_code, $headers);
100 }
101
102 /**
103 * Generate a URL to a route
104 *
105 * @param string $route Name of the route to travel
106 * @param array $params String or array of additional url parameters
107 * @param bool $is_amp Is url using & (true) or & (false)
108 * @param string|bool $session_id Possibility to use a custom session id instead of the global one
109 * @param bool|string $reference_type The type of reference to be generated (one of the constants)
110 * @return string The URL already passed through append_sid()
111 */
112 public function route($route, array $params = array(), $is_amp = true, $session_id = false, $reference_type = UrlGeneratorInterface::ABSOLUTE_PATH)
113 {
114 return $this->routing_helper->route($route, $params, $is_amp, $session_id, $reference_type);
115 }
116
117 /**
118 * Output an error, effectively the same thing as trigger_error
119 *
120 * @param string $message The error message
121 * @param int $code The error code (e.g. 404, 500, 503, etc.)
122 * @return Response A Response instance
123 *
124 * @deprecated 3.1.3 (To be removed: 3.3.0) Use exceptions instead.
125 */
126 public function error($message, $code = 500)
127 {
128 return $this->message($message, array(), 'INFORMATION', $code);
129 }
130
131 /**
132 * Output a message
133 *
134 * In case of an error, please throw an exception instead
135 *
136 * @param string $message The message to display (must be a language variable)
137 * @param array $parameters The parameters to use with the language var
138 * @param string $title Title for the message (must be a language variable)
139 * @param int $code The HTTP status code (e.g. 404, 500, 503, etc.)
140 * @return Response A Response instance
141 */
142 public function message($message, array $parameters = array(), $title = 'INFORMATION', $code = 200)
143 {
144 array_unshift($parameters, $message);
145 $message_text = call_user_func_array(array($this->user, 'lang'), $parameters);
146 $message_title = $this->user->lang($title);
147
148 if ($this->request->is_ajax())
149 {
150 global $refresh_data;
151
152 return new JsonResponse(
153 array(
154 'MESSAGE_TITLE' => $message_title,
155 'MESSAGE_TEXT' => $message_text,
156 'S_USER_WARNING' => false,
157 'S_USER_NOTICE' => false,
158 'REFRESH_DATA' => (!empty($refresh_data)) ? $refresh_data : null
159 ),
160 $code
161 );
162 }
163
164 $this->template->assign_vars(array(
165 'MESSAGE_TEXT' => $message_text,
166 'MESSAGE_TITLE' => $message_title,
167 ));
168
169 return $this->render('message_body.html', $message_title, $code);
170 }
171
172 /**
173 * Assigns automatic refresh time meta tag in template
174 *
175 * @param int $time time in seconds, when redirection should occur
176 * @param string $url the URL where the user should be redirected
177 * @return null
178 */
179 public function assign_meta_refresh_var($time, $url)
180 {
181 $this->template->assign_vars(array(
182 'META' => '<meta http-equiv="refresh" content="' . $time . '; url=' . $url . '" />',
183 ));
184 }
185
186 /**
187 * Return the current url
188 *
189 * @return string
190 */
191 public function get_current_url()
192 {
193 return generate_board_url(true) . $this->request->escape($this->symfony_request->getRequestUri(), true);
194 }
195 }
196