AbstractImportCsv.class.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Super class of CSV import plugins for phpMyAdmin
  5. *
  6. * @package PhpMyAdmin-Import
  7. * @subpackage CSV
  8. */
  9. if (! defined('PHPMYADMIN')) {
  10. exit;
  11. }
  12. /* Get the import interface */
  13. require_once 'libraries/plugins/ImportPlugin.class.php';
  14. /**
  15. * Super class of the import plugins for the CSV format
  16. *
  17. * @package PhpMyAdmin-Import
  18. * @subpackage CSV
  19. */
  20. abstract class AbstractImportCsv extends ImportPlugin
  21. {
  22. /**
  23. * Sets the import plugin properties.
  24. * Called in the constructor.
  25. *
  26. * @return object OptionsPropertyMainGroup object of the plugin
  27. */
  28. protected function setProperties()
  29. {
  30. $props = 'libraries/properties/';
  31. include_once "$props/plugins/ImportPluginProperties.class.php";
  32. include_once "$props/options/groups/OptionsPropertyRootGroup.class.php";
  33. include_once "$props/options/groups/OptionsPropertyMainGroup.class.php";
  34. include_once "$props/options/items/BoolPropertyItem.class.php";
  35. include_once "$props/options/items/TextPropertyItem.class.php";
  36. $importPluginProperties = new ImportPluginProperties();
  37. $importPluginProperties->setOptionsText(__('Options'));
  38. // create the root group that will be the options field for
  39. // $importPluginProperties
  40. // this will be shown as "Format specific options"
  41. $importSpecificOptions = new OptionsPropertyRootGroup();
  42. $importSpecificOptions->setName("Format Specific Options");
  43. // general options main group
  44. $generalOptions = new OptionsPropertyMainGroup();
  45. $generalOptions->setName("general_opts");
  46. // create common items and add them to the group
  47. $leaf = new BoolPropertyItem();
  48. $leaf->setName("replace");
  49. $leaf->setText(__('Replace table data with file'));
  50. $generalOptions->addProperty($leaf);
  51. $leaf = new TextPropertyItem();
  52. $leaf->setName("terminated");
  53. $leaf->setText(__('Columns separated with:'));
  54. $leaf->setSize(2);
  55. $leaf->setLen(2);
  56. $generalOptions->addProperty($leaf);
  57. $leaf = new TextPropertyItem();
  58. $leaf->setName("enclosed");
  59. $leaf->setText(__('Columns enclosed with:'));
  60. $leaf->setSize(2);
  61. $leaf->setLen(2);
  62. $generalOptions->addProperty($leaf);
  63. $leaf = new TextPropertyItem();
  64. $leaf->setName("escaped");
  65. $leaf->setText(__('Columns escaped with:'));
  66. $leaf->setSize(2);
  67. $leaf->setLen(2);
  68. $generalOptions->addProperty($leaf);
  69. $leaf = new TextPropertyItem();
  70. $leaf->setName("new_line");
  71. $leaf->setText(__('Lines terminated with:'));
  72. $leaf->setSize(2);
  73. $generalOptions->addProperty($leaf);
  74. // add the main group to the root group
  75. $importSpecificOptions->addProperty($generalOptions);
  76. // set the options for the import plugin property item
  77. $importPluginProperties->setOptions($importSpecificOptions);
  78. $this->properties = $importPluginProperties;
  79. return $generalOptions;
  80. }
  81. }
  82. ?>