Projet

Général

Profil

Révision 8e7483ab

Ajouté par Assos Assos il y a plus de 4 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/file_entity/admin_views_default/file.admin-content-file.inc
21 21
$handler->display->display_options['css_class'] = 'admin-views-view';
22 22
$handler->display->display_options['use_ajax'] = TRUE;
23 23
$handler->display->display_options['use_more_always'] = FALSE;
24
$handler->display->display_options['access']['type'] = 'menu';
24
$handler->display->display_options['access']['type'] = 'perm';
25
$handler->display->display_options['access']['perm'] = 'access administration pages';
25 26
$handler->display->display_options['cache']['type'] = 'none';
26 27
$handler->display->display_options['query']['type'] = 'views_query';
27 28
$handler->display->display_options['exposed_form']['type'] = 'basic';
drupal7/sites/all/modules/file_entity/file_entity.info
32 32
; We have to add a fake version so Git checkouts do not fail Media dependencies
33 33
version = 7.x-2.x-dev
34 34

  
35
; Information added by Drupal.org packaging script on 2019-09-29
36
version = "7.x-2.26"
35
; Information added by Drupal.org packaging script on 2019-11-20
36
version = "7.x-2.27"
37 37
core = "7.x"
38 38
project = "file_entity"
39
datestamp = "1569787388"
39
datestamp = "1574278088"
drupal7/sites/all/modules/file_entity/file_entity.install
1095 1095
  // database. It has been removed due to reported problems and is better
1096 1096
  // addressed by adding support for ctools default content to features.
1097 1097
}
1098

  
1099
/**
1100
 * Remove deprecated views_plugin_access_menu plugin.
1101
 */
