PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/exchange/code/trunk/administrator/components/com_exchange/adapters/export/xmi.php

https://bitbucket.org/eddieajau/the-art-of-joomla-archive
PHP | 119 lines | 75 code | 25 blank | 19 comment | 0 complexity | aaf741dbeded2c11aebdbc410bcba29d MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: xmi.php 280 2010-09-18 02:14:15Z eddieajau $
  4. * @package NewLifeInIT
  5. * @subpackage com_exchange
  6. * @copyright Copyright 2005 - 2010 New Life in IT Pty Ltd. All rights reserved.
  7. * @license GNU General Public License version 2 or later.
  8. * @link http://www.theartofjoomla.com
  9. */
  10. // no direct access
  11. defined('_JEXEC') or die;
  12. /**
  13. * @package NewLifeInIT
  14. * @subpackage com_exchange
  15. */
  16. class ExportAdapterXMI
  17. {
  18. /**
  19. * Creates an XMI document that can be imported into Visual Paradigm
  20. */
  21. function export(&$tables, &$table_fields, &$table_creates, &$options)
  22. {
  23. return '<?xml version="1.0"?>' . "\n" . $this->_createXMI($table_fields);
  24. }
  25. function _createXMI(&$table_fields)
  26. {
  27. global $_VERSION;
  28. mosFS::load('@domit');
  29. $xmlDoc = new DOMIT_Lite_Document();
  30. // root element
  31. $elem = new DOMIT_Lite_Element('XMI');
  32. $elem->setAttribute('xmi.version', '1.2');
  33. $elem->setAttribute('xmlns:UML', 'org.omg/UML/1.4');
  34. $xmlDoc->setDocumentElement($elem);
  35. $root =& $xmlDoc->documentElement;
  36. // XMI Header
  37. $expo =& $xmlDoc->createElement('XMI.exporter');
  38. $expo->setText('Joomla! Open Source CMS ' . $_VERSION->RELEASE . '.' . $_VERSION->DEV_LEVEL . ' ' . $_VERSION->DEV_STATUS);
  39. $docu =& $xmlDoc->createElement('XMI.documentation');
  40. $docu->appendChild($expo);
  41. $meta =& $xmlDoc->createElement('XMI.metamodel');
  42. $meta->setAttribute('xmi.name', 'UML');
  43. $meta->setAttribute('xmi.version', '1.4');
  44. $head =& $xmlDoc->createElement('XMI.header');
  45. $head->appendChild($docu);
  46. $head->appendChild($meta);
  47. $root->appendChild($head);
  48. // XMI Content
  49. $cont =& $xmlDoc->createElement('XMI.content');
  50. $model =& $xmlDoc->createElement('UML:Model');
  51. $model->setAttribute('xmi.id', 'M.1');
  52. $model->setAttribute('name', 'Joomla');
  53. $model->setAttribute('visibility', 'public');
  54. $model->setAttribute('isSpecification', 'false');
  55. $model->setAttribute('ownerScope', 'instance');
  56. $model->setAttribute('isRoot', 'false');
  57. $model->setAttribute('isLeaf', 'false');
  58. $model->setAttribute('isAbstract', 'false');
  59. $namesp =& $xmlDoc->createElement('UML:Namespace.ownedElement');
  60. $classCount = 1;
  61. $attribCount = 1;
  62. foreach ($table_fields as $table=>$fields) {
  63. $class =& $xmlDoc->createElement('UML:Class');
  64. $class->setAttribute('name', $table);
  65. $class->setAttribute('xmi.id', 'C.' . $classCount);
  66. $class->setAttribute('visibility', 'public');
  67. $class->setAttribute('isSpecification', 'false');
  68. $class->setAttribute('namespace', 'M.1');
  69. $class->setAttribute('isRoot', 'true');
  70. $class->setAttribute('isLeaf', 'true');
  71. $class->setAttribute('isAbstract', 'false');
  72. $class->setAttribute('isActive', 'true');
  73. $classif =& $xmlDoc->createElement('UML:Classifier.feature');
  74. foreach ($fields as $name=>$type) {
  75. $attrib =& $xmlDoc->createElement('UML:Attribute');
  76. $attrib->setAttribute('xmi.id', 'A.' . $attribCount);
  77. $attrib->setAttribute('name', $name);
  78. $attrib->setAttribute('type', $type);
  79. $attrib->setAttribute('visibility', 'public');
  80. $attrib->setAttribute('isSpecification', 'false');
  81. $attrib->setAttribute('ownerScope', 'instance');
  82. $classif->appendChild($attrib);
  83. $attribCount++;
  84. }
  85. $class->appendChild($classif);
  86. $namesp->appendChild($class);
  87. $classCount++;
  88. }
  89. $model->appendChild($namesp);
  90. $cont->appendChild($model);
  91. $root->appendChild($cont);
  92. return $xmlDoc->toNormalizedString();
  93. }
  94. }