Projet

Général

Profil

Paste
Télécharger (21,6 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / menu_icons / menu_icons.module @ 13755f8d

1 85ad3d82 Assos Assos
<?php
2
/**
3
 * @file
4
 * Module to associate icons with menu items
5
 */
6
7
/**
8
 * Implements hook_menu().
9
 */
10
function menu_icons_menu() {
11
  $items['admin/config/user-interface/menu_icons'] = array(
12
    'title' => 'Menu Icon settings',
13
    'description' => 'Associates icons with menu items',
14
    'page callback' => 'drupal_get_form',
15
    'page arguments' => array('menu_icons_admin_settings'),
16
    'access arguments' => array('administer site configuration'),
17
  );
18
  return $items;
19
}
20
21
/**
22
 * Implements hook_theme_registry_alter()
23
 *   Override the nodehierarchy child links function.
24
 *
25
 * @param $theme_registry
26
 */
27
function menu_icons_theme_registry_alter(&$theme_registry) {
28
  // Override the link theming functions to hide titles if so configured.
29
  if (variable_get('menu_icons_hide_titles', FALSE)) {
30
    if (!empty($theme_registry['menu_link'])) {
31
      $theme_registry['menu_link']['function'] = 'menu_icon_menu_link';
32
    }
33
    if (!empty($theme_registry['link'])) {
34
      $theme_registry['link']['function'] = 'menu_icon_link';
35
    }
36
  }
37
}
38
39
/**
40
 * Implements hook_form_alter().
41
 */
42
function menu_icons_form_alter(&$form, $form_state, $form_id) {
43
44
  if ($form_id == 'menu_edit_item') {
45
    if (isset($form['mlid']['#value'])) {
46
      $options = unserialize(db_query('SELECT options FROM {menu_links} WHERE mlid = :mlid', array(':mlid' => $form['mlid']['#value']))->fetchField());
47
    }
48
    if (!isset($options) || !isset($options['menu_icon'])) {
49
      $options = array('menu_icon' => array('enable' => NULL, 'image_style' => NULL));
50
    }
51
52
    $form['icon'] = array(
53
      '#type' => 'fieldset',
54
      '#weight' => 5,
55
      '#title' => t('Menu icon settings'),
56
      '#description' => t('If checked, the following icon will be used as background image for this menu item.'),
57
      '#attributes' => array('classes' => array('theme-settings-bottom')),
58
    );
59
    $form['icon']['use_icon_logo'] = array(
60
      '#type' => 'checkbox',
61
      '#title' => t('Use an icon'),
62
      '#default_value' => $options['menu_icon']['enable'],
63
      '#tree' => FALSE,
64
      '#description' => t('Check this if you want this icon to be used.'),
65
    );
66
67
    $form['icon']['image_style'] = array(
68
      '#title' => t('Image style'),
69
      '#type' => 'select',
70
      '#options' => image_style_options(FALSE),
71
      '#empty_option' => '<' . t('Menu Icons default') . '>',
72
      '#default_value' => $options['menu_icon']['image_style'],
73
      '#description' => t('The preview image will be shown while editing the content.'),
74
      '#required' => FALSE,
75
    );
76
77
    $form['icon']['icon_path'] = array(
78
      '#type' => 'textfield',
79
      '#title' => t('Path to the icon'),
80
      '#default_value' => (isset($options['menu_icon']['path']) ? $options['menu_icon']['path'] : variable_get('menu_icons_default_icon', drupal_get_path('module', 'menu_icons') . '/images/default_icon.png')),
81
      '#description' => t('The path to the image you would like to use as a background image for this menu item.'),
82
    );
83
    $form['icon']['icon_path']['#states'] = array(
84
        'visible' => array (
85
        ':input[name="use_icon_logo"]' => array('checked' => TRUE),
86
      ),
87
    );
88
89
    $form['icon']['icon_upload'] = array(
90
      '#type' => 'file',
91
      '#title' => t('Upload a new icon image'),
92
      '#maxlength' => 40,
93
      '#description' => t("If you don't have direct file access to the server, use this field to upload your icon."),
94
    );
95
    $form['icon']['icon_upload']['#states'] = array(
96
        'visible' => array (
97
        ':input[name="use_icon_logo"]' => array('checked' => TRUE),
98
      ),
99
    );
100
101
    $form['submit']['#weight'] = 9;
102
    $form['delete']['#weight'] = 10;
103
104
    $form['#attributes']['enctype'] = 'multipart/form-data';
105
    $form['#submit'][] = 'menu_icons_form_submit';
106
  }
107
108
  // Add a custom submit callback for image style forms.
109
  if (in_array($form_id, array('image_style_form', 'image_effect_form', 'image_style_revert_form', 'image_style_delete_form', 'menu_icons_admin_settings'))) {
110
    $form['#submit'][] = 'menu_icons_css_generate';
111
  }
112
}
113
114
/**
115
 * Implements hook_form_FORMID_alter().
116
 */
117
function menu_icons_form_node_form_alter(&$form, &$form_state, $form_id) {
118
  if (isset($form['menu'])) {
119
    if ($form['menu']['link']['mlid']['#value']) {
120
      $options = unserialize(db_query('SELECT options FROM {menu_links} WHERE mlid = :mlid', array(':mlid' => $form['menu']['link']['mlid']['#value']))->fetchField());
121
    }
122
    if (!isset($options) || !isset($options['menu_icon'])) {
123
      $options = array('menu_icon' => array('enable' => NULL, 'image_style' => NULL));
124
    }
125
126
    $form['menu']['icon'] = array(
127
      '#type' => 'fieldset',
128
      '#weight' => 5,
129
      '#title' => t('Menu icon settings'),
130
      '#description' => t('If checked, the following icon will be used as background image for this menu item.'),
131
      '#collapsible' => TRUE,
132
      '#collapsed' => !$options['menu_icon']['enable'],
133
      '#states' => array(
134
        'invisible' => array(
135
          ':input[name="menu[enabled]"]' => array('checked' => FALSE),
136
          ),
137
        ),
138
    );
139
    $form['menu']['icon']['use_icon_logo'] = array(
140
      '#type' => 'checkbox',
141
      '#title' => t('Use an icon'),
142
      '#default_value' => $options['menu_icon']['enable'],
143
      '#tree' => FALSE,
144
      '#description' => t('Check this if you want this icon to be used.'),
145
    );
146
147
    $form['menu']['icon']['image_style'] = array(
148
      '#title' => t('Image style'),
149
      '#type' => 'select',
150
      '#options' => image_style_options(FALSE),
151
      '#empty_option' => '<' . t('Menu Icons default') . '>',
152
      '#default_value' => $options['menu_icon']['image_style'],
153
      '#description' => t('The preview image will be shown while editing the content.'),
154
      '#required' => FALSE,
155
    );
156
157
    $form['menu']['icon']['icon_path'] = array(
158
      '#type' => 'textfield',
159
      '#title' => t('Path to the icon'),
160
      '#default_value' => (isset($options['menu_icon']['path']) ? $options['menu_icon']['path'] : variable_get('menu_icons_default_icon', drupal_get_path('module', 'menu_icons') . '/images/default_icon.png')),
161
      '#description' => t('The path to the image you would like to use as a background image for this menu item.'),
162
    );
163
    $form['menu']['icon']['icon_path']['#states'] = array(
164
        'visible' => array (
165
        ':input[name="use_icon_logo"]' => array('checked' => TRUE),
166
      ),
167
    );
168
169
    $form['menu']['icon']['icon_upload'] = array(
170
      '#type' => 'file',
171
      '#title' => t('Upload a new icon image'),
172
      '#maxlength' => 40,
173
      '#description' => t("If you don't have direct file access to the server, use this field to upload your icon."),
174
      '#states' => array(
175
        'visible' => array (
176
          ':input[name="use_icon_logo"]' => array('checked' => TRUE),
177
          ),
178
        ),
179
    );
180
181
    $form['#attributes']['enctype'] = 'multipart/form-data';
182
    $form['#submit'][] = 'menu_icons_node_form_submit';
183
  }
184
}
185
186
/**
187
 * Process the submitted form
188
 */
189
function menu_icons_form_submit($form, &$form_state) {
190
  // Check the destination folder, attempt to create it if it does't exist
191
  $directory_path = menu_icons_directory_path();
192
  file_prepare_directory($directory_path, FILE_CREATE_DIRECTORY);
193
194
  // Store the current icon path
195
  $path = $form_state['values']['icon_path'];
196
197
  // Define the validation settings
198
  $validate = array(
199
    'file_validate_is_image' => array(),
200
  );
201
202
  // Check for a new uploaded icon, and use that instead.
203
  if ($file = file_save_upload('icon_upload', $validate)) {
204
    $parts = pathinfo($file->filename);
205
    $filename = $directory_path . '/menu_icon_' . $form_state['values']['mlid'] . '.' . $parts['extension'];
206
    file_unmanaged_copy($file->uri, $filename, FILE_EXISTS_REPLACE);
207
208
    // Flush image style generated images
209
    image_path_flush($filename);
210
211
    $path = $filename;
212
  }
213
214
  $options = unserialize(db_query('SELECT options FROM {menu_links} WHERE mlid = :mlid', array(':mlid' => $form_state['values']['mlid']))->fetchField());
215
  $options['menu_icon'] = array(
216
    'enable' => $form_state['values']['use_icon_logo'],
217
    'path' => $path,
218
    'image_style' => $form_state['values']['image_style'],
219
  );
220
221
  // Use default image style if not explicitly set.
222
  if (empty($options['menu_icon']['image_style'])) {
223
    $options['menu_icon']['image_style'] = variable_get('menu_icons_image_style_default', 'menu_icon');
224
  }
225
226
  if (!isset($options['attributes'])) {
227
    $options['attributes'] = array();
228
  }
229
  if (!isset($options['attributes']['class'])) {
230
    $options['attributes']['class'] = array();
231
  }
232
233
  $classes = array();
234
  $classes[] = "menu_icon";
235
  $classes[] = "menu-" . $form_state['values']['mlid'];
236
  if ($options['menu_icon']['enable'] && !empty($options['menu_icon']['path']) && file_exists($options['menu_icon']['path'])) {
237
    foreach ($classes as $class) {
238
      if (!in_array($class, $options['attributes']['class'])) {
239
        $options['attributes']['class'][] = $class;
240
      }
241
    }
242
  }
243
244
  if (empty($options['attributes']['class'])) {
245
    unset($options['attributes']['class']);
246
  }
247
248
  db_update('menu_links')
249
  ->fields(array(
250
    'options' => serialize($options),
251
  ))
252
  ->condition('mlid', $form_state['values']['mlid'])
253
  ->execute();
254
255
  // Regenerate the css file
256
  menu_icons_css_generate();
257
}
258
259
260
/**
261
 * Implements hook_node_insert().
262
 */
263
function menu_icons_node_insert($node) {
264
  menu_icons_node_save($node);
265
}
266
267
/**
268
 * Implements hook_node_update().
269
 */
270
function menu_icons_node_update($node) {
271
  menu_icons_node_save($node);
272
}
273
274
/**
275
 * Helper for hook_node_insert() and hook_node_update().
276
 */
277
function menu_icons_node_save($node) {
278
  if (isset($node->menu['icon']) && $node->menu['icon']['enable']) {
279
    // Check the destination folder, attempt to create it if it does't exist
280
    $directory_path = menu_icons_directory_path();
281
    file_prepare_directory($directory_path, FILE_CREATE_DIRECTORY);
282
283
    // Take the current icon path
284
    $path = $node->menu['icon']['path'];
285
    $file = FALSE;
286
    if (!empty($path)) {
287
      $file = image_load($path);
288
    }
289
    if ($file) {
290
      // Move temporary file to it's destination.
291
      $parts = pathinfo($file->source);
292
      $new_path = $directory_path . '/menu_icon_' . $node->menu['mlid'] . '.' . $parts['extension'];
293
      $node->menu['icon']['path'] = $new_path;
294
295
      if ($new_path != $path) {
296
        $new_file = file_unmanaged_copy($path, $new_path, FILE_EXISTS_REPLACE);
297
        // Delete temporary file.
298
        file_unmanaged_delete($path);
299
      }
300
301
      // Get link options from db.
302
      $options = unserialize(db_query('SELECT options FROM {menu_links} WHERE mlid = :mlid', array(':mlid' => $node->menu['mlid']))->fetchField());
303
304
      if (!isset($options['attributes'])) {
305
        $options['attributes'] = array();
306
      }
307
      if (!isset($options['attributes']['class'])) {
308
        $options['attributes']['class'] = array();
309
      }
310
      $classes = array();
311
      $classes[] = "menu_icon";
312
      $classes[] = "menu-" . $node->menu['mlid'];
313
314
      if (!empty($node->menu['icon']['path']) && file_exists($node->menu['icon']['path'])) {
315
        // Add our menu icon info to the options array
316
        $options['menu_icon'] = array(
317
          'enable' => $node->menu['icon']['enable'],
318
          'path' => $node->menu['icon']['path'],
319
          'image_style' => $node->menu['icon']['image_style'],
320
        );
321
        // Add new classes
322
        foreach ($classes as $class) {
323
          if (!in_array($class, $options['attributes']['class'])) {
324
            $options['attributes']['class'][] = $class;
325
          }
326
        }
327
328
        if (empty($options['attributes']['class'])) {
329
          unset($options['attributes']['class']);
330
        }
331
        // Update the link options
332
        db_update('menu_links')
333
        ->fields(array(
334
          'options' => serialize($options),
335
        ))
336
        ->condition('mlid', $node->menu['mlid'])
337
        ->execute();
338
339
        // Regenerate the css file
340
        menu_icons_css_generate();
341
342
        // @TODO The icon is not shown on first page load. We need to find a solution for this. Meanwhile:
343
        drupal_set_message(t('A new menu icon has been set for this node. Please refresh the page to view it.'));
344
      }
345
    }
346
  }
347
}
348
349
/**
350
 *
351
 */
352
function menu_icons_node_form_submit($form, &$form_state) {
353
  // Check the destination folder, attempt to create it if it does't exist
354
  $directory_path = menu_icons_directory_path();
355
  file_prepare_directory($directory_path, FILE_CREATE_DIRECTORY);
356
357
  // Store the current icon path
358
  $path = $form_state['values']['menu']['icon']['icon_path'];
359
360
  // Define the validation settings
361
  $validate = array(
362
    'file_validate_is_image' => array(),
363
  );
364
365
  // Check for a new uploaded icon, and use that instead.
366
  if ($file = file_save_upload('menu', $validate)) {
367
    $parts = pathinfo($file->filename);
368
    $filename = $directory_path . '/menu_icon_temp_' . time() . '.' . $parts['extension'];
369
    file_unmanaged_copy($file->uri, $filename, FILE_EXISTS_REPLACE);
370
    // Flush image style generated images
371
    image_path_flush($filename);
372
    $path = $filename;
373
  }
374
375
  $options = array();
376
  $options['menu_icon'] = array(
377
    'enable' => $form_state['values']['use_icon_logo'],
378
    'path' => $path,
379
    'image_style' => $form_state['values']['menu']['icon']['image_style'],
380
  );
381
  // Use default image style if not explicitly set.
382
  if (empty($options['menu_icon']['image_style'])) {
383
    $options['menu_icon']['image_style'] = variable_get('menu_icons_image_style_default', 'menu_icon');
384
  }
385
386
  $form_state['values']['menu']['icon'] = $options['menu_icon'];
387
}
388
389
390
/**
391
 * Implements hook_init().
392
 */
393
function menu_icons_init() {
394
  $cssfile = 'public://css/menu_icons.css';
395
  if (variable_get('menu_icons_use_css', TRUE) && file_exists($cssfile)){
396
    drupal_add_css($cssfile);
397
  }
398
}
399
400
/**
401
 * Build the menu_icon's settings form
402
 *
403
 * @return a form array
404
 */
405
function menu_icons_admin_settings($form, &$form_state) {
406
  $form['menu_icons_default_icon'] = array(
407
    '#type' => 'textfield',
408
    '#title' => t('Icon path'),
409
    '#default_value' => variable_get('menu_icons_default_icon', drupal_get_path('module', 'menu_icons') . '/images/default_icon.png'),
410
    '#description' => t('A Drupal path to the icon or image to use as a default.'),
411
    '#required' => FALSE,
412
  );
413
414
  $options = array();
415
  foreach (image_styles() as $pid => $preset) {
416
    $options[$preset['name']] = $preset['name'];
417
  }
418
419
  if (!empty($options)) {
420
    $form['menu_icons_image_style_default'] = array(
421
      '#type' => 'select',
422
      '#title' => t('Image default style'),
423
      '#default_value' => variable_get('menu_icons_image_style_default', 'menu_icon'),
424
      '#description' => t('Choose a default !link to be used for menu icons. This setting can be overwritten per menu item.', array('!link' => l(t('Image style'), 'admin/config/media/image-styles'))),
425
      '#required' => FALSE,
426
      '#options' => $options,
427
    );
428
  }
429
430
  $form['menu_icons_image_folder'] = array(
431
    '#type' => 'textfield',
432
    '#title' => t('Icon folder'),
433
    '#default_value' => variable_get('menu_icons_image_folder', 'menu_icons'),
434
    '#description' => t('The name of the files directory in which the new uploaded icons will be stored. This folder will be created in the files directory'),
435
    '#required' => FALSE,
436
  );
437
  $form['menu_icons_position'] = array(
438
    '#type' => 'select',
439
    '#title' => t('Position'),
440
    '#default_value' => variable_get('menu_icons_position', 'left'),
441
    '#options' => array(
442
      'top' => t('top'),
443
      'bottom' => t('bottom'),
444
      'right' => t('right'),
445
      'left' => t('left'),
446
    ),
447
    '#required' => FALSE,
448
  );
449
  $form['menu_icons_hide_titles'] = array(
450
    '#type' => 'checkbox',
451
    '#title' => t('Hide menu titles if icon is present'),
452
    '#default_value' => variable_get('menu_icons_hide_titles', FALSE),
453
    '#description' => t('Check this to hide menu titles and display only the icon, if an icon is configured. You will need to clear the theme registry cache after changing this option for it to take effect.'),
454
  );
455
  $form['menu_icons_use_css'] = array(
456
    '#type' => 'checkbox',
457
    '#title' => t('Provide default CSS for placing menu icons into the menu'),
458
    '#default_value' => variable_get('menu_icons_use_css', TRUE),
459
    '#description' => t("Advanced: uncheck this box if you do not want to enable the Menu Icon style sheet that's provided by default. If you uncheck this box, you must provide your own CSS for Menu Icons to appear!"),
460
  );
461
  return system_settings_form($form);
462
}
463
464
/**
465
 * Implements hook_image_default_styles().
466
 * Define the default menu_icons image style.
467
 */
468
function menu_icons_image_default_styles() {
469
  $styles = array();
470
471
  $styles['menu_icon'] = array(
472
    'effects' => array(
473
      array(
474
        'name' => 'image_scale',
475
        'data' => array('width' => 45, 'height' => 45, 'upscale' => 1),
476
        'weight' => 0,
477
      ),
478
    )
479
  );
480
481
  return $styles;
482
}
483
484
/**
485
 * Build CSS based on menu IDs
486
 *
487
 * @return A string with the CSS
488
 */
489
function menu_icons_css_generate() {
490
491
  $css = "";
492
  $result = db_query("SELECT mlid, options FROM {menu_links}");
493
  $pos = variable_get('menu_icons_position', 'left');
494
  $absolute = variable_get('menu_icons_absolute_links', FALSE);
495
496
  foreach ($result as $item) {
497
    $options = unserialize($item->options);
498
499
    if (isset($options['menu_icon']) && $options['menu_icon']['enable'] && !empty($options['menu_icon']['path']) && file_exists($options['menu_icon']['path'])) {
500
501
      $image_path = $options['menu_icon']['path'];
502
      $image_style = (isset($options['menu_icon']['image_style']) && !empty($options['menu_icon']['image_style'])) ? $options['menu_icon']['image_style'] : NULL;
503
504
      if ($image_style) {
505
        $source_uri = $image_path;
506
        $image_path = image_style_path($image_style, $source_uri);
507
508
        if (!file_exists($image_path)) {
509
          image_style_create_derivative(image_style_load($image_style), $source_uri, $image_path);
510
        }
511
      }
512
513
      // Retrieve the image dimensions
514
      $info = image_get_info($image_path);
515
516
      if ($absolute) {
517
        $image_url = file_create_url($image_path);
518
      }
519
      else {
520
        $wrapper = file_stream_wrapper_get_instance_by_scheme(file_uri_scheme($image_path));
521
        $image_url = '/' . $wrapper->getDirectoryPath() . '/' . file_uri_target($image_path);
522
      }
523
524
      $size = $pos == 'right' || $pos == 'left' ? $info['width'] : $info['height'];
525
      // Support private filesystem
526
      $css .= theme('menu_icons_css_item', array('mlid' => $item->mlid, 'path' => $image_url, 'size' => $size, 'height' => $info['height'], 'pos' => $pos, 'source' => $source_uri));
527
    }
528
  }
529
  $csspath = 'public://css';
530
  if (!empty($css)) {
531
    file_prepare_directory($csspath, FILE_CREATE_DIRECTORY);
532
    file_unmanaged_delete($csspath . '/menu_icons.css');
533
    file_unmanaged_save_data($css, $csspath . '/menu_icons.css', FILE_EXISTS_REPLACE);
534
  }
535
  else {
536
    file_unmanaged_delete($csspath . '/menu_icons.css');
537
  }
538
}
539
540
/**
541
 * Implements hook_theme().
542
 */
543
function menu_icons_theme() {
544
  return array(
545
    'menu_icons_css_item' => array(
546
      'variables' => array('mlid' => NULL, 'path' => NULL, 'size' => NULL, 'height' => NULL, 'pos' => NULL, 'source' => NULL),
547
      'template' => 'menu_icons_css_item',
548
    ),
549
  );
550
}
551
552
/**
553
 * Implements hook_menu_breadcrumb_alter()
554
 * Prevent menu icons from being displayed next to breadcrumbs.
555
 *
556
 * @param $active_trail
557
 * @param $item
558
 */
559
function menu_icons_menu_breadcrumb_alter(&$active_trail, $item) {
560
  foreach ($active_trail as &$crumb) {
561
    // Check if this is an item with a menu icon.
562
    if (array_key_exists('mlid', $crumb) && isset($crumb['localized_options']['attributes']['class'])) {
563
      $mlid = $crumb['mlid'];
564
      $count = count($crumb['localized_options']['attributes']['class']);
565
      for ($i = 0; $i < $count; $i++) {
566
        $class = $crumb['localized_options']['attributes']['class'][$i];
567
        // If this is a menu_icon class, remove it.
568
        switch ($class) {
569
          case 'menu_icon':
570
          case 'menu-' . $mlid:
571
            unset($crumb['localized_options']['attributes']['class'][$i]);
572
            break;
573
        }
574
      }
575
    }
576
  }
577
}
578
579
/**
580
 * Implements hook_flush_caches().
581
 */
582
function menu_icons_flush_caches() {
583
  menu_icons_css_generate();
584
}
585
586
/**
587
 * Returns the file directory path in which both the CSS file and the icons are stored.
588
 */
589
function menu_icons_directory_path($full = TRUE) {
590
  $path = variable_get('menu_icons_image_folder', 'menu_icons');
591
  $path_full = 'public://' . $path;
592
  return ($full ? $path_full : $path);
593
}
594
595
/**
596
 * Override theme_menu_link - hide link titles if enabled.
597
 *
598
 * @param $variables
599
 *
600
 * @return string
601
 */
602
function menu_icon_menu_link($variables) {
603
  $element = $variables['element'];
604
  $sub_menu = '';
605
606
  if ($element['#below']) {
607
    $sub_menu = drupal_render($element['#below']);
608
  }
609
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
610
  if (isset($element['#localized_options']['menu_icon'])) {
611
    if ($element['#localized_options']['menu_icon']['enable'] == 1) {
612
      $element['#attributes']['title'] = $element['#title'];
613
      $output = l('', $element['#href'], $element['#localized_options']);
614
    }
615
  }
616
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
617
}
618
619
/**
620
 * Override theme_link - hide link titles if enabled.
621
 *
622
 * @param $variables
623
 *
624
 * @return string
625
 */
626
function menu_icon_link($variables) {
627
  if (isset($variables['options']['menu_icon'])) {
628
    if ($variables['options']['menu_icon']['enable'] == 1) {
629
      $variables['options']['attributes']['title'] = $variables['text'];
630
      return '<a href="' . check_plain(url($variables['path'], $variables['options'])) . '"' . drupal_attributes($variables['options']['attributes']) . '></a>';
631
    }
632
  }
633
  return '<a href="' . check_plain(url($variables['path'], $variables['options'])) . '"' . drupal_attributes($variables['options']['attributes']) . '>' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '</a>';
634
}