Import any XML or CSV File to WordPress - Version 3.3.9

Version Description

  • improvement: new re-import option 'is update post type'
  • bug fix: hierarchy taxonomies preview
  • bug fix: empty logs folder generation
  • bug fix: 'Keep images currently in Media Library' option for add-ons
  • bug fix: import bundles with gz files
  • bug fix: custom functions for attachments
Download this release

Release Info

Developer soflyy
Plugin Icon 128x128 Import any XML or CSV File to WordPress
Version 3.3.9
Comparing to
See all releases

Code changes from version 3.3.8 to 3.3.9

classes/PHPExcel/CachedObjectStorage/MemoryGZip.php CHANGED
@@ -1,137 +1,137 @@
1
- <?php
2
- /**
3
- * PHPExcel
4
- *
5
- * Copyright (c) 2006 - 2014 PHPExcel
6
- *
7
- * This library is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU Lesser General Public
9
- * License as published by the Free Software Foundation; either
10
- * version 2.1 of the License, or (at your option) any later version.
11
- *
12
- * This library is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- * Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public
18
- * License along with this library; if not, write to the Free Software
19
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
- *
21
- * @category PHPExcel
22
- * @package PHPExcel_CachedObjectStorage
23
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25
- * @version ##VERSION##, ##DATE##
26
- */
27
-
28
-
29
- /**
30
- * PHPExcel_CachedObjectStorage_MemoryGZip
31
- *
32
- * @category PHPExcel
33
- * @package PHPExcel_CachedObjectStorage
34
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
35
- */
36
- class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
37
-
38
- /**
39
- * Store cell data in cache for the current cell object if it's "dirty",
40
- * and the 'nullify' the current cell object
41
- *
42
- * @return void
43
- * @throws PHPExcel_Exception
44
- */
45
- protected function _storeData() {
46
- if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
47
- $this->_currentObject->detach();
48
-
49
- $this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
50
- $this->_currentCellIsDirty = false;
51
- }
52
- $this->_currentObjectID = $this->_currentObject = null;
53
- } // function _storeData()
54
-
55
-
56
- /**
57
- * Add or Update a cell in cache identified by coordinate address
58
- *
59
- * @param string $pCoord Coordinate address of the cell to update
60
- * @param PHPExcel_Cell $cell Cell to update
61
- * @return PHPExcel_Cell
62
- * @throws PHPExcel_Exception
63
- */
64
- public function addCacheData($pCoord, PHPExcel_Cell $cell) {
65
- if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
66
- $this->_storeData();
67
- }
68
-
69
- $this->_currentObjectID = $pCoord;
70
- $this->_currentObject = $cell;
71
- $this->_currentCellIsDirty = true;
72
-
73
- return $cell;
74
- } // function addCacheData()
75
-
76
-
77
- /**
78
- * Get cell at a specific coordinate
79
- *
80
- * @param string $pCoord Coordinate of the cell
81
- * @throws PHPExcel_Exception
82
- * @return PHPExcel_Cell Cell that was found, or null if not found
83
- */
84
- public function getCacheData($pCoord) {
85
- if ($pCoord === $this->_currentObjectID) {
86
- return $this->_currentObject;
87
- }
88
- $this->_storeData();
89
-
90
- // Check if the entry that has been requested actually exists
91
- if (!isset($this->_cellCache[$pCoord])) {
92
- // Return null if requested entry doesn't exist in cache
93
- return null;
94
- }
95
-
96
- // Set current entry to the requested entry
97
- $this->_currentObjectID = $pCoord;
98
- $this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord]));
99
- // Re-attach this as the cell's parent
100
- $this->_currentObject->attach($this);
101
-
102
- // Return requested entry
103
- return $this->_currentObject;
104
- } // function getCacheData()
105
-
106
-
107
- /**
108
- * Get a list of all cell addresses currently held in cache
109
- *
110
- * @return string[]
111
- */
112
- public function getCellList() {
113
- if ($this->_currentObjectID !== null) {
114
- $this->_storeData();
115
- }
116
-
117
- return parent::getCellList();
118
- }
119
-
120
-
121
- /**
122
- * Clear the cell collection and disconnect from our parent
123
- *
124
- * @return void
125
- */
126
- public function unsetWorksheetCells() {
127
- if(!is_null($this->_currentObject)) {
128
- $this->_currentObject->detach();
129
- $this->_currentObject = $this->_currentObjectID = null;
130
- }
131
- $this->_cellCache = array();
132
-
133
- // detach ourself from the worksheet, so that it can then delete this object successfully
134
- $this->_parent = null;
135
- } // function unsetWorksheetCells()
136
-
137
- }
1
+ <?php
2
+ /**
3
+ * PHPExcel
4
+ *
5
+ * Copyright (c) 2006 - 2014 PHPExcel
6
+ *
7
+ * This library is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * This library is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with this library; if not, write to the Free Software
19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
+ *
21
+ * @category PHPExcel
22
+ * @package PHPExcel_CachedObjectStorage
23
+ * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25
+ * @version ##VERSION##, ##DATE##
26
+ */
27
+
28
+
29
+ /**
30
+ * PHPExcel_CachedObjectStorage_MemoryGZip
31
+ *
32
+ * @category PHPExcel
33
+ * @package PHPExcel_CachedObjectStorage
34
+ * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
35
+ */
36
+ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
37
+
38
+ /**
39
+ * Store cell data in cache for the current cell object if it's "dirty",
40
+ * and the 'nullify' the current cell object
41
+ *
42
+ * @return void
43
+ * @throws PHPExcel_Exception
44
+ */
45
+ protected function _storeData() {
46
+ if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
47
+ $this->_currentObject->detach();
48
+
49
+ $this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
50
+ $this->_currentCellIsDirty = false;
51
+ }
52
+ $this->_currentObjectID = $this->_currentObject = null;
53
+ } // function _storeData()
54
+
55
+
56
+ /**
57
+ * Add or Update a cell in cache identified by coordinate address
58
+ *
59
+ * @param string $pCoord Coordinate address of the cell to update
60
+ * @param PHPExcel_Cell $cell Cell to update
61
+ * @return PHPExcel_Cell
62
+ * @throws PHPExcel_Exception
63
+ */
64
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
65
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
66
+ $this->_storeData();
67
+ }
68
+
69
+ $this->_currentObjectID = $pCoord;
70
+ $this->_currentObject = $cell;
71
+ $this->_currentCellIsDirty = true;
72
+
73
+ return $cell;
74
+ } // function addCacheData()
75
+
76
+
77
+ /**
78
+ * Get cell at a specific coordinate
79
+ *
80
+ * @param string $pCoord Coordinate of the cell
81
+ * @throws PHPExcel_Exception
82
+ * @return PHPExcel_Cell Cell that was found, or null if not found
83
+ */
84
+ public function getCacheData($pCoord) {
85
+ if ($pCoord === $this->_currentObjectID) {
86
+ return $this->_currentObject;
87
+ }
88
+ $this->_storeData();
89
+
90
+ // Check if the entry that has been requested actually exists
91
+ if (!isset($this->_cellCache[$pCoord])) {
92
+ // Return null if requested entry doesn't exist in cache
93
+ return null;
94
+ }
95
+
96
+ // Set current entry to the requested entry
97
+ $this->_currentObjectID = $pCoord;
98
+ $this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord]));
99
+ // Re-attach this as the cell's parent
100
+ $this->_currentObject->attach($this);
101
+
102
+ // Return requested entry
103
+ return $this->_currentObject;
104
+ } // function getCacheData()
105
+
106
+
107
+ /**
108
+ * Get a list of all cell addresses currently held in cache
109
+ *
110
+ * @return string[]
111
+ */
112
+ public function getCellList() {
113
+ if ($this->_currentObjectID !== null) {
114
+ $this->_storeData();
115
+ }
116
+
117
+ return parent::getCellList();
118
+ }
119
+
120
+
121
+ /**
122
+ * Clear the cell collection and disconnect from our parent
123
+ *
124
+ * @return void
125
+ */
126
+ public function unsetWorksheetCells() {
127
+ if(!is_null($this->_currentObject)) {
128
+ $this->_currentObject->detach();
129
+ $this->_currentObject = $this->_currentObjectID = null;
130
+ }
131
+ $this->_cellCache = array();
132
+
133
+ // detach ourself from the worksheet, so that it can then delete this object successfully
134
+ $this->_parent = null;
135
+ } // function unsetWorksheetCells()
136
+
137
+ }
classes/PHPExcel/CachedObjectStorage/SQLite.php CHANGED
@@ -1,306 +1,306 @@
1
- <?php
2
- /**
3
- * PHPExcel
4
- *
5
- * Copyright (c) 2006 - 2014 PHPExcel
6
- *
7
- * This library is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU Lesser General Public
9
- * License as published by the Free Software Foundation; either
10
- * version 2.1 of the License, or (at your option) any later version.
11
- *
12
- * This library is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- * Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public
18
- * License along with this library; if not, write to the Free Software
19
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
- *
21
- * @category PHPExcel
22
- * @package PHPExcel_CachedObjectStorage
23
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25
- * @version ##VERSION##, ##DATE##
26
- */
27
-
28
-
29
- /**
30
- * PHPExcel_CachedObjectStorage_SQLite
31
- *
32
- * @category PHPExcel
33
- * @package PHPExcel_CachedObjectStorage
34
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
35
- */
36
- class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
37
-
38
- /**
39
- * Database table name
40
- *
41
- * @var string
42
- */
43
- private $_TableName = null;
44
-
45
- /**
46
- * Database handle
47
- *
48
- * @var resource
49
- */
50
- private $_DBHandle = null;
51
-
52
- /**
53
- * Store cell data in cache for the current cell object if it's "dirty",
54
- * and the 'nullify' the current cell object
55
- *
56
- * @return void
57
- * @throws PHPExcel_Exception
58
- */
59
- protected function _storeData() {
60
- if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
61
- $this->_currentObject->detach();
62
-
63
- if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')"))
64
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
65
- $this->_currentCellIsDirty = false;
66
- }
67
- $this->_currentObjectID = $this->_currentObject = null;
68
- } // function _storeData()
69
-
70
-
71
- /**
72
- * Add or Update a cell in cache identified by coordinate address
73
- *
74
- * @param string $pCoord Coordinate address of the cell to update
75
- * @param PHPExcel_Cell $cell Cell to update
76
- * @return PHPExcel_Cell
77
- * @throws PHPExcel_Exception
78
- */
79
- public function addCacheData($pCoord, PHPExcel_Cell $cell) {
80
- if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
81
- $this->_storeData();
82
- }
83
-
84
- $this->_currentObjectID = $pCoord;
85
- $this->_currentObject = $cell;
86
- $this->_currentCellIsDirty = true;
87
-
88
- return $cell;
89
- } // function addCacheData()
90
-
91
-
92
- /**
93
- * Get cell at a specific coordinate
94
- *
95
- * @param string $pCoord Coordinate of the cell
96
- * @throws PHPExcel_Exception
97
- * @return PHPExcel_Cell Cell that was found, or null if not found
98
- */
99
- public function getCacheData($pCoord) {
100
- if ($pCoord === $this->_currentObjectID) {
101
- return $this->_currentObject;
102
- }
103
- $this->_storeData();
104
-
105
- $query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
106
- $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
107
- if ($cellResultSet === false) {
108
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
109
- } elseif ($cellResultSet->numRows() == 0) {
110
- // Return null if requested entry doesn't exist in cache
111
- return null;
112
- }
113
-
114
- // Set current entry to the requested entry
115
- $this->_currentObjectID = $pCoord;
116
-
117
- $cellResult = $cellResultSet->fetchSingle();
118
- $this->_currentObject = unserialize($cellResult);
119
- // Re-attach this as the cell's parent
120
- $this->_currentObject->attach($this);
121
-
122
- // Return requested entry
123
- return $this->_currentObject;
124
- } // function getCacheData()
125
-
126
-
127
- /**
128
- * Is a value set for an indexed cell?
129
- *
130
- * @param string $pCoord Coordinate address of the cell to check
131
- * @return boolean
132
- */
133
- public function isDataSet($pCoord) {
134
- if ($pCoord === $this->_currentObjectID) {
135
- return true;
136
- }
137
-
138
- // Check if the requested entry exists in the cache
139
- $query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
140
- $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
141
- if ($cellResultSet === false) {
142
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
143
- } elseif ($cellResultSet->numRows() == 0) {
144
- // Return null if requested entry doesn't exist in cache
145
- return false;
146
- }
147
- return true;
148
- } // function isDataSet()
149
-
150
-
151
- /**
152
- * Delete a cell in cache identified by coordinate address
153
- *
154
- * @param string $pCoord Coordinate address of the cell to delete
155
- * @throws PHPExcel_Exception
156
- */
157
- public function deleteCacheData($pCoord) {
158
- if ($pCoord === $this->_currentObjectID) {
159
- $this->_currentObject->detach();
160
- $this->_currentObjectID = $this->_currentObject = null;
161
- }
162
-
163
- // Check if the requested entry exists in the cache
164
- $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
165
- if (!$this->_DBHandle->queryExec($query))
166
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
167
-
168
- $this->_currentCellIsDirty = false;
169
- } // function deleteCacheData()
170
-
171
-
172
- /**
173
- * Move a cell object from one address to another
174
- *
175
- * @param string $fromAddress Current address of the cell to move
176
- * @param string $toAddress Destination address of the cell to move
177
- * @return boolean
178
- */
179
- public function moveCell($fromAddress, $toAddress) {
180
- if ($fromAddress === $this->_currentObjectID) {
181
- $this->_currentObjectID = $toAddress;
182
- }
183
-
184
- $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'";
185
- $result = $this->_DBHandle->exec($query);
186
- if ($result === false)
187
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
188
-
189
- $query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
190
- $result = $this->_DBHandle->exec($query);
191
- if ($result === false)
192
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
193
-
194
- return TRUE;
195
- } // function moveCell()
196
-
197
-
198
- /**
199
- * Get a list of all cell addresses currently held in cache
200
- *
201
- * @return string[]
202
- */
203
- public function getCellList() {
204
- if ($this->_currentObjectID !== null) {
205
- $this->_storeData();
206
- }
207
-
208
- $query = "SELECT id FROM kvp_".$this->_TableName;
209
- $cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC);
210
- if ($cellIdsResult === false)
211
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
212
-
213
- $cellKeys = array();
214
- foreach($cellIdsResult as $row) {
215
- $cellKeys[] = $row['id'];
216
- }
217
-
218
- return $cellKeys;
219
- } // function getCellList()
220
-
221
-
222
- /**
223
- * Clone the cell collection
224
- *
225
- * @param PHPExcel_Worksheet $parent The new worksheet
226
- * @return void
227
- */
228
- public function copyCellCollection(PHPExcel_Worksheet $parent) {
229
- $this->_currentCellIsDirty;
230
- $this->_storeData();
231
-
232
- // Get a new id for the new table name
233
- $tableName = str_replace('.','_',$this->_getUniqueID());
234
- if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
235
- AS SELECT * FROM kvp_'.$this->_TableName))
236
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
237
-
238
- // Copy the existing cell cache file
239
- $this->_TableName = $tableName;
240
- } // function copyCellCollection()
241
-
242
-
243
- /**
244
- * Clear the cell collection and disconnect from our parent
245
- *
246
- * @return void
247
- */
248
- public function unsetWorksheetCells() {
249
- if(!is_null($this->_currentObject)) {
250
- $this->_currentObject->detach();
251
- $this->_currentObject = $this->_currentObjectID = null;
252
- }
253
- // detach ourself from the worksheet, so that it can then delete this object successfully
254
- $this->_parent = null;
255
-
256
- // Close down the temporary cache file
257
- $this->__destruct();
258
- } // function unsetWorksheetCells()
259
-
260
-
261
- /**
262
- * Initialise this new cell collection
263
- *
264
- * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
265
- */
266
- public function __construct(PHPExcel_Worksheet $parent) {
267
- parent::__construct($parent);
268
- if (is_null($this->_DBHandle)) {
269
- $this->_TableName = str_replace('.','_',$this->_getUniqueID());
270
- $_DBName = ':memory:';
271
-
272
- $this->_DBHandle = new SQLiteDatabase($_DBName);
273
- if ($this->_DBHandle === false)
274
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
275
- if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
276
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
277
- }
278
- } // function __construct()
279
-
280
-
281
- /**
282
- * Destroy this cell collection
283
- */
284
- public function __destruct() {
285
- if (!is_null($this->_DBHandle)) {
286
- $this->_DBHandle->queryExec('DROP TABLE kvp_'.$this->_TableName);
287
- }
288
- $this->_DBHandle = null;
289
- } // function __destruct()
290
-
291
-
292
- /**
293
- * Identify whether the caching method is currently available
294
- * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
295
- *
296
- * @return boolean
297
- */
298
- public static function cacheMethodIsAvailable() {
299
- if (!function_exists('sqlite_open')) {
300
- return false;
301
- }
302
-
303
- return true;
304
- }
305
-
306
- }
1
+ <?php
2
+ /**
3
+ * PHPExcel
4
+ *
5
+ * Copyright (c) 2006 - 2014 PHPExcel
6
+ *
7
+ * This library is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * This library is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with this library; if not, write to the Free Software
19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
+ *
21
+ * @category PHPExcel
22
+ * @package PHPExcel_CachedObjectStorage
23
+ * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25
+ * @version ##VERSION##, ##DATE##
26
+ */
27
+
28
+
29
+ /**
30
+ * PHPExcel_CachedObjectStorage_SQLite
31
+ *
32
+ * @category PHPExcel
33
+ * @package PHPExcel_CachedObjectStorage
34
+ * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
35
+ */
36
+ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
37
+
38
+ /**
39
+ * Database table name
40
+ *
41
+ * @var string
42
+ */
43
+ private $_TableName = null;
44
+
45
+ /**
46
+ * Database handle
47
+ *
48
+ * @var resource
49
+ */
50
+ private $_DBHandle = null;
51
+
52
+ /**
53
+ * Store cell data in cache for the current cell object if it's "dirty",
54
+ * and the 'nullify' the current cell object
55
+ *
56
+ * @return void
57
+ * @throws PHPExcel_Exception
58
+ */
59
+ protected function _storeData() {
60
+ if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
61
+ $this->_currentObject->detach();
62
+
63
+ if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')"))
64
+ throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
65
+ $this->_currentCellIsDirty = false;
66
+ }
67
+ $this->_currentObjectID = $this->_currentObject = null;
68
+ } // function _storeData()
69
+
70
+
71
+ /**
72
+ * Add or Update a cell in cache identified by coordinate address
73
+ *
74
+ * @param string $pCoord Coordinate address of the cell to update
75
+ * @param PHPExcel_Cell $cell Cell to update
76
+ * @return PHPExcel_Cell
77
+ * @throws PHPExcel_Exception
78
+ */
79
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
80
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
81
+ $this->_storeData();
82
+ }
83
+
84
+ $this->_currentObjectID = $pCoord;
85
+ $this->_currentObject = $cell;
86
+ $this->_currentCellIsDirty = true;
87
+
88
+ return $cell;
89
+ } // function addCacheData()
90
+
91
+
92
+ /**
93
+ * Get cell at a specific coordinate
94
+ *
95
+ * @param string $pCoord Coordinate of the cell
96
+ * @throws PHPExcel_Exception
97
+ * @return PHPExcel_Cell Cell that was found, or null if not found
98
+ */
99
+ public function getCacheData($pCoord) {
100
+ if ($pCoord === $this->_currentObjectID) {
101
+ return $this->_currentObject;
102
+ }
103
+ $this->_storeData();
104
+
105
+ $query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
106
+ $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
107
+ if ($cellResultSet === false) {
108
+ throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
109
+ } elseif ($cellResultSet->numRows() == 0) {
110
+ // Return null if requested entry doesn't exist in cache
111
+ return null;
112
+ }
113
+
114
+ // Set current entry to the requested entry
115
+ $this->_currentObjectID = $pCoord;
116
+
117
+ $cellResult = $cellResultSet->fetchSingle();
118
+ $this->_currentObject = unserialize($cellResult);
119
+ // Re-attach this as the cell's parent
120
+ $this->_currentObject->attach($this);
121
+
122
+ // Return requested entry
123
+ return $this->_currentObject;
124
+ } // function getCacheData()
125
+
126
+
127
+ /**
128
+ * Is a value set for an indexed cell?
129
+ *
130
+ * @param string $pCoord Coordinate address of the cell to check
131
+ * @return boolean
132
+ */
133
+ public function isDataSet($pCoord) {
134
+ if ($pCoord === $this->_currentObjectID) {
135
+ return true;
136
+ }
137
+
138
+ // Check if the requested entry exists in the cache
139
+ $query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
140
+ $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);
141
+ if ($cellResultSet === false) {
142
+ throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
143
+ } elseif ($cellResultSet->numRows() == 0) {
144
+ // Return null if requested entry doesn't exist in cache
145
+ return false;
146
+ }
147
+ return true;
148
+ } // function isDataSet()
149
+
150
+
151
+ /**
152
+ * Delete a cell in cache identified by coordinate address
153
+ *
154
+ * @param string $pCoord Coordinate address of the cell to delete
155
+ * @throws PHPExcel_Exception
156
+ */
157
+ public function deleteCacheData($pCoord) {
158
+ if ($pCoord === $this->_currentObjectID) {
159
+ $this->_currentObject->detach();
160
+ $this->_currentObjectID = $this->_currentObject = null;
161
+ }
162
+
163
+ // Check if the requested entry exists in the cache
164
+ $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
165
+ if (!$this->_DBHandle->queryExec($query))
166
+ throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
167
+
168
+ $this->_currentCellIsDirty = false;
169
+ } // function deleteCacheData()
170
+
171
+
172
+ /**
173
+ * Move a cell object from one address to another
174
+ *
175
+ * @param string $fromAddress Current address of the cell to move
176
+ * @param string $toAddress Destination address of the cell to move
177
+ * @return boolean
178
+ */
179
+ public function moveCell($fromAddress, $toAddress) {
180
+ if ($fromAddress === $this->_currentObjectID) {
181
+ $this->_currentObjectID = $toAddress;
182
+ }
183
+
184
+ $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'";
185
+ $result = $this->_DBHandle->exec($query);
186
+ if ($result === false)
187
+ throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
188
+
189
+ $query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
190
+ $result = $this->_DBHandle->exec($query);
191
+ if ($result === false)
192
+ throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
193
+
194
+ return TRUE;
195
+ } // function moveCell()
196
+
197
+
198
+ /**
199
+ * Get a list of all cell addresses currently held in cache
200
+ *
201
+ * @return string[]
202
+ */
203
+ public function getCellList() {
204
+ if ($this->_currentObjectID !== null) {
205
+ $this->_storeData();
206
+ }
207
+
208
+ $query = "SELECT id FROM kvp_".$this->_TableName;
209
+ $cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC);
210
+ if ($cellIdsResult === false)
211
+ throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
212
+
213
+ $cellKeys = array();
214
+ foreach($cellIdsResult as $row) {
215
+ $cellKeys[] = $row['id'];
216
+ }
217
+
218
+ return $cellKeys;
219
+ } // function getCellList()
220
+
221
+
222
+ /**
223
+ * Clone the cell collection
224
+ *
225
+ * @param PHPExcel_Worksheet $parent The new worksheet
226
+ * @return void
227
+ */
228
+ public function copyCellCollection(PHPExcel_Worksheet $parent) {
229
+ $this->_currentCellIsDirty;
230
+ $this->_storeData();
231
+
232
+ // Get a new id for the new table name
233
+ $tableName = str_replace('.','_',$this->_getUniqueID());
234
+ if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
235
+ AS SELECT * FROM kvp_'.$this->_TableName))
236
+ throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
237
+
238
+ // Copy the existing cell cache file
239
+ $this->_TableName = $tableName;
240
+ } // function copyCellCollection()
241
+
242
+
243
+ /**
244
+ * Clear the cell collection and disconnect from our parent
245
+ *
246
+ * @return void
247
+ */
248
+ public function unsetWorksheetCells() {
249
+ if(!is_null($this->_currentObject)) {
250
+ $this->_currentObject->detach();
251
+ $this->_currentObject = $this->_currentObjectID = null;
252
+ }
253
+ // detach ourself from the worksheet, so that it can then delete this object successfully
254
+ $this->_parent = null;
255
+
256
+ // Close down the temporary cache file
257
+ $this->__destruct();
258
+ } // function unsetWorksheetCells()
259
+
260
+
261
+ /**
262
+ * Initialise this new cell collection
263
+ *
264
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
265
+ */
266
+ public function __construct(PHPExcel_Worksheet $parent) {
267
+ parent::__construct($parent);
268
+ if (is_null($this->_DBHandle)) {
269
+ $this->_TableName = str_replace('.','_',$this->_getUniqueID());
270
+ $_DBName = ':memory:';
271
+
272
+ $this->_DBHandle = new SQLiteDatabase($_DBName);
273
+ if ($this->_DBHandle === false)
274
+ throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
275
+ if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
276
+ throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
277
+ }
278
+ } // function __construct()
279
+
280
+
281
+ /**
282
+ * Destroy this cell collection
283
+ */
284
+ public function __destruct() {
285
+ if (!is_null($this->_DBHandle)) {
286
+ $this->_DBHandle->queryExec('DROP TABLE kvp_'.$this->_TableName);
287
+ }
288
+ $this->_DBHandle = null;
289
+ } // function __destruct()
290
+
291
+
292
+ /**
293
+ * Identify whether the caching method is currently available
294
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
295
+ *
296
+ * @return boolean
297
+ */
298
+ public static function cacheMethodIsAvailable() {
299
+ if (!function_exists('sqlite_open')) {
300
+ return false;
301
+ }
302
+
303
+ return true;
304
+ }
305
+
306
+ }
classes/PHPExcel/CachedObjectStorage/SQLite3.php CHANGED
@@ -1,345 +1,345 @@
1
- <?php
2
- /**
3
- * PHPExcel
4
- *
5
- * Copyright (c) 2006 - 2014 PHPExcel
6
- *
7
- * This library is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU Lesser General Public
9
- * License as published by the Free Software Foundation; either
10
- * version 2.1 of the License, or (at your option) any later version.
11
- *
12
- * This library is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
- * Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public
18
- * License along with this library; if not, write to the Free Software
19
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
- *
21
- * @category PHPExcel
22
- * @package PHPExcel_CachedObjectStorage
23
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25
- * @version ##VERSION##, ##DATE##
26
- */
27
-
28
-
29
- /**
30
- * PHPExcel_CachedObjectStorage_SQLite3
31
- *
32
- * @category PHPExcel
33
- * @package PHPExcel_CachedObjectStorage
34
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
35
- */
36
- class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
37
-
38
- /**
39
- * Database table name
40
- *
41
- * @var string
42
- */
43
- private $_TableName = null;
44
-
45
- /**
46
- * Database handle
47
- *
48
- * @var resource
49
- */
50
- private $_DBHandle = null;
51
-
52
- /**
53
- * Prepared statement for a SQLite3 select query
54
- *
55
- * @var SQLite3Stmt
56
- */
57
- private $_selectQuery;
58
-
59
- /**
60
- * Prepared statement for a SQLite3 insert query
61
- *
62
- * @var SQLite3Stmt
63
- */
64
- private $_insertQuery;
65
-
66
- /**
67
- * Prepared statement for a SQLite3 update query
68
- *
69
- * @var SQLite3Stmt
70
- */
71
- private $_updateQuery;
72
-
73
- /**
74
- * Prepared statement for a SQLite3 delete query
75
- *
76
- * @var SQLite3Stmt
77
- */
78
- private $_deleteQuery;
79
-
80
- /**
81
- * Store cell data in cache for the current cell object if it's "dirty",
82
- * and the 'nullify' the current cell object
83
- *
84
- * @return void
85
- * @throws PHPExcel_Exception
86
- */
87
- protected function _storeData() {
88
- if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
89
- $this->_currentObject->detach();
90
-
91
- $this->_insertQuery->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT);
92
- $this->_insertQuery->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB);
93
- $result = $this->_insertQuery->execute();
94
- if ($result === false)
95
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
96
- $this->_currentCellIsDirty = false;
97
- }
98
- $this->_currentObjectID = $this->_currentObject = null;
99
- } // function _storeData()
100
-
101
-
102
- /**
103
- * Add or Update a cell in cache identified by coordinate address
104
- *
105
- * @param string $pCoord Coordinate address of the cell to update
106
- * @param PHPExcel_Cell $cell Cell to update
107
- * @return PHPExcel_Cell
108
- * @throws PHPExcel_Exception
109
- */
110
- public function addCacheData($pCoord, PHPExcel_Cell $cell) {
111
- if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
112
- $this->_storeData();
113
- }
114
-
115
- $this->_currentObjectID = $pCoord;
116
- $this->_currentObject = $cell;
117
- $this->_currentCellIsDirty = true;
118
-
119
- return $cell;
120
- } // function addCacheData()
121
-
122
-
123
- /**
124
- * Get cell at a specific coordinate
125
- *
126
- * @param string $pCoord Coordinate of the cell
127
- * @throws PHPExcel_Exception
128
- * @return PHPExcel_Cell Cell that was found, or null if not found
129
- */
130
- public function getCacheData($pCoord) {
131
- if ($pCoord === $this->_currentObjectID) {
132
- return $this->_currentObject;
133
- }
134
- $this->_storeData();
135
-
136
- $this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
137
- $cellResult = $this->_selectQuery->execute();
138
- if ($cellResult === FALSE) {
139
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
140
- }
141
- $cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
142
- if ($cellData === FALSE) {
143
- // Return null if requested entry doesn't exist in cache
144
- return NULL;
145
- }
146
-
147
- // Set current entry to the requested entry
148
- $this->_currentObjectID = $pCoord;
149
-
150
- $this->_currentObject = unserialize($cellData['value']);
151
- // Re-attach this as the cell's parent
152
- $this->_currentObject->attach($this);
153
-
154
- // Return requested entry
155
- return $this->_currentObject;
156
- } // function getCacheData()
157
-
158
-
159
- /**
160
- * Is a value set for an indexed cell?
161
- *
162
- * @param string $pCoord Coordinate address of the cell to check
163
- * @return boolean
164
- */
165
- public function isDataSet($pCoord) {
166
- if ($pCoord === $this->_currentObjectID) {
167
- return TRUE;
168
- }
169
-
170
- // Check if the requested entry exists in the cache
171
- $this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
172
- $cellResult = $this->_selectQuery->execute();
173
- if ($cellResult === FALSE) {
174
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
175
- }
176
- $cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
177
-
178
- return ($cellData === FALSE) ? FALSE : TRUE;
179
- } // function isDataSet()
180
-
181
-
182
- /**
183
- * Delete a cell in cache identified by coordinate address
184
- *
185
- * @param string $pCoord Coordinate address of the cell to delete
186
- * @throws PHPExcel_Exception
187
- */
188
- public function deleteCacheData($pCoord) {
189
- if ($pCoord === $this->_currentObjectID) {
190
- $this->_currentObject->detach();
191
- $this->_currentObjectID = $this->_currentObject = NULL;
192
- }
193
-
194
- // Check if the requested entry exists in the cache
195
- $this->_deleteQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
196
- $result = $this->_deleteQuery->execute();
197
- if ($result === FALSE)
198
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
199
-
200
- $this->_currentCellIsDirty = FALSE;
201
- } // function deleteCacheData()
202
-
203
-
204
- /**
205
- * Move a cell object from one address to another
206
- *
207
- * @param string $fromAddress Current address of the cell to move
208
- * @param string $toAddress Destination address of the cell to move
209
- * @return boolean
210
- */
211
- public function moveCell($fromAddress, $toAddress) {
212
- if ($fromAddress === $this->_currentObjectID) {
213
- $this->_currentObjectID = $toAddress;
214
- }
215
-
216
- $this->_deleteQuery->bindValue('id',$toAddress,SQLITE3_TEXT);
217
- $result = $this->_deleteQuery->execute();
218
- if ($result === false)
219
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
220
-
221
- $this->_updateQuery->bindValue('toid',$toAddress,SQLITE3_TEXT);
222
- $this->_updateQuery->bindValue('fromid',$fromAddress,SQLITE3_TEXT);
223
- $result = $this->_updateQuery->execute();
224
- if ($result === false)
225
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
226
-
227
- return TRUE;
228
- } // function moveCell()
229
-
230
-
231
- /**
232
- * Get a list of all cell addresses currently held in cache
233
- *
234
- * @return string[]
235
- */
236
- public function getCellList() {
237
- if ($this->_currentObjectID !== null) {
238
- $this->_storeData();
239
- }
240
-
241
- $query = "SELECT id FROM kvp_".$this->_TableName;
242
- $cellIdsResult = $this->_DBHandle->query($query);
243
- if ($cellIdsResult === false)
244
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
245
-
246
- $cellKeys = array();
247
- while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
248
- $cellKeys[] = $row['id'];
249
- }
250
-
251
- return $cellKeys;
252
- } // function getCellList()
253
-
254
-
255
- /**
256
- * Clone the cell collection
257
- *
258
- * @param PHPExcel_Worksheet $parent The new worksheet
259
- * @return void
260
- */
261
- public function copyCellCollection(PHPExcel_Worksheet $parent) {
262
- $this->_currentCellIsDirty;
263
- $this->_storeData();
264
-
265
- // Get a new id for the new table name
266
- $tableName = str_replace('.','_',$this->_getUniqueID());
267
- if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
268
- AS SELECT * FROM kvp_'.$this->_TableName))
269
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
270
-
271
- // Copy the existing cell cache file
272
- $this->_TableName = $tableName;
273
- } // function copyCellCollection()
274
-
275
-
276
- /**
277
- * Clear the cell collection and disconnect from our parent
278
- *
279
- * @return void
280
- */
281
- public function unsetWorksheetCells() {
282
- if(!is_null($this->_currentObject)) {
283
- $this->_currentObject->detach();
284
- $this->_currentObject = $this->_currentObjectID = null;
285
- }
286
- // detach ourself from the worksheet, so that it can then delete this object successfully
287
- $this->_parent = null;
288
-
289
- // Close down the temporary cache file
290
- $this->__destruct();
291
- } // function unsetWorksheetCells()
292
-
293
-
294
- /**
295
- * Initialise this new cell collection
296
- *
297
- * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
298
- */
299
- public function __construct(PHPExcel_Worksheet $parent) {
300
- parent::__construct($parent);
301
- if (is_null($this->_DBHandle)) {
302
- $this->_TableName = str_replace('.','_',$this->_getUniqueID());
303
- $_DBName = ':memory:';
304
-
305
- $this->_DBHandle = new SQLite3($_DBName);
306
- if ($this->_DBHandle === false)
307
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
308
- if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
309
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
310
- }
311
-
312
- $this->_selectQuery = $this->_DBHandle->prepare("SELECT value FROM kvp_".$this->_TableName." WHERE id = :id");
313
- $this->_insertQuery = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)");
314
- $this->_updateQuery = $this->_DBHandle->prepare("UPDATE kvp_".$this->_TableName." SET id=:toId WHERE id=:fromId");
315
- $this->_deleteQuery = $this->_DBHandle->prepare("DELETE FROM kvp_".$this->_TableName." WHERE id = :id");
316
- } // function __construct()
317
-
318
-
319
- /**
320
- * Destroy this cell collection
321
- */
322
- public function __destruct() {
323
- if (!is_null($this->_DBHandle)) {
324
- $this->_DBHandle->exec('DROP TABLE kvp_'.$this->_TableName);
325
- $this->_DBHandle->close();
326
- }
327
- $this->_DBHandle = null;
328
- } // function __destruct()
329
-
330
-
331
- /**
332
- * Identify whether the caching method is currently available
333
- * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
334
- *
335
- * @return boolean
336
- */
337
- public static function cacheMethodIsAvailable() {
338
- if (!class_exists('SQLite3',FALSE)) {
339
- return false;
340
- }
341
-
342
- return true;
343
- }
344
-
345
- }
1
+ <?php
2
+ /**
3
+ * PHPExcel
4
+ *
5
+ * Copyright (c) 2006 - 2014 PHPExcel
6
+ *
7
+ * This library is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * This library is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with this library; if not, write to the Free Software
19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
+ *
21
+ * @category PHPExcel
22
+ * @package PHPExcel_CachedObjectStorage
23
+ * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25
+ * @version ##VERSION##, ##DATE##
26
+ */
27
+
28
+
29
+ /**
30
+ * PHPExcel_CachedObjectStorage_SQLite3
31
+ *
32
+ * @category PHPExcel
33
+ * @package PHPExcel_CachedObjectStorage
34
+ * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
35
+ */
36
+ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
37
+
38
+ /**
39
+ * Database table name
40
+ *
41
+ * @var string
42
+ */
43
+ private $_TableName = null;
44
+
45
+ /**
46
+ * Database handle
47
+ *
48
+ * @var resource
49
+ */
50
+ private $_DBHandle = null;
51
+
52
+ /**
53
+ * Prepared statement for a SQLite3 select query
54
+ *
55
+ * @var SQLite3Stmt
56
+ */
57
+ private $_selectQuery;
58
+
59
+ /**
60
+ * Prepared statement for a SQLite3 insert query
61
+ *
62
+ * @var SQLite3Stmt
63
+ */
64
+ private $_insertQuery;
65
+
66
+ /**
67
+ * Prepared statement for a SQLite3 update query
68
+ *
69
+ * @var SQLite3Stmt
70
+ */
71
+ private $_updateQuery;
72
+
73
+ /**
74
+ * Prepared statement for a SQLite3 delete query
75
+ *
76
+ * @var SQLite3Stmt
77
+ */
78
+ private $_deleteQuery;
79
+
80
+ /**
81
+ * Store cell data in cache for the current cell object if it's "dirty",
82
+ * and the 'nullify' the current cell object
83
+ *
84
+ * @return void
85
+ * @throws PHPExcel_Exception
86
+ */
87
+ protected function _storeData() {
88
+ if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
89
+ $this->_currentObject->detach();
90
+
91
+ $this->_insertQuery->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT);
92
+ $this->_insertQuery->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB);
93
+ $result = $this->_insertQuery->execute();
94
+ if ($result === false)
95
+ throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
96
+ $this->_currentCellIsDirty = false;
97
+ }
98
+ $this->_currentObjectID = $this->_currentObject = null;
99
+ } // function _storeData()
100
+
101
+
102
+ /**
103
+ * Add or Update a cell in cache identified by coordinate address
104
+ *
105
+ * @param string $pCoord Coordinate address of the cell to update
106
+ * @param PHPExcel_Cell $cell Cell to update
107
+ * @return PHPExcel_Cell
108
+ * @throws PHPExcel_Exception
109
+ */
110
+ public function addCacheData($pCoord, PHPExcel_Cell $cell) {
111
+ if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
112
+ $this->_storeData();
113
+ }
114
+
115
+ $this->_currentObjectID = $pCoord;
116
+ $this->_currentObject = $cell;
117
+ $this->_currentCellIsDirty = true;
118
+
119
+ return $cell;
120
+ } // function addCacheData()
121
+
122
+
123
+ /**
124
+ * Get cell at a specific coordinate
125
+ *
126
+ * @param string $pCoord Coordinate of the cell
127
+ * @throws PHPExcel_Exception
128
+ * @return PHPExcel_Cell Cell that was found, or null if not found
129
+ */
130
+ public function getCacheData($pCoord) {
131
+ if ($pCoord === $this->_currentObjectID) {
132
+ return $this->_currentObject;
133
+ }
134
+ $this->_storeData();
135
+
136
+ $this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
137
+ $cellResult = $this->_selectQuery->execute();
138
+ if ($cellResult === FALSE) {
139
+ throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
140
+ }
141
+ $cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
142
+ if ($cellData === FALSE) {
143
+ // Return null if requested entry doesn't exist in cache
144
+ return NULL;
145
+ }
146
+
147
+ // Set current entry to the requested entry
148
+ $this->_currentObjectID = $pCoord;
149
+
150
+ $this->_currentObject = unserialize($cellData['value']);
151
+ // Re-attach this as the cell's parent
152
+ $this->_currentObject->attach($this);
153
+
154
+ // Return requested entry
155
+ return $this->_currentObject;
156
+ } // function getCacheData()
157
+
158
+
159
+ /**
160
+ * Is a value set for an indexed cell?
161
+ *
162
+ * @param string $pCoord Coordinate address of the cell to check
163
+ * @return boolean
164
+ */
165
+ public function isDataSet($pCoord) {
166
+ if ($pCoord === $this->_currentObjectID) {
167
+ return TRUE;
168
+ }
169
+
170
+ // Check if the requested entry exists in the cache
171
+ $this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
172
+ $cellResult = $this->_selectQuery->execute();
173
+ if ($cellResult === FALSE) {
174
+ throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
175
+ }
176
+ $cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
177
+
178
+ return ($cellData === FALSE) ? FALSE : TRUE;
179
+ } // function isDataSet()
180
+
181
+
182
+ /**
183
+ * Delete a cell in cache identified by coordinate address
184
+ *
185
+ * @param string $pCoord Coordinate address of the cell to delete
186
+ * @throws PHPExcel_Exception
187
+ */
188
+ public function deleteCacheData($pCoord) {
189
+ if ($pCoord === $this->_currentObjectID) {
190
+ $this->_currentObject->detach();
191
+ $this->_currentObjectID = $this->_currentObject = NULL;
192
+ }
193
+
194
+ // Check if the requested entry exists in the cache
195
+ $this->_deleteQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
196
+ $result = $this->_deleteQuery->execute();
197
+ if ($result === FALSE)
198
+ throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
199
+
200
+ $this->_currentCellIsDirty = FALSE;
201
+ } // function deleteCacheData()
202
+
203
+
204
+ /**
205
+ * Move a cell object from one address to another
206
+ *
207
+ * @param string $fromAddress Current address of the cell to move
208
+ * @param string $toAddress Destination address of the cell to move
209
+ * @return boolean
210
+ */
211
+ public function moveCell($fromAddress, $toAddress) {
212
+ if ($fromAddress === $this->_currentObjectID) {
213
+ $this->_currentObjectID = $toAddress;
214
+ }
215
+
216
+ $this->_deleteQuery->bindValue('id',$toAddress,SQLITE3_TEXT);
217
+ $result = $this->_deleteQuery->execute();
218
+ if ($result === false)
219
+ throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
220
+
221
+ $this->_updateQuery->bindValue('toid',$toAddress,SQLITE3_TEXT);
222
+ $this->_updateQuery->bindValue('fromid',$fromAddress,SQLITE3_TEXT);
223
+ $result = $this->_updateQuery->execute();
224
+ if ($result === false)
225
+ throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
226
+
227
+ return TRUE;
228
+ } // function moveCell()
229
+
230
+
231
+ /**
232
+ * Get a list of all cell addresses currently held in cache
233
+ *
234
+ * @return string[]
235
+ */
236
+ public function getCellList() {
237
+ if ($this->_currentObjectID !== null) {
238
+ $this->_storeData();
239
+ }
240
+
241
+ $query = "SELECT id FROM kvp_".$this->_TableName;
242
+ $cellIdsResult = $this->_DBHandle->query($query);
243
+ if ($cellIdsResult === false)
244
+ throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
245
+
246
+ $cellKeys = array();
247
+ while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
248
+ $cellKeys[] = $row['id'];
249
+ }
250
+
251
+ return $cellKeys;
252
+ } // function getCellList()
253
+
254
+
255
+ /**
256
+ * Clone the cell collection
257
+ *
258
+ * @param PHPExcel_Worksheet $parent The new worksheet
259
+ * @return void
260
+ */
261
+ public function copyCellCollection(PHPExcel_Worksheet $parent) {
262
+ $this->_currentCellIsDirty;
263
+ $this->_storeData();
264
+
265
+ // Get a new id for the new table name
266
+ $tableName = str_replace('.','_',$this->_getUniqueID());
267
+ if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
268
+ AS SELECT * FROM kvp_'.$this->_TableName))
269
+ throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
270
+
271
+ // Copy the existing cell cache file
272
+ $this->_TableName = $tableName;
273
+ } // function copyCellCollection()
274
+
275
+
276
+ /**
277
+ * Clear the cell collection and disconnect from our parent
278
+ *
279
+ * @return void
280
+ */
281
+ public function unsetWorksheetCells() {
282
+ if(!is_null($this->_currentObject)) {
283
+ $this->_currentObject->detach();
284
+ $this->_currentObject = $this->_currentObjectID = null;
285
+ }
286
+ // detach ourself from the worksheet, so that it can then delete this object successfully
287
+ $this->_parent = null;
288
+
289
+ // Close down the temporary cache file
290
+ $this->__destruct();
291
+ } // function unsetWorksheetCells()
292
+
293
+
294
+ /**
295
+ * Initialise this new cell collection
296
+ *
297
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
298
+ */
299
+ public function __construct(PHPExcel_Worksheet $parent) {
300
+ parent::__construct($parent);
301
+ if (is_null($this->_DBHandle)) {
302
+ $this->_TableName = str_replace('.','_',$this->_getUniqueID());
303
+ $_DBName = ':memory:';
304
+
305
+ $this->_DBHandle = new SQLite3($_DBName);
306
+ if ($this->_DBHandle === false)
307
+ throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
308
+ if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
309
+ throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
310
+ }
311
+
312
+ $this->_selectQuery = $this->_DBHandle->prepare("SELECT value FROM kvp_".$this->_TableName." WHERE id = :id");
313
+ $this->_insertQuery = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)");
314
+ $this->_updateQuery = $this->_DBHandle->prepare("UPDATE kvp_".$this->_TableName." SET id=:toId WHERE id=:fromId");
315
+ $this->_deleteQuery = $this->_DBHandle->prepare("DELETE FROM kvp_".$this->_TableName." WHERE id = :id");
316
+ } // function __construct()
317
+
318
+
319
+ /**
320
+ * Destroy this cell collection
321
+ */
322
+ public function __destruct() {
323
+ if (!is_null($this->_DBHandle)) {
324
+ $this->_DBHandle->exec('DROP TABLE kvp_'.$this->_TableName);
325
+ $this->_DBHandle->close();
326
+ }
327
+ $this->_DBHandle = null;
328
+ } // function __destruct()
329
+
330
+
331
+ /**
332
+ * Identify whether the caching method is currently available
333
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
334
+ *
335
+ * @return boolean
336
+ */
337
+ public static function cacheMethodIsAvailable() {
338
+ if (!class_exists('SQLite3',FALSE)) {
339
+ return false;
340
+ }
341
+
342
+ return true;
343
+ }
344
+
345
+ }
classes/chunk.php CHANGED
@@ -376,9 +376,19 @@ class preprocessXml_filter extends php_user_filter {
376
  {
377
  // the & symbol is not valid in XML, so replace it with temporary word _ampersand_
378
  $bucket->data = str_replace("&", "_ampersand_", $bucket->data);
379
- $bucket->data = preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $this->replace_colons($bucket->data));
380
- }
381
- $consumed += $bucket->datalen;
 
 
 
 
 
 
 
 
 
 
382
  stream_bucket_append($out, $bucket);
