Passed
Push — master ( 4dcbbb...5b4602 )
by Tobias
37s
created
event/extensions.php 2 patches
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -16,133 +16,133 @@
 block discarded – undo
16 16
  */
17 17
 class extensions implements EventSubscriberInterface
18 18
 {
19
-	/** @var \tas2580\seourls\event\base */
20
-	protected $base;
19
+    /** @var \tas2580\seourls\event\base */
20
+    protected $base;
21 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
-	}
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 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
-			'paybas.recenttopics.modify_tpl_ary'		=> 'recenttopics_modify_tpl_ary'
48
-		);
49
-	}
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
+            'paybas.recenttopics.modify_tpl_ary'		=> 'recenttopics_modify_tpl_ary'
48
+        );
49
+    }
50 50
 
51
-	public function recenttopics_modify_tpl_ary($event)
52
-	{
53
-		$tpl_ary = $event['tpl_ary'];
54
-		$u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']);
55
-		$tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic);
56
-		$tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($tpl_ary['REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']);
57
-		$tpl_ary['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name']));
58
-		$tpl_ary['U_NEWEST_POST'] = $u_view_topic . '?view=unread#unread';
51
+    public function recenttopics_modify_tpl_ary($event)
52
+    {
53
+        $tpl_ary = $event['tpl_ary'];
54
+        $u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']);
55
+        $tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic);
56
+        $tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($tpl_ary['REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']);
57
+        $tpl_ary['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name']));
58
+        $tpl_ary['U_NEWEST_POST'] = $u_view_topic . '?view=unread#unread';
59 59
 
60
-		$event['tpl_ary'] = $tpl_ary;
61
-	}
60
+        $event['tpl_ary'] = $tpl_ary;
61
+    }
62 62
 
63
-	/**
64
-	 * Rewrite URLs in tas2580 Sitemap Extension
65
-	 *
66
-	 * @param	object	$event	The event object
67
-	 * @return	null
68
-	 * @access	public
69
-	 */
70
-	public function sitemap_modify_before_output($event)
71
-	{
72
-		// Nothing to rewrite in the sitemap index
73
-		if ($event['type'] == 'sitemapindex')
74
-		{
75
-			return;
76
-		}
63
+    /**
64
+     * Rewrite URLs in tas2580 Sitemap Extension
65
+     *
66
+     * @param	object	$event	The event object
67
+     * @return	null
68
+     * @access	public
69
+     */
70
+    public function sitemap_modify_before_output($event)
71
+    {
72
+        // Nothing to rewrite in the sitemap index
73
+        if ($event['type'] == 'sitemapindex')
74
+        {
75
+            return;
76
+        }
77 77
 
78
-		$url_data =$event['url_data'] ;
78
+        $url_data =$event['url_data'] ;
79 79
 
80
-		foreach ($url_data as $id => $data)
81
-		{
82
-			$row = $data['row'];
83
-			if (isset($row['topic_id']))
84
-			{
85
-				$url_data[$id]['url'] = $this->base->generate_topic_link($row['forum_id'], $row['forum_name'], $row['topic_id'], $row['topic_title'],  $data['start'], true);
86
-			}
87
-			else if (isset($row['forum_id']))
88
-			{
89
-				$url_data[$id]['url'] = $this->base->generate_forum_link($row['forum_id'], $row['forum_name'], $data['start'], true);
90
-			}
91
-		}
80
+        foreach ($url_data as $id => $data)
81
+        {
82
+            $row = $data['row'];
83
+            if (isset($row['topic_id']))
84
+            {
85
+                $url_data[$id]['url'] = $this->base->generate_topic_link($row['forum_id'], $row['forum_name'], $row['topic_id'], $row['topic_title'],  $data['start'], true);
86
+            }
87
+            else if (isset($row['forum_id']))
88
+            {
89
+                $url_data[$id]['url'] = $this->base->generate_forum_link($row['forum_id'], $row['forum_name'], $data['start'], true);
90
+            }
91
+        }
92 92
 
93
-		$event['url_data'] = $url_data;
94
-	}
93
+        $event['url_data'] = $url_data;
94
+    }
95 95
 
96
-	/**
97
-	 * Rewrite URLs in Similar Topics Extension
98
-	 *
99
-	 * @param	object	$event	The event object
100
-	 * @return	null
101
-	 * @access	public
102
-	 */
103
-	public function similartopics_modify_topicrow($event)
104
-	{
105
-		$this->forum_title = $event['row']['forum_name'];
106
-		$this->forum_id = $event['row']['forum_id'];
107
-		$this->topic_title = $event['row']['topic_title'];
108
-		$this->topic_id = $event['row']['topic_id'];
96
+    /**
97
+     * Rewrite URLs in Similar Topics Extension
98
+     *
99
+     * @param	object	$event	The event object
100
+     * @return	null
101
+     * @access	public
102
+     */
103
+    public function similartopics_modify_topicrow($event)
104
+    {
105
+        $this->forum_title = $event['row']['forum_name'];
106
+        $this->forum_id = $event['row']['forum_id'];
107
+        $this->topic_title = $event['row']['topic_title'];
108
+        $this->topic_id = $event['row']['topic_id'];
109 109
 
110
-		$topic_row = $event['topic_row'];
111
-		$u_view_topic= $this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title);
112
-		$topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic);
113
-		$topic_row['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title));
114
-		$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']);
115
-		$event['topic_row'] = $topic_row;
116
-	}
110
+        $topic_row = $event['topic_row'];
111
+        $u_view_topic= $this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title);
112
+        $topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic);
113
+        $topic_row['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title));
114
+        $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']);
115
+        $event['topic_row'] = $topic_row;
116
+    }
117 117
 
