Commit 59d6eb1e authored by Nathan Haug's avatar Nathan Haug
Browse files

Notices cleanup. Thanks eaton.

parent f57b0a8d
......@@ -79,7 +79,7 @@ function link_field_settings($op, $field) {
$form['enable_tokens'] = array(
'#type' => 'checkbox',
'#title' => t('Allow user-entered tokens'),
'#default_value' => isset($field['enable_tokens']) ? $field['enable_tokens'] : 1,
'#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.'),
);
}
......@@ -108,14 +108,14 @@ function link_field_settings($op, $field) {
$form['attributes']['target'] = array(
'#type' => 'radios',
'#title' => t('Link Target'),
'#default_value' => $field['attributes']['target'] ? $field['attributes']['target'] : 'default',
'#default_value' => empty($field['attributes']['target']) ? 'default' : $field['attributes']['target'],
'#options' => $target_options,
);
$form['attributes']['rel'] = array(
'#type' => 'textfield',
'#title' => t('Rel Attribute'),
'#description' => t('When output, this link will have this rel attribute. The most common usage is <a href="http://en.wikipedia.org/wiki/Nofollow">rel=&quot;nofollow&quot;</a> which prevents some search engines from spidering entered links.'),
'#default_value' => $field['attributes']['rel'] ? $field['attributes']['rel'] : '',
'#default_value' => empty($field['attributes']['rel']) ? '' : $field['attributes']['rel'],
'#field_prefix' => 'rel = "',
'#field_suffix' => '"',
'#size' => 20,
......@@ -124,7 +124,7 @@ function link_field_settings($op, $field) {
'#type' => 'textfield',
'#title' => t('Additional CSS Class'),
'#description' => t('When output, this link will have have this class attribute. Multiple classes should be seperated by spaces.'),
'#default_value' => isset($field['attributes']['class']) ? $field['attributes']['class'] : '',
'#default_value' => empty($field['attributes']['class']) ? '' : $field['attributes']['class'],
);
return $form;
......@@ -145,10 +145,7 @@ function link_field_settings($op, $field) {
);
case 'views data':
if (!empty($field)) {
$data = link_views_data($field);
}
return isset($data) ? $data : NULL;
return link_views_content_field_data($field);
}
}
......@@ -288,7 +285,7 @@ function _link_validate(&$item, $delta, $field, $node, &$optional_field_found) {
/**
* Cleanup user-entered values for a link field according to field settings.
*
*
* @param $item
* A single link item, usually containing url, title, and attributes.
* @param $delta
......@@ -351,7 +348,7 @@ function _link_sanitize(&$item, $delta, &$field, &$node) {
// Add attributes defined at the widget level
$attributes = array();
if (is_array($item['attributes'])) {
if (!empty($item['attributes']) && is_array($item['attributes'])) {
foreach($item['attributes'] as $attribute => $attbvalue) {
if (isset($item['attributes'][$attribute]) && $field['attributes'][$attribute] == 'user') {
$attributes[$attribute] = $attbvalue;
......@@ -482,7 +479,7 @@ function link_process($element, $edit, $form_state, $form) {
'#default_value' => isset($element['#value']['title']) ? $element['#value']['title'] : NULL,
);
}
if ($field['attributes']['target'] == 'user') {
if (!empty($field['attributes']['target']) && $field['attributes']['target'] == 'user') {
$element['attributes']['target'] = array(
'#type' => 'checkbox',
'#title' => t('Open URL in a New Window'),
......@@ -650,8 +647,8 @@ function link_validate_url($text) {
$protocol = '((' . implode("|", $allowed_protocols) . '):\/\/)';
$authentication = '([a-z0-9]+(:[a-z0-9]+)?@)';
$domain = '((([a-z0-9]([a-z0-9\-_\[\]]*\.))+)('. LINK_DOMAINS .'|[a-z]{2}))';
$ipv4 = '([0-9]{1,3}(\.[0-9]{1,3}){3})';
$ipv6 = '([0-9a-fA-F]{1,4}(\:[0-9a-fA-F]{1,4}){7})';
$ipv4 = '([0-9]{1,3}(\.[0-9]{1,3}){3})';
$ipv6 = '([0-9a-fA-F]{1,4}(\:[0-9a-fA-F]{1,4}){7})';
$port = '(:([0-9]{1,5}))';
// Pattern specific to eternal links.
......
......@@ -3,7 +3,7 @@
/**
* Return CCK Views data for the link_field_settings($op == 'views data').
*/
function link_views_data($field) {
function link_views_content_field_data($field) {
// Build the automatic views data provided for us by CCK.
// This creates all the information necessary for the "url" field.
$data = content_views_field_views_data($field);
......@@ -165,7 +165,7 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
foreach ($protocols as $protocol) {
// Simple case, the URL begins with the specified protocol.
$condition = $field . ' LIKE \''. $protocol .'%\'';
// More complex case, no protocol specified but is automatically cleaned up
// by link_cleanup_url(). RegEx is required for this search operation.
if ($protocol == 'http') {
......@@ -173,12 +173,12 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
// PostGreSQL code has NOT been tested. Please report any problems to the link issue queue.
// pgSQL requires all slashes to be double escaped in regular expressions.
// See http://www.postgresql.org/docs/8.1/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP
$condition .= ' OR '. $field .' ~* \''. '^(([a-z0-9]([a-z0-9\\-_]*\\.)+)('. LINK_DOMAINS .'|[a-z][a-z]))' .'\'';
$condition .= ' OR '. $field .' ~* \''. '^(([a-z0-9]([a-z0-9\\-_]*\\.)+)('. LINK_DOMAINS .'|[a-z][a-z]))' .'\'';
}
else {
// mySQL requires backslashes to be double (triple?) escaped within character classes.
// See http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_regexp
$condition .= ' OR '. $field .' REGEXP \''. '^(([a-z0-9]([a-z0-9\\\-_]*\.)+)('. LINK_DOMAINS .'|[a-z][a-z]))' .'\'';
$condition .= ' OR '. $field .' REGEXP \''. '^(([a-z0-9]([a-z0-9\\\-_]*\.)+)('. LINK_DOMAINS .'|[a-z][a-z]))' .'\'';
}
}
......
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