? 506658_customizable_text_tokens.patch Index: talk.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/talk/Attic/talk.install,v retrieving revision 1.1.2.2 diff -u -p -r1.1.2.2 talk.install --- talk.install 10 Apr 2009 15:58:35 -0000 1.1.2.2 +++ talk.install 6 Jul 2009 01:50:33 -0000 @@ -8,4 +8,17 @@ function talk_uninstall() { variable_del('talk_title'); $result = db_query("DELETE FROM {variable} WHERE name LIKE 'comment_talk_%%'"); cache_clear_all('variables', 'cache'); +} + +/** + * Provide 3 different settings instead of the one. Default to the one. + */ +function talk_update_1() { + $default = variable_get('talk_title', t('Talk')); + variable_set('talk_tab', $default); + variable_set('talk_page', $default); + variable_set('talk_link', $default); + variable_del('talk_title'); + + return array(array('success' => TRUE, 'query' => 'Your Talk module settings have been updated automatically to support customizable strings. You may want to configure them further at Administer > Site configuration > Talk page.')); } \ No newline at end of file Index: talk.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/talk/talk.module,v retrieving revision 1.6.2.5 diff -u -p -r1.6.2.5 talk.module --- talk.module 3 May 2009 19:39:17 -0000 1.6.2.5 +++ talk.module 6 Jul 2009 01:50:33 -0000 @@ -24,6 +24,7 @@ function talk_menu() { $items = array(); $items['node/%node/talk'] = array( 'title callback' => 'talk_title', + 'title arguments' => array(1), 'page callback' => 'talk_handle', 'page arguments' => array(1), 'access callback' => '_talk_access', @@ -53,23 +54,51 @@ function _talk_access($node) { */ function talk_admin_form() { $form = array(); - $form['talk_title'] = array( + $form['talk_page'] = array( '#type' => 'textfield', '#title' => t('Title of the "talk" page'), - '#default_value' => talk_title(), + '#default_value' => talk_title(NULL, 'page'), + '#description' => t('If token is enabled you can use tokens like [title] or [nid]') ); + $form['talk_link'] = array( + '#type' => 'textfield', + '#title' => t('Link from the node "links" to the "talk" page'), + '#default_value' => talk_title(NULL, 'link'), + '#description' => t('If token is enabled you can use tokens like [title] or [nid]. Leave blank to disable.') + ); + $form['talk_tab'] = array( + '#type' => 'textfield', + '#title' => t('Link from the node "tab" to the "talk" page'), + '#default_value' => talk_title(NULL, 'tab'), + '#description' => t('If token is enabled you can use tokens like [title] or [nid].') + ); + return system_settings_form($form); } -function talk_title() { - return variable_get('talk_title', t('Talk')); +/** + * Provide an appropriate title for the context. + * + * @param object $node + * Optional node object. + * @param string $type + * Optional string for context: tab, page, link. + * @return string + */ +function talk_title($node = NULL, $type = 'tab') { + $title = variable_get('talk_'. $type, t('Talk')); + if (module_exists('token') && isset($node->nid)) { + global $user; + $title = token_replace_multiple($title, array('global' => NULL, 'user' => $user, 'node' => $node)); + } + return check_plain($title); } /** * Menu callback for talk page. */ function talk_handle($node) { - drupal_set_title(t('@title page for @node', array('@title' => talk_title(), '@node' => $node->title))); + drupal_set_title(talk_title($node, 'page')); $add_comments = _talk_node_comment_value($node) == COMMENT_NODE_READ_WRITE && user_access('post comments'); return theme('talkpage', $node, $add_comments); } @@ -98,10 +127,13 @@ function talk_link($type, $node = NULL, if ($type == 'node' && talk_activated($node->type) && user_access('access comments') && _talk_node_comment_value($node)) { $result = array(); if ($node->comment_count) { - $result['comment_comments'] = array( - 'title' => t('@title page (@nr comments)', array('@nr' => $node->comment_count, '@title' => talk_title())), - 'href' => 'node/'. $node->nid .'/talk', - ); + $title = talk_title($node, 'link'); + if (!empty($title)) { + $result['comment_comments'] = array( + 'title' => $title, + 'href' => 'node/'. $node->nid .'/talk', + ); + } } if (_talk_node_comment_value($node) == COMMENT_NODE_READ_WRITE) { $result['comment_add'] = array( @@ -141,7 +173,7 @@ function talk_comment($a1, $op) { $_REQUEST['destination'] = 'node/'. $a1['nid'] .'/talk'; } } -} +} /** * Is talk page option activated for node tpye? */ @@ -155,7 +187,7 @@ function talk_activated($node_type) { function _talk_node_comment_value(&$node) { return isset($node->comment_original_value) ? $node->comment_original_value : $node->comment; } - + /** * Implementation of hook_theme(). */ @@ -177,10 +209,10 @@ function talk_theme() { * Boolean which indicates if adding comments is allowed for current user. * @ingroup themeable */ -function template_preprocess_talkpage(&$variables) { +function talk_preprocess_talkpage(&$variables) { $add_comments = $variables['add_comments']; $node = $variables['node']; - $variables['title'] = talk_title(); + $variables['title'] = talk_title($node, 'page'); $comment_link = ''; if ($add_comments) { if (variable_get('comment_form_location_'. $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {