SchemaSvg.php 2.4 KB

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