PluginProbe ʕ •ᴥ•ʔ
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets / 3.2.2
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets v3.2.2
4.1.1 3.9.5 3.9.6 4.0.0 4.0.1 4.1.0 trunk 2.12 2.13 2.14 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9 3.7.0 3.7.1 3.7.2 3.7.3 3.7.3-beta-1.0 3.7.4 3.7.4-beta-1.0 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4
wp-all-import / classes / nested.php
wp-all-import / classes Last commit date
chunk.php 11 years ago config.php 11 years ago download.php 11 years ago handler.php 11 years ago helper.php 11 years ago input.php 11 years ago nested.php 11 years ago render.php 11 years ago session.php 11 years ago upload.php 11 years ago
nested.php
88 lines
1 <?php
2
3 if ( ! class_exists('PMXI_Nested')){
4
5 class PMXI_Nested{
6 protected $nested_files;
7 protected $xpath;
8 protected $dom;
9 protected $elements;
10 public $xml;
11
12 public function __construct( $dom, $nested_files, $xml, $xpath, $elements = false){
13 $this->dom = $dom;
14 $this->nested_files = $nested_files;
15 $this->xpath = $xpath;
16 $this->xml = $xml;
17 $this->elements = $elements;
18 }
19
20 public function merge(){
21
22 /* Merge nested XML/CSV files */
23 if ( ! empty($this->nested_files) ){
24 $tmp_files = array();
25 foreach ($this->nested_files as $key => $nfile) {
26 $nested_fileURL = array_shift(XmlImportParser::factory($this->xml, $this->xpath, $nfile, $tmp_file)->parse()); $tmp_files[] = $tmp_file;
27 if ( ! empty($nested_fileURL) ){
28 $errors = new WP_Error();
29
30 $uploader = new PMXI_Upload($nested_fileURL, $errors);
31 $upload_result = $uploader->url();
32
33 if ($upload_result instanceof WP_Error){
34 $errors = $upload_result;
35 }
36 else{
37 $source = $upload_result['source'];
38 $filePath = $upload_result['filePath'];
39 if ( ! empty($upload_result['root_element']))
40 $root_element = $upload_result['root_element'];
41 else
42 $root_element = '';
43 $feed_type = $upload_result['feed_type'];
44 }
45
46 unset($uploader);
47
48 $nested_xml = file_get_contents($filePath);
49
50 if ( ! empty($nested_xml) )
51 {
52 PMXI_Import_Record::preprocessXml($nested_xml);
53
54 if ( PMXI_Import_Record::validateXml($nested_xml) === true ){
55
56 $nestedDom = new DOMDocument('1.0', 'UTF-8');
57 $nestedold = libxml_use_internal_errors(true);
58 $nestedDom->loadXML($nested_xml);
59 libxml_use_internal_errors($nestedold);
60 $second = $nestedDom->documentElement;
61
62 if ($second->hasChildNodes()) {
63
64 foreach($second->childNodes as $node)
65 {
66 $importNode = $this->dom->importNode($node, true);
67 $this->dom->documentElement->appendChild($importNode);
68 }
69
70 $this->xml = ($this->elements) ? $this->dom->saveXML($this->elements->item(0)) : $this->dom->saveXML();
71 }
72 unset($nestedDom);
73 }
74 }
75 }
76 }
77 foreach ($tmp_files as $tmp_file) { // remove all temporary files created
78 @unlink($tmp_file);
79 }
80 }
81 }
82
83 public function get_xml(){
84 return $this->xml;
85 }
86
87 }
88 }