PluginProbe ʕ •ᴥ•ʔ
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets / 3.0
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets v3.0
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 / libraries / XmlImportTemplate.php
wp-all-import / libraries Last commit date
ast 13 years ago cache 13 years ago XmlImportConfig.php 13 years ago XmlImportCsvParse.php 13 years ago XmlImportException.php 13 years ago XmlImportParser.php 13 years ago XmlImportReaderInterface.php 13 years ago XmlImportStringReader.php 13 years ago XmlImportTemplate.php 13 years ago XmlImportTemplateCodeGenerator.php 13 years ago XmlImportTemplateParser.php 13 years ago XmlImportTemplateScanner.php 13 years ago XmlImportToken.php 13 years ago pclzip.lib.php 13 years ago
XmlImportTemplate.php
78 lines
1 <?php
2 /**
3 * @author Olexandr Zanichkovsky <olexandr.zanichkovsky@zophiatech.com>
4 * @author Pavel Kulbakin <p.kulbakin@gmail.com>
5 * @package General
6 */
7
8 require_once dirname(__FILE__) . '/XmlImportConfig.php';
9
10 /**
11 * Represents a template
12 */
13 class XmlImportTemplate {
14 /**
15 * Root element of the record that is being parsed
16 *
17 * @var SimpleXMLElement
18 */
19 protected $xml;
20
21 /**
22 * file name of the cached template
23 *
24 * @var string
25 */
26 protected $cachedTemplate;
27
28 /**
29 * Creates new instance
30 *
31 * @param SimpleXmlElement $xml
32 * @param string $cachedTemplate
33 */
34 public function __construct($xml, $cachedTemplate)
35 {
36 $this->xml = $xml;
37 $this->cachedTemplate = $cachedTemplate;
38 }
39
40 /**
41 * Parses a template using {@see $this->xml}
42 *
43 * @return string
44 */
45 public function parse()
46 {
47
48 ob_start();
49 $err_lvl = error_reporting(E_ALL);
50 include $this->cachedTemplate;
51 error_reporting($err_lvl);
52
53 return ob_get_clean();
54 }
55
56 /**
57 * Get the value by XPath expression
58 *
59 * @param SimpleXmlElement $xpath XPath result
60 * @return mixed
61 */
62 protected function getValue($xpath)
63 {
64
65 if (is_array($xpath) && count($xpath) > 0) {
66 $result = array();
67 foreach ($xpath as $xp) { // cancatenate multiple elements into 1 string
68 ob_start();
69 echo $xp;
70 $result[] = trim(ob_get_clean());
71 }
72 return implode(XmlImportConfig::getInstance()->getMultiGlue(), $result);
73 } else {
74 // return null if nothing found
75 return null;
76 }
77 }
78 }