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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
base.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 /**
017 * Base class with some generic functions and settings.
018 */
019 abstract class base
020 {
021 /**
022 * Feed helper object
023 * @var \phpbb\feed\helper
024 */
025 protected $helper;
026
027 /** @var \phpbb\config\config */
028 protected $config;
029
030 /** @var \phpbb\db\driver\driver_interface */
031 protected $db;
032
033 /** @var \phpbb\cache\driver\driver_interface */
034 protected $cache;
035
036 /** @var \phpbb\user */
037 protected $user;
038
039 /** @var \phpbb\auth\auth */
040 protected $auth;
041
042 /** @var string */
043 protected $phpEx;
044
045 /**
046 * SQL Query to be executed to get feed items
047 */
048 var $sql = array();
049
050 /**
051 * Keys specified for retrieval of title, content, etc.
052 */
053 var $keys = array();
054
055 /**
056 * Number of items to fetch. Usually overwritten by $config['feed_something']
057 */
058 var $num_items = 15;
059
060 /**
061 * Separator for title elements to separate items (for example forum / topic)
062 */
063 var $separator = "\xE2\x80\xA2"; // •
064
065 /**
066 * Separator for the statistics row (Posted by, post date, replies, etc.)
067 */
068 var $separator_stats = "\xE2\x80\x94"; // —
069
070 /**
071 * Constructor
072 *
073 * @param \phpbb\feed\helper $helper Feed helper
074 * @param \phpbb\config\config $config Config object
075 * @param \phpbb\db\driver\driver_interface $db Database connection
076 * @param \phpbb\cache\driver\driver_interface $cache Cache object
077 * @param \phpbb\user $user User object
078 * @param \phpbb\auth\auth $auth Auth object
079 * @param \phpbb\content_visibility $content_visibility Auth object
080 * @param string $phpEx php file extension
081 */
082 function __construct(\phpbb\feed\helper $helper, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\cache\driver\driver_interface $cache, \phpbb\user $user, \phpbb\auth\auth $auth, \phpbb\content_visibility $content_visibility, $phpEx)
083 {
084 $this->config = $config;
085 $this->helper = $helper;
086 $this->db = $db;
087 $this->cache = $cache;
088 $this->user = $user;
089 $this->auth = $auth;
090 $this->content_visibility = $content_visibility;
091 $this->phpEx = $phpEx;
092
093 $this->set_keys();
094
095 // Allow num_items to be string
096 if (is_string($this->num_items))
097 {
098 $this->num_items = (int) $this->config[$this->num_items];
099
100 // A precaution
101 if (!$this->num_items)
102 {
103 $this->num_items = 10;
104 }
105 }
106 }
107
108 /**
109 * Set keys.
110 */
111 function set_keys()
112 {
113 }
114
115 /**
116 * Open feed
117 */
118 function open()
119 {
120 }
121
122 /**
123 * Close feed
124 */
125 function close()
126 {
127 if (!empty($this->result))
128 {
129 $this->db->sql_freeresult($this->result);
130 }
131 }
132
133 /**
134 * Set key
135 *
136 * @param string $key Key
137 * @param mixed $value Value
138 */
139 function set($key, $value)
140 {
141 $this->keys[$key] = $value;
142 }
143
144 /**
145 * Get key
146 *
147 * @param string $key Key
148 * @return mixed
149 */
150 function get($key)
151 {
152 return (isset($this->keys[$key])) ? $this->keys[$key] : null;
153 }
154
155 function get_readable_forums()
156 {
157 static $forum_ids;
158
159 if (!isset($forum_ids))
160 {
161 $forum_ids = array_keys($this->auth->acl_getf('f_read', true));
162 }
163
164 return $forum_ids;
165 }
166
167 function get_moderator_approve_forums()
168 {
169 static $forum_ids;
170
171 if (!isset($forum_ids))
172 {
173 $forum_ids = array_keys($this->auth->acl_getf('m_approve', true));
174 }
175
176 return $forum_ids;
177 }
178
179 function is_moderator_approve_forum($forum_id)
180 {
181 static $forum_ids;
182
183 if (!isset($forum_ids))
184 {
185 $forum_ids = array_flip($this->get_moderator_approve_forums());
186 }
187
188 return (isset($forum_ids[$forum_id])) ? true : false;
189 }
190
191 function get_excluded_forums()
192 {
193 static $forum_ids;
194
195 // Matches acp/acp_board.php
196 $cache_name = 'feed_excluded_forum_ids';
197
198 if (!isset($forum_ids) && ($forum_ids = $this->cache->get('_' . $cache_name)) === false)
199 {
200 $sql = 'SELECT forum_id
201 FROM ' . FORUMS_TABLE . '
202 WHERE ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '<> 0');
203 $result = $this->db->sql_query($sql);
204
205 $forum_ids = array();
206 while ($forum_id = (int) $this->db->sql_fetchfield('forum_id'))
207 {
208 $forum_ids[$forum_id] = $forum_id;
209 }
210 $this->db->sql_freeresult($result);
211
212 $this->cache->put('_' . $cache_name, $forum_ids);
213 }
214
215 return $forum_ids;
216 }
217
218 function is_excluded_forum($forum_id)
219 {
220 $forum_ids = $this->get_excluded_forums();
221
222 return isset($forum_ids[$forum_id]) ? true : false;
223 }
224
225 function get_passworded_forums()
226 {
227 return $this->user->get_passworded_forums();
228 }
229
230 function get_item()
231 {
232 static $result;
233
234 if (!isset($result))
235 {
236 if (!$this->get_sql())
237 {
238 return false;
239 }
240
241 // Query database
242 $sql = $this->db->sql_build_query('SELECT', $this->sql);
243 $result = $this->db->sql_query_limit($sql, $this->num_items);
244 }
245
246 return $this->db->sql_fetchrow($result);
247 }
248
249 function user_viewprofile($row)
250 {
251 $author_id = (int) $row[$this->get('author_id')];
252
253 if ($author_id == ANONYMOUS)
254 {
255 // Since we cannot link to a profile, we just return GUEST
256 // instead of $row['username']
257 return $this->user->lang['GUEST'];
258 }
259
260 return '<a href="' . $this->helper->append_sid('memberlist.' . $this->phpEx, 'mode=viewprofile&u=' . $author_id) . '">' . $row[$this->get('creator')] . '</a>';
261 }
262 }
263