function _vud_term_generate_table in Vote Up/Down 7
Same name and namespace in other branches
- 6.3 vud_term/vud_term.module \_vud_term_generate_table()
- 6.2 vud_term/vud_term.module \_vud_term_generate_table()
Function to generate the voting table.
2 calls to _vud_term_generate_table()
- vud_term_handler_field_widget::render in vud_term/
views/ vud_term_handler_field_widget.inc - Render the field.
- vud_term_node_view in vud_term/
vud_term.module - Implementation of hook_node_view().
File
- vud_term/
vud_term.module, line 109 - Adds a voting widget to terms.
Code
function _vud_term_generate_table(&$node) {
$widget = variable_get('vud_term_widget', 'plain');
$header = array();
$rows = array();
foreach ($node->taxonomy as $term => $tdetails) {
$entity_id = $tdetails->tid;
$tag = "n{$node->nid}";
$reset_token = drupal_get_token("votereset/term/{$entity_id}/{$tag}");
if (variable_get('vud_term_reset', 0) && user_access('reset vote up/down votes')) {
$header = array(
array(
'data' => t('Term'),
),
array(
'data' => t('Description'),
),
array(
'data' => t('Vote'),
),
array(
'data' => t('Score'),
),
array(
'data' => t('Reset'),
),
);
$rows[] = array(
check_plain($tdetails->name),
check_plain($tdetails->description),
theme('vud_widget', array(
'entity_id' => $entity_id,
'type' => 'term',
'tag' => $tag,
'widget_theme' => $widget,
)),
"<span id=\"total-votes-term-{$entity_id}\">" . _vud_term_get_row_votes($entity_id, $tag) . '</span>',
l('Reset your vote', "votereset/term/{$entity_id}/{$tag}/{$reset_token}"),
);
}
else {
$header = array(
array(
'data' => t('Term'),
),
array(
'data' => t('Description'),
),
array(
'data' => t('Vote'),
),
array(
'data' => t('Score'),
),
);
$rows[] = array(
check_plain($tdetails->name),
check_plain($tdetails->description),
theme('vud_widget', array(
'entity_id' => $entity_id,
'type' => 'term',
'tag' => $tag,
'widget_theme' => $widget,
)),
"<span id=\"total-votes-term-{$entity_id}\">" . _vud_term_get_row_votes($entity_id, $tag) . '</span>',
);
}
}
$node->content['vud_term_show_table'] = array(
'#markup' => theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'class' => 'vud-term-table',
'id' => "term-table-{$node->nid}",
),
)),
'#weight' => 0,
);
}