| Versionen | |
|---|---|
| drupal6 – drupal7 | comment_admin_overview($type = 'new', $arg) |
Form builder; Builds the comment overview form for the admin.
see comment_admin_overview_validate()
$type Not used.
$arg Current path's fourth component deciding the form type (Published comments/Approval queue).
The form structure.
comment_admin_overview_submit()
theme_comment_admin_overview()
modules/
<?php
function comment_admin_overview($type = 'new', $arg) {
// Build an 'Update options' form.
$form['options'] = array(
'#type' => 'fieldset',
'#title' => t('Update options'),
'#prefix' => '<div class="container-inline">',
'#suffix' => '</div>',
);
$options = array();
foreach (comment_operations($arg == 'approval' ? 'publish' : 'unpublish') as $key => $value) {
$options[$key] = $value[0];
}
$form['options']['operation'] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => 'publish',
);
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
);
// Load the comments that need to be displayed.
$status = ($arg == 'approval') ? COMMENT_NOT_PUBLISHED : COMMENT_PUBLISHED;
$header = array(
'subject' => array('data' => t('Subject'), 'field' => 'subject'),
'author' => array('data' => t('Author'), 'field' => 'name'),
'posted_in' => array('data' => t('Posted in'), 'field' => 'node_title'),
'time' => array('data' => t('Time'), 'field' => 'timestamp', 'sort' => 'desc'),
'operations' => array('data' => t('Operations')),
);
$query = db_select('comment', 'c');
$query->join('users', 'u', 'u.uid = c.uid');
$query->join('node', 'n', 'n.nid = c.nid');
$query->addField('u', 'name', 'registered_name');
$query->addField('n', 'title', 'node_title');
$query
->fields('c', array('subject', 'nid', 'cid', 'comment', 'timestamp', 'status', 'name', 'homepage'))
->fields('u', array('uid'))
->condition('c.status', $status)
->extend('PagerDefault')->extend('TableSort')
->limit(50)
->orderByHeader($header);
$result = $query->execute();
// Build a table listing the appropriate comments.
$options = array();
$destination = drupal_get_destination();
foreach ($result as $comment) {
$options[$comment->cid] = array(
'subject' => l($comment->subject, 'node/' . $comment->nid, array('attributes' => array('title' => truncate_utf8($comment->comment, 128)), 'fragment' => 'comment-' . $comment->cid)),
'author' => theme('username', $comment),
'posted_in' => l($comment->node_title, 'node/' . $comment->nid),
'time' => format_date($comment->timestamp, 'small'),
'operations' => l(t('edit'), 'comment/edit/' . $comment->cid, array('query' => $destination)),
);
}
$form['comments'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No comments available.'),
);
$form['pager'] = array(
'#markup' => theme('pager', NULL)
);
return $form;
}
?>
Kommentare
Kommentar hinzufügen