SchemaPdf.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 PDF
  8. */
  9. declare(strict_types=1);
  10. namespace PhpMyAdmin\Plugins\Schema;
  11. use PhpMyAdmin\Plugins\Schema\Pdf\PdfRelationSchema;
  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\BoolPropertyItem;
  16. use PhpMyAdmin\Properties\Options\Items\SelectPropertyItem;
  17. use PhpMyAdmin\Properties\Plugins\SchemaPluginProperties;
  18. /**
  19. * Handles the schema export for the PDF format
  20. *
  21. * @package PhpMyAdmin-Schema
  22. * @subpackage PDF
  23. */
  24. class SchemaPdf extends SchemaPlugin
  25. {
  26. /**
  27. * Constructor
  28. */
  29. public function __construct()
  30. {
  31. $this->setProperties();
  32. }
  33. /**
  34. * Sets the schema export PDF properties
  35. *
  36. * @return void
  37. */
  38. protected function setProperties()
  39. {
  40. $schemaPluginProperties = new SchemaPluginProperties();
  41. $schemaPluginProperties->setText('PDF');
  42. $schemaPluginProperties->setExtension('pdf');
  43. $schemaPluginProperties->setMimeType('application/pdf');
  44. // create the root group that will be the options field for
  45. // $schemaPluginProperties
  46. // this will be shown as "Format specific options"
  47. $exportSpecificOptions = new OptionsPropertyRootGroup(
  48. "Format Specific Options"
  49. );
  50. // specific options main group
  51. $specificOptions = new OptionsPropertyMainGroup("general_opts");
  52. // add options common to all plugins
  53. $this->addCommonOptions($specificOptions);
  54. // create leaf items and add them to the group
  55. $leaf = new BoolPropertyItem(
  56. 'all_tables_same_width',
  57. __('Same width for all tables')
  58. );
  59. $specificOptions->addProperty($leaf);
  60. $leaf = new SelectPropertyItem(
  61. "orientation",
  62. __('Orientation')
  63. );
  64. $leaf->setValues(
  65. [
  66. 'L' => __('Landscape'),
  67. 'P' => __('Portrait'),
  68. ]
  69. );
  70. $specificOptions->addProperty($leaf);
  71. $leaf = new SelectPropertyItem(
  72. "paper",
  73. __('Paper size')
  74. );
  75. $leaf->setValues($this->getPaperSizeArray());
  76. $specificOptions->addProperty($leaf);
  77. $leaf = new BoolPropertyItem(
  78. 'show_grid',
  79. __('Show grid')
  80. );
  81. $specificOptions->addProperty($leaf);
  82. $leaf = new BoolPropertyItem(
  83. 'with_doc',
  84. __('Data dictionary')
  85. );
  86. $specificOptions->addProperty($leaf);
  87. $leaf = new SelectPropertyItem(
  88. "table_order",
  89. __('Order of the tables')
  90. );
  91. $leaf->setValues(
  92. [
  93. '' => __('None'),
  94. 'name_asc' => __('Name (Ascending)'),
  95. 'name_desc' => __('Name (Descending)'),
  96. ]
  97. );
  98. $specificOptions->addProperty($leaf);
  99. // add the main group to the root group
  100. $exportSpecificOptions->addProperty($specificOptions);
  101. // set the options for the schema export plugin property item
  102. $schemaPluginProperties->setOptions($exportSpecificOptions);
  103. $this->properties = $schemaPluginProperties;
  104. }
  105. /**
  106. * Exports the schema into PDF format.
  107. *
  108. * @param string $db database name
  109. *
  110. * @return bool Whether it succeeded
  111. */
  112. public function exportSchema($db)
  113. {
  114. $export = new PdfRelationSchema($db);
  115. $export->showOutput();
  116. return true;
  117. }
  118. }