118
-	/**
119
-	 * Rewrite URLs in Top 5 Extension
120
-	 *
121
-	 * @param	object	$event	The event object
122
-	 * @return	null
123
-	 * @access	public
124
-	 */
125
-	public function topfive_sql_pull_topics_data($event)
126
-	{
127
-		$sql_array = $event['sql_array'];
128
-		$sql_array['SELECT'] = array_merge($sql_array, array('SELECT' => 'f.forum_name'));
129
-		$sql_array['LEFT_JOIN'] = array_merge($sql_array['LEFT_JOIN'], array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id'));
130
-		$event['sql_array'] = $sql_array;
131
-	}
118
+    /**
119
+     * Rewrite URLs in Top 5 Extension
120
+     *
121
+     * @param	object	$event	The event object
122
+     * @return	null
123
+     * @access	public
124
+     */
125
+    public function topfive_sql_pull_topics_data($event)
126
+    {
127
+        $sql_array = $event['sql_array'];
128
+        $sql_array['SELECT'] = array_merge($sql_array, array('SELECT' => 'f.forum_name'));
129
+        $sql_array['LEFT_JOIN'] = array_merge($sql_array['LEFT_JOIN'], array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id'));
130
+        $event['sql_array'] = $sql_array;
131
+    }
132 132
 
133
-	/**
134
-	 * Rewrite URLs in Top 5 Extension
135
-	 *
136
-	 * @param	object	$event	The event object
137
-	 * @return	null
138
-	 * @access	public
139
-	 */
140
-	public function topfive_modify_tpl_ary($event)
141
-	{
142
-		$tpl_ary = $event['tpl_ary'];
143
-		$replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1;
144
-		$u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']);
145
-		$tpl_ary['U_TOPIC'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']);
146
-		$event['tpl_ary'] = $tpl_ary;
147
-	}
133
+    /**
134
+     * Rewrite URLs in Top 5 Extension
135
+     *
136
+     * @param	object	$event	The event object
137
+     * @return	null
138
+     * @access	public
139
+     */
140
+    public function topfive_modify_tpl_ary($event)
141
+    {
142
+        $tpl_ary = $event['tpl_ary'];
143
+        $replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1;
144
+        $u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']);
145
+        $tpl_ary['U_TOPIC'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']);
146
+        $event['tpl_ary'] = $tpl_ary;
147
+    }
148 148
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 		$tpl_ary = $event['tpl_ary'];
54 54
 		$u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']);
55 55
 		$tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic);
56
-		$tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($tpl_ary['REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']);
56
+		$tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($tpl_ary['REPLIES'], $u_view_topic).'#p'.$event['row']['topic_last_post_id']);
57 57
 		$tpl_ary['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name']));
58
-		$tpl_ary['U_NEWEST_POST'] = $u_view_topic . '?view=unread#unread';
58
+		$tpl_ary['U_NEWEST_POST'] = $u_view_topic.'?view=unread#unread';
59 59
 
60 60
 		$event['tpl_ary'] = $tpl_ary;
61 61
 	}
@@ -75,14 +75,14 @@  discard block
 block discarded – undo
75 75
 			return;
76 76
 		}
77 77
 
78
-		$url_data =$event['url_data'] ;
78
+		$url_data = $event['url_data'];
79 79
 
80 80
 		foreach ($url_data as $id => $data)
81 81
 		{
82 82
 			$row = $data['row'];
83 83
 			if (isset($row['topic_id']))
84 84
 			{
85
-				$url_data[$id]['url'] = $this->base->generate_topic_link($row['forum_id'], $row['forum_name'], $row['topic_id'], $row['topic_title'],  $data['start'], true);
85
+				$url_data[$id]['url'] = $this->base->generate_topic_link($row['forum_id'], $row['forum_name'], $row['topic_id'], $row['topic_title'], $data['start'], true);
86 86
 			}
87 87
 			else if (isset($row['forum_id']))
88 88
 			{
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 		$this->topic_id = $event['row']['topic_id'];
109 109
 
110 110
 		$topic_row = $event['topic_row'];
111
-		$u_view_topic= $this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title);
111
+		$u_view_topic = $this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title);
112 112
 		$topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic);
113 113
 		$topic_row['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title));
114
-		$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']);
114
+		$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']);
115 115
 		$event['topic_row'] = $topic_row;
116 116
 	}
117 117
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		$tpl_ary = $event['tpl_ary'];
143 143
 		$replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1;
144 144
 		$u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']);
145
-		$tpl_ary['U_TOPIC'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']);
145
+		$tpl_ary['U_TOPIC'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic).'#p'.$event['row']['topic_last_post_id']);
146 146
 		$event['tpl_ary'] = $tpl_ary;
147 147
 	}
148 148
 }
Please login to merge, or discard this patch.
event/listener.php 2 patches
Indentation   +406 added lines, -406 removed lines patch added patch discarded remove patch
@@ -16,410 +16,410 @@
 block discarded – undo
16 16
  */
17 17
 class listener implements EventSubscriberInterface
