build.schema.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * Gallery
  4. *
  5. * Copyright 2010-2012 by Shaun McCormick <shaun@modx.com>
  6. *
  7. * Gallery is free software; you can redistribute it and/or modify it under the
  8. * terms of the GNU General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option) any later
  10. * version.
  11. *
  12. * Gallery is distributed in the hope that it will be useful, but WITHOUT ANY
  13. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  14. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * Gallery; if not, write to the Free Software Foundation, Inc., 59 Temple
  18. * Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. * @package gallery
  21. */
  22. /**
  23. * Build Schema script
  24. *
  25. * @package gallery
  26. * @subpackage build
  27. */
  28. $mtime = microtime();
  29. $mtime = explode(" ", $mtime);
  30. $mtime = $mtime[1] + $mtime[0];
  31. $tstart = $mtime;
  32. set_time_limit(0);
  33. /* setup paths */
  34. $root = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))).'/';
  35. $sources = array(
  36. 'root' => $root,
  37. 'build' => $root.'_build/',
  38. 'core' => $root.'core/components/gallery/',
  39. 'model' => $root.'core/components/gallery/model/',
  40. 'assets' => $root.'assets/components/gallery/',
  41. );
  42. require_once $sources['build'].'/build.config.php';
  43. include_once MODX_CORE_PATH . 'model/modx/modx.class.php';
  44. $modx= new modX();
  45. $modx->initialize('mgr');
  46. $modx->loadClass('transport.modPackageBuilder','',false, true);
  47. echo '<pre>'; /* used for nice formatting of log messages */
  48. $modx->setLogLevel(modX::LOG_LEVEL_INFO);
  49. $modx->setLogTarget('ECHO');
  50. $manager= $modx->getManager();
  51. $generator= $manager->getGenerator();
  52. $generator->classTemplate= <<<EOD
  53. <?php
  54. /**
  55. * [+phpdoc-package+]
  56. */
  57. class [+class+] extends [+extends+] {}
  58. ?>
  59. EOD;
  60. $generator->platformTemplate= <<<EOD
  61. <?php
  62. /**
  63. * [+phpdoc-package+]
  64. */
  65. require_once (strtr(realpath(dirname(dirname(__FILE__))), '\\\\', '/') . '/[+class-lowercase+].class.php');
  66. class [+class+]_[+platform+] extends [+class+] {}
  67. ?>
  68. EOD;
  69. $generator->mapHeader= <<<EOD
  70. <?php
  71. /**
  72. * [+phpdoc-package+]
  73. */
  74. EOD;
  75. if (!is_dir($sources['model'])) {
  76. $modx->log(modX::LOG_LEVEL_ERROR,'Model directory not found!');
  77. die();
  78. }
  79. $generator->parseSchema(dirname(__FILE__) . '/gallery.mysql.schema.xml',$sources['model']);
  80. $mtime= microtime();
  81. $mtime= explode(" ", $mtime);
  82. $mtime= $mtime[1] + $mtime[0];
  83. $tend= $mtime;
  84. $totalTime= ($tend - $tstart);
  85. $totalTime= sprintf("%2.4f s", $totalTime);
  86. echo "\nExecution time: {$totalTime}\n";
  87. exit ();