PluginProbe ʕ •ᴥ•ʔ
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets / 2.13
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets v2.13
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 / ast / XmlImportAstSequence.php
wp-all-import / libraries / ast Last commit date
XmlImportAstElseif.php 14 years ago XmlImportAstExpression.php 14 years ago XmlImportAstFloat.php 14 years ago XmlImportAstForeach.php 14 years ago XmlImportAstFunction.php 14 years ago XmlImportAstIf.php 14 years ago XmlImportAstInteger.php 14 years ago XmlImportAstLiteral.php 14 years ago XmlImportAstMath.php 14 years ago XmlImportAstPrint.php 14 years ago XmlImportAstSequence.php 14 years ago XmlImportAstStatement.php 14 years ago XmlImportAstString.php 14 years ago XmlImportAstText.php 14 years ago XmlImportAstWith.php 14 years ago XmlImportAstXPath.php 14 years ago XmlImportAstXpathClause.php 14 years ago
XmlImportAstSequence.php
161 lines
1 <?php
2 /**
3 * @author Olexandr Zanichkovsky <olexandr.zanichkovsky@zophiatech.com>
4 * @package AST
5 */
6
7 require_once dirname(__FILE__) . '/XmlImportAstStatement.php';
8
9 /**
10 * Represents statement sequence
11 */
12 class XmlImportAstSequence extends XmlImportAstStatement
13 {
14
15 /**
16 * Sequence instance number
17 *
18 * @var int
19 */
20 private static $sequenceInstanceNumber = 0;
21
22 /**
23 * Current sequence number
24 *
25 * @var int
26 */
27 private $sequenceNumber;
28
29 /**
30 * Current variable number
31 *
32 * @var int
33 */
34 private $varNumber = 0;
35
36 /**
37 * List of statements
38 *
39 * @var array
40 */
41 private $statements = array();
42
43 /**
44 * Variable definitions
45 *
46 * @var array
47 */
48 private $variableDefinitions = array();
49
50 /**
51 * Variables
52 *
53 * @var array
54 */
55 private $variables = array();
56
57 /**
58 * Creates new instance
59 */
60 public function __construct()
61 {
62 $this->sequenceNumber = self::$sequenceInstanceNumber++;
63 }
64
65 /**
66 * Adds statement to a sequence
67 *
68 * @param XmlImportAstStatement $statement
69 */
70 public function addStatement(XmlImportAstStatement $statement)
71 {
72 $this->statements[] = $statement;
73 }
74
75 /**
76 * Gets the list of statements
77 *
78 * @return array
79 */
80 public function getStatements()
81 {
82 return $this->statements;
83 }
84
85 /**
86 * Adds variable to a sequence
87 *
88 * @param XmlImportAstXPath $xpath
89 */
90 public function addVariable(XmlImportAstXPath $xpath)
91 {
92 if (!array_key_exists($xpath->getValue(), $this->variables))
93 {
94 $var = '$v' . $this->sequenceNumber . '_' . $this->varNumber++;
95 $value = $escapedValue = strtr($xpath->getValue(), array(
96 "\n" => "\\n",
97 "\t" => "\\t",
98 "\r" => "\\r",
99 "$" => "\\$",
100 "\"" => "\\\"",
101 "\\" => "\\\\",
102 ));
103 $result = $var . ' = {{XML}}->xpath("' . $value . '");';
104 $this->variables[$xpath->getValue()] = $var;
105 $this->variableDefinitions[] = $result;
106 }
107 }
108
109 /**
110 * Gets variable definitions
111 *
112 * @return array
113 */
114 public function getVariableDefinitions()
115 {
116 return $this->variableDefinitions;
117 }
118
119 /**
120 * Gets variables
121 *
122 * @return array
123 */
124 public function getVariables()
125 {
126 return $this->variables;
127 }
128
129 /**
130 * Returns the number of current instance
131 *
132 * @return int
133 */
134 public function getSequenceNumber()
135 {
136 return $this->sequenceNumber;
137 }
138
139 /**
140 * String representation of a sequence node
141 *
142 * @return string
143 */
144 public function __toString()
145 {
146 $result = "--> begin " . get_class($this) . "\n";
147 foreach ($this->getStatements() as $statement)
148 {
149 $array = explode("\n", $statement);
150 for ($i = 0; $i < count($array); $i++)
151 {
152 $array[$i] = ' ' . $array[$i];
153 }
154 $result .= implode("\n", $array) . "\n";
155 }
156
157 $result .= "--> end " . get_class($this);
158
159 return $result;
160 }
161 }