18 18
 {
19
-	/** @var \tas2580\seourls\event\base */
20
-	protected $base;
21
-
22
-	/** @var \phpbb\template\template */
23
-	protected $template;
24
-
25
-	/** @var \phpbb\request\request */
26
-	protected $request;
27
-
28
-	/** @var \phpbb\path_helper */
29
-	protected $path_helper;
30
-
31
-	/** @var string phpbb_root_path */
32
-	protected $phpbb_root_path;
33
-
34
-	/** @var string php_ext */
35
-	protected $php_ext;
36
-
37
-	private $in_viewforum;
38
-
39
-	/**
40
-	 * Constructor
41
-	 *
42
-	 * @param \tas2580\seourls\event\base	$base
43
-	 * @param \phpbb\template\template		$template				Template object
44
-	 * @param \phpbb\request\request		$request				Request object
45
-	 * @param \phpbb\path_helper			$path_helper			Controller helper object
46
-	 * @param string						$phpbb_root_path		phpbb_root_path
47
-	 * @param string						$php_ext				php_ext
48
-	 * @access public
49
-	 */
50
-	public function __construct(\tas2580\seourls\event\base $base, \phpbb\template\template $template, \phpbb\request\request $request, \phpbb\path_helper $path_helper, $phpbb_root_path, $php_ext)
51
-	{
52
-		$this->base = $base;
53
-		$this->template = $template;
54
-		$this->request = $request;
55
-		$this->path_helper = $path_helper;
56
-		$this->phpbb_root_path = $phpbb_root_path;
57
-		$this->php_ext = $php_ext;
58
-
59
-		$this->in_viewtopic = false;
60
-	}
61
-
62
-	/**
63
-	 * Assign functions defined in this class to event listeners in the core
64
-	 *
65
-	 * @return array
66
-	 * @static
67
-	 * @access public
68
-	 */
69
-	public static function getSubscribedEvents()
70
-	{
71
-		return array(
72
-			'core.append_sid'										=> 'append_sid',
73
-			'core.display_forums_modify_sql'						=> 'display_forums_modify_sql',
74
-			'core.display_forums_modify_template_vars'				=> 'display_forums_modify_template_vars',
75
-			'core.display_forums_modify_forum_rows'					=> 'display_forums_modify_forum_rows',
76
-			'core.display_forums_modify_category_template_vars'		=> 'display_forums_modify_category_template_vars',
77
-			'core.generate_forum_nav'								=> 'generate_forum_nav',
78
-			'core.make_jumpbox_modify_tpl_ary'						=> 'make_jumpbox_modify_tpl_ary',				// Not in phpBB
79
-			'core.memberlist_view_profile'							=> 'memberlist_view_profile',
80
-			'core.pagination_generate_page_link'					=> 'pagination_generate_page_link',
81
-			'core.search_modify_tpl_ary'							=> 'search_modify_tpl_ary',
82
-			'core.viewforum_modify_topicrow'						=> 'viewforum_modify_topicrow',
83
-			'core.viewforum_get_topic_data'							=> 'viewforum_get_topic_data',
84
-			'core.viewtopic_assign_template_vars_before'			=> 'viewtopic_assign_template_vars_before',
85
-			'core.viewtopic_before_f_read_check'					=> 'viewtopic_before_f_read_check',
86
-			'core.viewtopic_modify_page_title'						=> 'viewtopic_modify_page_title',
87
-			'core.viewtopic_modify_post_row'						=> 'viewtopic_modify_post_row',
88
-			'core.viewtopic_get_post_data'							=> 'viewtopic_get_post_data',
89
-		);
90
-	}
91
-
92
-	/**
93
-	 * Correct the path of $viewtopic_url
94
-	 *
95
-	 * @param	object	$event	The event object
96
-	 * @return	null
97
-	 * @access	public
98
-	 */
99
-	public function append_sid($event)
100
-	{
101
-		if ($this->in_viewtopic && preg_match('#./../viewtopic.' . $this->php_ext  . '#', $event['url']))
102
-		{
103
-			$url = '../viewtopic.' . $this->php_ext ;
104
-			$event['url'] = $url;
105
-		}
106
-		if (isset($event['params']['redirect']))
107
-		{
108
-			$params = $event['params'];
109
-			$params['redirect'] = str_replace('..', '.', $event['params']['redirect']);
110
-			$event['params'] = $params;
111
-		}
112
-	}
113
-
114
-	/**
115
-	 * Get informations for the last post from Database
116
-	 *
117
-	 * @param	object	$event	The event object
118
-	 * @return	null
119
-	 * @access	public
120
-	 */
121
-	public function display_forums_modify_sql($event)
122
-	{
123
-		$sql_array = $event['sql_ary'];
124
-		$sql_array['LEFT_JOIN'][] = array(
125
-			'FROM' => array(TOPICS_TABLE => 't'),
126
-			'ON' => "f.forum_last_post_id = t.topic_last_post_id"
127
-		);
128
-		$sql_array['SELECT'] .= ', t.topic_title, t.topic_id, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted';
129
-		$event['sql_ary'] = $sql_array;
130
-	}
131
-
132
-	/**
133
-	 * Store informations for the last post in forum_rows array
134
-	 *
135
-	 * @param	object	$event	The event object
136
-	 * @return	null
137
-	 * @access	public
138
-	 */
139
-	public function display_forums_modify_forum_rows($event)
140
-	{
141
-		$forum_rows = $event['forum_rows'];
142
-		if ($event['row']['forum_last_post_time'] == $forum_rows[$event['parent_id']]['forum_last_post_time'])
143
-		{
144
-			$forum_rows[$event['parent_id']]['forum_name_last_post'] =$event['row']['forum_name'];
145
-			$forum_rows[$event['parent_id']]['topic_id_last_post'] =$event['row']['topic_id'];
146
-			$forum_rows[$event['parent_id']]['topic_title_last_post'] =$event['row']['topic_title'];
147
-			$event['forum_rows'] = $forum_rows;
148
-		}
149
-	}
150
-
151
-	/**
152
-	 * Rewrite links to forums and subforums in forum index
153
-	 * also correct the path of the forum images if we are in a forum
154
-	 *
155
-	 * @param	object	$event	The event object
156
-	 * @return	null
157
-	 * @access	public
158
-	 */
159
-	public function display_forums_modify_template_vars($event)
160
-	{
161
-		$subforums_row = $event['subforums_row'];
162
-		$forum_row = $event['forum_row'];
163
-
164
-		// Rewrite URLs of sub forums
165
-		foreach ($subforums_row as $i => $subforum)
166
-		{
167
-			// A little bit a dirty way, but there is no better solution
168
-			$query = str_replace('&', '&', parse_url($subforum['U_SUBFORUM'], PHP_URL_QUERY));
169
-			parse_str($query, $id);
170
-			$subforums_row[$i]['U_SUBFORUM'] = append_sid($this->base->generate_forum_link($id['f'], $subforum['SUBFORUM_NAME']));
171
-		}
172
-
173
-		// Update the image source in forums
174
-		$img = $this->path_helper->update_web_root_path($forum_row['FORUM_IMAGE_SRC']);
175
-		$forum_row['FORUM_IMAGE'] = preg_replace('#img src=\"(.*)\" alt#', 'img src="' . $img . '" alt', $forum_row['FORUM_IMAGE']);
176
-
177
-		// Rewrite links to topics, posts and forums
178
-		$replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1;
179
-		$url = $this->base->generate_topic_link($event['row']['forum_id_last_post'], $event['row']['forum_name_last_post'], $event['row']['topic_id_last_post'], $event['row']['topic_title_last_post']);
180
-		$forum_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $url) . '#p' . $event['row']['forum_last_post_id']);
181
-		$forum_row['U_VIEWFORUM'] = append_sid($this->base->generate_forum_link($forum_row['FORUM_ID'], $forum_row['FORUM_NAME']));
182
-		$forum_row['U_NEWEST_POST'] = $url . '?view=unread#unread';
183
-
184
-		$event['subforums_row'] = $subforums_row;
185
-		$event['forum_row'] = $forum_row;
186
-	}
187
-
188
-	/**
189
-	 * Rewrite the categorie links
190
-	 *
191
-	 * @param	object	$event	The event object
192
-	 * @return	null
193
-	 * @access	public
194
-	 */
195
-	public function display_forums_modify_category_template_vars($event)
196
-	{
197
-		$cat_row = $event['cat_row'];
198
-		$row = $event['row'];
199
-		$cat_row['U_VIEWFORUM'] = append_sid($this->base->generate_forum_link($row['forum_id'], $row['forum_name']));
200
-		$event['cat_row'] = $cat_row;
201
-	}
202
-
203
-	/**
204
-	 * Rewrite links in breadcrumbs
205
-	 *
206
-	 * @param	object	$event	The event object
207
-	 * @return	null
208
-	 * @access	public
209
-	 */
210
-	public function generate_forum_nav($event)
211
-	{
212
-		$forum_data = $event['forum_data'];
213
-		$navlinks = $event['navlinks'];
214
-		$navlinks_parents = $event['navlinks_parents'];
215
-
216
-		foreach ($navlinks_parents as $id => $data)
217
-		{
218
-			$navlinks_parents[$id]['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($data['FORUM_ID'] , $data['FORUM_NAME']));
219
-		}
220
-
221
-		$navlinks['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($forum_data['forum_id'], $forum_data['forum_name']));
222
-		$event['navlinks'] = $navlinks;
223
-		$event['navlinks_parents'] = $navlinks_parents;
224
-	}
225
-
226
-	// Not in phpBB
227
-	public function make_jumpbox_modify_tpl_ary($event)
228
-	{
229
-		$tpl_ary = $event['tpl_ary'];
230
-		$row = $event['row'];
231
-		foreach ($tpl_ary as $id => $data)
232
-		{
233
-			$tpl_ary[$id]['LINK']	 = append_sid($this->base->generate_forum_link($row['forum_id'], $row['forum_name']));
234
-		}
235
-
236
-		$event['tpl_ary'] = $tpl_ary;
237
-	}
238
-
239
-	/**
240
-	 * Rewrite links to most active forum and topic on profile page
241
-	 *
242
-	 * @param	object	$event	The event object
243
-	 * @return	null
244
-	 * @access	public
245
-	 */
246
-	public function memberlist_view_profile($event)
247
-	{
248
-		$data = $event['member'];
249
-		$this->template->assign_vars(array(
250
-			'U_ACTIVE_FORUM' => $this->base->generate_forum_link($data['active_f_row']['forum_id'], $data['active_f_row']['forum_name'], 0, true),
251
-			'U_ACTIVE_TOPIC' => $this->base->generate_topic_link($data['active_f_row']['forum_id'], $data['active_f_row']['forum_name'], $data['active_t_row']['topic_id'], $data['active_t_row']['topic_title'], 0, true),
252
-		));
253
-	}
254
-
255
-	/**
256
-	 * Rewrite pagination links
257
-	 *
258
-	 * @param	object	$event	The event object
259
-	 * @return	null
260
-	 * @access	public
261
-	 */
262
-	public function pagination_generate_page_link($event)
263
-	{
264
-		// If we have a sort key we do not rewrite the URL
265
-		$query = str_replace('&', '&', parse_url($event['base_url'], PHP_URL_QUERY));
266
-		parse_str($query, $param);
267
-		if (isset($param['sd']) || isset($param['sk']) || isset($param['st']))
268
-		{
269
-			return;
270
-		}
271
-
272
-		$start = (($event['on_page'] - 1) * $event['per_page']);
273
-		if (!empty($this->topic_data) && isset($param['f']) && isset($param['t']))
274
-		{
275
-			$event['generate_page_link_override'] = append_sid($this->base->generate_topic_link($this->topic_data['forum_id'], $this->topic_data['forum_name'], $this->topic_data['topic_id'], $this->topic_data['topic_title'], $start));
276
-		}
277
-		else if (!empty($this->forum_data) && isset($param['f']))
278
-		{
279
-			$event['generate_page_link_override'] = append_sid($this->base->generate_forum_link($this->forum_data['forum_id'], $this->forum_data['forum_name'], $start));
280
-		}
281
-	}
282
-
283
-	/**
284
-	 * Rewrite links in the search result
285
-	 *
286
-	 * @param	object	$event	The event object
287
-	 * @return	null
288
-	 * @access	public
289
-	 */
290
-	public function search_modify_tpl_ary($event)
291
-	{
292
-		$replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1;
293
-		$u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']);
294
-
295
-		$tpl_ary = $event['tpl_ary'];
296
-		$tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']);
297
-		$tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic);
298
-		$tpl_ary['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name']));
299
-		$tpl_ary['U_NEWEST_POST'] = $u_view_topic . '?view=unread#unread';
300
-
301
-		$event['tpl_ary'] = $tpl_ary;
302
-	}
303
-
304
-	/**
305
-	 * Rewrite links to topics in forum view
306
-	 *
307
-	 * @param	object	$event	The event object
308
-	 * @return	null
309
-	 * @access	public
310
-	 */
311
-	public function viewforum_modify_topicrow($event)
312
-	{
313
-		// assign to be used in pagination_generate_page_link
314
-		$this->topic_data = array(
315
-			'forum_id' => $event['topic_row']['FORUM_ID'],
316
-			'forum_name' => $event['topic_row']['FORUM_NAME'],
317
-			'topic_id' => $event['topic_row']['TOPIC_ID'],
318
-			'topic_title' => $event['topic_row']['TOPIC_TITLE']
319
-		);
320
-
321
-		$topic_row = $event['topic_row'];
322
-
323
-		$u_view_topic = $this->base->generate_topic_link($topic_row['FORUM_ID'], $topic_row['FORUM_NAME'], $topic_row['TOPIC_ID'], $topic_row['TOPIC_TITLE']);
324
-		$topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic);
325
-		$topic_row['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($topic_row['FORUM_ID'], $topic_row['FORUM_NAME']));
326
-		$topic_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($event['topic_row']['REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']);
327
-		$topic_row['U_NEWEST_POST'] = $u_view_topic . '?view=unread#unread';
328
-
329
-		$event['topic_row'] = $topic_row;
330
-	}
331
-
332
-	/**
333
-	 * Rewrite the canonical URL on viewforum.php
334
-	 *
335
-	 * @param	object	$event	The event object
336
-	 * @return	null
337
-	 * @access	public
338
-	 */
339
-	public function viewforum_get_topic_data($event)
340
-	{
341
-		// assign to be used in pagination_generate_page_link
342
-		$this->forum_data = array(
343
-			'forum_id' => $event['forum_data']['forum_id'],
344
-			'forum_name' => $event['forum_data']['forum_name']
345
-		);
346
-
347
-		$start = $this->request->variable('start', 0);
348
-		$this->template->assign_vars(array(
349
-			'U_VIEW_FORUM'		=> append_sid($this->base->generate_forum_link($event['forum_data']['forum_id'], $event['forum_data']['forum_name'], $start)),
350
-			'U_CANONICAL'		=> $this->base->generate_forum_link($event['forum_data']['forum_id'], $event['forum_data']['forum_name'], $start, true),
351
-		));
352
-	}
353
-
354
-	/**
355
-	 * Rewrite the topic URL for the headline of the topic page and the link back to forum
356
-	 *
357
-	 * @param	object	$event	The event object
358
-	 * @return	null
359
-	 * @access	public
360
-	 */
361
-	public function viewtopic_get_post_data($event)
362
-	{
363
-		$data = $event['topic_data'];
364
-		$this->template->assign_vars(array(
365
-			'U_VIEW_TOPIC'		=> append_sid($this->base->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])),
366
-			'U_VIEW_FORUM'		=> append_sid($this->base->generate_forum_link($event['forum_id'] , $data['forum_name'])),
367
-			'S_POLL_ACTION'		=> append_sid($this->base->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])),
368
-		));
369
-	}
370
-
371
-	/**
372
-	 * Assign topic data to global variables for pagination
373
-	 *
374
-	 * @param	object	$event	The event object
375
-	 * @return	null
376
-	 * @access	public
377
-	 */
378
-	public function viewtopic_assign_template_vars_before($event)
379
-	{
380
-		// assign to be used in pagination_generate_page_link
381
-		$this->topic_data = array(
382
-			'forum_id' => $event['topic_data']['forum_id'],
383
-			'forum_name' => $event['topic_data']['forum_name'],
384
-			'topic_id' => $event['topic_data']['topic_id'],
385
-			'topic_title' => $event['topic_data']['topic_title']
386
-		);
387
-	}
388
-
389
-	public function viewtopic_before_f_read_check()
390
-	{
391
-		$this->in_viewtopic = true;
392
-	}
393
-
394
-	/**
395
-	 * Rewrite the canonical URL on viewtopic.php
396
-	 *
397
-	 * @param	object	$event	The event object
398
-	 * @return	null
399
-	 * @access	public
400
-	 */
401
-	public function viewtopic_modify_page_title($event)
402
-	{
403
-		$start = $this->request->variable('start', 0);
404
-		$data = $event['topic_data'];
405
-		$this->template->assign_vars(array(
406
-			'U_CANONICAL'		=> $this->base->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start, true),
407
-		));
408
-	}
409
-
410
-	/**
411
-	 * Rewrite mini post img link
412
-	 *
413
-	 * @param	object	$event	The event object
414
-	 * @return	null
415
-	 * @access	public
416
-	 */
417
-	public function viewtopic_modify_post_row($event)
418
-	{
419
-		$row = $event['post_row'];
420
-		$start = $this->request->variable('start', 0);
421
-		$data = $event['topic_data'];
422
-		$row['U_MINI_POST'] = append_sid($this->base->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start) . '#p' . $event['row']['post_id']);
423
-		$event['post_row'] = $row;
424
-	}
19
+    /** @var \tas2580\seourls\event\base */
20
+    protected $base;
21
+
22
+    /** @var \phpbb\template\template */
23
+    protected $template;
24
+
25
+    /** @var \phpbb\request\request */
26
+    protected $request;
27
+
28
+    /** @var \phpbb\path_helper */
29
+    protected $path_helper;
30
+
31
+    /** @var string phpbb_root_path */
32
+    protected $phpbb_root_path;
33
+
34
+    /** @var string php_ext */
35
+    protected $php_ext;
36
+
37
+    private $in_viewforum;
38
+
39
+    /**
40
+     * Constructor
41
+     *
42
+     * @param \tas2580\seourls\event\base	$base
43
+     * @param \phpbb\template\template		$template				Template object
44
+     * @param \phpbb\request\request		$request				Request object
45
+     * @param \phpbb\path_helper			$path_helper			Controller helper object
46
+     * @param string						$phpbb_root_path		phpbb_root_path
47
+     * @param string						$php_ext				php_ext
48
+     * @access public
49
+     */
50
+    public function __construct(\tas2580\seourls\event\base $base, \phpbb\template\template $template, \phpbb\request\request $request, \phpbb\path_helper $path_helper, $phpbb_root_path, $php_ext)
51
+    {
52
+        $this->base = $base;
53
+        $this->template = $template;
54
+        $this->request = $request;
55
+        $this->path_helper = $path_helper;
56
+        $this->phpbb_root_path = $phpbb_root_path;
57
+        $this->php_ext = $php_ext;
58
+
59
+        $this->in_viewtopic = false;
60
+    }
61
+
62
+    /**
63
+     * Assign functions defined in this class to event listeners in the core
64
+     *
65
+     * @return array
66
+     * @static
67
+     * @access public
68
+     */
69
+    public static function getSubscribedEvents()
70
+    {
71
+        return array(
72
+            'core.append_sid'										=> 'append_sid',
73
+            'core.display_forums_modify_sql'						=> 'display_forums_modify_sql',
74
+            'core.display_forums_modify_template_vars'				=> 'display_forums_modify_template_vars',
75
+            'core.display_forums_modify_forum_rows'					=> 'display_forums_modify_forum_rows',
76
+            'core.display_forums_modify_category_template_vars'		=> 'display_forums_modify_category_template_vars',
77
+            'core.generate_forum_nav'								=> 'generate_forum_nav',
78
+            'core.make_jumpbox_modify_tpl_ary'						=> 'make_jumpbox_modify_tpl_ary',				// Not in phpBB
79
+            'core.memberlist_view_profile'							=> 'memberlist_view_profile',
80
+            'core.pagination_generate_page_link'					=> 'pagination_generate_page_link',
81
+            'core.search_modify_tpl_ary'							=> 'search_modify_tpl_ary',
82
+            'core.viewforum_modify_topicrow'						=> 'viewforum_modify_topicrow',
83
+            'core.viewforum_get_topic_data'							=> 'viewforum_get_topic_data',
84
+            'core.viewtopic_assign_template_vars_before'			=> 'viewtopic_assign_template_vars_before',
85
+            'core.viewtopic_before_f_read_check'					=> 'viewtopic_before_f_read_check',
86
+            'core.viewtopic_modify_page_title'						=> 'viewtopic_modify_page_title',
87
+            'core.viewtopic_modify_post_row'						=> 'viewtopic_modify_post_row',
88
+            'core.viewtopic_get_post_data'							=> 'viewtopic_get_post_data',
89
+        );
90
+    }
91
+
92
+    /**
93
+     * Correct the path of $viewtopic_url
94
+     *
95
+     * @param	object	$event	The event object
96
+     * @return	null
97
+     * @access	public
98
+     */
99
+    public function append_sid($event)
100
+    {
101
+        if ($this->in_viewtopic && preg_match('#./../viewtopic.' . $this->php_ext  . '#', $event['url']))
102
+        {
103
+            $url = '../viewtopic.' . $this->php_ext ;
104
+            $event['url'] = $url;
105
+        }
106
+        if (isset($event['params']['redirect']))
107
+        {
108
+            $params = $event['params'];
109
+            $params['redirect'] = str_replace('..', '.', $event['params']['redirect']);
110
+            $event['params'] = $params;
111
+        }
112
+    }
113
+
114
+    /**
115
+     * Get informations for the last post from Database
116
+     *
117
+     * @param	object	$event	The event object
118
+     * @return	null
119
+     * @access	public
120
+     */
121
+    public function display_forums_modify_sql($event)
122
+    {
123
+        $sql_array = $event['sql_ary'];
124
+        $sql_array['LEFT_JOIN'][] = array(
125
+            'FROM' => array(TOPICS_TABLE => 't'),
126
+            'ON' => "f.forum_last_post_id = t.topic_last_post_id"
127
+        );
128
+        $sql_array['SELECT'] .= ', t.topic_title, t.topic_id, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted';
129
+        $event['sql_ary'] = $sql_array;
130
+    }
131
+
132
+    /**
133
+     * Store informations for the last post in forum_rows array
134
+     *
135
+     * @param	object	$event	The event object
136
+     * @return	null
137
+     * @access	public
138
+     */
139
+    public function display_forums_modify_forum_rows($event)
140
+    {
141
+        $forum_rows = $event['forum_rows'];
142
+        if ($event['row']['forum_last_post_time'] == $forum_rows[$event['parent_id']]['forum_last_post_time'])
143
+        {
144
+            $forum_rows[$event['parent_id']]['forum_name_last_post'] =$event['row']['forum_name'];
145
+            $forum_rows[$event['parent_id']]['topic_id_last_post'] =$event['row']['topic_id'];
146
+            $forum_rows[$event['parent_id']]['topic_title_last_post'] =$event['row']['topic_title'];
147
+            $event['forum_rows'] = $forum_rows;
148
+        }
149
+    }
150
+
151
+    /**
152
+     * Rewrite links to forums and subforums in forum index
153
+     * also correct the path of the forum images if we are in a forum
154
+     *
155
+     * @param	object	$event	The event object
156
+     * @return	null
157
+     * @access	public
158
+     */
159
+    public function display_forums_modify_template_vars($event)
160
+    {
161
+        $subforums_row = $event['subforums_row'];
162
+        $forum_row = $event['forum_row'];
163
+
164
+        // Rewrite URLs of sub forums
165
+        foreach ($subforums_row as $i => $subforum)
166
+        {
167
+            // A little bit a dirty way, but there is no better solution
168
+            $query = str_replace('&', '&', parse_url($subforum['U_SUBFORUM'], PHP_URL_QUERY));
169
+            parse_str($query, $id);
170
+            $subforums_row[$i]['U_SUBFORUM'] = append_sid($this->base->generate_forum_link($id['f'], $subforum['SUBFORUM_NAME']));
171
+        }
172
+
173
+        // Update the image source in forums
174
+        $img = $this->path_helper->update_web_root_path($forum_row['FORUM_IMAGE_SRC']);
175
+        $forum_row['FORUM_IMAGE'] = preg_replace('#img src=\"(.*)\" alt#', 'img src="' . $img . '" alt', $forum_row['FORUM_IMAGE']);
176
+
177
+        // Rewrite links to topics, posts and forums
178
+        $replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1;
179
+        $url = $this->base->generate_topic_link($event['row']['forum_id_last_post'], $event['row']['forum_name_last_post'], $event['row']['topic_id_last_post'], $event['row']['topic_title_last_post']);
180
+        $forum_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $url) . '#p' . $event['row']['forum_last_post_id']);
181
+        $forum_row['U_VIEWFORUM'] = append_sid($this->base->generate_forum_link($forum_row['FORUM_ID'], $forum_row['FORUM_NAME']));
182
+        $forum_row['U_NEWEST_POST'] = $url . '?view=unread#unread';
183
+
184
+        $event['subforums_row'] = $subforums_row;
185
+        $event['forum_row'] = $forum_row;
186
+    }
187
+
188
+    /**
189
+     * Rewrite the categorie links
190
+     *
191
+     * @param	object	$event	The event object
192
+     * @return	null
193
+     * @access	public
194
+     */
195
+    public function display_forums_modify_category_template_vars($event)
196
+    {
197
+        $cat_row = $event['cat_row'];
198
+        $row = $event['row'];
199
+        $cat_row['U_VIEWFORUM'] = append_sid($this->base->generate_forum_link($row['forum_id'], $row['forum_name']));
200
+        $event['cat_row'] = $cat_row;
201
+    }
202
+
203
+    /**
204
+     * Rewrite links in breadcrumbs
205
+     *
206
+     * @param	object	$event	The event object
207
+     * @return	null
208
+     * @access	public
209
+     */
210
+    public function generate_forum_nav($event)
211
+    {
212
+        $forum_data = $event['forum_data'];
213
+        $navlinks = $event['navlinks'];
214
+        $navlinks_parents = $event['navlinks_parents'];
215
+
216
+        foreach ($navlinks_parents as $id => $data)
217
+        {
218
+            $navlinks_parents[$id]['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($data['FORUM_ID'] , $data['FORUM_NAME']));
219
+        }
220
+
221
+        $navlinks['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($forum_data['forum_id'], $forum_data['forum_name']));
222
+        $event['navlinks'] = $navlinks;
223
+        $event['navlinks_parents'] = $navlinks_parents;
224
+    }
225
+
226
+    // Not in phpBB
227
+    public function make_jumpbox_modify_tpl_ary($event)
228
+    {
229
+        $tpl_ary = $event['tpl_ary'];
230
+        $row = $event['row'];
231
+        foreach ($tpl_ary as $id => $data)
232
+        {
233
+            $tpl_ary[$id]['LINK']	 = append_sid($this->base->generate_forum_link($row['forum_id'], $row['forum_name']));
234
+        }
235
+
236
+        $event['tpl_ary'] = $tpl_ary;
237
+    }
238
+
239
+    /**
240
+     * Rewrite links to most active forum and topic on profile page
241
+     *
242
+     * @param	object	$event	The event object
243
+     * @return	null
244
+     * @access	public
245
+     */
246
+    public function memberlist_view_profile($event)
247
+    {
248
+        $data = $event['member'];
249
+        $this->template->assign_vars(array(
250
+            'U_ACTIVE_FORUM' => $this->base->generate_forum_link($data['active_f_row']['forum_id'], $data['active_f_row']['forum_name'], 0, true),
251
+            'U_ACTIVE_TOPIC' => $this->base->generate_topic_link($data['active_f_row']['forum_id'], $data['active_f_row']['forum_name'], $data['active_t_row']['topic_id'], $data['active_t_row']['topic_title'], 0, true),
252
+        ));
253
+    }
254
+
255
+    /**
256
+     * Rewrite pagination links
257
+     *
258
+     * @param	object	$event	The event object
259
+     * @return	null
260
+     * @access	public
261
+     */
262
+    public function pagination_generate_page_link($event)
263
+    {
264
+        // If we have a sort key we do not rewrite the URL
265
+        $query = str_replace('&', '&', parse_url($event['base_url'], PHP_URL_QUERY));
266
+        parse_str($query, $param);
267
+        if (isset($param['sd']) || isset($param['sk']) || isset($param['st']))
268
+        {
269
+            return;
270
+        }
271
+
272
+        $start = (($event['on_page'] - 1) * $event['per_page']);
273
+        if (!empty($this->topic_data) && isset($param['f']) && isset($param['t']))
274
+        {
275
+            $event['generate_page_link_override'] = append_sid($this->base->generate_topic_link($this->topic_data['forum_id'], $this->topic_data['forum_name'], $this->topic_data['topic_id'], $this->topic_data['topic_title'], $start));
276
+        }
277
+        else if (!empty($this->forum_data) && isset($param['f']))
278
+        {
279
+            $event['generate_page_link_override'] = append_sid($this->base->generate_forum_link($this->forum_data['forum_id'], $this->forum_data['forum_name'], $start));
280
+        }
281
+    }
282
+
283
+    /**
284
+     * Rewrite links in the search result
285
+     *
286
+     * @param	object	$event	The event object
287
+     * @return	null
288
+     * @access	public
289
+     */
290
+    public function search_modify_tpl_ary($event)
291
+    {
292
+        $replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1;
293
+        $u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']);
294
+
295
+        $tpl_ary = $event['tpl_ary'];
296
+        $tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']);
297
+        $tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic);
298
+        $tpl_ary['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name']));
299
+        $tpl_ary['U_NEWEST_POST'] = $u_view_topic . '?view=unread#unread';
300
+
301
+        $event['tpl_ary'] = $tpl_ary;
302
+    }
303
+
304
+    /**
305
+     * Rewrite links to topics in forum view
306
+     *
307
+     * @param	object	$event	The event object
308
+     * @return	null
309
+     * @access	public
310
+     */
311
+    public function viewforum_modify_topicrow($event)
312
+    {
313
+        // assign to be used in pagination_generate_page_link
314
+        $this->topic_data = array(
315
+            'forum_id' => $event['topic_row']['FORUM_ID'],
316
+            'forum_name' => $event['topic_row']['FORUM_NAME'],
317
+            'topic_id' => $event['topic_row']['TOPIC_ID'],
318
+            'topic_title' => $event['topic_row']['TOPIC_TITLE']
319
+        );
320
+
321
+        $topic_row = $event['topic_row'];
322
+
323
+        $u_view_topic = $this->base->generate_topic_link($topic_row['FORUM_ID'], $topic_row['FORUM_NAME'], $topic_row['TOPIC_ID'], $topic_row['TOPIC_TITLE']);
324
+        $topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic);
325
+        $topic_row['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($topic_row['FORUM_ID'], $topic_row['FORUM_NAME']));
326
+        $topic_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($event['topic_row']['REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']);
327
+        $topic_row['U_NEWEST_POST'] = $u_view_topic . '?view=unread#unread';
328
+
329
+        $event['topic_row'] = $topic_row;
330
+    }
331
+
332
+    /**
333
+     * Rewrite the canonical URL on viewforum.php
334
+     *
335
+     * @param	object	$event	The event object
336
+     * @return	null
337
+     * @access	public
338
+     */
339
+    public function viewforum_get_topic_data($event)
340
+    {
341
+        // assign to be used in pagination_generate_page_link
342
+        $this->forum_data = array(
343
+            'forum_id' => $event['forum_data']['forum_id'],
344
+            'forum_name' => $event['forum_data']['forum_name']
345
+        );
346
+
347
+        $start = $this->request->variable('start', 0);
348
+        $this->template->assign_vars(array(
349
+            'U_VIEW_FORUM'		=> append_sid($this->base->generate_forum_link($event['forum_data']['forum_id'], $event['forum_data']['forum_name'], $start)),
350
+            'U_CANONICAL'		=> $this->base->generate_forum_link($event['forum_data']['forum_id'], $event['forum_data']['forum_name'], $start, true),
351
+        ));
352
+    }
353
+
354
+    /**
355
+     * Rewrite the topic URL for the headline of the topic page and the link back to forum
356
+     *
357
+     * @param	object	$event	The event object
358
+     * @return	null
359
+     * @access	public
360
+     */
361
+    public function viewtopic_get_post_data($event)
362
+    {
363
+        $data = $event['topic_data'];
364
+        $this->template->assign_vars(array(
365
+            'U_VIEW_TOPIC'		=> append_sid($this->base->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])),
366
+            'U_VIEW_FORUM'		=> append_sid($this->base->generate_forum_link($event['forum_id'] , $data['forum_name'])),
367
+            'S_POLL_ACTION'		=> append_sid($this->base->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])),
368
+        ));
369
+    }
370
+
371
+    /**
372
+     * Assign topic data to global variables for pagination
373
+     *
374
+     * @param	object	$event	The event object
375
+     * @return	null
376
+     * @access	public
377
+     */
378
+    public function viewtopic_assign_template_vars_before($event)
379
+    {
380
+        // assign to be used in pagination_generate_page_link
381
+        $this->topic_data = array(
382
+            'forum_id' => $event['topic_data']['forum_id'],
383
+            'forum_name' => $event['topic_data']['forum_name'],
384
+            'topic_id' => $event['topic_data']['topic_id'],
385
+            'topic_title' => $event['topic_data']['topic_title']
386
+        );
387
+    }
388
+
389
+    public function viewtopic_before_f_read_check()
390
+    {
391
+        $this->in_viewtopic = true;
392
+    }
393
+
394
+    /**
395
+     * Rewrite the canonical URL on viewtopic.php
396
+     *
397
+     * @param	object	$event	The event object
398
+     * @return	null
399
+     * @access	public
400
+     */
401
+    public function viewtopic_modify_page_title($event)
402
+    {
403
+        $start = $this->request->variable('start', 0);
404
+        $data = $event['topic_data'];
405
+        $this->template->assign_vars(array(
406
+            'U_CANONICAL'		=> $this->base->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start, true),
407
+        ));
408
+    }
409
+
410
+    /**
411
+     * Rewrite mini post img link
412
+     *
413
+     * @param	object	$event	The event object
414
+     * @return	null
415
+     * @access	public
416
+     */
417
+    public function viewtopic_modify_post_row($event)
418
+    {
419
+        $row = $event['post_row'];
420
+        $start = $this->request->variable('start', 0);
421
+        $data = $event['topic_data'];
422
+        $row['U_MINI_POST'] = append_sid($this->base->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start) . '#p' . $event['row']['post_id']);
423
+        $event['post_row'] = $row;
424
+    }
425 425
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 			'core.display_forums_modify_forum_rows'					=> 'display_forums_modify_forum_rows',
76 76
 			'core.display_forums_modify_category_template_vars'		=> 'display_forums_modify_category_template_vars',
