Completed
Push — master ( 987ed7...df4c3b )
by Tobias
02:41
created
event/base.php 3 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 	{
56 56
 		if ($full)
57 57
 		{
58
-			return generate_board_url() . '/' . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . $this->title_to_url($topic_title) . '-t' . $topic_id . ($start ? '-s' . $start : '') . '.html';
58
+			return generate_board_url().'/'.$this->title_to_url($forum_name).'-f'.$forum_id.'/'.$this->title_to_url($topic_title).'-t'.$topic_id.($start ? '-s'.$start : '').'.html';
59 59
 		}
60
-		return $this->phpbb_root_path . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . $this->title_to_url($topic_title) . '-t' . $topic_id . ($start ? '-s' . $start : '') . '.html';
60
+		return $this->phpbb_root_path.$this->title_to_url($forum_name).'-f'.$forum_id.'/'.$this->title_to_url($topic_title).'-t'.$topic_id.($start ? '-s'.$start : '').'.html';
61 61
 	}
62 62
 
63 63
 	/**
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	{
75 75
 		if ($full)
76 76
 		{
77
-			return generate_board_url() . '/' . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . ($start ? 'index-s' . $start . '.html' : '');
77
+			return generate_board_url().'/'.$this->title_to_url($forum_name).'-f'.$forum_id.'/'.($start ? 'index-s'.$start.'.html' : '');
78 78
 		}
79
-		return $this->phpbb_root_path . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . ($start ? 'index-s' . $start . '.html' : '');
79
+		return $this->phpbb_root_path.$this->title_to_url($forum_name).'-f'.$forum_id.'/'.($start ? 'index-s'.$start.'.html' : '');
80 80
 	}
81 81
 
82 82
 	/**
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 		{
96 96
 			for ($j = 0; $j < $replies + 1; $j += $per_page)
97 97
 			{
98
-				$last_post_link = $url . '-s' . $j . '.html';
98
+				$last_post_link = $url.'-s'.$j.'.html';
99 99
 			}
100 100
 		}
101 101
 		else
102 102
 		{
103
-			$last_post_link = $url . '.html';
103
+			$last_post_link = $url.'.html';
104 104
 		}
105 105
 		return $last_post_link;
106 106
 	}
@@ -139,9 +139,9 @@  discard block
 block discarded – undo
139 139
 	{
140 140
 		if (!$this->auth->acl_get('m_approve', $forum_id))
141 141
 		{
142
-			return (int) $data[$mode . '_approved'];
142
+			return (int) $data[$mode.'_approved'];
143 143
 		}
144 144
 
145
-		return (int) $data[$mode . '_approved'] + (int) $data[$mode . '_unapproved'] + (int) $data[$mode . '_softdeleted'];
145
+		return (int) $data[$mode.'_approved'] + (int) $data[$mode.'_unapproved'] + (int) $data[$mode.'_softdeleted'];
146 146
 	}
147 147
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -97,8 +97,7 @@
 block discarded – undo
97 97
 			{
98 98
 				$last_post_link = $url . '-s' . $j . '.html';
99 99
 			}
100
-		}
101
-		else
100
+		} else
102 101
 		{
103 102
 			$last_post_link = $url . '.html';
104 103
 		}
Please login to merge, or discard this patch.
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -15,133 +15,133 @@
 block discarded – undo
15 15
 class base
16 16
 {
17 17
 
18
-	/** @var \phpbb\auth\auth */
19
-	protected $auth;
18
+    /** @var \phpbb\auth\auth */
19
+    protected $auth;
20 20
 
21
-	/** @var \phpbb\config\config */
22
-	protected $config;
21
+    /** @var \phpbb\config\config */
22
+    protected $config;
23 23
 
24
-	/** @var string phpbb_root_path */
25
-	protected $phpbb_root_path;
24
+    /** @var string phpbb_root_path */
25
+    protected $phpbb_root_path;
26 26
 
27
-	/**
28
-	 * Constructor
29
-	 *
30
-	 * @param \phpbb\auth\auth				auth					Authentication object
31
-	 * @param \phpbb\config\config			$config					Config Object
32
-	 * @param string						$phpbb_root_path		phpbb_root_path
33
-	 * @access public
34
-	 */
35
-	public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, $phpbb_root_path)
36
-	{
37
-		$this->auth = $auth;
38
-		$this->config = $config;
39
-		$this->phpbb_root_path = $phpbb_root_path;
40
-	}
27
+    /**
28
+     * Constructor
29
+     *
30
+     * @param \phpbb\auth\auth				auth					Authentication object
31
+     * @param \phpbb\config\config			$config					Config Object
32
+     * @param string						$phpbb_root_path		phpbb_root_path
33
+     * @access public
34
+     */
35
+    public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, $phpbb_root_path)
36
+    {
37
+        $this->auth = $auth;
38
+        $this->config = $config;
39
+        $this->phpbb_root_path = $phpbb_root_path;
40
+    }
41 41
 
42
-	/**
43
-	 * Generate the SEO link for a topic
44
-	 *
45
-	 * @param	int		$forum_id		The ID of the forum
46
-	 * @param	string	$forum_name		The title of the forum
47
-	 * @param	int		$topic_id		The ID if the topic
48
-	 * @param	string	$topic_title	The title of the topic
49
-	 * @param	int		$start			Optional start parameter
50
-	 * @param	bool	$full			Return the full URL
51
-	 * @return	string	The SEO URL
52
-	 * @access private
53
-	 */
54
-	public function generate_topic_link($forum_id, $forum_name, $topic_id, $topic_title, $start = 0, $full = false)
55
-	{
56
-		if ($full)
57
-		{
58
-			return generate_board_url() . '/' . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . $this->title_to_url($topic_title) . '-t' . $topic_id . ($start ? '-s' . $start : '') . '.html';
59
-		}
60
-		return $this->phpbb_root_path . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . $this->title_to_url($topic_title) . '-t' . $topic_id . ($start ? '-s' . $start : '') . '.html';
61
-	}
42
+    /**
43
+     * Generate the SEO link for a topic
44
+     *
45
+     * @param	int		$forum_id		The ID of the forum
46
+     * @param	string	$forum_name		The title of the forum
47
+     * @param	int		$topic_id		The ID if the topic
48
+     * @param	string	$topic_title	The title of the topic
49
+     * @param	int		$start			Optional start parameter
50
+     * @param	bool	$full			Return the full URL
51
+     * @return	string	The SEO URL
52
+     * @access private
53
+     */
54
+    public function generate_topic_link($forum_id, $forum_name, $topic_id, $topic_title, $start = 0, $full = false)
55
+    {
56
+        if ($full)
57
+        {
58
+            return generate_board_url() . '/' . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . $this->title_to_url($topic_title) . '-t' . $topic_id . ($start ? '-s' . $start : '') . '.html';
59
+        }
60
+        return $this->phpbb_root_path . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . $this->title_to_url($topic_title) . '-t' . $topic_id . ($start ? '-s' . $start : '') . '.html';
61
+    }
62 62
 
