Révision c8740e19
Ajouté par Assos Assos il y a plus de 9 ans
drupal7/sites/all/modules/highlightjs/contrib/highlight_js_filter/highlight_js_filter.info | ||
---|---|---|
4 | 4 |
dependencies[] = filter |
5 | 5 |
core = 7.x |
6 | 6 |
|
7 |
; Information added by Drupal.org packaging script on 2014-06-26
|
|
8 |
version = "7.x-1.1"
|
|
7 |
; Information added by Drupal.org packaging script on 2014-10-22
|
|
8 |
version = "7.x-1.2"
|
|
9 | 9 |
core = "7.x" |
10 | 10 |
project = "highlightjs" |
11 |
datestamp = "1403806728"
|
|
11 |
datestamp = "1413962329"
|
|
12 | 12 |
|
drupal7/sites/all/modules/highlightjs/contrib/highlight_js_filter/highlight_js_filter.module | ||
---|---|---|
17 | 17 |
'prepare callback' => '_highlight_js_filter_prepare', |
18 | 18 |
'process callback' => '_highlight_js_filter_process', |
19 | 19 |
'tips callback' => '_highlight_js_filter_tips', |
20 |
'cache' => FALSE,
|
|
20 |
'cache' => TRUE,
|
|
21 | 21 |
); |
22 | 22 |
return $filters; |
23 | 23 |
} |
... | ... | |
38 | 38 |
/** |
39 | 39 |
* Prepare callback for Highlight JS filter. |
40 | 40 |
*/ |
41 |
function _highlight_js_filter_prepare($text, $format) { |
|
42 |
$text = preg_replace_callback('@<code>(.+?)</code>@s', '_highlight_js_filter_escape_code_tag_callback', $text); |
|
43 |
$text = preg_replace_callback('@<code class="(.+?)">(.+?)</code>@s', '_highlight_js_filter_escape_code_tag_lang_callback', $text); |
|
41 |
function _highlight_js_filter_prepare($text) { |
|
42 |
$text = preg_replace_callback('@^<\?php(.+?)\?>@sm', '_highlight_js_filter_escape_code_tag_callback', $text); |
|
43 |
$text = preg_replace_callback('@^<code>(.+?)</code>@sm', '_highlight_js_filter_escape_code_tag_callback', $text); |
|
44 |
$text = preg_replace_callback('@^<code class="(.+?)">(.+?)</code>@sm', '_highlight_js_filter_escape_code_tag_lang_callback', $text); |
|
44 | 45 |
return $text; |
45 | 46 |
} |
46 | 47 |
|
drupal7/sites/all/modules/highlightjs/highlight_js.drush.inc | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* drush integration for highlightjs. |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* The highlightjs plugin URI. |
|
10 |
*/ |
|
11 |
define('HIGHLIGHTJS_DOWNLOAD_URI', 'https://github.com/components/highlightjs/archive/master.zip'); |
|
12 |
|
|
13 |
/** |
|
14 |
* Implementation of hook_drush_command(). |
|
15 |
* |
|
16 |
* In this hook, you specify which commands your |
|
17 |
* drush module makes available, what it does and |
|
18 |
* description. |
|
19 |
* |
|
20 |
* Notice how this structure closely resembles how |
|
21 |
* you define menu hooks. |
|
22 |
* |
|
23 |
* See `drush topic docs-commands` for a list of recognized keys. |
|
24 |
* |
|
25 |
* @return |
|
26 |
* An associative array describing your command(s). |
|
27 |
*/ |
|
28 |
function highlight_js_drush_command() { |
|
29 |
$items = array(); |
|
30 |
|
|
31 |
// The key in the $items array is the name of the command. |
|
32 |
$items['highlightjs-plugin'] = array( |
|
33 |
'callback' => 'drush_highlightjs_plugin', |
|
34 |
'description' => dt('Download and install the highlight js plugin.'), |
|
35 |
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, // No bootstrap. |
|
36 |
'arguments' => array( |
|
37 |
'path' => dt('Optional. A path where to install the highlight js plugin. If omitted Drush will use the default location.'), |
|
38 |
), |
|
39 |
'aliases' => array('highlightjs'), |
|
40 |
); |
|
41 |
|
|
42 |
return $items; |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* Implementation of hook_drush_help(). |
|
47 |
* |
|
48 |
* This function is called whenever a drush user calls |
|
49 |
* 'drush help <name-of-your-command>'. |
|
50 |
* |
|
51 |
* @param |
|
52 |
* A string with the help section (prepend with 'drush:'). |
|
53 |
* |
|
54 |
* @return |
|
55 |
* A string with the help text for your command. |
|
56 |
*/ |
|
57 |
function highlight_js_drush_help($section) { |
|
58 |
switch ($section) { |
|
59 |
case 'drush:highlightjs-plugin': |
|
60 |
return dt('Download and install the highlight js plugin, default location is sites/all/libraries.'); |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Command to download the highlightjs plugin. |
|
66 |
*/ |
|
67 |
function drush_highlightjs_plugin() { |
|
68 |
$args = func_get_args(); |
|
69 |
if (!empty($args[0])) { |
|
70 |
$path = $args[0]; |
|
71 |
} |
|
72 |
else { |
|
73 |
$path = 'sites/all/libraries'; |
|
74 |
} |
|
75 |
|
|
76 |
// Create the path if it does not exist. |
|
77 |
if (!is_dir($path)) { |
|
78 |
drush_op('mkdir', $path); |
|
79 |
drush_log(dt('Directory @path was created', array('@path' => $path)), 'notice'); |
|
80 |
} |
|
81 |
|
|
82 |
// Set the directory to the download location. |
|
83 |
$olddir = getcwd(); |
|
84 |
chdir($path); |
|
85 |
|
|
86 |
// Download the zip archive. |
|
87 |
if ($filepath = drush_download_file(HIGHLIGHTJS_DOWNLOAD_URI)) { |
|
88 |
$filename = basename($filepath); |
|
89 |
$dirname = 'highlightjs-master'; |
|
90 |
|
|
91 |
// Remove any existing highlightjs plugin directory. |
|
92 |
if (is_dir($dirname) || is_dir('highlightjs')) { |
|
93 |
drush_delete_dir($dirname, TRUE); |
|
94 |
drush_delete_dir('highlightjs', TRUE); |
|
95 |
drush_log(dt('A existing highlight js plugin was deleted from @path', array('@path' => $path)), 'notice'); |
|
96 |
} |
|
97 |
|
|
98 |
// Decompress the zip archive. |
|
99 |
drush_tarball_extract($filename); |
|
100 |
|
|
101 |
// Change the directory name to "highlightjs" if needed. |
|
102 |
if ($dirname != 'highlightjs') { |
|
103 |
drush_move_dir($dirname, 'highlightjs', TRUE); |
|
104 |
$dirname = 'highlightjs'; |
|
105 |
} |
|
106 |
} |
|
107 |
|
|
108 |
if (is_dir($dirname)) { |
|
109 |
drush_log(dt('highlight js plugin has been installed in @path', array('@path' => $path)), 'success'); |
|
110 |
} |
|
111 |
else { |
|
112 |
drush_log(dt('Drush was unable to install the highlightjs plugin to @path', array('@path' => $path)), 'error'); |
|
113 |
} |
|
114 |
|
|
115 |
// Set working directory back to the previous working directory. |
|
116 |
chdir($olddir); |
|
117 |
} |
drupal7/sites/all/modules/highlightjs/highlight_js.info | ||
---|---|---|
2 | 2 |
description = JavaScript Syntax Highlighter for client-side syntax highlighting. |
3 | 3 |
php = 5 |
4 | 4 |
core = 7.x |
5 |
dependencies[] = libraries |
|
5 |
dependencies[] = libraries (>=2.0)
|
|
6 | 6 |
|
7 |
; Information added by Drupal.org packaging script on 2014-06-26
|
|
8 |
version = "7.x-1.1"
|
|
7 |
; Information added by Drupal.org packaging script on 2014-10-22
|
|
8 |
version = "7.x-1.2"
|
|
9 | 9 |
core = "7.x" |
10 | 10 |
project = "highlightjs" |
11 |
datestamp = "1403806728"
|
|
11 |
datestamp = "1413962329"
|
|
12 | 12 |
|
drupal7/sites/all/modules/highlightjs/highlight_js.install | ||
---|---|---|
14 | 14 |
$requirements = array(); |
15 | 15 |
|
16 | 16 |
switch ($phase) { |
17 |
|
|
18 |
case 'install': |
|
19 |
// Check to make sure at least Libraries 2.x is installed. |
|
20 |
if (!function_exists('libraries_detect')) { |
|
21 |
$requirements['highlightjs'] = array( |
|
22 |
'title' => t('Libraries'), |
|
23 |
'value' => t('1.x'), |
|
24 |
'description' => t('Highlight.js requires Libraries 7.x-2.0-alpha1 or higher.'), |
|
25 |
'severity' => REQUIREMENT_ERROR, |
|
26 |
); |
|
27 |
} |
|
28 |
break; |
|
29 |
|
|
30 | 17 |
case 'runtime': |
31 | 18 |
// Check to make sure the highlight.js library is available. |
32 | 19 |
$library = libraries_detect('highlightjs'); |
drupal7/sites/all/modules/highlightjs/highlight_js.make | ||
---|---|---|
1 |
api = 2 |
|
2 |
core = 7.x |
|
3 |
|
|
4 |
; Libraries |
|
5 |
libraries[highlightjs][directory_name] = highlightjs |
|
6 |
libraries[highlightjs][download][type] = file |
|
7 |
libraries[highlightjs][download][url] = https://github.com/components/highlightjs/archive/master.zip |
|
8 |
libraries[highlightjs][type] = library |
drupal7/sites/all/modules/highlightjs/highlight_js.module | ||
---|---|---|
13 | 13 |
function highlight_js_libraries_info() { |
14 | 14 |
$libraries['highlightjs'] = array( |
15 | 15 |
'name' => 'highlightjs', |
16 |
'vendor url' => 'http://softwaremaniacs.org/soft/highlight/en',
|
|
17 |
'download url' => 'http://softwaremaniacs.org/soft/highlight/en/download',
|
|
18 |
'version' => '7.2',
|
|
16 |
'vendor url' => 'http://highlightjs.org/',
|
|
17 |
'download url' => 'http://highlightjs.org/download/',
|
|
18 |
'version' => '8.0',
|
|
19 | 19 |
'files' => array( |
20 | 20 |
'js' => array( |
21 | 21 |
'highlight.pack.js', |
... | ... | |
64 | 64 |
'#title' => t('Highlight JS default style'), |
65 | 65 |
'#default_value' => variable_get('highlightjs_style', 'default'), |
66 | 66 |
'#description' => t('Select the default code style format. Please refer to the !url page for a live demo of all the styles.', |
67 |
array('!url' => l('Demo', 'http://softwaremaniacs.org/media/soft/highlight/test.html'))),
|
|
67 |
array('!url' => l('Demo', 'http://highlightjs.org/static/test.html'))),
|
|
68 | 68 |
'#options' => $options, |
69 | 69 |
); |
70 | 70 |
return system_settings_form($form); |
drupal7/sites/all/modules/link/link.info | ||
---|---|---|
18 | 18 |
files[] = views/link_views_handler_argument_target.inc |
19 | 19 |
files[] = views/link_views_handler_filter_protocol.inc |
20 | 20 |
|
21 |
; Information added by packaging script on 2013-11-24
|
|
22 |
version = "7.x-1.2"
|
|
21 |
; Information added by Drupal.org packaging script on 2014-10-21
|
|
22 |
version = "7.x-1.3"
|
|
23 | 23 |
core = "7.x" |
24 | 24 |
project = "link" |
25 |
datestamp = "1385335705"
|
|
25 |
datestamp = "1413924830"
|
|
26 | 26 |
|
drupal7/sites/all/modules/link/link.migrate.inc | ||
---|---|---|
97 | 97 |
} |
98 | 98 |
} |
99 | 99 |
if (isset($arguments['attributes'])) { |
100 |
$item['attributes'] = $arguments['attributes']; |
|
100 |
if (is_array($arguments['attributes']) && isset($arguments['attributes'][$delta])) { |
|
101 |
$item['attributes'] = $arguments['attributes'][$delta]; |
|
102 |
} |
|
103 |
else { |
|
104 |
$item['attributes'] = $arguments['attributes']; |
|
105 |
} |
|
101 | 106 |
} |
102 | 107 |
$item['url'] = $value; |
103 | 108 |
$return[$language][$delta] = $item; |
drupal7/sites/all/modules/link/link.module | ||
---|---|---|
10 | 10 |
define('LINK_FRONT', 'front'); |
11 | 11 |
define('LINK_EMAIL', 'email'); |
12 | 12 |
define('LINK_NEWS', 'news'); |
13 |
define('LINK_DOMAINS', 'aero|arpa|asia|biz|com|cat|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|mobi|local|xxx');
|
|
13 |
define('LINK_DOMAINS', 'aero|arpa|asia|biz|build|com|cat|ceo|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|post|pro|tel|travel|mobi|local|xxx');
|
|
14 | 14 |
|
15 | 15 |
define('LINK_TARGET_DEFAULT', 'default'); |
16 | 16 |
define('LINK_TARGET_NEW_WINDOW', '_blank'); |
... | ... | |
46 | 46 |
'url' => 0, |
47 | 47 |
'title' => 'optional', |
48 | 48 |
'title_value' => '', |
49 |
'title_label_use_field_label' => FALSE, |
|
49 | 50 |
'title_maxlength' => 128, |
50 | 51 |
'enable_tokens' => 1, |
51 | 52 |
'display' => array( |
52 | 53 |
'url_cutoff' => 80, |
53 | 54 |
), |
54 | 55 |
'validate_url' => 1, |
56 |
'absolute_url' => 1, |
|
55 | 57 |
), |
56 | 58 |
'default_widget' => 'link_field', |
57 | 59 |
'default_formatter' => 'link_default', |
... | ... | |
70 | 72 |
'#element_validate' => array('link_field_settings_form_validate'), |
71 | 73 |
); |
72 | 74 |
|
75 |
$form['absolute_url'] = array( |
|
76 |
'#type' => 'checkbox', |
|
77 |
'#title' => t('Absolute URL'), |
|
78 |
'#default_value' => isset($instance['settings']['absolute_url']) && ($instance['settings']['absolute_url'] !== '') ? $instance['settings']['absolute_url'] : TRUE, |
|
79 |
'#description' => t('If checked, the URL will always render as an absolute URL.'), |
|
80 |
); |
|
81 |
|
|
73 | 82 |
$form['validate_url'] = array( |
74 | 83 |
'#type' => 'checkbox', |
75 | 84 |
'#title' => t('Validate URL'), |
... | ... | |
107 | 116 |
'#description' => t('This title will always be used if “Static Title” is selected above.'), |
108 | 117 |
); |
109 | 118 |
|
119 |
$form['title_label_use_field_label'] = array( |
|
120 |
'#type' => 'checkbox', |
|
121 |
'#title' => t('Use field label as the label for the title field'), |
|
122 |
'#default_value' => isset($instance['settings']['title_label_use_field_label']) ? $instance['settings']['title_label_use_field_label'] : FALSE, |
|
123 |
'#description' => t('If this is checked the field label will be hidden.'), |
|
124 |
); |
|
125 |
|
|
110 | 126 |
$form['title_maxlength'] = array( |
111 | 127 |
'#type' => 'textfield', |
112 | 128 |
'#title' => t('Max length of title field'), |
... | ... | |
117 | 133 |
); |
118 | 134 |
|
119 | 135 |
if (module_exists('token')) { |
120 |
// Add token module replacements fields |
|
136 |
// Add token module replacements fields.
|
|
121 | 137 |
$form['enable_tokens'] = array( |
122 | 138 |
'#type' => 'checkbox', |
123 | 139 |
'#title' => t('Allow user-entered tokens'), |
124 | 140 |
'#default_value' => isset($instance['settings']['enable_tokens']) ? $instance['settings']['enable_tokens'] : 1, |
125 | 141 |
'#description' => t('Checking will allow users to enter tokens in URLs and Titles on the entity edit form. This does not affect the field settings on this page.'), |
126 | 142 |
); |
127 |
|
|
143 |
|
|
128 | 144 |
$entity_info = entity_get_info($instance['entity_type']); |
129 | 145 |
$form['tokens_help'] = array( |
130 | 146 |
'#theme' => 'token_tree', |
... | ... | |
183 | 199 |
'#description' => t('Turn on/off if rel attribute should be removed automatically, if user given link is internal/external'), |
184 | 200 |
'#options' => $rel_remove_options, |
185 | 201 |
); |
202 |
$form['attributes']['configurable_class'] = array( |
|
203 |
'#title' => t("Allow the user to enter a custom link class per link"), |
|
204 |
'#type' => 'checkbox', |
|
205 |
'#default_value' => empty($instance['settings']['attributes']['configurable_class']) ? '' : $instance['settings']['attributes']['configurable_class'], |
|
206 |
); |
|
186 | 207 |
$form['attributes']['class'] = array( |
187 | 208 |
'#type' => 'textfield', |
188 | 209 |
'#title' => t('Additional CSS Class'), |
... | ... | |
351 | 372 |
/** |
352 | 373 |
* Prepares the item attributes and url for storage. |
353 | 374 |
*/ |
354 |
function _link_process(&$item, $delta = 0, $field, $entity) {
|
|
375 |
function _link_process(&$item, $delta, $field, $entity) { |
|
355 | 376 |
// Trim whitespace from URL. |
356 |
$item['url'] = trim($item['url']); |
|
377 |
if (!empty($item['url'])) { |
|
378 |
$item['url'] = trim($item['url']); |
|
379 |
} |
|
357 | 380 |
|
358 | 381 |
// If no attributes are set then make sure $item['attributes'] is an empty |
359 | 382 |
// array, so $field['attributes'] can override it. |
... | ... | |
383 | 406 |
if (link_validate_url(trim($item['url'])) == FALSE) { |
384 | 407 |
$errors[$field['field_name']][$langcode][$delta][] = array( |
385 | 408 |
'error' => 'link_required', |
386 |
'message' => t('The value provided for %field is not a valid URL.', array('%field' => $instance['label'])), |
|
409 |
'message' => t('The value %value provided for %field is not a valid URL.', array( |
|
410 |
'%value' => trim($item['url']), |
|
411 |
'%field' => $instance['label'], |
|
412 |
)), |
|
387 | 413 |
'error_element' => array('url' => TRUE, 'title' => FALSE), |
388 | 414 |
); |
389 | 415 |
} |
... | ... | |
405 | 431 |
); |
406 | 432 |
} |
407 | 433 |
// In a totally bizzaro case, where URLs and titles are optional but the field is required, ensure there is at least one link. |
408 |
if ($instance['settings']['url'] === 'optional' && $instance['settings']['title'] === 'optional' && (strlen(trim($item['url'])) !== 0 || strlen(trim($item['title'])) !== 0)) { |
|
434 |
if ($instance['settings']['url'] === 'optional' && $instance['settings']['title'] === 'optional' |
|
435 |
&& (strlen(trim($item['url'])) !== 0 || strlen(trim($item['title'])) !== 0)) { |
|
409 | 436 |
$optional_field_found = TRUE; |
410 | 437 |
} |
411 |
// Require entire field |
|
438 |
// Require entire field.
|
|
412 | 439 |
if ($instance['settings']['url'] === 'optional' && $instance['settings']['title'] === 'optional' && $instance['required'] == 1 && !$optional_field_found && isset($instance['id'])) { |
413 | 440 |
$errors[$field['field_name']][$langcode][$delta][] = array( |
414 | 441 |
'error' => 'link_required', |
... | ... | |
421 | 448 |
/** |
422 | 449 |
* Clean up user-entered values for a link field according to field settings. |
423 | 450 |
* |
424 |
* @param $item
|
|
451 |
* @param array $item
|
|
425 | 452 |
* A single link item, usually containing url, title, and attributes. |
426 |
* @param $delta
|
|
453 |
* @param int $delta
|
|
427 | 454 |
* The delta value if this field is one of multiple fields. |
428 |
* @param $field
|
|
455 |
* @param array $field
|
|
429 | 456 |
* The CCK field definition. |
430 |
* @param $entity
|
|
457 |
* @param object $entity
|
|
431 | 458 |
* The entity containing this link. |
432 | 459 |
*/ |
433 | 460 |
function _link_sanitize(&$item, $delta, &$field, $instance, &$entity) { |
... | ... | |
435 | 462 |
if (empty($item['url']) && empty($item['title'])) { |
436 | 463 |
return; |
437 | 464 |
} |
465 |
if (empty($item['html'])) { |
|
466 |
$item['html'] = FALSE; |
|
467 |
} |
|
438 | 468 |
|
439 | 469 |
// Replace URL tokens. |
440 | 470 |
$entity_type = $instance['entity_type']; |
... | ... | |
466 | 496 |
$url_parts = _link_parse_url($url); |
467 | 497 |
|
468 | 498 |
if (!empty($url_parts['url'])) { |
469 |
$item['url'] = url($url_parts['url'], |
|
470 |
array( |
|
471 |
'query' => isset($url_parts['query']) ? $url_parts['query'] : NULL, |
|
472 |
'fragment' => isset($url_parts['fragment']) ? $url_parts['fragment'] : NULL, |
|
473 |
'absolute' => TRUE, |
|
474 |
'html' => TRUE, |
|
475 |
) |
|
499 |
$item['url'] = $url_parts['url']; |
|
500 |
$item += array( |
|
501 |
'query' => isset($url_parts['query']) ? $url_parts['query'] : NULL, |
|
502 |
'fragment' => isset($url_parts['fragment']) ? $url_parts['fragment'] : NULL, |
|
503 |
'absolute' => !empty($instance['settings']['absolute_url']), |
|
504 |
'html' => TRUE, |
|
476 | 505 |
); |
477 | 506 |
} |
478 | 507 |
|
... | ... | |
485 | 514 |
array( |
486 | 515 |
'query' => isset($url_parts['query']) ? $url_parts['query'] : NULL, |
487 | 516 |
'fragment' => isset($url_parts['fragment']) ? $url_parts['fragment'] : NULL, |
488 |
'absolute' => TRUE,
|
|
517 |
'absolute' => !empty($instance['settings']['absolute_url']),
|
|
489 | 518 |
) |
490 | 519 |
); |
491 | 520 |
} |
... | ... | |
510 | 539 |
$title = ''; |
511 | 540 |
} |
512 | 541 |
|
513 |
// Replace tokens. |
|
542 |
// Replace title tokens.
|
|
514 | 543 |
if ($title && ($instance['settings']['title'] == 'value' || $instance['settings']['enable_tokens'])) { |
515 | 544 |
// Load the entity if necessary for entities in views. |
516 | 545 |
if (isset($entity->{$property_id})) { |
... | ... | |
532 | 561 |
|
533 | 562 |
// Unserialize attributtes array if it has not been unserialized yet. |
534 | 563 |
if (!is_array($item['attributes'])) { |
535 |
$item['attributes'] = (array)unserialize($item['attributes']); |
|
564 |
$item['attributes'] = (array) unserialize($item['attributes']);
|
|
536 | 565 |
} |
537 | 566 |
|
538 | 567 |
// Add default attributes. |
... | ... | |
581 | 610 |
$item['attributes']['title'] = token_replace($item['attributes']['title'], array($entity_token_type => $entity_loaded)); |
582 | 611 |
$item['attributes']['title'] = filter_xss($item['attributes']['title'], array('b', 'br', 'code', 'em', 'i', 'img', 'span', 'strong', 'sub', 'sup', 'tt', 'u')); |
583 | 612 |
} |
613 |
// Handle attribute classes. |
|
614 |
if (!empty($item['attributes']['class'])) { |
|
615 |
$classes = explode(' ', $item['attributes']['class']); |
|
616 |
foreach ($classes as &$class) { |
|
617 |
$class = drupal_html_class($class); |
|
618 |
} |
|
619 |
$item['attributes']['class'] = implode(' ', $classes); |
|
620 |
} |
|
621 |
unset($item['attributes']['configurable_class']); |
|
622 |
|
|
584 | 623 |
// Remove title attribute if it's equal to link text. |
585 | 624 |
if (isset($item['attributes']['title']) && $item['attributes']['title'] == $item['title']) { |
586 | 625 |
unset($item['attributes']['title']); |
... | ... | |
597 | 636 |
* @param string $url |
598 | 637 |
* URL to parse. |
599 | 638 |
* |
600 |
* @return Array
|
|
639 |
* @return array
|
|
601 | 640 |
* Array of url pieces - only 'url', 'query', and 'fragment'. |
602 | 641 |
*/ |
603 | 642 |
function _link_parse_url($url) { |
... | ... | |
618 | 657 |
} |
619 | 658 |
|
620 | 659 |
/** |
621 |
* Bacause parse_str replaces the following characters in query parameters name |
|
660 |
* Replaces the PHP parse_str() function. |
|
661 |
* |
|
662 |
* Because parse_str replaces the following characters in query parameters name |
|
622 | 663 |
* in order to maintain compability with deprecated register_globals directive: |
623 | 664 |
* |
624 | 665 |
* - chr(32) ( ) (space) |
... | ... | |
629 | 670 |
* @param string $query |
630 | 671 |
* Query to parse. |
631 | 672 |
* |
632 |
* @return Array
|
|
673 |
* @return array
|
|
633 | 674 |
* Array of query parameters. |
634 | 675 |
* |
635 | 676 |
* @see http://php.net/manual/en/language.variables.external.php#81080 |
... | ... | |
639 | 680 |
|
640 | 681 |
$pairs = explode('&', $query); |
641 | 682 |
foreach ($pairs as $pair) { |
642 |
$name_value = explode('=', $pair); |
|
683 |
$name_value = explode('=', $pair, 2);
|
|
643 | 684 |
$name = urldecode($name_value[0]); |
644 | 685 |
$value = isset($name_value[1]) ? urldecode($name_value[1]) : NULL; |
645 | 686 |
$query_array[$name] = $value; |
... | ... | |
712 | 753 |
if (!empty($element['attributes']['title'])) { |
713 | 754 |
$output .= '<div class="link-attributes">' . drupal_render($element['attributes']['title']) . '</div>'; |
714 | 755 |
} |
756 |
if (!empty($element['attributes']['class'])) { |
|
757 |
$output .= '<div class="link-attributes">' . drupal_render($element['attributes']['class']) . '</div>'; |
|
758 |
} |
|
759 |
$output .= drupal_render_children($element); |
|
715 | 760 |
return $output; |
716 | 761 |
} |
717 | 762 |
|
... | ... | |
759 | 804 |
'#default_value' => isset($element['#value']['url']) ? $element['#value']['url'] : NULL, |
760 | 805 |
); |
761 | 806 |
if ($settings['title'] !== 'none' && $settings['title'] !== 'value') { |
807 |
// Figure out the label of the title field. |
|
808 |
if (!empty($settings['title_label_use_field_label'])) { |
|
809 |
// Use the element label as the title field label. |
|
810 |
$title_label = $element['#title']; |
|
811 |
// Hide the field label because there is no need for the duplicate labels. |
|
812 |
$element['#title_display'] = 'invisible'; |
|
813 |
} |
|
814 |
else { |
|
815 |
$title_label = t('Title'); |
|
816 |
} |
|
817 |
|
|
762 | 818 |
$element['title'] = array( |
763 | 819 |
'#type' => 'textfield', |
764 | 820 |
'#maxlength' => $settings['title_maxlength'], |
765 |
'#title' => t('Title'),
|
|
821 |
'#title' => $title_label,
|
|
766 | 822 |
'#description' => t('The link title is limited to @maxlength characters maximum.', array('@maxlength' => $settings['title_maxlength'])), |
767 | 823 |
'#required' => ($settings['title'] == 'required' && (($element['#delta'] == 0 && $element['#required']) || !empty($element['#value']['url']))) ? TRUE : FALSE, |
768 | 824 |
'#default_value' => isset($element['#value']['title']) ? $element['#value']['title'] : NULL, |
... | ... | |
793 | 849 |
'#field_suffix' => '"', |
794 | 850 |
); |
795 | 851 |
} |
852 |
if (!empty($settings['attributes']['configurable_class']) && $settings['attributes']['configurable_class'] == 1) { |
|
853 |
$element['attributes']['class'] = array( |
|
854 |
'#type' => 'textfield', |
|
855 |
'#title' => t('Custom link class'), |
|
856 |
'#default_value' => isset($attributes['class']) ? $attributes['class'] : '', |
|
857 |
'#field_prefix' => 'class = "', |
|
858 |
'#field_suffix' => '"', |
|
859 |
); |
|
860 |
} |
|
796 | 861 |
|
797 | 862 |
// If the title field is avaliable or there are field accepts multiple values |
798 | 863 |
// then allow the individual field items display the required asterisk if needed. |
... | ... | |
922 | 987 |
if (isset($link_options['attributes']['class'])) { |
923 | 988 |
$link_options['attributes']['class'] = array($link_options['attributes']['class']); |
924 | 989 |
} |
925 |
|
|
926 | 990 |
// Display a normal link if both title and URL are available. |
927 | 991 |
if (!empty($vars['element']['title']) && !empty($vars['element']['url'])) { |
928 | 992 |
return l($vars['element']['title'], $vars['element']['url'], $link_options); |
929 | 993 |
} |
930 | 994 |
// If only a title, display the title. |
931 | 995 |
elseif (!empty($vars['element']['title'])) { |
932 |
return check_plain($vars['element']['title']); |
|
996 |
return $link_options['html'] ? $vars['element']['title'] : check_plain($vars['element']['title']);
|
|
933 | 997 |
} |
934 | 998 |
elseif (!empty($vars['element']['url'])) { |
935 | 999 |
return l($vars['element']['title'], $vars['element']['url'], $link_options); |
... | ... | |
952 | 1016 |
} |
953 | 1017 |
|
954 | 1018 |
/** |
955 |
* Formats a link as an absolute URL |
|
1019 |
* Formats a link as an absolute URL.
|
|
956 | 1020 |
*/ |
957 | 1021 |
function theme_link_formatter_link_absolute($vars) { |
958 | 1022 |
$absolute = array('absolute' => TRUE); |
... | ... | |
1021 | 1085 |
unset($link_options['url']); |
1022 | 1086 |
$title = empty($vars['element']['title']) ? '' : check_plain($vars['element']['title']); |
1023 | 1087 |
|
1024 |
/** |
|
1025 |
* @TODO static html markup looks not very elegant |
|
1026 |
* needs smarter output solution and an optional title/url seperator |
|
1027 |
*/ |
|
1088 |
// @TODO static html markup looks not very elegant |
|
1089 |
// needs smarter output solution and an optional title/url seperator |
|
1028 | 1090 |
$url_parts = _link_parse_url($vars['element']['url']); |
1029 | 1091 |
$output = ''; |
1030 | 1092 |
$output .= '<div class="link-item ' . $class . '">'; |
... | ... | |
1038 | 1100 |
|
1039 | 1101 |
/** |
1040 | 1102 |
* Implements hook_token_list(). |
1103 |
* |
|
1104 |
* @TODO: hook_token_list no longer exists - this should change to hook_token_info(). |
|
1041 | 1105 |
*/ |
1042 | 1106 |
function link_token_list($type = 'all') { |
1043 | 1107 |
if ($type === 'field' || $type === 'all') { |
... | ... | |
1049 | 1113 |
} |
1050 | 1114 |
} |
1051 | 1115 |
|
1116 |
/** |
|
1117 |
* Implements hook_token_values(). |
|
1118 |
* |
|
1119 |
* @TODO: hook_token_values no longer exists - this should change to hook_tokens(). |
|
1120 |
*/ |
|
1052 | 1121 |
function link_token_values($type, $object = NULL) { |
1053 | 1122 |
if ($type === 'field') { |
1054 | 1123 |
$item = $object[0]; |
... | ... | |
1078 | 1147 |
* protocol specified |
1079 | 1148 |
* |
1080 | 1149 |
* @param string $url |
1150 |
* The url entered by the user. |
|
1081 | 1151 |
* @param string $protocol |
1082 | 1152 |
* The protocol to be prepended to the url if one is not specified |
1083 | 1153 |
*/ |
... | ... | |
1108 | 1178 |
* addresses following the RFC 2368 standard for mailto address formation. |
1109 | 1179 |
* |
1110 | 1180 |
* @param string $text |
1181 |
* Url to be validated. |
|
1111 | 1182 |
* |
1112 | 1183 |
* @return mixed |
1113 | 1184 |
* Returns boolean FALSE if the URL is not valid. On success, returns one of |
... | ... | |
1177 | 1248 |
$allowed_protocols = variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal')); |
1178 | 1249 |
$LINK_DOMAINS = _link_domains(); |
1179 | 1250 |
|
1180 |
// Starting a parenthesis group with (?: means that it is grouped, but is not captured |
|
1251 |
// Starting a parenthesis group with (?: means that it is grouped, but is not captured.
|
|
1181 | 1252 |
$protocol = '((?:' . implode("|", $allowed_protocols) . '):\/\/)'; |
1182 | 1253 |
$authentication = "(?:(?:(?:[\w\.\-\+!$&'\(\)*\+,;=" . $LINK_ICHARS . "]|%[0-9a-f]{2})+(?::(?:[\w" . $LINK_ICHARS . "\.\-\+%!$&'\(\)*\+,;=]|%[0-9a-f]{2})*)?)?@)"; |
1183 | 1254 |
$domain = '(?:(?:[a-z0-9' . $LINK_ICHARS_DOMAIN . ']([a-z0-9' . $LINK_ICHARS_DOMAIN . '\-_\[\]])*)(\.(([a-z0-9' . $LINK_ICHARS_DOMAIN . '\-_\[\]])+\.)*(' . $LINK_DOMAINS . '|[a-z]{2}))?)'; |
... | ... | |
1194 | 1265 |
|
1195 | 1266 |
$directories = "(?:\/[a-z0-9" . $LINK_ICHARS . "_\-\.~+%=&,$'#!():;*@\[\]]*)*"; |
1196 | 1267 |
// Yes, four backslashes == a single backslash. |
1197 |
$query = "(?:\/?\?([?a-z0-9" . $LINK_ICHARS . "+_|\-\.~\/\\\\%=&,$'():;*@\[\]{} ]*))"; |
|
1268 |
$query = "(?:\/?\?([?a-z0-9" . $LINK_ICHARS . "+_|\-\.~\/\\\\%=&,$'!():;*@\[\]{} ]*))";
|
|
1198 | 1269 |
$anchor = "(?:#[a-z0-9" . $LINK_ICHARS . "_\-\.~+%=&,$'():;*@\[\]\/\?]*)"; |
1199 | 1270 |
|
1200 | 1271 |
// The rest of the path for a standard URL. |
... | ... | |
1287 | 1358 |
/** |
1288 | 1359 |
* Additional callback to adapt the property info of link fields. |
1289 | 1360 |
* |
1290 |
* @see entity_metadata_field_entity_property_info().
|
|
1361 |
* @see entity_metadata_field_entity_property_info() |
|
1291 | 1362 |
*/ |
1292 | 1363 |
function link_field_property_info_callback(&$info, $entity_type, $field, $instance, $field_type) { |
1293 | 1364 |
$property = &$info[$entity_type]['bundles'][$instance['bundle']]['properties'][$field['field_name']]; |
... | ... | |
1331 | 1402 |
'label' => t('The URL of the link.'), |
1332 | 1403 |
'setter callback' => 'entity_property_verbatim_set', |
1333 | 1404 |
); |
1405 |
$properties['attributes'] = array( |
|
1406 |
'type' => 'struct', |
|
1407 |
'label' => t('The attributes of the link.'), |
|
1408 |
'setter callback' => 'entity_property_verbatim_set', |
|
1409 |
'getter callback' => 'link_attribute_property_get', |
|
1410 |
); |
|
1334 | 1411 |
return $properties; |
1335 | 1412 |
} |
1336 | 1413 |
|
1414 |
/** |
|
1415 |
* Entity property info getter callback for link attributes. |
|
1416 |
*/ |
|
1417 |
function link_attribute_property_get($data, array $options, $name, $type, $info) { |
|
1418 |
return isset($data[$name]) ? array_filter($data[$name]) : array(); |
|
1419 |
} |
|
1420 |
|
|
1337 | 1421 |
/** |
1338 | 1422 |
* Implements hook_field_update_instance(). |
1339 | 1423 |
*/ |
drupal7/sites/all/modules/link/tests/link.attribute.test | ||
---|---|---|
46 | 46 |
protected function assertLinkOnNode($field_name, $link_value, $message = '', $group = 'Other') { |
47 | 47 |
$this->zebra++; |
48 | 48 |
$zebra_string = ($this->zebra % 2 == 0) ? 'even' : 'odd'; |
49 |
$cssFieldLocator = 'field-'. str_replace('_', '-', $field_name); |
|
50 |
$this->assertPattern('@<div class="field field-type-link '. $cssFieldLocator .'".*<div class="field-item '. $zebra_string .'">\s*'. $link_value .'\s*</div>@is',
|
|
49 |
$cssFieldLocator = 'field-' . str_replace('_', '-', $field_name);
|
|
50 |
$this->assertPattern('@<div class="field field-type-link ' . $cssFieldLocator . '".*<div class="field-item ' . $zebra_string . '">\s*' . $link_value . '\s*</div>@is',
|
|
51 | 51 |
$message, |
52 | 52 |
$group); |
53 | 53 |
} |
... | ... | |
66 | 66 |
// Create the content type. |
67 | 67 |
$this->clickLink(t('Add content type')); |
68 | 68 |
|
69 |
$edit = array (
|
|
69 |
$edit = array( |
|
70 | 70 |
'name' => $content_type_friendly, |
71 | 71 |
'type' => $content_type_machine, |
72 | 72 |
); |
... | ... | |
76 | 76 |
// Now add a singleton field. |
77 | 77 |
$single_field_name_friendly = $this->randomName(20); |
78 | 78 |
$single_field_name_machine = strtolower($this->randomName(10)); |
79 |
$single_field_name = 'field_'. $single_field_name_machine; |
|
80 |
$edit = array (
|
|
79 |
$single_field_name = 'field_' . $single_field_name_machine;
|
|
80 |
$edit = array( |
|
81 | 81 |
'fields[_add_new_field][label]' => $single_field_name_friendly, |
82 | 82 |
'fields[_add_new_field][field_name]' => $single_field_name_machine, |
83 | 83 |
'fields[_add_new_field][type]' => 'link_field', |
... | ... | |
112 | 112 |
$this->drupalLogin($this->web_user); |
113 | 113 |
|
114 | 114 |
// Go to page. |
115 |
$this->drupalGet('node/add/'. $content_type_machine); |
|
115 |
$this->drupalGet('node/add/' . $content_type_machine);
|
|
116 | 116 |
|
117 | 117 |
// Add a node. |
118 | 118 |
$edit = array( |
119 | 119 |
'title' => $title, |
120 |
'field_'. $single_field_name_machine. '[und][0][title]' => 'Link',
|
|
121 |
'field_'. $single_field_name_machine. '[und][0][url]' => 'http://www.drupal.org/',
|
|
120 |
'field_' . $single_field_name_machine . '[und][0][title]' => 'Link',
|
|
121 |
'field_' . $single_field_name_machine . '[und][0][url]' => 'http://www.drupal.org/',
|
|
122 | 122 |
); |
123 | 123 |
|
124 | 124 |
$this->drupalPost(NULL, $edit, t('Save')); |
125 | 125 |
$this->assertText(t('@content_type_friendly @title has been created', array('@content_type_friendly' => $content_type_friendly, '@title' => $title))); |
126 | 126 |
|
127 |
$this->drupalGet('node/add/'. $content_type_machine); |
|
127 |
$this->drupalGet('node/add/' . $content_type_machine);
|
|
128 | 128 |
|
129 | 129 |
// Create a node: |
130 | 130 |
$edit = array( |
... | ... | |
143 | 143 |
|
144 | 144 |
protected function createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine) { |
145 | 145 |
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/fields'); |
146 |
$edit = array (
|
|
146 |
$edit = array( |
|
147 | 147 |
'fields[_add_new_field][label]' => $single_field_name_friendly, |
148 | 148 |
'fields[_add_new_field][field_name]' => $single_field_name_machine, |
149 | 149 |
'fields[_add_new_field][type]' => 'link_field', |
... | ... | |
180 | 180 |
} |
181 | 181 |
|
182 | 182 |
protected function createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $title, $url, $node_title = '') { |
183 |
$this->drupalGet('node/add/'. $content_type_machine); |
|
183 |
$this->drupalGet('node/add/' . $content_type_machine);
|
|
184 | 184 |
|
185 | 185 |
if (!$node_title) { |
186 | 186 |
$node_title = $this->randomName(20); |
... | ... | |
219 | 219 |
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine); |
220 | 220 |
|
221 | 221 |
// Okay, now we want to make sure this display is changed: |
222 |
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
|
|
222 |
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
|
|
223 | 223 |
$edit = array( |
224 |
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
|
|
225 |
'fields[field_'. $single_field_name_machine .'][type]' => 'link_plain',
|
|
224 |
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
|
|
225 |
'fields[field_' . $single_field_name_machine . '][type]' => 'link_plain',
|
|
226 | 226 |
); |
227 | 227 |
$this->drupalPost(NULL, $edit, t('Save')); |
228 | 228 |
|
... | ... | |
270 | 270 |
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine); |
271 | 271 |
|
272 | 272 |
// Okay, now we want to make sure this display is changed: |
273 |
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
|
|
273 |
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
|
|
274 | 274 |
$edit = array( |
275 |
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
|
|
276 |
'fields[field_'. $single_field_name_machine .'][type]' => 'link_url',
|
|
275 |
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
|
|
276 |
'fields[field_' . $single_field_name_machine . '][type]' => 'link_url',
|
|
277 | 277 |
); |
278 | 278 |
$this->drupalPost(NULL, $edit, t('Save')); |
279 | 279 |
|
... | ... | |
320 | 320 |
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine); |
321 | 321 |
|
322 | 322 |
// Okay, now we want to make sure this display is changed: |
323 |
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
|
|
323 |
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
|
|
324 | 324 |
$edit = array( |
325 |
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
|
|
326 |
'fields[field_'. $single_field_name_machine .'][type]' => 'link_short',
|
|
325 |
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
|
|
326 |
'fields[field_' . $single_field_name_machine . '][type]' => 'link_short',
|
|
327 | 327 |
); |
328 | 328 |
$this->drupalPost(NULL, $edit, t('Save')); |
329 | 329 |
|
... | ... | |
371 | 371 |
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine); |
372 | 372 |
|
373 | 373 |
// Okay, now we want to make sure this display is changed: |
374 |
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
|
|
374 |
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
|
|
375 | 375 |
$edit = array( |
376 |
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
|
|
377 |
'fields[field_'. $single_field_name_machine .'][type]' => 'link_label',
|
|
376 |
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
|
|
377 |
'fields[field_' . $single_field_name_machine . '][type]' => 'link_label',
|
|
378 | 378 |
); |
379 | 379 |
$this->drupalPost(NULL, $edit, t('Save')); |
380 | 380 |
|
... | ... | |
422 | 422 |
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine); |
423 | 423 |
|
424 | 424 |
// Okay, now we want to make sure this display is changed: |
425 |
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
|
|
425 |
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
|
|
426 | 426 |
$edit = array( |
427 |
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
|
|
428 |
'fields[field_'. $single_field_name_machine .'][type]' => 'link_separate',
|
|
427 |
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
|
|
428 |
'fields[field_' . $single_field_name_machine . '][type]' => 'link_separate',
|
|
429 | 429 |
); |
430 | 430 |
$this->drupalPost(NULL, $edit, t('Save')); |
431 | 431 |
|
... | ... | |
474 | 474 |
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine); |
475 | 475 |
|
476 | 476 |
// Okay, now we want to make sure this display is changed: |
477 |
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
|
|
477 |
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
|
|
478 | 478 |
$edit = array( |
479 |
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
|
|
480 |
'fields[field_'. $single_field_name_machine .'][type]' => 'link_title_plain',
|
|
479 |
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
|
|
480 |
'fields[field_' . $single_field_name_machine . '][type]' => 'link_title_plain',
|
|
481 | 481 |
); |
482 | 482 |
$this->drupalPost(NULL, $edit, t('Save')); |
483 | 483 |
|
drupal7/sites/all/modules/link/tests/link.crud.test | ||
---|---|---|
37 | 37 |
// Create the content type. |
38 | 38 |
$this->clickLink(t('Add content type')); |
39 | 39 |
|
40 |
$edit = array (
|
|
40 |
$edit = array( |
|
41 | 41 |
'name' => $content_type_friendly, |
42 | 42 |
'type' => $content_type_machine, |
43 | 43 |
); |
44 | 44 |
$this->drupalPost(NULL, $edit, t('Save and add fields')); |
45 | 45 |
$this->assertText(t('The content type @name has been added.', array('@name' => $content_type_friendly))); |
46 | 46 |
|
47 |
//$field = $this->createField(array('type' => 'link', 'widget_type' => 'link'), 0); |
|
48 | 47 |
// Now add a singleton field. |
49 | 48 |
$single_field_name_friendly = $this->randomName(20); |
50 | 49 |
$single_field_name_machine = strtolower($this->randomName(10)); |
51 |
$edit = array (
|
|
50 |
$edit = array( |
|
52 | 51 |
'fields[_add_new_field][label]' => $single_field_name_friendly, |
53 | 52 |
'fields[_add_new_field][field_name]' => $single_field_name_machine, |
54 | 53 |
'fields[_add_new_field][type]' => 'link_field', |
... | ... | |
69 | 68 |
menu_rebuild(); |
70 | 69 |
$type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $content_type_machine))->fetchField(); |
71 | 70 |
$this->assertTrue($type_exists, 'The new content type has been created in the database.'); |
72 |
|
|
73 |
/*$table_schema = drupal_get_schema(); |
|
74 |
$this->assertEqual(1, 1, print_r(array_keys($table_schema), TRUE)); |
|
75 |
// Check the schema - the values should be in the per-type table. |
|
76 |
$this->assertSchemaMatchesTables(array( |
|
77 |
'per_type' => array( |
|
78 |
$this->content_types[0]->type => array($field['field_name'] => array('url', 'title', 'attributes')), |
|
79 |
), |
|
80 |
));*/ |
|
81 | 71 |
} |
82 | 72 |
} |
drupal7/sites/all/modules/link/tests/link.crud_browser.test | ||
---|---|---|
76 | 76 |
//$this->drupalGet('node/add'); |
77 | 77 |
$this->drupalGet('node/add/page'); |
78 | 78 |
$field_name = 'field_' . $name; |
79 |
$this->assertField('edit-field-'. $name .'-und-0-title', 'Title found');
|
|
80 |
$this->assertField('edit-field-'. $name .'-und-0-url', 'URL found');
|
|
79 |
$this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
|
|
80 |
$this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
|
|
81 | 81 |
|
82 | 82 |
$input_test_cases = array( |
83 | 83 |
array( |
... | ... | |
124 | 124 |
), |
125 | 125 |
); |
126 | 126 |
$test_case = array( |
127 |
'href' => 'www.example.com/'. $this->randomName(), |
|
127 |
'href' => 'www.example.com/' . $this->randomName(),
|
|
128 | 128 |
'label' => $this->randomName(), |
129 | 129 |
'msg' => 'Link found', |
130 | 130 |
'type' => self::LINK_INPUT_TYPE_GOOD, |
131 | 131 |
); |
132 |
$test_case['expected_href'] = 'http://'. $test_case['href']; |
|
132 |
$test_case['expected_href'] = 'http://' . $test_case['href'];
|
|
133 | 133 |
$input_test_cases[] = $test_case; |
134 | 134 |
|
135 | 135 |
foreach ($input_test_cases as $input) { |
... | ... | |
143 | 143 |
); |
144 | 144 |
$this->drupalPost(NULL, $edit, t('Save')); |
145 | 145 |
if ($input['type'] == self::LINK_INPUT_TYPE_BAD_URL) { |
146 |
$this->assertRaw(t('The value provided for %field is not a valid URL.', array('%field' => $name)), 'Not a valid URL: ' . $input['href']);
|
|
146 |
$this->assertRaw(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => trim($input['href']))), 'Not a valid URL: ' . $input['href']);
|
|
147 | 147 |
continue; |
148 | 148 |
} |
149 | 149 |
else { |
150 |
$this->assertRaw(t(' has been created.',
|
|
150 |
$this->assertRaw(' ' . t('has been created.',
|
|
151 | 151 |
array('@type' => 'Basic Page', '%title' => $edit['title'])), |
152 | 152 |
'Page created: ' . $input['href']); |
153 | 153 |
} |
154 | 154 |
$url = $this->getUrl(); |
155 | 155 |
|
156 |
// change to anonym user
|
|
156 |
// change to Anonymous user.
|
|
157 | 157 |
$this->drupalLogout(); |
158 | 158 |
|
159 | 159 |
$this->drupalGet($url); |
... | ... | |
162 | 162 |
// us and let us know it's broken. |
163 | 163 |
$this->assertFalse(libxml_use_internal_errors(TRUE)); |
164 | 164 |
if (isset($input['expected_href'])) { |
165 |
$path = '//a[@href="'. $input['expected_href'] .'" and text()="'. $input['label'] .'"]';
|
|
165 |
$path = '//a[@href="' . $input['expected_href'] . '" and text()="' . $input['label'] . '"]';
|
|
166 | 166 |
} |
167 | 167 |
else { |
168 |
$path = '//a[@href="'. $input['href'] .'" and text()="'. $input['label'] .'"]';
|
|
168 |
$path = '//a[@href="' . $input['href'] . '" and text()="' . $input['label'] . '"]';
|
|
169 | 169 |
} |
170 |
//$this->pass(htmlentities($path)); |
|
171 | 170 |
$elements = $this->xpath($path); |
172 | 171 |
libxml_use_internal_errors(FALSE); |
173 | 172 |
$this->assertIdentical(isset($elements[0]), $input['type'] == self::LINK_INPUT_TYPE_GOOD, $input['msg']); |
... | ... | |
185 | 184 |
|
186 | 185 |
// create field |
187 | 186 |
$name = strtolower($this->randomName()); |
188 |
$field_name = 'field_'. $name; |
|
187 |
$field_name = 'field_' . $name;
|
|
189 | 188 |
$edit = array( |
190 | 189 |
'fields[_add_new_field][label]' => $name, |
191 | 190 |
'fields[_add_new_field][field_name]' => $name, |
... | ... | |
196 | 195 |
$this->drupalPost(NULL, array(), t('Save field settings')); |
197 | 196 |
$this->drupalPost(NULL, array( |
198 | 197 |
'instance[settings][title]' => 'value', |
199 |
'instance[settings][title_value]' => '<strong>'. $name .'</strong>'), t('Save settings'));
|
|
198 |
'instance[settings][title_value]' => '<strong>' . $name . '</strong>'), t('Save settings'));
|
|
200 | 199 |
|
201 | 200 |
// Is field created? |
202 | 201 |
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added'); |
... | ... | |
221 | 220 |
$this->drupalLogout(); |
222 | 221 |
$this->drupalGet($url); |
223 | 222 |
|
224 |
$this->assertRaw(l('<strong>'. $name .'</strong>', $input['href'], array('html' => TRUE))); |
|
223 |
$this->assertRaw(l('<strong>' . $name . '</strong>', $input['href'], array('html' => TRUE))); |
|
224 |
} |
|
225 |
|
|
226 |
/** |
|
227 |
* Testing that if you have the title but no url, the title is not sanitized twice. |
|
228 |
*/ |
|
229 |
function testCRUDTitleOnlyTitleNoLink() { |
|
230 |
$this->web_user = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content')); |
|
231 |
$this->drupalLogin($this->web_user); |
|
232 |
|
|
233 |
// create field |
|
234 |
$name = strtolower($this->randomName()); |
|
235 |
$field_name = 'field_' . $name; |
|
236 |
$edit = array( |
|
237 |
'fields[_add_new_field][label]' => $name, |
|
238 |
'fields[_add_new_field][field_name]' => $name, |
|
239 |
'fields[_add_new_field][type]' => 'link_field', |
|
240 |
'fields[_add_new_field][widget_type]' => 'link_field', |
|
241 |
); |
|
242 |
$this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save')); |
|
243 |
$this->drupalPost(NULL, array(), t('Save field settings')); |
|
244 |
$this->drupalPost(NULL, array( |
|
245 |
'instance[settings][url]' => 1, |
|
246 |
), t('Save settings')); |
|
247 |
|
|
248 |
// Is field created? |
|
249 |
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added'); |
|
250 |
|
|
251 |
// create page form |
|
252 |
$this->drupalGet('node/add/page'); |
|
253 |
$this->assertField($field_name . '[und][0][url]', 'URL found'); |
|
254 |
|
|
255 |
$input = array( |
|
256 |
'title' => 'This & That', |
|
257 |
'href' => '', |
|
258 |
); |
|
259 |
|
|
260 |
$edit = array( |
|
261 |
'title' => $name, |
|
262 |
$field_name . '[und][0][title]' => $input['title'], |
|
263 |
$field_name . '[und][0][url]' => $input['href'], |
|
264 |
); |
|
265 |
$this->drupalPost(NULL, $edit, t('Save')); |
|
266 |
|
|
267 |
$url = $this->getUrl(); |
|
268 |
|
|
269 |
// change to anonymous user |
|
270 |
$this->drupalLogout(); |
|
271 |
$this->drupalGet($url); |
|
272 |
|
|
273 |
$this->assertRaw('This & That'); |
|
225 | 274 |
} |
226 | 275 |
|
227 | 276 |
/** |
... | ... | |
248 | 297 |
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added'); |
249 | 298 |
node_types_rebuild(); |
250 | 299 |
menu_rebuild(); |
251 |
//_content_type_info(TRUE); |
|
252 |
//$fields = content_fields(); |
|
253 |
//$field = $fields['field_'. $name]; |
|
254 |
//$field = field_info_field('field_'. $name); |
|
300 |
|
|
255 | 301 |
_field_info_collate_fields(TRUE); |
256 | 302 |
$instances = field_info_instances('node', 'page'); |
257 |
//$this->debug($instances); |
|
258 |
//$this->assert('debug', '<pre>'. print_r($instances, TRUE) .'</pre>', 'Debug'); |
|
259 |
$instance = $instances['field_'. $name]; |
|
260 |
//$this->assertTrue(1 === $instance['validate_url'], 'Make sure validation is on.'); |
|
303 |
|
|
304 |
$instance = $instances['field_' . $name]; |
|
261 | 305 |
$this->assertFalse($instance['required'], 'Make sure field is not required.'); |
262 | 306 |
$this->assertEqual($instance['settings']['title'], 'optional', 'Title should be optional by default.'); |
263 |
$this->assertTrue($instance['settings']['enable_tokens'], 'Enable Tokens should be off by default.'); |
|
307 |
$this->assertTrue($instance['settings']['validate_url'], 'Make sure validation is on.'); |
|
308 |
$this->assertTrue($instance['settings']['enable_tokens'], 'Enable Tokens should be on by default.'); |
|
264 | 309 |
$this->assertEqual($instance['settings']['display']['url_cutoff'], 80, 'Url cutoff should be at 80 characters.'); |
265 | 310 |
$this->assertEqual($instance['settings']['attributes']['target'], 'default', 'Target should be "default"'); |
266 | 311 |
$this->assertFalse($instance['settings']['attributes']['rel'], 'Rel should be blank by default.'); |
267 | 312 |
$this->assertFalse($instance['settings']['attributes']['class'], 'By default, no class should be set.'); |
268 | 313 |
$this->assertFalse($instance['settings']['title_value'], 'By default, no title should be set.'); |
269 |
|
|
270 |
//$this->fail('<pre>'. print_r($fields['field_'. $name], TRUE) .'</pre>'); |
|
271 | 314 |
} |
272 | 315 |
} |
drupal7/sites/all/modules/link/tests/link.test | ||
---|---|---|
36 | 36 |
'fields[_add_new_field][type]' => 'link_field', |
37 | 37 |
'fields[_add_new_field][widget_type]' => 'link_field', |
38 | 38 |
); |
39 |
$field_name = 'field_'. $name; |
|
40 |
$this->drupalPost('admin/structure/types/manage/'. $node_type .'/fields', $edit, t('Save'));
|
|
39 |
$field_name = 'field_' . $name;
|
|
40 |
$this->drupalPost('admin/structure/types/manage/' . $node_type . '/fields', $edit, t('Save'));
|
|
41 | 41 |
$this->drupalPost(NULL, array(), t('Save field settings')); |
42 | 42 |
$this->drupalPost(NULL, $settings, t('Save settings')); |
43 | 43 |
|
drupal7/sites/all/modules/link/tests/link.token.test | ||
---|---|---|
75 | 75 |
$name = $this->randomName(); |
76 | 76 |
$settings = array( |
77 | 77 |
'instance[settings][title]' => 'value', |
78 |
'instance[settings][title_value]' => $name .' [node:content-type:machine-name]'); |
|
78 |
'instance[settings][title_value]' => $name . ' [node:content-type:machine-name]');
|
|
79 | 79 |
$field_name = $this->createLinkField('page', $settings); |
80 | 80 |
|
81 | 81 |
// create page form |
... | ... | |
118 | 118 |
$name = $this->randomName(); |
119 | 119 |
$settings = array( |
120 | 120 |
'instance[settings][title]' => 'value', |
121 |
'instance[settings][title_value]' => $name .' [node:title]'); |
|
121 |
'instance[settings][title_value]' => $name . ' [node:title]');
|
|
122 | 122 |
$field_name = $this->createLinkField('page', $settings); |
123 | 123 |
|
124 | 124 |
// create page form |
... | ... | |
144 | 144 |
$this->drupalLogout(); |
145 | 145 |
$this->drupalGet($url); |
146 | 146 |
|
147 |
$this->assertRaw(l($name .' '. $name, $input['href']));
|
|
147 |
$this->assertRaw(l($name . ' ' . $name, $input['href']));
|
|
148 | 148 |
} |
149 | 149 |
|
150 | 150 |
// This test doesn't seem to actually work, due to lack of 'title' in url. |
... | ... | |
191 | 191 |
|
192 | 192 |
$edit = array(); |
193 | 193 |
$test_link_url = 'http://www.example.com/test'; |
194 |
$edit[$field_name .'[und][0][url]'] = $test_link_url; |
|
195 |
$title = 'title_'. $this->randomName(20); |
|
196 |
$edit[$field_name .'[und][0][title]'] = $title; |
|
194 |
$edit[$field_name . '[und][0][url]'] = $test_link_url;
|
|
195 |
$title = 'title_' . $this->randomName(20);
|
|
196 |
$edit[$field_name . '[und][0][title]'] = $title;
|
|
197 | 197 |
$edit['title'] = $name; |
198 | 198 |
|
199 | 199 |
$this->drupalGet('node/add/page'); |
... | ... | |
206 | 206 |
|
207 | 207 |
//$this->drupalGet('node/'. $node->nid); |
208 | 208 |
$this->assertText($title, 'Make sure the link title/text shows'); |
209 |
$this->assertRaw(' title="'. $test_link_url .'"', "Do we show the link url as the title attribute?");
|
|
210 |
$this->assertNoRaw(' title="['. $field_name .'-url]"');
|
|
209 |
$this->assertRaw(' title="' . $test_link_url . '"', "Do we show the link url as the title attribute?");
|
|
210 |
$this->assertNoRaw(' title="[' . $field_name . '-url]"');
|
|
211 | 211 |
$this->assertTrue(module_exists('token'), t('Assure that Token Module is enabled.')); |
212 | 212 |
//$this->fail($this->content); |
213 | 213 |
} |
... | ... | |
236 | 236 |
$field_db_info = content_database_info($field); |
237 | 237 |
$url_type = str_replace('_', '-', $this->content_types[0]->type); |
238 | 238 |
|
239 |
$edit = array('attributes[title]' => '['. $field_name .'-title]',
|
|
239 |
$edit = array('attributes[title]' => '[' . $field_name . '-title]',
|
|
240 | 240 |
'enable_tokens' => TRUE); |
241 | 241 |
|
242 |
$this->drupalPost('admin/content/node-type/'. $url_type .'/fields/'. $field['field_name'],
|
|
242 |
$this->drupalPost('admin/content/node-type/' . $url_type . '/fields/' . $field['field_name'],
|
|
243 | 243 |
$edit, t('Save field settings')); |
244 | 244 |
$this->assertText(t('Saved field @field_name', array('@field_name' => $field['field_name']))); |
245 | 245 |
|
... | ... | |
248 | 248 |
|
249 | 249 |
$node = node_load($this->nodes[0]->nid); |
250 | 250 |
|
251 |
$this->drupalGet('node/'. $this->nodes[0]->nid); |
|
251 |
$this->drupalGet('node/' . $this->nodes[0]->nid);
|
|
252 | 252 |
|
253 | 253 |
$edit = array(); |
254 |
$edit[$field['field_name'] .'[0][url]'] = 'http://www.example.com/test'; |
|
255 |
$title = 'title_'. $this->randomName(20); |
|
256 |
$edit[$field['field_name'] .'[0][title]'] = $title; |
|
254 |
$edit[$field['field_name'] . '[0][url]'] = 'http://www.example.com/test';
|
|
255 |
$title = 'title_' . $this->randomName(20);
|
|
256 |
$edit[$field['field_name'] . '[0][title]'] = $title;
|
|
257 | 257 |
|
258 |
$this->drupalPost('node/'. $this->nodes[0]->nid .'/edit', $edit, t('Save'));
|
|
258 |
$this->drupalPost('node/' . $this->nodes[0]->nid . '/edit', $edit, t('Save'));
|
|
259 | 259 |
|
260 | 260 |
// Make sure we get a new version! |
261 | 261 |
$node = node_load($this->nodes[0]->nid, NULL, TRUE); |
... | ... | |
263 | 263 |
array('@title' => $node->title, |
264 | 264 |
'@type' => $this->content_types[0]->name))); |
265 | 265 |
|
266 |
$this->drupalGet('node/'. $node->nid); |
|
266 |
$this->drupalGet('node/' . $node->nid);
|
|
267 | 267 |
$this->assertText($title, 'Make sure the link title/text shows'); |
268 |
$this->assertNoRaw(' title="'. $title .'"', "We should not show the link title as the title attribute?");
|
|
269 |
$this->assertNoRaw(' title="['. $field_name .'-title]"');
|
|
268 |
$this->assertNoRaw(' title="' . $title . '"', "We should not show the link title as the title attribute?");
|
|
269 |
$this->assertNoRaw(' title="[' . $field_name . '-title]"');
|
|
270 | 270 |
//$this->fail($this->content); |
271 | 271 |
} |
272 | 272 |
|
... | ... | |
319 | 319 |
$this->drupalLogout(); |
320 | 320 |
$this->drupalGet($url); |
321 | 321 |
|
322 |
$this->assertRaw(l($input['label'], $input['href'] .'/page')); |
|
322 |
$this->assertRaw(l($input['label'], $input['href'] . '/page'));
|
|
323 | 323 |
//$this->fail($this->content); |
324 | 324 |
} |
325 | 325 |
|
... | ... | |
372 | 372 |
$this->drupalLogout(); |
373 | 373 |
$this->drupalGet($url); |
374 | 374 |
|
375 |
$this->assertRaw(l($input['label'], $input['href'] .'/'. $this->web_user->uid)); |
|
375 |
$this->assertRaw(l($input['label'], $input['href'] . '/' . $this->web_user->uid)); |
|
376 |
} |
|
377 |
|
|
378 |
/** |
|
379 |
* Test that if you have a title and no url on a field which does not have tokens enabled, |
|
380 |
* that the title is sanitized once. |
|
381 |
*/ |
|
382 |
function testCRUDTitleOnlyTitleNoLink2() { |
|
383 |
$this->web_user = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content')); |
|
384 |
$this->drupalLogin($this->web_user); |
|
385 |
|
|
386 |
// create field |
|
387 |
$name = strtolower($this->randomName()); |
|
388 |
$field_name = 'field_' . $name; |
|
389 |
$edit = array( |
|
390 |
'fields[_add_new_field][label]' => $name, |
|
391 |
'fields[_add_new_field][field_name]' => $name, |
|
392 |
'fields[_add_new_field][type]' => 'link_field', |
|
393 |
'fields[_add_new_field][widget_type]' => 'link_field', |
|
394 |
); |
|
395 |
$this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save')); |
|
396 |
$this->drupalPost(NULL, array(), t('Save field settings')); |
|
397 |
$this->drupalPost(NULL, array( |
|
398 |
'instance[settings][url]' => 1, |
|
399 |
'instance[settings][enable_tokens]' => 0, |
|
400 |
), t('Save settings')); |
|
401 |
|
|
402 |
// Is field created? |
|
403 |
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added'); |
|
404 |
|
|
405 |
// create page form |
|
406 |
$this->drupalGet('node/add/page'); |
|
407 |
$this->assertField($field_name . '[und][0][url]', 'URL found'); |
|
408 |
|
|
409 |
$input = array( |
|
410 |
'title' => 'This & That', |
|
411 |
'href' => '', |
|
412 |
); |
|
413 |
|
|
414 |
$edit = array( |
|
415 |
'title' => $name, |
|
416 |
$field_name . '[und][0][title]' => $input['title'], |
|
417 |
$field_name . '[und][0][url]' => $input['href'], |
|
418 |
); |
|
419 |
$this->drupalPost(NULL, $edit, t('Save')); |
|
420 |
|
|
421 |
$url = $this->getUrl(); |
|
422 |
|
|
423 |
// change to anonymous user |
|
424 |
$this->drupalLogout(); |
|
425 |
$this->drupalGet($url); |
|
426 |
|
|
427 |
$this->assertRaw('This & That'); |
|
376 | 428 |
} |
377 | 429 |
} |
drupal7/sites/all/modules/link/tests/link.validate.test | ||
---|---|---|
34 | 34 |
$field_name . '[und][0][url]' => $url, |
35 | 35 |
); |
36 | 36 |
$this->drupalPost(NULL, $edit, t('Save')); |
37 |
$this->assertRaw(t(' has been created.'), 'Node created');
|
|
37 |
$this->assertRaw(' has been created.', 'Node created');
|
|
38 | 38 |
|
39 | 39 |
$nid = 1; //$matches[1]; |
40 | 40 |
|
... | ... | |
90 | 90 |
// create page form |
91 | 91 |
$this->drupalGet('node/add/page'); |
92 | 92 |
$field_name = 'field_' . $name; |
93 |
$this->assertField('edit-field-'. $name .'-und-0-title', 'Title found');
|
|
94 |
$this->assertField('edit-field-'. $name .'-und-0-url', 'URL found');
|
|
93 |
$this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
|
|
94 |
$this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
|
|
95 | 95 |
|
96 | 96 |
|
97 | 97 |
$edit = array( |
98 | 98 |
'title' => 'Simple Title', |
99 |
$field_name .'[und][0][url]' => 'edik:naw', |
|
99 |
$field_name . '[und][0][url]' => 'edik:naw',
|
|
100 | 100 |
); |
101 | 101 |
|
102 | 102 |
$this->drupalPost(NULL, $edit, t('Save')); |
103 |
$this->assertText(t('The value provided for @field is not a valid URL.', array('@field' => $name)));
|
|
103 |
$this->assertText(t('The value @value provided for @field is not a valid URL.', array('@value' => 'edik:naw', '@field' => $name)));
|
|
104 | 104 |
} |
105 | 105 |
|
106 | 106 |
/** |
... | ... | |
135 | 135 |
// create page form |
136 | 136 |
$this->drupalGet('node/add/page'); |
137 | 137 |
$field_name = 'field_' . $name; |
138 |
$this->assertField('edit-field-'. $name .'-und-0-title', 'Title found');
|
|
139 |
$this->assertField('edit-field-'. $name .'-und-0-url', 'URL found');
|
|
138 |
$this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
|
|
139 |
$this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
|
|
140 | 140 |
|
141 | 141 |
|
142 | 142 |
$edit = array( |
143 | 143 |
'title' => 'Simple Title', |
144 |
$field_name .'[und][0][url]' => 'edik:naw', |
|
144 |
$field_name . '[und][0][url]' => 'edik:naw',
|
|
145 | 145 |
); |
146 | 146 |
|
147 | 147 |
$this->drupalPost(NULL, $edit, t('Save')); |
148 |
$this->assertText(t('The value provided for @field is not a valid URL.', array('@field' => $name)));
|
|
148 |
$this->assertText(t('The value @value provided for @field is not a valid URL.', array('@field' => $name, '@value' => 'edik:naw')));
|
|
149 | 149 |
|
150 | 150 |
} |
151 | 151 |
|
... | ... | |
185 | 185 |
// create page form |
186 | 186 |
$this->drupalGet('node/add/page'); |
187 | 187 |
$field_name = 'field_' . $name; |
188 |
$this->assertField('edit-field-'. $name .'-und-0-title', 'Title found');
|
|
189 |
$this->assertField('edit-field-'. $name .'-und-0-url', 'URL found');
|
|
188 |
$this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
|
|
189 |
$this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
|
|
190 | 190 |
|
191 | 191 |
|
192 | 192 |
$edit = array( |
193 | 193 |
'title' => 'Simple Title', |
194 |
$field_name .'[und][0][url]' => 'edik:naw', |
|
194 |
$field_name . '[und][0][url]' => 'edik:naw',
|
|
195 | 195 |
); |
196 | 196 |
|
197 | 197 |
$this->drupalPost(NULL, $edit, t('Save')); |
198 |
$this->assertNoText(t('The value provided for @field is not a valid URL.', array('@field' => $name)));
|
|
198 |
$this->assertNoText(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => 'edik:naw')));
|
|
199 | 199 |
} |
200 | 200 |
|
201 | 201 |
/** |
... | ... | |
207 | 207 |
'administer nodes', |
208 | 208 |
'access administration pages', |
209 | 209 |
'access content', |
210 |
'create '. $this->content_types[0]->type .' content',
|
|
211 |
'edit any '. $this->content_types[0]->type .' content'));
|
|
210 |
'create ' . $this->content_types[0]->type . ' content',
|
|
211 |
'edit any ' . $this->content_types[0]->type . ' content'));
|
|
212 | 212 |
$this->drupalLogin($this->web_user); |
213 |
variable_set('node_options_'. $this->content_types[0]->name, array('status', 'promote')); |
|
213 |
variable_set('node_options_' . $this->content_types[0]->name, array('status', 'promote'));
|
|
214 | 214 |
$field_settings = array( |
215 | 215 |
'type' => 'link', |
216 | 216 |
'widget_type' => 'link', |
... | ... | |
227 | 227 |
|
228 | 228 |
$node = node_load($this->nodes[0]->nid); |
229 | 229 |
|
230 |
$this->drupalGet('node/'. $this->nodes[0]->nid); |
|
230 |
$this->drupalGet('node/' . $this->nodes[0]->nid);
|
|
231 | 231 |
|
232 | 232 |
$edit = array(); |
233 | 233 |
$title = $this->randomName(); |
234 | 234 |
$url = 'javascript:alert("http://example.com/' . $this->randomName() . '")'; |
235 |
$edit[$field['field_name'] .'[0][url]'] = $url; |
|
236 |
$edit[$field['field_name'] .'[0][title]'] = $title; |
|
235 |
$edit[$field['field_name'] . '[0][url]'] = $url;
|
|
236 |
$edit[$field['field_name'] . '[0][title]'] = $title;
|
|
237 | 237 |
|
238 |
$this->drupalPost('node/'. $this->nodes[0]->nid .'/edit', $edit, t('Save'));
|
|
238 |
$this->drupalPost('node/' . $this->nodes[0]->nid . '/edit', $edit, t('Save'));
|
|
239 | 239 |
//$this->pass($this->content); |
240 |
$this->assertNoText(t('The value provided for %field is not a valid URL.', array('%field' => $name)));
|
|
240 |
$this->assertNoText(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => trim($url))));
|
|
241 | 241 |
|
242 | 242 |
// Make sure we get a new version! |
243 | 243 |
$node = node_load($this->nodes[0]->nid, NULL, TRUE); |
244 | 244 |
$this->assertEqual($url, $node->{$field['field_name']}[0]['url']); |
245 | 245 |
|
246 |
$this->drupalGet('node/'. $node->nid); |
|
246 |
$this->drupalGet('node/' . $node->nid);
|
|
247 | 247 |
$this->assertNoRaw($url, 'Make sure Javascript does not display.'); |
248 | 248 |
|
249 | 249 |
// Turn the array validation back _on_. |
... | ... | |
251 | 251 |
$node_type_link = str_replace('_', '-', $node->type); |
252 | 252 |
//$this->drupalGet('admin/content/node-type/'. $node_type_link .'/fields'); ///'. $field['field_name']); |
253 | 253 |
//$this->fail($this->content); |
254 |
$this->drupalPost('admin/content/node-type/'. $node_type_link .'/fields/'. $field['field_name'], $edit, t('Save field settings'));
|
|
254 |
$this->drupalPost('admin/content/node-type/' . $node_type_link . '/fields/' . $field['field_name'], $edit, t('Save field settings'));
|
|
255 | 255 |
|
256 |
$this->drupalGet('node/'. $node->nid); |
|
256 |
$this->drupalGet('node/' . $node->nid);
|
|
257 | 257 |
// This actually works because the display_url goes through the core |
258 | 258 |
// url() function. But we should have a test that makes sure it continues |
259 | 259 |
// to work. |
... | ... | |
382 | 382 |
case FALSE: |
383 | 383 |
return "Invalid Link"; |
384 | 384 |
default: |
385 |
return "Bad Value:". $type; |
|
385 |
return "Bad Value:" . $type;
|
|
386 | 386 |
} |
387 | 387 |
} |
388 | 388 |
|
... | ... | |
460 | 460 |
$allowed_protocols = variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal')); |
461 | 461 |
foreach ($allowed_protocols as $protocol) { |
462 | 462 |
if ($protocol !== 'news' && $protocol !== 'mailto') { |
463 |
$links[] = $protocol .'://www.example.com'; |
|
463 |
$links[] = $protocol . '://www.example.com';
|
|
464 | 464 |
} |
465 | 465 |
} |
466 | 466 |
foreach ($links as $link) { |
467 | 467 |
$valid = link_validate_url($link); |
468 |
$this->assertEqual(LINK_EXTERNAL, $valid, 'Testing that '. $link .' is a valid external link.');
|
|
468 |
$this->assertEqual(LINK_EXTERNAL, $valid, 'Testing that ' . $link . ' is a valid external link.');
|
|
469 | 469 |
// The following two lines are commented out and only used for comparisons. |
470 | 470 |
//$valid2 = valid_url($link, TRUE); |
471 | 471 |
//$this->assertEqual(TRUE, $valid2, "Using valid_url() on $link."); |
... | ... | |
488 | 488 |
); |
489 | 489 |
foreach ($links as $link) { |
490 | 490 |
$valid = link_validate_url($link); |
491 |
$this->assertEqual(FALSE, $valid, 'Testing that '. $link .' is not a valid link.');
|
|
491 |
$this->assertEqual(FALSE, $valid, 'Testing that ' . $link . ' is not a valid link.');
|
|
492 | 492 |
} |
493 | 493 |
} |
494 | 494 |
} |
drupal7/sites/all/modules/link/views/link_views_handler_argument_target.inc | ||
---|---|---|
144 | 144 |
$this->ensure_my_table(); |
145 | 145 |
// Because attributes are stored serialized, our only option is to also |
146 | 146 |
// serialize the data we're searching for and use LIKE to find similar data. |
147 |
$this->query->add_where(0, $this->table_alias . '.' . $this->real_field . " LIKE '%%%s%'", serialize(array('target' => $this->argument)));
|
|
147 |
$this->query->add_where(0, $this->table_alias . ' . ' . $this->real_field . " LIKE '%%%s%'", serialize(array('target' => $this->argument)));
|
|
148 | 148 |
} |
149 | 149 |
} |
drupal7/sites/all/modules/link/views/link_views_handler_filter_protocol.inc | ||
---|---|---|
90 | 90 |
// PostGreSQL code has NOT been tested. Please report any problems to the link issue queue. |
91 | 91 |
// pgSQL requires all slashes to be double escaped in regular expressions. |
92 | 92 |
// See http://www.postgresql.org/docs/8.1/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP |
93 |
$condition .= ' OR ' . $field .' ~* \''.'^(([a-z0-9]([a-z0-9\\-_]*\\.)+)(' . $LINK_DOMAINS . '|[a-z][a-z]))' . '\'';
|
|
93 |
$condition .= ' OR ' . $field . ' ~* \'' . '^(([a-z0-9]([a-z0-9\\-_]*\\.)+)(' . $LINK_DOMAINS . '|[a-z][a-z]))' . '\'';
|
|
94 | 94 |
} |
95 | 95 |
else { |
96 | 96 |
// mySQL requires backslashes to be double (triple?) escaped within character classes. |
97 | 97 |
// See http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_regexp |
98 |
$condition .= ' OR ' . $field . ' REGEXP \''.'^(([a-z0-9]([a-z0-9\\\-_]*\.)+)(' . $LINK_DOMAINS . '|[a-z][a-z]))' . '\'';
|
|
98 |
$condition .= ' OR ' . $field . ' REGEXP \'' . '^(([a-z0-9]([a-z0-9\\\-_]*\.)+)(' . $LINK_DOMAINS . '|[a-z][a-z]))' . '\'';
|
|
99 | 99 |
} |
100 | 100 |
} |
101 | 101 |
|
drupal7/sites/all/modules/menu_attributes/CHANGELOG.txt | ||
---|---|---|
1 |
|
|
2 |
Menu attributes 7.x-1.0-rc3, 2014-07-05 |
|
3 |
------------------------------------ |
|
4 |
- #2185403 by juanjo_dv: Fixed Localizable options for link target. |
|
5 |
- 80 char coding standards |
|
6 |
- #1488960 by andrewmacpherson, michaek | JamesRobertson: Added Attributes for LI element. |
|
7 |
- #1627806 by d.clarke | clavigne: Added Move Attributes into its own fieldset within the Menu settings area. |
|
8 |
- #1894772 by amateescu, alberto56: Fixed hook_menu_attribute_info() API example. |
|
9 |
- #1909564 by opi: Fixed Typo in menu_attributes_menu_attribute_info() comment. |
|
10 |
- #1761804 by osopolar, quicksketch: Do not add empty classes produced by leading, trailing or double spaces. |
|
11 |
- #1077426 by cweagans: Followup: Fix permission checks. |
|
12 |
- #1886014 by Berdir: Fixed Argument 2 passed to _menu_attributes_form_alter() must be an array, null given. |
|
13 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules