Commit 31ecd88c authored by John C Fiala's avatar John C Fiala
Browse files

bug report #948628 by brenk28, bec: Fixing setting references in , and...

bug report #948628 by brenk28, bec: Fixing setting references in , and removing calls to see if token is enabled.
parent e5534e6b
......@@ -108,26 +108,24 @@ function link_field_settings_form($field, $instance, $has_data) {
'#description' => t('This title will always be used if “Static Title” is selected above.'),
);
// Add token module replacements if available
if (module_exists('token')) {
$form['tokens'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Placeholder tokens'),
'#description' => t("The following placeholder tokens can be used in both paths and titles. When used in a path or title, they will be replaced with the appropriate values."),
);
$form['tokens']['help'] = array(
'#value' => theme('token_help', 'node'),
);
// Add token module replacements fields
$form['tokens'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Placeholder tokens'),
'#description' => t("The following placeholder tokens can be used in both paths and titles. When used in a path or title, they will be replaced with the appropriate values."),
);
$form['tokens']['help'] = array(
'#value' => theme('token_help', 'node'),
);
$form['enable_tokens'] = array(
'#type' => 'checkbox',
'#title' => t('Allow user-entered tokens'),
'#default_value' => isset($field['settings']['enable_tokens']) ? $field['settings']['enable_tokens'] : 1,
'#description' => t('Checking will allow users to enter tokens in URLs and Titles on the node edit form. This does not affect the field settings on this page.'),
);
}
$form['enable_tokens'] = array(
'#type' => 'checkbox',
'#title' => t('Allow user-entered tokens'),
'#default_value' => isset($field['settings']['enable_tokens']) ? $field['settings']['enable_tokens'] : 1,
'#description' => t('Checking will allow users to enter tokens in URLs and Titles on the node edit form. This does not affect the field settings on this page.'),
);
$form['display'] = array(
'#tree' => TRUE,
......@@ -185,8 +183,10 @@ function link_field_settings_form_validate($element, &$form_state, $complete_for
/**
* Implementation of hook_field_settings().
*
* I don't think this actually gets _used_ anymore.
*/
function link_field_settings($op, $field) {
/*function link_field_settings($op, $field) {
switch ($op) {
case 'form':
$form = array(
......@@ -222,26 +222,24 @@ function link_field_settings($op, $field) {
'#size' => '46',
);
// Add token module replacements if available
if (module_exists('token')) {
$form['tokens'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Placeholder tokens'),
'#description' => t("The following placeholder tokens can be used in both paths and titles. When used in a path or title, they will be replaced with the appropriate values."),
);
$form['tokens']['help'] = array(
'#value' => theme('token_help', 'node'),
);
$form['enable_tokens'] = array(
'#type' => 'checkbox',
'#title' => t('Allow user-entered tokens'),
'#default_value' => isset($field['enable_tokens']) ? $field['enable_tokens'] : 1,
'#description' => t('Checking will allow users to enter tokens in URLs and Titles on the node edit form. This does not affect the field settings on this page.'),
);
}
// Add token module replacements
$form['tokens'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Placeholder tokens'),
'#description' => t("The following placeholder tokens can be used in both paths and titles. When used in a path or title, they will be replaced with the appropriate values."),
);
$form['tokens']['help'] = array(
'#value' => theme('token_help', 'node'),
);
$form['enable_tokens'] = array(
'#type' => 'checkbox',
'#title' => t('Allow user-entered tokens'),
'#default_value' => isset($field['enable_tokens']) ? $field['enable_tokens'] : 1,
'#description' => t('Checking will allow users to enter tokens in URLs and Titles on the node edit form. This does not affect the field settings on this page.'),
);
$form['display'] = array(
'#tree' => TRUE,
......@@ -307,7 +305,7 @@ function link_field_settings($op, $field) {
module_load_include('inc', 'link', 'views/link.views');
return link_views_content_field_data($field);
}
}
}*/
/**
* Theme the settings form for the link field.
......@@ -470,10 +468,10 @@ function _link_sanitize(&$item, $delta, &$field, &$node) {
}
// Replace URL tokens.
if (module_exists('token') && $field['enable_tokens']) {
if ($field['settings']['enable_tokens']) {
// Load the node if necessary for nodes in views.
$token_node = isset($node->nid) ? node_load($node->nid) : $node;
$item['url'] = token_replace($item['url'], 'node', $token_node);
$item['url'] = token_replace($item['url'], array('node' => $token_node));
}
$type = link_validate_url($item['url']);
......@@ -507,12 +505,16 @@ function _link_sanitize(&$item, $delta, &$field, &$node) {
else if (isset($item['title'])) {
$title = $item['title'];
}
else {
$title = '';
}
// Replace tokens.
if (module_exists('token') && ($field['title'] == 'value' || $field['enable_tokens'])) {
if ($title && ($field['settings']['title'] == 'value' || $field['settings']['enable_tokens'])) {
// Load the node if necessary for nodes in views.
$token_node = isset($node->nid) ? node_load($node->nid) : $node;
$title = filter_xss(token_replace($title, 'node', $token_node), array('b', 'br', 'code', 'em', 'i', 'img', 'span', 'strong', 'sub', 'sup', 'tt', 'u'));
$title = filter_xss(token_replace($title, array('node' => $token_node)),
array('b', 'br', 'code', 'em', 'i', 'img', 'span', 'strong', 'sub', 'sup', 'tt', 'u'));
$item['html'] = TRUE;
}
$item['title'] = empty($title) ? $item['display_url'] : $title;
......
Supports Markdown
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