SchemaPlugin.php 2.3 KB

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