1102
function file_entity_update_7227() {
1103
  $result = db_query("SELECT vid, id, display_options FROM {views_display}");
1104
  foreach ($result as $record) {
1105
    $options = unserialize($record->display_options);
1106
    if (isset($options['access']) && is_array($options['access']) && isset($options['access']['type']) && $options['access']['type'] === 'menu') {
1107
      $options['access'] = array(
1108
        'type' => 'perm',
1109
        'perm' => 'access administration pages',
1110
      );
1111

  
1112
      db_query("UPDATE {views_display} SET display_options = :options WHERE vid = :vid AND id = :id", array(
1113
        'vid' => $record->vid,
1114
        'id' => $record->id,
1115
        'options' => serialize($options),
1116
      ));
1117
    }
1118
  }
1119
}
1120

  
drupal7/sites/all/modules/file_entity/file_entity.pages.inc
1208 1208
  if ($archive = file_load($form_state['values']['upload'])) {
1209 1209
    if ($archiver = archiver_get_archiver($archive->uri)) {
1210 1210
      $files = $archiver->listContents();
1211
      $destination = pathinfo($archive->filename, PATHINFO_FILENAME);
1212

  
1213
      // Prepare a temporary directory to extract the archive to before saving
1214
      // it is content.
1215
      $extract_location = 'temporary://' . $destination;
1216
      $extract_location = file_destination($extract_location, FILE_EXISTS_RENAME);
1217
      if (!file_prepare_directory($extract_location, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY)) {
1218
        throw new Exception(t('Unable to prepar, a temporary directory %dir for extraction.', array('%dir' => $extract_location)));
1219
      }
1211 1220

  
1212
      $extract_dir = file_default_scheme() . '://' . pathinfo($archive->filename, PATHINFO_FILENAME);
1213
      $extract_dir = file_destination($extract_dir, FILE_EXISTS_RENAME);
1214
      if (!file_prepare_directory($extract_dir, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY)) {
1215
        throw new Exception(t('Unable to prepare directory %dir for extraction.', array('%dir' => $extract_dir)));
1221
      // Prepare target directory where files are going to be saved.
1222
      $target_dir = file_default_scheme() . '://' . $destination;
1223
      $target_dir = file_destination($target_dir, FILE_EXISTS_RENAME);
1224
      if (!file_prepare_directory($target_dir, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY)) {
1225
        throw new Exception(t('Unable to prepar, a directory %dir for extraction.', array('%dir' => $target_dir)));
1216 1226
      }
1217 1227

  
1218
      $archiver->extract($extract_dir);
1228
      $archiver->extract($extract_location);
1219 1229
      $pattern = '/' . $form_state['values']['pattern'] . '/';
1220
      if ($files = file_scan_directory($extract_dir, $pattern)) {
1221
        foreach ($files as $file) {
1230
      if ($extracted_files = file_scan_directory($extract_location, $pattern)) {
1231
        foreach ($extracted_files as $extracted_file) {
1232
          $file = new stdClass();
1233
          $file->fid = NULL;
1234
           $file->uid = $archive->uid;
1235
          $file->filename = $extracted_file->filename;
1236
          $file->origname = $extracted_file->filename;
1222 1237
          $file->status = FILE_STATUS_PERMANENT;
1223
          $file->uid = $archive->uid;
1238
          $file->filemime = file_get_mimetype($extracted_file->filename);
1239

  
1240
          // destination uri should match the current file directory hierarchy.
1241
          $file->uri = $target_dir . str_replace($extract_location, '', $extracted_file->uri);
1242

  
1243
          // Rename potentially executable files, to help prevent exploits (i.e. will
1244
          // rename filename.php.foo and filename.php to filename.php.foo.txt and
1245
          // filename.php.txt, respectively). Don't rename if 'allow_insecure_uploads'
1246
          // evaluates to TRUE.
1247
          if (!variable_get('allow_insecure_uploads', 0) && preg_match('/\.(php|pl|py|cgi|asp|js)(\.|$)/i', $file->filename) && (substr($file->filename, -4) != '.txt')) {
1248
            $file->filemime = 'text/plain';
1249
            $file->uri .= '.txt';
1250
            $file->filename .= '.txt';
1251
          }
1252

  
1253
          // prepare destination path for the extracted file while keeping the
1254
          // directory hierarchy of the file.
1255
          $destination = pathinfo($file->uri, PATHINFO_DIRNAME);
1256
          if (!file_prepare_directory($destination, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY)) {
1257
            throw new Exception(t('Unable to prepar, a directory %dir for extraction.', array('%dir' => $destination)));
1258
          }
1259

  
1260
          if (!file_unmanaged_move($extracted_file->uri, $file->uri)) {
1261
            throw new Exception(t('Could not move uploaded file %file to destination %destination.', array('%file' => $extracted_file->filename, '%destination' => $file->uri)));
1262
            return FALSE;
1263
          }
1264

  
1224 1265
          file_save($file);
1225 1266
          $form_state['files'][$file->fid] = $file;
1226 1267
        }
1227 1268
      }
1269
      // Delete extract location
1270
      file_unmanaged_delete_recursive($extract_location);
1228 1271
      drupal_set_message(t('Extracted %file and added @count new files.', array('%file' => $archive->filename, '@count' => count($files))));
1229 1272
    }
1230 1273
    else {
drupal7/sites/all/modules/file_entity/tests/file_entity_test.info
5 5
dependencies[] = file_entity
6 6
hidden = TRUE
7 7

  
8
; Information added by Drupal.org packaging script on 2019-09-29
9
version = "7.x-2.26"
8
; Information added by Drupal.org packaging script on 2019-11-20
9
version = "7.x-2.27"
10 10
core = "7.x"
11 11
project = "file_entity"
12
datestamp = "1569787388"
12
datestamp = "1574278088"
drupal7/sites/all/modules/link/CHANGELOG.txt
1
Link 7.x-1.7, 2019-11-14
2
------------------------
3
#3094381 by DamienMcKenna: Add a CHANGELOG.txt file.
4
#3094370 by DamienMcKenna: Coding standards tidy-up.
5
#3094307 by DamienMcKenna: Clean up tests a bit.
6
By DamienMcKenna: Added myself to the maintainers list.
7
#3041220 by Daniel Korte, nileema.jadhav, Deepak.Sharma, pifagor: False positive
8
  in link_validate_url() function with relative URLs with fragments.
9
#3038104 by jwilson3, cm0dit, pifagor: Support hashbang (#!) in URLs.
10
By drumm: Ensure attributes are not strings.
11
#2654246 by SurfinSpirit, moleCuleFFF, recrit, okapi1987@gmail.com, whthat,
12
  sdstyles, rajiv.singh, ac, pifagor, dgtlmoon, Chris Matthews, Nishruu: Anchor
13
  and Query urls are not supported.
14
#2943127 by sean_e_dietrich, kyuubi, Chris Matthews, ShaunLaws, pifagor: Link
15
  field with static title always shows even when no url entered.
16
#2675568 by pianomansam, Chris Matthews, pifagor: Whether URL and Title entity
17
  properties are required is incorrectly determined.
18
#2718563 by makbul_khan8, jgalletta, idebr, malcomio, joekers, b.lammers,
19
  pifagor: Use link field widget in custom form.
20
#1475790 by idebr, quicksketch, donquixote, skessler, jcfiala, stevector, Zach,
21
  bk_bigfish, balumahender, jrao, pifagor, jbitdrop, das-peter: Link should not
22
  modify $item['url'] on node_view() (causes data loss when combined with
23
  Workbench Moderation).
24
#949604 by boazr, webadpro, zilverdistel, TheRuslan, GaëlG, barraponto,
25
  jhodgdon, diqidoq, jcfiala, Gábor Hojtsy, colan, mErilainen, knalstaaf,
26
  mfernea, pifagor: Static link text cannot be translated.
27
#1993920 by lwalley, johnnybgoode, Dragan Eror, weri, idebr, Etroid, jcfiala,
28
  jsst, alex_optim, diqidoq, dandaman: Allow tel: links.
29
#2428185 by das-peter, harsha012, hgoto, recrit, eelkeblok, weseze, nironan,
30
  pifagor, Alex Bukach, diqidoq: Language prefix and relative links broken.
31
#2974486 by naidim: Title field assumed when it may not exist.
32
#2966141 by RenatoG: Add translate in help section.
33
#2574331 by RenatoG, tjhart87: Utilize link target action in rules.
34
#2653852 by sassafrass, pifagor, NWOM, RenatoG: Token displayed when field is
35
  empty.
36
#2966082 by RenatoG: Remove unused file for structure.
37
#2965798 by RenatoG: Update documentation for requirements.
38
#2965735 by RenatoG: Organize style structure. Create css folder for organizer.
39
#2965727 by RenatoG: Remove unused / commented code in views/link.views.inc.
40
#2295071 by interX, pifagor: Recursion in field formatter with views.
41
#2195699 by Dane Powell, pifagor: Generate more creative URLS with
42
  devel_generate.
43
#2536756 by gareth-davies, pifagor: Unless using the default field formatter,
44
  classes are not transformed into an array which causes a fatal error.
45
#2916152 by azinck, pifagor: Override title in field formatter.
46
#2921141 by chishah92, Ambient.Impact, RenatoG: Use a real ellpsis instead of
47
  three dots (...).
48
#2945199 by salvis, pifagor: drupal_encode_path() is called twice.
49
#2813057 by klausi, pifagor, John Cook: mailto: link with subject parameter and
50
  upper case letter does not validate.
51
#2952073 by pifagor: Change correct deskription.
52
#2930024 by Dylan Donkersgoed, pifagor: file:// links often don't work.
53
#2948578 by RenatoG: Resolve all items reported by pareview.sh.
54

  
55
Link 7.x-1.6, 2019-02-20
56
------------------------
57
Ensure attributes are not strings.
58

  
59
Link 7.x-1.5, 2018-05-13
60
------------------------
61
#2553705 and #2961210 by billywardrop, pifagor, vinmassaro, alex_optim,
62
  alex.mazaltov: Preparation of module version 1.5.
63

  
64
Link 7.x-1.5-beta3, 2018-02-21
65
------------------------------
66
By pifagor: Fixed test.
67
#2945139: options(&$options) deprecated since views2.
68
#2945137: Unused variables.
69
#2945133: Warning: Method call uses 2 parameters, but method signature uses 1
70
  parameters.
71
#2945131: Fix coding standards module.
72
#2945128: Fix coding standard test parts
73
#2901656 and #2210297 by nightwalkr, mfernea: validates that the input on the
74
  URL field actually exists as a path alias. Theme_link_formatter_link_default()
75
  doesn't work with classes defined in a preprocess function.
76
#2216399 by jemond: Provide Formatter to remove http:// or https:// from URL.
77
#1836632 by jmart: Double HTML escaping when using plain_title formatter.
78
By nileema.jadhav: Modification for bug fixes related to HTML entities in title
79
  and no protocol for url display format.
80
#2480723 by krystalcode, naidim, rrrob, sumitmadan, Argus, diqidoq, RenatoG,
81
  jbitdrop: Avoid warning in diff integration for links without title.
82
#2911860 by RenatoG: Fix tests items results.
83
By RenatoG: Fix tests.
84
#2244041 by alberto56, RenatoG: Undefined index: widget in link.module on line
85
  1341.
86
#2743401 by RenatoG, MHuebner: Use parent directory in internal url.
87
#2897563 by RenatoG: Fix Coding Standards, Best Practices and Insert
88
  Documentation in Comments for Tests.
89
#2897348 by RenatoG: Update documentation in README file for nre template of
90
  Drupal.org.
91
#2897332 by RenatoG: Fix all items of Code Review for Link.
92
#2166459 by j0rd, mstef: Notice: Undefined index: error_element in
93
  link_field_widget_error() (line 328 of link.module).
94

  
95
Link 7.x-1.5-beta2, 2017-07-25
96
------------------------------
97
#2889683 by Yago Elias, RenatoG: Protocol-less URLs should be cleaned for use.
98
#2558497 by joachim, RenatoG: property type for 'url' entity metadata property
99
  should not be 'url'.
100
#2299657 by RenatoG, egfrith, ChuChuNaKu, idebr, jtsnow, rootwork,
101
  kristiaanvandeneynde, GoddamnNoise, Leeteq, jcfiala, Remon, drumm, tobiberlin,
102
  brantwynn, klonos, Vacilando, quicksketch, mikeytown2, samuel.mortenson,
103
  brice_gato, katjam, kenorb, ultimike, Graber, rv0, othermachines, r0nn1ef,
104
  DamienMcKenna, doraf, jmart, reptilex, Berliner-dupe, jp.stacey, JonMcL: Allow
105
  any TLD because site admins can never keep up with ICANN.
106
#2499165 by jcnventura, RenatoG: Validate all latin accented chars.
107
#1295132 by Scyther, RenatoG: Unnecessary variables in link.install.
108
#1335424 by claudiu.cristea, RenatoG: Title as a select.
109
#2612176 by FluxSauce, pcambra, RenatoG: PHP Fatal error: Class
110
  'MigrateFieldHandler' not found.
111
#2693731 by Antonnavi, RenatoG: Tokens replaced on "Static title" when "Allow
112
  user-entered tokens" not enabled.
113

  
114
Link 7.x-1.5-beta1, 2017-01-14
115
------------------------------
116
#2140087 by olofjohansson, maximpodorov, mistermoper, RenatoG: Allow '0' as the
117
  link title.
118
#1418762 by num37, RenatoG, rvilar, jcfiala, randyhook: Provide default title
119
  when title is optional.
120
#2553705 by Trav84, aguilarm, michaelfavia, reshma.i, RenatoG, roopeshnaik:
121
  Static Title does not show up when using 'Optional URL' + 'Static Title' with
122
  an empty URL.
123
#2323441 by paolomainardi, sumitmadan, SylvainM, brockfanning, rob_johnston,
124
  RenatoG, mikeryan: [Patch] Migrate language argument array handling.
125
#2299657 by egfrith, RenatoG, ChuChuNaKu, idebr, jtsnow, rootwork,
126
  kristiaanvandeneynde, GoddamnNoise, Leeteq, jcfiala, Remon, drumm, tobiberlin,
127
  brantwynn, klonos, Vacilando, quicksketch, mikeytown2, samuel.mortenson,
128
  brice_gato, katjam, kenorb, ultimike, Graber, rv0, othermachines, r0nn1ef,
129
  DamienMcKenna, doraf, jmart, reptilex, jp.stacey, JonMcL: Allow any TLD
130
  because site admins can never keep up with ICANN.
131
#1909788 by mthomas, jesss, csc4, Kpolymorphic, RenatoG: Add an entity token for
132
  the display_url.
133
#2650956 by loopduplicate, amitmaity, karsumit94, RenatoG: Code standards are
134
  not followed for array modified in 2367069.
135
#2299657 by egfrith, RenatoG, ChuChuNaKu, idebr, jtsnow, rootwork,
136
  kristiaanvandeneynde, GoddamnNoise, Leeteq, jcfiala, Remon, drumm, tobiberlin,
137
  brantwynn, klonos, Vacilando, quicksketch, mikeytown2, samuel.mortenson,
138
  brice_gato, katjam, kenorb, ultimike, Graber, rv0, othermachines, r0nn1ef,
139
  DamienMcKenna, doraf, jmart, reptilex, Berliner-dupe, jp.stacey, JonMcL,
140
  peter-majmesku: Allow any TLD because site admins can never keep up with
141
  ICANN.
142
#2299657 by egfrith, ChuChuNaKu, RenatoG, idebr, jtsnow, rootwork, Leeteq,
143
  kristiaanvandeneynde, GoddamnNoise, tobiberlin, Remon, drumm, jcfiala, klonos,
144
  brantwynn, quicksketch, mikeytown2, samuel.mortenson, brice_gato, Vacilando,
145
  katjam, kenorb, ultimike, Graber, rv0, DamienMcKenna, doraf, jmart, reptilex,
146
  jp.stacey, JonMcL: Allow any TLD because site admins can never keep up with
147
  ICANN.
148
#2890057 by RenatoG: All content of file commented "link.views.inc" should be
149
  use @codingStandardsIgnoreFile tag.
150
#2299657 by egfrith, ChuChuNaKu, RenatoG, idebr, jtsnow, Leeteq, GoddamnNoise,
151
  tobiberlin, kristiaanvandeneynde, Remon, jcfiala, rootwork, drumm, klonos,
152
  brice_gato, quicksketch, brantwynn, mikeytown2, Vacilando, reptilex,
153
  samuel.mortenson, DamienMcKenna, ultimike, Graber, rv0, doraf, jp.stacey,
154
  kenorb, jmart, JonMcL, katjam: Allow any TLD because site admins can never
155
  keep up with ICANN.
156
#2890013 by RenatoG: Fix codings standards for Link.
157
#2889755 by RenatoG: Fixed Best practice in Drupal.
158
#2566443 by ohthehugemanatee, RenatoG: Broken description text when used through
159
  Form API.
160
#2888582 by RenatoG: Resolved unused variables in install file.
161
#2723993 by dhruveshdtripathi, rahul.shinde, jeevanbhushetty, RenatoG: help hook
162
  is not there.
163
#2578521 by kala4ek, arialvix, soapboxcicero, ervit, RenatoG: Validation error.
164
#2888510 by RenatoG: Create tip for token on install.
165
#2888480 by RenatoG: Fixed documentation links in new window target "blank".
166
#2888461 by RenatoG: Clear variable "link_extra_domains" on uninstall.
167
#2843813 by idebr, klausi, michael_wojcik, clemens.tolboom: Fix failing tests
168
  due to missing 'administer fields' permission.
169

  
170
Link 7.x-1.4, 2016-01-14
171
------------------------
172
UPC-99: Apply patch: link-field_link_validate_overrites_langcode-2632728.patch
173
#2470377 by rhclayto: Adding a class with underscores, the class gets rendered
174
  with hyphens
175
#609560 by Boobaa: Provide token for hostname
176
#2470968: Add README.txt
177
#2247261 by heddn, sumitmadan: URLs are not validated
178
#2513706 by rrfegade: Spelling errors in D7
179
#2055111 by joelpittet, mikeytown2: skip over re-loading entities for tokens in
180
  link field attributes unless there's a token to process.
181
#2367069 by jcfiala:Fixed entity_token for link after node_view was called.
182
Added setup function to LinkValidateUrlLight to enable link module, which was
183
  failing drupal.org qa testbot.
184
#2364673 by jcfiala: Replaced drupal_html_class() with
185
  drupal_clean_css_identifier() so that link field classes are not forced to
186
  lower case.
187
Added tests to test entity_token token with link.
188

  
189
Link 7.x-1.3, 2014-10-21
190
------------------------
191
By jcfiala: Various small fixes to pass coder review.
192
#2351223 by Xano: Improve field validation error message.
193
#2350253 by genjohnson: Fixed Link with ! (exclamation) in URL query returns
194
  "not a valid URL".
195
#1483494 by vinmassaro, cord1: Notice: Undefined index: url in _link_process()
196
  (line 345 of ../link.module).
197
#1955976 by chOP, erikhopp, idebr, d.clarke | Jim Cutler: Added Allow relative
198
  paths with validation.
199
#2117099 by tim.plunkett: Expose attributes as property info.
200
#1930430 by benjifisher: Fixed Migration integration misses title attribute for
201
  mutiple-valued link fields.
202
#97766 by tanepiper, heddn, timbrandin, droath, alanburke, Digidog: Class
203
  attribute field option for each dataset in link widget.
204
#1266474 by redndahead, franz, RobLoach, jcfiala, markabur: Use field label as
205
  the label for the title field
206
#2036645 by lex0r: restricting the explode to 2 items when breaking apart
207
  querystrings helps prevent problems with unescaped = characters in the data.
208
#2223571 by jcfiala: Included new tld that had been included into the 6.x-2.x
209
  branch.
210
#1836632 by jcfiala:Removed double-encoding of titles when url not specified in
211
  link field.
212
#1980736 by Cottser: Allow child elements of the link field to be rendered.
213

  
214
Link 7.x-1.2, 2013-11-24
215
------------------------
216
#1866632 by mohamadaliakbari,poiu:Adding rtl support to the link field.
217
#1928116 by jcfiala: Added field variable to variables for link formatter
218
  functions in hook_theme.
219
#2141643:Applying changes suggested by coder
220
#2043001 by zhuber:Add xxx to list of top level domains.
221
#2036115 by Samvel:Validation of link field was not being properly passed
222
  through to hook_field_widget_error().
223
#1616752 by Taran2L:Period in names of querystring items was being replaced with
224
  underscores.
225
#2123277 by zhuber:Link devel generate was applying titles to links with no
226
  title set.
227
#1936784 by jeffam, illmasterc: Ampersands were being escaped in urls.
228
#1784862 by aaronbauman: Added dialog switch to code displaying available
229
  tokens.
230
#1914286 by facine: Fixes Title value in link_field_update_instance undefined
231
  error.
232
#1918850 by jsacksick: Prevents undefined variable messages in
233
  link_i18n_string_list_field_alter().
234

  
235
Link 7.x-1.1, 2013-02-09
236
------------------------
237
By jcfiala: Fixed broken token tests - setUp on LinkBaseTestClass was broken.
238
#949604 by zilverdistel: Added i18n support for the static link text field
239
  option.
240
#1909314 by Simon Georges: Removing link.install from the link.info files[]
241
  array.
242
By jcfiala: Removed all places where #markup was being set to a theme function
243
  output with #theme.
244
#1674284 by sun, jcfiala: Cleaning up the code to Drupal standards, this time
245
  with the tests.
246
#1674284 by sun, jcfiala: Cleaning up the code to Drupal standards.
247
By hass:Fixing a string in the target argument handler to be t-compatible.
248
By hackwater: Fixed minor typo which spelled automatically wrong.
249
#1458502 by eugene.brit:Fixing Undefined index: target in _link_sanitize()
250
#1010850 by benjifisher: Update MigrateFieldHandler to work with migrate-7.x-2.4
251
  and later.
252
#1889918 by jcfiala,Boobaa: Changed the bad url error message to include the
253
  field's label.
254
#1179944 by jcfiala, mr.york: Added variable_get calls so that the list of TLD
255
  that pass validation can be set by admins.
256
#1766150 by jcfiala: Blank urls will no longer be treated the same as links to
257
  <front>.
258
#1686024 by Alan D.: Added implementation of hook_field_diff_view().
259
#1715246 by Haza, jcfiala: Fixed strict warning when loading entity for token
260
  use, also fixed problem with the title attribute not being handeld properly.
261
#1309768 by jcfiala: Made URL label of url-only link fields invisible instead of
262
  removing it, to be 508 compliant.
263
#1645640 by barraponto:Fixing <front> links as well as double-printing of
264
  querystring.
265
By jcfiala: Fixed how possible tokens are displayed when setting up a link field
266
  - had been using a variable which was not defined in that scope.
267
#43870: Cleaned up and conslidated the link formatter tests so that the tests
268
  can run faster.
269
#438770: Fixed code to align with tests - handling the 'token type' fetching
270
  better and fixing the separate link display to match previous functionality.
271
#1047444 by Sweetchuck, jcfiala: Updated how tokens are handled so that the
272
  proper token references are used, and not just 'node'.
273
#1309658 by jcfiala: Small nudge to the views tokens fix to handle problem with
274
  relative links going through url() twice.
275
#472766 by mstrelan: Added new formatter to display domain as link.
276
#1710578 by jcfiala: Added code to prevent unnecessary = signs in querystrings.
277
#1309658 by jcfiala: Rearranged the link code so that the query and fragment are
278
  not separated from the url so that views can access them in a token.
279
#1290904 by gordon:Moved link processing on save from the hook_field_presave
280
  link to the hook_field_insert/update hook to prevent problem with
281
  field_attach_update.
282
#1525668 by mikeryan: Removed type-hint of $entity in the migrate prepare
283
  handler.
284
#1599314 by arpieb: Adding spaces, periods, and parenthesis to internal file
285
  paths.
286
#1368616 by grndlvl: Fix required marker so it shows if title is not displayed.
287
#1512954 by jfiala, mikeytown2: Added code to prevent error in
288
  theme_link_formatter_link_plain(), improved use of $link_options array in
289
  theme functions.
290
#1125766 by jcfiala, David Stosik, Eric_A: Provided default value for link
291
  targets when link field uses user input for target.
292
#1230256 by yched: Fixed D6 migration (cck_migrate()).
293
#1218428 by twistor, Digidog: Fixed - Link tests, LinkValidateUrlLight because
294
  link validate_url is called but not available.
295
#1409980 by luisortizramos, effulgentsia, Digidog: Fixed - Validation error
296
  -Invalid URL- is not reported properly. The corresponding form_set_error()
297
  calls have been fixed.
298
#1441702 by Digidog: Fixed - Rel attribute should have an option to get
299
  automaticly turned on/off if link is internal/external.
300
#1418674 by rvilar, Digidog: Fixed - Bad variable concatenation in t() function-
301
#1321482 by Liam Morland, KarlShea, Summit, Jevedor, Digidog: Fixed -Query
302
  string and fragment are removed, resulting in parts of the URL being lost-
303
#1066328 by Bevan, jcfiala, dkingofpa, sammys, Digidog: Formatter for use with
304
  url() and Views its -output this field as a link- fields (Absolute url
305
  formatter added).
306
#1429684 by das-pater: Dont unserialize already unserialized attributes in
307
  _link_load(). The patch contains condition before unserialize in _link_load(),
308
  link_views_handler_argument_target::query() is now compatible to its parent to
309
  avoid php strict notices.
310
#698438 by tim.plunkett: Added support for Devel Generate
311
#1010850 by jcfiala, quartsize, raman2385, Bevan, eporama, das-peter,
312
  smithmilner, Digidog: Fixed MigrateFieldHandler to work with Migrate Module.
313

  
314
Link 7.x-1.0, 2011-10-23
315
------------------------
316
#1318850 by Digidog: Fixed completion of special chars for function
317
  link_validate_url() in line 916.
318
#1199806 by ss81, jcfiala, Digidog: Fixed fatal error when the link URl is equal
319
  to page URL.
320
#1307788 Feature request by nmc, tars16, Digidog: Fixed Add custom maxlength to
321
  link title text.
322
#1217396 by WilliamB,noahb,orakili,Digidog: Fixed options multiple-value &
323
  required break input/save and produces error: At least one title or URL must
324
  be entered.
325
#1036628 by gargoyle,jcfiala,wizonesolutions,Digidog: Fixed to allow more
326
  special chars in url validation for use cases like twitter etc. (f.e.: # , ~ )
327
#948658 by brenk28, Dave Reid, becw, jcfiala, iMiksu, BTMash, Digidog: Fixed
328
  noticeof Undefined index: title in _link_sanitize() - hopefully, finally.
329
#1079782 by fago, klausi, drunken monkey, jcfiala, Digidog: Fixed support for
330
  hook_entity_property_info() including search API and Rules. @TODO: needs
331
  simpletests to be submitted for rc1.
332

  
333
Link 7.x-1.0-beta1, 2011-09-26
334
-------------------------------
335
#1264208 by lazysoundsystem, Digidog: Fixed recursive serialization of
336
  attributes.
337
#1218422 by Dave Reid, twistor, Digidog: Fixed tests files: strict warnings
338
  about static getInfo and parameters for setUp(), whitespace, and file
339
  structure.
340
#1038444 by Dave Reid, Digidog: Fixed 3 issues plus #required on title prevents
341
  submission. All issues have been fixed with patch of Dave Reid from January.
342
  Patch manually retrieved for latest 7.x-1.x by Digidog.
343
#1105816 by thekevinday, jcfiala, Digidog: Fixed improper use of db_type by
344
  committing patch of thekevinday at comment-5028534.
345
#335281 by thePanz, jcfiala, stella, Digidog: committed patch by stella
346
  #comment-4929778 for title attribute support.
347
#519416 by jcfiala: Added the plain text display of just the link title, which
348
  was available in 6.x but had not been added to 7.x yet.
349
By jcfiala: Added slight changes to how links are validated to bring them in
350
  line withvalid_url().
351
#1148864 by jcfiala: Re-enabled the ability to turn off url validation.
352
#1063764 by bdragon,jcfiala: Renamed all field formatters to start with 'link_'
353
  so they will be unique.
354
#1078254 by jcfiala: added a hook_update_n call that copies settings from the
355
  field to the instance.
356
#1126384 by burki: Started using field_widget_instance to get link field
357
  settings in link_field_process, which is more standard than hunting in the
358
  for it.
359
#1125384 by Rob Loach: Changed url length in link_field_schema to not use the
360
  constant which is not always defined.
361
#1043348 by jcfiala: Finished updating the formatting code so that querystrings
362
  and fragments of urls work as in 6.x-2.x.
363
#438770 by jcfiala: Adding test that makes sure the 'plain url' formatter is
364
  working properly with the basic case.
365
#1043348 by jcfiala: First pass at fixing problems with raw www.example.com urls
366
  ending up as index.php?q=www.example.com. Need more testing/fixing with
367
  fragments and querystrings - not complete.
368
#1056364 by the_phi: Checking that ['settings']['enable_tokens'] exists before
369
  the value is compared.
370
#1078736 by jcfiala: Added empty handler for hook_link_form_settings to make
371
  ield Permissions work.
372

  
373
Link 7.x-1.0-alpha3, 2011-02-07
374
-------------------------------
375
bug report #1008562 by jcfiala: Looking into URL, as link error caused me to
376
  realize that the _link_sanitize was being called in the wrong place - now
377
  called on link_field_prepare_view.
378
bug report by jcfiala: Fixed error from missing index by changing ['required']
379
  to ['required'].
380
bug report #1026040 by pcambra: Updated token help to use the updated token
381
  module and token display.
382
bug report #1033112 by Dave Reid: Removing extra lines from link.info.
383
task #970392 by jcfiala: Added content_migrate_field_alter and
384
  content_migrate_instance_alter hooks to link.module to help with upgrading
385
  from D6 to D7.
386
feature request #1012372 by jcfiala: Tried using
387
  hook_field_instance_settings_form to allow per-instance settings. Also,
388
  re-added a bunch of old tests from 6.x.
389

  
390
Link 7.x-1.0-alpha2, 2010-12-13
391
-------------------------------
392
task #960062 by jcfiala: Added package of 'fields' to the link.info file.
393
task #997270 by jcfiala: Removed content in link.views.inc, and added file
394
  references to the link_views_handler files in link.info for better views
395
  integration.
396
By jcfiala: Added more code to attribute test.
397
By jcfiala: Edited the two test files so that simpletests run without error,
398
  although they don't test nearly enough.
399
bug report #952656 by Dave_Reid: Moved hook_field_schema() to link.install,
400
  other small tweaks to remove old references.
401
bug report #948628 by brenk28, bec: Fixing setting references in and removing
402
  calls to see if token is enabled.
403

  
404
Link 7.x-1.0-alpha1, 2010-12-07
405
-------------------------------
406
#955214 by alex_b,jcfiala: Fixed problem where a url with a querystring caused
407
  fatal errors.
408
#956182 by jmiccolis, bec, Bevan: Theme fixing for the theme_link_field
409
#696678 by tristanoneil: Link module now showing basic functionality - still not
410
  done, but better.
411
#696678 by Garrett Albright: Initial attempt at updating Link module to Drupal 7
412
  - does not really work but is a start.
413
By dropcube: First working copy of the 7.x version.
drupal7/sites/all/modules/link/README.txt
22 22
input conversion, and many more.
23 23

  
24 24

  
25

  
26 25
REQUIREMENTS
27 26
------------
28 27

  
29
Project in Drupal 7 requires the following modules:
30

  
31
 * Fields API (Fields API is provided already by core)
32
 * Panels (https://drupal.org/project/panels)
33

  
34
Drupal 8:
35

  
36
 * Link is in core now. No installation needed. Yay! Don't forget to activate
37
   it. It's deactivated by default.
28
No special requirements
38 29

  
39 30

  
40 31
INSTALLATION
......
99 90
 * Tom Kirkpatrick (mrfelton) - https://www.drupal.org/user/305669
100 91
 * Sumit Madan (sumitmadan) - https://www.drupal.org/user/1538790
101 92
 * Daniel Kudwien (sun) - https://www.drupal.org/user/54136
93
 * Damien McKenna - https://www.drupal.org/u/damienmckenna
drupal7/sites/all/modules/link/link-rtl.css
1
.link-field-column {
2
  float: right;
3
}
4
.link-field-column.link-field-url .form-text {
5
  direction: ltr;
6
  text-align: left;
7
}
drupal7/sites/all/modules/link/link.devel_generate.inc
21 21
 * Callback for hook_devel_generate().
22 22
 */
23 23
function _link_devel_generate($object, $field, $instance, $bundle) {
24
  $url = 'http://example.com/' . devel_generate_word(mt_rand(6, 12));
24 25
  $link = array(
25
    'url' => url('<front>', array('absolute' => TRUE)),
26
    'url' => url($url, array('absolute' => TRUE)),
26 27
    'attributes' => _link_default_attributes(),
27 28
  );
28 29
  if ($instance['settings']['title'] != 'none') {
drupal7/sites/all/modules/link/link.info
13 13
files[] = tests/link.token.test
14 14
files[] = tests/link.entity_token.test
15 15
files[] = tests/link.validate.test
16
files[] = tests/link.multilingual.test
16 17

  
17 18
; Views Handlers
18 19
files[] = views/link_views_handler_argument_target.inc
19 20
files[] = views/link_views_handler_filter_protocol.inc
20 21

  
21
; Information added by Drupal.org packaging script on 2019-02-20
22
version = "7.x-1.6"
22
; Information added by Drupal.org packaging script on 2019-11-14
23
version = "7.x-1.7"
23 24
core = "7.x"
24 25
project = "link"
25
datestamp = "1550680687"
26
datestamp = "1573731676"
drupal7/sites/all/modules/link/link.install
12 12
 */
13 13

  
14 14
/**
15
 * Implements hook_uninstall().
15
 * Implements hook_install().
16 16
 */
17 17
function link_install() {
18 18
  // Notify the user they may want to install token.
drupal7/sites/all/modules/link/link.module
8 8
define('LINK_EXTERNAL', 'external');
9 9
define('LINK_INTERNAL', 'internal');
10 10
define('LINK_FRONT', 'front');
11
define('LINK_FRAGMENT', 'fragment');
12
define('LINK_QUERY', 'query');
11 13
define('LINK_EMAIL', 'email');
14
define('LINK_TEL', 'tel');
12 15
define('LINK_NEWS', 'news');
16
define('LINK_FILE', 'file');
13 17
define('LINK_TARGET_DEFAULT', 'default');
14 18
define('LINK_TARGET_NEW_WINDOW', '_blank');
15 19
define('LINK_TARGET_TOP', '_top');
......
26 30
function link_help($path, $arg) {
27 31
  switch ($path) {
28 32
    case 'admin/help#link':
29
      $output = '<p><strong>About</strong></p>';
30
      $output .= '<p>' . 'The link provides a standard custom content field for links. Links can be easily added to any content types and profiles and include advanced validating and different ways of storing internal or external links and URLs. It also supports additional link text title, site wide tokens for titles and title attributes, target attributes, css class attribution, static repeating values, input conversion, and many more.' . '</p>';
31
      $output .= '<p>' . '<strong>Requirements / Dependencies</strong>' . '</p>';
33
      $output = '<p><strong>' . t('About') . '</strong></p>';
34
      $output .= '<p>' . t('The link provides a standard custom content field for links. Links can be easily added to any content types and profiles and include advanced validating and different ways of storing internal or external links and URLs. It also supports additional link text title, site wide tokens for titles and title attributes, target attributes, css class attribution, static repeating values, input conversion, and many more.') . '</p>';
35
      $output .= '<p><strong>' . t('Requirements / Dependencies') . '</strong></p>';
32 36
      $output .= '<p>' . 'Fields API is provided already by core [no dependencies].' . '</p>';
33 37
      $output .= '<p><strong>Configuration</strong></p>';
34 38
      $output .= '<p>' . 'Configuration is only slightly more complicated than a text field. Link text titles for URLs can be made required, set as instead of URL, optional (default), or left out entirely. If no link text title is provided, the trimmed version of the complete URL will be displayed. The target attribute should be set to "_blank", "top", or left out completely (checkboxes provide info). The rel=nofollow attribute prevents the link from being followed by certain search engines.' . '</p>';
......
195 199
    '#size' => 3,
196 200
  );
197 201

  
202
  // Target options. E.g. New window = target="_blank".
198 203
  $target_options = array(
199 204
    LINK_TARGET_DEFAULT => t('Default (no target attribute)'),
200 205
    LINK_TARGET_TOP => t('Open link in window root'),
201 206
    LINK_TARGET_NEW_WINDOW => t('Open link in new window'),
202 207
    LINK_TARGET_USER => t('Allow the user to choose'),
203 208
  );
209

  
204 210
  $form['attributes'] = array(
205 211
    '#tree' => TRUE,
206 212
  );
213

  
207 214
  $form['attributes']['target'] = array(
208 215
    '#type' => 'radios',
209 216
    '#title' => t('Link Target'),
......
300 307
  foreach ($entities as $id => $entity) {
301 308
    foreach ($items[$id] as $delta => $item) {
302 309
      $items[$id][$delta]['attributes'] = _link_load($field, $item, $instances[$id]);
310
      $items[$id][$delta]['original_title'] = $item['title'];
311
      $items[$id][$delta]['original_url'] = $item['url'];
303 312
    }
304 313
  }
305 314
}
......
525 534
 */
526 535
function _link_sanitize(&$item, $delta, &$field, $instance, &$entity) {
527 536
  // @codingStandardsIgnoreEnd
537
  // As this function can be called multiple times and the item is changed by
538
  // reference we need to ensure that there's always the original data to
539
  // process otherwise processed data are processed again which might leads to
540
  // unexpected results.
541
  if (isset($item['_link_sanitized'])) {
542
    return;
543
  }
544

  
545
  // Store a flag to check in case of a second call.
546
  $item['_link_sanitized'] = TRUE;
547

  
528 548
  // Don't try to process empty links.
529 549
  if (empty($item['url']) && empty($item['title'])) {
530 550
    return;
......
561 581
  if ($type == FALSE && $instance['settings']['validate_url'] === 0) {
562 582
    $type = LINK_EXTERNAL;
563 583
  }
584
  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'];
587
  }
564 588
  $url = link_cleanup_url($item['url']);
565 589
  $url_parts = _link_parse_url($url);
566 590

  
567 591
  if (!empty($url_parts['url'])) {
568
    $item['url'] = url($url_parts['url'],
569
      array(
570
        'query' => isset($url_parts['query']) ? $url_parts['query'] : NULL,
571
        'fragment' => isset($url_parts['fragment']) ? $url_parts['fragment'] : NULL,
572
        'absolute' => !empty($instance['settings']['absolute_url']),
573
        'html' => TRUE,
574
      )
575
    );
592
    $item = array(
593
      'url' => $url_parts['url'],
594
      'query' => isset($url_parts['query']) ? $url_parts['query'] : NULL,
595
      'fragment' => isset($url_parts['fragment']) ? $url_parts['fragment'] : NULL,
596
      'absolute' => !empty($instance['settings']['absolute_url']),
597
      'html' => TRUE,
598
    ) + $item;
576 599
  }
577 600

  
578 601
  // Create a shortened URL for display.
579 602
  if ($type == LINK_EMAIL) {
580 603
    $display_url = str_replace('mailto:', '', $url);
581 604
  }
605
  elseif ($type === LINK_EXTERNAL) {
606
    $display_url = $item['url'];
607
  }
608
  elseif ($type == LINK_TEL) {
609
    $display_url = str_replace('tel:', '', $url);
610
  }
582 611
  else {
583 612
    $display_url = url($url_parts['url'],
584 613
      array(
......
589 618
    );
590 619
  }
591 620
  if ($instance['settings']['display']['url_cutoff'] && strlen($display_url) > $instance['settings']['display']['url_cutoff']) {
592
    $display_url = substr($display_url, 0, $instance['settings']['display']['url_cutoff']) . "...";
621
    $display_url = substr($display_url, 0, $instance['settings']['display']['url_cutoff']) . "";
593 622
  }
594 623
  $item['display_url'] = $display_url;
595 624

  
......
602 631
    }
603 632
  }
604 633
  // Use the title defined by the user at the widget level.
605
  elseif (drupal_strlen(trim($item['title']))) {
634
  elseif (isset($item['title']) && drupal_strlen(trim($item['title']))) {
606 635
    $title = $item['title'];
607 636
  }
608 637
  // Use the static title if a user-defined title is optional and a static title
......
702 731
      else {
703 732
        $entity_loaded = $entity;
704 733
      }
705
      $item['attributes']['title'] = token_replace($item['attributes']['title'], array($entity_token_type => $entity_loaded));
734
      $item['attributes']['title'] = token_replace($item['attributes']['title'], array($entity_token_type => $entity_loaded), array('clear' => TRUE));
706 735
    }
707 736
    $item['attributes']['title'] = filter_xss($item['attributes']['title'], array(
708 737
      'b',
......
851 880
 * Formats a link field widget.
852 881
 */
853 882
function theme_link_field($vars) {
854
  drupal_add_css(drupal_get_path('module', 'link') . '/link.css');
883
  drupal_add_css(drupal_get_path('module', 'link') . '/css/link.css');
855 884
  $element = $vars['element'];
856 885
  // Prefix single value link fields with the name of the field.
857 886
  if (empty($element['#field']['multiple'])) {
......
916 945
 */
917 946
function link_field_process($element, $form_state, $complete_form) {
918 947
  $instance = field_widget_instance($element, $form_state);
948
  if (!$instance) {
949
    // The element comes from a custom form, we have to manually create the
950
    // $instance settings.
951
    $instance['settings'] = array(
952
      'title_maxlength' => isset($element['#title_maxlength']) ? $element['#title_maxlength'] : 128,
953
      'title' => isset($element['#title_mode']) ? $element['#title_mode'] : 'optional',
954
      'title_label_use_field_label' => isset($element['#title_label_use_field_label']) ? $element['#title_label_use_field_label'] : FALSE,
955
      'url' => isset($element['#url']) ? $element['#url'] : 'optional',
956
    );
957
    if (isset($element['#attributes'])) {
958
      $instance['settings']['attributes'] = $element['#attributes'];
959
    }
960
  }
919 961
  $settings = $instance['settings'];
920 962
  $element['url'] = array(
921 963
    '#type' => 'textfield',
......
1017 1059
      'label' => t('Title, as link (default)'),
1018 1060
      'field types' => array('link_field'),
1019 1061
      'multiple values' => FIELD_BEHAVIOR_DEFAULT,
1062
      'settings' => array(
1063
        'custom_title' => '',
1064
      ),
1020 1065
    ),
1021 1066
    'link_title_plain' => array(
1022 1067
      'label' => t('Title, as plain text'),
......
1088 1133
      '#default_value' => $settings['strip_www'],
1089 1134
    );
1090 1135
  }
1136
  if ($display['type'] == 'link_default') {
1137
    $element['custom_title'] = array(
1138
      '#title' => t('Override title'),
1139
      '#description' => t('Optionally override the title for the link(s).'),
1140
      '#type' => 'textfield',
1141
      '#default_value' => $settings['custom_title'],
1142
    );
1143
  }
1091 1144
  return $element;
1092 1145
}
1093 1146

  
......
1106 1159
      return t('Leave www. in domain');
1107 1160
    }
1108 1161
  }
1162
  if ($display['type'] == 'link_default') {
1163
    if ($display['settings']['custom_title']) {
1164
      return t('Title: %title', array('%title' => $display['settings']['custom_title']));
1165
    }
1166
  }
1109 1167
  return '';
1110 1168
}
1111 1169

  
......
1115 1173
function link_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
1116 1174
  $elements = array();
1117 1175
  foreach ($items as $delta => $item) {
1176
    if (!empty($display['settings']['custom_title'])) {
1177
      $item['title'] = $display['settings']['custom_title'];
1178
    }
1118 1179
    $elements[$delta] = array(
1119 1180
      '#theme' => 'link_formatter_' . $display['type'],
1120 1181
      '#element' => $item,
1121 1182
      '#field' => $instance,
1122
      '#display' => $display,
1183
      '#display' => array(
1184
        'settings' => $display['settings'],
1185
      ),
1123 1186
    );
1124 1187
  }
1125 1188
  return $elements;
......
1138 1201
  }
1139 1202
  // Display a normal link if both title and URL are available.
1140 1203
  if (!empty($vars['element']['title']) && !empty($vars['element']['url'])) {
1141
    return l($vars['element']['title'], $vars['element']['url'], $link_options);
1204
    return l($vars['element']['title'], rawurldecode($vars['element']['url']), $link_options);
1142 1205
  }
1143 1206
  // If only a title, display the title.
1144 1207
  elseif (!empty($vars['element']['title'])) {
1145 1208
    return !empty($link_options['html']) ? $vars['element']['title'] : check_plain($vars['element']['title']);
1146 1209
  }
1147 1210
  elseif (!empty($vars['element']['url'])) {
1148
    return l($vars['element']['title'], $vars['element']['url'], $link_options);
1211
    return l($vars['element']['title'], rawurldecode($vars['element']['url']), $link_options);
1149 1212
  }
1150 1213
}
1151 1214

  
......
1222 1285
 */
1223 1286
function theme_link_formatter_link_url($vars) {
1224 1287
  $link_options = $vars['element'];
1288
  if (isset($link_options['attributes']['class'])) {
1289
    $link_options['attributes']['class'] = array($link_options['attributes']['class']);
1290
  }
1225 1291
  unset($link_options['title']);
1226 1292
  unset($link_options['url']);
1227 1293
  return $vars['element']['url'] ? l($vars['element']['display_url'], $vars['element']['url'], $link_options) : '';
......
1244 1310
  $link_options = $vars['element'];
1245 1311
  unset($link_options['title']);
1246 1312
  unset($link_options['url']);
1247
  return $vars['element']['url'] ? l($vars['field']['label'], $vars['element']['url'], $link_options) : '';
1313
  $label = $vars['field']['label'];
1314
  if (function_exists('i18n_string_translate')) {
1315
    $i18n_string_name = "field:{$vars['field']['field_name']}:{$vars['field']['bundle']}:label";
1316
    $label = i18n_string_translate($i18n_string_name, $label);
1317
  }
1318
  return $vars['element']['url'] ? l($label, $vars['element']['url'], $link_options) : '';
1248 1319
}
1249 1320

  
1250 1321
/**
......
1365 1436
  $type = link_url_type($text);
1366 1437

  
1367 1438
  if ($type && ($type == LINK_INTERNAL || $type == LINK_EXTERNAL)) {
1368
    $flag = valid_url($text, TRUE);
1439
    $flag = valid_url($text, $type == LINK_EXTERNAL);
1369 1440
    if (!$flag) {
1370 1441
      $normal_path = drupal_get_normal_path($text, $langcode);
1371 1442
      $parsed_link = parse_url($normal_path, PHP_URL_PATH);
......
1504 1575

  
1505 1576
  $link_ichars = $link_ichars_domain . (string) html_entity_decode(implode("", array(
1506 1577
      // ß.
1507
      "&#x00DF;",
1508
    )), ENT_QUOTES, 'UTF-8');
1578
    "&#x00DF;",
1579
  )), ENT_QUOTES, 'UTF-8');
1509 1580
  $allowed_protocols = variable_get('filter_allowed_protocols', array(
1510 1581
    'http',
1511 1582
    'https',
1512 1583
    'ftp',
1584
    'file',
1513 1585
    'news',
1514 1586
    'nntp',
1515 1587
    'telnet',
......
1518 1590
    'ssh',
1519 1591
    'sftp',
1520 1592
    'webcal',
1593
    'tel',
1521 1594
  ));
1522 1595
  $link_domains = _link_domains();
1523 1596

  
......
1538 1611

  
1539 1612
  $directories = "(?:\/[a-z0-9" . $link_ichars . "_\-\.~+%=&,$'#!():;*@\[\]]*)*";
1540 1613
  // Yes, four backslashes == a single backslash.
1541
  $query = "(?:\/?\?([?a-z0-9" . $link_ichars . "+_|\-\.~\/\\\\%=&,$'!():;*@\[\]{} ]*))";
1542
  $anchor = "(?:#[a-z0-9" . $link_ichars . "_\-\.~+%=&,$'():;*@\[\]\/\?]*)";
1614
  $query = "(?:\/?\?([?a-zA-Z0-9" . $link_ichars . "+_|\-\.~\/\\\\%=&,$'!():;*@\[\]{} ]*))";
1615
  $anchor = "(?:#[a-zA-Z0-9" . $link_ichars . "_\-\.~+%=&,$'():;*@\[\]\/\?!]*)";
1543 1616

  
1544 1617
  // The rest of the path for a standard URL.
1545 1618
  // @codingStandardsIgnoreLine
......
1551 1624

  
1552 1625
  $user = '[a-zA-Z0-9' . $link_ichars . '_\-\.\+\^!#\$%&*+\/\=\?\`\|\{\}~\'\[\]]+';
1553 1626
  $email_pattern = '/^mailto:' . $user . '@' . '(?:' . $domain . '|' . $ipv4 . '|' . $ipv6 . '|localhost)' . $query . '?$/';
1627
  $tel_pattern = '/^tel:(?:\+[1-9]\d{1,14}|\d{2,15})$/';
1628

  
1629
  $file_pattern = "/^(?:file:\/\/)" . "(?:\/?[a-z0-9" . $link_ichars . "_\-\.\\\~+%=&,$'#!():;*@\[\]]*)*" . '$/i';
1554 1630

  
1555 1631
  if (strpos($text, '<front>') === 0) {
1556 1632
    return LINK_FRONT;
......
1558 1634
  if (in_array('mailto', $allowed_protocols) && preg_match($email_pattern, $text)) {
1559 1635
    return LINK_EMAIL;
1560 1636
  }
1637
  if (strpos($text, '#') === 0) {
1638
    return LINK_FRAGMENT;
1639
  }
1640
  if (strpos($text, '?') === 0) {
1641
    return LINK_QUERY;
1642
  }
1643
  if (in_array('tel', $allowed_protocols) && strpos($text, 'tel:') === 0) {
1644
    if (preg_match($tel_pattern, $text)) {
1645
      // Based on our tel pattern this is a 'valid' phone number so return tel
1646
      // type.
1647
      return LINK_TEL;
1648
    }
1649
    else {
1650
      // Based on our tel pattern this is using the tel protocol, but is not a
1651
      // 'valid' phone number. If we don't return false here $text will match
1652
      // LINK_EXTERNAL which is incorrect.
1653
      return FALSE;
1654
    }
1655
  }
1561 1656
  if (in_array('news', $allowed_protocols) && preg_match($news_pattern, $text)) {
1562 1657
    return LINK_NEWS;
1563 1658
  }
1659
  if (in_array('file', $allowed_protocols) && preg_match($file_pattern, $text, $as)) {
1660
    return LINK_FILE;
1661
  }
1564 1662
  if (preg_match($internal_pattern . $end, $text)) {
1565 1663
    return LINK_INTERNAL;
1566 1664
  }
......
1599 1697
    $field_value['type'] = 'link_field';
1600 1698
    // Remove settings that are now on the instance.
1601 1699
    foreach (array(
1602
               'attributes',
1603
               'display',
1604
               'url',
1605
               'title',
1606
               'title_value',
1607
               'enable_tokens',
1608
               'validate_url',
1609
             ) as $setting) {
1700
      'attributes',
1701
      'display',
1702
      'url',
1703
      'title',
1704
      'title_value',
1705
      'enable_tokens',
1706
      'validate_url',
1707
    ) as $setting) {
1610 1708
      unset($field_value['settings'][$setting]);
1611 1709
    }
1612 1710
  }
......
1621 1719
  if ($field_value['type'] == 'link') {
1622 1720
    // Grab settings that were previously on the field.
1623 1721
    foreach (array(
1624
               'attributes',
1625
               'display',
1626
               'url',
1627
               'title',
1628
               'title_value',
1629
               'enable_tokens',
1630
               'validate_url',
1631
             ) as $setting) {
1722
      'attributes',
1723
      'display',
1724
      'url',
1725
      'title',
1726
      'title_value',
1727
      'enable_tokens',
1728
      'validate_url',
1729
    ) as $setting) {
1632 1730
      if (isset($field_value['settings'][$setting])) {
1633 1731
        $instance_value['settings'][$setting] = $field_value['settings'][$setting];
1634 1732
      }
......
1677 1775
  $property['auto creation'] = 'link_field_item_create';
1678 1776

  
1679 1777
  $property['property info'] = link_field_item_property_info();
1680
  $property['property info']['url']['required'] = !$instance['settings']['url'];
1681
  $property['property info']['title']['required'] = ($instance['settings']['title'] == 'required');
1778
  $property['property info']['url']['required'] = $instance['required'] && !$instance['settings']['url'];
1779
  $property['property info']['title']['required'] = $instance['required'] && ($instance['settings']['title'] == 'required');
1682 1780
  if ($instance['settings']['title'] == 'none') {
1683 1781
    unset($property['property info']['title']);
1684 1782
  }
drupal7/sites/all/modules/link/tests/link.attribute.test
35 35
  }
36 36

  
37 37
  /**
38
   * Setup.
38
   * {@inheritdoc}
39 39
   */
40
  public function setup() {
41
    parent::setup('field_ui', 'link');
40
  public function setUp(array $modules = array()) {
41
    $modules[] = 'field_ui';
42
    $modules[] = 'link';
43
    parent::setUp($modules);
44

  
42 45
    $this->zebra = 0;
46

  
43 47
    // Create and login user.
44 48
    $this->web_user = $this->drupalCreateUser(array(
45 49
      'administer content types',
......
236 240
      '@content_type_friendly' => $content_type_friendly,
237 241
      '@title' => $node_title,
238 242
    )));
239

  
240 243
  }
241 244

  
242 245
  /**
......
332 335

  
333 336
  /**
334 337
   * Formatter URL.
335
   *
336
   * @codingStandardsIgnoreStart
337 338
   */
338
  public function testFormatterURL() {
339
    // @codingStandardsIgnoreEnd
339
  public function testFormatterUrl() {
340 340
    $content_type_friendly = $this->randomName(20);
341 341
    $content_type_machine = strtolower($this->randomName(10));
342 342

  
drupal7/sites/all/modules/link/tests/link.crud.test
25 25
  }
26 26

  
27 27
  /**
28
   * Setup.
28
   * {@inheritdoc}
29 29
   */
30
  public function setUp() {
31
    parent::setUp('field_ui', 'link');
30
  public function setUp(array $modules = array()) {
31
    $modules[] = 'field_ui';
32
    $modules[] = 'link';
33
    parent::setUp($modules);
32 34
  }
33 35

  
34 36
  /**
......
36 38
   *
37 39
   * All we're doing here is creating a content type, creating a simple link
38 40
   * field on that content type.
39
   *
40
   * @codingStandardsIgnoreStart
41 41
   */
42
  public function testLinkCreateFieldAPI() {
43
    // @codingStandardsIgnoreEnd
42
  public function testLinkCreateFieldApi() {
44 43
    $content_type_friendly = $this->randomName(20);
45 44
    $content_type_machine = strtolower($this->randomName(10));
46 45

  
drupal7/sites/all/modules/link/tests/link.crud_browser.test
8 8
/**
9 9
 * Testing that users can not input bad URLs or labels.
10 10
 */
11
class LinkUITest extends DrupalWebTestcase {
11
class LinkUiTest extends DrupalWebTestcase {
12 12

  
13 13
  /**
14 14
   * Link supposed to be good.
......
37 37
  }
38 38

  
39 39
  /**
40
   * Setup.
40
   * {@inheritdoc}
41 41
   */
42
  public function setUp() {
43
    parent::setUp('field_ui', 'link');
42
  public function setUp(array $modules = array()) {
43
    $modules[] = 'field_ui';
44
    $modules[] = 'link';
45
    parent::setUp($modules);
44 46
  }
45 47

  
46 48
  /**
......
191 193
   * title actually displays <strong>.
192 194
   */
193 195
  public function testStaticLinkCreate() {
194

  
195 196
    $this->web_user = $this->drupalCreateUser(array(
196 197
      'administer content types',
197 198
      'administer fields',
......
248 249
   *
249 250
   * Testing that if you have the title but no url, the title is not sanitized
250 251
   * twice.
251
   *
252
   * @codingStandardsIgnoreStart
253 252
   */
254
  public function testCRUDTitleOnlyTitleNoLink() {
255
    // @codingStandardsIgnoreEnd
253
  public function testCrudTitleOnlyTitleNoLink() {
256 254
    $this->web_user = $this->drupalCreateUser(array(
257 255
      'administer content types',
258 256
      'administer fields',
......
309 307
   *
310 308
   * If we're creating a new field and just hit 'save' on the default options,
311 309
   * we want to make sure they are set to the expected results.
312
   *
313
   * @codingStandardsIgnoreStart
314 310
   */
315
  public function testCRUDCreateFieldDefaults() {
316
    // @codingStandardsIgnoreEnd
317

  
311
  public function testCrudCreateFieldDefaults() {
318 312
    $this->web_user = $this->drupalCreateUser(array(
319 313
      'administer content types',
320 314
      'administer fields',
......
361 355
   *
362 356
   * If we're creating a new field and just hit 'save' on the default options,
363 357
   * we want to make sure they are set to the expected results.
364
   *
365
   * @codingStandardsIgnoreStart
366 358
   */
367
  public function testCRUDCreateFieldWithClass() {
368
    // @codingStandardsIgnoreEnd
359
  public function testCrudCreateFieldWithClass() {
369 360
    $this->web_user = $this->drupalCreateUser(array(
370 361
      'administer content types',
371 362
      'administer fields',
......
443 434
   *
444 435
   * If we're creating a new field and just hit 'save' on the default options,
445 436
   * we want to make sure they are set to the expected results.
446
   *
447
   * @codingStandardsIgnoreStart
448 437
   */
449
  public function testCRUDCreateFieldWithTwoClasses() {
450
    // @codingStandardsIgnoreEnd
438
  public function testCrudCreateFieldWithTwoClasses() {
451 439
    $this->web_user = $this->drupalCreateUser(array(
452 440
      'administer content types',
453 441
      'administer fields',
drupal7/sites/all/modules/link/tests/link.entity_token.test
23 23
  }
24 24

  
25 25
  /**
26
   * Setup.
26
   * {@inheritdoc}
27 27
   */
28
  public function setUp($modules = array()) {
29
    parent::setUp(array('token', 'entity', 'entity_token'));
28
  public function setUp(array $modules = array()) {
29
    $modules[] = 'token';
30
    $modules[] = 'entity';
31
    $modules[] = 'entity_token';
32
    parent::setUp($modules);
30 33
  }
31 34

  
32 35
  /**
drupal7/sites/all/modules/link/tests/link.multilingual.test
1
<?php
2

  
3
/**
4
 * @file
5
 * Tests that exercise the relative / absolute output of the link module.
6
 */
7

  
8
/**
9
 * Testing that absolute / relative outputs match the expected format.
10
 */
11
class LinkMultilingualTestCase extends LinkBaseTestClass {
12

  
13
  /**
14
   * {@inheritdoc}
15
   */
16
  public function setUp(array $modules = array()) {
17
    $this->permissions = array_merge($this->permissions, array(
18
      'administer site configuration',
19
      'administer languages',
20
    ));
21
    $modules[] = 'locale';
22
    $modules[] = 'locale_test';
23
    $modules[] = 'translation';
24
    parent::setUp($modules);
25
  }
26

  
27
  /**
28
   * Enables and configured language related stuff.
29
   */
30
  public function setUpLanguage() {
31
    global $language_url;
32
    $this->drupalGet('admin/config/regional/language');
33
    // Enable the path prefix for the default language: this way any un-prefixed
34
    // URL must have a valid fallback value.
35
    $edit = array('prefix' => 'en');
36
    $this->drupalPost('admin/config/regional/language/edit/en', $edit, t('Save language'));
37
    $language_url->prefix = $language_url->language;
38

  
39
    // Add custom language - as we need more than 1 language to be multilingual.
40
    // Code for the language.
41
    $langcode = 'xx';
42
    // The English name for the language.
43
    $name = $this->randomName(16);
44
    // The native name for the language.
45
    $native = $this->randomName(16);
46
    $edit = array(
47
      'langcode' => $langcode,
48
      'name' => $name,
49
      'native' => $native,
50
      'prefix' => $langcode,
51
      'direction' => '0',
52
    );
53
    $this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
54
    variable_set('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX);
55

  
56
    // Enable URL language detection and selection.
57
    $edit = array('language[enabled][locale-url]' => 1);
58
    $this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
59
    language_negotiation_set(LANGUAGE_TYPE_INTERFACE, array(LOCALE_LANGUAGE_NEGOTIATION_URL));
60

  
61
    // Reset static caching.
62
    drupal_static_reset('language_list');
63
    drupal_static_reset('locale_url_outbound_alter');
64
    drupal_static_reset('locale_language_url_rewrite_url');
65
  }
66

  
67
}
68
/**
69
 *
70
 */
71
class LinkMultilingualPathTest extends LinkMultilingualTestCase {
72

  
73
  /**
74
   *
75
   */
76
  public static function getInfo() {
77
    return array(
78
      'name' => 'Link language path prefix',
79
      'description' => 'Tests that path properly work with language path prefixes.',
80
      'group' => 'Link',
81
    );
82
  }
83

  
84
  /**
85
   * Creates a link field, fills it, then uses a loaded node to test paths.
86
   */
87
  public function testLanguagePrefixedPaths() {
88
    $this->setUpLanguage();
89

  
90
    // Create fields.
91
    // Field for absolute urls.
92
    $field_name_absolute = $this->createLinkField('page');
93

  
94
    // Field for relative urls.
95
    $settings = array(
96
      'instance[settings][absolute_url]' => FALSE,
97
    );
98
    $field_name_relative = $this->createLinkField('page', $settings);
99

  
100
    // Check the node edit form.
101
    $this->drupalGet('node/add/page');
102
    $this->assertField($field_name_absolute . '[und][0][title]', 'Title absolute found');
103
    $this->assertField($field_name_absolute . '[und][0][url]', 'URL absolute found');
104
    $this->assertField($field_name_relative . '[und][0][title]', 'Title relative found');
105
    $this->assertField($field_name_relative . '[und][0][url]', 'URL relative found');
106

  
107
    // Create test content.
108
    $url_tests = array(
109
      1 => array(
110
        'href' => 'http://dummy.com/' . $this->randomName(),
111
        'label' => $this->randomName(),
112
      ),
113
      2 => array(
114
        'href' => 'node/1',
115
        'label' => $this->randomName(),
116
      ),
117
      3 => array(
118
        'href' => 'node/1?property=value',
119
        'label' => $this->randomName(),
120
        'query' => array('property' => 'value'),
121
      ),
122
      4 => array(
123
        'href' => 'node/1#position',
124
        'label' => $this->randomName(),
125
        'fragment' => 'position',
126
      ),
127
      5 => array(
128
        'href' => 'node/1?property=value2#lower',
129
        'label' => $this->randomName(),
130
        'fragment' => 'lower',
131
        'query' => array('property' => 'value2'),
132
      ),
133
    );
134
    foreach ($url_tests as $index => &$input) {
135
      $this->drupalGet('node/add/page');
136

  
137
      $edit = array(
138
        'title' => $input['label'],
139
        $field_name_absolute . '[und][0][title]' => $input['label'],
140
        $field_name_absolute . '[und][0][url]' => $input['href'],
141
        $field_name_relative . '[und][0][title]' => $input['label'],
142
        $field_name_relative . '[und][0][url]' => $input['href'],
143
      );
144
      $this->drupalPost(NULL, $edit, t('Save'));
145
      $url = $this->getUrl();
146
      $input['url'] = $url;
147
    }
148

  
149
    // Change to anonymous user.
150
    $this->drupalLogout();
151

  
152
    foreach (array_slice($url_tests, 1, NULL, TRUE) as $index => $input2) {
153
      $node = node_load($index);
154
      $this->assertNotEqual(NULL, $node, "Do we have a node?");
155
      $this->assertEqual($node->nid, $index, "Test that we have a node.");
156
      $this->drupalGet('node/' . $index);
157

  
158
      $relative_expected = url('node/1', array('absolute' => FALSE) + $input2);
159
      $absolute_expected = url('node/1', array('absolute' => TRUE) + $input2);
160

  
161
      $absolute_result = $this->xpath('//*[contains(@class, "field-name-' . drupal_clean_css_identifier($field_name_absolute) . '")]/div/div/a/@href');
162
      $absolute_result = (string) reset($absolute_result);
163
      $this->assertEqual($absolute_result, $absolute_expected, "Absolute url output ('" . $absolute_result . "') looks as expected ('" . $absolute_expected . "')");
164

  
165
      $relative_result = $this->xpath('//*[contains(@class, "field-name-' . drupal_clean_css_identifier($field_name_relative) . '")]/div/div/a/@href');
166
      $relative_result = (string) reset($relative_result);
167
      $this->assertEqual($relative_result, $relative_expected, "Relative url output ('" . $relative_result . "') looks as expected ('" . $relative_expected . "')");
168
    }
169

  
170
    // Check if this works with the alias too.
171
    // Add a path alias for node 1.
172
    $path = array(
173
      'source' => 'node/1',
174
      'alias' => $url_tests[1]['label'],
175
    );
176
    path_save($path);
177
    // Another iteration over the same nodes - this time they should use the
178
    // path alias.
179
    foreach (array_slice($url_tests, 1, NULL, TRUE) as $index => $input2) {
180
      $node = node_load($index);
181
      $this->assertNotEqual(NULL, $node, "Do we have a node?");
182
      $this->assertEqual($node->nid, $index, "Test that we have a node.");
183
      $this->drupalGet('node/' . $index);
184

  
185
      $relative_expected = url('node/1', array('absolute' => FALSE) + $input2);
186
      $absolute_expected = url('node/1', array('absolute' => TRUE) + $input2);
187

  
188
      $absolute_result = $this->xpath('//*[contains(@class, "field-name-' . drupal_clean_css_identifier($field_name_absolute) . '")]/div/div/a/@href');
189
      $absolute_result = (string) reset($absolute_result);
190
      $this->assertEqual($absolute_result, $absolute_expected, "Absolute alias-url output ('" . $absolute_result . "') looks as expected ('" . $absolute_expected . "')");
191

  
192
      $relative_result = $this->xpath('//*[contains(@class, "field-name-' . drupal_clean_css_identifier($field_name_relative) . '")]/div/div/a/@href');
193
      $relative_result = (string) reset($relative_result);
194
      $this->assertEqual($relative_result, $relative_expected, "Relative alias-url output ('" . $relative_result . "') looks as expected ('" . $relative_expected . "')");
195
    }
196
  }
197

  
198
}
drupal7/sites/all/modules/link/tests/link.test
23 23
  );
24 24

  
25 25
  /**
26
   * Setup.
26
   * {@inheritdoc}
27 27
   */
28
  public function setUp() {
29
    $modules = func_get_args();
30
    $modules = (isset($modules[0]) && is_array($modules[0]) ? $modules[0] : $modules);
28
  public function setUp(array $modules = array()) {
31 29
    $modules[] = 'field_ui';
32 30
    $modules[] = 'link';
33 31
    parent::setUp($modules);
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff