PageRenderTime 611ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/_build/build.schema.php

https://github.com/molotsnk/miniShop
PHP | 95 lines | 55 code | 5 blank | 35 comment | 0 complexity | 414627c1d222707253081d204dbd62c7 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /**
  3. * miniShop
  4. *
  5. * Copyright 2012 by Vasiliy Naumkin <bezumkin@yandex.ru>
  6. *
  7. * miniShop 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. * miniShop 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. * miniShop; if not, write to the Free Software Foundation, Inc., 59 Temple
  18. * Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. * @package minishop
  21. */
  22. /**
  23. * Build Schema script
  24. *
  25. * @package minishop
  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. /* define package name */
  34. define('PKG_NAME','miniShop');
  35. define('PKG_NAME_LOWER',strtolower(PKG_NAME));
  36. /* define sources */
  37. $root = dirname(dirname(__FILE__)).'/';
  38. $sources = array(
  39. 'root' => $root,
  40. 'core' => $root.'core/components/'.PKG_NAME_LOWER.'/',
  41. 'model' => $root.'core/components/'.PKG_NAME_LOWER.'/model/',
  42. 'assets' => $root.'assets/components/'.PKG_NAME_LOWER.'/',
  43. );
  44. /* load modx and configs */
  45. require_once dirname(__FILE__) . '/build.config.php';
  46. include_once MODX_CORE_PATH . 'model/modx/modx.class.php';
  47. $modx= new modX();
  48. $modx->initialize('mgr');
  49. $modx->loadClass('transport.modPackageBuilder','',false, true);
  50. echo '<pre>'; /* used for nice formatting of log messages */
  51. $modx->setLogLevel(modX::LOG_LEVEL_INFO);
  52. $modx->setLogTarget('ECHO');
  53. $manager= $modx->getManager();
  54. $generator= $manager->getGenerator();
  55. $generator->classTemplate= <<<EOD
  56. <?php
  57. /**
  58. * [+phpdoc-package+]
  59. */
  60. class [+class+] extends [+extends+] {}
  61. ?>
  62. EOD;
  63. $generator->platformTemplate= <<<EOD
  64. <?php
  65. /**
  66. * [+phpdoc-package+]
  67. */
  68. require_once (strtr(realpath(dirname(dirname(__FILE__))), '\\\\', '/') . '/[+class-lowercase+].class.php');
  69. class [+class+]_[+platform+] extends [+class+] {}
  70. ?>
  71. EOD;
  72. $generator->mapHeader= <<<EOD
  73. <?php
  74. /**
  75. * [+phpdoc-package+]
  76. */
  77. EOD;
  78. $generator->parseSchema($sources['model'] . 'schema/'.PKG_NAME_LOWER.'.mysql.schema.xml', $sources['model']);
  79. $mtime= microtime();
  80. $mtime= explode(" ", $mtime);
  81. $mtime= $mtime[1] + $mtime[0];
  82. $tend= $mtime;
  83. $totalTime= ($tend - $tstart);
  84. $totalTime= sprintf("%2.4f s", $totalTime);
  85. echo "\nExecution time: {$totalTime}\n";
  86. exit ();