AbstractImportCsv.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Super class of CSV import plugins for phpMyAdmin
  4. */
  5. declare(strict_types=1);
  6. namespace PhpMyAdmin\Plugins\Import;
  7. use PhpMyAdmin\Plugins\ImportPlugin;
  8. use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
  9. use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
  10. use PhpMyAdmin\Properties\Options\Items\TextPropertyItem;
  11. use function __;
  12. /**
  13. * Super class of the import plugins for the CSV format
  14. */
  15. abstract class AbstractImportCsv extends ImportPlugin
  16. {
  17. final protected function getGeneralOptions(): OptionsPropertyMainGroup
  18. {
  19. $generalOptions = new OptionsPropertyMainGroup('general_opts');
  20. // create common items and add them to the group
  21. $leaf = new BoolPropertyItem(
  22. 'replace',
  23. __(
  24. 'Update data when duplicate keys found on import (add ON DUPLICATE KEY UPDATE)'
  25. )
  26. );
  27. $generalOptions->addProperty($leaf);
  28. $leaf = new TextPropertyItem(
  29. 'terminated',
  30. __('Columns separated with:')
  31. );
  32. $leaf->setSize(2);
  33. $generalOptions->addProperty($leaf);
  34. $leaf = new TextPropertyItem(
  35. 'enclosed',
  36. __('Columns enclosed with:')
  37. );
  38. $leaf->setSize(2);
  39. $leaf->setLen(2);
  40. $generalOptions->addProperty($leaf);
  41. $leaf = new TextPropertyItem(
  42. 'escaped',
  43. __('Columns escaped with:')
  44. );
  45. $leaf->setSize(2);
  46. $leaf->setLen(2);
  47. $generalOptions->addProperty($leaf);
  48. $leaf = new TextPropertyItem(
  49. 'new_line',
  50. __('Lines terminated with:')
  51. );
  52. $leaf->setSize(2);
  53. $generalOptions->addProperty($leaf);
  54. return $generalOptions;
  55. }
  56. }