ImportPlugin.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Abstract class for the import plugins
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. namespace PhpMyAdmin\Plugins;
  9. use PhpMyAdmin\Properties\Plugins\ImportPluginProperties;
  10. /**
  11. * Provides a common interface that will have to be implemented by all of the
  12. * import plugins.
  13. *
  14. * @package PhpMyAdmin
  15. */
  16. abstract class ImportPlugin
  17. {
  18. /**
  19. * ImportPluginProperties object containing the import plugin properties
  20. *
  21. * @var ImportPluginProperties
  22. */
  23. protected $properties;
  24. /**
  25. * Handles the whole import logic
  26. *
  27. * @return void
  28. */
  29. abstract public function doImport();
  30. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  31. /**
  32. * Gets the import specific format plugin properties
  33. *
  34. * @return \PhpMyAdmin\Properties\Plugins\ImportPluginProperties
  35. */
  36. public function getProperties()
  37. {
  38. return $this->properties;
  39. }
  40. /**
  41. * Sets the export plugins properties and is implemented by each import
  42. * plugin
  43. *
  44. * @return void
  45. */
  46. abstract protected function setProperties();
  47. /**
  48. * Define DB name and options
  49. *
  50. * @param string $currentDb DB
  51. * @param string $defaultDb Default DB name
  52. *
  53. * @return array DB name and options (an associative array of options)
  54. */
  55. protected function getDbnameAndOptions($currentDb, $defaultDb)
  56. {
  57. if (strlen($currentDb) > 0) {
  58. $db_name = $currentDb;
  59. $options = array('create_db' => false);
  60. } else {
  61. $db_name = $defaultDb;
  62. $options = null;
  63. }
  64. return array($db_name, $options);
  65. }
  66. }