SchemaDia.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * Dia schema export code
  4. */
  5. declare(strict_types=1);
  6. namespace PhpMyAdmin\Plugins\Schema;
  7. use PhpMyAdmin\Plugins\Schema\Dia\DiaRelationSchema;
  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\SelectPropertyItem;
  12. use PhpMyAdmin\Properties\Plugins\SchemaPluginProperties;
  13. /**
  14. * Handles the schema export for the Dia format
  15. */
  16. class SchemaDia extends SchemaPlugin
  17. {
  18. public function __construct()
  19. {
  20. $this->setProperties();
  21. }
  22. /**
  23. * Sets the schema export Dia properties
  24. *
  25. * @return void
  26. */
  27. protected function setProperties()
  28. {
  29. $schemaPluginProperties = new SchemaPluginProperties();
  30. $schemaPluginProperties->setText('Dia');
  31. $schemaPluginProperties->setExtension('dia');
  32. $schemaPluginProperties->setMimeType('application/dia');
  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. $leaf = new SelectPropertyItem(
  44. 'orientation',
  45. __('Orientation')
  46. );
  47. $leaf->setValues(
  48. [
  49. 'L' => __('Landscape'),
  50. 'P' => __('Portrait'),
  51. ]
  52. );
  53. $specificOptions->addProperty($leaf);
  54. $leaf = new SelectPropertyItem(
  55. 'paper',
  56. __('Paper size')
  57. );
  58. $leaf->setValues($this->getPaperSizeArray());
  59. $specificOptions->addProperty($leaf);
  60. // add the main group to the root group
  61. $exportSpecificOptions->addProperty($specificOptions);
  62. // set the options for the schema export plugin property item
  63. $schemaPluginProperties->setOptions($exportSpecificOptions);
  64. $this->properties = $schemaPluginProperties;
  65. }
  66. /**
  67. * Exports the schema into DIA format.
  68. *
  69. * @param string $db database name
  70. *
  71. * @return bool Whether it succeeded
  72. */
  73. public function exportSchema($db)
  74. {
  75. $export = new DiaRelationSchema($db);
  76. $export->showOutput();
  77. return true;
  78. }
  79. }