63
-	/**
64
-	 * Generate the SEO link for a forum
65
-	 *
66
-	 * @param	int		$forum_id		The ID of the forum
67
-	 * @param	string	$forum_name		The title of the forum
68
-	 * @param	int		$start			Optional start parameter
69
-	 * @param	bool	$full			Return the full URL
70
-	 * @return	string	The SEO URL
71
-	 * @access private
72
-	 */
73
-	public function generate_forum_link($forum_id, $forum_name, $start = 0, $full = false)
74
-	{
75
-		if ($full)
76
-		{
77
-			return generate_board_url() . '/' . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . ($start ? 'index-s' . $start . '.html' : '');
78
-		}
79
-		return $this->phpbb_root_path . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . ($start ? 'index-s' . $start . '.html' : '');
80
-	}
63
+    /**
64
+     * Generate the SEO link for a forum
65
+     *
66
+     * @param	int		$forum_id		The ID of the forum
67
+     * @param	string	$forum_name		The title of the forum
68
+     * @param	int		$start			Optional start parameter
69
+     * @param	bool	$full			Return the full URL
70
+     * @return	string	The SEO URL
71
+     * @access private
72
+     */
73
+    public function generate_forum_link($forum_id, $forum_name, $start = 0, $full = false)
74
+    {
75
+        if ($full)
76
+        {
77
+            return generate_board_url() . '/' . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . ($start ? 'index-s' . $start . '.html' : '');
78
+        }
79
+        return $this->phpbb_root_path . $this->title_to_url($forum_name) . '-f' . $forum_id . '/' . ($start ? 'index-s' . $start . '.html' : '');
80
+    }
81 81
 
82
-	/**
83
-	 *
84
-	 * @global	type	$_SID
85
-	 * @param	int		$replies	Replays in the topic
86
-	 * @param	string	$url		URL oft the topic
87
-	 * @return	string				The URL with start included
88
-	 */
89
-	public function generate_lastpost_link($replies, $url)
90
-	{
91
-		$url = str_replace('.html', '', $url);
92
-		$per_page = ($this->config['posts_per_page'] <= 0) ? 1 : $this->config['posts_per_page'];
93
-		$last_post_link = '';
94
-		if (($replies + 1) > $per_page)
95
-		{
96
-			for ($j = 0; $j < $replies + 1; $j += $per_page)
97
-			{
98
-				$last_post_link = $url . '-s' . $j . '.html';
99
-			}
100
-		}
101
-		else
102
-		{
103
-			$last_post_link = $url . '.html';
104
-		}
105
-		return $last_post_link;
106
-	}
82
+    /**
83
+     *
84
+     * @global	type	$_SID
85
+     * @param	int		$replies	Replays in the topic
86
+     * @param	string	$url		URL oft the topic
87
+     * @return	string				The URL with start included
88
+     */
89
+    public function generate_lastpost_link($replies, $url)
90
+    {
91
+        $url = str_replace('.html', '', $url);
92
+        $per_page = ($this->config['posts_per_page'] <= 0) ? 1 : $this->config['posts_per_page'];
93
+        $last_post_link = '';
94
+        if (($replies + 1) > $per_page)
95
+        {
96
+            for ($j = 0; $j < $replies + 1; $j += $per_page)
97
+            {
98
+                $last_post_link = $url . '-s' . $j . '.html';
99
+            }
100
+        }
101
+        else
102
+        {
103
+            $last_post_link = $url . '.html';
104
+        }
105
+        return $last_post_link;
106
+    }
107 107
 
108
-	/**
109
-	 * Replace letters to use title in URL
110
-	 *
111
-	 * @param	string	$title	The title to use in the URL
112
-	 * @return	string	Title to use in URLs
113
-	 */
114
-	public static function title_to_url($title)
115
-	{
116
-		$url = strtolower(censor_text(utf8_normalize_nfc(strip_tags($title))));
108
+    /**
109
+     * Replace letters to use title in URL
110
+     *
111
+     * @param	string	$title	The title to use in the URL
112
+     * @return	string	Title to use in URLs
113
+     */
114
+    public static function title_to_url($title)
115
+    {
116
+        $url = strtolower(censor_text(utf8_normalize_nfc(strip_tags($title))));
117 117
 
118
-		// Let's replace
119
-		$url_search = array(' ', 'í', 'ý', 'ß', 'ö', 'ô', 'ó', 'ò', 'ä', 'â', 'à', 'á', 'é', 'è', 'ü', 'ú', 'ù', 'ñ', 'ß', '²', '³', '@', '€', '$');
120
-		$url_replace = array('-', 'i', 'y', 's', 'oe', 'o', 'o', 'o', 'ae', 'a', 'a', 'a', 'e', 'e', 'ue', 'u', 'u', 'n', 'ss', '2', '3', 'at', 'eur', 'usd');
121
-		$url = str_replace($url_search, $url_replace, $url);
122
-		$url_search = array('&amp;', '&quot;', '&', '"', "'", '¸', '`', '(', ')', '[', ']', '<', '>', '{', '}', '.', ':', ',', ';', '!', '?', '+', '*', '/', '=', 'µ', '#', '~', '"', '§', '%', '|', '°', '^', '„', '“');
123
-		$url = str_replace($url_search, '-', $url);
124
-		$url = str_replace(array('----', '---', '--'), '-', $url);
118
+        // Let's replace
119
+        $url_search = array(' ', 'í', 'ý', 'ß', 'ö', 'ô', 'ó', 'ò', 'ä', 'â', 'à', 'á', 'é', 'è', 'ü', 'ú', 'ù', 'ñ', 'ß', '²', '³', '@', '€', '$');
120
+        $url_replace = array('-', 'i', 'y', 's', 'oe', 'o', 'o', 'o', 'ae', 'a', 'a', 'a', 'e', 'e', 'ue', 'u', 'u', 'n', 'ss', '2', '3', 'at', 'eur', 'usd');
121
+        $url = str_replace($url_search, $url_replace, $url);
122
+        $url_search = array('&amp;', '&quot;', '&', '"', "'", '¸', '`', '(', ')', '[', ']', '<', '>', '{', '}', '.', ':', ',', ';', '!', '?', '+', '*', '/', '=', 'µ', '#', '~', '"', '§', '%', '|', '°', '^', '„', '“');
123
+        $url = str_replace($url_search, '-', $url);
124
+        $url = str_replace(array('----', '---', '--'), '-', $url);
125 125
 
126
-		$url = substr($url, 0, 50); // Max length for a title in URL
127
-		return urlencode($url);
128
-	}
126
+        $url = substr($url, 0, 50); // Max length for a title in URL
127
+        return urlencode($url);
128
+    }
129 129
 
