Commit 32c34106 authored by webchick's avatar webchick
Browse files

#606608 follow-up by Gábor Hojtsy and sun: Go back to numeric placeholders for...

#606608 follow-up by Gábor Hojtsy and sun: Go back to numeric placeholders for comment menu paths for performance.
parent 424cc9bb
...@@ -233,6 +233,16 @@ function comment_multiple_delete_confirm_submit($form, &$form_state) { ...@@ -233,6 +233,16 @@ function comment_multiple_delete_confirm_submit($form, &$form_state) {
$form_state['redirect'] = 'admin/content/comment'; $form_state['redirect'] = 'admin/content/comment';
} }
/**
* Page callback for comment deletions.
*/
function comment_confirm_delete_page($cid) {
if ($comment = comment_load($cid)) {
return drupal_get_form('comment_confirm_delete', $comment);
}
return MENU_NOT_FOUND;
}
/** /**
* Form builder; Builds the confirmation form for deleting a single comment. * Form builder; Builds the confirmation form for deleting a single comment.
* *
......
...@@ -233,45 +233,44 @@ function comment_menu() { ...@@ -233,45 +233,44 @@ function comment_menu() {
'access arguments' => array('administer comments'), 'access arguments' => array('administer comments'),
'type' => MENU_LOCAL_TASK, 'type' => MENU_LOCAL_TASK,
); );
$items['comment/%comment'] = array( $items['comment/%'] = array(
'title' => 'Comment permalink', 'title' => 'Comment permalink',
'page callback' => 'comment_permalink', 'page callback' => 'comment_permalink',
'page arguments' => array(1), 'page arguments' => array(1),
'access arguments' => array('access comments'), 'access arguments' => array('access comments'),
'type' => MENU_CALLBACK, 'type' => MENU_CALLBACK,
); );
$items['comment/%comment/view'] = array( $items['comment/%/view'] = array(
'title' => 'View comment', 'title' => 'View comment',
'type' => MENU_DEFAULT_LOCAL_TASK, 'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10, 'weight' => -10,
); );
// Every other comment path uses %, but this one loads the comment directly,
// so we don't end up loading it twice (in the page and access callback).
$items['comment/%comment/edit'] = array( $items['comment/%comment/edit'] = array(
'title' => 'Edit', 'title' => 'Edit',
'page callback' => 'drupal_get_form', 'page callback' => 'comment_edit_page',
'page arguments' => array('comment_form', 1), 'page arguments' => array(1),
'access callback' => 'comment_access', 'access callback' => 'comment_access',
'access arguments' => array('edit', 1), 'access arguments' => array('edit', 1),
'type' => MENU_LOCAL_TASK, 'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'weight' => 0, 'weight' => 0,
); );
$items['comment/%comment/approve'] = array( $items['comment/%/approve'] = array(
'title' => 'Approve', 'title' => 'Approve',
'page callback' => 'comment_approve', 'page callback' => 'comment_approve',
'page arguments' => array(1), 'page arguments' => array(1),
'access arguments' => array('administer comments'), 'access arguments' => array('administer comments'),
'type' => MENU_LOCAL_TASK, 'type' => MENU_CALLBACK,
'context' => MENU_CONTEXT_INLINE,
'file' => 'comment.pages.inc', 'file' => 'comment.pages.inc',
'weight' => 1, 'weight' => 1,
); );
$items['comment/%comment/delete'] = array( $items['comment/%/delete'] = array(
'title' => 'Delete', 'title' => 'Delete',
'page callback' => 'drupal_get_form', 'page callback' => 'comment_confirm_delete_page',
'page arguments' => array('comment_confirm_delete', 1), 'page arguments' => array(1),
'access arguments' => array('administer comments'), 'access arguments' => array('administer comments'),
'type' => MENU_LOCAL_TASK, 'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'file' => 'comment.admin.inc', 'file' => 'comment.admin.inc',
'weight' => 2, 'weight' => 2,
); );
...@@ -437,14 +436,13 @@ function comment_block_view($delta = '') { ...@@ -437,14 +436,13 @@ function comment_block_view($delta = '') {
* calculates the page number based on current comment settings and returns * calculates the page number based on current comment settings and returns
* the full comment view with the pager set dynamically. * the full comment view with the pager set dynamically.
* *
* @param $comment * @param $cid
* A comment object. * A comment identifier.
* @return * @return
* The comment listing set to the page on which the comment appears. * The comment listing set to the page on which the comment appears.
*/ */
function comment_permalink($comment) { function comment_permalink($cid) {
$node = node_load($comment->nid); if (($comment = comment_load($cid)) && ($node = node_load($comment->nid))) {
if ($node && $comment) {
// Find the current display page for this comment. // Find the current display page for this comment.
$page = comment_get_display_page($comment->cid, $node->type); $page = comment_get_display_page($comment->cid, $node->type);
...@@ -1717,6 +1715,14 @@ function comment_get_display_page($cid, $node_type) { ...@@ -1717,6 +1715,14 @@ function comment_get_display_page($cid, $node_type) {
return floor($ordinal / $comments_per_page); return floor($ordinal / $comments_per_page);
} }
/**
* Page callback for comment editing.
*/
function comment_edit_page($comment) {
drupal_set_title(t('Edit comment %comment', array('%comment' => $comment->subject)), PASS_THROUGH);
return drupal_get_form('comment_form', $comment);
}
/** /**
* Generate the basic commenting form, for appending to a node or display on a separate page. * Generate the basic commenting form, for appending to a node or display on a separate page.
* *
......
...@@ -103,13 +103,16 @@ function comment_reply($node, $pid = NULL) { ...@@ -103,13 +103,16 @@ function comment_reply($node, $pid = NULL) {
/** /**
* Menu callback; publish specified comment. * Menu callback; publish specified comment.
* *
* @param $comment * @param $cid
* A comment object. * A comment identifier.
*/ */
function comment_approve($comment) { function comment_approve($cid) {
$comment->status = COMMENT_PUBLISHED; if ($comment = comment_load($cid)) {
comment_save($comment); $comment->status = COMMENT_PUBLISHED;
comment_save($comment);
drupal_set_message(t('Comment approved.')); drupal_set_message(t('Comment approved.'));
drupal_goto('node/' . $comment->nid); drupal_goto('node/' . $comment->nid);
}
return MENU_NOT_FOUND;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment