PluginProbe ʕ •ᴥ•ʔ
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets / trunk
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets vtrunk
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
XmlStreamReader 3 weeks ago partner-discount-sdk 3 weeks ago api.php 3 weeks ago arraytoxml.php 3 weeks ago chunk.php 3 weeks ago config.php 2 years ago download.php 3 weeks ago error.php 3 weeks ago handler.php 3 weeks ago helper.php 3 weeks ago input.php 3 weeks ago nested.php 3 weeks ago rapidaddon.php 3 weeks ago render.php 3 weeks ago session.php 9 months ago upload.php 3 weeks ago zip.php 10 years ago
nested.php
89 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 $factory = XmlImportParser::factory($this->xml, $this->xpath, $nfile, $tmp_file)->parse();
27 $nested_fileURL = array_shift($factory); $tmp_files[] = $tmp_file;
28 if ( ! empty($nested_fileURL) ){
29 $errors = new WP_Error();
30
31 $uploader = new PMXI_Upload($nested_fileURL, $errors);
32 $upload_result = $uploader->url();
33
34 if ($upload_result instanceof WP_Error){
35 $errors = $upload_result;
36 }
37 else{
38 $source = $upload_result['source'];
39 $filePath = $upload_result['filePath'];
40 if ( ! empty($upload_result['root_element']))
41 $root_element = $upload_result['root_element'];
42 else
43 $root_element = '';
44 $feed_type = $upload_result['feed_type'];
45 }
46
47 unset($uploader);
48
49 $nested_xml = file_get_contents($filePath);
50
51 if ( ! empty($nested_xml) )
52 {
53 PMXI_Import_Record::preprocessXml($nested_xml);
54
55 if ( PMXI_Import_Record::validateXml($nested_xml) === true ){
56
57 $nestedDom = new DOMDocument('1.0', 'UTF-8');
58 $nestedold = libxml_use_internal_errors(true);
59 $nestedDom->loadXML($nested_xml);
60 libxml_use_internal_errors($nestedold);
61 $second = $nestedDom->documentElement;
62
63 if ($second->hasChildNodes()) {
64
65 foreach($second->childNodes as $node)
66 {
67 $importNode = $this->dom->importNode($node, true);
68 $this->dom->documentElement->appendChild($importNode);
69 }
70
71 $this->xml = ($this->elements) ? $this->dom->saveXML($this->elements->item(0)) : $this->dom->saveXML();
72 }
73 unset($nestedDom);
74 }
75 }
76 }
77 }
78 foreach ($tmp_files as $tmp_file) { // remove all temporary files created
79 wp_delete_file($tmp_file);
80 }
81 }
82 }
83
84 public function get_xml(){
85 return $this->xml;
86 }
87
88 }
89 }