CFDBViewImportCsv

The Contact Form DB CFDBViewImportCsv class.

Defined (1)

The class is defined in the following location(s).

/CFDBViewImportCsv.php  
  1. class CFDBViewImportCsv extends CFDBView 
  2.  
  3. /** 
  4. * @param $plugin CF7DBPlugin 
  5. * @return void 
  6. */ 
  7. function display(&$plugin) 
  8.  
  9. if ($plugin == null) { 
  10. $plugin = new CF7DBPlugin; 
  11.  
  12. $forms = $plugin->getForms(); 
  13. $importUrl = admin_url('admin-ajax.php') . '?action=cfdb-importcsv'; 
  14. $renameUrl = admin_url('admin-ajax.php') . '?action=cfdb-renameform'; 
  15. $clenaupUrl = admin_url('admin-ajax.php') . '?action=cfdb-cleanup'; 
  16.  
  17. ?> 
  18. <h2><?php echo htmlspecialchars(__('Import CSV File into Form', 'contact-form-7-to-database-extension')); ?></h2> 
  19. <form enctype="multipart/form-data" action="<?php echo $importUrl; ?>" method="post"> 
  20. <table> 
  21. <tbody> 
  22. <tr> 
  23. <td><label for="file"><?php echo htmlspecialchars(__('File', 'contact-form-7-to-database-extension')); ?></label></td> 
  24. <td><input type="file" name="file" id="file" size="50"></td> 
  25. </tr> 
  26. <tr> 
  27. <td><input type="radio" name="into" id="new" value="new" checked> <?php echo htmlspecialchars(__('New Form', 'contact-form-7-to-database-extension')); ?></td> 
  28. <td><input type="text" name="newformname" id="newformname" size="50"/></td> 
  29. </tr> 
  30. <tr> 
  31. <td><input type="radio" name="into" id="existing" value="into"> <?php echo htmlspecialchars(__('Existing Form', 'contact-form-7-to-database-extension')); ?></td> 
  32. <td> 
  33. <select name="form" id="form"> 
  34. <option value=""></option> 
  35. <?php 
  36. foreach ($forms as $formName) { 
  37. echo "<option value=\"$formName\">$formName</option>"; 
  38. ?> 
  39. </select> 
  40. </td> 
  41. </tr> 
  42. </tbody> 
  43. </table> 
  44. <input type="submit" name="<?php echo htmlspecialchars(__('Import', 'contact-form-7-to-database-extension')); ?>" id="importsubmit" value="import"> 
  45. </form> 
  46.  
  47. <script type="text/javascript"> 
  48. jQuery('#file').change(function () { 
  49. var val = jQuery(this).val(); 
  50. val = val.substring(val.lastIndexOf('/') + 1); 
  51. val = val.substring(val.lastIndexOf('\\') + 1); 
  52. val = val.replace(/\.([^\.])*$/, ""); 
  53. jQuery('#newformname').val(val); 
  54. }); 
  55. </script> 
  56. <form enctype="multipart/form-data" action="<?php echo $renameUrl; ?>" method="post"> 
  57. <h2><?php echo htmlspecialchars(__('Rename Form', 'contact-form-7-to-database-extension')); ?></h2> 
  58. <select name="form" id="form"> 
  59. <option value=""></option> 
  60. <?php 
  61. foreach ($forms as $formName) { 
  62. echo "<option value=\"$formName\">$formName</option>"; 
  63. ?> 
  64. </select> 
  65. <td><input type="text" name="newformname" id="renameformname" size="10"/></td> 
  66. <input type="submit" name="rename" id="renamesubmit" value="<?php echo htmlspecialchars(__('Rename', 'contact-form-7-to-database-extension')); ?>"> 
  67. </form> 
  68.  
  69. <h2><?php echo htmlspecialchars(__('Backup Form to CSV File', 'contact-form-7-to-database-extension')); ?></h2> 
  70. <ul> 
  71. <li><?php echo htmlspecialchars(__('Backup a form into a CSV file that can be re-imported without loss of data.', 'contact-form-7-to-database-extension')); ?></li> 
  72. <li><?php echo htmlspecialchars(__('Limitation: this will not export file uploads.', 'contact-form-7-to-database-extension')); ?></li> 
  73. <li><?php echo htmlspecialchars(__('Limitation: extremely large numbers of records in your form may cause the export operation on your server to run out of memory, thereby not giving you all the rows.', 'contact-form-7-to-database-extension')); ?></li> 
  74. </ul> 
  75. <form method="get" action="<?php echo $plugin->getPluginDirUrl() ?>export.php"> 
  76. <input type="hidden" name="enc" value="CSV"/> 
  77. <input type="hidden" name="bak" value="true"/> 
  78. <select name="form"> 
  79. <option value=""></option> 
  80. <?php 
  81. foreach ($forms as $formName) { 
  82. echo "<option value=\"$formName\">$formName</option>"; 
  83. ?> 
  84. </select> 
  85. <input type="submit" name="<?php echo htmlspecialchars(__('Export', 'contact-form-7-to-database-extension')); ?>" value="export"> 
  86. </form> 
  87. <h2><?php echo htmlspecialchars(__('Data Cleanup', 'contact-form-7-to-database-extension')); ?></h2> 
  88. <?php echo htmlspecialchars(__('Clean up data that can cause incorrect behavior', 'contact-form-7-to-database-extension')); ?> 
  89. <form name="cleanup" action="<?php echo $clenaupUrl; ?>" method="post"> 
  90. <input type="submit" name="cleanup" id="cleanupsubmit" value="<?php echo htmlspecialchars(__('Clean up data', 'contact-form-7-to-database-extension')); ?>"> 
  91. </form> 
  92.  
  93. <?php 
  94.