SchemaSvg.php 2.4 KB

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