Parsing Error
MODX_CORE_PATH not defined! Did you include the correct config file?
'); exit; } require_once MODX_CORE_PATH . 'config/config.inc.php'; $xpdo_path = strtr(MODX_CORE_PATH . 'xpdo/xpdo.class.php', '\\', '/'); include_once ( $xpdo_path ); // A few definitions of files/folders: $package_dir = MODX_CORE_PATH . "components/$package_name/"; $model_dir = MODX_CORE_PATH . "components/$package_name/model/"; $class_dir = MODX_CORE_PATH . "components/$package_name/model/$package_name"; $schema_dir = MODX_CORE_PATH . "components/$package_name/model/schema"; $mysql_class_dir = MODX_CORE_PATH . "components/$package_name/model/$package_name/mysql"; $xml_schema_file = MODX_CORE_PATH . "components/$package_name/model/schema/$package_name.mysql.schema.xml"; // A few variables used to track execution times. $mtime= microtime(); $mtime= explode(' ', $mtime); $mtime= $mtime[1] + $mtime[0]; $tstart= $mtime; // Validations if ( empty($package_name) ) { print_msg('The $package_name cannot be empty! Please adjust the configuration and try again.
'); exit; } // Create directories if necessary $dirs = array($package_dir, $schema_dir ,$mysql_class_dir, $class_dir); foreach ($dirs as $d) { if ( !file_exists($d) ) { if ( !mkdir($d, 0777, true) ) { print_msg( sprintf('Error creating %s
Create the directory (and its parents) and try again.
' , $d )); exit; } } if ( !is_writable($d) ) { print_msg( sprintf('The %s
directory is not writable by PHP.
Adjust the permissions and try again.
' , $d)); exit; } } print_msg( sprintf('%s
', $package_dir));
if (file_exists($xml_schema_file)) {
print_msg( sprintf('%s
',$xml_schema_file));
}
$xpdo = new xPDO("mysql:host=$database_server;dbname=$dbase", $database_user, $database_password, $table_prefix);
$xpdo->setLogLevel(xPDO::LOG_LEVEL_INFO);
$xpdo->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
$manager = $xpdo->getManager();
$generator = $manager->getGenerator();
// Use this to generate classes and maps from your schema
if ($regenerate_classes) {
print_msg('$class_dir
for your newly generated class files!");
exit();
//------------------------------------------------------------------------------
//! FUNCTIONS
//------------------------------------------------------------------------------
/**
* Deletes the MODX class files in a given directory.
*
* @param string $dir: full path to directory containing class files you wish to delete.
* @return void
*/
function delete_class_files($dir) {
global $verbose;
$all_files = scandir($dir);
foreach ( $all_files as $f ) {
if ( preg_match('#\.class\.php$#i', $f) || preg_match('#\.map\.inc\.php$#i', $f)) {
if ( unlink("$dir/$f") ) {
if ($verbose) {
print_msg( sprintf('%s/%s
',$dir,$f) );
}
}
else {
print_msg( sprintf('%s/%s
',$dir,$f) );
}
}
}
}
/**
* Formats/prints messages. HTML is stripped if this is run via the command line.
*
* @param string $msg to be printed
* @return void this actually prints data to stdout
*/
function print_msg($msg) {
if ( php_sapi_name() == 'cli' ) {
$msg = preg_replace('#