SchemaPlugin.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * Abstract class for the schema export plugins
  4. */
  5. declare(strict_types=1);
  6. namespace PhpMyAdmin\Plugins;
  7. use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
  8. use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
  9. use PhpMyAdmin\Properties\Plugins\SchemaPluginProperties;
  10. /**
  11. * Provides a common interface that will have to be implemented by all of the
  12. * schema export plugins. Some of the plugins will also implement other public
  13. * methods, but those are not declared here, because they are not implemented
  14. * by all export plugins.
  15. */
  16. abstract class SchemaPlugin
  17. {
  18. /**
  19. * PhpMyAdmin\Properties\Plugins\SchemaPluginProperties object containing
  20. * the specific schema export plugin type properties
  21. *
  22. * @var SchemaPluginProperties
  23. */
  24. protected $properties;
  25. /**
  26. * Gets the export specific format plugin properties
  27. *
  28. * @return SchemaPluginProperties
  29. */
  30. public function getProperties()
  31. {
  32. return $this->properties;
  33. }
  34. /**
  35. * Sets the export plugins properties and is implemented by
  36. * each schema export plugin
  37. *
  38. * @return void
  39. */
  40. abstract protected function setProperties();
  41. /**
  42. * Exports the schema into the specified format.
  43. *
  44. * @param string $db database name
  45. *
  46. * @return bool Whether it succeeded
  47. */
  48. abstract public function exportSchema($db);
  49. /**
  50. * Adds export options common to all plugins.
  51. *
  52. * @param OptionsPropertyMainGroup $propertyGroup property group
  53. *
  54. * @return void
  55. */
  56. protected function addCommonOptions(OptionsPropertyMainGroup $propertyGroup)
  57. {
  58. $leaf = new BoolPropertyItem('show_color', __('Show color'));
  59. $propertyGroup->addProperty($leaf);
  60. $leaf = new BoolPropertyItem('show_keys', __('Only show keys'));
  61. $propertyGroup->addProperty($leaf);
  62. }
  63. /**
  64. * Returns the array of paper sizes
  65. *
  66. * @return array array of paper sizes
  67. */
  68. protected function getPaperSizeArray()
  69. {
  70. $ret = [];
  71. foreach ($GLOBALS['cfg']['PDFPageSizes'] as $val) {
  72. $ret[$val] = $val;
  73. }
  74. return $ret;
  75. }
  76. }