function commons_groups_group_contributors_count_topics in Drupal Commons 7.3
1 call to commons_groups_group_contributors_count_topics()
- commons_groups_tokens in modules/
commons/ commons_groups/ commons_groups.module - Implements hook_tokens().
File
- modules/
commons/ commons_groups/ commons_groups.module, line 287
Code
function commons_groups_group_contributors_count_topics($group) {
// Format the count of contributors.
$output = '';
$view = views_get_view('commons_contributors_group');
if (!empty($view)) {
$view
->set_display('panel_pane_1');
$view
->set_arguments(array(
$group->nid,
));
$view->get_total_rows = TRUE;
$view
->execute();
// If there are no contributors with avatars, return an empty string
// rather than displaying '0 contributors'.
if (empty($view->total_rows)) {
return '';
}
$contributors_count = $view->total_rows;
$output .= l(format_plural($contributors_count, '1 contributor', '@count contributors'), 'node/' . $group->nid . '/contributors');
}
// Format the list of topics:
if (!empty($group->field_topics[LANGUAGE_NONE])) {
foreach ($group->field_topics[LANGUAGE_NONE] as $item) {
$tids[] = $item['tid'];
}
$topics = taxonomy_term_load_multiple($tids);
$topics_text = ' discussing the @topics ';
$t_args = array(
'@topics' => format_plural(count($topics), 'topic', 'topics'),
);
foreach ($topics as $topic) {
$topics_text .= '!topic-' . $topic->tid;
if ($topic == end($topics)) {
$topics_text .= '.';
}
else {
$topics_text .= ', ';
}
$t_args['!topic-' . $topic->tid] = l(t($topic->name), 'taxonomy/term/' . $topic->tid);
}
$output .= t($topics_text, $t_args);
}
return $output;
}