Révision 13c3c9b4
Ajouté par Assos Assos il y a environ 9 ans
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 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules