Table Maker - Version 1.3

Version Description

  • Added export/import of table and some fixes
Download this release

Release Info

Developer wpsoul
Plugin Icon 128x128 Table Maker
Version 1.3
Comparing to
See all releases

Code changes from version 1.2 to 1.3

css/style.css CHANGED
@@ -1 +1 @@
1
- @font-face { font-family: 'wpsm-icons'; src: url('../font/wpsm-icons.eot?-jgkfsj'); src: url('../font/wpsm-icons.eot?#iefix-jgkfsj') format('embedded-opentype'), url('../font/wpsm-icons.woff?-jgkfsj') format('woff'), url('../font/wpsm-icons.ttf?-jgkfsj') format('truetype'), url('../font/wpsm-icons.svg?-jgkfsj#wpsm-icons') format('svg'); font-weight: normal; font-style: normal; }
2
- webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
3
 
 
4
- webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
5
 
 
 
1
 
2
+ @font-face { font-family: 'wpsm-icons'; src: url('../font/wpsm-icons.eot?-jgkfsj'); src: url('../font/wpsm-icons.eot?#iefix-jgkfsj') format('embedded-opentype'), url('../font/wpsm-icons.woff?-jgkfsj') format('woff'), url('../font/wpsm-icons.ttf?-jgkfsj') format('truetype'), url('../font/wpsm-icons.svg?-jgkfsj#wpsm-icons') format('svg'); font-weight: normal; font-style: normal; }
 
3
 
inc/class-wpsm-table-maker.php CHANGED
@@ -41,6 +41,7 @@ class WPSM_Table_Maker
41
  private function load_dependencies(){
42
  require_once 'class-wpsm-list-table.php';
43
  require_once 'class-wpsm-db-table.php';
 
44
  }
45
 
46
  public function add_menu_items() {
@@ -225,12 +226,24 @@ class WPSM_Table_Maker
225
  submit_button( __('Save Changes', 'wpsm-plugin'), 'primary', 'wpsm-save-changes', false );
226
  echo ' ';
227
  submit_button( __('Dublicate Table', 'wpsm-plugin'), 'primary', 'wpsm-create-table', false );
 
 
228
  echo '</p>';
229
  } else {
230
  submit_button( __('Create Table', 'wpsm-plugin'), 'primary', 'wpsm-create-table', true );
231
  }
232
  ?>
 
 
 
 
 
 
 
 
 
233
  </form>
 
234
 
235
  <div id="wpsm-comptable-resize-dialog" class="wpsm-dialog" title="<?php _e('Change Table Size', 'wpsm-tableplugin') ?>">
236
  <div class="wpsm-dialog-error"></div>
@@ -314,6 +327,30 @@ class WPSM_Table_Maker
314
  $sendback = add_query_arg( array( 'page' => $_GET['page'], 'deleted' => $result ), '' );
315
  wp_redirect($sendback);
316
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  }
318
 
319
  public function admin_notices(){
41
  private function load_dependencies(){
42
  require_once 'class-wpsm-list-table.php';
43
  require_once 'class-wpsm-db-table.php';
44
+ require_once 'class-wpsm-table-xml.php';
45
  }
46
 
47
  public function add_menu_items() {
226
  submit_button( __('Save Changes', 'wpsm-plugin'), 'primary', 'wpsm-save-changes', false );
227
  echo ' ';
228
  submit_button( __('Dublicate Table', 'wpsm-plugin'), 'primary', 'wpsm-create-table', false );
229
+ echo ' ';
230
+ submit_button( __('Export XML', 'wpsm-plugin'), 'primary', 'wpsm-export-table', false );
231
  echo '</p>';
232
  } else {
233
  submit_button( __('Create Table', 'wpsm-plugin'), 'primary', 'wpsm-create-table', true );
234
  }
235
  ?>
236
+ </form>
237
+
238
+ <?php if(!$table) : ?>
239
+ <form enctype="multipart/form-data" method="POST">
240
+ <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
241
+ <p class="submit">
242
+ <input name="upload_xml" type="file" />
243
+ <?php submit_button( __('Import XML', 'wpsm-plugin'), 'primary', 'wpsm-import-table', false ); ?>
244
+ </p>
245
  </form>
246
+ <?php endif; ?>
247
 
248
  <div id="wpsm-comptable-resize-dialog" class="wpsm-dialog" title="<?php _e('Change Table Size', 'wpsm-tableplugin') ?>">
249
  <div class="wpsm-dialog-error"></div>
327
  $sendback = add_query_arg( array( 'page' => $_GET['page'], 'deleted' => $result ), '' );
328
  wp_redirect($sendback);
329
  }
330
+
331
+ if(isset($_POST['wpsm-export-table'])) {
332
+ $result = $this->db->get( $_GET['table'] );
333
+ $converter = new Array_XML();
334
+ $xmlStr = $converter->convert($result);
335
+ header( 'Content-Description: File Transfer' );
336
+ header( 'Content-Disposition: attachment; filename=' . $_POST['table_name'] . '.xml' );
337
+ header('Content-Length: ' . strlen($xmlStr));
338
+ echo $xmlStr;
339
+ }
340
+
341
+ If(isset($_POST['wpsm-import-table'])) {
342
+ if(isset($_FILES['upload_xml']) && $_FILES['upload_xml']['type'] = 'text/xml') {
343
+ $xml = simplexml_load_file($_FILES['upload_xml']['tmp_name']);
344
+ $array = xml2array($xml);
345
+ } else {
346
+ exit('Can`t open file: ' . $_FILES['userfile']['name'] . '. Error: '. $_FILES['upload_xml']['error'] .'.');
347
+ }
348
+ $result = $this->db->add($array['name'], $array['rows'], $array['cols'], $array['subs'], $array['color'], $array['responsive'], $array['tvalues'] );
349
+ if($result){
350
+ $sendback = add_query_arg( array( 'page' => $_GET['page'], 'action' => 'edit', 'table' => $result, 'added' => true ), '' );
351
+ wp_redirect($sendback);
352
+ }
353
+ }
354
  }
