MODX Revolution PHP Cross Reference Content Management Systems

Source: /core/model/schema/build.modx.php - 85 lines - 2825 bytes - Text - Print

Description: [+phpdoc-package+] [+phpdoc-subpackage+]

   1  <?php
   2  $mtime= microtime();
   3  $mtime= explode(" ", $mtime);
   4  $mtime= $mtime[1] + $mtime[0];
   5  $tstart= $mtime;
   6  
   7  $properties = array();
   8  include_once (dirname(dirname(dirname(__FILE__))) . '/xpdo/xpdo.class.php');
   9  require_once (dirname(dirname(dirname(dirname(__FILE__)))) . '/config.core.php');
  10  require_once (dirname(dirname(dirname(dirname(__FILE__)))) . '/_build/build.properties.php');
  11  
  12  foreach (array('mysql', 'sqlsrv') as $driver) {
  13      $xpdo= new xPDO(
  14          $properties["{$driver}_string_dsn_nodb"],
  15          $properties["{$driver}_string_username"],
  16          $properties["{$driver}_string_password"],
  17          $properties["{$driver}_array_options"],
  18          $properties["{$driver}_array_driverOptions"]
  19      );
  20      $xpdo->setPackage('modx', dirname(XPDO_CORE_PATH) . '/model/');
  21      $xpdo->setDebug(true);
  22  
  23      $manager= $xpdo->getManager();
  24      $generator= $manager->getGenerator();
  25  
  26      $generator->classTemplate= <<<EOD
  27  <?php
  28  /**

  29   * [+phpdoc-package+]

  30   * [+phpdoc-subpackage+]

  31   */
  32  /**

  33   * [+phpdoc-package+]

  34   * [+phpdoc-subpackage+]

  35   */
  36  class [+class+] extends [+extends+] {
  37  }
  38  EOD;
  39      $generator->platformTemplate= <<<EOD
  40  <?php
  41  /**

  42   * [+phpdoc-package+]

  43   * [+phpdoc-subpackage+]

  44   */
  45  require_once (dirname(dirname(__FILE__)) . '/[+class-lowercase+].class.php');
  46  /**

  47   * [+phpdoc-package+]

  48   * [+phpdoc-subpackage+]

  49   */
  50  class [+class+]_[+platform+] extends [+class+] {
  51  }
  52  EOD;
  53      $generator->mapHeader= <<<EOD
  54  <?php
  55  /**

  56   * [+phpdoc-package+]

  57   * [+phpdoc-subpackage+]

  58   */
  59  EOD;
  60  
  61      //Use this to create a schema from an existing database

  62      //$xml= $generator->writeSchema(XPDO_CORE_PATH . '../model/schema/modx.mysql.schema.xml', 'modx', 'xPDOObject', 'modx_');

  63  
  64      //Use this to generate classes and maps from a schema

  65      // NOTE: by default, only maps are overwritten; delete class files if you want to regenerate classes

  66      $package= 'modx';
  67      $generator->parseSchema(dirname(XPDO_CORE_PATH) . "/model/schema/modx.{$driver}.schema.xml", dirname(XPDO_CORE_PATH) . '/model/');
  68      $package= 'modx.transport';
  69      $generator->parseSchema(dirname(XPDO_CORE_PATH) . "/model/schema/modx.transport.{$driver}.schema.xml", dirname(XPDO_CORE_PATH) . '/model/');
  70      $package= 'modx.registry.db';
  71      $generator->parseSchema(dirname(XPDO_CORE_PATH) . "/model/schema/modx.registry.db.{$driver}.schema.xml", dirname(XPDO_CORE_PATH) . '/model/');
  72      $package= 'modx.sources';
  73      $generator->parseSchema(dirname(XPDO_CORE_PATH) . "/model/schema/modx.sources.{$driver}.schema.xml", dirname(XPDO_CORE_PATH) . '/model/');
  74  }
  75  
  76  $mtime= microtime();
  77  $mtime= explode(" ", $mtime);
  78  $mtime= $mtime[1] + $mtime[0];
  79  $tend= $mtime;
  80  $totalTime= ($tend - $tstart);
  81  $totalTime= sprintf("%2.4f s", $totalTime);
  82  
  83  echo "\nExecution time: {$totalTime}\n";
  84  
  85  exit ();

title

Description

title

Description

title

Description

title

title

Body