SchemaEps.php 2.6 KB

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