FINAL suepr merge step : added all modules to this super repos
This commit is contained in:
111
sites/all/modules/contrib/content/diff/includes/file.inc
Normal file
111
sites/all/modules/contrib/content/diff/includes/file.inc
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide diff field functions for the file module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Diff field callback for preloading file entities.
|
||||
*/
|
||||
function file_field_diff_view_prepare(&$old_items, &$new_items, $context) {
|
||||
$fids = array();
|
||||
foreach (array_merge_recursive($old_items, $new_items) as $info) {
|
||||
$fids[$info['fid']] = $info['fid'];
|
||||
}
|
||||
$files = file_load_multiple($fids);
|
||||
|
||||
foreach ($old_items as $delta => $info) {
|
||||
$old_items[$delta]['file'] = isset($files[$info['fid']]) ? $files[$info['fid']] : NULL;
|
||||
}
|
||||
foreach ($new_items as $delta => $info) {
|
||||
$new_items[$delta]['file'] = isset($files[$info['fid']]) ? $files[$info['fid']] : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Diff field callback for parsing file field comparative values.
|
||||
*/
|
||||
function file_field_diff_view($items, $context) {
|
||||
$field = $context['field'];
|
||||
$instance = $context['instance'];
|
||||
$settings = $context['settings'];
|
||||
|
||||
$diff_items = array();
|
||||
foreach ($items as $delta => $item) {
|
||||
if (isset($item['file'])) {
|
||||
$output = array();
|
||||
|
||||
// We populate as much as possible to allow the best flexability in any
|
||||
// string overrides.
|
||||
$t_args = array();
|
||||
foreach ($item as $key => $value) {
|
||||
if (is_scalar($value)) {
|
||||
$t_args['!' . $key] = $value;
|
||||
}
|
||||
}
|
||||
// Some states do not have the file properties in the item, so put these
|
||||
// out of the main file object.
|
||||
if (!empty($item['file'])) {
|
||||
$file_values = (array) $item['file'];
|
||||
foreach ($file_values as $key => $value) {
|
||||
if (is_scalar($value) && !isset($t_args['!' . $key])) {
|
||||
$t_args['!' . $key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output['file'] = t('File: !filename', $t_args);
|
||||
if ($settings['compare_description_field'] && !empty($instance['settings']['description_field'])) {
|
||||
if (!empty($item['description'])) {
|
||||
$output['description'] = t('Description: !description', $t_args);
|
||||
}
|
||||
}
|
||||
if ($settings['show_id']) {
|
||||
$output['fid'] = t('File ID: !fid', $t_args);
|
||||
}
|
||||
if ($settings['compare_display_field'] && !empty($field['settings']['display_field'])) {
|
||||
$output['display'] = $item['display'] ? t('Displayed') : t('Hidden');
|
||||
}
|
||||
$diff_items[$delta] = implode('; ', $output);
|
||||
}
|
||||
}
|
||||
|
||||
return $diff_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide default field comparison options.
|
||||
*/
|
||||
function file_field_diff_default_options($field_type) {
|
||||
return array(
|
||||
'show_id' => 0,
|
||||
'compare_display_field' => 0,
|
||||
'compare_description_field' => 0,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a form for setting the field comparison options.
|
||||
*/
|
||||
function file_field_diff_options_form($field_type, $settings) {
|
||||
$options_form = array();
|
||||
$options_form['show_id'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show file ID'),
|
||||
'#default_value' => $settings['show_id'],
|
||||
);
|
||||
$options_form['compare_description_field'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Compare description field'),
|
||||
'#default_value' => $settings['compare_description_field'],
|
||||
'#description' => t('This is only used if the "Enable <em>Description</em> field" is checked in the instance settings.'),
|
||||
);
|
||||
$options_form['compare_display_field'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Compare display state field'),
|
||||
'#default_value' => $settings['compare_display_field'],
|
||||
'#description' => t('This is only used if the "Enable <em>Display</em> field" is checked in the field settings.'),
|
||||
);
|
||||
return $options_form;
|
||||
}
|
112
sites/all/modules/contrib/content/diff/includes/image.inc
Normal file
112
sites/all/modules/contrib/content/diff/includes/image.inc
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide diff field functions for the image module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Diff field callback for preloading the image file entities.
|
||||
*/
|
||||
function image_field_diff_view_prepare(&$old_items, &$new_items, $context) {
|
||||
$fids = array();
|
||||
foreach (array_merge_recursive($old_items, $new_items) as $info) {
|
||||
$fids[$info['fid']] = $info['fid'];
|
||||
}
|
||||
$files = file_load_multiple($fids);
|
||||
|
||||
foreach ($old_items as $delta => $info) {
|
||||
$old_items[$delta]['file'] = isset($files[$info['fid']]) ? $files[$info['fid']] : NULL;
|
||||
}
|
||||
foreach ($new_items as $delta => $info) {
|
||||
$new_items[$delta]['file'] = isset($files[$info['fid']]) ? $files[$info['fid']] : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Diff field callback for parsing image field comparative values.
|
||||
*/
|
||||
function image_field_diff_view($items, $context) {
|
||||
$instance = $context['instance'];
|
||||
$settings = $context['settings'];
|
||||
|
||||
$diff_items = array();
|
||||
foreach ($items as $delta => $item) {
|
||||
if (isset($item['file'])) {
|
||||
$output = array();
|
||||
|
||||
// We populate as much as possible to allow the best flexability in any
|
||||
// string overrides.
|
||||
$t_args = array();
|
||||
foreach ($item as $key => $value) {
|
||||
if (is_scalar($value)) {
|
||||
$t_args['!' . $key] = $value;
|
||||
}
|
||||
}
|
||||
// Some states do not have the file properties in the item, so put these
|
||||
// out of the main file object.
|
||||
if (!empty($item['file'])) {
|
||||
$file_values = (array) $item['file'];
|
||||
foreach ($file_values as $key => $value) {
|
||||
if (is_scalar($value) && !isset($t_args['!' . $key])) {
|
||||
$t_args['!' . $key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output[] = t('Image: !filename', $t_args);
|
||||
if ($settings['compare_alt_field'] && !empty($instance['settings']['alt_field'])) {
|
||||
if (!empty($item['alt'])) {
|
||||
$output[] = t('Alt: !alt', $t_args);
|
||||
}
|
||||
}
|
||||
if ($settings['compare_title_field'] && !empty($instance['settings']['title_field'])) {
|
||||
if (!empty($item['title'])) {
|
||||
$output[] = t('Title: !title', $t_args);
|
||||
}
|
||||
}
|
||||
if ($settings['show_id']) {
|
||||
$output[] = t('File ID: !fid', $t_args);
|
||||
}
|
||||
$diff_items[$delta] = implode('; ', $output);
|
||||
}
|
||||
}
|
||||
|
||||
return $diff_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide default field comparison options.
|
||||
*/
|
||||
function image_field_diff_default_options($field_type) {
|
||||
return array(
|
||||
'show_id' => 0,
|
||||
'compare_alt_field' => 0,
|
||||
'compare_title_field' => 0,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a form for setting the field comparison options.
|
||||
*/
|
||||
function image_field_diff_options_form($field_type, $settings) {
|
||||
$options_form = array();
|
||||
$options_form['show_id'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show image ID'),
|
||||
'#default_value' => $settings['show_id'],
|
||||
);
|
||||
$options_form['compare_alt_field'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Compare <em>Alt</em> field'),
|
||||
'#default_value' => $settings['compare_alt_field'],
|
||||
'#description' => t('This is only used if the "Enable <em>Alt</em> field" is checked in the instance settings.'),
|
||||
);
|
||||
$options_form['compare_title_field'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Compare <em>Title</em> field'),
|
||||
'#default_value' => $settings['compare_title_field'],
|
||||
'#description' => t('This is only used if the "Enable <em>Title</em> field" is checked in the instance settings.'),
|
||||
);
|
||||
return $options_form;
|
||||
}
|
71
sites/all/modules/contrib/content/diff/includes/list.inc
Normal file
71
sites/all/modules/contrib/content/diff/includes/list.inc
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide diff field functions for the List module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Diff field callback for parsing list field comparative values.
|
||||
*/
|
||||
function list_field_diff_view($items, $context) {
|
||||
$field = $context['field'];
|
||||
$instance = $context['instance'];
|
||||
$settings = $context['settings'];
|
||||
|
||||
$diff_items = array();
|
||||
$allowed_values = list_allowed_values($field, $instance, $context['entity_type'], $context['entity']);
|
||||
foreach ($items as $delta => $item) {
|
||||
// Fairly complex condition to prevent duplicate "key (key)" type rendering.
|
||||
if (isset($allowed_values[$item['value']]) &&
|
||||
$allowed_values[$item['value']] != $item['value'] &&
|
||||
strlen($allowed_values[$item['value']])) {
|
||||
switch ($settings['compare']) {
|
||||
case 'both':
|
||||
$diff_items[$delta] = $allowed_values[$item['value']] . ' (' . $item['value'] . ')';
|
||||
break;
|
||||
|
||||
case 'label':
|
||||
$diff_items[$delta] = $allowed_values[$item['value']];
|
||||
break;
|
||||
|
||||
default:
|
||||
$diff_items[$delta] = $item['value'];
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
// If no match was found for the label, fall back to the key.
|
||||
$diff_items[$delta] = $item['value'];
|
||||
}
|
||||
}
|
||||
return $diff_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide default field comparison options.
|
||||
*/
|
||||
function list_field_diff_default_options($field_type) {
|
||||
return array(
|
||||
'compare' => 'label',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a form for setting the field comparison options.
|
||||
*/
|
||||
function list_field_diff_options_form($field_type, $settings) {
|
||||
$options_form = array();
|
||||
$options_form['compare'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Comparison method'),
|
||||
'#options' => array(
|
||||
'label' => t('Label'),
|
||||
'key' => t('Key'),
|
||||
'both' => t('Label (key)'),
|
||||
),
|
||||
'#default_value' => $settings['compare'],
|
||||
);
|
||||
return $options_form;
|
||||
}
|
107
sites/all/modules/contrib/content/diff/includes/node.inc
Normal file
107
sites/all/modules/contrib/content/diff/includes/node.inc
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide diff functions for the node module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_entity_diff().
|
||||
*
|
||||
* This function compares core node properties. This is currently limited to:
|
||||
* - title: The title of the node.
|
||||
*
|
||||
* @param object $old_node
|
||||
* The older node revision.
|
||||
* @param object $new_node
|
||||
* The newer node revision.
|
||||
* @param array $context
|
||||
* An associative array containing:
|
||||
* - entity_type: The entity type; e.g., 'node' or 'user'.
|
||||
* - old_entity: The older entity.
|
||||
* - new_entity: The newer entity.
|
||||
* - view_mode: The view mode to use. Defaults to FALSE. If no view mode is
|
||||
* given, the recommended fallback view mode is 'default'.
|
||||
* - states: An array of view states. These could be one of:
|
||||
* - raw: The raw value of the diff, the classic 7.x-2.x view.
|
||||
* - rendered: The rendered HTML as determined by the view mode. Only
|
||||
* return markup for this state if the value is normally shown
|
||||
* by this view mode. The user will most likely be able to see
|
||||
* the raw or raw_plain state, so this is optional.
|
||||
*
|
||||
* The rendering state is a work in progress.
|
||||
*
|
||||
* Conditionally, you can get these states, but setting these will override
|
||||
* the user selectable markdown method.
|
||||
*
|
||||
* - raw_plain: As raw, but text should be markdowned.
|
||||
* - rendered_plain: As rendered, but text should be markdowned.
|
||||
*
|
||||
* @return array
|
||||
* An associative array of values keyed by the entity property.
|
||||
*
|
||||
* This is effectively an unnested Form API-like structure.
|
||||
*
|
||||
* States are returned as follows:
|
||||
*
|
||||
* $results['line'] = array(
|
||||
* '#name' => t('Line'),
|
||||
* '#states' => array(
|
||||
* 'raw' => array(
|
||||
* '#old' => '<p class="line">This was the old line number [tag].</p>',
|
||||
* '#new' => '<p class="line">This is the new line [tag].</p>',
|
||||
* ),
|
||||
* 'rendered' => array(
|
||||
* '#old' => '<p class="line">This was the old line number <span class="line-number">57</span>.</p>',
|
||||
* '#new' => '<p class="line">This is the new line <span class="line-number">57</span>.</p>',
|
||||
* ),
|
||||
* ),
|
||||
* );
|
||||
*
|
||||
* For backwards compatability, no changes are required to support states,
|
||||
* but it is recommended to provide a better UI for end users.
|
||||
*
|
||||
* For example, the following example is equivalent to returning the raw
|
||||
* state from the example above.
|
||||
*
|
||||
* $results['line'] = array(
|
||||
* '#name' => t('Line'),
|
||||
* '#old' => '<p class="line">This was the old line number [tag].</p>',
|
||||
* '#new' => '<p class="line">This is the new line [tag].</p>',
|
||||
* );
|
||||
*/
|
||||
function node_entity_diff($old_node, $new_node, $context) {
|
||||
$result = array();
|
||||
if ($context['entity_type'] == 'node') {
|
||||
$type = node_type_get_type($new_node);
|
||||
$result['title'] = array(
|
||||
'#name' => $type->title_label,
|
||||
'#states' => array(),
|
||||
'#weight' => -5,
|
||||
'#settings' => array(
|
||||
// Global setting - 'diff_show_header_' . $entity_type
|
||||
'show_header' => variable_get('diff_show_header_node', 1),
|
||||
),
|
||||
);
|
||||
foreach ($context['states'] as $state) {
|
||||
switch ($state) {
|
||||
case 'rendered':
|
||||
$result['title']['#states'][$state] = array(
|
||||
'#old' => l($old_node->title, 'node/' . $old_node->title),
|
||||
'#new' => l($new_node->title, 'node/' . $new_node->title),
|
||||
);
|
||||
break;
|
||||
|
||||
// We specify a default so that the title is allows compared.
|
||||
case 'raw':
|
||||
default:
|
||||
$result['title']['#states'][$state] = array(
|
||||
'#old' => array($old_node->title),
|
||||
'#new' => array($new_node->title),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
17
sites/all/modules/contrib/content/diff/includes/number.inc
Normal file
17
sites/all/modules/contrib/content/diff/includes/number.inc
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide diff field functions for the Number module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Diff field callback for parsing number field comparative values.
|
||||
*/
|
||||
function number_field_diff_view($items, $context) {
|
||||
$diff_items = array();
|
||||
foreach ($items as $delta => $item) {
|
||||
$diff_items[$delta] = $item['value'];
|
||||
}
|
||||
return $diff_items;
|
||||
}
|
107
sites/all/modules/contrib/content/diff/includes/taxonomy.inc
Normal file
107
sites/all/modules/contrib/content/diff/includes/taxonomy.inc
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Implements pusdeo-hook hook_field_diff_view() for the Taxonomy module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Diff field callback for preloading term entities.
|
||||
*/
|
||||
function taxonomy_field_diff_view_prepare(&$old_items, &$new_items, $context) {
|
||||
$tids = array();
|
||||
foreach (array_merge_recursive($old_items, $new_items) as $info) {
|
||||
$tids[$info['tid']] = $info['tid'];
|
||||
}
|
||||
$terms = taxonomy_term_load_multiple($tids);
|
||||
foreach ($old_items as $delta => $info) {
|
||||
$old_items[$delta]['term'] = isset($terms[$info['tid']]) ? $terms[$info['tid']] : NULL;
|
||||
}
|
||||
foreach ($new_items as $delta => $info) {
|
||||
$new_items[$delta]['term'] = isset($terms[$info['tid']]) ? $terms[$info['tid']] : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Diff field callback for parsing term field comparative values.
|
||||
*/
|
||||
function taxonomy_field_diff_view($items, $context) {
|
||||
$settings = $context['settings'];
|
||||
$instance = $context['instance'];
|
||||
|
||||
$diff_items = array();
|
||||
foreach ($items as $delta => $item) {
|
||||
if (!empty($item['tid'])) {
|
||||
if ($item['tid'] == 'autocreate') {
|
||||
$diff_items[$delta] = t('!term_name (new)', array('!term_name' => $item['name']));
|
||||
}
|
||||
elseif (empty($item['term'])) {
|
||||
$diff_items[$delta] = t('Missing term reference (!tid)', array('!tid' => $item['tid']));
|
||||
}
|
||||
else {
|
||||
$output = array();
|
||||
$output['name'] = $item['term']->name;
|
||||
if ($settings['show_id']) {
|
||||
$output['tid'] = t('Term ID: !tid', array('!tid' => $item['term']->tid));
|
||||
}
|
||||
$diff_items[$delta] = implode('; ', $output);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($settings['sort']) && !empty($diff_items)) {
|
||||
if ($settings['sort'] == DIFF_SORT_VALUE || $instance['widget']['type'] == 'taxonomy_autocomplete') {
|
||||
usort($diff_items, 'uasort_taxonomy_field_diff_terms');
|
||||
}
|
||||
}
|
||||
return $diff_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for sorting terms.
|
||||
*/
|
||||
function uasort_taxonomy_field_diff_terms($a, $b) {
|
||||
// We need to use t() to test for string overrides.
|
||||
$missing_text = t('Missing term reference');
|
||||
$a_missing = strpos($a, $missing_text) === 0;
|
||||
$b_missing = strpos($b, $missing_text) === 0;
|
||||
if ($a_missing && $b_missing) {
|
||||
return strnatcmp($a, $b);
|
||||
}
|
||||
elseif ($a_missing xor $b_missing) {
|
||||
return $a_missing ? 100 : -100;
|
||||
}
|
||||
return strnatcmp($a, $b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide default field comparison options.
|
||||
*/
|
||||
function taxonomy_field_diff_default_options($field_type) {
|
||||
return array(
|
||||
'show_id' => 0,
|
||||
'sort' => DIFF_SORT_CUSTOM,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a form for setting the field comparison options.
|
||||
*/
|
||||
function taxonomy_field_diff_options_form($field_type, $settings) {
|
||||
$options_form = array();
|
||||
$options_form['show_id'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show term ID'),
|
||||
'#default_value' => $settings['show_id'],
|
||||
);
|
||||
$options_form['sort'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Sort'),
|
||||
'#options' => array(
|
||||
DIFF_SORT_NONE => t('No sort'),
|
||||
DIFF_SORT_VALUE => t('Sort'),
|
||||
DIFF_SORT_CUSTOM => t('Sort if free tagging field'),
|
||||
),
|
||||
'#default_value' => $settings['sort'],
|
||||
);
|
||||
return $options_form;
|
||||
}
|
113
sites/all/modules/contrib/content/diff/includes/text.inc
Normal file
113
sites/all/modules/contrib/content/diff/includes/text.inc
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide diff field functions for the Text module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Diff field callback for parsing text field comparative values.
|
||||
*/
|
||||
function text_field_diff_view($items, $context) {
|
||||
$field = $context['field'];
|
||||
$instance = $context['instance'];
|
||||
$settings = $context['settings'];
|
||||
|
||||
$diff_items = array();
|
||||
foreach ($items as $delta => $item) {
|
||||
$diff_items[$delta] = array();
|
||||
|
||||
// Compute the format for appending to the label.
|
||||
$format_text = '';
|
||||
if ($instance['settings']['text_processing'] && $settings['compare_format']) {
|
||||
$format_id = empty($item['format']) ? filter_fallback_format() : $item['format'];
|
||||
if ($format = filter_format_load($format_id)) {
|
||||
$format_text = $format->name;
|
||||
}
|
||||
else {
|
||||
$format_text = t('Missing format !format', array('!format' => $format_id));
|
||||
}
|
||||
}
|
||||
|
||||
// Compare the summary fields.
|
||||
$summary = $field['type'] == 'text_with_summary' && $settings['compare_summary'];
|
||||
if ($summary) {
|
||||
// Allow users to optionally clean system specific characters.
|
||||
if (empty($item['summary'])) {
|
||||
$diff_items[$delta][] = t('Summary field is empty.');
|
||||
}
|
||||
else {
|
||||
if ($format_text) {
|
||||
$diff_items[$delta][] = t('Summary (!text_format):', array('!text_format' => $format_text));
|
||||
}
|
||||
else {
|
||||
$diff_items[$delta][] = t('Summary:');
|
||||
}
|
||||
$diff_items[$delta][] = diff_normalise_text($item['summary']);
|
||||
}
|
||||
}
|
||||
|
||||
// Only show label if field has summary displayed.
|
||||
if ($summary) {
|
||||
if ($format_text) {
|
||||
$diff_items[$delta][] = t('Content (!text_format):', array('!text_format' => $format_text));
|
||||
}
|
||||
else {
|
||||
$diff_items[$delta][] = t('Content:');
|
||||
}
|
||||
}
|
||||
|
||||
// Allow users to optionally clean system specific characters.
|
||||
$diff_items[$delta][] = diff_normalise_text($item['value']);
|
||||
|
||||
// If no summary, append the format selection to the bottom of the screen.
|
||||
// This prevents adding the "Content (format)" label.
|
||||
if ($format_text && !$summary) {
|
||||
$diff_items[$delta][] = t('Text format: !text_format', array('!text_format' => $format_text));
|
||||
}
|
||||
|
||||
$diff_items[$delta] = $diff_items[$delta];
|
||||
}
|
||||
return $diff_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide default field comparison options.
|
||||
*/
|
||||
function text_field_diff_default_options($field_type) {
|
||||
// Overrides the global 'markdown' setting which does not escape HTML.
|
||||
$settings = array(
|
||||
'compare_format' => 0,
|
||||
'markdown' => 'drupal_html_to_text',
|
||||
'line_counter' => '',
|
||||
);
|
||||
if ($field_type == 'text_with_summary') {
|
||||
$settings += array(
|
||||
'compare_summary' => 0,
|
||||
);
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a form for setting the field comparison options.
|
||||
*/
|
||||
function text_field_diff_options_form($field_type, $settings) {
|
||||
$options_form = array();
|
||||
$options_form['compare_format'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Compare format'),
|
||||
'#default_value' => $settings['compare_format'],
|
||||
'#description' => t('This is only used if the "Text processing" instance settings are set to <em>Filtered text (user selects text format)</em>.'),
|
||||
);
|
||||
if ($field_type == 'text_with_summary') {
|
||||
$options_form['compare_summary'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Compare summary separately'),
|
||||
'#default_value' => $settings['compare_summary'],
|
||||
'#description' => t('This is only used if the "Summary input" option is checked in the instance settings.'),
|
||||
);
|
||||
}
|
||||
return $options_form;
|
||||
}
|
Reference in New Issue
Block a user