383
  }
384
  return PSFS_PASS_ON;
376
  {
377
  // the & symbol is not valid in XML, so replace it with temporary word _ampersand_
378
  $bucket->data = str_replace("&", "_ampersand_", $bucket->data);
379
+ $cleanXML = preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $this->replace_colons($bucket->data));
380
+ if ($cleanXML == NULL && preg_last_error() == PREG_BAD_UTF8_ERROR){
381
+ $cleanXML = preg_replace('/[^\x09\x0a\x0d\x20-\xFF]+/', ' ', $this->replace_colons($bucket->data));
382
+ }
383
+ if ($cleanXML == NULL && preg_last_error() == PREG_BAD_UTF8_ERROR){
384
+ if (function_exists('mb_ereg_replace')){
385
+ mb_regex_encoding('UTF-8');
386
+ $cleanXML = mb_ereg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $this->replace_colons($bucket->data));
387
+ }
388
+ }
389
+ $bucket->data = empty($cleanXML) ? $this->replace_colons($bucket->data) : $cleanXML;
390
+ }
391
+ $consumed += $bucket->datalen;
392
  stream_bucket_append($out, $bucket);
393
  }
394
  return PSFS_PASS_ON;
classes/upload.php CHANGED
@@ -70,7 +70,7 @@ if ( ! class_exists('PMXI_Upload')){
70
  {
71
  foreach ($v_result_list as $unzipped_file)
72
  {
73
- if ($unzipped_file['status'] == 'ok' and preg_match('%\W(xml|csv|txt|dat|psv|json|xls|xlsx)$%i', trim($unzipped_file['stored_filename'])) and strpos($unzipped_file['stored_filename'], 'readme.txt') === false )
74
  {
75
  if ( strpos(basename($unzipped_file['stored_filename']), 'WP All Import Template') === 0 || strpos(basename($unzipped_file['stored_filename']), 'templates_') === 0 )
76
  {
70
  {
71
  foreach ($v_result_list as $unzipped_file)
72
  {
73
+ if ($unzipped_file['status'] == 'ok' and preg_match('%\W(xml|csv|txt|dat|psv|json|xls|xlsx|gz)$%i', trim($unzipped_file['stored_filename'])) and strpos($unzipped_file['stored_filename'], 'readme.txt') === false )
74
  {
75
  if ( strpos(basename($unzipped_file['stored_filename']), 'WP All Import Template') === 0 || strpos(basename($unzipped_file['stored_filename']), 'templates_') === 0 )
76
  {
filters/pmxi_custom_types.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function pmxi_pmxi_custom_types($custom_types)
4
+ {
5
+
6
+ if ( class_exists('WooCommerce') && ! class_exists('PMWI_Plugin') )
7
+ {
8
+ if ( ! empty($custom_types['product']) ) $custom_types['product']->labels->name = __('WooCommerce Products','wp_all_import_plugin');
9
+ if ( ! empty($custom_types['shop_order']) ) $custom_types['shop_order']->labels->name = __('WooCommerce Orders','wp_all_import_plugin');
10
+ if ( ! empty($custom_types['shop_coupon'])) $custom_types['shop_coupon']->labels->name = __('WooCommerce Coupons','wp_all_import_plugin');
11
+ if ( ! empty($custom_types['product_variation'])) unset($custom_types['product_variation']);
12
+ if ( ! empty($custom_types['shop_order_refund'])) unset($custom_types['shop_order_refund']);
13
+
14
+ $order = array('shop_order', 'shop_coupon', 'product');
15
+
16
+ $ordered_custom_types = array();
17
+
18
+ foreach ($order as $type)
19
+ {
20
+ if (isset($ordered_custom_types[$type])) continue;
21
+
22
+ foreach ($custom_types as $key => $custom_type)
23
+ {
24
+ if (isset($ordered_custom_types[$key])) continue;
25
+
26
+ if (in_array($key, $order))
27
+ {
28
+ if ($key == $type)
29
+ {
30
+ $ordered_custom_types[$key] = $custom_type;
31
+ }
32
+ }
33
+ else
34
+ {
35
+ $ordered_custom_types[$key] = $custom_type;
36
+ }
37
+ }
38
+ }
39
+ return $ordered_custom_types;
40
+ }
41
+
42
+ return $custom_types;
43
+ }
helpers/functions.php CHANGED
@@ -154,3 +154,10 @@
154
  return stripslashes(esc_sql(htmlspecialchars(strip_tags($str))));
155
  }
156
  }
 
 
 
 
 
 
 
154
  return stripslashes(esc_sql(htmlspecialchars(strip_tags($str))));
155
  }
156
  }
157
+
158
+ if ( ! function_exists('wp_all_import_cmp_custom_types')){
159
+ function wp_all_import_cmp_custom_types($a, $b)
160
+ {
161
+ return strcmp($a->labels->name, $b->labels->name);
162
+ }
163
+ }
helpers/wp_all_import_get_image_from_gallery.php CHANGED
@@ -13,9 +13,9 @@ function wp_all_import_get_image_from_gallery($image_name, $targetDir = false, $
13
  $attch = '';
14
 
15
  // search attachment by attached file
16
- $attachment_meta = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $wpdb->postmeta . " WHERE meta_key = %s AND meta_value LIKE %s;", '_wp_attached_file', "%/" . $image_name ) );
17
 
18
- if ( ! empty($attachment_meta) )
19
  {
20
  $attch = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $wpdb->posts . " WHERE ID = %d;", $attachment_meta->post_id ) );
21
  }
13
  $attch = '';
14
 
15
  // search attachment by attached file
16
+ $attachment_meta = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $wpdb->postmeta . " WHERE meta_key = %s AND meta_value = %s OR meta_value LIKE %s;", '_wp_attached_file', $image_name, "%/" . $image_name ) );
17
 
