Commit 9e373e76 authored by webchick's avatar webchick

#625460 by sun: Add input format to taxonomy term descriptions.

parent 35ff7005
......@@ -614,6 +614,7 @@ function taxonomy_form_term($form, &$form_state, $edit = array(), $vocabulary =
$edit += array(
'name' => '',
'description' => '',
'format' => filter_default_format(),
'vocabulary_machine_name' => $vocabulary->machine_name,
'tid' => NULL,
'weight' => 0,
......@@ -653,7 +654,9 @@ function taxonomy_form_term($form, &$form_state, $edit = array(), $vocabulary =
'#type' => 'textarea',
'#title' => t('Description'),
'#default_value' => $edit['description'],
'#description' => t('A description of the term. To be displayed on taxonomy/term pages and RSS feeds.'));
'#description' => t('A description of the term. To be displayed on taxonomy/term pages and RSS feeds.'),
'#text_format' => $edit['format'],
);
$form['vocabulary_machine_name'] = array(
'#type' => 'textfield',
......@@ -768,6 +771,10 @@ function taxonomy_form_term_submit($form, &$form_state) {
return;
}
// Massage #text_format.
$form_state['values']['format'] = $form_state['values']['description_format'];
unset($form_state['values']['description_format']);
$term = taxonomy_form_term_submit_builder($form, $form_state);
$status = taxonomy_term_save($term);
......
......@@ -50,6 +50,13 @@ function taxonomy_schema() {
'description' => 'A description of the term.',
'translatable' => TRUE,
),
'format' => array(
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
'default' => 0,
'description' => 'The {filter_format}.format of the description.',
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
......@@ -407,3 +414,17 @@ function taxonomy_update_7005(&$sandbox) {
db_drop_table('taxonomy_term_node');
}
}
/**
* Add vocabulary machine_name column.
*/
function taxonomy_update_7006() {
db_add_field('taxonomy_term_data', 'format', array(
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
'default' => 0,
'description' => 'The {filter_format}.format of the description.',
));
}
......@@ -33,14 +33,12 @@ function taxonomy_term_page($term) {
field_attach_prepare_view('taxonomy_term', array($term->tid => $term), 'full');
$build = array();
$build += field_attach_view('taxonomy_term', $term);
if (!empty($term->description)) {
$build['term_description'] = array(
'#markup' => filter_xss_admin($term->description),
'#weight' => -1,
'#prefix' => '<div class="taxonomy-term-description">',
'#suffix' => '</div>',
);
}
$build['term_description'] = array(
'#markup' => check_markup($term->description, $term->format, '', TRUE),
'#weight' => -1,
'#prefix' => '<div class="taxonomy-term-description">',
'#suffix' => '</div>',
);
if ($nids = taxonomy_select_nodes($term->tid, TRUE, variable_get('default_nodes_main', 10))) {
$nodes = node_load_multiple($nids);
$build += node_build_multiple($nodes);
......@@ -69,8 +67,8 @@ function taxonomy_term_feed($term) {
$channel['link'] = url('taxonomy/term/' . $term->tid, array('absolute' => TRUE));
$channel['title'] = variable_get('site_name', 'Drupal') . ' - ' . $term->name;
// Only display the description if we have a single term, to avoid clutter and confusion.
// HTML will be removed from feed description, so no need to filter here.
$channel['description'] = $term->description;
// HTML will be removed from feed description.
$channel['description'] = check_markup($term->description, $term->format, '', TRUE);
$nids = taxonomy_select_nodes($term->tid, FALSE, variable_get('feed_default_items', 10));
node_feed($nids, $channel);
......
......@@ -115,7 +115,7 @@ function taxonomy_tokens($type, $tokens, array $data = array(), array $options =
break;
case 'description':
$replacements[$original] = $sanitize ? filter_xss($term->description) : $term->description;
$replacements[$original] = $sanitize ? check_markup($term->description, $term->format, '', TRUE) : $term->description;
break;
case 'url':
......
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