SchemaSvg.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * PDF schema export code
  4. */
  5. declare(strict_types=1);
  6. namespace PhpMyAdmin\Plugins\Schema;
  7. use PhpMyAdmin\Plugins\Schema\Svg\SvgRelationSchema;
  8. use PhpMyAdmin\Plugins\SchemaPlugin;
  9. use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
  10. use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
  11. use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
  12. use PhpMyAdmin\Properties\Plugins\SchemaPluginProperties;
  13. /**
  14. * Handles the schema export for the SVG format
  15. */
  16. class SchemaSvg extends SchemaPlugin
  17. {
  18. public function __construct()
  19. {
  20. $this->setProperties();
  21. }
  22. /**
  23. * Sets the schema export SVG properties
  24. *
  25. * @return void
  26. */
  27. protected function setProperties()
  28. {
  29. $schemaPluginProperties = new SchemaPluginProperties();
  30. $schemaPluginProperties->setText('SVG');
  31. $schemaPluginProperties->setExtension('svg');
  32. $schemaPluginProperties->setMimeType('application/svg');
  33. // create the root group that will be the options field for
  34. // $schemaPluginProperties
  35. // this will be shown as "Format specific options"
  36. $exportSpecificOptions = new OptionsPropertyRootGroup(
  37. 'Format Specific Options'
  38. );
  39. // specific options main group
  40. $specificOptions = new OptionsPropertyMainGroup('general_opts');
  41. // add options common to all plugins
  42. $this->addCommonOptions($specificOptions);
  43. // create leaf items and add them to the group
  44. $leaf = new BoolPropertyItem(
  45. 'all_tables_same_width',
  46. __('Same width for all tables')
  47. );
  48. $specificOptions->addProperty($leaf);
  49. // add the main group to the root group
  50. $exportSpecificOptions->addProperty($specificOptions);
  51. // set the options for the schema export plugin property item
  52. $schemaPluginProperties->setOptions($exportSpecificOptions);
  53. $this->properties = $schemaPluginProperties;
  54. }
  55. /**
  56. * Exports the schema into SVG format.
  57. *
  58. * @param string $db database name
  59. *
  60. * @return bool Whether it succeeded
  61. */
  62. public function exportSchema($db)
  63. {
  64. $export = new SvgRelationSchema($db);
  65. $export->showOutput();
  66. return true;
  67. }
  68. }