130
-	/**
131
-	 * Get the topics post count or the forums post/topic count based on permissions
132
-	 *
133
-	 * @param $mode            string    One of topic_posts, forum_posts or forum_topics
134
-	 * @param $data            array    Array with the topic/forum data to calculate from
135
-	 * @param $forum_id        int        The forum id is used for permission checks
136
-	 * @return int    Number of posts/topics the user can see in the topic/forum
137
-	 */
138
-	public function get_count($mode, $data, $forum_id)
139
-	{
140
-		if (!$this->auth->acl_get('m_approve', $forum_id))
141
-		{
142
-			return (int) $data[$mode . '_approved'];
143
-		}
130
+    /**
131
+     * Get the topics post count or the forums post/topic count based on permissions
132
+     *
133
+     * @param $mode            string    One of topic_posts, forum_posts or forum_topics
134
+     * @param $data            array    Array with the topic/forum data to calculate from
135
+     * @param $forum_id        int        The forum id is used for permission checks
136
+     * @return int    Number of posts/topics the user can see in the topic/forum
137
+     */
138
+    public function get_count($mode, $data, $forum_id)
139
+    {
140
+        if (!$this->auth->acl_get('m_approve', $forum_id))
141
+        {
142
+            return (int) $data[$mode . '_approved'];
143
+        }
144 144
 
145
-		return (int) $data[$mode . '_approved'] + (int) $data[$mode . '_unapproved'] + (int) $data[$mode . '_softdeleted'];
146
-	}
145
+        return (int) $data[$mode . '_approved'] + (int) $data[$mode . '_unapproved'] + (int) $data[$mode . '_softdeleted'];
146
+    }
147 147
 }
Please login to merge, or discard this patch.
event/extensions.php 3 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
 			return;
64 64
 		}
65 65
 
66
-		$url_data =$event['url_data'] ;
66
+		$url_data = $event['url_data'];
67 67
 
68 68
 		foreach ($url_data as $id => $data)
69 69
 		{
70 70
 			$row = $data['row'];
71 71
 			if (isset($row['topic_id']))
72 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);
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 74
 			}
75 75
 			else if (isset($row['forum_id']))
76 76
 			{
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 		$this->topic_id = $event['row']['topic_id'];
97 97
 
98 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);
99
+		$u_view_topic = $this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title);
100 100
 		$topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic);
101 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']);
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 103
 		$event['topic_row'] = $topic_row;
104 104
 	}
105 105
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		$tpl_ary = $event['tpl_ary'];
131 131
 		$replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1;
132 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']);
133
+		$tpl_ary['U_TOPIC'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic).'#p'.$event['row']['topic_last_post_id']);
134 134
 		$event['tpl_ary'] = $tpl_ary;
135 135
 	}
136 136
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,8 +71,7 @@
 block discarded – undo
71 71
 			if (isset($row['topic_id']))
72 72
 			{
73 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']))
74
+			} else if (isset($row['forum_id']))
76 75
 			{
77 76
 				$url_data[$id]['url'] = $this->base->generate_forum_link($row['forum_id'], $row['forum_name'], $data['start'], true);
78 77
 			}
Please login to merge, or discard this patch.
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -16,121 +16,121 @@
 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
-		);
48
-	}
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 49
 
50 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
-		}
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 65
 
66
-		$url_data =$event['url_data'] ;
66
+        $url_data =$event['url_data'] ;
67 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
-		}
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 80
 
81
-		$event['url_data'] = $url_data;
82
-	}
81
+        $event['url_data'] = $url_data;
82
+    }
83 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'];
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 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
-	}
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 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
-	}
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 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
-	}
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 136
 }
Please login to merge, or discard this patch.
event/listener.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -228,8 +228,7 @@
 block discarded – undo
228 228
 		if (!empty($this->topic_title))
229 229
 		{
230 230
 			$event['generate_page_link_override'] = append_sid($this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title, $start));
231
-		}
232
-		else if (!empty($this->forum_title))
231
+		} else if (!empty($this->forum_title))
233 232
 		{
234 233
 			$event['generate_page_link_override'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title, $start));
235 234
 		}
Please login to merge, or discard this patch.
Indentation   +350 added lines, -350 removed lines patch added patch discarded remove patch
@@ -16,354 +16,354 @@
 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.generate_forum_nav'						=> 'generate_forum_nav',
