function theme_flag_lists_list in Flag Lists 6
Same name and namespace in other branches
- 7.3 flag_lists.module \theme_flag_lists_list()
- 7 flag_lists.module \theme_flag_lists_list()
1 theme call to theme_flag_lists_list()
- flag_lists_block in ./
flag_lists.module - Implementation of hook_block().
File
- ./
flag_lists.module, line 604 - The Flag Lists module.
Code
function theme_flag_lists_list($node, $create = TRUE, $ops = TRUE, $use_flags = FALSE) {
// Make sure we have a node.
if (is_object($node) && user_access('create flag lists')) {
$content_type = $node->type;
$content_id = $node->nid;
}
elseif (arg(0) == 'node' && is_numeric(arg(1)) && is_null(arg(2)) && user_access('create flag lists')) {
$content_id = arg(1);
$content_type = db_result(db_query("SELECT type from {node} WHERE nid = %d", $content_id));
}
else {
return;
}
// Do we have a list template for this node type, or are we s
if (!flag_lists_template_exists($content_type) && !$use_flags) {
return;
}
global $user;
if ($flags = flag_lists_get_user_flags($content_type, $user, $use_flags)) {
// Build the list of lists for this node.
foreach ($flags as $flag) {
if ($flag->module == 'flag_lists') {
$action = _flag_lists_is_flagged($flag, $content_id, $user->uid, 0) ? 'unflag' : 'flag';
}
else {
$action = $flag
->is_flagged($content_id) ? 'unflag' : 'flag';
}
// Do we need the ops?
if ($ops && $flag->module == 'flag_lists') {
$ops_links = theme('flag_lists_ops', $flag);
$link = $flag
->theme($action, $content_id) . $ops_links;
}
else {
$link = $flag
->theme($action, $content_id);
}
// If it's a list, fix the link.
if ($flag->module == 'flag_lists') {
flag_lists_fix_link($link, $action);
}
$items[] = $link;
}
}
if ($create && flag_lists_template_exists($content_type)) {
$items[] = l(t('Make a new @name', array(
'@name' => variable_get('flag_lists_name', t('list')),
)), 'flags/lists/add/' . $content_type, array(
'query' => drupal_get_destination(),
));
}
// Return if nothing to display.
if (!$items) {
return;
}
drupal_add_css(drupal_get_path('module', 'flag_lists') . '/theme/flag_lists.css');
return theme('item_list', $items, NULL, 'ul', array(
'class' => 'flag-lists-links',
));
}