PluginProbe
Import WP – CSV & XML Import Export for WordPress / 2.15.0
Import WP – CSV & XML Import Export for WordPress v2.15.0
2.15.1 2.15.0 2.14.24 2.14.23 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 2.9.1 All 144 releases
jc-importer / class / Common / Importer / Parser / CSVParser.php

CSVParser.php in Import WP – CSV & XML Import Export for WordPress 2.15.0, at class/Common/Importer/Parser/CSVParser.php

45 lines 976 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ImportWP\Common\Importer\Parser;
4
5 use ImportWP\Common\Importer\File\CSVFile;
6 use ImportWP\Common\Importer\ParserInterface;
7
8 /**
9 * @property CSVFile $file
10 */
11 class CSVParser extends AbstractParser implements ParserInterface
12 {
13 /**
14 * CSV Record
15 *
16 * @var array
17 */
18 private $csv_record;
19
20 public function query($query)
21 {
22 return isset($this->csv_record[$query]) ? $this->csv_record[$query] : '';
23 }
24
25 protected function onRecordLoaded()
26 {
27 $this->csv_record = str_getcsv($this->record, $this->file->getDelimiter(), $this->file->getEnclosure());
28 }
29
30 public function record()
31 {
32 return $this->csv_record;
33 }
34
35 public function query_matches($matches)
36 {
37 // make sure the selector is numeric {0}
38 if (isset($matches[0]) && preg_match('/^\d+$/', $matches[1]) === 1) {
39 return parent::query_matches($matches);
40 }
41
42 return $matches[0];
43 }
44 }
45