Projet

Général

Profil

Révision bad4e148

Ajouté par Assos Assos il y a environ 3 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/dhtml_menu/dhtml_menu.info
16 16
datestamp = "1380569449"
17 17

  
18 18

  
19
; Information added by Drupal.org packaging script on 2019-10-07
20
version = "7.x-1.0-beta2"
19
; Information added by Drupal.org packaging script on 2021-04-15
20
version = "7.x-1.0-beta3"
21 21
core = "7.x"
22 22
project = "dhtml_menu"
23
datestamp = "1570442588"
23
datestamp = "1618470530"
drupal7/sites/all/modules/dhtml_menu/dhtml_menu.js
105 105
          });
106 106
        }
107 107

  
108
        /**
109
         * If link is a placeholder (ie from special_menu_items module) make sure that
110
         * when you click it, the children show
111
         */
112
        if (link.attr('href') == '#') {
113
          link.click(function(e) {
114
            Drupal.dhtmlMenu.toggleMenu(li, link, ul);
115
            if (settings.effects.remember) {
116
              Drupal.dhtmlMenu.cookieSet();
117
            }
118
            return false;
119
          });
120
        }
121

  
108 122
        /* When using bullet expansion:
109 123
         * - Change the icon to a folder image
110 124
         * - Add the clickable overlay and its handler
......
198 212
    });
199 213

  
200 214
    // When using LTR, all icons can be shifted as one, as the text width is not relevant.
201
    if (settings.nav == 'bullet' && !rtl && $('.menu li.dhtml-folder').length) {
215
    if (settings.nav == 'bullet' && $('.menu li').length && !rtl && $('.menu li.dhtml-folder').length) {
202 216
      // Shift overlay to the left by the width of the icon and the distance between icon and text.
203 217
      if ($('.menu li').hasClass('margin-left')) {
204 218
        // Saved for a later backport if needs.
drupal7/sites/all/modules/dhtml_menu/dhtml_menu.theme.inc
26 26

  
27 27
  // Saves a lot of code.
28 28
  $l = &$variables['element']['#original_link'];
29
  if (empty($l)) {
30
    return;
31
  }
29 32

  
30 33
  // Determine if the menu is blacklisted or not whitelisted.
31 34
  // First check menu blocks.
drupal7/sites/all/modules/link/CHANGELOG.txt
1
Link 7.x-1.9, 2021-04-19
2
------------------------
3
#3209434 by DamienMcKenna, tiziano.sartori: Syntax error, unexpected '(' after
4
  upgrade to 7.x-1.8.
5

  
6

  
7
Link 7.x-1.8, 2021-04-16
8
------------------------
9
#2537248 by osopolar, Ronino, DamienMcKenna: Allow title without url on
10
  migration.
11
#836710 by DamienMcKenna, ciss, Johan den Hollander, joachim, mstrelan, sos4nt,
12
  Paul Lomax, rcross, rooby, timofey, seanB, Adirael, esbite, kay_v,
13
  joep.hendrix: Convert links to their internal link representation if they
14
  exist.
15
#3110061 by DamienMcKenna: Tidy up test files.
16
#3120382 by dsnopek, RenatoG, DamienMcKenna: Notice: Undefined index: title in
17
  link_field_load() (line 310 of link.module).
18
By DamienMcKenna: Unnecessary syntax change broke PHP 5.3 compatibility.
19
#3156021 by roman.haluska, klausi, DamienMcKenna, RenatoG: According to RFC4343
20
  uppercase letters in the domain name should be allowed.
21
#3208147 by DamienMcKenna: Simplify nested ternary logic in _link_sanitize().
22
#3121196 by torotil, DamienMcKenna, calebtr: Support relative fragment or query
23
  -only links.
24
#3208151 by DamienMcKenna: Coding standards cleanup.
25
#3178419 by DamienMcKenna: Simplify the theme functions.
26
#3208738 by jedihe, DamienMcKenna: Missing proper test_dependencies, testbot
27
  ignoring some tests.
28
#3208869 by DamienMcKenna: Simplify tests by extending LinkBaseTestClass.
29
#3208869 by DamienMcKenna: Forgot to update LinkSanitizeTest.
30
#3208957 by DamienMcKenna: Add unit tests for _link_parse_url().
31
#3095484 by DamienMcKenna, jedihe, silverham, circuscowboy, dungahk,
32
  codebymikey, bondjimbond, tcnolan7, La558, timwright_, Ron Collins, Summit,
33
  BrianLewisDesign, chegor, danbarron, SKrossa, wylbur, zorya: Query string,
34
  fragment stripped from URL.
35
#3158296 by marcosdr, opdavies, DamienMcKenna, paulocs: Enable to switch default
36
  link protocol between HTTP and HTTPS.
37
#3201437 by xlin, DamienMcKenna: Optional title for Selected Title.
38

  
39

  
1 40
Link 7.x-1.7, 2019-11-14
2 41
------------------------
3 42
#3094381 by DamienMcKenna: Add a CHANGELOG.txt file.
......
327 366
#948658 by brenk28, Dave Reid, becw, jcfiala, iMiksu, BTMash, Digidog: Fixed
328 367
  noticeof Undefined index: title in _link_sanitize() - hopefully, finally.
329 368
#1079782 by fago, klausi, drunken monkey, jcfiala, Digidog: Fixed support for
330
  hook_entity_property_info() including search API and Rules. @TODO: needs
369
  hook_entity_property_info() including search API and Rules. @todo: needs
331 370
  simpletests to be submitted for rc1.
332 371

  
333 372
Link 7.x-1.0-beta1, 2011-09-26
drupal7/sites/all/modules/link/link.admin.inc
1
<?php
2

  
3
/**
4
 * @file
5
 * Link admin settings.
6
 */
7

  
8
/**
9
 * Form constructor for the settings form.
10
 *
11
 * @ingroup forms
12
 */
