1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* @package sitemaker |
5
|
|
|
* @copyright (c) 2017 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\event; |
11
|
|
|
|
12
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
13
|
|
|
|
14
|
|
|
class feed implements EventSubscriberInterface |
15
|
|
|
{ |
16
|
|
|
/** @var \phpbb\config\config */ |
17
|
|
|
protected $config; |
18
|
|
|
|
19
|
|
|
/** @var \phpbb\db\driver\driver_interface */ |
20
|
|
|
protected $db; |
21
|
|
|
|
22
|
|
|
/** @var \phpbb\template\template */ |
23
|
|
|
protected $template; |
24
|
|
|
|
25
|
|
|
/* @var \blitze\content\services\types */ |
26
|
|
|
protected $content_types; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Constructor |
30
|
|
|
* |
31
|
|
|
* @param \phpbb\config\config $config Config object |
32
|
|
|
* @param \phpbb\db\driver\driver_interface $db Database connection |
33
|
|
|
* @param \phpbb\template\template $template Template object |
34
|
|
|
* @param \blitze\content\services\types $content_types Content types object |
35
|
|
|
*/ |
36
|
|
|
public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\template\template $template, \blitze\content\services\types $content_types) |
37
|
|
|
{ |
38
|
|
|
$this->config = $config; |
39
|
|
|
$this->db = $db; |
40
|
|
|
$this->template = $template; |
41
|
|
|
$this->content_types = $content_types; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return array |
46
|
|
|
*/ |
47
|
|
|
public static function getSubscribedEvents() |
48
|
|
|
{ |
49
|
|
|
return array( |
50
|
|
|
'core.feed_base_modify_item_sql' => 'hide_from_feeds', |
51
|
|
|
'core.page_header_after' => 'set_content_feeds', |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* This excludes content forums from feeds |
57
|
|
|
* |
58
|
|
|
* @param \phpbb\event\data $event |
59
|
|
|
* @return void |
60
|
|
|
*/ |
61
|
|
|
public function hide_from_feeds(\phpbb\event\data $event) |
62
|
|
|
{ |
63
|
|
|
$sql_ary = $event['sql_ary']; |
64
|
|
|
|
65
|
|
|
$forum_ids = array_keys($this->content_types->get_forum_types()); |
66
|
|
|
$sql_ary['WHERE'] .= ' AND ' . $this->db->sql_in_set('f.forum_id', array_map('intval', $forum_ids), true); |
67
|
|
|
|
68
|
|
|
$event['sql_ary'] = $sql_ary; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return void |
73
|
|
|
*/ |
74
|
|
|
public function set_content_feeds() |
75
|
|
|
{ |
76
|
|
|
if ($this->config['feed_enable']) |
77
|
|
|
{ |
78
|
|
|
$types_ary = $this->content_types->get_all_types(); |
79
|
|
|
|
80
|
|
|
$feeds = array(); |
81
|
|
|
foreach ($types_ary as $type) |
82
|
|
|
{ |
83
|
|
|
$feeds[] = array( |
84
|
|
|
'type' => $type->get_content_name(), |
85
|
|
|
'langname' => $type->get_content_langname(), |
86
|
|
|
); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
$this->template->assign_var('CONTENT_FEEDS', $feeds); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|