77 77
 			'core.generate_forum_nav'								=> 'generate_forum_nav',
78
-			'core.make_jumpbox_modify_tpl_ary'						=> 'make_jumpbox_modify_tpl_ary',				// Not in phpBB
78
+			'core.make_jumpbox_modify_tpl_ary'						=> 'make_jumpbox_modify_tpl_ary', // Not in phpBB
79 79
 			'core.memberlist_view_profile'							=> 'memberlist_view_profile',
80 80
 			'core.pagination_generate_page_link'					=> 'pagination_generate_page_link',
81 81
 			'core.search_modify_tpl_ary'							=> 'search_modify_tpl_ary',
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	public function append_sid($event)
100 100
 	{
101
-		if ($this->in_viewtopic && preg_match('#./../viewtopic.' . $this->php_ext  . '#', $event['url']))
101
+		if ($this->in_viewtopic && preg_match('#./../viewtopic.'.$this->php_ext.'#', $event['url']))
102 102
 		{
103
-			$url = '../viewtopic.' . $this->php_ext ;
103
+			$url = '../viewtopic.'.$this->php_ext;
104 104
 			$event['url'] = $url;
105 105
 		}
106 106
 		if (isset($event['params']['redirect']))
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 		$forum_rows = $event['forum_rows'];
142 142
 		if ($event['row']['forum_last_post_time'] == $forum_rows[$event['parent_id']]['forum_last_post_time'])
143 143
 		{
144
-			$forum_rows[$event['parent_id']]['forum_name_last_post'] =$event['row']['forum_name'];
145
-			$forum_rows[$event['parent_id']]['topic_id_last_post'] =$event['row']['topic_id'];
146
-			$forum_rows[$event['parent_id']]['topic_title_last_post'] =$event['row']['topic_title'];
144
+			$forum_rows[$event['parent_id']]['forum_name_last_post'] = $event['row']['forum_name'];
145
+			$forum_rows[$event['parent_id']]['topic_id_last_post'] = $event['row']['topic_id'];
146
+			$forum_rows[$event['parent_id']]['topic_title_last_post'] = $event['row']['topic_title'];
147 147
 			$event['forum_rows'] = $forum_rows;
148 148
 		}
149 149
 	}
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 
173 173
 		// Update the image source in forums
