1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* @package sitemaker |
5
|
|
|
* @copyright (c) 2013 Daniel A. (blitze) |
6
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
7
|
|
|
* |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace blitze\content\services\views\driver; |
11
|
|
|
|
12
|
|
|
class portal extends base_view |
13
|
|
|
{ |
14
|
|
|
/** @var \phpbb\config\config */ |
15
|
|
|
protected $config; |
16
|
|
|
|
17
|
|
|
/** @var \blitze\content\services\types */ |
18
|
|
|
protected $content_types; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Constructor |
22
|
|
|
* |
23
|
|
|
* @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object |
24
|
|
|
* @param \phpbb\language\language $language Language Object |
25
|
|
|
* @param \phpbb\pagination $pagination Pagination object |
26
|
|
|
* @param \phpbb\template\template $template Template object |
27
|
|
|
* @param \blitze\content\services\fields $fields Content fields object |
28
|
|
|
* @param \blitze\sitemaker\services\forum\data $forum Forum Data object |
29
|
|
|
* @param \blitze\content\services\helper $helper Content helper object |
30
|
|
|
* @param \blitze\content\services\quickmod $quickmod Quick moderator tools |
31
|
|
|
* @param string $phpbb_root_path Path to the phpbb includes directory. |
32
|
|
|
* @param string $php_ext php file extension |
33
|
|
|
* @param \phpbb\config\config $config Config object |
34
|
|
|
* @param \blitze\content\services\types $content_types Content types object |
35
|
|
|
*/ |
36
|
|
|
public function __construct(\phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\language\language $language, \phpbb\pagination $pagination, \phpbb\template\template $template, \blitze\content\services\fields $fields, \blitze\sitemaker\services\forum\data $forum, \blitze\content\services\helper $helper, \blitze\content\services\quickmod $quickmod, $phpbb_root_path, $php_ext, \phpbb\config\config $config, \blitze\content\services\types $content_types) |
37
|
|
|
{ |
38
|
|
|
parent::__construct($phpbb_dispatcher, $language, $pagination, $template, $fields, $forum, $helper, $quickmod, $phpbb_root_path, $php_ext); |
39
|
|
|
|
40
|
|
|
$this->config = $config; |
41
|
|
|
$this->content_types = $content_types; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @inheritdoc |
46
|
|
|
*/ |
47
|
|
|
public function get_name() |
48
|
|
|
{ |
49
|
|
|
return 'portal'; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @inheritdoc |
54
|
|
|
*/ |
55
|
|
|
public function get_langname() |
56
|
|
|
{ |
57
|
|
|
return 'CONTENT_DISPLAY_PORTAL'; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @inheritdoc |
62
|
|
|
*/ |
63
|
|
|
public function get_index_template() |
64
|
|
|
{ |
65
|
|
|
return 'views/portal.html'; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* {@inheritdoc} |
70
|
|
|
*/ |
71
|
|
|
public function render_filter($filter_type, $filter_value, $page) |
72
|
|
|
{ |
73
|
|
|
$this->build_index_query($filter_type, $filter_value); |
74
|
|
|
|
75
|
|
|
$total_topics = $this->forum->get_topics_count(); |
76
|
|
|
$items_per_page = $this->config['topics_per_page']; |
77
|
|
|
$start = ($page - 1) * $items_per_page; |
78
|
|
|
$topics_data = $this->forum->get_topic_data($items_per_page, $start); |
79
|
|
|
$this->generate_pagination('summary', $total_topics, $start, $items_per_page, array( |
80
|
|
|
'filter_type' => $filter_type, |
81
|
|
|
'filter_value' => $filter_value, |
82
|
|
|
)); |
83
|
|
|
|
84
|
|
|
if (sizeof($topics_data)) |
85
|
|
|
{ |
86
|
|
|
$posts_data = $this->forum->get_post_data('first'); |
87
|
|
|
$users_cache = $this->forum->get_posters_info(); |
88
|
|
|
|
89
|
|
|
$forums_data = array(); |
90
|
|
|
foreach ($posts_data as $topic_id => $row) |
91
|
|
|
{ |
92
|
|
|
$post = current($row); |
93
|
|
|
$forums_data[$post['forum_id']][$topic_id] = $post; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
$this->display_filtered_topics($forums_data, $topics_data, $users_cache); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param array $forums_data |
102
|
|
|
* @return void |
103
|
|
|
*/ |
104
|
|
|
protected function display_filtered_topics(array $forums_data, array $topics_data, array $users_cache) |
105
|
|
|
{ |
106
|
|
|
$update_count = array(); |
107
|
|
|
foreach ($forums_data as $forum_id => $posts_data) |
108
|
|
|
{ |
109
|
|
|
$content_type = $this->content_types->get_forum_type($forum_id); |
110
|
|
|
$entity = $this->content_types->get_type($content_type); |
|
|
|
|
111
|
|
|
$this->template->assign_vars($entity->to_array()); |
112
|
|
|
|
113
|
|
|
$this->fields->prepare_to_show($entity, array_keys($posts_data), $entity->get_summary_tags(), $entity->get_summary_tpl(), 'summary'); |
|
|
|
|
114
|
|
|
|
115
|
|
|
$topic_tracking_info = $this->forum->get_topic_tracking_info($forum_id); |
116
|
|
|
$attachments = $this->forum->get_attachments($forum_id); |
117
|
|
|
|
118
|
|
|
foreach ($posts_data as $topic_id => $post_data) |
119
|
|
|
{ |
120
|
|
|
$topic_data = $topics_data[$topic_id]; |
121
|
|
|
$topic = $this->fields->show($content_type, $topic_data, $post_data, $users_cache, $attachments, $update_count, $topic_tracking_info); |
|
|
|
|
122
|
|
|
|
123
|
|
|
$this->template->assign_block_vars('topicrow', $topic); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.