Projet

Général

Profil

Révision 41cc1b08

Ajouté par Assos Assos il y a presque 9 ans

Update feeds 7.x-2.0-alpha9 -> 7.x-2.0-beta1

Install lib simplepie 1.3.1

Voir les différences:

drupal7/sites/all/modules/feeds/plugins/FeedsParser.inc
315 315
   */
316 316
  public function setAllowedExtensions($extensions) {
317 317
    // Normalize whitespace so that empty extensions are not allowed.
318
    $this->allowedExtensions = trim(preg_replace('/\s/', ' ', $extensions));
318
    $this->allowedExtensions = drupal_strtolower(trim(preg_replace('/\s+/', ' ', $extensions)));
319 319
  }
320 320

  
321 321
  /**
......
332 332
  }
333 333

  
334 334
  /**
335
   * Returns the full path to the file URI with a safe filen ame.
335
   * Returns the full path to the file URI with a safe file name.
336 336
   *
337 337
   * @return string
338 338
   *   The safe file URI.
......
352 352
   *
353 353
   * @throws RuntimeException
354 354
   *   Thrown if the file extension is invalid.
355
   *
356
   * @see FeedsElement::getValue()
357 355
   */
358 356
  public function getLocalValue() {
359 357
    return str_replace(' ', '_', $this->getSafeFilename());
......
367 365
   *
368 366
   * @throws RuntimeException
369 367
   *   Thrown if the file extension is invalid.
370
   *
371
   * @see FeedsElement::getValue()
372 368
   */
373 369
  protected function getSafeFilename() {
374 370
    if (isset($this->safeFilename)) {
375 371
      return $this->safeFilename;
376 372
    }
377 373

  
378
    $filename = rawurldecode(drupal_basename($this->getValue()));
374
    // Strip any query string or fragment from file name.
375
    list($filename) = explode('?', $this->getValue());
376
    list($filename) = explode('#', $filename);
379 377

  
380
    if (module_exists('transliteration')) {
381
      require_once drupal_get_path('module', 'transliteration') . '/transliteration.inc';
382
      $filename = transliteration_clean_filename($filename);
383
    }
378
    $filename = rawurldecode(drupal_basename($filename));
384 379

  
385 380
    // Remove leading and trailing whitespace and periods.
386 381
    $filename = trim($filename, " \t\n\r\0\x0B.");
......
389 384
      $extension = FALSE;
390 385
    }
391 386
    else {
392
      $extension = substr($filename, strrpos($filename, '.') + 1);
387
      $extension = drupal_strtolower(substr($filename, strrpos($filename, '.') + 1));
393 388
    }
394 389

  
395 390
    if (!$extension || !in_array($extension, explode(' ', $this->allowedExtensions), TRUE)) {
......
430 425
   *   If file object could not be created.
431 426
   */
432 427
  public function getFile($destination) {
433

  
428
    $file = NULL;
434 429
    if ($this->getValue()) {
435 430
      // Prepare destination directory.
436 431
      file_prepare_directory($destination, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY);
......
439 434
        $file           = new stdClass();
440 435
        $file->uid      = 0;
441 436
        $file->uri      = $this->getSanitizedUri();
442
        $file->filemime = $this->mime_type;
437
        $file->filemime = $this->getMIMEType();
443 438
        $file->filename = $this->getSafeFilename();
444 439

  
445 440
        if (drupal_dirname($file->uri) !== $destination) {
......
463 458
          $destination = trim($destination, '/') . '/';
464 459
        }
465 460
        try {
466
          $file = file_save_data($this->getContent(), $destination . $this->getLocalValue());
461
          $filename = $this->getLocalValue();
462

  
463
          if (module_exists('transliteration')) {
464
            require_once drupal_get_path('module', 'transliteration') . '/transliteration.inc';
465
            $filename = transliteration_clean_filename($filename);
466
          }
467

  
468
          $file = file_save_data($this->getContent(), $destination . $filename);
467 469
        }
468 470
        catch (Exception $e) {
469 471
          watchdog_exception('Feeds', $e, nl2br(check_plain($e)));
......
478 480
      return $file;
479 481
    }
480 482
  }
481

  
482 483
}
483 484

  
484 485
/**
......
680 681
   *   PHP DateTimeZone object, NULL allowed
681 682
   */
682 683
  public function __construct($time = '', $tz = NULL) {
683
    // Assume UNIX timestamp if numeric.
684 684
    if (is_numeric($time)) {
685
      // Make sure it's not a simple year
686
      if ((is_string($time) && strlen($time) > 4) || is_int($time)) {
685
      // Assume UNIX timestamp if it doesn't look like a simple year.
686
      if (strlen($time) > 4) {
687 687
        $time = "@" . $time;
688 688
      }
689
      // If it's a year, add a default month too, because PHP's date functions
690
      // won't parse standalone years after 2000 correctly (see explanation at
691
      // http://aaronsaray.com/blog/2007/07/11/helpful-strtotime-reminders/#comment-47).
692
      else {
693
        $time = 'January ' . $time;
694
      }
689 695
    }
690 696

  
691 697
    // PHP < 5.3 doesn't like the GMT- notation for parsing timezones.
......
693 699
    $time = str_replace("GMT+", "+", $time);
694 700

  
695 701
    // Some PHP 5.2 version's DateTime class chokes on invalid dates.
696
    if (!strtotime($time)) {
702
    if (!date_create($time)) {
697 703
      $time = 'now';
698 704
    }
699 705

  

Formats disponibles : Unified diff