77
-			'core.make_jumpbox_modify_tpl_ary'				=> 'make_jumpbox_modify_tpl_ary',				// Not in phpBB
78
-			'core.pagination_generate_page_link'			=> 'pagination_generate_page_link',
79
-			'core.search_modify_tpl_ary'					=> 'search_modify_tpl_ary',
80
-			'core.viewforum_modify_topicrow'				=> 'viewforum_modify_topicrow',
81
-			'core.viewforum_get_topic_data'					=> 'viewforum_get_topic_data',
82
-			'core.viewtopic_assign_template_vars_before'	=> 'viewtopic_assign_template_vars_before',
83
-			'core.viewtopic_before_f_read_check'			=> 'viewtopic_before_f_read_check',
84
-			'core.viewtopic_modify_page_title'				=> 'viewtopic_modify_page_title',
85
-			'core.viewtopic_modify_post_row'				=> 'viewtopic_modify_post_row',
86
-			'core.viewtopic_get_post_data'					=> 'viewtopic_get_post_data',
87
-		);
88
-	}
89
-
90
-	/**
91
-	 * Correct the path of $viewtopic_url
92
-	 *
93
-	 * @param	object	$event	The event object
94
-	 * @return	null
95
-	 * @access	public
96
-	 */
97
-	public function append_sid($event)
98
-	{
99
-		if ($this->in_viewtopic && preg_match('#./../viewtopic.' . $this->php_ext  . '#', $event['url']))
100
-		{
101
-			$url = $this->phpbb_root_path . 'viewtopic.' . $this->php_ext ;
102
-			$event['url'] = $url;
103
-		}
104
-	}
105
-
106
-	/**
107
-	 * Get informations for the last post from Database
108
-	 *
109
-	 * @param	object	$event	The event object
110
-	 * @return	null
111
-	 * @access	public
112
-	 */
113
-	public function display_forums_modify_sql($event)
114
-	{
115
-		$sql_array = $event['sql_ary'];
116
-		$sql_array['LEFT_JOIN'][] = array(
117
-			'FROM' => array(TOPICS_TABLE => 't'),
118
-			'ON' => "f.forum_last_post_id = t.topic_last_post_id"
119
-		);
120
-		$sql_array['SELECT'] .= ', t.topic_title, t.topic_id, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted';
121
-		$event['sql_ary'] = $sql_array;
122
-	}
123
-
124
-	/**
125
-	 * Store informations for the last post in forum_rows array
126
-	 *
127
-	 * @param	object	$event	The event object
128
-	 * @return	null
129
-	 * @access	public
130
-	 */
131
-	public function display_forums_modify_forum_rows($event)
132
-	{
133
-		$forum_rows = $event['forum_rows'];
134
-		if ($event['row']['forum_last_post_time'] == $forum_rows[$event['parent_id']]['forum_last_post_time'])
135
-		{
136
-			$forum_rows[$event['parent_id']]['forum_name_last_post'] =$event['row']['forum_name'];
137
-			$forum_rows[$event['parent_id']]['topic_id_last_post'] =$event['row']['topic_id'];
138
-			$forum_rows[$event['parent_id']]['topic_title_last_post'] =$event['row']['topic_title'];
139
-			$event['forum_rows'] = $forum_rows;
140
-		}
141
-	}
142
-
143
-	/**
144
-	 * Rewrite links to forums and subforums in forum index
145
-	 * also correct the path of the forum images if we are in a forum
146
-	 *
147
-	 * @param	object	$event	The event object
148
-	 * @return	null
149
-	 * @access	public
150
-	 */
151
-	public function display_forums_modify_template_vars($event)
152
-	{
153
-		$subforums_row = $event['subforums_row'];
154
-		$forum_row = $event['forum_row'];
155
-
156
-		// Rewrite URLs of sub forums
157
-		foreach ($subforums_row as $i => $subforum)
158
-		{
159
-			// A little bit a dirty way, but there is no better solution
160
-			$query = str_replace('&amp;', '&', parse_url($subforum['U_SUBFORUM'], PHP_URL_QUERY));
161
-			parse_str($query, $id);
162
-			$subforums_row[$i]['U_SUBFORUM'] = append_sid($this->base->generate_forum_link($id['f'], $subforum['SUBFORUM_NAME']));
163
-		}
164
-
165
-		// Update the image source in forums
166
-		$img = $this->path_helper->update_web_root_path($forum_row['FORUM_IMAGE_SRC']);
167
-		$forum_row['FORUM_IMAGE'] = preg_replace('#img src=\"(.*)\" alt#', 'img src="' . $img . '" alt', $forum_row['FORUM_IMAGE']);
168
-
169
-		// Rewrite links to topics, posts and forums
170
-		$replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1;
171
-		$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']);
172
-		$forum_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $url) . '#p' . $event['row']['forum_last_post_id']);
173
-		$forum_row['U_VIEWFORUM'] = append_sid($this->base->generate_forum_link($forum_row['FORUM_ID'], $forum_row['FORUM_NAME']));
174
-
175
-		$event['subforums_row'] = $subforums_row;
176
-		$event['forum_row'] = $forum_row;
177
-	}
178
-
179
-	/**
180
-	 * Rewrite links in breadcrumbs
181
-	 *
182
-	 * @param	object	$event	The event object
183
-	 * @return	null
184
-	 * @access	public
185
-	 */
186
-	public function generate_forum_nav($event)
187
-	{
188
-		$forum_data = $event['forum_data'];
189
-		$navlinks = $event['navlinks'];
190
-		$navlinks_parents = $event['navlinks_parents'];
191
-
192
-		foreach ($navlinks_parents as $id => $data)
193
-		{
194
-			$navlinks_parents[$id]['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($data['FORUM_ID'] , $data['FORUM_NAME']));
195
-		}
196
-
197
-		$navlinks['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($forum_data['forum_id'], $forum_data['forum_name']));
198
-		$event['navlinks'] = $navlinks;
199
-		$event['navlinks_parents'] = $navlinks_parents;
200
-	}
201
-
202
-	// Not in phpBB
203
-	public function make_jumpbox_modify_tpl_ary($event)
204
-	{
205
-		$tpl_ary = $event['tpl_ary'];
206
-		$row = $event['row'];
207
-		foreach ($tpl_ary as $id => $data)
208
-		{
209
-			$tpl_ary[$id]['LINK']	 = append_sid($this->base->generate_forum_link($row['forum_id'], $row['forum_name']));
210
-		}
211
-
212
-		$event['tpl_ary'] = $tpl_ary;
213
-	}
214
-
215
-	/**
216
-	 * Rewrite pagination links
217
-	 *
218
-	 * @param	object	$event	The event object
219
-	 * @return	null
220
-	 * @access	public
221
-	 */
222
-	public function pagination_generate_page_link($event)
223
-	{
224
-		// If we have a sort key we do not rewrite the URL
225
-		$query = str_replace('&amp;', '&', parse_url($event['base_url'], PHP_URL_QUERY));
226
-		parse_str($query, $param);
227
-		if (isset($param['sd']) || isset($param['sk']) || isset($param['st']))
228
-		{
229
-			return;
230
-		}
231
-
232
-		$start = (($event['on_page'] - 1) * $event['per_page']);
233
-		if (!empty($this->topic_title))
234
-		{
235
-			$event['generate_page_link_override'] = append_sid($this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title, $start));
236
-		}
237
-		else if (!empty($this->forum_title))
238
-		{
239
-			$event['generate_page_link_override'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title, $start));
240
-		}
241
-	}
242
-
243
-	/**
244
-	 * Rewrite links in the search result
245
-	 *
246
-	 * @param	object	$event	The event object
247
-	 * @return	null
248
-	 * @access	public
249
-	 */
250
-	public function search_modify_tpl_ary($event)
251
-	{
252
-		$replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1;
253
-		$u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']);
254
-
255
-		$tpl_ary = $event['tpl_ary'];
256
-		$tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']);
257
-		$tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic);
258
-		$tpl_ary['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name']));
259
-
260
-		$event['tpl_ary'] = $tpl_ary;
261
-	}
262
-
263
-	/**
264
-	 * Rewrite links to topics in forum view
265
-	 *
266
-	 * @param	object	$event	The event object
267
-	 * @return	null
268
-	 * @access	public
269
-	 */
270
-	public function viewforum_modify_topicrow($event)
271
-	{
272
-		$topic_row = $event['topic_row'];
273
-		$this->forum_title = $topic_row['FORUM_NAME'];
274
-		$this->forum_id = $topic_row['FORUM_ID'];
275
-		$this->topic_title = $topic_row['TOPIC_TITLE'];
276
-		$this->topic_id = $topic_row['TOPIC_ID'];
277
-
278
-		$u_view_topic = $this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title);
279
-		$topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic);
280
-		$topic_row['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title));
281
-		$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']);
282
-
283
-		$event['topic_row'] = $topic_row;
284
-	}
285
-
286
-	/**
287
-	 * Rewrite the canonical URL on viewforum.php
288
-	 *
289
-	 * @param	object	$event	The event object
290
-	 * @return	null
291
-	 * @access	public
292
-	 */
293
-	public function viewforum_get_topic_data($event)
294
-	{
295
-		$start = $this->request->variable('start', 0);
296
-		$this->template->assign_vars(array(
297
-			'U_VIEW_FORUM'	=> append_sid($this->base->generate_forum_link($event['forum_data']['forum_id'], $event['forum_data']['forum_name'], $start)),
298
-			'U_CANONICAL'		=> $this->base->generate_forum_link($event['forum_data']['forum_id'], $event['forum_data']['forum_name'], $start, true),
299
-		));
300
-	}
301
-
302
-	/**
303
-	 * Rewrite the topic URL for the headline of the topic page and the link back to forum
304
-	 *
305
-	 * @param	object	$event	The event object
306
-	 * @return	null
307
-	 * @access	public
308
-	 */
309
-	public function viewtopic_get_post_data($event)
310
-	{
311
-		$data = $event['topic_data'];
312
-		$this->template->assign_vars(array(
313
-			'U_VIEW_TOPIC'		=> append_sid($this->base->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])),
314
-			'U_VIEW_FORUM'	=> append_sid($this->base->generate_forum_link($event['forum_id'] , $data['forum_name'])),
315
-		));
316
-	}
317
-
318
-	/**
319
-	 * Assign topic data to global variables for pagination
320
-	 *
321
-	 * @param	object	$event	The event object
322
-	 * @return	null
323
-	 * @access	public
324
-	 */
325
-	public function viewtopic_assign_template_vars_before($event)
326
-	{
327
-		$this->forum_title = $event['topic_data']['forum_name'];
328
-		$this->forum_id = $event['topic_data']['forum_id'];
329
-		$this->topic_title = $event['topic_data']['topic_title'];
330
-		$this->topic_id = $event['topic_data']['topic_id'];
331
-	}
332
-
333
-	public function viewtopic_before_f_read_check()
334
-	{
335
-		$this->in_viewtopic = true;
336
-	}
337
-
338
-	/**
339
-	 * Rewrite the canonical URL on viewtopic.php
340
-	 *
341
-	 * @param	object	$event	The event object
342
-	 * @return	null
343
-	 * @access	public
344
-	 */
345
-	public function viewtopic_modify_page_title($event)
346
-	{
347
-		$start = $this->request->variable('start', 0);
348
-		$data = $event['topic_data'];
349
-		$this->template->assign_vars(array(
350
-			'U_CANONICAL'		=> $this->base->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start, true),
351
-		));
352
-	}
353
-
354
-	/**
355
-	 * Rewrite mini post img link
356
-	 *
357
-	 * @param	object	$event	The event object
358
-	 * @return	null
359
-	 * @access	public
360
-	 */
361
-	public function viewtopic_modify_post_row($event)
362
-	{
363
-		$row = $event['post_row'];
364
-		$start = $this->request->variable('start', 0);
365
-		$data = $event['topic_data'];
366
-		$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']);
367
-		$event['post_row'] = $row;
368
-	}
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.generate_forum_nav'						=> 'generate_forum_nav',
77
+            'core.make_jumpbox_modify_tpl_ary'				=> 'make_jumpbox_modify_tpl_ary',				// Not in phpBB
78
+            'core.pagination_generate_page_link'			=> 'pagination_generate_page_link',
79
+            'core.search_modify_tpl_ary'					=> 'search_modify_tpl_ary',
80
+            'core.viewforum_modify_topicrow'				=> 'viewforum_modify_topicrow',
81
+            'core.viewforum_get_topic_data'					=> 'viewforum_get_topic_data',
82
+            'core.viewtopic_assign_template_vars_before'	=> 'viewtopic_assign_template_vars_before',
83
+            'core.viewtopic_before_f_read_check'			=> 'viewtopic_before_f_read_check',
84
+            'core.viewtopic_modify_page_title'				=> 'viewtopic_modify_page_title',
85
+            'core.viewtopic_modify_post_row'				=> 'viewtopic_modify_post_row',
86
+            'core.viewtopic_get_post_data'					=> 'viewtopic_get_post_data',
87
+        );
88
+    }
89
+
90
+    /**
91
+     * Correct the path of $viewtopic_url
92
+     *
93
+     * @param	object	$event	The event object
94
+     * @return	null
95
+     * @access	public
96
+     */
97
+    public function append_sid($event)
98
+    {
99
+        if ($this->in_viewtopic && preg_match('#./../viewtopic.' . $this->php_ext  . '#', $event['url']))
100
+        {
101
+            $url = $this->phpbb_root_path . 'viewtopic.' . $this->php_ext ;
102
+            $event['url'] = $url;
103
+        }
104
+    }
105
+
106
+    /**
107
+     * Get informations for the last post from Database
108
+     *
109
+     * @param	object	$event	The event object
110
+     * @return	null
111
+     * @access	public
112
+     */
113
+    public function display_forums_modify_sql($event)
114
+    {
115
+        $sql_array = $event['sql_ary'];
116
+        $sql_array['LEFT_JOIN'][] = array(
117
+            'FROM' => array(TOPICS_TABLE => 't'),
118
+            'ON' => "f.forum_last_post_id = t.topic_last_post_id"
119
+        );
120
+        $sql_array['SELECT'] .= ', t.topic_title, t.topic_id, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted';
121
+        $event['sql_ary'] = $sql_array;
122
+    }
123
+
124
+    /**
125
+     * Store informations for the last post in forum_rows array
126
+     *
127
+     * @param	object	$event	The event object
128
+     * @return	null
129
+     * @access	public
130
+     */
131
+    public function display_forums_modify_forum_rows($event)
132
+    {
133
+        $forum_rows = $event['forum_rows'];
134
+        if ($event['row']['forum_last_post_time'] == $forum_rows[$event['parent_id']]['forum_last_post_time'])
135
+        {
136
+            $forum_rows[$event['parent_id']]['forum_name_last_post'] =$event['row']['forum_name'];
137
+            $forum_rows[$event['parent_id']]['topic_id_last_post'] =$event['row']['topic_id'];
138
+            $forum_rows[$event['parent_id']]['topic_title_last_post'] =$event['row']['topic_title'];
139
+            $event['forum_rows'] = $forum_rows;
140
+        }
141
+    }
142
+
143
+    /**
144
+     * Rewrite links to forums and subforums in forum index
145
+     * also correct the path of the forum images if we are in a forum
146
+     *
147
+     * @param	object	$event	The event object
148
+     * @return	null
149
+     * @access	public
150
+     */
151
+    public function display_forums_modify_template_vars($event)
152
+    {
153
+        $subforums_row = $event['subforums_row'];
154
+        $forum_row = $event['forum_row'];
155
+
156
+        // Rewrite URLs of sub forums
157
+        foreach ($subforums_row as $i => $subforum)
158
+        {
159
+            // A little bit a dirty way, but there is no better solution
160
+            $query = str_replace('&amp;', '&', parse_url($subforum['U_SUBFORUM'], PHP_URL_QUERY));
161
+            parse_str($query, $id);
162
+            $subforums_row[$i]['U_SUBFORUM'] = append_sid($this->base->generate_forum_link($id['f'], $subforum['SUBFORUM_NAME']));
163
+        }
164
+
165
+        // Update the image source in forums
166
+        $img = $this->path_helper->update_web_root_path($forum_row['FORUM_IMAGE_SRC']);
167
+        $forum_row['FORUM_IMAGE'] = preg_replace('#img src=\"(.*)\" alt#', 'img src="' . $img . '" alt', $forum_row['FORUM_IMAGE']);
168
+
169
+        // Rewrite links to topics, posts and forums
170
+        $replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1;
171
+        $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']);
172
+        $forum_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $url) . '#p' . $event['row']['forum_last_post_id']);
173
+        $forum_row['U_VIEWFORUM'] = append_sid($this->base->generate_forum_link($forum_row['FORUM_ID'], $forum_row['FORUM_NAME']));
174
+
175
+        $event['subforums_row'] = $subforums_row;
176
+        $event['forum_row'] = $forum_row;
177
+    }
178
+
179
+    /**
180
+     * Rewrite links in breadcrumbs
181
+     *
182
+     * @param	object	$event	The event object
183
+     * @return	null
184
+     * @access	public
185
+     */
186
+    public function generate_forum_nav($event)
187
+    {
188
+        $forum_data = $event['forum_data'];
189
+        $navlinks = $event['navlinks'];
190
+        $navlinks_parents = $event['navlinks_parents'];
191
+
192
+        foreach ($navlinks_parents as $id => $data)
193
+        {
194
+            $navlinks_parents[$id]['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($data['FORUM_ID'] , $data['FORUM_NAME']));
195
+        }
196
+
197
+        $navlinks['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($forum_data['forum_id'], $forum_data['forum_name']));
198
+        $event['navlinks'] = $navlinks;
199
+        $event['navlinks_parents'] = $navlinks_parents;
200
+    }
201
+
202
+    // Not in phpBB
203
+    public function make_jumpbox_modify_tpl_ary($event)
204
+    {
205
+        $tpl_ary = $event['tpl_ary'];
206
+        $row = $event['row'];
207
+        foreach ($tpl_ary as $id => $data)
208
+        {
209
+            $tpl_ary[$id]['LINK']	 = append_sid($this->base->generate_forum_link($row['forum_id'], $row['forum_name']));
210
+        }
211
+
212
+        $event['tpl_ary'] = $tpl_ary;
213
+    }
214
+
215
+    /**
216
+     * Rewrite pagination links
217
+     *
218
+     * @param	object	$event	The event object
219
+     * @return	null
220
+     * @access	public
221
+     */
222
+    public function pagination_generate_page_link($event)
223
+    {
224
+        // If we have a sort key we do not rewrite the URL
225
+        $query = str_replace('&amp;', '&', parse_url($event['base_url'], PHP_URL_QUERY));
226
+        parse_str($query, $param);
227
+        if (isset($param['sd']) || isset($param['sk']) || isset($param['st']))
228
+        {
229
+            return;
230
+        }
231
+
232
+        $start = (($event['on_page'] - 1) * $event['per_page']);
233
+        if (!empty($this->topic_title))
234
+        {
235
+            $event['generate_page_link_override'] = append_sid($this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title, $start));
236
+        }
237
+        else if (!empty($this->forum_title))
238
+        {
239
+            $event['generate_page_link_override'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title, $start));
240
+        }
241
+    }
242
+
243
+    /**
244
+     * Rewrite links in the search result
245
+     *
246
+     * @param	object	$event	The event object
247
+     * @return	null
248
+     * @access	public
249
+     */
250
+    public function search_modify_tpl_ary($event)
251
+    {
252
+        $replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1;
253
+        $u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']);
254
+
255
+        $tpl_ary = $event['tpl_ary'];
256
+        $tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']);
257
+        $tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic);
258
+        $tpl_ary['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name']));
259
+
260
+        $event['tpl_ary'] = $tpl_ary;
261
+    }
262
+
263
+    /**
264
+     * Rewrite links to topics in forum view
265
+     *
266
+     * @param	object	$event	The event object
267
+     * @return	null
268
+     * @access	public
269
+     */
270
+    public function viewforum_modify_topicrow($event)
271
+    {
272
+        $topic_row = $event['topic_row'];
273
+        $this->forum_title = $topic_row['FORUM_NAME'];
274
+        $this->forum_id = $topic_row['FORUM_ID'];
275
+        $this->topic_title = $topic_row['TOPIC_TITLE'];
276
+        $this->topic_id = $topic_row['TOPIC_ID'];
277
+
278
+        $u_view_topic = $this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title);
279
+        $topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic);
280
+        $topic_row['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title));
281
+        $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']);
282
+
283
+        $event['topic_row'] = $topic_row;
284
+    }
285
+
286
+    /**
287
+     * Rewrite the canonical URL on viewforum.php
288
+     *
289
+     * @param	object	$event	The event object
290
+     * @return	null
291
+     * @access	public
292
+     */
293
+    public function viewforum_get_topic_data($event)
294
+    {
295
+        $start = $this->request->variable('start', 0);
296
+        $this->template->assign_vars(array(
297
+            'U_VIEW_FORUM'	=> append_sid($this->base->generate_forum_link($event['forum_data']['forum_id'], $event['forum_data']['forum_name'], $start)),
298
+            'U_CANONICAL'		=> $this->base->generate_forum_link($event['forum_data']['forum_id'], $event['forum_data']['forum_name'], $start, true),
299
+        ));
300
+    }
301
+
302
+    /**
303
+     * Rewrite the topic URL for the headline of the topic page and the link back to forum
304
+     *
305
+     * @param	object	$event	The event object
306
+     * @return	null
307
+     * @access	public
308
+     */
309
+    public function viewtopic_get_post_data($event)
310
+    {
311
+        $data = $event['topic_data'];
312
+        $this->template->assign_vars(array(
313
+            'U_VIEW_TOPIC'		=> append_sid($this->base->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])),
314
+            'U_VIEW_FORUM'	=> append_sid($this->base->generate_forum_link($event['forum_id'] , $data['forum_name'])),
315
+        ));
316
+    }
317
+
318
+    /**
319
+     * Assign topic data to global variables for pagination
320
+     *
321
+     * @param	object	$event	The event object
322
+     * @return	null
323
+     * @access	public
324
+     */
325
+    public function viewtopic_assign_template_vars_before($event)
326
+    {
327
+        $this->forum_title = $event['topic_data']['forum_name'];
328
+        $this->forum_id = $event['topic_data']['forum_id'];
329
+        $this->topic_title = $event['topic_data']['topic_title'];
330
+        $this->topic_id = $event['topic_data']['topic_id'];
331
+    }
332
+
333
+    public function viewtopic_before_f_read_check()
334
+    {
335
+        $this->in_viewtopic = true;
336
+    }
337
+
338
+    /**
339
+     * Rewrite the canonical URL on viewtopic.php
340
+     *
341
+     * @param	object	$event	The event object
342
+     * @return	null
343
+     * @access	public
344
+     */
345
+    public function viewtopic_modify_page_title($event)
346
+    {
347
+        $start = $this->request->variable('start', 0);
348
+        $data = $event['topic_data'];
349
+        $this->template->assign_vars(array(
350
+            'U_CANONICAL'		=> $this->base->generate_topic_link($data['forum_id'], $data['forum_name'], $data['topic_id'], $data['topic_title'], $start, true),
351
+        ));
352
+    }
353
+
354
+    /**
355
+     * Rewrite mini post img link
356
+     *
357
+     * @param	object	$event	The event object
358
+     * @return	null
359
+     * @access	public
360
+     */
361
+    public function viewtopic_modify_post_row($event)
362
+    {
363
+        $row = $event['post_row'];
364
+        $start = $this->request->variable('start', 0);
365
+        $data = $event['topic_data'];
366
+        $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']);
367
+        $event['post_row'] = $row;
368
+    }
369 369
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 			'core.display_forums_modify_template_vars'		=> 'display_forums_modify_template_vars',
75 75
 			'core.display_forums_modify_forum_rows'			=> 'display_forums_modify_forum_rows',
