1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* @package phpBB Extension - tas2580 SEO URLs |
5
|
|
|
* @copyright (c) 2016 tas2580 (https://tas2580.net) |
6
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
7
|
|
|
* |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace tas2580\seourls\event; |
11
|
|
|
|
12
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Event listener |
16
|
|
|
*/ |
17
|
|
|
class extensions implements EventSubscriberInterface |
18
|
|
|
{ |
19
|
|
|
/** @var \tas2580\seourls\event\base */ |
20
|
|
|
protected $base; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Constructor |
24
|
|
|
* |
25
|
|
|
* @param \tas2580\seourls\event\base $base |
26
|
|
|
* @access public |
27
|
|
|
*/ |
28
|
|
|
public function __construct(\tas2580\seourls\event\base $base) |
29
|
|
|
{ |
30
|
|
|
$this->base = $base; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Assign functions defined in this class to event listeners in the core |
35
|
|
|
* |
36
|
|
|
* @return array |
37
|
|
|
* @static |
38
|
|
|
* @access public |
39
|
|
|
*/ |
40
|
|
|
public static function getSubscribedEvents() |
41
|
|
|
{ |
42
|
|
|
return array( |
43
|
|
|
'rmcgirr83.topfive.sql_pull_topics_data' => 'topfive_sql_pull_topics_data', |
44
|
|
|
'rmcgirr83.topfive.modify_tpl_ary' => 'topfive_modify_tpl_ary', |
45
|
|
|
'tas2580.sitemap_modify_before_output' => 'sitemap_modify_before_output', |
46
|
|
|
'vse.similartopics.modify_topicrow' => 'similartopics_modify_topicrow', |
47
|
|
|
); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Rewrite URLs in tas2580 Sitemap Extension |
53
|
|
|
* |
54
|
|
|
* @param object $event The event object |
55
|
|
|
* @return null |
56
|
|
|
* @access public |
57
|
|
|
*/ |
58
|
|
|
public function sitemap_modify_before_output($event) |
59
|
|
|
{ |
60
|
|
|
// Nothing to rewrite in the sitemap index |
61
|
|
|
if ($event['type'] == 'sitemapindex') |
62
|
|
|
{ |
63
|
|
|
return; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
$url_data =$event['url_data'] ; |
67
|
|
|
|
68
|
|
|
foreach ($url_data as $id => $data) |
69
|
|
|
{ |
70
|
|
|
$row = $data['row']; |
71
|
|
|
if (isset($row['topic_id'])) |
72
|
|
|
{ |
73
|
|
|
$url_data[$id]['url'] = $this->base->generate_topic_link($row['forum_id'], $row['forum_name'], $row['topic_id'], $row['topic_title'], $data['start'], true); |
74
|
|
|
} |
75
|
|
|
else if (isset($row['forum_id'])) |
76
|
|
|
{ |
77
|
|
|
$url_data[$id]['url'] = $this->base->generate_forum_link($row['forum_id'], $row['forum_name'], $data['start'], true); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
$event['url_data'] = $url_data; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Rewrite URLs in Similar Topics Extension |
86
|
|
|
* |
87
|
|
|
* @param object $event The event object |
88
|
|
|
* @return null |
89
|
|
|
* @access public |
90
|
|
|
*/ |
91
|
|
|
public function similartopics_modify_topicrow($event) |
92
|
|
|
{ |
93
|
|
|
$this->forum_title = $event['row']['forum_name']; |
94
|
|
|
$this->forum_id = $event['row']['forum_id']; |
95
|
|
|
$this->topic_title = $event['row']['topic_title']; |
96
|
|
|
$this->topic_id = $event['row']['topic_id']; |
97
|
|
|
|
98
|
|
|
$topic_row = $event['topic_row']; |
99
|
|
|
$u_view_topic= $this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title); |
100
|
|
|
$topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic); |
101
|
|
|
$topic_row['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title)); |
102
|
|
|
$topic_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($topic_row['TOPIC_REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
103
|
|
|
$event['topic_row'] = $topic_row; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Rewrite URLs in Top 5 Extension |
108
|
|
|
* |
109
|
|
|
* @param object $event The event object |
110
|
|
|
* @return null |
111
|
|
|
* @access public |
112
|
|
|
*/ |
113
|
|
|
public function topfive_sql_pull_topics_data($event) |
114
|
|
|
{ |
115
|
|
|
$sql_array = $event['sql_array']; |
116
|
|
|
$sql_array['SELECT'] = array_merge($sql_array, array('SELECT' => 'f.forum_name')); |
117
|
|
|
$sql_array['LEFT_JOIN'] = array_merge($sql_array['LEFT_JOIN'], array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id')); |
118
|
|
|
$event['sql_array'] = $sql_array; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Rewrite URLs in Top 5 Extension |
123
|
|
|
* |
124
|
|
|
* @param object $event The event object |
125
|
|
|
* @return null |
126
|
|
|
* @access public |
127
|
|
|
*/ |
128
|
|
|
public function topfive_modify_tpl_ary($event) |
129
|
|
|
{ |
130
|
|
|
$tpl_ary = $event['tpl_ary']; |
131
|
|
|
$replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1; |
132
|
|
|
$u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']); |
133
|
|
|
$tpl_ary['U_TOPIC'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']); |
134
|
|
|
$event['tpl_ary'] = $tpl_ary; |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|