SchemaDia.class.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. 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/dia/Dia_Relation_Schema.class.php';
  15. /**
  16. * Handles the schema export for the Dia format
  17. *
  18. * @package PhpMyAdmin-Schema
  19. * @subpackage Dia
  20. */
  21. class SchemaDia extends SchemaPlugin
  22. {
  23. /**
  24. * Constructor
  25. */
  26. public function __construct()
  27. {
  28. $this->setProperties();
  29. }
  30. /**
  31. * Sets the schema export Dia 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('Dia');
  45. $schemaPluginProperties->setExtension('dia');
  46. $schemaPluginProperties->setMimeType('application/dia');
  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. $leaf = new SelectPropertyItem();
  58. $leaf->setName("orientation");
  59. $leaf->setText(__('Orientation'));
  60. $leaf->setValues(
  61. array(
  62. 'L' => __('Landscape'),
  63. 'P' => __('Portrait'),
  64. )
  65. );
  66. $specificOptions->addProperty($leaf);
  67. $leaf = new SelectPropertyItem();
  68. $leaf->setName("paper");
  69. $leaf->setText(__('Paper size'));
  70. $leaf->setValues($this->_getPaperSizeArray());
  71. $specificOptions->addProperty($leaf);
  72. // add the main group to the root group
  73. $exportSpecificOptions->addProperty($specificOptions);
  74. // set the options for the schema export plugin property item
  75. $schemaPluginProperties->setOptions($exportSpecificOptions);
  76. $this->properties = $schemaPluginProperties;
  77. }
  78. /**
  79. * Returns the array of paper sizes
  80. *
  81. * @return array array of paper sizes
  82. */
  83. private function _getPaperSizeArray()
  84. {
  85. $ret = array();
  86. foreach ($GLOBALS['cfg']['PDFPageSizes'] as $val) {
  87. $ret[$val] = $val;
  88. }
  89. return $ret;
  90. }
  91. /**
  92. * Exports the schema into DIA format.
  93. *
  94. * @param string $db database name
  95. *
  96. * @return bool Whether it succeeded
  97. */
  98. public function exportSchema($db)
  99. {
  100. $export = new PMA_Dia_Relation_Schema($db);
  101. $export->showOutput();
  102. }
  103. }