SchemaDia.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Dia schema export code
  5. *
  6. * @package PhpMyAdmin-Schema
  7. * @subpackage Dia
  8. */
  9. declare(strict_types=1);
  10. namespace PhpMyAdmin\Plugins\Schema;
  11. use PhpMyAdmin\Plugins\Schema\Dia\DiaRelationSchema;
  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\SelectPropertyItem;
  16. use PhpMyAdmin\Properties\Plugins\SchemaPluginProperties;
  17. /**
  18. * Handles the schema export for the Dia format
  19. *
  20. * @package PhpMyAdmin-Schema
  21. * @subpackage Dia
  22. */
  23. class SchemaDia extends SchemaPlugin
  24. {
  25. /**
  26. * Constructor
  27. */
  28. public function __construct()
  29. {
  30. $this->setProperties();
  31. }
  32. /**
  33. * Sets the schema export Dia properties
  34. *
  35. * @return void
  36. */
  37. protected function setProperties()
  38. {
  39. $schemaPluginProperties = new SchemaPluginProperties();
  40. $schemaPluginProperties->setText('Dia');
  41. $schemaPluginProperties->setExtension('dia');
  42. $schemaPluginProperties->setMimeType('application/dia');
  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. $leaf = new SelectPropertyItem(
  54. "orientation",
  55. __('Orientation')
  56. );
  57. $leaf->setValues(
  58. [
  59. 'L' => __('Landscape'),
  60. 'P' => __('Portrait'),
  61. ]
  62. );
  63. $specificOptions->addProperty($leaf);
  64. $leaf = new SelectPropertyItem(
  65. "paper",
  66. __('Paper size')
  67. );
  68. $leaf->setValues($this->getPaperSizeArray());
  69. $specificOptions->addProperty($leaf);
  70. // add the main group to the root group
  71. $exportSpecificOptions->addProperty($specificOptions);
  72. // set the options for the schema export plugin property item
  73. $schemaPluginProperties->setOptions($exportSpecificOptions);
  74. $this->properties = $schemaPluginProperties;
  75. }
  76. /**
  77. * Exports the schema into DIA format.
  78. *
  79. * @param string $db database name
  80. *
  81. * @return bool Whether it succeeded
  82. */
  83. public function exportSchema($db)
  84. {
  85. $export = new DiaRelationSchema($db);
  86. $export->showOutput();
  87. return true;
  88. }
  89. }