SchemaPdf.class.php 4.3 KB

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