~ubuntu-fr/ubuntu-fr-website/www.dev

« back to all changes in this revision

Viewing changes to sites/all/modules/pathauto/pathauto.inc

  • Committer: Vincent Liefooghe
  • Date: 2010-11-16 20:51:54 UTC
  • Revision ID: vl@ubuntovo-20101116205154-fuyfka524rm2zgni
Mise à jour des modules Backup & Migrate, Image API, Token et Pathauto

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
// $Id: pathauto.inc,v 1.45.2.27 2010/08/10 23:09:01 davereid Exp $
 
2
// $Id: pathauto.inc,v 1.45.2.29 2010/09/27 15:52:58 greggles Exp $
3
3
 
4
4
/**
5
5
 * @file
543
543
    watchdog('Pathauto', 'It appears that you have installed Pathauto, which depends on token, but token is either not installed or not installed properly.');
544
544
    return array('tokens' => array(), 'values' => array());
545
545
  }
546
 
  $full = token_get_values($type, $object, TRUE);
 
546
 
 
547
  $options = array('pathauto' => TRUE);
 
548
  $full = token_get_values($type, $object, TRUE, $options);
547
549
  $tokens = token_prepare_tokens($full->tokens);
548
 
  $values = pathauto_clean_token_values($full);
 
550
  $values = pathauto_clean_token_values($full, $options);
549
551
  return array('tokens' => $tokens, 'values' => $values);
550
552
}
551
553
 
559
561
 * @return
560
562
 *   An array of the cleaned tokens.
561
563
 */
562
 
function pathauto_clean_token_values($full) {
 
564
function pathauto_clean_token_values($full, $options = array()) {
563
565
  $replacements = array();
564
566
  foreach ($full->values as $key => $value) {
565
 
    // Only clean non-path tokens.
566
567
    $token = $full->tokens[$key];
567
 
    if (!preg_match('/(path|alias|url|url-brief)(-raw)?$/', $token)) {
 
568
    if (strpos($token, 'path') !== FALSE && is_array($value) && !empty($options['pathauto'])) {
 
569
      // If the token name contains 'path', the token value is an array, and
 
570
      // the 'pathauto' option was passed to token_get_values(), then the token
 
571
      // should have each segment cleaned, and then glued back together to
 
572
      // construct a value resembling an URL.
 
573
      $segments = array_map('pathauto_cleanstring', $value);
 
574
      $replacements[$token] = implode('/', $segments);
 
575
    }
 
576
    elseif (preg_match('/(path|alias|url|url-brief)(-raw)?$/', $token)) {
 
577
      // Token name matches an URL-type name and should be left raw.
 
578
      $replacements[$token] = $value;
 
579
    }
 
580
    else {
 
581
      // Token is not an URL, so it should have its value cleaned.
568
582
      $replacements[$token] = pathauto_cleanstring($value);
569
583
    }
570
 
    else {
571
 
      $replacements[$token] = $value;
572
 
    }
573
584
  }
574
585
  return $replacements;
575
586
}