76 76
 			'core.generate_forum_nav'						=> 'generate_forum_nav',
77
-			'core.make_jumpbox_modify_tpl_ary'				=> 'make_jumpbox_modify_tpl_ary',				// Not in phpBB
77
+			'core.make_jumpbox_modify_tpl_ary'				=> 'make_jumpbox_modify_tpl_ary', // Not in phpBB
78 78
 			'core.pagination_generate_page_link'			=> 'pagination_generate_page_link',
79 79
 			'core.search_modify_tpl_ary'					=> 'search_modify_tpl_ary',
80 80
 			'core.viewforum_modify_topicrow'				=> 'viewforum_modify_topicrow',
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function append_sid($event)
98 98
 	{
99
-		if ($this->in_viewtopic && preg_match('#./../viewtopic.' . $this->php_ext  . '#', $event['url']))
99
+		if ($this->in_viewtopic && preg_match('#./../viewtopic.'.$this->php_ext.'#', $event['url']))
100 100
 		{
101
-			$url = $this->phpbb_root_path . 'viewtopic.' . $this->php_ext ;
101
+			$url = $this->phpbb_root_path.'viewtopic.'.$this->php_ext;
102 102
 			$event['url'] = $url;
103 103
 		}
104 104
 	}
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 		$forum_rows = $event['forum_rows'];
134 134
 		if ($event['row']['forum_last_post_time'] == $forum_rows[$event['parent_id']]['forum_last_post_time'])