18
+ if ( ! empty($attachment_meta) )
19
  {
20
  $attch = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $wpdb->posts . " WHERE ID = %d;", $attachment_meta->post_id ) );
21
  }
helpers/wp_all_import_secure_file.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  if ( ! function_exists('wp_all_import_secure_file') ){
3
 
4
- function wp_all_import_secure_file( $targetDir, $importID = false, $remove_dir = false ){
5
 
6
  $is_secure_import = PMXI_Plugin::getInstance()->getOption('secure');
7
 
@@ -11,11 +11,11 @@ if ( ! function_exists('wp_all_import_secure_file') ){
11
 
12
  if ( @is_dir($dir) and $remove_dir ) wp_all_import_remove_source($dir . DIRECTORY_SEPARATOR . 'index.php' );
13
 
14
- @wp_mkdir_p($dir);
15
 
16
  if (@is_writable($dir) and @is_dir($dir)){
17
  $targetDir = $dir;
18
- if (!@file_exists($dir . DIRECTORY_SEPARATOR . 'index.php'))
19
  {
20
  @touch( $dir . DIRECTORY_SEPARATOR . 'index.php' );
21
  }
1
  <?php
2
  if ( ! function_exists('wp_all_import_secure_file') ){
3
 
4
+ function wp_all_import_secure_file( $targetDir, $importID = false, $remove_dir = false, $generateDir = true ){
5
 
6
  $is_secure_import = PMXI_Plugin::getInstance()->getOption('secure');
7
 
11
 
12
  if ( @is_dir($dir) and $remove_dir ) wp_all_import_remove_source($dir . DIRECTORY_SEPARATOR . 'index.php' );
13
 
14
+ if ( $generateDir ) @wp_mkdir_p($dir);
15
 
16
  if (@is_writable($dir) and @is_dir($dir)){
17
  $targetDir = $dir;
18
+ if (!@file_exists($dir . DIRECTORY_SEPARATOR . 'index.php') && $generateDir)
19
  {
20
  @touch( $dir . DIRECTORY_SEPARATOR . 'index.php' );
21
  }
models/history/record.php CHANGED
@@ -16,10 +16,10 @@ class PMXI_History_Record extends PMXI_Model_Record {
16
 
17
  $uploads = wp_upload_dir();
18
 
19
- $history_file_path = wp_all_import_secure_file( $uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::LOGS_DIRECTORY, $this->id ) . DIRECTORY_SEPARATOR . $this->id . '.html';
20
- if ( @file_exists($history_file_path) ){
21
  wp_all_import_remove_source($history_file_path);
22
- }
23
  }
24
  return ($db) ? parent::delete() : true;
25
  }
16
 
17
  $uploads = wp_upload_dir();
18
 
19
+ $history_file_path = wp_all_import_secure_file( $uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::LOGS_DIRECTORY, $this->id, false, false ) . DIRECTORY_SEPARATOR . $this->id . '.html';
20
+ if ( @file_exists($history_file_path) ){
21
  wp_all_import_remove_source($history_file_path);
22
+ }
23
  }
24
  return ($db) ? parent::delete() : true;
25
  }
models/import/record.php CHANGED
@@ -752,7 +752,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
752
 
753
  if ($this->options['attachments']) {
754
  // Detect if attachments is separated by comma
755
- $atchs = explode(',', $this->options['attachments']);
756
  if (!empty($atchs)){
757
  $parse_multiple = true;
758
  foreach($atchs as $atch) if (!preg_match("/{.*}/", trim($atch))) $parse_multiple = false;
@@ -1139,6 +1139,10 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1139
  $articleData['post_parent'] = $post_to_update->post_parent;
1140
  $logger and call_user_func($logger, sprintf(__('Preserve post parent of already existing article for `%s`', 'wp_all_import_plugin'), $articleData['post_title']));
1141
  }
 
 
 
 
1142
  if ( ! $this->options['is_update_comment_status']){
1143
  $articleData['comment_status'] = $post_to_update->comment_status;
1144
  $logger and call_user_func($logger, sprintf(__('Preserve comment status of already existing article for `%s`', 'wp_all_import_plugin'), $articleData['post_title']));
@@ -1176,11 +1180,19 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1176
  wp_delete_attachments($articleData['ID'], true, 'files');
1177
  }
1178
  // handle obsolete attachments (i.e. delete or keep) according to import settings
1179
- if ( $this->options['update_all_data'] == 'yes' or ( $this->options['update_all_data'] == 'no' and $this->options['is_update_images'] and $this->options['update_images_logic'] == "full_update")){
1180
- $logger and call_user_func($logger, sprintf(__('Deleting images for `%s`', 'wp_all_import_plugin'), $articleData['post_title']));
1181
- $do_not_remove_images = ( $this->options['download_images'] == 'gallery' or $this->options['do_not_remove_images']) ? false : true;
1182
- $missing_images = wp_delete_attachments($articleData['ID'], $do_not_remove_images, 'images');
1183
- }
 
 
 
 
 
 
 
 
1184
  }
1185
  }
1186
  }
@@ -2473,11 +2485,17 @@ class PMXI_Import_Record extends PMXI_Model_Record {
2473
  'import_id' => $this->id,
2474
  ));
2475
  if ( ! $postRecord->isEmpty() )
2476
- {
2477
- $postRecord->set(array(
2478
- 'iteration' => $iteration
2479
- ))->save();
2480
- }
 
 
 
 
 
 
2481
 
2482
  do_action('pmxi_missing_post', $missingPostRecord['post_id']);
2483
 
752
 
753
  if ($this->options['attachments']) {
754
  // Detect if attachments is separated by comma
755
+ $atchs = empty($this->options['atch_delim']) ? explode(',', $this->options['attachments']) : explode($this->options['atch_delim'], $this->options['attachments']);
756
  if (!empty($atchs)){
757
  $parse_multiple = true;
758
  foreach($atchs as $atch) if (!preg_match("/{.*}/", trim($atch))) $parse_multiple = false;
1139
  $articleData['post_parent'] = $post_to_update->post_parent;
1140
  $logger and call_user_func($logger, sprintf(__('Preserve post parent of already existing article for `%s`', 'wp_all_import_plugin'), $articleData['post_title']));
1141
  }
1142
+ if ( ! $this->options['is_update_post_type']){
1143
+ $articleData['post_type'] = $post_to_update->post_type;
1144
+ $logger and call_user_func($logger, sprintf(__('Preserve post type of already existing article for `%s`', 'wp_all_import_plugin'), $articleData['post_title']));
1145
+ }
1146
  if ( ! $this->options['is_update_comment_status']){
1147
  $articleData['comment_status'] = $post_to_update->comment_status;
1148
  $logger and call_user_func($logger, sprintf(__('Preserve comment status of already existing article for `%s`', 'wp_all_import_plugin'), $articleData['post_title']));
1180
  wp_delete_attachments($articleData['ID'], true, 'files');
1181
  }
1182
  // handle obsolete attachments (i.e. delete or keep) according to import settings
1183
+ if ($this->options['update_all_data'] == 'yes' or ($this->options['update_all_data'] == 'no' and $this->options['is_update_images'] and $this->options['update_images_logic'] == "full_update")) {
1184
+ $logger and call_user_func($logger, sprintf(__('Deleting images for `%s`', 'wp_all_import_plugin'), $articleData['post_title']));
1185
+ if (!empty($images_bundle)) {
1186
+ foreach ($images_bundle as $slug => $bundle_data) {
1187
+ $option_slug = ($slug == 'pmxi_gallery_image') ? '' : $slug;
1188
+ if (count($images_bundle) > 1 && $slug == 'pmxi_gallery_image') {
1189
+ continue;
1190
+ }
1191
+ $do_not_remove_images = ($this->options[$option_slug . 'download_images'] == 'gallery' or $this->options[$option_slug . 'do_not_remove_images']) ? FALSE : TRUE;
1192
+ $missing_images = wp_delete_attachments($articleData['ID'], $do_not_remove_images, 'images');
1193
+ }
1194
+ }
1195
+ }
1196
  }
1197
  }
