Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
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\feed;
015
016 use phpbb\config\config;
017 use phpbb\path_helper;
018 use phpbb\textformatter\s9e\renderer;
019 use phpbb\user;
020 use phpbb\auth\auth;
021 use Symfony\Component\DependencyInjection\ContainerInterface;
022
023 /**
024 * Class with some helpful functions used in feeds
025 */
026 class helper
027 {
028 /** @var config */
029 protected $config;
030
031 /** @var ContainerInterface */
032 protected $container;
033
034 /** @var path_helper */
035 protected $path_helper;
036
037 /** @var renderer */
038 protected $renderer;
039
040 /** @var user */
041 protected $user;
042
043 /** @var auth */
044 protected $auth;
045
046 /**
047 * Constructor
048 *
049 * @param auth $auth Auth object
050 * @param config $config Config object
051 * @param ContainerInterface $container Service container object
052 * @param path_helper $path_helper Path helper object
053 * @param renderer $renderer TextFormatter renderer object
054 * @param user $user User object
055 */
056 public function __construct(auth $auth, config $config, ContainerInterface $container, path_helper $path_helper, renderer $renderer, user $user)
057 {
058 $this->auth = $auth;
059 $this->config = $config;
060 $this->container = $container;
061 $this->path_helper = $path_helper;
062 $this->renderer = $renderer;
063 $this->user = $user;
064 }
065
066 /**
067 * Returns the board url (and caches it in the function)
068 */
069 public function get_board_url()
070 {
071 static $board_url;
072
073 if (empty($board_url))
074 {
075 $board_url = generate_board_url();
076 }
077
078 return $board_url;
079 }
080
081 /**
082 * Run links through append_sid(), prepend generate_board_url() and remove session id
083 */
084 public function append_sid($url, $params)
085 {
086 return append_sid($this->get_board_url() . '/' . $url, $params, true, '');
087 }
088
089 /**
090 * Generate ISO 8601 date string (RFC 3339)
091 */
092 public function format_date($time)
093 {
094 static $zone_offset;
095 static $offset_string;
096
097 if (empty($offset_string))
098 {
099 $zone_offset = $this->user->create_datetime()->getOffset();
100 $offset_string = phpbb_format_timezone_offset($zone_offset, true);
101 }
102
103 return gmdate("Y-m-d\TH:i:s", $time + $zone_offset) . $offset_string;
104 }
105
106 /**
107 * Generate text content
108 *
109 * @param string $content is feed text content
110 * @param string $uid is bbcode_uid
111 * @param string $bitfield is bbcode bitfield
112 * @param int $options bbcode flag options
113 * @param int $forum_id is the forum id
114 * @param array $post_attachments is an array containing the attachments and their respective info
115 * @return string the html content to be printed for the feed
116 */
117 public function generate_content($content, $uid, $bitfield, $options, $forum_id, $post_attachments)
118 {
119 if (empty($content))
120 {
121 return '';
122 }
123
124 // Setup our own quote_helper to remove all attributes from quotes
125 $this->renderer->configure_quote_helper($this->container->get('feed.quote_helper'));
126
127 $this->renderer->set_smilies_path($this->get_board_url() . '/' . $this->config['smilies_path']);
128
129 $this->renderer->configure_user($this->user, $this->config, $this->auth);
130
131 $content = generate_text_for_display($content, $uid, $bitfield, $options);
132
133 // Remove "Select all" link and mouse events
134 $content = str_replace('<a href="#" onclick="selectCode(this); return false;">' . $this->user->lang['SELECT_ALL_CODE'] . '</a>', '', $content);
135 $content = preg_replace('#(onkeypress|onclick)="(.*?)"#si', '', $content);
136
137 // Firefox does not support CSS for feeds, though
138
139 // Remove font sizes
140 // $content = preg_replace('#<span style="font-size: [0-9]+%; line-height: [0-9]+%;">([^>]+)</span>#iU', '\1', $content);
141
142 // Make text strong :P
143 // $content = preg_replace('#<span style="font-weight: bold?">(.*?)</span>#iU', '<strong>\1</strong>', $content);
144
145 // Italic
146 // $content = preg_replace('#<span style="font-style: italic?">([^<]+)</span>#iU', '<em>\1</em>', $content);
147
148 // Underline
149 // $content = preg_replace('#<span style="text-decoration: underline?">([^<]+)</span>#iU', '<u>\1</u>', $content);
150
151 // Remove embed Windows Media Streams
152 $content = preg_replace( '#<\!--\[if \!IE\]>-->([^[]+)<\!--<!\[endif\]-->#si', '', $content);
153
154 // Do not use < and >, because we want to retain code contained in [code][/code]
155
156 // Remove embed and objects
157 $content = preg_replace( '#<(object|embed)(.*?) (value|src)=(.*?) ([^[]+)(object|embed)>#si',' <a href=$4 target="_blank"><strong>$1</strong></a> ',$content);
158
159 // Remove some specials html tag, because somewhere there are a mod to allow html tags ;)
160 $content = preg_replace( '#<(script|iframe)([^[]+)\1>#siU', ' <strong>$1</strong> ', $content);
161
162 // Parse inline images to display with the feed
163 if (!empty($post_attachments))
164 {
165 $update_count = array();
166 parse_attachments($forum_id, $content, $post_attachments, $update_count);
167 $content .= implode('<br />', $post_attachments);
168
169 // Convert attachments' relative path to absolute path
170 $content = str_replace($this->path_helper->get_web_root_path() . 'download/file.' . $this->path_helper->get_php_ext(), $this->get_board_url() . '/download/file.' . $this->path_helper->get_php_ext(), $content);
171 }
172
173 // Remove Comments from inline attachments [ia]
174 $content = preg_replace('#<dd>(.*?)</dd>#','',$content);
175
176 // Replace some entities with their unicode counterpart
177 $entities = array(
178 ' ' => "\xC2\xA0",
179 '•' => "\xE2\x80\xA2",
180 '·' => "\xC2\xB7",
181 '©' => "\xC2\xA9",
182 );
183
184 $content = str_replace(array_keys($entities), array_values($entities), $content);
185
186 // Remove CDATA blocks. ;)
187 $content = preg_replace('#\<\!\[CDATA\[(.*?)\]\]\>#s', '', $content);
188
189 // Other control characters
190 $content = preg_replace('#(?:[\x00-\x1F\x7F]+|(?:\xC2[\x80-\x9F])+)#', '', $content);
191
192 return $content;
193 }
194 }
195