135 135
 		{
136
-			$forum_rows[$event['parent_id']]['forum_name_last_post'] =$event['row']['forum_name'];
137
-			$forum_rows[$event['parent_id']]['topic_id_last_post'] =$event['row']['topic_id'];
138
-			$forum_rows[$event['parent_id']]['topic_title_last_post'] =$event['row']['topic_title'];
136
+			$forum_rows[$event['parent_id']]['forum_name_last_post'] = $event['row']['forum_name'];
137
+			$forum_rows[$event['parent_id']]['topic_id_last_post'] = $event['row']['topic_id'];
138
+			$forum_rows[$event['parent_id']]['topic_title_last_post'] = $event['row']['topic_title'];
139 139
 			$event['forum_rows'] = $forum_rows;
140 140
 		}
141 141
 	}
@@ -164,12 +164,12 @@  discard block
 block discarded – undo
164 164
 
165 165
 		// Update the image source in forums
166 166
 		$img = $this->path_helper->update_web_root_path($forum_row['FORUM_IMAGE_SRC']);
167
-		$forum_row['FORUM_IMAGE'] = preg_replace('#img src=\"(.*)\" alt#', 'img src="' . $img . '" alt', $forum_row['FORUM_IMAGE']);
167
+		$forum_row['FORUM_IMAGE'] = preg_replace('#img src=\"(.*)\" alt#', 'img src="'.$img.'" alt', $forum_row['FORUM_IMAGE']);
168 168
 