1198
  }
2485
  'import_id' => $this->id,
2486
  ));
2487
  if ( ! $postRecord->isEmpty() )
2488
+ {
2489
+ $is_unlink_missing_posts = apply_filters('wp_all_import_is_unlink_missing_posts', false, $this->id, $missingPostRecord['post_id']);
2490
+ if ( $is_unlink_missing_posts ){
2491
+ $postRecord->delete();
2492
+ }
2493
+ else {
2494
+ $postRecord->set(array(
2495
+ 'iteration' => $iteration
2496
+ ))->save();
2497
+ }
2498
+ }
2499
 
2500
  do_action('pmxi_missing_post', $missingPostRecord['post_id']);
2501
 
plugin.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP All Import
4
  Plugin URI: http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=plugins-page&utm_campaign=free+plugin
5
  Description: The most powerful solution for importing XML and CSV files to WordPress. Create Posts and Pages with content from any XML or CSV file. A paid upgrade to WP All Import Pro is available for support and additional features.
6
- Version: 3.3.8
7
  Author: Soflyy
8
  */
9
 
@@ -25,7 +25,7 @@ define('WP_ALL_IMPORT_ROOT_URL', rtrim(plugin_dir_url(__FILE__), '/'));
25
  */
26
  define('WP_ALL_IMPORT_PREFIX', 'pmxi_');
