Projet

Général

Profil

Révision ed9a13f1

Ajouté par Assos Assos il y a presque 4 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/feeds/libraries/ParserCSV.inc
17 17
  private $currentLine;
18 18
  private $currentPos;
19 19

  
20
  /**
21
   * {@inheritdoc}
22
   */
20 23
  public function __construct($filepath) {
21 24
    $this->handle = fopen($filepath, 'r');
22 25
    $this->currentLine = NULL;
23 26
    $this->currentPos = NULL;
24 27
  }
25 28

  
26
  function __destruct() {
29
  /**
30
   * {@inheritdoc}
31
   */
32
  public function __destruct() {
27 33
    if ($this->handle) {
28 34
      fclose($this->handle);
29 35
    }
......
39 45
    }
40 46
  }
41 47

  
48
  /**
49
   * {@inheritdoc}
50
   */
42 51
  public function rewind($pos = 0) {
43 52
    if ($this->handle) {
44 53
      fseek($this->handle, $pos);
......
46 55
    }
47 56
  }
48 57

  
58
  /**
59
   * {@inheritdoc}
60
   */
49 61
  public function next() {
50 62
    if ($this->handle) {
51 63
      $this->currentLine = feof($this->handle) ? NULL : fgets($this->handle);
......
54 66
    }
55 67
  }
56 68

  
69
  /**
70
   * {@inheritdoc}
71
   */
57 72
  public function valid() {
58 73
    return isset($this->currentLine);
59 74
  }
60 75

  
76
  /**
77
   * {@inheritdoc}
78
   */
61 79
  public function current() {
62 80
    return $this->currentLine;
63 81
  }
64 82

  
83
  /**
84
   * {@inheritdoc}
85
   */
65 86
  public function currentPos() {
66 87
    return $this->currentPos;
67 88
  }
68 89

  
90
  /**
91
   * {@inheritdoc}
92
   */
69 93
  public function key() {
70 94
    return 'line';
71 95
  }
96

  
72 97
}
73 98

  
74 99
/**
......
87 112
  private $lastLinePos;
88 113
  private $useMbString;
89 114

  
115
  /**
116
   * {@inheritdoc}
117
   */
90 118
  public function __construct() {
91 119
    $this->delimiter = ',';
92 120
    $this->fromEncoding = 'UTF-8';
......
182 210
   * Get the byte number where the parser left off after last parse() call.
183 211
   *
184 212
   * @return int
185
   *  0 if all lines or no line has been parsed, the byte position of where a
186
   *  timeout or the line limit has been reached otherwise. This position can be
187
   *  used to set the start byte for the next iteration after parse() has
188
   *  reached the timeout set with setTimeout() or the line limit set with
189
   *  setLineLimit().
213
   *   0 if all lines or no line has been parsed, the byte position of where a
214
   *   timeout or the line limit has been reached otherwise. This position can be
215
   *   used to set the start byte for the next iteration after parse() has
216
   *   reached the timeout set with setTimeout() or the line limit set with
217
   *   setLineLimit().
190 218
   *
191 219
   * @see ParserCSV::setStartByte()
192 220
   */
......
285 313
            $currentIndex = $nextQuoteIndex + 1;
286 314
          }
287 315
        }
288
        else { // $quoted == FALSE
316
        // $quoted == FALSE.
317
        else {
289 318
          // First, let's find out where the next character of interest is.
290 319
          $nextQuoteIndex = strpos($line, '"', $currentIndex);
291 320
          $nextDelimiterIndex = strpos($line, $this->delimiter, $currentIndex);
......
314 343
            $currentIndex += $length + 1;
315 344
            // Continue with the next field.
316 345
          }
317
          else { // $line[$nextIndex] == '"'
346
          // $line[$nextIndex] == '"'.
347
          else {
318 348
            $quoted = TRUE;
319 349
            $currentField .= substr($line, $currentIndex, $nextIndex - $currentIndex);
320 350
            $currentIndex = $nextIndex + 1;
......
324 354
      }
325 355
      // End of CSV parser. We've now got all the fields of the line as strings
326 356
      // in the $fields array.
327

  
328 357
      if (empty($this->columnNames)) {
329 358
        $row = $fields;
330 359
      }
......
381 410

  
382 411
    return $data;
383 412
  }
413

  
384 414
}
385 415

  
386 416
/**

Formats disponibles : Unified diff