169 169
 		// Rewrite links to topics, posts and forums
170 170
 		$replies = $this->base->get_count('topic_posts', $event['row'], $event['row']['forum_id']) - 1;
171 171
 		$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']);
172
-		$forum_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $url) . '#p' . $event['row']['forum_last_post_id']);
172
+		$forum_row['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $url).'#p'.$event['row']['forum_last_post_id']);
173 173
 		$forum_row['U_VIEWFORUM'] = append_sid($this->base->generate_forum_link($forum_row['FORUM_ID'], $forum_row['FORUM_NAME']));
174 174
 
175 175
 		$event['subforums_row'] = $subforums_row;
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
 		foreach ($navlinks_parents as $id => $data)
193 193
 		{
194
-			$navlinks_parents[$id]['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($data['FORUM_ID'] , $data['FORUM_NAME']));
194
+			$navlinks_parents[$id]['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($data['FORUM_ID'], $data['FORUM_NAME']));
195 195
 		}
196 196
 
197 197
 		$navlinks['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($forum_data['forum_id'], $forum_data['forum_name']));
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 		$row = $event['row'];
207 207
 		foreach ($tpl_ary as $id => $data)
208 208
 		{
209
-			$tpl_ary[$id]['LINK']	 = append_sid($this->base->generate_forum_link($row['forum_id'], $row['forum_name']));
209
+			$tpl_ary[$id]['LINK'] = append_sid($this->base->generate_forum_link($row['forum_id'], $row['forum_name']));
210 210
 		}
211 211
 
212 212
 		$event['tpl_ary'] = $tpl_ary;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 		$u_view_topic = $this->base->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']);
254 254
 
255 255
 		$tpl_ary = $event['tpl_ary'];
256
-		$tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic) . '#p' . $event['row']['topic_last_post_id']);
256
+		$tpl_ary['U_LAST_POST'] = append_sid($this->base->generate_lastpost_link($replies, $u_view_topic).'#p'.$event['row']['topic_last_post_id']);
257 257
 		$tpl_ary['U_VIEW_TOPIC'] = append_sid($u_view_topic);
258 258
 		$tpl_ary['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($event['row']['forum_id'], $event['row']['forum_name']));
259 259
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		$u_view_topic = $this->base->generate_topic_link($this->forum_id, $this->forum_title, $this->topic_id, $this->topic_title);
279 279
 		$topic_row['U_VIEW_TOPIC'] = append_sid($u_view_topic);
280 280
 		$topic_row['U_VIEW_FORUM'] = append_sid($this->base->generate_forum_link($this->forum_id, $this->forum_title));
281
-		$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']);
281
+		$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']);
282 282
 
283 283
 		$event['topic_row'] = $topic_row;
284 284
 	}
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 	{
311 311
 		$data = $event['topic_data'];
312 312
 		$this->template->assign_vars(array(
313
-			'U_VIEW_TOPIC'		=> append_sid($this->base->generate_topic_link($event['forum_id'] , $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])),
314
-			'U_VIEW_FORUM'	=> append_sid($this->base->generate_forum_link($event['forum_id'] , $data['forum_name'])),
313
+			'U_VIEW_TOPIC'		=> append_sid($this->base->generate_topic_link($event['forum_id'], $data['forum_name'], $event['topic_id'], $data['topic_title'], $event['start'])),
314
+			'U_VIEW_FORUM'	=> append_sid($this->base->generate_forum_link($event['forum_id'], $data['forum_name'])),
315 315
 		));
316 316
 	}
317 317
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 		$row = $event['post_row'];
364 364
 		$start = $this->request->variable('start', 0);
365 365
 		$data = $event['topic_data'];
366
-		$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']);
366
+		$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']);
367 367
 		$event['post_row'] = $row;
368 368
 	}
369 369
 }
Please login to merge, or discard this patch.