13
function link_admin_settings() {
14
  $form['link_default_protocol'] = array(
15
    '#type' => 'select',
16
    '#title' => t('Protocol'),
17
    '#options' => array(
18
      LINK_HTTP_PROTOCOL => strtoupper(LINK_HTTP_PROTOCOL),
19
      LINK_HTTPS_PROTOCOL => strtoupper(LINK_HTTPS_PROTOCOL),
20
    ),
21
    '#default_value' => variable_get('link_default_protocol', LINK_HTTP_PROTOCOL),
22
    '#description' => t('Select the default protocol to use for each link.'),
23
  );
24

  
25
  return system_settings_form($form);
26
}
drupal7/sites/all/modules/link/link.info
2 2
description = Defines simple link field types.
3 3
core = 7.x
4 4
package = Fields
5
configure = admin/config/content/link
5 6

  
7
; Migrate integration.
6 8
files[] = link.migrate.inc
7 9

  
8
; Tests
9
files[] = tests/link.test
10
files[] = tests/link.attribute.test
11
files[] = tests/link.crud.test
12
files[] = tests/link.crud_browser.test
13
files[] = tests/link.token.test
14
files[] = tests/link.entity_token.test
15
files[] = tests/link.validate.test
16
files[] = tests/link.multilingual.test
17

  
18
; Views Handlers
10
; Views integration.
19 11
files[] = views/link_views_handler_argument_target.inc
20 12
files[] = views/link_views_handler_filter_protocol.inc
21 13

  
22
; Information added by Drupal.org packaging script on 2019-11-14
23
version = "7.x-1.7"
14
; Tests.
15
; Most tests extend from this class.
16
files[] = tests/LinkBaseTestClass.test
17

  
18
; All of the actual tests.
19
files[] = tests/LinkConvertInternalPathsTest.test
20
files[] = tests/LinkDefaultProtocolTest.test
21
files[] = tests/LinkEntityTokenTest.test
22
files[] = tests/LinkFieldAttributesTest.test
23
files[] = tests/LinkFieldCrudTest.test
24
files[] = tests/LinkFieldValidateTest.test
25
files[] = tests/LinkPathPrefixesTest.test
26
files[] = tests/LinkSanitizeTest.test
27
files[] = tests/LinkTokenTest.test
28
files[] = tests/LinkValidationApiTest.test
29

  
30
; Testing dependencies.
31
test_dependencies[] = entity:entity
32
test_dependencies[] = token:token
33

  
34
; Standalone unit tests.
35
files[] = tests/LinkUnitTestCase.test
36

  
37
; Information added by Drupal.org packaging script on 2021-04-19
38
version = "7.x-1.9"
24 39
core = "7.x"
25 40
project = "link"
26
datestamp = "1573731676"
41
datestamp = "1618831239"
drupal7/sites/all/modules/link/link.install
36 36
 */
37 37
function link_uninstall() {
38 38
  variable_del('link_allowed_domains');
39
  variable_del('link_default_protocol');
39 40
}
40 41

  
41 42
/**
drupal7/sites/all/modules/link/link.migrate.inc
102 102
    }
103 103

  
104 104
    $language = $this->getFieldLanguage($entity, $field_info, $arguments);
105
    $values = array_filter($values);
105

  
106
    // URLs are numeric array elements, keyed by delta. As those elements don't
107
    // exist for empty URLs they are allowed and it's up to the developer what
108
    // data to migrate, add elements for those URLs up to the maximum delta
109
    // found.
110
    //
111
    // First of all, determine the maximum delta from non-empty URLs.
112
    $max_delta = max(array_merge(array(0), array_keys($values)));
113

  
114
    // Next, determine the max delta from arguments.
115
    foreach ($arguments as $key => $value) {
116
      if (is_array($value)) {
117
        $max_delta = max($max_delta, max(array_keys($value)));
118
      }
119
    }
120

  
121
    // Finally, add missing elements for empty URLs.
122
    for ($delta = 0; $delta <= $max_delta; $delta++) {
123
      if (!isset($values[$delta])) {
124
        $values[$delta] = '';
125
      }
126
    }
106 127

  
107 128
    foreach ($values as $delta => $value) {
108 129
      $item = array();
drupal7/sites/all/modules/link/link.module
18 18
define('LINK_TARGET_NEW_WINDOW', '_blank');
19 19
define('LINK_TARGET_TOP', '_top');
20 20
define('LINK_TARGET_USER', 'user');
21
define('LINK_HTTP_PROTOCOL', 'http');
22
define('LINK_HTTPS_PROTOCOL', 'https');
21 23

  
22 24
/**
23 25
 * Maximum URLs length - needs to match value in link.install.
......
67 69
        'title_label_use_field_label' => FALSE,
68 70
        'title_maxlength' => 128,
69 71
        'enable_tokens' => 1,
72
        'convert_aliases' => 0,
70 73
        'display' => array(
71 74
          'url_cutoff' => 80,
72 75
        ),
......
187 190
    );
188 191
  }
189 192

  
193
  $form['convert_aliases'] = array(
194
    '#type' => 'checkbox',
195
    '#title' => t('Convert local aliases'),
196
    '#default_value' => isset($instance['settings']['convert_aliases']) ? $instance['settings']['convert_aliases'] : '',
197
    '#description' => t('If checked, a path alias is converted to the internal system path, the same way as when saving menu links.'),
198
  );
199

  
190 200
  $form['display'] = array(
191 201
    '#tree' => TRUE,
192 202
  );
......
307 317
  foreach ($entities as $id => $entity) {
308 318
    foreach ($items[$id] as $delta => $item) {
309 319
      $items[$id][$delta]['attributes'] = _link_load($field, $item, $instances[$id]);
310
      $items[$id][$delta]['original_title'] = $item['title'];
320
      $items[$id][$delta]['original_title'] = isset($item['title']) ? $item['title'] : NULL;
311 321
      $items[$id][$delta]['original_url'] = $item['url'];
312 322
    }
313 323
  }
......
341 351
      'error_element' => array('url' => FALSE, 'title' => TRUE),
342 352
    );
343 353
  }
354

  
355
  // Specific logic for when using the 'select' option on the title field.
356
  if ($instance['settings']['title'] == 'select') {
357
    // The title is required.
358
    if (!empty($item['title']) && !empty($item['url'])) {
359
      $errors[$field['field_name']][$langcode][$delta][] = array(
360
        'error' => 'link_required',
361
        'message' => t('The title field is required when a URL is provided.'),
362
        'error_element' => array('url' => FALSE, 'title' => TRUE),
363
      );
364
    }
365
  }
344 366
}
345 367

  
346 368
/**
......
449 471
    $item['url'] = trim($item['url']);
450 472
  }
451 473

  
474
  // Optionally convert aliases to the system path.
475
  if (!empty($instance['settings']['convert_aliases'])) {
476
    global $base_url;
477

  
478
    // Check if either the site's absolute URL or the relative base URL are at
479
    // the start of the URL, if so remove them.
480
    $base_paths = array(
481
      $base_url . base_path(),
482
      base_path(),
483
    );
484

  
485
    // Work out the correct base_path to use based on the HTTPS settings.
486
    if (isset($GLOBALS['base_secure_url'])) {
487
      $base_paths[] = $GLOBALS['base_secure_url'] . base_path();
488
    }
489
    if (isset($GLOBALS['base_insecure_url'])) {
490
      $base_paths[] = $GLOBALS['base_insecure_url'] . base_path();
491
    }
492

  
493
    // Add any additional paths.
494
    if ($extra_paths = variable_get('link_base_urls', array())) {
495
      // Create versions with and without the base path.
496
      foreach ($extra_paths as $extra_path) {
497
        $base_paths[] = $extra_path;
498
        $base_paths[] = $extra_path . base_path();
499
      }
500
    }
501

  
502
    $paths_to_test = array(
503
      $item['url'],
504
    );
505

  
506
    foreach ($base_paths as $path) {
507
      // Verify the path is at the beginning of the URL string.
508
      if (strpos($item['url'], $path) === 0) {
509
        $strlen = drupal_strlen($path);
510
        $paths_to_test[] = drupal_substr($item['url'], $strlen);
511
      }
512
    }
513

  
514
    // Check each of the paths to see if one of them is a system path.
515
    foreach (array_unique($paths_to_test) as $path) {
516
      $language = NULL;
517

  
518
      // If we have locale enabled attempt to remove the language prefix first.
519
      if (module_exists('locale')) {
520
        require_once DRUPAL_ROOT . '/includes/language.inc';
521
        list($language, $path) = language_url_split_prefix($path, language_list());
522
      }
523

  
524
      // Attempt to get a system path.
525
      $normal_path = drupal_get_normal_path($path, $language);
526

  
527
      // If we get back a different path it means Drupal found a system path we
528
      // can use.
529
      if ($normal_path != $path) {
530
        $item['url'] = $normal_path;
531
        break;
532
      }
533
    }
534
  }
535

  
452 536
  // If no attributes are set then make sure $item['attributes'] is an empty
453 537
  // array, so $field['attributes'] can override it.
454 538
  if (empty($item['attributes'])) {
......
516 600
      'error_element' => array('url' => FALSE, 'title' => TRUE),
517 601
    );
518 602
  }
603

  
604
  // Specific logic for when using the 'select' option on the title field.
605
  if ($instance['settings']['title'] == 'select') {
606
    // The title is required.
607
    if (!empty($item['title']) && !empty($item['url'])) {
608
      $errors[$field['field_name']][$langcode][$delta][] = array(
609
        'error' => 'link_required',
610
        'message' => t('The title field is required when a URL is provided.'),
611
        'error_element' => array('url' => FALSE, 'title' => TRUE),
612
      );
613
    }
614
  }
519 615
}
520 616

  
521 617
/**
522 618
 * Clean up user-entered values for a link field according to field settings.
523 619
 *
620
 * Note: this cannot be properly unit tested as it checks for certain entity
621
 * values.
622
 *
623
 * @todo Rewrite so that the logic can be unit tested.
624
 *
524 625
 * @param array $item
525 626
 *   A single link item, usually containing url, title, and attributes.
526 627
 * @param int $delta
......
557 658
  $entity_type = $instance['entity_type'];
558 659
  $entity_info = entity_get_info($entity_type);
559 660
  $property_id = $entity_info['entity keys']['id'];
560
  $entity_token_type = isset($entity_info['token type']) ? $entity_info['token type'] : (
561
  $entity_type == 'taxonomy_term' || $entity_type == 'taxonomy_vocabulary' ? str_replace('taxonomy_', '', $entity_type) : $entity_type
562
  );
661
  if (isset($entity_info['token type'])) {
662
    $entity_token_type = $entity_info['token type'];
663
  }
664
  elseif ($entity_type == 'taxonomy_term' || $entity_type == 'taxonomy_vocabulary') {
665
    $entity_token_type = str_replace('taxonomy_', '', $entity_type);
666
  }
667
  else {
668
    $entity_token_type = $entity_type;
669
  }
563 670
  if (isset($instance['settings']['enable_tokens']) && $instance['settings']['enable_tokens']) {
564 671
    $text_tokens = token_scan($item['url']);
565 672
    if (!empty($text_tokens)) {
......
582 689
    $type = LINK_EXTERNAL;
583 690
  }
584 691
  elseif ($type == LINK_FRAGMENT || $type == LINK_QUERY) {
585
    // If type is a fragment or query, then use the current URL.
586
    $item['url'] = $_GET['q'] . $item['url'];
692
    // Treat fragment or query-only links as external.
693
    if (!empty($instance['settings']['absolute_url'])) {
694
      $item['url'] = $_GET['q'] . $item['url'];
695
    }
696
    else {
697
      $item['external'] = TRUE;
698
    }
587 699
  }
588
  $url = link_cleanup_url($item['url']);
700
  $url = link_cleanup_url($item['url'], variable_get('link_default_protocol', LINK_HTTP_PROTOCOL));
589 701
  $url_parts = _link_parse_url($url);
590 702

  
591 703
  if (!empty($url_parts['url'])) {
......
603 715
    $display_url = str_replace('mailto:', '', $url);
604 716
  }
605 717
  elseif ($type === LINK_EXTERNAL) {
606
    $display_url = $item['url'];
718
    $display_url = url($url_parts['url'],
719
      array(
720
        'query' => isset($url_parts['query']) ? $url_parts['query'] : NULL,
721
        'fragment' => isset($url_parts['fragment']) ? $url_parts['fragment'] : NULL,
722
        'absolute' => TRUE,
723
      )
724
    );
607 725
  }
608 726
  elseif ($type == LINK_TEL) {
609 727
    $display_url = str_replace('tel:', '', $url);
......
828 946
  return $query_array;
829 947
}
830 948

  
949
/**
950
 * Implements hook_menu().
951
 */