355
 
356
  public function admin_notices(){
inc/class-wpsm-table-xml.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'WPINC' ) ) {
4
+ die;
5
+ }
6
+
7
+ class Array_XML {
8
+
9
+ private $writer;
10
+ private $version = '1.0';
11
+ private $encoding = 'UTF-8';
12
+ private $rootName = 'wpsm';
13
+
14
+ function __construct() {
15
+ $this->writer = new XMLWriter();
16
+ }
17
+
18
+ public function convert($data) {
19
+ $this->writer->openMemory();
20
+ $this->writer->startDocument($this->version, $this->encoding);
21
+ $this->writer->startElement($this->rootName);
22
+ if (is_array($data)) {
23
+ $this->getXML($data);
24
+ }
25
+ $this->writer->endElement();
26
+ return $this->writer->outputMemory();
27
+ }
28
+
29
+ public function setVersion($version) {
30
+ $this->version = $version;
31
+ }
32
+
33
+ public function setEncoding($encoding) {
34
+ $this->encoding = $encoding;
35
+ }
36
+
37
+ public function setRootName($rootName) {
38
+ $this->rootName = $rootName;
39
+ }
40
+
41
+ private function getXML($data) {
42
+ foreach ($data as $key => $val) {
43
+ if (!is_array($val) && $val == '') {
44
+ continue;
45
+ } else {
46
+ if (is_numeric($key)) {
47
+ $key = 'key'.$key;
48
+ }
49
+ if (is_array($val)) {
50
+ $this->writer->startElement($key);
51
+ $this->getXML($val);
52
+ $this->writer->endElement();
53
+ }
54
+ else {
55
+ $this->writer->writeElement($key, $val);
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+
62
+ function xml2array($xml) {
63
+ $json = json_encode($xml);
64
+ $array = json_decode($json,TRUE);
65
+ $tvalues = $array['tvalues'];
66
+
67
+ foreach($tvalues as $_key0=>$_v0) {
68
+ $key1 = str_ireplace('key', '', $_key0);
69
+
70
+ foreach($_v0 as $_key1=>$_val) {
71
+ $key2 = str_ireplace('key', '', $_key1);
72
+ $_v[$key1][$key2] = $_val;
73
+ }
74
+ }
75
+ $array['tvalues'] = $_v;
76
+ unset($_key0, $_v0, $_key, $_key1, $_val, $_v);
77
+
78
+ if(isset($array['id']) ) {
79
+ unset( $array['id'] );
80
+ }
81
+ return $array;
82
+ }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: responsive tables, pricing tables, comparison tables, wordpress tables, ta
4
  Donate link: http://wpsoul.com/
5
  Requires at least: 3.0
6
  Tested up to: 4.3.3
7
- Stable tag: 1.1
8
  License: License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -48,6 +48,10 @@ If you like this plugin please give it a good rating.
48
  3. How it looks on mobile
49
 
50
  == Changelog ==
 
 
 
 
51
  = 1.2 =
52
  * some fixes
53
 
4
  Donate link: http://wpsoul.com/
5
  Requires at least: 3.0
6
  Tested up to: 4.3.3
7
+ Stable tag: 1.2
8
  License: License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
48
  3. How it looks on mobile
49
 
50
  == Changelog ==
51
+
52
+ = 1.3 =
53
+ * Added export/import of table and some fixes
54
+
55
  = 1.2 =
56
  * some fixes
57
 
table-maker.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /*
3
  Plugin Name: Table Maker
4
- Plugin URI:
5
  Description: Create tables with just a few clicks.
6
- Version: 1.2
7
  Author: Wpsoul
8
  Author URI: https://wpsoul.com
9
  License: GPL2
@@ -18,7 +18,7 @@ if ( ! defined( 'WPINC' ) ) {
18
  require_once plugin_dir_path( __FILE__ ) . 'inc/class-wpsm-table-maker.php';
19
 
20
  function wpsm_run_table_maker() {
21
- $plugin_instance = new WPSM_Table_Maker('1.2');
22
  register_activation_hook( __FILE__, array($plugin_instance, 'initialize') );
23
  register_uninstall_hook( __FILE__, array('WPSM_Table_Maker', 'rollback') );
24
  }
1
  <?php
2
  /*
3
  Plugin Name: Table Maker
4
+ Plugin URI: https://wordpress.org/plugins/table-maker/
5
  Description: Create tables with just a few clicks.
6
+ Version: 1.3
7
  Author: Wpsoul
8
  Author URI: https://wpsoul.com
9
  License: GPL2
18
  require_once plugin_dir_path( __FILE__ ) . 'inc/class-wpsm-table-maker.php';
19
 
20
  function wpsm_run_table_maker() {
21
+ $plugin_instance = new WPSM_Table_Maker('1.3');
22
  register_activation_hook( __FILE__, array($plugin_instance, 'initialize') );
23
  register_uninstall_hook( __FILE__, array('WPSM_Table_Maker', 'rollback') );
24
  }