174 174
 		$img = $this->path_helper->update_web_root_path($forum_row['FORUM_IMAGE_SRC']);
175
-		$forum_row['FORUM_IMAGE'] = preg_replace('#img src=\"(.*)\" alt#', 'img src="' . $img . '" alt', $forum_row['FORUM_IMAGE']);
175
+		$forum_row['FORUM_IMAGE'] = preg_replace('#img src=\"(.*)\" alt#', 'img src="'.$img.'" alt', $forum_row['FORUM_IMAGE']);
176 176
 
177 177
 		// Rewrite links to topics, posts and forums
178 178
 		$replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1;
179 179
 		$url = $this->base->generate_topic_link($event['row']['forum_id_last_post'], $event['row']['forum_name_last_post'], $event['row']['topic_id_last_post'], $event['row']['topic_title_last_post']);
180
-		$forum_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $url) . '#p' . $event['row']['forum_last_post_id']);
180
+		$forum_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $url).'#p'.$event['row']['forum_last_post_id']);
181 181
 		$forum_row['U_VIEWFORUM'] = append_sid($this->base->generate_forum_link($forum_row['FORUM_ID'], $forum_row['FORUM_NAME']));
182
-		$forum_row['U_NEWEST_POST'] = $url . '?view=unread#unread';
182
+		$forum_row['U_NEWEST_POST'] = $url.'?view=unread#unread';
183 183
 
