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 |
attachments_base.php
01 <?php
02 /**
03 *
04 * This file is part of the phpBB Forum Software package.
05 *
06 * @copyright (c) phpBB Limited <https://www.phpbb.com>
07 * @license GNU General Public License, version 2 (GPL-2.0)
08 *
09 * For full copyright and license information, please see
10 * the docs/CREDITS.txt file.
11 *
12 */
13
14 namespace phpbb\feed;
15
16 /**
17 * Abstract class for feeds displaying attachments
18 */
19 abstract class attachments_base extends \phpbb\feed\base
20 {
21 /**
22 * Attachments that may be displayed
23 */
24 protected $attachments = array();
25
26 /**
27 * Retrieve the list of attachments that may be displayed
28 */
29 protected function fetch_attachments()
30 {
31 $sql_array = array(
32 'SELECT' => 'a.*',
33 'FROM' => array(
34 ATTACHMENTS_TABLE => 'a'
35 ),
36 'WHERE' => 'a.in_message = 0 ',
37 'ORDER_BY' => 'a.filetime DESC, a.post_msg_id ASC',
38 );
39
40 if (isset($this->topic_id))
41 {
42 $sql_array['WHERE'] .= 'AND a.topic_id = ' . (int) $this->topic_id;
43 }
44 else if (isset($this->forum_id))
45 {
46 $sql_array['LEFT_JOIN'] = array(
47 array(
48 'FROM' => array(TOPICS_TABLE => 't'),
49 'ON' => 'a.topic_id = t.topic_id',
50 )
51 );
52 $sql_array['WHERE'] .= 'AND t.forum_id = ' . (int) $this->forum_id;
53 }
54
55 $sql = $this->db->sql_build_query('SELECT', $sql_array);
56 $result = $this->db->sql_query($sql);
57
58 // Set attachments in feed items
59 while ($row = $this->db->sql_fetchrow($result))
60 {
61 $this->attachments[$row['post_msg_id']][] = $row;
62 }
63 $this->db->sql_freeresult($result);
64 }
65
66 /**
67 * {@inheritDoc}
68 */
69 public function open()
70 {
71 parent::open();
72 $this->fetch_attachments();
73 }
74
75 /**
76 * Get attachments related to a given post
77 *
78 * @param $post_id int Post id
79 * @return mixed Attachments related to $post_id
80 */
81 public function get_attachments($post_id)
82 {
83 return $this->attachments[$post_id];
84 }
85 }
86