SchemaPlugin.php 2.3 KB

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