Révision 13c3c9b4
Ajouté par Assos Assos il y a environ 9 ans
drupal7/sites/all/modules/advanced_forum/advanced_forum.info | ||
---|---|---|
1 | 1 |
|
2 | 2 |
name = Advanced Forum |
3 | 3 |
description = Enables the look and feel of other popular forum software. |
4 |
version = 7.x-2.x-dev |
|
4 |
core = 7.x |
|
5 |
package = Advanced Forum |
|
6 |
|
|
5 | 7 |
dependencies[] = forum |
6 | 8 |
dependencies[] = ctools |
7 | 9 |
dependencies[] = views |
... | ... | |
13 | 15 |
files[] = includes/views/advanced_forum_handler_field_node_topic_pager.inc |
14 | 16 |
files[] = includes/views/advanced_forum_plugin_style_forum_topic_list.inc |
15 | 17 |
|
16 |
core = 7.x |
|
18 |
; Tests |
|
19 |
files[] = tests/af.test |
|
17 | 20 |
|
18 |
; Information added by Drupal.org packaging script on 2014-06-21
|
|
19 |
version = "7.x-2.4"
|
|
21 |
; Information added by Drupal.org packaging script on 2015-02-10
|
|
22 |
version = "7.x-2.5"
|
|
20 | 23 |
core = "7.x" |
21 | 24 |
project = "advanced_forum" |
22 |
datestamp = "1403371728"
|
|
25 |
datestamp = "1423590792"
|
|
23 | 26 |
|
drupal7/sites/all/modules/advanced_forum/advanced_forum.install | ||
---|---|---|
4 | 4 |
* @file |
5 | 5 |
* Installation code for Advanced Forum. |
6 | 6 |
*/ |
7 |
|
|
8 |
/** |
|
9 |
* Implements hook_install(). |
|
10 |
*/ |
|
7 | 11 |
function advanced_forum_install() { |
8 | 12 |
db_update('system') |
9 | 13 |
->fields(array('weight' => 15)) |
... | ... | |
11 | 15 |
->execute(); |
12 | 16 |
} |
13 | 17 |
|
18 |
/** |
|
19 |
* Implements hook_uninstall(). |
|
20 |
*/ |
|
14 | 21 |
function advanced_forum_uninstall() { |
15 | 22 |
db_delete('variable') |
16 | 23 |
->condition('name', "advanced_forum_%", "LIKE") |
... | ... | |
18 | 25 |
cache_clear_all('variables', 'cache_bootstrap'); |
19 | 26 |
} |
20 | 27 |
|
28 |
/** |
|
29 |
* Implements hook_update_N(). |
|
30 |
*/ |
|
21 | 31 |
function advanced_forum_update_5000() { |
22 | 32 |
db_update('system') |
23 | 33 |
->fields(array('weight' => 10)) |
... | ... | |
25 | 35 |
->execute(); |
26 | 36 |
} |
27 | 37 |
|
38 |
/** |
|
39 |
* Implements hook_update_N(). |
|
40 |
*/ |
|
28 | 41 |
function advanced_forum_update_5003() { |
29 | 42 |
db_drop_table('advforum_last_post'); |
30 | 43 |
} |
31 | 44 |
|
45 |
/** |
|
46 |
* Implements hook_update_N(). |
|
47 |
*/ |
|
32 | 48 |
function advanced_forum_update_5005() { |
33 | 49 |
db_update('system') |
34 | 50 |
->fields(array('weight' => 15)) |
... | ... | |
36 | 52 |
->execute(); |
37 | 53 |
} |
38 | 54 |
|
55 |
/** |
|
56 |
* Implements hook_update_N(). |
|
57 |
*/ |
|
39 | 58 |
function advanced_forum_update_7200() { |
40 | 59 |
if (variable_get('advanced_forum_forum_disabled') == NULL) { |
41 | 60 |
variable_set('advanced_forum_forum_disabled', FALSE); |
42 | 61 |
} |
43 |
} |
|
62 |
} |
drupal7/sites/all/modules/advanced_forum/advanced_forum.module | ||
---|---|---|
4 | 4 |
* @file |
5 | 5 |
* Enables the look and feel of other popular forum software. |
6 | 6 |
*/ |
7 |
// DRUPAL HOOKS **************************************************************/ |
|
8 | 7 |
|
9 | 8 |
/** |
10 | 9 |
* Implementation of hook_perm(). |
... | ... | |
12 | 11 |
function advanced_forum_permission() { |
13 | 12 |
return array( |
14 | 13 |
'administer advanced forum' => array( |
15 |
'title' => t('Administer Advanced Forum') |
|
14 |
'title' => t('Administer Advanced Forum'),
|
|
16 | 15 |
), |
17 | 16 |
'view forum statistics' => array( |
18 |
'title' => t('View Advanced Forum statistics') |
|
17 |
'title' => t('View Advanced Forum statistics'),
|
|
19 | 18 |
), |
20 | 19 |
'view last edited notice' => array( |
21 |
'title' => t('View last edited notice') |
|
20 |
'title' => t('View last edited notice'),
|
|
22 | 21 |
) |
23 | 22 |
); |
24 | 23 |
} |
25 | 24 |
|
26 | 25 |
/** |
27 |
* Implementation of hook_menu().
|
|
26 |
* Implements hook_menu().
|
|
28 | 27 |
*/ |
29 | 28 |
function advanced_forum_menu() { |
30 | 29 |
$items['admin/config/content/advanced-forum'] = array( |
... | ... | |
33 | 32 |
'page arguments' => array('advanced_forum_settings_page'), |
34 | 33 |
'page callback' => 'drupal_get_form', |
35 | 34 |
'title' => 'Advanced Forum', |
36 |
'file' => 'includes/settings.inc' |
|
35 |
'file' => 'includes/settings.inc',
|
|
37 | 36 |
); |
38 | 37 |
|
39 | 38 |
$items['forum/markasread'] = array( |
... | ... | |
55 | 54 |
} |
56 | 55 |
|
57 | 56 |
/** |
58 |
* Implementation of hook_cron().
|
|
57 |
* Implements hook_cron().
|
|
59 | 58 |
*/ |
60 | 59 |
function advanced_forum_cron() { |
61 |
// ensure the reply stats are up-to-date
|
|
60 |
// Ensure the reply stats are up-to-date.
|
|
62 | 61 |
advanced_forum_statistics_replies(NULL, TRUE); |
63 | 62 |
} |
64 | 63 |
|
65 | 64 |
/** |
66 |
* Implementation of hook_menu_alter().
|
|
65 |
* Implements hook_menu_alter().
|
|
67 | 66 |
*/ |
68 | 67 |
function advanced_forum_menu_alter(&$items) { |
69 | 68 |
// Take over the forum page creation so we can add more information. |
... | ... | |
71 | 70 |
$items['forum']['module'] = 'advanced_forum'; |
72 | 71 |
unset($items['forum']['file']); |
73 | 72 |
|
74 |
|
|
75 | 73 |
// Take over forum/%forum_forum page because we want advanced_forum_forum_load |
76 | 74 |
// is called instead of core forum_forum_load |
77 | 75 |
$items['forum/%advanced_forum_forum'] = $items['forum/%forum_forum']; |
... | ... | |
93 | 91 |
} |
94 | 92 |
|
95 | 93 |
/** |
96 |
* Implementation of hook_module_implements_alter().
|
|
94 |
* Implements hook_module_implements_alter().
|
|
97 | 95 |
* |
98 | 96 |
* We don't want forum_menu_local_tasks_alter() to be called and mess with our links. |
99 |
* |
|
100 | 97 |
*/ |
101 | 98 |
function advanced_forum_module_implements_alter(&$implementations, $hook) { |
102 | 99 |
if ($hook == 'menu_local_tasks_alter') { |
... | ... | |
105 | 102 |
} |
106 | 103 |
|
107 | 104 |
/** |
108 |
* Implementation of hook_theme().
|
|
105 |
* Implements hook_theme().
|
|
109 | 106 |
*/ |
110 | 107 |
function advanced_forum_theme() { |
111 | 108 |
advanced_forum_load_style_includes(); |
112 | 109 |
|
113 |
// Bulk read all available (active) style templates |
|
110 |
// Bulk read all available (active) style templates.
|
|
114 | 111 |
$existing_items = advanced_forum_find_style_templates(); |
115 | 112 |
|
116 | 113 |
$items['advanced_forum_l'] = array( |
... | ... | |
119 | 116 |
'path' => NULL, |
120 | 117 |
'options' => array(), |
121 | 118 |
'button_class' => NULL, |
122 |
) |
|
119 |
),
|
|
123 | 120 |
); |
124 | 121 |
|
125 | 122 |
$items['advanced_forum_topic_header'] = array( |
126 | 123 |
'variables' => array( |
127 | 124 |
'node' => NULL, |
128 | 125 |
'comment_count' => NULL, |
129 |
) |
|
126 |
),
|
|
130 | 127 |
); |
131 | 128 |
|
132 | 129 |
$items['advanced_forum_active_poster'] = array( |
... | ... | |
136 | 133 |
'posts' => NULL, |
137 | 134 |
'topics' => NULL, |
138 | 135 |
'last_post' => NULL, |
139 |
) |
|
136 |
),
|
|
140 | 137 |
); |
141 | 138 |
|
142 | 139 |
$items['advanced_forum_user_picture'] = array( |
143 | 140 |
'variables' => array( |
144 | 141 |
'account' => NULL, |
145 |
) |
|
142 |
),
|
|
146 | 143 |
); |
147 | 144 |
|
148 | 145 |
$items['advanced_forum_reply_link'] = array( |
149 | 146 |
'variables' => array( |
150 | 147 |
'node' => NULL, |
151 |
) |
|
148 |
),
|
|
152 | 149 |
); |
153 | 150 |
|
154 | 151 |
$items['advanced_forum_topic_pager'] = array( |
155 | 152 |
'variables' => array( |
156 | 153 |
'pagecount' => NULL, |
157 | 154 |
'topic' => NULL, |
158 |
) |
|
155 |
),
|
|
159 | 156 |
); |
160 | 157 |
|
161 | 158 |
$items['advanced_forum_shadow_topic'] = array( |
... | ... | |
163 | 160 |
'title' => NULL, |
164 | 161 |
'nid' => NULL, |
165 | 162 |
'new_forum' => NULL, |
166 |
) |
|
163 |
),
|
|
167 | 164 |
); |
168 | 165 |
|
169 | 166 |
$items['advanced_forum_subforum_list'] = array( |
170 | 167 |
'variables' => array( |
171 | 168 |
'subforum_list' => NULL, |
172 |
) |
|
169 |
),
|
|
173 | 170 |
); |
174 | 171 |
|
175 | 172 |
$items['advanced_forum_subcontainer_list'] = array( |
176 | 173 |
'variables' => array( |
177 | 174 |
'subcontainer_list' => NULL, |
178 |
) |
|
175 |
),
|
|
179 | 176 |
); |
180 | 177 |
|
181 | 178 |
$items['advanced_forum_simple_author_pane'] = array( |
182 | 179 |
'variables' => array( |
183 | 180 |
'context' => NULL, |
184 |
) |
|
181 |
),
|
|
185 | 182 |
); |
186 | 183 |
|
187 | 184 |
$items['advanced_forum_post_edited'] = array( |
... | ... | |
189 | 186 |
'who' => NULL, |
190 | 187 |
'when' => NULL, |
191 | 188 |
'why' => NULL, |
192 |
) |
|
189 |
),
|
|
193 | 190 |
); |
194 | 191 |
|
195 | 192 |
$items['advanced_forum_node_type_create_list'] = array( |
196 | 193 |
'variables' => array( |
197 | 194 |
'forum_id' => NULL, |
198 |
) |
|
195 |
),
|
|
199 | 196 |
); |
200 | 197 |
/* |
201 |
// Templates for features added by Views
|
|
198 |
// Templates for features added by Views |
|
202 | 199 |
|
203 |
// style
|
|
204 |
$items['views_view_forum_topic_list__advanced_forum_topic_list'] = array(
|
|
205 |
'variables' => array('view' => NULL, 'options' => NULL, 'rows' => NULL, 'title' => NULL),
|
|
206 |
'template' => 'advanced-forum-topic-list-view',
|
|
207 |
//'base hook' => 'views_view_forum_topic_list',
|
|
208 |
);
|
|
200 |
// style |
|
201 |
$items['views_view_forum_topic_list__advanced_forum_topic_list'] = array( |
|
202 |
'variables' => array('view' => NULL, 'options' => NULL, 'rows' => NULL, 'title' => NULL), |
|
203 |
'template' => 'advanced-forum-topic-list-view', |
|
204 |
//'base hook' => 'views_view_forum_topic_list', |
|
205 |
); |
|
209 | 206 |
*/ |
210 |
//display
|
|
207 |
// Display.
|
|
211 | 208 |
$items['views_view__advanced_forum_topic_list'] = array( |
212 | 209 |
'variables' => array('view' => NULL), |
213 | 210 |
'template' => 'advanced-forum-topic-list-outer-view', |
214 |
//'base hook' => 'views_view', |
|
215 | 211 |
); |
216 | 212 |
|
217 |
//display group
|
|
213 |
// Display group.
|
|
218 | 214 |
$items['views_view__advanced_forum_group_topic_list'] = array( |
219 | 215 |
'variables' => array('view' => NULL), |
220 | 216 |
'template' => 'advanced-forum-group-topic-list-outer-view', |
221 |
//'base hook' => 'views_view', |
|
222 | 217 |
); |
223 | 218 |
|
224 | 219 |
// Return merged items found in style folder with new ones |
225 |
// array_merge_recursive doesn't work as desired |
|
220 |
// array_merge_recursive doesn't work as desired.
|
|
226 | 221 |
foreach ($items as $key => $item) { |
227 | 222 |
if (array_key_exists($key, $existing_items)) { |
228 | 223 |
$existing_items[$key] += $item; |
... | ... | |
236 | 231 |
} |
237 | 232 |
|
238 | 233 |
/** |
239 |
* Implementation of hook_theme_registry_alter().
|
|
234 |
* Implements hook_theme_registry_alter().
|
|
240 | 235 |
*/ |
241 | 236 |
function advanced_forum_theme_registry_alter(&$theme_registry) { |
242 | 237 |
advanced_forum_load_style_includes(); |
... | ... | |
274 | 269 |
// --- for the given templates can be found first in the (sub)theme directory |
275 | 270 |
// --- then in ancestor themes, if any, then in the active style directory |
276 | 271 |
// --- for advanced forum or any ancestor styles. |
277 |
// Affected templates |
|
272 |
// Affected templates.
|
|
278 | 273 |
$templates = array( |
279 | 274 |
'node', |
280 | 275 |
'comment', |
... | ... | |
294 | 289 |
'advanced_forum_active_poster', */ |
295 | 290 |
); |
296 | 291 |
|
297 |
// Get the sequence of styles to look in for templates |
|
292 |
// Get the sequence of styles to look in for templates.
|
|
298 | 293 |
$lineage = advanced_forum_style_lineage(); |
299 | 294 |
|
300 | 295 |
if (!array_key_exists('naked', $lineage)) { |
... | ... | |
303 | 298 |
$lineage['naked'] = drupal_get_path('module', 'advanced_forum') . '/styles/naked'; |
304 | 299 |
} |
305 | 300 |
|
306 |
// Get theme engine extension |
|
301 |
// Get theme engine extension.
|
|
307 | 302 |
global $theme_engine; |
308 | 303 |
$extension = '.tpl.php'; |
309 | 304 |
if (isset($theme_engine)) { |
... | ... | |
336 | 331 |
} |
337 | 332 |
} |
338 | 333 |
|
339 |
|
|
340 |
// temp workaround |
|
334 |
// Temp workaround. |
|
341 | 335 |
if (isset($theme_registry['views_view__advanced_forum_topic_list']['preprocess functions'])) { |
342 | 336 |
array_splice($theme_registry['views_view__advanced_forum_topic_list']['preprocess functions'], 1, 0, 'template_preprocess_views_view'); |
343 | 337 |
} |
344 | 338 |
if (isset($theme_registry['views_view__advanced_forum_group_topic_list']['preprocess functions'])) { |
345 | 339 |
array_splice($theme_registry['views_view__advanced_forum_group_topic_list']['preprocess functions'], 1, 0, 'template_preprocess_views_view'); |
346 | 340 |
} |
347 |
//array_splice($theme_registry['views_view_forum_topic_list__advanced_forum_topic_list']['preprocess functions'], 1, 0, 'template_preprocess_views_view_forum_topic_list'); |
|
348 | 341 |
} |
349 | 342 |
|
350 | 343 |
/** |
351 |
* Own link alteration implementaion because there are no |
|
352 |
* hook_link nor hook_link_alter in D7 |
|
344 |
* Own link alteration implementation because there are no hook_link nor hook_link_alter in D7. |
|
353 | 345 |
* |
354 | 346 |
* Name changed intentionally to avoid confusion with hook_link_alter! |
355 | 347 |
*/ |
356 | 348 |
function advanced_forum_links_alter(&$object, $view_mode, $object_type = 'node') { |
357 |
// Don't alter anything if in preview mode |
|
349 |
// Don't alter anything if in preview mode.
|
|
358 | 350 |
if (!empty($object->in_preview)) { |
359 | 351 |
return; |
360 | 352 |
} |
... | ... | |
398 | 390 |
$links['comment-add']['href'] = "comment/reply/$node->nid"; |
399 | 391 |
} |
400 | 392 |
|
401 |
|
|
402 | 393 |
// List the keys we are interested in. |
403 |
$affected_keys = array('post-edit', 'comment-edit', 'post-delete', 'comment-delete', 'quote', 'comment-add', 'comment-reply'); |
|
394 |
$affected_keys = array( |
|
395 |
'post-edit', |
|
396 |
'comment-edit', |
|
397 |
'post-delete', |
|
398 |
'comment-delete', |
|
399 |
'quote', |
|
400 |
'comment-add', |
|
401 |
'comment-reply', |
|
402 |
); |
|
404 | 403 |
|
405 | 404 |
// Add extra span tags for image replacement. |
406 |
foreach ($links AS $key => $link) {
|
|
405 |
foreach ($links as $key => $link) {
|
|
407 | 406 |
if (in_array($key, $affected_keys)) { |
408 | 407 |
$links[$key]['attributes']['class'][] = "af-button-small"; |
409 | 408 |
$links[$key]['title'] = '<span>' . $links[$key]['title'] . '</span>'; |
... | ... | |
420 | 419 |
} |
421 | 420 |
} |
422 | 421 |
|
423 |
// we want to put comment links last
|
|
422 |
// We want to put comment links last.
|
|
424 | 423 |
unset($object->content['links']['comment']); |
425 | 424 |
$object->content['links']['comment'] = $comment_links; |
426 | 425 |
|
427 |
// put links back
|
|
426 |
// Put links back.
|
|
428 | 427 |
$object->content['links']['comment']['#links'] = $links; |
429 | 428 |
} |
430 | 429 |
|
431 | 430 |
/** |
432 |
* Implementation of hook_node_view().
|
|
431 |
* Implements hook_node_view().
|
|
433 | 432 |
* |
434 |
* hook_link() and hook_link_alter() functionalty implemented here |
|
433 |
* hook_link() and hook_link_alter() functionality implemented here
|
|
435 | 434 |
*/ |
436 | 435 |
function advanced_forum_node_view($node, $view_mode, $langcode) { |
437 | 436 |
advanced_forum_links_alter($node, $view_mode, 'node'); |
438 | 437 |
} |
439 | 438 |
|
440 | 439 |
/** |
441 |
* Implementation of hook_comment_view().
|
|
440 |
* Implements hook_comment_view().
|
|
442 | 441 |
*/ |
443 | 442 |
function advanced_forum_comment_view($comment, $view_mode, $langcode) { |
444 | 443 |
advanced_forum_links_alter($comment, $view_mode, 'comment'); |
445 | 444 |
} |
446 | 445 |
|
447 | 446 |
/** |
448 |
* Implementation of hook_comment_delete().
|
|
447 |
* Implements hook_comment_delete().
|
|
449 | 448 |
*/ |
450 | 449 |
function advanced_forum_comment_delete($comment) { |
451 | 450 |
if (!empty($comment->node_type) && ($comment->node_type == "comment_node_forum")) { |
... | ... | |
454 | 453 |
} |
455 | 454 |
|
456 | 455 |
/** |
457 |
* Implementation of hook_comment_update().
|
|
456 |
* Implements hook_comment_update().
|
|
458 | 457 |
*/ |
459 | 458 |
function advanced_forum_comment_update($comment) { |
460 | 459 |
if (!empty($comment->node_type) && ($comment->node_type == "comment_node_forum")) { |
461 |
// comment unpublished?
|
|
460 |
// Comment unpublished?
|
|
462 | 461 |
if (!$comment->status) { |
463 | 462 |
advanced_forum_statistics_replies(-1); |
464 | 463 |
} |
... | ... | |
466 | 465 |
} |
467 | 466 |
|
468 | 467 |
/** |
469 |
* Implementation of hook_comment_publish().
|
|
468 |
* Implements hook_comment_publish().
|
|
470 | 469 |
*/ |
471 | 470 |
function advanced_forum_comment_publish($comment) { |
472 | 471 |
if (!empty($comment->node_type) && ($comment->node_type == "comment_node_forum")) { |
... | ... | |
475 | 474 |
} |
476 | 475 |
|
477 | 476 |
/** |
478 |
* Implementation of hook_form_alter().
|
|
477 |
* Implements hook_form_alter().
|
|
479 | 478 |
*/ |
480 | 479 |
function advanced_forum_form_alter(&$form, &$form_state, $form_id) { |
481 | 480 |
if (!empty($form['#node']->type) && advanced_forum_type_is_in_forum($form['#node']) && isset($form['body_field']) && isset($form['body_field']['#after_build'])) { |
... | ... | |
492 | 491 |
} |
493 | 492 |
} |
494 | 493 |
|
495 |
// MAKE VIEWS BITS WORK *****************************************************/ |
|
494 |
/** |
|
495 |
* Implements hook_views_api(). |
|
496 |
*/ |
|
496 | 497 |
function advanced_forum_views_api() { |
497 | 498 |
return array( |
498 | 499 |
'api' => '3.0-alpha1', |
... | ... | |
500 | 501 |
); |
501 | 502 |
} |
502 | 503 |
|
503 |
// MAKE CTOOLS BITS WORK *****************************************************/ |
|
504 | 504 |
/** |
505 | 505 |
* Tell CTools about what plugins we support. |
506 | 506 |
*/ |
... | ... | |
514 | 514 |
} |
515 | 515 |
} |
516 | 516 |
|
517 |
/** |
|
518 |
* Implements hook_ctools_plugin_api(). |
|
519 |
*/ |
|
517 | 520 |
function advanced_forum_ctools_plugin_api($module, $api) { |
518 | 521 |
if ($module == 'page_manager' && $api = 'pages_default') { |
519 | 522 |
return array( |
... | ... | |
536 | 539 |
module_load_include('inc', 'advanced_forum', 'includes/mark-read'); |
537 | 540 |
|
538 | 541 |
// VIEWS RELATED GOODIES ******************************************************/ |
539 |
|
|
540 | 542 |
/** |
541 | 543 |
* Post render a view and replace any advanced forum tokens. |
542 | 544 |
*/ |
... | ... | |
557 | 559 |
// Replace the Author Pane token with the actual Author Pane. |
558 | 560 |
if (preg_match_all('/<!--post:author-pane-([\d]+)-->/us', $output, $matches)) { |
559 | 561 |
foreach ($matches[1] as $match => $uid) { |
560 |
$token = $matches[0][$match]; // This is the exact string that matched. |
|
562 |
// This is the exact string that matched. |
|
563 |
$token = $matches[0][$match]; |
|
561 | 564 |
if (!isset($tokens[$token])) { |
562 | 565 |
$account = user_load($uid); |
563 | 566 |
$tokens[$token] = theme('author_pane', array( |
... | ... | |
575 | 578 |
// Replace the Post edited token. |
576 | 579 |
if (preg_match_all('/<!--post:post-edited-([\d]+)-->/us', $output, $matches)) { |
577 | 580 |
foreach ($matches[1] as $match => $nid) { |
578 |
$token = $matches[0][$match]; // This is the exact string that matched. |
|
581 |
// This is the exact string that matched. |
|
582 |
$token = $matches[0][$match]; |
|
579 | 583 |
if (!isset($tokens[$token])) { |
580 | 584 |
if (user_access('view last edited notice')) { |
581 | 585 |
$sql = 'SELECT uid, log, timestamp FROM {node_revision} WHERE nid = %d ORDER BY timestamp DESC'; |
... | ... | |
597 | 601 |
// Replace the core Signature token. |
598 | 602 |
if (preg_match_all('/<!--post:signature-core-([\d]+)-->/us', $output, $matches)) { |
599 | 603 |
foreach ($matches[1] as $match => $uid) { |
600 |
$token = $matches[0][$match]; // This is the exact string that matched. |
|
604 |
// This is the exact string that matched. |
|
605 |
$token = $matches[0][$match]; |
|
601 | 606 |
if (!isset($tokens[$token])) { |
602 | 607 |
$account = user_load($uid); |
603 | 608 |
if ($account->signature) { |
... | ... | |
613 | 618 |
} |
614 | 619 |
|
615 | 620 |
/** |
616 |
* Display the "sort" widget. This is a specially hacked widget that only |
|
621 |
* Display the "sort" widget. |
|
622 |
* |
|
623 |
* This is a specially hacked widget that only |
|
617 | 624 |
* works with tablesorting. Tablesorting MUST be on for these widgets |
618 | 625 |
* to appear. |
619 | 626 |
*/ |
... | ... | |
630 | 637 |
return drupal_render($form); |
631 | 638 |
} |
632 | 639 |
|
640 |
/** |
|
641 |
* Sort form. |
|
642 |
*/ |
|
633 | 643 |
function advanced_forum_forum_topic_list_sort_form($form_state) { |
634 | 644 |
$view = views_get_view('advanced_forum_topic_list'); |
635 | 645 |
$view->set_display('default'); |
... | ... | |
701 | 711 |
} |
702 | 712 |
|
703 | 713 |
// STATISTICS *****************************************************************/ |
704 |
|
|
705 | 714 |
/** |
706 | 715 |
* Count total amount of forum threads. |
707 | 716 |
*/ |
... | ... | |
710 | 719 |
} |
711 | 720 |
|
712 | 721 |
/** |
713 |
* Counts total amount of replies. Initial posts are added to this total |
|
714 |
* in the calling function. |
|
722 |
* Counts total amount of replies. |
|
723 |
* |
|
724 |
* Initial posts are added to this total in the calling function. |
|
715 | 725 |
* |
716 |
* @param $delta |
|
726 |
* @param int|null $delta
|
|
717 | 727 |
* if not NULL, a numerical delta which should be applied to the count |
718 |
* @param $refresh
|
|
719 |
* @param $refresh |
|
728 |
* |
|
729 |
* @param bool $refresh
|
|
720 | 730 |
* TRUE if the stored count should be updated. |
721 |
* @return |
|
731 |
* |
|
732 |
* @return int |
|
722 | 733 |
* Total number of replies in the forum. |
723 | 734 |
*/ |
724 | 735 |
function advanced_forum_statistics_replies($delta = NULL, $refresh = FALSE) { |
... | ... | |
731 | 742 |
$total_replies = $cache->data; |
732 | 743 |
} |
733 | 744 |
|
734 |
|
|
735 | 745 |
if (!empty($delta) && is_numeric($delta)) { |
736 | 746 |
$total_replies += $delta; |
737 | 747 |
cache_set('advanced_forum_stats_replies', $total_replies); |
... | ... | |
751 | 761 |
* Return the newest X active (not blocked) users, linked to their profiles. |
752 | 762 |
*/ |
753 | 763 |
function advanced_forum_statistics_latest_users() { |
754 |
$number_to_fetch = 5; // @TODO: Make this a setting. |
|
764 |
// @TODO: Make this a setting. |
|
765 |
$number_to_fetch = 5; |
|
755 | 766 |
|
756 | 767 |
$query = db_select("users", "u") |
757 | 768 |
->fields("u", array("uid", "name")) |
... | ... | |
767 | 778 |
return $list; |
768 | 779 |
} |
769 | 780 |
|
781 |
/** |
|
782 |
* Returns session count. |
|
783 |
*/ |
|
770 | 784 |
function advanced_forum_session_count($anonymous = TRUE) { |
771 | 785 |
|
772 | 786 |
$interval = REQUEST_TIME - variable_get('user_block_seconds_online', 900); |
... | ... | |
808 | 822 |
return $list; |
809 | 823 |
} |
810 | 824 |
|
811 |
// CALCULATING LINKS - New, Last, Etc *****************************************/ |
|
812 |
|
|
825 |
/** |
|
826 |
* Calculating links - New, Last, Etc. |
|
827 |
*/ |
|
813 | 828 |
function advanced_forum_get_reply_link($node) { |
814 | 829 |
$reply_link = array(); |
815 | 830 |
|
... | ... | |
820 | 835 |
|
821 | 836 |
$allowed = FALSE; |
822 | 837 |
if (module_exists('forum_access')) { |
823 |
// get tid
|
|
838 |
// Get tid.
|
|
824 | 839 |
if (!empty($node->taxonomy_forums)) { |
825 | 840 |
reset($node->taxonomy_forums); |
826 | 841 |
$langcode = key($node->taxonomy_forums); |
... | ... | |
854 | 869 |
$reply_link['href'] = $_GET['q']; |
855 | 870 |
$reply_link['options']['fragment'] = $fragment; |
856 | 871 |
$current_page = isset($_GET['page']) ? $_GET['page'] : 0; |
857 |
if ($current_page) |
|
872 |
if ($current_page) {
|
|
858 | 873 |
$reply_link['options']['query'] = array('page' => $current_page); |
874 |
} |
|
859 | 875 |
|
860 | 876 |
$reply_link['class'] = 'reply-allowed'; |
861 | 877 |
$reply_link['title'] = t('Quick reply'); |
... | ... | |
877 | 893 |
/** |
878 | 894 |
* Get a link to the last post in a topic. |
879 | 895 |
* |
880 |
* @param $node |
|
896 |
* @param object $node
|
|
881 | 897 |
* Node object |
882 |
* @return |
|
898 |
* |
|
899 |
* @return string |
|
883 | 900 |
* Text linking to the last post in a topic. |
884 | 901 |
*/ |
885 | 902 |
function advanced_forum_last_post_link($node) { |
886 | 903 |
$last_comment_id = advanced_forum_last_post_in_topic($node->nid); |
887 | 904 |
// Return empty link if post doesn't have comments. |
888 |
if (empty($last_comment_id)) |
|
905 |
if (empty($last_comment_id)) {
|
|
889 | 906 |
return ''; |
907 |
} |
|
890 | 908 |
|
891 | 909 |
$last_page = advanced_forum_get_last_page($node); |
892 | 910 |
|
893 |
if ($last_page > 0) |
|
911 |
if ($last_page > 0) {
|
|
894 | 912 |
$query = array('page' => $last_page); |
913 |
} |
|
895 | 914 |
|
896 | 915 |
$options = array( |
897 | 916 |
'html' => TRUE, |
... | ... | |
910 | 929 |
/** |
911 | 930 |
* Returns a link directly to the first new post in a topic. |
912 | 931 |
* |
913 |
* @param $node |
|
932 |
* @param object $node
|
|
914 | 933 |
* Node object |
915 |
* @param $comment_count |
|
934 |
* |
|
935 |
* @param int $comment_count |
|
916 | 936 |
* Number of comments on passed node. |
917 |
* @return |
|
937 |
* |
|
938 |
* @return string |
|
918 | 939 |
* Link to the first unread post. |
919 | 940 |
*/ |
920 | 941 |
function advanced_forum_first_new_post_link($node, $comment_count) { |
... | ... | |
935 | 956 |
$options = array( |
936 | 957 |
'html' => TRUE, |
937 | 958 |
'query' => $page_of_first_new, |
938 |
'fragment' => "comment-$cid_of_first_new" |
|
959 |
'fragment' => "comment-$cid_of_first_new",
|
|
939 | 960 |
); |
940 | 961 |
|
941 | 962 |
return theme('advanced_forum_l', array( |
942 | 963 |
'text' => t('First unread'), |
943 | 964 |
'path' => "node/$nid", |
944 | 965 |
'options' => $options, |
945 |
'button_class' => 'large' |
|
966 |
'button_class' => 'large',
|
|
946 | 967 |
)); |
947 | 968 |
} |
948 | 969 |
} |
... | ... | |
963 | 984 |
static $number_new_for_node = array(); |
964 | 985 |
|
965 | 986 |
// $nid is empty if new topic in preview. |
966 |
if (empty($nid)) |
|
987 |
if (empty($nid)) {
|
|
967 | 988 |
return 0; |
989 |
} |
|
968 | 990 |
|
969 | 991 |
if (empty($number_new_for_node[$nid])) { |
970 | 992 |
global $user; |
971 | 993 |
|
972 | 994 |
$node = node_load($nid); |
973 | 995 |
|
974 |
// We must also check the forum post itself to see if we have viewed it |
|
975 |
$viewed = 0; // If not told otherwise, it has been viewed before |
|
996 |
// We must also check the forum post itself to see if we have viewed it. |
|
997 |
// If not told otherwise, it has been viewed before. |
|
998 |
$viewed = 0; |
|
976 | 999 |
if ($user->uid) { |
977 | 1000 |
$viewed = node_last_viewed($nid); |
978 | 1001 |
// Set it to 1 if it has not been viewed before. |
... | ... | |
988 | 1011 |
/** |
989 | 1012 |
* Get the comment id of the last post in a topic. |
990 | 1013 |
* |
991 |
* @param $node |
|
992 |
* Node object |
|
993 |
* @return |
|
1014 |
* @param int $nid |
|
1015 |
* Node id. |
|
1016 |
* |
|
1017 |
* @return int |
|
994 | 1018 |
* cid of last post. |
995 | 1019 |
*/ |
996 | 1020 |
function advanced_forum_last_post_in_topic($nid) { |
997 | 1021 |
// $nid is empty if new topic in preview. |
998 |
if (empty($nid)) |
|
1022 |
if (empty($nid)) {
|
|
999 | 1023 |
return NULL; |
1024 |
} |
|
1000 | 1025 |
|
1001 | 1026 |
$node = node_load($nid); |
1002 | 1027 |
|
1003 |
// Comment module version |
|
1028 |
// Comment module version.
|
|
1004 | 1029 |
$query = 'SELECT c.cid |
1005 | 1030 |
FROM {comment} c |
1006 | 1031 |
WHERE c.nid = :nid AND c.status = :status |
... | ... | |
1023 | 1048 |
/** |
1024 | 1049 |
* Returns the ID of the first unread comment. |
1025 | 1050 |
* |
1026 |
* @param $nid |
|
1051 |
* @param int $nid
|
|
1027 | 1052 |
* Node ID |
1028 |
* @param $timestamp |
|
1053 |
* |
|
1054 |
* @param int $timestamp |
|
1029 | 1055 |
* Date/time used to override when the user last viewed the node. |
1030 |
* @return |
|
1056 |
* |
|
1057 |
* @return int |
|
1031 | 1058 |
* Comment ID |
1032 | 1059 |
*/ |
1033 | 1060 |
function advanced_forum_first_new_comment($nid, $timestamp = 0) { |
... | ... | |
1040 | 1067 |
$timestamp = node_last_viewed($nid); |
1041 | 1068 |
} |
1042 | 1069 |
|
1043 |
// Set the timestamp to the limit if the node was last read past the cutoff |
|
1070 |
// Set the timestamp to the limit if the node was last read past the cutoff.
|
|
1044 | 1071 |
$timestamp = ($timestamp > NODE_NEW_LIMIT ? $timestamp : NODE_NEW_LIMIT); |
1045 | 1072 |
|
1046 | 1073 |
// Use the timestamp to retrieve the oldest new comment. |
... | ... | |
1059 | 1086 |
} |
1060 | 1087 |
|
1061 | 1088 |
// GENERAL UTILITY FUNCTIONS *************************************************/ |
1062 |
|
|
1063 | 1089 |
/** |
1064 | 1090 |
* Return an array of node types allowed in a given vocabulary or term ID. |
1065 | 1091 |
*/ |
... | ... | |
1087 | 1113 |
function advanced_forum_type_is_in_forum($node, $tid = 0) { |
1088 | 1114 |
$vid = (empty($vid)) ? variable_get('forum_nav_vocabulary', 0) : $vid; |
1089 | 1115 |
if (!empty($node->taxonomy_forums)) { |
1090 |
// Check for language used |
|
1116 |
// Check for language used.
|
|
1091 | 1117 |
if (!isset($node->taxonomy_forums[$node->language])) { |
1092 | 1118 |
$langcode = LANGUAGE_NONE; |
1093 | 1119 |
} |
... | ... | |
1099 | 1125 |
if (!isset($tforum['taxonomy_term'])) { |
1100 | 1126 |
continue; |
1101 | 1127 |
} |
1102 |
if (($tforum['taxonomy_term']->vid == $vid) || ($tforum['taxonomy_term']->tid == $tid)) |
|
1128 |
if (($tforum['taxonomy_term']->vid == $vid) || ($tforum['taxonomy_term']->tid == $tid)) {
|
|
1103 | 1129 |
return TRUE; |
1130 |
} |
|
1104 | 1131 |
} |
1105 | 1132 |
} |
1106 | 1133 |
return FALSE; |
... | ... | |
1206 | 1233 |
/** |
1207 | 1234 |
* Creates a pager to place on each multi-page topic of the topic listing page. |
1208 | 1235 |
* |
1209 |
* @param $max_pages_to_display |
|
1236 |
* @param int $max_pages_to_display
|
|
1210 | 1237 |
* Number of pages to include on the pager. |
1211 |
* @param $topic |
|
1238 |
* |
|
1239 |
* @param object $topic |
|
1212 | 1240 |
* Topic object to create a pager for. |
1213 |
* @return |
|
1241 |
* |
|
1242 |
* @return object |
|
1214 | 1243 |
* Object containing the linked pages ready assembly by the theme function. |
1215 | 1244 |
*/ |
1216 | 1245 |
function advanced_forum_create_topic_pager($max_pages_to_display, $topic) { |
... | ... | |
1222 | 1251 |
// first page because that doesn't have a query. |
1223 | 1252 |
$pager_array = array(); |
1224 | 1253 |
$current_display_page = 1; |
1254 |
// @codingStandardsIgnoreStart |
|
1225 | 1255 |
$pager_array[0] = l('1', "node/$topic->nid"); |
1256 |
// @codingStandardsIgnoreEnd |
|
1226 | 1257 |
|
1227 | 1258 |
// Find the ending point. The pager URL is always 1 less than |
1228 | 1259 |
// the number being displayed because the first page is 0. |
... | ... | |
1231 | 1262 |
|
1232 | 1263 |
// Add pages until we run out or until we hit the max to show. |
1233 | 1264 |
while (($current_display_page < $last_display_page) && ($current_display_page < $max_pages_to_display)) { |
1234 |
// Move to the next page |
|
1265 |
// Move to the next page.
|
|
1235 | 1266 |
$current_display_page++; |
1236 | 1267 |
|
1237 |
// The page number we link to is 1 less than what's displayed |
|
1268 |
// The page number we link to is 1 less than what's displayed.
|
|
1238 | 1269 |
$link_to_page = $current_display_page - 1; |
1239 | 1270 |
|
1240 |
// Add the link to the array |
|
1271 |
// Add the link to the array.
|
|
1241 | 1272 |
$pager_array[$link_to_page] = l($current_display_page, "node/$topic->nid", array('query' => array('page' => $link_to_page))); |
1242 | 1273 |
} |
1243 | 1274 |
|
1244 |
// Move to the next page |
|
1275 |
// Move to the next page.
|
|
1245 | 1276 |
$current_display_page++; |
1246 | 1277 |
|
1247 | 1278 |
if ($current_display_page == $last_display_page) { |
... | ... | |
1276 | 1307 |
} |
1277 | 1308 |
|
1278 | 1309 |
/** |
1279 |
* Create a drop down list of forum hierarchy |
|
1310 |
* Create a drop down list of forum hierarchy.
|
|
1280 | 1311 |
*/ |
1281 | 1312 |
function advanced_forum_forum_jump($tid = 0) { |
1282 | 1313 |
global $user; |
... | ... | |
1290 | 1321 |
$select[url("forum/" . $forum->tid)] = str_repeat("-", $forum->depth) . $forum->name; |
1291 | 1322 |
} |
1292 | 1323 |
} |
1293 |
else { |
|
1294 |
// nothing |
|
1295 |
} |
|
1296 | 1324 |
|
1297 | 1325 |
$options['choose'] = t("- Select a forum -"); |
1298 | 1326 |
|
... | ... | |
1302 | 1330 |
} |
1303 | 1331 |
|
1304 | 1332 |
/** |
1305 |
* Calculates the number of unread replies for each forum and returns the |
|
1306 |
* count for the requested forum. |
|
1333 |
* Calculates the number of unread replies for each forum and returns the count for the requested forum. |
|
1307 | 1334 |
*/ |
1308 | 1335 |
function advanced_forum_unread_replies_in_forum($tid, $uid) { |
1309 | 1336 |
static $result_cache = NULL; |
... | ... | |
1313 | 1340 |
|
1314 | 1341 |
$query = db_select("comment", "c"); |
1315 | 1342 |
$f_alias = $query->join("forum", "f", "c.nid = f.nid"); |
1316 |
//$n_alias = $query->join("node", "n", "f.vid = n.vid"); |
|
1317 | 1343 |
$h_alias = $query->leftJoin("history", "h", "c.nid = h.nid AND h.uid = :uid", array(":uid" => $uid)); |
1318 | 1344 |
$query->addExpression("COUNT(DISTINCT(c.cid))", "count"); |
1319 | 1345 |
$query->addField($f_alias, "tid"); |
... | ... | |
1382 | 1408 |
if (($index = array_search($post_id, $post_order[$node_id])) !== FALSE) { |
1383 | 1409 |
$post_position = $index; |
1384 | 1410 |
|
1385 |
// We need to add 2 because the array starts at 0 and also because the topic |
|
1386 |
// node is post #1 on display but is not included in the index. |
|
1387 |
$post_position = $post_position + 2; |
|
1411 |
$advanced_forum_styled_node_types = variable_get('advanced_forum_styled_node_types', array('forum')); |
|
1412 |
// We need to add 1 because the topic node is post #1 on display but is not included in the index. |
|
1413 |
if (in_array($node->type, $advanced_forum_styled_node_types)) { |
|
1414 |
$post_position = $post_position + 1; |
|
1415 |
} |
|
1388 | 1416 |
} |
1389 | 1417 |
} |
1390 | 1418 |
|
drupal7/sites/all/modules/advanced_forum/includes/advanced_forum_preprocess_comment.inc | ||
---|---|---|
5 | 5 |
* Holds the contents of a preprocess function moved into its own file |
6 | 6 |
* to ease memory requirements and having too much code in one file. |
7 | 7 |
*/ |
8 |
|
|
9 |
/** |
|
10 |
* Preprocess comment. |
|
11 |
*/ |
|
8 | 12 |
function _advanced_forum_preprocess_comment(&$variables) { |
9 | 13 |
/* Easy links to the comment and parent node */ |
10 | 14 |
$comment = $variables['comment']; |
... | ... | |
16 | 20 |
|
17 | 21 |
/* Determine the template file to use for the comment. */ |
18 | 22 |
if (arg(1) == 'reply' || arg(2) == 'edit') { |
19 |
// Use the preview version |
|
23 |
// Use the preview version.
|
|
20 | 24 |
advanced_forum_add_template_suggestions("post-preview", $variables); |
21 | 25 |
} |
22 | 26 |
else { |
23 |
// Use our combined node/comment template file |
|
27 |
// Use our combined node/comment template file.
|
|
24 | 28 |
advanced_forum_add_template_suggestions("post", $variables); |
25 | 29 |
} |
26 | 30 |
|
27 |
|
|
28 |
// Add in our classes overwriting existing. |
|
29 |
$variables['classes_array'] = array(); |
|
31 |
if (!variable_get('advanced_forum_keep_classes', FALSE) || !is_array($variables['classes_array'])) { |
|
32 |
// Add in our classes overwriting existing. |
|
33 |
$variables['classes_array'] = array(); |
|
34 |
} |
|
30 | 35 |
$variables['classes_array'][] = 'forum-post clearfix'; |
31 | 36 |
|
32 | 37 |
// Add the current language to the classes for image handling. |
... | ... | |
35 | 40 |
$variables['classes_array'][] = $language->language; |
36 | 41 |
} |
37 | 42 |
|
38 |
// Add the poster's UID |
|
43 |
// Add the poster's UID.
|
|
39 | 44 |
$variables['classes_array'][] = "posted-by-$comment->uid"; |
40 | 45 |
|
41 | 46 |
// Add class if the poster is the viewer. |
... | ... | |
49 | 54 |
$variables['classes_array'][] = "post-by-starter"; |
50 | 55 |
} |
51 | 56 |
|
52 |
// Set the post ID for theming / targetting |
|
57 |
// Set the post ID for theming / targetting.
|
|
53 | 58 |
$variables['post_id'] = "post-$comment->cid"; |
54 |
|
|
55 |
|
|
56 |
|
|
57 | 59 |
$num_comments = $node->comment_count; |
58 | 60 |
$posts_per_page = variable_get('comment_default_per_page_' . $node->type, 50); |
59 | 61 |
|
60 | 62 |
$page_number = !empty($_GET['page']) ? $_GET['page'] : 0; |
61 | 63 |
|
62 |
// page_number sanity check
|
|
63 |
if ($page_number > floor($num_comments / $posts_per_page)) |
|
64 |
// Page_number sanity check.
|
|
65 |
if ($page_number > floor($num_comments / $posts_per_page)) {
|
|
64 | 66 |
$page_number = floor($num_comments / $posts_per_page); |
67 |
} |
|
65 | 68 |
|
66 | 69 |
if (!$page_number) { |
67 | 70 |
$page_number = 0; |
68 | 71 |
} |
69 |
|
|
70 | 72 |
/* Linked post number */ |
71 | 73 |
if (!isset($post_number)) { |
72 | 74 |
static $post_number = 1; |
73 | 75 |
} |
74 |
|
|
75 |
// check if node type is forum
|
|
76 |
|
|
77 |
// Check if node type is forum.
|
|
76 | 78 |
$topic_id = advanced_forum_node_is_styled($variables['node']); |
77 | 79 |
$post_number_delta = ($topic_id) ? 1 : 0; |
78 |
|
|
79 | 80 |
$linktext = '#' . (($page_number * $posts_per_page) + $post_number + $post_number_delta); |
80 |
|
|
81 | 81 |
$post_number++; |
82 |
|
|
83 |
// Permalink |
|
84 |
// You can erase next 3 lines if you wish to use built-in Permalink.
|
|
85 |
// Template adjusted: $post_link -> $permalink
|
|
82 |
|
|
83 |
// Permalink.
|
|
84 |
// You can erase next 3 lines if you wish to use built-in Permalink. |
|
85 |
// Template adjusted: $post_link -> $permalink.
|
|
86 | 86 |
$uri = entity_uri('comment', $comment); |
87 | 87 |
$uri['options'] += array('attributes' => array('class' => array('permalink'), 'rel' => 'bookmark')); |
88 | 88 |
$variables['permalink'] = l($linktext, $uri['path'], $uri['options']); |
... | ... | |
98 | 98 |
if ($post_position > 0) { |
99 | 99 |
// Find the page the post is on. We need to compensate for the topic node |
100 | 100 |
// being #1 which puts an extra post on the first page but not on the rest. |
101 |
$page_number = floor(($post_position - 2) / $posts_per_page);
|
|
101 |
$page_number = floor(($post_position - 1) / $posts_per_page);
|
|
102 | 102 |
|
103 | 103 |
// Assemble the link. |
104 | 104 |
$fragment = 'comment-' . $comment->pid; |
105 | 105 |
|
106 |
if ($page_number) |
|
106 |
if ($page_number) {
|
|
107 | 107 |
$query = array('page' => $page_number); |
108 |
} |
|
108 | 109 |
|
109 | 110 |
$linktext = t("(Reply to #!post_position)", array('!post_position' => $post_position)); |
110 | 111 |
$linkpath = "node/$node->nid"; |
... | ... | |
114 | 115 |
|
115 | 116 |
/* Title */ |
116 | 117 |
if (variable_get('comment_subject_field_' . $node->type, 1) == 0) { |
117 |
// if comment titles are disabled, don't display it.
|
|
118 |
// If comment titles are disabled, don't display it.
|
|
118 | 119 |
$variables['title'] = ''; |
119 | 120 |
} |
120 | 121 |
else { |
... | ... | |
131 | 132 |
$variables['account']->email = empty($comment->email) ? "" : $comment->email; |
132 | 133 |
} |
133 | 134 |
else { |
134 |
// Load up the real user object |
|
135 |
// Load up the real user object.
|
|
135 | 136 |
$variables['account'] = user_load($comment->uid); |
136 | 137 |
} |
137 | 138 |
|
138 |
// Create the author pane |
|
139 |
// Create the author pane.
|
|
139 | 140 |
if (module_exists('author_pane')) { |
140 | 141 |
$variables['author_pane'] = theme('author_pane', array( |
141 | 142 |
'account' => $variables['account'], |
... | ... | |
152 | 153 |
/* Content */ |
153 | 154 |
// Helpful $content variable for templates. |
154 | 155 |
foreach (element_children($variables['elements']) as $key) { |
155 |
// Adjust content vriable to suit post template |
|
156 |
if ($key == 'comment_body') |
|
156 |
// Adjust content vriable to suit post template.
|
|
157 |
if ($key == 'comment_body') {
|
|
157 | 158 |
$variables['content']['body'] = $variables['elements'][$key]; |
158 |
else |
|
159 |
} |
|
160 |
else { |
|
159 | 161 |
$variables['content'][$key] = $variables['elements'][$key]; |
162 |
} |
|
160 | 163 |
} |
161 | 164 |
|
162 |
// Adjust comment timestamp to match node template |
|
165 |
// Adjust comment timestamp to match node template.
|
|
163 | 166 |
$variables['date'] = $variables['created']; |
164 | 167 |
|
165 | 168 |
/* Post edited */ |
166 | 169 |
$variables['post_edited'] = (isset($variables['comment_edited'])) ? $variables['comment_edited'] : ""; |
167 |
} |
|
170 |
} |
drupal7/sites/all/modules/advanced_forum/includes/advanced_forum_preprocess_forum_list.inc | ||
---|---|---|
5 | 5 |
* Holds the contents of a preprocess function moved into its own file |
6 | 6 |
* to ease memory requirements and having too much code in one file. |
7 | 7 |
*/ |
8 |
|
|
9 |
/** |
|
10 |
* Preprocess forum list. |
|
11 |
*/ |
|
8 | 12 |
function _advanced_forum_preprocess_forum_list(&$variables) { |
9 | 13 |
advanced_forum_add_template_suggestions("forum_list", $variables); |
10 | 14 |
|
11 |
// Added variable for default collapsed configuration |
|
15 |
// Added variable for default collapsed configuration.
|
|
12 | 16 |
$variables['collapsed_main_list'] = variable_get('advanced_forum_default_collapsed_list', array()); |
13 | 17 |
|
14 | 18 |
// Add needed items for the collapsible containers. |
... | ... | |
99 | 103 |
$table_counter = 0; |
100 | 104 |
} |
101 | 105 |
|
102 |
// workaround for container-less forums on main page
|
|
106 |
// Workaround for container-less forums on main page.
|
|
103 | 107 |
$depth_offset = 0; |
104 | 108 |
foreach ($items as $id => $item) { |
105 | 109 |
// Get a handle on the parent of this item. |
... | ... | |
179 | 183 |
// container. Start a new generic one. We need a tid so just grab |
180 | 184 |
// the tid of the current forum for it. |
181 | 185 |
$table_counter++; |
182 |
if (!isset($tables[$table_counter]['table_info'])) |
|
186 |
if (!isset($tables[$table_counter]['table_info'])) {
|
|
183 | 187 |
$tables[$table_counter]['table_info'] = new stdClass(); |
188 |
} |
|
184 | 189 |
$tables[$table_counter]['table_info']->name = t('Forums'); |
185 | 190 |
$tables[$table_counter]['table_info']->description = ''; |
186 | 191 |
$tables[$table_counter]['table_info']->tid = $item->tid; |
187 | 192 |
|
188 | 193 |
// Reset the striping. |
189 | 194 |
advanced_forum_stripe(TRUE); |
190 |
$depth_offset = 1; |
|
191 | 195 |
} |
196 |
$depth_offset = 1; |
|
192 | 197 |
|
193 | 198 |
// Set the variable to control the row striping. |
194 | 199 |
$item->zebra = advanced_forum_stripe(); |
... | ... | |
230 | 235 |
unset($variables['zebra']); |
231 | 236 |
} |
232 | 237 |
|
238 |
/** |
|
239 |
* Forum stripe. |
|
240 |
*/ |
|
233 | 241 |
function advanced_forum_stripe($reset = FALSE) { |
234 | 242 |
static $stripe = 'odd'; |
235 | 243 |
|
... | ... | |
362 | 370 |
unset($forum->last_post); |
363 | 371 |
$forum->last_post = theme('forum_submitted', array('topic' => $last_post)); |
364 | 372 |
|
365 |
// Display forum images using Field API |
|
373 |
// Display forum images using Field API.
|
|
366 | 374 |
$entity = entity_load('taxonomy_term', array($forum->tid)); |
367 | 375 |
$field_name = variable_get('advanced_forum_forum_image_field', ''); |
368 | 376 |
|
drupal7/sites/all/modules/advanced_forum/includes/advanced_forum_preprocess_forums.inc | ||
---|---|---|
6 | 6 |
* to ease memory requirements and having too much code in one file. |
7 | 7 |
*/ |
8 | 8 |
|
9 |
/** |
|
10 |
* Preprocess forum. |
|
11 |
*/ |
|
9 | 12 |
function _advanced_forum_preprocess_forums(&$variables) { |
10 | 13 |
$variables['forums_defined'] = count($variables['forums']) || count($variables['parents']); |
11 | 14 |
|
... | ... | |
39 | 42 |
$variables['forum_legend'] = theme('advanced_forum_forum_legend'); |
40 | 43 |
} |
41 | 44 |
else { |
42 |
// Grab the forum description and make it available to the template file |
|
45 |
// Grab the forum description and make it available to the template file.
|
|
43 | 46 |
$forum = taxonomy_term_load($tid); |
44 | 47 |
$variables['forum_description'] = $forum->description; |
45 | 48 |
|
drupal7/sites/all/modules/advanced_forum/includes/advanced_forum_preprocess_node.inc | ||
---|---|---|
6 | 6 |
* to ease memory requirements and having too much code in one file. |
7 | 7 |
*/ |
8 | 8 |
|
9 |
/** |
|
10 |
* Preprocess node. |
|
11 |
*/ |
|
9 | 12 |
function _advanced_forum_preprocess_node(&$variables) { |
10 | 13 |
/* Shortcut variables */ |
11 | 14 |
$node = $variables['node']; |
... | ... | |
16 | 19 |
// We send this to a special .tpl so people can adjust it to their needs. |
17 | 20 |
advanced_forum_add_template_suggestions("post-repeated", $variables); |
18 | 21 |
} |
19 |
elseif (arg(1) == 'reply' || (arg(0) == 'node' && arg(1) == 'add') || !empty($node->in_preview) ) {
|
|
22 |
elseif (arg(1) == 'reply' || (arg(0) == 'node' && arg(1) == 'add') || !empty($node->in_preview)) { |
|
20 | 23 |
// 'reply' deals with the first post being shown when adding a comment. |
21 | 24 |
// 'node/add' is when previewing a new forum post. |
22 | 25 |
advanced_forum_add_template_suggestions("post-preview", $variables); |
23 | 26 |
} |
24 | 27 |
else { |
25 |
// Use our combined node/comment template file |
|
28 |
// Use our combined node/comment template file.
|
|
26 | 29 |
advanced_forum_add_template_suggestions("post", $variables); |
27 | 30 |
} |
28 | 31 |
|
29 | 32 |
/* Topic header */ |
30 | 33 |
$variables['top_post'] = TRUE; |
31 | 34 |
|
32 |
// Build the topic header |
|
35 |
// Build the topic header.
|
|
33 | 36 |
$variables['topic_header'] = theme('advanced_forum_topic_header', array( |
34 | 37 |
'node' => $node, |
35 | 38 |
'comment_count' => isset($variables['comment_count']) ? $variables['comment_count'] : 0, |
36 | 39 |
)); |
37 | 40 |
|
38 |
|
|
39 |
// Add in our classes merging with existing. |
|
40 |
if (!is_array($variables['classes_array'])) { |
|
41 |
if (!variable_get('advanced_forum_keep_classes', FALSE) || !is_array($variables['classes_array'])) { |
|
42 |
// Add in our classes overwriting existing. |
|
41 | 43 |
$variables['classes_array'] = array(); |
42 | 44 |
} |
43 | 45 |
|
44 |
$variables['classes_array'] = array('forum-post clearfix');
|
|
46 |
$variables['classes_array'][] = 'forum-post clearfix';
|
|
45 | 47 |
|
46 | 48 |
// Add the current language to the classes for image handling. |
47 | 49 |
global $language; |
... | ... | |
49 | 51 |
$variables['classes_array'][] = $language->language; |
50 | 52 |
} |
51 | 53 |
|
52 |
// Add the poster's UID
|
|
54 |
// Add the poster's UID.
|
|
53 | 55 |
$variables['classes_array'][] = "posted-by-$node->uid"; |
54 | 56 |
|
55 | 57 |
/* Post ID */ |
56 |
// Set the post ID for theming / targetting
|
|
58 |
// Set the post ID for theming/targetting.
|
|
57 | 59 |
$variables['post_id'] = "post-$node->nid"; |
58 | 60 |
|
59 | 61 |
/* Linked post number */ |
... | ... | |
64 | 66 |
$page_number = !empty($_GET['page']) ? $_GET['page'] : 0; |
65 | 67 |
|
66 | 68 |
// If this is the topic starting node, we need to start off the numbering. |
67 |
// variable changed from post_link to permalink to match core variable |
|
69 |
// Variable changed from post_link to permalink to match core variable. |
|
70 |
// @codingStandardsIgnoreStart |
|
68 | 71 |
$variables['permalink'] = l('#1', "node/$node->nid"); |
69 |
|
|
72 |
// @codingStandardsIgnoreEnd |
|
70 | 73 |
|
71 | 74 |
/* In reply to */ |
72 | 75 |
$variables['in_reply_to'] = ""; |
... | ... | |
100 | 103 |
|
101 | 104 |
/* Signatures */ |
102 | 105 |
if (variable_get('user_signatures', 0)) { |
103 |
$variables['signature'] = '<!--post:signature-core-' . $node->uid . '-->';
|
|
106 |
$variables['signature'] = '<!--post:signature-core-' . $node->uid . '-->'; |
|
104 | 107 |
} |
105 | 108 |
|
106 | 109 |
/* User specific node theming class */ |
... | ... | |
126 | 129 |
$variables['post_edited'] = theme('advanced_forum_post_edited', array( |
127 | 130 |
'who' => $variables['revision_uid'], |
128 | 131 |
'when' => $variables['revision_timestamp'], |
129 |
'why' => $variables['log'] |
|
132 |
'why' => $variables['log'],
|
|
130 | 133 |
)); |
131 | 134 |
} |
132 | 135 |
|
drupal7/sites/all/modules/advanced_forum/includes/core-overrides.inc | ||
---|---|---|
14 | 14 |
$forum_term = advanced_forum_forum_load(0); |
15 | 15 |
} |
16 | 16 |
|
17 |
// Set tid for <root> container |
|
17 |
// Set tid for <root> container.
|
|
18 | 18 |
if (!isset($forum_term->tid)) { |
19 | 19 |
$forum_term->tid = 0; |
20 | 20 |
} |
... | ... | |
54 | 54 |
$title = $vocabulary->name; |
55 | 55 |
} |
56 | 56 |
|
57 |
|
|
58 | 57 |
if (!variable_get('advanced_forum_disable_breadcrumbs', FALSE)) { |
59 | 58 |
drupal_set_breadcrumb($breadcrumb); |
60 | 59 |
} |
... | ... | |
67 | 66 |
'parents' => $forum_term->parents, |
68 | 67 |
'tid' => $forum_term->tid, |
69 | 68 |
'sortby' => $sortby, |
70 |
'forums_per_page' => $forum_per_page |
|
69 |
'forums_per_page' => $forum_per_page,
|
|
71 | 70 |
)); |
72 | 71 |
} |
73 | 72 |
|
... | ... | |
76 | 75 |
* |
77 | 76 |
* This is copied from the forum module and adapted. |
78 | 77 |
* |
79 |
* @param $tid |
|
80 |
* (optional) Taxonomy ID of the forum, if not givin all forums will be returned. |
|
81 |
* @return |
|
78 |
* @param int|null $tid |
|
79 |
* (optional) Taxonomy ID of the forum, if not givin all forums will be returned. |
|
80 |
* |
|
81 |
* @return object |
|
82 | 82 |
* A tree of taxonomy objects, with the following additional properties: |
83 | 83 |
* - 'num_topics': Number of topics in the forum |
84 | 84 |
* - 'num_posts': Total number of posts in all topics |
... | ... | |
88 | 88 |
function advanced_forum_forum_load($tid = NULL) { |
89 | 89 |
$cache = &drupal_static(__FUNCTION__, array()); |
90 | 90 |
|
91 |
global $language; |
|
91 | 92 |
|
92 | 93 |
// Return a cached forum tree if available. |
93 | 94 |
if (empty($tid)) { |
... | ... | |
117 | 118 |
// If $tid is 0, create an empty object to hold the child terms. |
118 | 119 |
elseif ($tid === 0) { |
119 | 120 |
$forum_term = (object) array( |
120 |
'tid' => 0,
|
|
121 |
'tid' => 0, |
|
121 | 122 |
); |
122 | 123 |
} |
123 | 124 |
|
... | ... | |
137 | 138 |
$_forums = i18n_taxonomy_localize_terms($_forums); |
138 | 139 |
} |
139 | 140 |
|
140 |
if ($cached = cache_get('adv_forum_counts' . $tid, 'cache')) { |
|
141 |
if ($cached = cache_get('adv_forum_counts' . $tid . ':' . $language->language, 'cache')) {
|
|
141 | 142 |
if ($cached->expire > time()) { |
142 | 143 |
$counts = $cached->data; |
143 | 144 |
} |
... | ... | |
169 | 170 |
if (!empty($node_types)) { |
170 | 171 |
$query->condition('type', $node_types, 'IN'); |
171 | 172 |
} |
173 |
|
|
174 |
$query->condition('language', array(LANGUAGE_NONE, $language->language)); |
|
172 | 175 |
} |
173 | 176 |
|
174 | 177 |
$counts = $query |
... | ... | |
178 | 181 |
->addTag('node_access') |
179 | 182 |
->execute() |
180 | 183 |
->fetchAllAssoc('tid'); |
181 |
cache_set('adv_forum_counts' . $tid, $counts, 'cache', time() + 60*60); //1 hour |
|
184 |
// 1 hour. |
|
185 |
cache_set('adv_forum_counts' . $tid, $counts, 'cache', time() + 60 * 60); |
|
182 | 186 |
} |
183 | 187 |
|
184 |
// get last nodes with comments for subquery SELECT optimization
|
|
188 |
// Get last nodes with comments for subquery SELECT optimization.
|
|
185 | 189 |
$subquery = db_select('node_comment_statistics', 'lnsc') |
186 | 190 |
->fields('lnsc', array('nid')) |
187 | 191 |
->distinct() |
188 | 192 |
->orderBy('last_comment_timestamp', 'DESC') |
189 |
->range(0, 1000); // should be moved to options or additionally calculated elsewhere
|
|
190 |
|
|
193 |
->range(0, 1000); |
|
194 |
// Should be moved to options or additionally calculated elsewhere. |
|
191 | 195 |
foreach ($_forums as $forum) { |
192 | 196 |
// Determine if the child term is a container. |
193 | 197 |
if (in_array($forum->tid, variable_get('forum_containers', array()))) { |
... | ... | |
249 | 253 |
return $forum_term; |
250 | 254 |
} |
251 | 255 |
|
256 |
/** |
|
257 |
* Update parent post count. |
|
258 |
*/ |
|
252 | 259 |
function _advanced_forum_update_parent_post_count(&$forums, $forum) { |
253 | 260 |
foreach ($forum->parents as $parent_tid) { |
254 | 261 |
if (!empty($forums[$parent_tid])) { |
255 | 262 |
$forums[$parent_tid]->num_topics += $forum->num_topics; |
256 | 263 |
$forums[$parent_tid]->num_posts += $forum->num_posts; |
257 | 264 |
|
258 |
// recursive loop to update all parents
|
|
265 |
// Recursive loop to update all parents/
|
|
259 | 266 |
if (!empty($forums[$parent_tid]->parents)) { |
260 | 267 |
_advanced_forum_update_parent_post_count($forums, $forums[$parent_tid]); |
261 | 268 |
} |
... | ... | |
270 | 277 |
$term = taxonomy_term_load($tid); |
271 | 278 |
drupal_add_feed('taxonomy/term/' . $tid . '/feed', 'RSS - ' . check_plain($term->name)); |
272 | 279 |
|
273 |
// Views handles this page |
|
280 |
// Views handles this page.
|
|
274 | 281 |
$view = views_get_view('advanced_forum_topic_list'); |
275 | 282 |
$view->set_items_per_page($forum_per_page); |
276 | 283 |
$view->sort_form = $sort_form; |
277 | 284 |
|
278 | 285 |
return $view->preview('default', array($tid)); |
279 | 286 |
} |
280 |
|
drupal7/sites/all/modules/advanced_forum/includes/mark-read.inc | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
|
3 |
|
|
4 | 3 |
/** |
5 | 4 |
* @file |
6 | 5 |
* Holds functions relating to the Mark Forum/All Read functionality. |
... | ... | |
49 | 48 |
if (isset($tid)) { |
50 | 49 |
$query_node->condition('f.tid', $tid); |
51 | 50 |
} |
52 |
|
|
51 |
|
|
53 | 52 |
$query_node->condition('t.vid', $vid); |
54 | 53 |
$query_node->addField('n', 'nid'); |
55 | 54 |
// Select query objects are one-shot, so clone for INSERT below. |
... | ... | |
85 | 84 |
global $user; |
86 | 85 |
return user_access('access content') && $user->uid; |
87 | 86 |
} |
88 |
|
drupal7/sites/all/modules/advanced_forum/includes/panels/advanced_forum.pages_default.inc | ||
---|---|---|
25 | 25 |
} |
26 | 26 |
} |
27 | 27 |
} |
28 |
|
|
28 |
|
|
29 | 29 |
return $handlers; |
30 | 30 |
} |
drupal7/sites/all/modules/advanced_forum/includes/plugins.inc | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
|
3 |
|
|
4 | 3 |
/** |
5 | 4 |
* @file |
6 | 5 |
* Allows modules to contribute styles. |
7 | 6 |
*/ |
8 | 7 |
|
9 |
// ----------------------------------------------------------------------- |
|
10 |
// REQUEST FUNCTIONS |
|
11 |
|
|
12 | 8 |
/** |
13 |
* Fetch an advanced forum style plugin |
|
9 |
* Fetch an advanced forum style plugin.
|
|
14 | 10 |
* |
15 |
* @param $style |
|
11 |
* @param string $style
|
|
16 | 12 |
* Name of the style plugin |
17 | 13 |
* |
18 |
* @return |
|
14 |
* @return array
|
|
19 | 15 |
* An array with information about the requested style plugin. |
20 | 16 |
*/ |
21 | 17 |
function advanced_forum_get_style($style) { |
... | ... | |
25 | 21 |
/** |
26 | 22 |
* Collate information about all available advanced_forum styles. |
27 | 23 |
* |
28 |
* @return |
|
24 |
* @return array
|
|
29 | 25 |
* An array with information about the requested forum style. |
30 | 26 |
*/ |
31 | 27 |
function advanced_forum_get_styles() { |
Formats disponibles : Unified diff
Weekly update of contrib modules