AbstractImportCsv.class.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 OptionsPropertyMainGroup 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. $generalOptions->addProperty($leaf);
  56. $leaf = new TextPropertyItem();
  57. $leaf->setName("enclosed");
  58. $leaf->setText(__('Columns enclosed with:'));
  59. $leaf->setSize(2);
  60. $leaf->setLen(2);
  61. $generalOptions->addProperty($leaf);
  62. $leaf = new TextPropertyItem();
  63. $leaf->setName("escaped");
  64. $leaf->setText(__('Columns escaped with:'));
  65. $leaf->setSize(2);
  66. $leaf->setLen(2);
  67. $generalOptions->addProperty($leaf);
  68. $leaf = new TextPropertyItem();
  69. $leaf->setName("new_line");
  70. $leaf->setText(__('Lines terminated with:'));
  71. $leaf->setSize(2);
  72. $generalOptions->addProperty($leaf);
  73. // add the main group to the root group
  74. $importSpecificOptions->addProperty($generalOptions);
  75. // set the options for the import plugin property item
  76. $importPluginProperties->setOptions($importSpecificOptions);
  77. $this->properties = $importPluginProperties;
  78. return $generalOptions;
  79. }
  80. }
  81. ?>