/_build/build.schema.php

https://github.com/Mark-H/MODX-CMP-Defaults · PHP · 139 lines · 46 code · 6 blank · 87 comment · 0 complexity · ee161e624db6d2fff901e0a2cfaa5e70 MD5 · raw file

  1. <?php
  2. /**
  3. * ExtraName
  4. *
  5. * Copyright 2011 by Mark Hamstra <hello@markhamstra.com>
  6. *
  7. * This file is part of ExtraName.
  8. *
  9. * ExtraName is free software; you can redistribute it and/or modify it under
  10. * the terms of the GNU General Public License as published by the Free Software
  11. * Foundation; either version 2 of the License, or (at your option) any later
  12. * version.
  13. *
  14. * ExtraName is distributed in the hope that it will be useful, but WITHOUT ANY
  15. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  16. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along with
  19. * ExtraName; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
  20. * Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. $mtime = microtime();
  24. $mtime = explode(" ", $mtime);
  25. $mtime = $mtime[1] + $mtime[0];
  26. $tstart = $mtime;
  27. set_time_limit(0);
  28. require_once dirname(dirname(__FILE__)) . '/config.core.php';
  29. include_once MODX_CORE_PATH . 'model/modx/modx.class.php';
  30. $modx= new modX();
  31. $modx->initialize('mgr');
  32. $modx->loadClass('transport.modPackageBuilder','',false, true);
  33. $modx->setLogLevel(modX::LOG_LEVEL_INFO);
  34. $modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
  35. $root = dirname(dirname(__FILE__)).'/';
  36. $sources = array(
  37. 'root' => $root,
  38. 'core' => $root.'core/components/extraname/',
  39. 'model' => $root.'core/components/extraname/model/',
  40. 'assets' => $root.'assets/components/extraname/',
  41. 'schema' => $root.'_build/schema/',
  42. );
  43. $manager= $modx->getManager();
  44. $generator= $manager->getGenerator();
  45. $generator->classTemplate= <<<EOD
  46. <?php
  47. /**
  48. * ExtraName
  49. *
  50. * Copyright 2011 by Mark Hamstra <hello@markhamstra.com>
  51. *
  52. * This file is part of ExtraName, a real estate property listings component
  53. * for MODX Revolution.
  54. *
  55. * ExtraName is free software; you can redistribute it and/or modify it under
  56. * the terms of the GNU General Public License as published by the Free Software
  57. * Foundation; either version 2 of the License, or (at your option) any later
  58. * version.
  59. *
  60. * ExtraName is distributed in the hope that it will be useful, but WITHOUT ANY
  61. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  62. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  63. *
  64. * You should have received a copy of the GNU General Public License along with
  65. * ExtraName; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
  66. * Suite 330, Boston, MA 02111-1307 USA
  67. *
  68. */
  69. class [+class+] extends [+extends+] {}
  70. ?>
  71. EOD;
  72. $generator->platformTemplate= <<<EOD
  73. <?php
  74. /**
  75. * ExtraName
  76. *
  77. * Copyright 2011 by Mark Hamstra <hello@markhamstra.com>
  78. *
  79. * This file is part of ExtraName, a real estate property listings component
  80. * for MODX Revolution.
  81. *
  82. * ExtraName is free software; you can redistribute it and/or modify it under
  83. * the terms of the GNU General Public License as published by the Free Software
  84. * Foundation; either version 2 of the License, or (at your option) any later
  85. * version.
  86. *
  87. * ExtraName is distributed in the hope that it will be useful, but WITHOUT ANY
  88. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  89. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  90. *
  91. * You should have received a copy of the GNU General Public License along with
  92. * ExtraName; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
  93. * Suite 330, Boston, MA 02111-1307 USA
  94. *
  95. */
  96. require_once (strtr(realpath(dirname(dirname(__FILE__))), '\\\\', '/') . '/[+class-lowercase+].class.php');
  97. class [+class+]_[+platform+] extends [+class+] {}
  98. ?>
  99. EOD;
  100. $generator->mapHeader= <<<EOD
  101. <?php
  102. /**
  103. * ExtraName
  104. *
  105. * Copyright 2011 by Mark Hamstra <hello@markhamstra.com>
  106. *
  107. * This file is part of ExtraName, a real estate property listings component
  108. * for MODX Revolution.
  109. *
  110. * ExtraName is free software; you can redistribute it and/or modify it under
  111. * the terms of the GNU General Public License as published by the Free Software
  112. * Foundation; either version 2 of the License, or (at your option) any later
  113. * version.
  114. *
  115. * ExtraName is distributed in the hope that it will be useful, but WITHOUT ANY
  116. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  117. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  118. *
  119. * You should have received a copy of the GNU General Public License along with
  120. * ExtraName; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
  121. * Suite 330, Boston, MA 02111-1307 USA
  122. *
  123. */
  124. EOD;
  125. $generator->parseSchema($sources['schema'].'extraname.mysql.schema.xml', $sources['model']);
  126. $mtime= microtime();
  127. $mtime= explode(" ", $mtime);
  128. $mtime= $mtime[1] + $mtime[0];
  129. $tend= $mtime;
  130. $totalTime= ($tend - $tstart);
  131. $totalTime= sprintf("%2.4f s", $totalTime);
  132. echo "\nExecution time: {$totalTime}\n";
  133. exit ();