27
 
28
- define('PMXI_VERSION', '3.3.8');
29
 
30
  define('PMXI_EDITION', 'free');
31
 
@@ -1040,6 +1040,7 @@ final class PMXI_Plugin {
1040
  'is_update_categories' => 1,
1041
  'is_update_author' => 1,
1042
  'is_update_comment_status' => 1,
 
1043
  'update_categories_logic' => 'full_update',
1044
  'taxonomies_list' => array(),
1045
  'taxonomies_only_list' => array(),
3
  Plugin Name: WP All Import
4
  Plugin URI: http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=plugins-page&utm_campaign=free+plugin
5
  Description: The most powerful solution for importing XML and CSV files to WordPress. Create Posts and Pages with content from any XML or CSV file. A paid upgrade to WP All Import Pro is available for support and additional features.
6
+ Version: 3.3.9
7
  Author: Soflyy
8
  */
9
 
25
  */
26
  define('WP_ALL_IMPORT_PREFIX', 'pmxi_');
27
 
28
+ define('PMXI_VERSION', '3.3.9');
29
 
30
  define('PMXI_EDITION', 'free');
31
 
1040
  'is_update_categories' => 1,
1041
  'is_update_author' => 1,
1042
  'is_update_comment_status' => 1,
1043
+ 'is_update_post_type' => 1,
1044
  'update_categories_logic' => 'full_update',
1045
  'taxonomies_list' => array(),
1046
  'taxonomies_only_list' => array(),
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === Import any XML or CSV File to WordPress ===
2
  Contributors: soflyy, wpallimport
3
  Requires at least: 4.1
4
- Tested up to: 4.6.1
5
- Stable tag: 3.3.8
6
  Tags: wordpress csv import, wordpress xml import, xml, csv, datafeed, import, migrate, import csv to wordpress, import xml to wordpress, advanced xml import, advanced csv import, bulk csv import, bulk xml import, bulk data import, xml to custom post type, csv to custom post type, woocommerce csv import, woocommerce xml import, csv import, import csv, xml import, import xml, csv importer
7
 
8
  WP All Import is an extremely powerful importer that makes it easy to import any XML or CSV file to WordPress.
@@ -105,6 +105,14 @@ Does it work with special character encoding like Hebrew, Arabic, Chinese, etc?
105
 
106
  == Changelog ==
107
 
 
 
 
 
 
 
 
 
108
  = 3.3.8 =
109
  * improvement: 'Force Stream Reader' setting
110
  * improvement: new filter 'wp_all_import_auto_create_csv_headers'
1
  === Import any XML or CSV File to WordPress ===
2
  Contributors: soflyy, wpallimport
3
  Requires at least: 4.1
4
+ Tested up to: 4.7
5
+ Stable tag: 3.3.9
6
  Tags: wordpress csv import, wordpress xml import, xml, csv, datafeed, import, migrate, import csv to wordpress, import xml to wordpress, advanced xml import, advanced csv import, bulk csv import, bulk xml import, bulk data import, xml to custom post type, csv to custom post type, woocommerce csv import, woocommerce xml import, csv import, import csv, xml import, import xml, csv importer
7
 
8
  WP All Import is an extremely powerful importer that makes it easy to import any XML or CSV file to WordPress.
105
 
106
  == Changelog ==
107
 
108
+ = 3.3.9 =
109
+ * improvement: new re-import option 'is update post type'
110
+ * bug fix: hierarchy taxonomies preview
111
+ * bug fix: empty logs folder generation
112
+ * bug fix: 'Keep images currently in Media Library' option for add-ons
113
+ * bug fix: import bundles with gz files
114
+ * bug fix: custom functions for attachments
115
+
116
  = 3.3.8 =
117
  * improvement: 'Force Stream Reader' setting
118
  * improvement: new filter 'wp_all_import_auto_create_csv_headers'
static/css/admin.css CHANGED
@@ -616,6 +616,38 @@ p.upgrade_link {
616
  .wpallimport-plugin .wpallimport-import-orders-notice{
617
  display: none;
618
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
619
  /*--------------------------------------------------------------------------
620
  *
621
  * Helpers
@@ -1405,8 +1437,8 @@ p.upgrade_link {
1405
  }
1406
  .wpallimport-plugin #custom_type_selector .dd-option .dashicon-product:before,
1407
  .wpallimport-plugin #custom_type_selector .dd-selected .dashicon-product:before{
1408
- font-family: "dashicons";
1409
- content: "\f174";
1410
  color: #555;
1411
  margin-top: 0;
1412
  }
@@ -1431,6 +1463,12 @@ p.upgrade_link {
1431
  content: "\f110";
1432
  color: #555;
1433
  }
 
 
 
 
 
 
1434
  .wpallimport-plugin #custom_type_selector .dd-option:hover .dashicon:before,
1435
  .wpallimport-plugin #custom_type_selector .dd-option-selected .dashicon:before{
1436
  color: #555;
@@ -3161,6 +3199,10 @@ body.rtl.wpallimport-plugin .show_hints
3161
  .wpallimport-plugin .wpallimport-extra-text-left{
3162
  width: 36%;
3163
  }
 
 
 
 
3164
  .wpallimport-plugin .wpallimport-extra-text-right{
3165
  width: 37%;
3166
  }
@@ -3202,6 +3244,10 @@ body.rtl.wpallimport-plugin .show_hints
3202
  .wpallimport-plugin .wpallimport-extra-text-left{
3203
  width: 35%;
3204
  }
 
 
 
 
3205
  .wpallimport-plugin .wpallimport-extra-text-right{
3206
  width: 35%;
3207
  }
@@ -3264,6 +3310,10 @@ body.rtl.wpallimport-plugin .show_hints
3264
  .wpallimport-plugin .wpallimport-extra-text-left{
3265
  width: 33%;
3266
  }
 
 
 
 
3267
  .wpallimport-plugin .wpallimport-extra-text-right{
3268
  width: 34%;
3269
  }
@@ -3339,6 +3389,10 @@ body.rtl.wpallimport-plugin .show_hints
3339
  .wpallimport-plugin .wpallimport-extra-text-left{
3340
  width: 30%;
3341
  }
 
 
 
 
3342
  .wpallimport-plugin .wpallimport-extra-text-right{
3343
  width: 31%;
3344
  }
@@ -3435,6 +3489,10 @@ body.rtl.wpallimport-plugin .show_hints
3435
  .wpallimport-plugin .wpallimport-extra-text-left{
3436
  width: 29%;
3437
  }
 
 
 
 
3438
  .wpallimport-plugin .wpallimport-extra-text-right{
3439
  width: 30%;
3440
  }
616
  .wpallimport-plugin .wpallimport-import-orders-notice{
617
  display: none;
618
  }
619
+ .wpallimport-plugin .wpallimport-step-4 .wpallimport-upgrade-notice{
620
+ background-color: #FFB8B8;
621
+ border: 1px solid #FF8383;
622
+ color: #000;
623
+ display: none;
624
+ line-height: 40px;
625
+ margin: 30px auto 0 -4px;
626
+ padding: 15px;
627
+ text-align: center;
628
+ width: 560px;
629
+ }
630
+ .wpallimport-plugin .wpallimport-choose-file .wpallimport-upgrade-notice{
631
+ background-color: #FFB8B8;
632
+ border: 1px solid #FF8383;
633
+ color: #000;
634
+ display: none;
635
+ line-height: 40px;
636
+ margin: 30px auto 0 29.8%;
637
+ padding: 15px;
638
+ text-align: center;
639
+ width: 650px;
640
+ }
641
+ .wpallimport-plugin .wpallimport-upgrade-notice p{
642
+ color: #000 !important;
643
+ font-size: 1.3em !important;
644
+ margin-bottom: 0;
645
+ }
646
+ .wpallimport-plugin .wpallimport-upgrade-notice .upgrade_link{
647
+ color: #000 !important;
648
+ font-size: 1.3em !important;
649
+ text-decoration: underline;
650
+ }
651
  /*--------------------------------------------------------------------------
652
  *
653
  * Helpers
1437
  }
1438
  .wpallimport-plugin #custom_type_selector .dd-option .dashicon-product:before,
1439
  .wpallimport-plugin #custom_type_selector .dd-selected .dashicon-product:before{
1440
+ font-family: "WooCommerce";
1441
+ content: "\e006";
1442
  color: #555;
1443
  margin-top: 0;
1444
  }
1463
  content: "\f110";
1464
  color: #555;
1465
  }
1466
+ .wpallimport-plugin #custom_type_selector .dd-option .dashicon-taxonomies:before,
1467
+ .wpallimport-plugin #custom_type_selector .dd-selected .dashicon-taxonomies:before{
1468
+ font-family: "dashicons";
1469
+ content: "\f318";
1470
+ color: #555;
1471
+ }
1472
  .wpallimport-plugin #custom_type_selector .dd-option:hover .dashicon:before,
1473
  .wpallimport-plugin #custom_type_selector .dd-option-selected .dashicon:before{
1474
  color: #555;
3199
  .wpallimport-plugin .wpallimport-extra-text-left{
3200
  width: 36%;
3201
  }
3202
+ .wpallimport-plugin .wpallimport-choose-file .wpallimport-upgrade-notice{
3203
+ margin: 30px auto 0 28.4%;
3204
+ width: 650px;
3205
+ }
3206
  .wpallimport-plugin .wpallimport-extra-text-right{
3207
  width: 37%;
3208
  }
3244
  .wpallimport-plugin .wpallimport-extra-text-left{
3245
  width: 35%;
3246
  }
3247
+ .wpallimport-plugin .wpallimport-choose-file .wpallimport-upgrade-notice{
3248
+ margin: 30px auto 0 26.7%;
3249
+ width: 666px;
3250
+ }
3251
  .wpallimport-plugin .wpallimport-extra-text-right{
3252
  width: 35%;
3253
  }
3310
  .wpallimport-plugin .wpallimport-extra-text-left{
3311
  width: 33%;
3312
  }
3313
+ .wpallimport-plugin .wpallimport-choose-file .wpallimport-upgrade-notice{
3314
+ margin: 30px auto 0 24.7%;
3315
+ width: 625px;
3316
+ }
3317
  .wpallimport-plugin .wpallimport-extra-text-right{
3318
  width: 34%;
3319
  }
3389
  .wpallimport-plugin .wpallimport-extra-text-left{
3390
  width: 30%;
3391
  }
3392
+ .wpallimport-plugin .wpallimport-choose-file .wpallimport-upgrade-notice{
3393
+ margin: 30px auto 0 22.7%;
3394
+ width: 553px;
3395
+ }
3396
  .wpallimport-plugin .wpallimport-extra-text-right{
3397
  width: 31%;
3398
  }
3489
  .wpallimport-plugin .wpallimport-extra-text-left{
3490
  width: 29%;
3491
  }
3492
+ .wpallimport-plugin .wpallimport-choose-file .wpallimport-upgrade-notice{
3493
+ margin: 30px auto 0 22%;
3494
+ width: 530px;
3495
+ }
3496
  .wpallimport-plugin .wpallimport-extra-text-right{
3497
  width: 30%;
3498
  }
static/js/admin.js CHANGED
@@ -209,12 +209,27 @@
209
  $wrap.css({'height': formHeight + 'px'});
210
  },
211
  onSelected: function(selectedData){
212
- if (fixWrapHeight)
213
- $wrap.css({'height': formHeight + 'px'});
214
- else
 
215
  fixWrapHeight = true;
216
- $('input[name=custom_type]').val(selectedData.selectedData.value);
217
- $('#custom_type_selector').find('.dd-selected').css({'color':'#555'});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  }
219
  });
220
 
@@ -338,9 +353,17 @@
338
 
339
  $('#custom_type_selector').find('.dd-selected').css({'color':'#555'});
340
 
 
 
341
  $('input[name=custom_type]').val(selectedData.selectedData.value);
342
 
343
- if (selectedData.selectedData.value == 'shop_order' && $('.wpallimport-import-orders-notice').attr('rel') == 'free')
 
 
 
 
 
 
344
  {
345
  $('.wpallimport-choose-file').find('.wpallimport-submit-buttons').hide();
346
  $('.wpallimport-import-orders-notice').show();
209
  $wrap.css({'height': formHeight + 'px'});
210
  },
211
  onSelected: function(selectedData){
212
+ if (fixWrapHeight){
213
+ $wrap.css({'height': formHeight + 'px'});
214
+ }
215
+ else{
216
  fixWrapHeight = true;
217
+ }
218
+
219
+ $('.wpallimport-upgrade-notice').hide();
220
+
221
+ $('input[name=custom_type]').val(selectedData.selectedData.value);
222
+ $('#custom_type_selector').find('.dd-selected').css({'color':'#555'});
223
+
224
+ var is_import_denied = $('.wpallimport-upgrade-notice[rel='+ selectedData.selectedData.value +']').length;
225
+
226
+ if (is_import_denied){
227
+ $('.wpallimport-upgrade-notice[rel='+ selectedData.selectedData.value +']').slideDown();
228
+ $('.wpallimport-submit-buttons').hide();
229
+ }
230
+ else{
231
+ $('.wpallimport-submit-buttons').slideDown();
232
+ }
233
  }
234
  });
235
 
353
 
354
  $('#custom_type_selector').find('.dd-selected').css({'color':'#555'});
355
 
356
+ $('.wpallimport-upgrade-notice').hide();
357
+
358
  $('input[name=custom_type]').val(selectedData.selectedData.value);
359
 
360
+ var is_import_denied = $('.wpallimport-upgrade-notice[rel='+ selectedData.selectedData.value +']').length;
361
+
362
+ if (is_import_denied){
363
+ $('.wpallimport-upgrade-notice[rel='+ selectedData.selectedData.value +']').slideDown();
364
+ }
365
+
366
+ if (is_import_denied)
367
  {
368
  $('.wpallimport-choose-file').find('.wpallimport-submit-buttons').hide();
369
  $('.wpallimport-import-orders-notice').show();
views/admin/history/index.php CHANGED
@@ -183,7 +183,7 @@ $columns = array(
183
  <?php
184
  if ( ! in_array($item['type'], array('trigger'))){
185
  $wp_uploads = wp_upload_dir();
186
- $log_file = wp_all_import_secure_file( $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::LOGS_DIRECTORY, $item['id'] ) . DIRECTORY_SEPARATOR . $item['id'] . '.html';
187
  if (file_exists($log_file)){
188
  ?>
189
  <a href="<?php echo add_query_arg(array('id' => $import->id, 'action' => 'log', 'history_id' => $item['id'], '_wpnonce' => wp_create_nonce( '_wpnonce-download_log' )), $this->baseUrl); ?>"><?php _e('Download Log', 'wp_all_import_plugin'); ?></a>
183
  <?php
184
  if ( ! in_array($item['type'], array('trigger'))){
185
  $wp_uploads = wp_upload_dir();
186
+ $log_file = wp_all_import_secure_file( $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::LOGS_DIRECTORY, $item['id'], false, false ) . DIRECTORY_SEPARATOR . $item['id'] . '.html';
187
  if (file_exists($log_file)){
188
  ?>
189
  <a href="<?php echo add_query_arg(array('id' => $import->id, 'action' => 'log', 'history_id' => $item['id'], '_wpnonce' => wp_create_nonce( '_wpnonce-download_log' )), $this->baseUrl); ?>"><?php _e('Download Log', 'wp_all_import_plugin'); ?></a>
views/admin/import/confirm.php CHANGED
@@ -218,6 +218,9 @@
218
  <?php if ( $post['is_update_parent']): ?>
219
  <li> <?php _e('parent post', 'wp_all_import_plugin'); ?></li>
220
  <?php endif; ?>
 
 
 
221
  <?php if ( $post['is_update_attachments']): ?>
222
  <li> <?php _e('attachments', 'wp_all_import_plugin'); ?></li>
223
  <?php endif; ?>
218
  <?php if ( $post['is_update_parent']): ?>
219
  <li> <?php _e('parent post', 'wp_all_import_plugin'); ?></li>
220
  <?php endif; ?>
221
+ <?php if ( $post['is_update_post_type']): ?>
222
+ <li> <?php _e('post type', 'wp_all_import_plugin'); ?></li>
223
+ <?php endif; ?>
224
  <?php if ( $post['is_update_attachments']): ?>
225
  <li> <?php _e('attachments', 'wp_all_import_plugin'); ?></li>
226
  <?php endif; ?>
views/admin/import/index.php CHANGED
@@ -180,6 +180,37 @@ $l10n = array(
180
  }
181
  $custom_types = apply_filters( 'pmxi_custom_types', $custom_types );
182
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  $hidden_post_types = get_post_types(array('_builtin' => false, 'show_ui' => false), 'objects');
184
  foreach ($hidden_post_types as $key => $ct) {
185
  if (in_array($key, array('attachment', 'revision', 'nav_menu_item'))) unset($hidden_post_types[$key]);
@@ -199,15 +230,15 @@ $l10n = array(
199
  </div>
200
  </div>
201
  <select name="custom_type_selector" id="custom_type_selector" class="wpallimport-post-types">
202
- <?php if ( ! empty($custom_types)): $unknown_cpt = array(); ?>
203
- <?php foreach ($custom_types as $key => $ct) :?>
204
  <?php
205
  $image_src = 'dashicon-cpt';
206
 
207
  $cpt = $key;
208
- $cpt_label = $ct->labels->name;
209
-
210
- if ( in_array($cpt, array('post', 'page', 'product', 'shop_order', 'shop_coupon') ) )
211
  {
212
  $image_src = 'dashicon-' . $cpt;
213
  }
@@ -219,9 +250,6 @@ $l10n = array(
219
  ?>
220
  <option value="<?php echo $cpt; ?>" data-imagesrc="dashicon <?php echo $image_src; ?>" <?php if ( $cpt == $post['custom_type'] ):?>selected="selected"<?php endif; ?>><?php echo $cpt_label; ?></option>
221
  <?php endforeach; ?>
222
- <?php if (class_exists('PMUI_Plugin')): ?>
223
- <option value="import_users" data-imagesrc="dashicon dashicon-import_users" <?php if ( 'import_users' == $post['custom_type'] ):?>selected="selected"<?php endif; ?>><?php _e('Users', 'wp_all_import_plugin'); ?></option>
224
- <?php endif; ?>
225
  <?php if ( ! empty($unknown_cpt)): ?>
226
  <?php foreach ($unknown_cpt as $key => $ct):?>
227
  <?php
@@ -243,7 +271,43 @@ $l10n = array(
243
  <option value="<?php echo $key; ?>" data-imagesrc="dashicon <?php echo $image_src; ?>"><?php echo $cpt->labels->name; ?></option>
244
  <?php endforeach; ?>
245
  <?php endif; ?>
246
- </select>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  </div>
248
  <div class="clear wpallimport-extra-text-below">
249
  <!--div class="wpallimport-existing-records">
@@ -281,13 +345,7 @@ $l10n = array(
281
  </div>
282
  </div>
283
  <a class="button button-primary button-hero wpallimport-large-button wpallimport-notify-read-more" href="http://www.wpallimport.com/documentation/troubleshooting/problems-with-import-files/#invalid" target="_blank"><?php _e('Read More', 'wp_all_import_plugin');?></a>
284
- </div>
285
-
286
- <div class="wpallimport-free-edition-notice wpallimport-import-orders-notice" rel="<?php echo (defined('PMWI_EDITION') ? PMWI_EDITION : 'free'); ?>" style="text-align:center; margin-top:20px; margin-bottom: 40px; display: none;">
287
- <a href="https://www.wpallimport.com/checkout/?edd_action=purchase_collection&taxonomy=download_category&terms=14&utm_source=free-plugin&utm_medium=in-plugin&utm_campaign=custom-fields" target="_blank" class="upgrade_link"><?php _e('Upgrade to the Pro edition of WooCommerce Add-On to Import WooCommerce Orders', 'wp_all_import_plugin');?></a>
288
- <p><?php _e('If you already own it, remove the free edition and install the Pro edition.', 'wp_all_import_plugin'); ?></p>
289
- </div>
290
-
291
  <p class="wpallimport-submit-buttons">
292
  <input type="hidden" name="custom_type" value="<?php echo $post['custom_type'];?>">
293
  <input type="hidden" name="is_submitted" value="1" />
180
  }
181
  $custom_types = apply_filters( 'pmxi_custom_types', $custom_types );
182
 
183
+ $sorted_cpt = array();
184
+ foreach ($custom_types as $key => $cpt){
185
+
186
+ $sorted_cpt[$key] = $cpt;
187
+
188
+ // Put users & comments & taxonomies after Pages
189
+ if ( ! empty($custom_types['page']) && $key == 'page' || empty($custom_types['page']) && $key == 'post' ){
190
+
191
+ $sorted_cpt['taxonomies'] = new stdClass();
192
+ $sorted_cpt['taxonomies']->labels = new stdClass();
193
+ $sorted_cpt['taxonomies']->labels->name = __('Taxonomies','wp_all_export_plugin');
194
+
195
+ $sorted_cpt['import_users'] = new stdClass();
196
+ $sorted_cpt['import_users']->labels = new stdClass();
197
+ $sorted_cpt['import_users']->labels->name = __('Users','wp_all_export_plugin');
198
+ break;
199
+ }
200
+ }
201
+ $order = array('shop_order', 'shop_coupon', 'shop_customer', 'product');
202
+ foreach ($order as $cpt){
203
+ if (!empty($custom_types[$cpt])) $sorted_cpt[$cpt] = $custom_types[$cpt];
204
+ }
205
+
206
+ uasort($custom_types, "wp_all_import_cmp_custom_types");
207
+
208
+ foreach ($custom_types as $key => $cpt) {
209
+ if (empty($sorted_cpt[$key])){
210
+ $sorted_cpt[$key] = $cpt;
211
+ }
212
+ }
213
+
214
  $hidden_post_types = get_post_types(array('_builtin' => false, 'show_ui' => false), 'objects');
215
  foreach ($hidden_post_types as $key => $ct) {
216
  if (in_array($key, array('attachment', 'revision', 'nav_menu_item'))) unset($hidden_post_types[$key]);
230
  </div>
231
  </div>
232
  <select name="custom_type_selector" id="custom_type_selector" class="wpallimport-post-types">
233
+ <?php if ( ! empty($sorted_cpt)): $unknown_cpt = array(); ?>
234
+ <?php foreach ($sorted_cpt as $key => $ct) :?>
235
  <?php
236
  $image_src = 'dashicon-cpt';
237
 
238
  $cpt = $key;
239
+ $cpt_label = $ct->labels->name;
240
+
241
+ if ( in_array($key, array('post', 'page', 'product', 'import_users', 'shop_order', 'shop_coupon', 'shop_customer', 'users', 'comments', 'taxonomies') ) )
242
  {
243
  $image_src = 'dashicon-' . $cpt;
244
  }
250
  ?>
251
  <option value="<?php echo $cpt; ?>" data-imagesrc="dashicon <?php echo $image_src; ?>" <?php if ( $cpt == $post['custom_type'] ):?>selected="selected"<?php endif; ?>><?php echo $cpt_label; ?></option>
252
  <?php endforeach; ?>
 
 
 
253
  <?php if ( ! empty($unknown_cpt)): ?>
254
  <?php foreach ($unknown_cpt as $key => $ct):?>
255
  <?php
271
  <option value="<?php echo $key; ?>" data-imagesrc="dashicon <?php echo $image_src; ?>"><?php echo $cpt->labels->name; ?></option>
272
  <?php endforeach; ?>
273
  <?php endif; ?>
274
+ </select>
275
+
276
+ <?php if ( ! class_exists('PMUI_Plugin') ): ?>
277
+ <div class="wpallimport-upgrade-notice" rel="import_users">
278
+ <p><?php _e('The User Import Add-On is Required to Import Users', 'wp_all_import_plugin'); ?></p>
279
+ <a href="http://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=1921&edd_options%5Bprice_id%5D=1" target="_blank" class="upgrade_link"><?php _e('Purchase the User Import Add-On', 'wp_all_import_plugin');?></a>
280
+ </div>
281
+ <?php endif; ?>
282
+ <?php if ( class_exists('WooCommerce') && ! class_exists('PMWI_Plugin') ): ?>
283
+ <div class="wpallimport-upgrade-notice" rel="product">
284
+ <p><?php _e('The WooCommerce Add-On is Required to Import Products', 'wp_all_import_plugin'); ?></p>
285
+ <a href="http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_campaign=wooco-products&utm_medium=in-plugin" target="_blank" class="upgrade_link"><?php _e('Get the WooCommerce Add-On', 'wp_all_import_plugin');?></a>
286
+ </div>
287
+ <?php endif; ?>
288
+ <?php if ( class_exists('WooCommerce') && ( ! class_exists('PMWI_Plugin') || class_exists('PMWI_Plugin') && PMWI_EDITION == 'free') ): ?>
289
+ <div class="wpallimport-upgrade-notice" rel="shop_order">
290
+ <?php if (class_exists('PMWI_Plugin') && PMWI_EDITION == 'free'): ?>
291
+ <p><?php _e('The Pro version of the WooCommerce Add-On is required to Import Orders, but you have the free version installed.', 'wp_all_import_plugin'); ?></p>
292
+ <?php else: ?>
293
+ <p><?php _e('The WooCommerce Add-On Pro is Required to Import Orders', 'wp_all_import_plugin'); ?></p>
294
+ <?php endif; ?>
295
+ <a href="http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_campaign=wooco-orders&utm_medium=in-plugin" target="_blank" class="upgrade_link"><?php _e('Purchase the WooCommerce Add-On Pro', 'wp_all_import_plugin');?></a>
296
+ </div>
297
+ <div class="wpallimport-upgrade-notice" rel="shop_coupon">
298
+ <?php if (class_exists('PMWI_Plugin') && PMWI_EDITION == 'free'): ?>
299
+ <p><?php _e('The Pro version of the WooCommerce Add-On is required to Import Coupons, but you have the free version installed.', 'wp_all_import_plugin'); ?></p>
300
+ <?php else: ?>
301
+ <p><?php _e('The WooCommerce Add-On Pro is Required to Import Coupons', 'wp_all_import_plugin'); ?></p>
302
+ <?php endif; ?>
303
+ <a href="http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_campaign=wooco-coupons&utm_medium=in-plugin" target="_blank" class="upgrade_link"><?php _e('Purchase the WooCommerce Add-On Pro', 'wp_all_import_plugin');?></a>
304
+ </div>
305
+ <?php endif; ?>
306
+ <div class="wpallimport-upgrade-notice" rel="taxonomies">
307
+ <p><?php _e('WP All Import Pro is Required to Import Taxonomies', 'wp_all_import_plugin'); ?></p>
308
+ <a href="http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_campaign=taxonomies&utm_medium=in-plugin" target="_blank" class="upgrade_link"><?php _e('Purchase WP All Import Pro', 'wp_all_import_plugin');?></a>
309
+ </div>
310
+
311
  </div>
312
  <div class="clear wpallimport-extra-text-below">
313
  <!--div class="wpallimport-existing-records">
345
  </div>
346
  </div>
347
  <a class="button button-primary button-hero wpallimport-large-button wpallimport-notify-read-more" href="http://www.wpallimport.com/documentation/troubleshooting/problems-with-import-files/#invalid" target="_blank"><?php _e('Read More', 'wp_all_import_plugin');?></a>
348
+ </div>
 
 
 
 
 
 
349
  <p class="wpallimport-submit-buttons">
350
  <input type="hidden" name="custom_type" value="<?php echo $post['custom_type'];?>">
351
  <input type="hidden" name="is_submitted" value="1" />
views/admin/import/options/_reimport_options.php CHANGED
@@ -114,6 +114,11 @@
114
  <input type="checkbox" id="is_update_parent" name="is_update_parent" value="1" <?php echo $post['is_update_parent'] ? 'checked="checked"': '' ?> />
115
  <label for="is_update_parent"><?php _e('Parent post', 'wp_all_import_plugin') ?></label>
116
  </div>
 
 
 
 
 
117
  <div class="input">
118
  <input type="hidden" name="is_update_comment_status" value="0" />
119
  <input type="checkbox" id="is_update_comment_status" name="is_update_comment_status" value="1" <?php echo $post['is_update_comment_status'] ? 'checked="checked"': '' ?> />
114
  <input type="checkbox" id="is_update_parent" name="is_update_parent" value="1" <?php echo $post['is_update_parent'] ? 'checked="checked"': '' ?> />
115
  <label for="is_update_parent"><?php _e('Parent post', 'wp_all_import_plugin') ?></label>
116
  </div>
117
+ <div class="input">
118
+ <input type="hidden" name="is_update_post_type" value="0" />
119
+ <input type="checkbox" id="is_update_post_type" name="is_update_post_type" value="1" <?php echo $post['is_update_post_type'] ? 'checked="checked"': '' ?> />
120
+ <label for="is_update_post_type"><?php _e('Post type', 'wp_all_import_plugin') ?></label>
121
+ </div>
122
  <div class="input">
123
  <input type="hidden" name="is_update_comment_status" value="0" />
124
  <input type="checkbox" id="is_update_comment_status" name="is_update_comment_status" value="1" <?php echo $post['is_update_comment_status'] ? 'checked="checked"': '' ?> />
views/admin/import/options/_settings_template.php CHANGED
@@ -53,6 +53,32 @@
53
  }
54
  $custom_types = apply_filters( 'pmxi_custom_types', $custom_types );
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  $hidden_post_types = get_post_types(array('_builtin' => false, 'show_ui' => false), 'objects');
57
  foreach ($hidden_post_types as $key => $ct) {
58
  if (in_array($key, array('attachment', 'revision', 'nav_menu_item'))) unset($hidden_post_types[$key]);
@@ -62,15 +88,15 @@
62
  ?>
63
  <div class="wpallimport-change-custom-type">
64
  <select name="custom_type_selector" id="custom_type_selector" class="wpallimport-post-types">
65
- <?php if ( ! empty($custom_types)): $unknown_cpt = array(); ?>
66
- <?php foreach ($custom_types as $key => $ct) :?>
67
  <?php
68
  $image_src = 'dashicon-cpt';
69
 
70
  $cpt = $key;
71
- $cpt_label = $ct->labels->name;
72
 
73
- if ( in_array($cpt, array('post', 'page', 'product', 'shop_order', 'shop_coupon') ) )
74
  {
75
  $image_src = 'dashicon-' . $cpt;
76
  }
@@ -82,9 +108,6 @@
82
  ?>
83
  <option value="<?php echo $cpt; ?>" data-imagesrc="dashicon <?php echo $image_src; ?>" <?php if ( $cpt == $post['custom_type'] ) echo 'selected="selected"';?>><?php echo $cpt_label; ?></option>
84
  <?php endforeach; ?>
85
- <?php if (class_exists('PMUI_Plugin')): ?>
86
- <option value="import_users" data-imagesrc="dashicon dashicon-import_users" <?php if ( 'import_users' == $post['custom_type'] ):?>selected="selected"<?php endif; ?>><?php _e('Users', 'wp_all_import_plugin'); ?></option>
87
- <?php endif; ?>
88
  <?php if ( ! empty($unknown_cpt)): ?>
89
  <?php foreach ($unknown_cpt as $key => $ct):?>
90
  <?php
@@ -106,6 +129,42 @@
106
  <?php endforeach; ?>
107
  <?php endif; ?>
108
  </select>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  </div>
110
 
111
  <h4><?php _e('XPath', 'wp_all_import_plugin'); ?></h4>
53
  }
54
  $custom_types = apply_filters( 'pmxi_custom_types', $custom_types );
55
 
56
+ $sorted_cpt = array();
57
+ foreach ($custom_types as $key => $cpt){
58
+
59
+ $sorted_cpt[$key] = $cpt;
60
+
61
+ // Put users & comments & taxonomies after Pages
62
+ if ( ! empty($custom_types['page']) && $key == 'page' || empty($custom_types['page']) && $key == 'post' ){
63
+ $sorted_cpt['import_users'] = new stdClass();
64
+ $sorted_cpt['import_users']->labels = new stdClass();
65
+ $sorted_cpt['import_users']->labels->name = __('Users','wp_all_export_plugin');
66
+ break;
67
+ }
68
+ }
69
+ $order = array('shop_order', 'shop_coupon', 'shop_customer', 'product');
70
+ foreach ($order as $cpt){
71
+ if (!empty($custom_types[$cpt])) $sorted_cpt[$cpt] = $custom_types[$cpt];
72
+ }
73
+
74
+ uasort($custom_types, "wp_all_import_cmp_custom_types");
75
+
76
+ foreach ($custom_types as $key => $cpt) {
77
+ if (empty($sorted_cpt[$key])){
78
+ $sorted_cpt[$key] = $cpt;
79
+ }
80
+ }
81
+
82
  $hidden_post_types = get_post_types(array('_builtin' => false, 'show_ui' => false), 'objects');
83
  foreach ($hidden_post_types as $key => $ct) {
84
  if (in_array($key, array('attachment', 'revision', 'nav_menu_item'))) unset($hidden_post_types[$key]);
88
  ?>
89
  <div class="wpallimport-change-custom-type">
90
  <select name="custom_type_selector" id="custom_type_selector" class="wpallimport-post-types">
91
+ <?php if ( ! empty($sorted_cpt)): $unknown_cpt = array(); ?>
92
+ <?php foreach ($sorted_cpt as $key => $ct) :?>
93
  <?php
94
  $image_src = 'dashicon-cpt';
95
 
96
  $cpt = $key;
97
+ $cpt_label = $ct->labels->name;
98
 
99
+ if ( in_array($cpt, array('post', 'page', 'product', 'import_users', 'shop_order', 'shop_coupon', 'shop_customer', 'users', 'comments', 'taxonomies') ) )
100
  {
101
  $image_src = 'dashicon-' . $cpt;
102
  }
108
  ?>
109
  <option value="<?php echo $cpt; ?>" data-imagesrc="dashicon <?php echo $image_src; ?>" <?php if ( $cpt == $post['custom_type'] ) echo 'selected="selected"';?>><?php echo $cpt_label; ?></option>
110
  <?php endforeach; ?>
 
 
 
111
  <?php if ( ! empty($unknown_cpt)): ?>
112
  <?php foreach ($unknown_cpt as $key => $ct):?>
113
  <?php
129
  <?php endforeach; ?>
130
  <?php endif; ?>
131
  </select>
132
+
133
+ <?php if ( ! class_exists('PMUI_Plugin') ): ?>
134
+ <div class="wpallimport-upgrade-notice" rel="import_users">
135
+ <p><?php _e('The User Import Add-On is Required to Import Users', 'wp_all_import_plugin'); ?></p>
136
+ <a href="http://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=1921&edd_options%5Bprice_id%5D=1" target="_blank" class="upgrade_link"><?php _e('Purchase the User Import Add-On', 'wp_all_import_plugin');?></a>
137
+ </div>
138
+ <?php endif; ?>
139
+ <?php if ( class_exists('WooCommerce') && ! class_exists('PMWI_Plugin') ): ?>
140
+ <div class="wpallimport-upgrade-notice" rel="product">
141
+ <p><?php _e('The WooCommerce Add-On is Required to Import Products', 'wp_all_import_plugin'); ?></p>
142
+ <a href="http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_campaign=wooco-products&utm_medium=in-plugin" target="_blank" class="upgrade_link"><?php _e('Get the WooCommerce Add-On', 'wp_all_import_plugin');?></a>
143
+ </div>
144
+ <?php endif; ?>
145
+ <?php if ( class_exists('WooCommerce') && ( ! class_exists('PMWI_Plugin') || class_exists('PMWI_Plugin') && PMWI_EDITION == 'free') ): ?>
146
+ <div class="wpallimport-upgrade-notice" rel="shop_order">
147
+ <?php if (class_exists('PMWI_Plugin') && PMWI_EDITION == 'free'): ?>
148
+ <p><?php _e('The Pro version of the WooCommerce Add-On is required to Import Orders, but you have the free version installed.', 'wp_all_import_plugin'); ?></p>
149
+ <?php else: ?>
150
+ <p><?php _e('The WooCommerce Add-On Pro is Required to Import Orders', 'wp_all_import_plugin'); ?></p>
151
+ <?php endif; ?>
152
+ <a href="http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_campaign=wooco-orders&utm_medium=in-plugin" target="_blank" class="upgrade_link"><?php _e('Purchase the WooCommerce Add-On Pro', 'wp_all_import_plugin');?></a>
153
+ </div>
154
+ <div class="wpallimport-upgrade-notice" rel="shop_coupon">
155
+ <?php if (class_exists('PMWI_Plugin') && PMWI_EDITION == 'free'): ?>
156
+ <p><?php _e('The Pro version of the WooCommerce Add-On is required to Import Coupons, but you have the free version installed.', 'wp_all_import_plugin'); ?></p>
157
+ <?php else: ?>
158
+ <p><?php _e('The WooCommerce Add-On Pro is Required to Import Coupons', 'wp_all_import_plugin'); ?></p>
159
+ <?php endif; ?>
160
+ <a href="http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_campaign=wooco-coupons&utm_medium=in-plugin" target="_blank" class="upgrade_link"><?php _e('Purchase the WooCommerce Add-On Pro', 'wp_all_import_plugin');?></a>
161
+ </div>
162
+ <?php endif; ?>
163
+ <div class="wpallimport-upgrade-notice" rel="taxonomies">
164
+ <p><?php _e('WP All Import Pro is Required to Import Taxonomies', 'wp_all_import_plugin'); ?></p>
165
+ <a href="http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_campaign=taxonomies&utm_medium=in-plugin" target="_blank" class="upgrade_link"><?php _e('Purchase WP All Import Pro', 'wp_all_import_plugin');?></a>
166
+ </div>
167
+
168
  </div>
169
 
170
  <h4><?php _e('XPath', 'wp_all_import_plugin'); ?></h4>
views/admin/import/preview_taxonomies.php CHANGED
@@ -24,6 +24,19 @@
24
  <?php
25
  if (!empty($terms_arr) and is_array($terms_arr)){
26
  foreach ($terms_arr as $terms) {
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  $terms_a = ( ! empty($post['tax_hierarchical_delim'][$ctx])) ? explode($post['tax_hierarchical_delim'][$ctx], $terms) : explode(',', $terms);
29
 
24
  <?php
25
  if (!empty($terms_arr) and is_array($terms_arr)){
26
  foreach ($terms_arr as $terms) {
27
+
28
+ // Apply mapping before splitting via separator symbol
29
+ if (! empty($post['tax_enable_mapping'][$ctx]) and !empty($post['tax_logic_mapping'][$ctx])){
30
+ $mapping_rules = json_decode($post['tax_mapping'][$ctx], true);
31
+ if ( ! empty( $mapping_rules) ){
32
+ foreach ($mapping_rules as $rule) {
33
+ if ( ! empty($rule[trim($terms)])){
34
+ $terms = trim($rule[trim($terms)]);
35
+ break;
36
+ }
37
+ }
38
+ }
39
+ }
40
 
41
  $terms_a = ( ! empty($post['tax_hierarchical_delim'][$ctx])) ? explode($post['tax_hierarchical_delim'][$ctx], $terms) : explode(',', $terms);
42