952
function link_menu() {
953
  $items['admin/config/content/link'] = array(
954
    'title' => 'Link settings',
955
    'description' => 'Settings for the link module.',
956
    'page callback' => 'drupal_get_form',
957
    'page arguments' => array('link_admin_settings'),
958
    'access arguments' => array('access administration pages'),
959
    'file' => 'link.admin.inc',
960
  );
961
  return $items;
962
}
963

  
831 964
/**
832 965
 * Implements hook_theme().
833 966
 */
......
1001 1134
      '#description' => t('Select the a title for this link.'),
1002 1135
      '#default_value' => isset($element['#value']['title']) ? $element['#value']['title'] : NULL,
1003 1136
      '#options' => $options,
1137
      '#empty_value' => '',
1004 1138
    );
1005 1139
  }
1006 1140

  
......
1148 1282
 * Implements hook_field_formatter_settings_summary().
1149 1283
 */
1150 1284
function link_field_formatter_settings_summary($field, $instance, $view_mode) {
1151

  
1152 1285
  $display = $instance['display'][$view_mode];
1153 1286

  
1154 1287
  if ($display['type'] == 'link_domain') {
......
1239 1372
 * Formats a link as an absolute URL.
1240 1373
 */
1241 1374
function theme_link_formatter_link_absolute($vars) {
1242
  $absolute = array('absolute' => TRUE);
1243
  return empty($vars['element']['url']) ? '' : url($vars['element']['url'], $absolute + $vars['element']);
1375
  // If no URL value is present there's no point in continuing.
1376
  if (empty($vars['element']['url'])) {
1377
    return '';
1378
  }
1379

  
1380
  // Hardcode the 'absolute' argument.
1381
  $vars['element']['absolute'] = TRUE;
1382
  return url($vars['element']['url'], $vars['element']);
1244 1383
}
1245 1384

  
1246 1385
/**
1247 1386
 * Formats a link using the URL's domain for it's link text.
1248 1387
 */
1249 1388
function theme_link_formatter_link_domain($vars) {
1389
  // If no URL value is present there's no point in continuing.
1390
  if (empty($vars['element']['url'])) {
1391
    return '';
1392
  }
1393

  
1250 1394
  $link_options = $vars['element'];
1251 1395
  unset($link_options['title']);
1252 1396
  unset($link_options['url']);
......
1254 1398
  if (!empty($vars['display']['settings']['strip_www'])) {
1255 1399
    $domain = str_replace('www.', '', $domain);
1256 1400
  }
1257
  return $vars['element']['url'] ? l($domain, $vars['element']['url'], $link_options) : '';
1401
  return l($domain, $vars['element']['url'], $link_options);
1258 1402
}
1259 1403

  
1260 1404
/**
1261 1405
 * Formats a link without the http:// or https://.
1262 1406
 */
1263 1407
function theme_link_formatter_link_no_protocol($vars) {
1408
  // If no URL value is present there's no point in continuing.
1409
  if (empty($vars['element']['url'])) {
1410
    return '';
1411
  }
1412

  
1264 1413
  $link_options = $vars['element'];
1265 1414
  unset($link_options['title']);
1266 1415
  unset($link_options['url']);
......
1270 1419
  $replace = '';
1271 1420
  $display_url = preg_replace($search, $replace, $vars['element']['url'], 1);
1272 1421

  
1273
  return $vars['element']['url'] ? l($display_url, $vars['element']['url'], $link_options) : '';
1422
  return l($display_url, $vars['element']['url'], $link_options);
1274 1423
}
1275 1424

  
1276 1425
/**
1277 1426
 * Formats a link's title as plain text.
1278 1427
 */
1279 1428
function theme_link_formatter_link_title_plain($vars) {
1280
  return empty($vars['element']['title']) ? '' : check_plain(decode_entities($vars['element']['title']));
1429
  // If no title value is present there's no point in continuing.
1430
  if (empty($vars['element']['title'])) {
1431
    return '';
1432
  }
1433

  
1434
  return check_plain(decode_entities($vars['element']['title']));
1281 1435
}
1282 1436

  
1283 1437
/**
1284 1438
 * Formats a link using an alternate display URL for its link text.
1285 1439
 */
1286 1440
function theme_link_formatter_link_url($vars) {
1441
  // If no URL value is present there's no point in continuing.
1442
  if (empty($vars['element']['url'])) {
1443
    return '';
1444
  }
1445

  
1287 1446
  $link_options = $vars['element'];
1288 1447
  if (isset($link_options['attributes']['class'])) {
1289 1448
    $link_options['attributes']['class'] = array($link_options['attributes']['class']);
1290 1449
  }
1291 1450
  unset($link_options['title']);
1292 1451
  unset($link_options['url']);
1293
  return $vars['element']['url'] ? l($vars['element']['display_url'], $vars['element']['url'], $link_options) : '';
1452
  return l($vars['element']['display_url'], $vars['element']['url'], $link_options);
1294 1453
}
1295 1454

  
1296 1455
/**
1297 1456
 * Formats a link using "Link" as the link text.
1298 1457
 */
1299 1458
function theme_link_formatter_link_short($vars) {
1459
  // If no URL value is present there's no point in continuing.
1460
  if (empty($vars['element']['url'])) {
1461
    return '';
1462
  }
1463

  
1300 1464
  $link_options = $vars['element'];
1301 1465
  unset($link_options['title']);
1302 1466
  unset($link_options['url']);
1303
  return $vars['element']['url'] ? l(t('Link'), $vars['element']['url'], $link_options) : '';
1467
  return l(t('Link'), $vars['element']['url'], $link_options);
1304 1468
}
1305 1469

  
1306 1470
/**
1307 1471
 * Formats a link using the field's label as link text.
1308 1472
 */
1309 1473
function theme_link_formatter_link_label($vars) {
1474
  // If no URL value is present there's no point in continuing.
1475
  if (empty($vars['element']['url'])) {
1476
    return '';
1477
  }
1478

  
1310 1479
  $link_options = $vars['element'];
1311 1480
  unset($link_options['title']);
1312 1481
  unset($link_options['url']);
......
1315 1484
    $i18n_string_name = "field:{$vars['field']['field_name']}:{$vars['field']['bundle']}:label";
1316 1485
    $label = i18n_string_translate($i18n_string_name, $label);
1317 1486
  }
1318
  return $vars['element']['url'] ? l($label, $vars['element']['url'], $link_options) : '';
1487
  return l($label, $vars['element']['url'], $link_options);
1319 1488
}
1320 1489

  
1321 1490
/**
......
1329 1498
  unset($link_options['url']);
1330 1499
  $title = empty($vars['element']['title']) ? '' : check_plain($vars['element']['title']);
1331 1500

  
1332
  // @TODO static html markup looks not very elegant
1333
  // needs smarter output solution and an optional title/url seperator
1501
  // @todo Static html markup looks not very elegant, needs smarter output
1502
  // solution and an optional title/URL seperator.
1334 1503
  $url_parts = _link_parse_url($vars['element']['url']);
1335 1504
  $output = '';
1336 1505
  $output .= '<div class="link-item ' . $class . '">';
......
1344 1513

  
1345 1514
/**
1346 1515
 * Implements hook_token_list().
1347
 *
1348
 * @TODO: hook_token_list no longer exists - this should change to
1349
 *   hook_token_info().
1350 1516
 */
1351 1517
function link_token_list($type = 'all') {
1518
  // @todo hook_token_list() no longer exists, this should be rewritten as
1519
  // hook_token_info().
1352 1520
  if ($type === 'field' || $type === 'all') {
1353 1521
    $tokens = array();
1354 1522
    $tokens['link']['url'] = t("Link URL");
......
1360 1528

  
1361 1529
/**
1362 1530
 * Implements hook_token_values().
1363
 *
1364
 * @TODO: hook_token_values no longer exists - this should change to
1365
 *   hook_tokens().
1366 1531
 */
1367 1532
function link_token_values($type, $object = NULL) {
1533
  // @todo hook_token_values() no longer exists, this should be rewritten as
1534
  // hook_tokens().
1368 1535
  if ($type === 'field') {
1369 1536
    $item = $object[0];
1370 1537

  
......
1398 1565
 *   The protocol to be prepended to the url if one is not specified.
1399 1566
 */
1400 1567
function link_cleanup_url($url, $protocol = 'http') {
1568
  try {
1569
    link_ensure_valid_default_protocol();
1570
  }
1571
  catch (Exception $e) {
1572
    watchdog('link', $e->getMessage(), array(), WATCHDOG_ERROR);
1573
  }
1401 1574
  $url = trim($url);
1402 1575
  $type = link_url_type($url);
1403 1576

  
......
1418 1591
  return $url;
1419 1592
}
1420 1593

  
1594
/**
1595
 * Validate that the protocol is either HTTP or HTTPS.
1596
 *
1597
 * @throws Exception
1598
 */
1599
function link_ensure_valid_default_protocol() {
1600
  $protocol = variable_get('link_default_protocol', LINK_HTTP_PROTOCOL);
1601
  if ($protocol !== LINK_HTTP_PROTOCOL && $protocol !== LINK_HTTPS_PROTOCOL) {
1602
    variable_set('link_default_protocol', LINK_HTTP_PROTOCOL);
1603
    throw new Exception(t('Protocol was set to !protocol but must be !HTTP or !HTTPS. Set to default HTTP.', array(
1604
      '!protocol' => $protocol,
1605
      '!HTTP' => LINK_HTTP_PROTOCOL,
1606
      '!HTTPS' => LINK_HTTPS_PROTOCOL,
1607
    )));
1608
  }
1609
}
1610

  
1421 1611
/**
1422 1612
 * Validates a URL.
1423 1613
 *
......
1430 1620
 *   True if a valid link, FALSE otherwise.
1431 1621
 */
1432 1622
function link_validate_url($text, $langcode = NULL) {
1433

  
1434 1623
  $text = _link_clean_relative($text);
1435 1624
  $text = link_cleanup_url($text);
1436 1625
  $type = link_url_type($text);
......
1499 1688
 *   the LINK_(linktype) constants.
1500 1689
 */
1501 1690
function link_url_type($text) {
1502
  // @TODO Complete letters.
1691
  // @todo Complete letters.
1503 1692
  // @codingStandardsIgnoreStart
1504 1693
  $link_ichars_domain = (string) html_entity_decode(implode("", array(
1505 1694
    "&#x00BF;", // ¿
......
1574 1763
  // @codingStandardsIgnoreEnd
1575 1764

  
1576 1765
  $link_ichars = $link_ichars_domain . (string) html_entity_decode(implode("", array(
1577
      // ß.
1766
    // ß.
1578 1767
    "&#x00DF;",
1579 1768
  )), ENT_QUOTES, 'UTF-8');
1580 1769
  $allowed_protocols = variable_get('filter_allowed_protocols', array(
......
1598 1787
  // captured.
1599 1788
  $protocol = '((?:' . implode("|", $allowed_protocols) . '):\/\/)';
1600 1789
  $authentication = "(?:(?:(?:[\w\.\-\+!$&'\(\)*\+,;=" . $link_ichars . "]|%[0-9a-f]{2})+(?::(?:[\w" . $link_ichars . "\.\-\+%!$&'\(\)*\+,;=]|%[0-9a-f]{2})*)?)?@)";
1601
  $domain = '(?:(?:[a-z0-9' . $link_ichars_domain . ']([a-z0-9' . $link_ichars_domain . '\-_\[\]])*)(\.(([a-z0-9' . $link_ichars_domain . '\-_\[\]])+\.)*(' . $link_domains . '|[a-z]{2}))?)';
1790
  $domain = '(?:(?:[a-zA-Z0-9' . $link_ichars_domain . ']([a-zA-Z0-9' . $link_ichars_domain . '\-_\[\]])*)(\.(([a-zA-Z0-9' . $link_ichars_domain . '\-_\[\]])+\.)*(' . $link_domains . '|[a-z]{2}))?)';
1602 1791
  $ipv4 = '(?:[0-9]{1,3}(\.[0-9]{1,3}){3})';
1603 1792
  $ipv6 = '(?:[0-9a-fA-F]{1,4}(\:[0-9a-fA-F]{1,4}){7})';
1604 1793
  $port = '(?::([0-9]{1,5}))';
......
1805 1994
    'type' => 'text',
1806 1995
    'label' => t('The URL of the link.'),
1807 1996
    'setter callback' => 'entity_property_verbatim_set',
1997
    'getter callback' => 'link_url_property_get',
1808 1998
  );
1809 1999
  $properties['attributes'] = array(
1810 2000
    'type' => 'struct',
......
1820 2010
  return $properties;
1821 2011
}
1822 2012

  
2013
/**
2014
 * Callback for getting the URL property.
2015
 *
2016
 * @see entity_metadata_entity_get_properties()
2017
 */
2018
function link_url_property_get($data, array $options, $name, $type, $info) {
2019
  $url = entity_property_verbatim_get($data, $options, $name, $type, $info);
2020

  
2021
  return url($url, $data + $options);
2022
}
2023

  
1823 2024
/**
1824 2025
 * Entity property info getter callback for link attributes.
1825 2026
 */
drupal7/sites/all/modules/link/tests/LinkBaseTestClass.test
2 2

  
3 3
/**
4 4
 * @file
5
 * Link base test file - contains common functions for testing links.
5
 * Base test class with helper methods, etc.
6 6
 */
7 7

  
8 8
/**
9
 * Base Test Class.
9
 * Base test class with helper methods, etc.
10 10
 */
11 11
class LinkBaseTestClass extends DrupalWebTestCase {
12 12

  
13
  /**
14
   * Default permissions used on tests.
15
   *
16
   * @var array
17
   */
13 18
  protected $permissions = array(
14 19
    'access content',
15 20
    'administer content types',
......
26 31
   * {@inheritdoc}
27 32
   */
28 33
  public function setUp(array $modules = array()) {
34
    // Most of the tests require the field UI to create & modify fields.
29 35
    $modules[] = 'field_ui';
36

  
37
    // This module.
30 38
    $modules[] = 'link';
39

  
31 40
    parent::setUp($modules);
32 41

  
33 42
    $this->web_user = $this->drupalCreateUser($this->permissions);
drupal7/sites/all/modules/link/tests/LinkConvertInternalPathsTest.test
1
<?php
2

  
3
/**
4
 * @file
5
 * Confirm path aliases are saved internally as the system path.
6
 */
7

  
8
/**
9
 * Confirm path aliases are saved internally as the system path.
10
 */
11
class LinkConvertInternalPathsTest extends LinkBaseTestClass {
12

  
13
  /**
14
   * Description of the tests.
15
   */
16
  public static function getInfo() {
17
    return array(
18
      'name' => 'Conversion of internal path aliases',
19
      'description' => 'Test that internal path aliases are saved as system paths.',
20
      'group' => 'Link',
21
    );
22
  }
23

  
24
  /**
25
   * {@inheritdoc}
26
   */
27
  public function setUp(array $modules = array()) {
28
    $modules[] = 'path';
29
    parent::setUp($modules);
30
  }
31

  
32
  /**
33
   * Test the alias handling.
34
   */
35
  public function testInternalPathConversion() {
36
    // Create 2 fields, one which converts aliases and one which doesn't.
37
    $settings = array(
38
      'instance[settings][convert_aliases]' => TRUE,
39
    );
40
    $field_name_converts = $this->createLinkField('page', $settings);
41
    $field_name_plain = $this->createLinkField('page');
42

  
43
    // Programatically create a node with an alias to link to.
44
    $aliased_node = (object) array(
45
      'type' => 'page',
46
      'uid' => 1,
47
      'title' => $this->randomName(),
48
      'path' => array(
49
        'alias' => $this->randomName(),
50
      ),
51
      // This is needed for path alias to be saved.
52
      'language' => LANGUAGE_NONE,
53
    );
54
    node_save($aliased_node);
55

  
56
    $this->drupalGet($aliased_node->path['alias']);
57
    $this->assertText($aliased_node->title, 'Aliased node created.');
58

  
59
    $this->drupalGet('node/add/page');
60

  
61
    $label = $this->randomName();
62
    $edit = array(
63
      'title' => $label,
64
      $field_name_converts . '[und][0][title]' => $label,
65
      $field_name_converts . '[und][0][url]' => $aliased_node->path['alias'],
66
      $field_name_plain . '[und][0][title]' => $label,
67
      $field_name_plain . '[und][0][url]' => $aliased_node->path['alias'],
68
    );
69
    $this->drupalPost(NULL, $edit, t('Save'));
70
    $this->assertRaw(' has been created.', 'Node created');
71

  
72
    // Load the node that was created.
73
    $url = $this->getUrl();
74
    $split = explode('/', $url);
75
    $nid = array_pop($split);
76

  
77
    $node = node_load($nid);
78

  
79
    $link_field_converts_items = field_get_items('node', $node, $field_name_converts);
80
    $this->assertEqual($link_field_converts_items[0]['url'], "node/{$aliased_node->nid}", "The field value was saved as the internal path for the alias.");
81

  
82
    $link_field_plain_items = field_get_items('node', $node, $field_name_plain);
83
    $this->assertEqual($link_field_plain_items[0]['url'], $aliased_node->path['alias'], "The field value was saved as the given alias.");
84
  }
85

  
86
}
drupal7/sites/all/modules/link/tests/LinkDefaultProtocolTest.test
1
<?php
2

  
3
/**
4
 * Test setting a global protocol, and using it for links when needed.
5
 *
6
 * Ensure that any links that are created not using an explict protocol (e.g.
7
 * a link entered as www.drupal.org, without a http:// or https:// prefix) will
8
 * use the globally defined protocol.
9
 *
10
 * Any links created with an explicit protocol will continue to use that
11
 * protocol and will ignore the global setting.
12
 */
13
class LinkDefaultProtocolTest extends LinkBaseTestClass {
14

  
15
  /**
16
   * Get Info.
17
   */
18
  public static function getInfo() {
19
    return array(
20
      'name' => 'Set default link protocol',
21
      'description' => 'Test that an url with a default protocol set.',
22
      'group' => 'Link',
23
    );
24
  }
25

  
26
  /**
27
   * A link without a default protocol uses the default (HTTP).
28
   */
29
  public function testHttpDefaultProtocolOnUrlWithoutDefinedProtocol() {
30
    $user = $this->drupalCreateUser($this->permissions);
31
    $this->drupalLogin($user);
32

  
33
    $this->createNodeWithLink('www.example.com');
34

  
35
    $this->drupalGet('node/1');
36

  
37
    $this->assertRaw('http://www.example.com');
38
  }
39

  
40
  /**
41
   * The protocol is set to HTTP by default if a wrong protocol has been set.
42
   */
43
  public function testHttpDefaultProtocolFromVariableConf() {
44
    variable_set('link_default_protocol', 'banana');
45

  
46
    try {
47
      link_ensure_valid_default_protocol();
48
    }
49
    catch (Exception $e) {
50
    }
51

  
52
    $protocol = variable_get('link_default_protocol');
53

  
54
    $this->assertEqual($protocol, LINK_HTTP_PROTOCOL);
55
  }
56

  
57
  /**
58
   * A link with no defined protocol in the URL uses the default (HTTPS).
59
   */
60
  public function testHttpsDefaultProtocolOnUrlWithoutDefinedProtocol() {
61
    $this->setupDefaultProtocol(LINK_HTTPS_PROTOCOL);
62

  
63
    $this->createNodeWithLink('www.example.com');
64

  
65
    $this->drupalGet('node/1');
66

  
67
    $this->assertRaw('https://www.example.com');
68
  }
69

  
70
  /**
71
   * A link with a defined protocol HTTPS overrides the default HTTP protocol.
72
   */
73
  public function testHttpDefaultProtocolOnUrlWithDefinedHttpsProtocol() {
74
    $this->setupDefaultProtocol(LINK_HTTP_PROTOCOL);
75

  
76
    $this->createNodeWithLink('https://www.example.com');
77

  
78
    $this->drupalGet('node/1');
79

  
80
    $this->assertRaw('https://www.example.com');
81
  }
82

  
83
  /**
84
   * A link with a defined protocol HTTP overrides the default HTTPS protocol.
85
   */
86
  public function testHttpsDefaultProtocolOnUrlWithDefinedHttpProtocol() {
87
    $this->setupDefaultProtocol(LINK_HTTPS_PROTOCOL);
88

  
89
    $this->createNodeWithLink('http://www.example.com');
90

  
91
    $this->drupalGet('node/1');
92

  
93
    $this->assertRaw('http://www.example.com');
94
  }
95

  
96
  /**
97
   * Setup the default global link protocol to either HTTP or HTTPS.
98
   *
99
   * @param string $protocol
100
   *   The protocol to use.
101
   */
102
  private function setupDefaultProtocol($protocol) {
103
    $user = $this->drupalCreateUser($this->permissions);
104
    $this->drupalLogin($user);
105

  
106
    $this->drupalPost(
107
      'admin/config/content/link',
108
      array('link_default_protocol' => $protocol),
109
      'Save configuration'
110
    );
111
  }
112

  
113
  /**
114
   * Create a page node with a link field.
115
   *
116
   * @param string $url
117
   *   The link URL.
118
   *
119
   * @return object
120
   *   The created node.
121
   */
122
  private function createNodeWithLink($url) {
123
    $link_field = $this->createLinkField('page');
124

  
125
    $settings = array(
126
      'title' => 'Basic page link test',
127
      $link_field => array(
128
        LANGUAGE_NONE => array(
129
          array(
130
            'title' => 'Field protocol link Test',
131
            'url' => $url,
132
          ),
133
        ),
134
      ),
135
    );
136

  
137
    return $this->drupalCreateNode($settings);
138
  }
139

  
140
}
drupal7/sites/all/modules/link/tests/LinkEntityTokenTest.test
2 2

  
3 3
/**
4 4
 * @file
5
 * Contains simpletests making sure entity_token integration works.
5
 * Testing that tokens can be used in link titles.
6 6
 */
7 7

  
8 8
/**
drupal7/sites/all/modules/link/tests/LinkFieldAttributesTest.test
2 2

  
3 3
/**
4 4
 * @file
5
 * Basic simpletests to test options on link module.
5
 * Field attributes test.
6 6
 */
7 7

  
8 8
/**
9
 * Attribute Crud Test.
9
 * Field attributes test.
10 10
 */
11
class LinkAttributeCrudTest extends DrupalWebTestCase {
11
class LinkFieldAttributesTest extends LinkBaseTestClass {
12 12

  
13
  /**
14
   * Track a zebra value, used to alternate the output.
15
   *
16
   * @var int
17
   */
13 18
  private $zebra;
14 19

  
15
  protected $permissions = array(
16
    'access content',
17
    'administer content types',
18
    'administer nodes',
19
    'administer filters',
20
    'access comments',
21
    'post comments',
22
    'skip comment approval',
23
    'access administration pages',
24
  );
25

  
26 20
  /**
27 21
   * Get Info.
28 22
   */
29 23
  public static function getInfo() {
30 24
    return array(
31
      'name' => 'Link Attribute Tests',
25
      'name' => 'Link field attribute Tests',
32 26
      'description' => 'Tests the field attributes, making sure they appear in various displayed situations.',
33 27
      'group' => 'Link',
34 28
    );
......
38 32
   * {@inheritdoc}
39 33
   */
40 34
  public function setUp(array $modules = array()) {
41
    $modules[] = 'field_ui';
42
    $modules[] = 'link';
43 35
    parent::setUp($modules);
44 36

  
45 37
    $this->zebra = 0;
46

  
47
    // Create and login user.
48
    $this->web_user = $this->drupalCreateUser(array(
49
      'administer content types',
50
      'administer fields',
51
    ));
52
    $this->drupalLogin($this->web_user);
53 38
  }
54 39

  
55 40
  /**
drupal7/sites/all/modules/link/tests/LinkFieldCrudTest.test
2 2

  
3 3
/**
4 4
 * @file
5
 * Testing CRUD API in the browser.
5
 * Testing that users can not input bad URLs or labels.
6 6
 */
7 7

  
8 8
/**
9 9
 * Testing that users can not input bad URLs or labels.
10 10
 */
11
class LinkUiTest extends DrupalWebTestcase {
11
class LinkFieldCrudTest extends LinkBaseTestClass {
12 12

  
13 13
  /**
14 14
   * Link supposed to be good.
......
98 98
      array(
99 99
        'href' => 'http://example.com/' . $this->randomName(),
100 100
        'label' => $this->randomName() . '<script>alert("hi");</script>',
101
        'msg' => 'js label',
101
        'msg' => 'JS in label',
102 102
        'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
103 103
      ),
104 104
      array(
105 105
        'href' => 'http://example.com/' . $this->randomName(),
106 106
        'label' => $this->randomName() . '<script src="http://devil.site.com"></script>',
107
        'msg' => 'js label',
107
        'msg' => 'Remote JS in label',
108 108
        'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
109 109
      ),
110 110
      array(
111 111
        'href' => 'http://example.com/' . $this->randomName(),
112 112
        'label' => $this->randomName() . '" onmouseover="alert(\'hi\')',
113
        'msg' => 'js label',
113
        'msg' => 'JS in label',
114 114
        'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
115 115
      ),
116 116
      array(
117 117
        'href' => 'http://example.com/' . $this->randomName(),
118 118
        'label' => $this->randomName() . '\' onmouseover="alert(\'hi\')',
119
        'msg' => 'js label',
119
        'msg' => 'Escaped JS in label',
120 120
        'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
121 121
      ),
122 122
      array(
123 123
        'href' => 'javascript:alert("http://example.com/' . $this->randomName() . '")',
124 124
        'label' => $this->randomName(),
125
        'msg' => 'js url',
125
        'msg' => 'JS in URL',
126 126
        'type' => self::LINK_INPUT_TYPE_BAD_URL,
127 127
      ),
128
      array(
129
        'href' => 'http://example.com?foo=bar&fruit=mango',
130
        'label' => $this->randomName(),
131
        'msg' => 'URL with querystring',
132
        'type' => self::LINK_INPUT_TYPE_GOOD,
133
      ),
128 134
      array(
129 135
        'href' => 'http://ecs-es.kelkoo.es/ctl/go/sitesearchGo?.ts=1338833010331&.sig=qP9GXeEFH6syBzwmzYkxmsvp1EI-',
130 136
        'label' => 'http://ecs-es.kelkoo.es/ctl/go/sitesearchGo?.ts=1338833010331&.sig=qP9GXeEFH6syBzwmzYkxmsvp1EI-',
131
        'msg' => 'Url with . in querystring',
137
        'msg' => 'URL with . in querystring',
132 138
        'type' => self::LINK_INPUT_TYPE_GOOD,
133 139
      ),
134 140
    );
......
173 179
      // If simpletest starts using something to override the error system, this
174 180
      // will flag us and let us know it's broken.
175 181
      $this->assertFalse(libxml_use_internal_errors(TRUE));
182
      $expected_href = $input['href'];
176 183
      if (isset($input['expected_href'])) {
177
        $path = '//a[@href="' . $input['expected_href'] . '" and text()="' . $input['label'] . '"]';
184
        $expected_href = $input['expected_href'];
178 185
      }
179
      else {
180
        $path = '//a[@href="' . $input['href'] . '" and text()="' . $input['label'] . '"]';
181
      }
182
      $elements = $this->xpath($path);
186
      $elements = $this->xpath('//a[@href="' . $expected_href . '" and text()="' . $input['label'] . '"]');
183 187
      libxml_use_internal_errors(FALSE);
184 188
      $this->assertIdentical(isset($elements[0]), $input['type'] == self::LINK_INPUT_TYPE_GOOD, $input['msg']);
185 189
    }
......
508 512
    $this->assertPattern('|class\s?=\s?"' . $link_class_name . '"|', "Classes $link_class_name exist on page.");
509 513
  }
510 514

  
515
  /**
516
   * Tests that link titles properly preserve the query params.
517
   */
518
  public function testLinkTitlePreservesQueryParams() {
519
    // Create field.
520
    $field_name = $this->createLinkField();
521

  
522
    // Create page form.
523
    $this->drupalGet('node/add/page');
524
    $this->assertField($field_name . '[und][0][title]', 'Title found');
525
    $this->assertField($field_name . '[und][0][url]', 'URL found');
526

  
527
    $link_title_tests = array(
528
      array(
529
        'href' => 'http://example.com/' . $this->randomName(),
530
      ),
531
      array(
532
        'href' => 'http://example.com/' . $this->randomName() . '?property=value',
533
      ),
534
      array(
535
        'href' => 'http://example.com/' . $this->randomName() . '#position',
536
      ),
537
      array(
538
        'href' => 'http://example.com/' . $this->randomName() . '#lower?property=value2',
539
      ),
540
      array(
541
        'href' => 'http://example.com/' . $this->randomName() . '?property=value2#lower',
542
      ),
543
    );
544

  
545
    foreach ($link_title_tests as &$input) {
546
      $this->drupalGet('node/add/page');
547
      $this->assertResponse(200);
548

  
549
      // Intentionally set empty title, to force using the url as the title.
550
      $edit = array(
551
        'title' => 'Some node title',
552
        $field_name . '[und][0][title]' => '',
553
        $field_name . '[und][0][url]' => $input['href'],
554
      );
555
      $this->drupalPost(NULL, $edit, t('Save'));
556
      // Confirm the node saved correctly.
557
      $this->assertResponse(200);
558
      $this->assertText($edit['title']);
559
      $input['url'] = $this->getUrl();
560
    }
561

  
562
    // Change to anonymous user.
563
    $this->drupalLogout();
564

  
565
    // Loop over the nodes, confirm each URL is rendered correctly.
566
    foreach ($link_title_tests as $input) {
567
      $this->drupalGet($input['url']);
568
      $this->assertRaw(l($input['href'], $input['href']), "Test that the link title has been set to " . $input['href']);
569
    }
570
  }
571

  
511 572
}
drupal7/sites/all/modules/link/tests/LinkFieldValidateTest.test
2 2

  
3 3
/**
4 4
 * @file
5
 * Tests that exercise the validation functions in the link module.
5
 * Link field Validation Tests.
6 6
 */
7 7

  
8 8
/**
9
 * Validate Test Case.
9
 * Link field Validation Tests.
10 10
 */
11
class LinkValidateTestCase extends LinkBaseTestClass {
11
class LinkFieldValidateTest extends LinkBaseTestClass {
12

  
13
  /**
14
   * Get Info.
15
   */
16
  public static function getInfo() {
17
    return array(
18
      'name' => 'Link field validation tests',
19
      'description' => 'Tests the field validation.',
20
      'group' => 'Link',
21
    );
22
  }
12 23

  
13 24
  /**
14 25
   * Create Link.
......
47 58
    $this->assertEqual($url, $node->{$field_name}[LANGUAGE_NONE][0]['url']);
48 59
  }
49 60

  
50
}
51

  
52
/**
53
 * Class for Validate Test.
54
 */
55
class LinkValidateTest extends LinkValidateTestCase {
56

  
57
  /**
58
   * Get Info.
59
   */
60
  public static function getInfo() {
61
    return array(
62
      'name' => 'Link Validation Tests',
63
      'description' => 'Tests the field validation.',
64
      'group' => 'Link',
65
    );
66
  }
67

  
68 61
  /**
69 62
   * Validate basic URL.
70 63
   */
......
233 226
   *
234 227
   * Test if a bad url can sneak through un-filtered if we play with the
235 228
   * validation...
229
   *
230
   * @todo Enable this, fix any problems that come up.
236 231
   */
237 232
  public function xTestLinkValidateSwitchingBetweenValidationStatus() {
238 233
    $this->acquireContentTypes(1);
......
344 339
    $this->linkTestValidateUrl('ftp://www.example.com/');
345 340
  }
346 341

  
347
}
348

  
349
/**
350
 * Validate Test News.
351
 */
352
class LinkValidateTestNews extends LinkValidateTestCase {
353

  
354
  /**
355
   * Get Info.
356
   */
357
  public static function getInfo() {
358
    return array(
359
      'name' => 'Link News Validation Tests',
360
      'description' => 'Tests the field validation for usenet urls.',
361
      'group' => 'Link',
362
    );
363
  }
364

  
365 342
  /**
366 343
   * Validate a news link to a message group.
367 344
   */
......
376 353
    $this->linkTestValidateUrl('news:hj0db8$vrm$1@news.eternal-september.org');
377 354
  }
378 355

  
379
}
380

  
381
/**
382
 * Validate Specific URL.
383
 */
384
class LinkValidateSpecificURL extends LinkValidateTestCase {
385

  
386
  /**
387
   * Get Info.
388
   */
389
  public static function getInfo() {
390
    return array(
391
      'name' => 'Link Specific URL Validation Tests',
392
      'description' => 'Tests field validation with unusual urls',
393
      'group' => 'Link',
394
    );
395
  }
396

  
397 356
  /**
398 357
   * Lets throw in a lot of umlouts for testing!
399 358
   */
......
440 399
  }
441 400

  
442 401
}
443

  
444
/**
445
 * Validate Url Light.
446
 *
447
 * A series of tests of links, only going against the link_validate_url function
448
 * in link.module.
449
 *
450
 * Validation is guided by the rules in http://tools.ietf.org/html/rfc1738 !
451
 */
452
class LinkValidateUrlLight extends DrupalWebTestCase {
453

  
454
  /**
455
   * Get Info.
456
   */
457
  public static function getInfo() {
458
    return array(
459
      'name' => 'Link Light Validation Tests',
460
      'description' => 'Tests the link_validate_url() function by itself, without invoking the full drupal/cck lifecycle.',
461
      'group' => 'Link',
462
    );
463
  }
464

  
465
  /**
466
   * {@inheritdoc}
467
   */
468
  public function setUp(array $modules = array()) {
469
    $modules[] = 'link';
470
    parent::setUp($modules);
471
  }
472

  
473
  /**
474
   * Name Link Type.
475
   *
476
   * Translates the LINK type constants to english for display and debugging of
477
   * tests.
478
   *
479
   * @codingStandardsIgnoreStart
480
   */
481
  public function name_Link_Type($type) {
482
    // @codingStandardsIgnoreEnd
483
    switch ($type) {
484
      case LINK_FRONT:
485
        return "Front";
486

  
487
      case LINK_EMAIL:
488
        return "Email";
489

  
490
      case LINK_TEL:
491
        return "Telephone";
492

  
493
      case LINK_NEWS:
494
        return "Newsgroup";
495

  
496
      case LINK_INTERNAL:
497
        return "Internal Link";
498

  
499
      case LINK_EXTERNAL:
500
        return "External Link";
501

  
502
      case FALSE:
503
        return "Invalid Link";
504

  
505
      default:
506
        return "Bad Value:" . $type;
507
    }
508
  }
509

  
510
  /**
511
   * Make sure that a link labeled <front> works.
512
   */
513
  public function testValidateFrontLink() {
514
    $valid = link_validate_url('<front>');
515
    $this->assertEqual(LINK_FRONT, $valid, 'Make sure that front link is verified and identified');
516
  }
517

  
518
  /**
519
   * Validate Email Link.
520
   */
521
  public function testValidateEmailLink() {
522
    $valid = link_validate_url('mailto:bob@example.com');
523
    $this->assertEqual(LINK_EMAIL, $valid, "Make sure a basic mailto is verified and identified");
524
  }
525

  
526
  /**
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff