SchemaDia.php 2.7 KB

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