184 184
 		$event['subforums_row'] = $subforums_row;
185 185
 		$event['forum_row'] = $forum_row;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
 		foreach ($navlinks_parents as $id => $data)
217 217
 		{
218
-			$navlinks_parents[$id]['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($data['FORUM_ID'] , $data['FORUM_NAME']));
218
+			$navlinks_parents[$id]['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($data['FORUM_ID'], $data['FORUM_NAME']));
219 219
 		}
220 220
 
221 221
 		$navlinks['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($forum_data['forum_id'], $forum_data['forum_name']));
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 		$row = $event['row'];
231 231
 		foreach ($tpl_ary as $id => $data)
232 232
 		{
233
-			$tpl_ary[$id]['LINK']	 = append_sid($this->base->generate_forum_link($row['forum_id'], $row['forum_name']));
233
+			$tpl_ary[$id]['LINK'] = append_sid($this->base->generate_forum_link($row['forum_id'], $row['forum_name']));
234 234
 		}
235 235
 
236 236
 		$event['tpl_ary'] = $tpl_ary;
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 		$u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']);
294 294
 
295 295
 		$tpl_ary = $event['tpl_ary'];
296
-		$tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']);
296
+		$tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic).'#p'.$event['row']['topic_last_post_id']);
297 297
 		$tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic);
