From 2b17b3a96693d74d81f212b330a5ea89c6db0c26 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 15 Dec 2004 21:19:42 +0000 Subject: - Patch #13907 by Neil: less ways to set the page title. * Less logic in theme code. * Encourages use of the menu system. * Easier to find where a title or breadcrumb comes from in other people's code because there are less places to look. Look in menu and then grep for the appropriate set function. Looking for calls to theme_page() is hard because there are too many of them. * Very slightly more efficient. --- modules/comment/comment.module | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'modules/comment/comment.module') diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 6822fd8f4..67197bbdb 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -124,7 +124,7 @@ function comment_menu($may_cache) { $access = user_access('post comments'); $items[] = array('path' => 'comment/reply', 'title' => t('reply to comment'), 'callback' => 'comment_reply', 'access' => $access, 'type' => MENU_CALLBACK); - $items[] = array('path' => 'comment/edit', 'title' => t('edit your comment'), + $items[] = array('path' => 'comment/edit', 'title' => t('edit comment'), 'callback' => 'comment_edit', 'access' => $access, 'type' => MENU_CALLBACK); $items[] = array('path' => 'comment', 'title' => t('reply to comment'), @@ -341,7 +341,10 @@ function comment_edit($cid) { $comment = drupal_unpack($comment); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; if (comment_access('edit', $comment)) { - print theme('page', comment_preview(object2array($comment)), t('Edit comment')); + print theme('page', comment_preview(object2array($comment))); + } + else { + drupal_access_denied(); } } @@ -356,13 +359,15 @@ function comment_reply($nid, $pid = NULL) { if ($_POST['op'] == t('Post comment')) { $edit = $_POST['edit']; comment_validate_form($edit); - print theme('page', comment_post($edit), t('Post comment')); + drupal_set_title(t('Post comment')); + print theme('page', comment_post($edit)); return; } else if ($_POST['op'] == t('Preview comment')) { $edit = $_POST['edit']; comment_validate_form($edit); - print theme('page', comment_preview($edit), t('Preview comment')); + drupal_set_title(t('Preview comment')); + print theme('page', comment_preview($edit)); return; } @@ -397,7 +402,8 @@ function comment_reply($nid, $pid = NULL) { $output .= theme('box', t('Reply'), t('You are not authorized to view comments.')); } - print theme('page', $output, t('Add new comment')); + drupal_set_title(t('Add new comment')); + print theme('page', $output); } function comment_validate_form($edit) { -- cgit v1.2.3