| 8272a21 by Ivan Fomichev at 2009-10-28 |
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<extension engine="1.0"> |
|
4 |
<id>most_subscribed</id> |
|
5 |
<title>Most Subscribed</title> |
| 7670782 by Ivan Fomichev at 2009-10-29 |
6 |
<version>0.2</version> |
| 8272a21 by Ivan Fomichev at 2009-10-28 |
7 |
<description>Show the list of most subscribed topics.</description> |
|
8 |
<author>Ivan Fomichev</author> |
|
9 |
<minversion>1.3</minversion> |
|
10 |
<maxtestedon>1.3.4</maxtestedon> |
|
11 |
|
|
12 |
<hooks> |
|
13 |
<hook id="co_common"><![CDATA[ |
|
14 |
// Include a language file |
|
15 |
if (file_exists($ext_info['path'] . '/lang/' . $forum_user['language'] . '.php')) |
|
16 |
include_once($ext_info['path'] . '/lang/' . $forum_user['language'] . '.php'); |
|
17 |
else |
|
18 |
include_once($ext_info['path'] . '/lang/English.php'); |
|
19 |
]]></hook> |
|
20 |
|
|
21 |
<hook id="co_modify_url_scheme"><![CDATA[ |
|
22 |
|
|
23 |
if (file_exists($ext_info['path'].'/url/'.$forum_config['o_sef'].'.php')) |
|
24 |
require $ext_info['path'].'/url/'.$forum_config['o_sef'].'.php'; |
|
25 |
else |
|
26 |
require $ext_info['path'].'/url/Default.php'; |
|
27 |
|
|
28 |
]]></hook> |
|
29 |
|
|
30 |
<hook id="sf_fn_validate_actions_start"><![CDATA[ |
|
31 |
|
|
32 |
array_push($valid_actions, 'show_most_subscribed'); |
|
33 |
|
|
34 |
]]></hook> |
|
35 |
|
|
36 |
<hook id="sf_fn_generate_action_search_query_end"><![CDATA[ |
|
37 |
if ($action == 'show_most_subscribed') |
|
38 |
{ |
|
39 |
$query = array( |
|
40 |
'SELECT' => 't.id AS tid, t.poster, t.subject, t.first_post_id, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.sticky, t.forum_id, f.forum_name', |
|
41 |
'FROM' => 'topics AS t', |
|
42 |
'JOINS' => array( |
|
43 |
array( |
|
44 |
'INNER JOIN' => 'forums AS f', |
|
45 |
'ON' => 'f.id=t.forum_id' |
|
46 |
), |
|
47 |
array( |
|
48 |
'LEFT JOIN' => 'forum_perms AS fp', |
|
49 |
'ON' => '(fp.forum_id=f.id AND fp.group_id='.$forum_user['g_id'].')' |
|
50 |
), |
|
51 |
array( |
|
52 |
'INNER JOIN' => 'subscriptions AS s', |
|
53 |
'ON' => 's.topic_id=t.id' |
|
54 |
) |
|
55 |
), |
|
56 |
'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1)', |
|
57 |
'GROUP BY' => 't.id', |
|
58 |
'ORDER BY' => 'subscribed_times DESC, t.last_post DESC' |
|
59 |
); |
|
60 |
|
|
61 |
// With "has posted" indication |
|
62 |
if (!$forum_user['is_guest'] && $forum_config['o_show_dot'] == '1') |
|
63 |
{ |
|
64 |
$subquery = array( |
|
65 |
'SELECT' => 'COUNT(p.id)', |
|
66 |
'FROM' => 'posts AS p', |
|
67 |
'WHERE' => 'p.poster_id='.$forum_user['id'].' AND p.topic_id=t.id' |
|
68 |
); |
|
69 |
|
|
70 |
($hook = get_hook('sf_fn_generate_action_search_query_qr_get_unanswered_topics_has_posted')) ? eval($hook) : null; |
|
71 |
$query['SELECT'] .= ', ('.$forum_db->query_build($subquery, true).') AS has_posted'; |
|
72 |
} |
|
73 |
|
|
74 |
$query['SELECT'] .= ', COUNT(s.user_id) AS subscribed_times'; |
|
75 |
|
|
76 |
$url_type = $forum_url['search_most_subscribed']; |
|
77 |
} |
|
78 |
|
|
79 |
]]></hook> |
|
80 |
|
|
81 |
<hook id="re_rewrite_rules"><![CDATA[ |
|
82 |
|
|
83 |
$forum_rewrite_rules['/^search[\/_-]?most-subscribed(\.html?|\/)?$/i'] = 'search.php?action=show_most_subscribed'; |
|
84 |
|
|
85 |
]]></hook> |
|
86 |
|
|
87 |
<hook id="se_results_topics_pre_item_header_output"><![CDATA[ |
|
88 |
|
| cefab6b by Ivan Fomichev at 2009-10-29 |
89 |
if (isset($action) && $action == 'show_most_subscribed') |
|
90 |
{ |
| 7670782 by Ivan Fomichev at 2009-10-29 |
91 |
// dirty hack |
|
92 |
$forum_page['item_header']['info']['replies'] = '<strong class="info-replies">'.$lang_most_subscribed['subscribers'].'</strong>'; |
|
93 |
} |
| 8272a21 by Ivan Fomichev at 2009-10-28 |
94 |
|
|
95 |
]]></hook> |
|
96 |
|
|
97 |
<hook id="se_results_topics_row_pre_display"><![CDATA[ |
|
98 |
|
| cefab6b by Ivan Fomichev at 2009-10-29 |
99 |
if (isset($action) && $action == 'show_most_subscribed') |
|
100 |
{ |
| 7670782 by Ivan Fomichev at 2009-10-29 |
101 |
// dirty hack |
|
102 |
$forum_page['item_body']['info']['replies'] = '<li class="info-replies"><strong>'.forum_number_format($cur_set['subscribed_times']).'</strong> <span class="label">'.(($cur_set['subscribed_times'] == 1) ? $lang_most_subscribed['Subscriber'] : $lang_most_subscribed['Subscribers']).'</span></li>'; |
|
103 |
} |
| 8272a21 by Ivan Fomichev at 2009-10-28 |
104 |
|
|
105 |
]]></hook> |
|
106 |
|
|
107 |
<hook id="hd_visit_elements"><![CDATA[ |
|
108 |
|
|
109 |
$visit_elements['<!-- forum_visit -->'] = preg_replace('#(?=</p>)#i', ' <span><a href="'.forum_link($forum_url['search_most_subscribed']).'">'.$lang_most_subscribed['Most subscribed'].'</a></span>', $visit_elements['<!-- forum_visit -->']); |
|
110 |
|
|
111 |
]]></hook> |
|
112 |
</hooks> |
|
113 |
</extension> |