298 298
 		$tpl_ary['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name']));
299
-		$tpl_ary['U_NEWEST_POST'] = $u_view_topic . '?view=unread#unread';
299
+		$tpl_ary['U_NEWEST_POST'] = $u_view_topic.'?view=unread#unread';
300 300
 
301 301
 		$event['tpl_ary'] = $tpl_ary;
302 302
 	}
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
 		$u_view_topic = $this->base->generate_topic_link($topic_row['FORUM_ID'], $topic_row['FORUM_NAME'], $topic_row['TOPIC_ID'], $topic_row['TOPIC_TITLE']);
324 324
 		$topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic);
325 325
 		$topic_row['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($topic_row['FORUM_ID'], $topic_row['FORUM_NAME']));
326
-		$topic_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($event['topic_row']['REPLIES'], $u_view_topic) . '#p' . $event['row']['topic_last_post_id']);
327
-		$topic_row['U_NEWEST_POST'] = $u_view_topic . '?view=unread#unread';
326
+		$topic_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($event['topic_row']['REPLIES'], $u_view_topic).'#p'.$event['row']['topic_last_post_id']);
327
+		$topic_row['U_NEWEST_POST'] = $u_view_topic.'?view=unread#unread';
328 328
 
329 329
 		$event['topic_row'] = $topic_row;
