SchemaPdf.php 3.6 KB

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