330 330
 	}
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 	{
363 363
 		$data = $event['topic_data'];
364 364
 		$this->template->assign_vars(array(
365
-			'U_VIEW_TOPIC'		=> append_sid($this->base->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])),
366
-			'U_VIEW_FORUM'		=> append_sid($this->base->generate_forum_link($event['forum_id'] , $data['forum_name'])),
367
-			'S_POLL_ACTION'		=> append_sid($this->base->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])),
365
+			'U_VIEW_TOPIC'		=> append_sid($this->base->generate_topic_link($event['forum_id'], $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])),
366
+			'U_VIEW_FORUM'		=> append_sid($this->base->generate_forum_link($event['forum_id'], $data['forum_name'])),
367
+			'S_POLL_ACTION'		=> append_sid($this->base->generate_topic_link($event['forum_id'], $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])),
368 368
 		));
369 369
 	}
370 370
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 		$row = $event['post_row'];
420 420
 		$start = $this->request->variable('start', 0);
421 421
 		$data = $event['topic_data'];
422
-		$row['U_MINI_POST'] = append_sid($this->base->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start) . '#p' . $event['row']['post_id']);
422
+		$row['U_MINI_POST'] = append_sid($this->base->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start).'#p'.$event['row']['post_id']);
423 423
 		$event['post_row'] = $row;
424 424
 	}
425 425
 }
Please login to merge, or discard this patch.