Ejemplo n.º 1
0
$root = dirname(dirname(__FILE__)) . '/';
$sources = array('root' => $root, 'build' => $root . '_build/', 'data' => $root . '_build/data/', 'resolvers' => $root . '_build/resolvers/', 'chunks' => $root . 'core/components/' . PKG_NAME_LOWER . '/chunks/', 'lexicon' => $root . 'core/components/' . PKG_NAME_LOWER . '/lexicon/', 'docs' => $root . 'core/components/' . PKG_NAME_LOWER . '/docs/', 'elements' => $root . 'core/components/' . PKG_NAME_LOWER . '/elements/', 'source_assets' => $root . 'assets/components/' . PKG_NAME_LOWER, 'source_core' => $root . 'core/components/' . PKG_NAME_LOWER);
unset($root);
/* override with your own defines here (see build.config.sample.php) */
require_once $sources['build'] . 'build.config.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
echo '<pre>';
/* used for nice formatting of log messages */
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget('ECHO');
$modx->loadClass('transport.modPackageBuilder', '', false, true);
$builder = new modPackageBuilder($modx);
$builder->directory = dirname(dirname(__FILE__)) . '/_package/';
$builder->createPackage(PKG_EXTRA_NAME, PKG_VERSION, PKG_RELEASE);
$builder->registerNamespace(PKG_NAME_LOWER, false, true, '{core_path}components/' . PKG_NAME_LOWER . '/');
//-- CREATE THE CATEGORY OBJECT
$category = $modx->newObject('modCategory');
$category->set('id', 1);
$category->set('category', PKG_NAME);
/* add snippets */
$modx->log(modX::LOG_LEVEL_INFO, 'Packaging in snippets...');
$snippets = (include $sources['data'] . 'transport.snippets.php');
if (empty($snippets)) {
    $modx->log(modX::LOG_LEVEL_ERROR, 'Could not package in snippets.');
}
$category->addMany($snippets);
/* add chunks */
$chunks = (include $sources['data'] . 'transport.chunks.php');
if (is_array($chunks)) {
Ejemplo n.º 2
0
unset($root); /* save memory */

require_once dirname(dirname(dirname(__FILE__))) . '/core/config/config.inc.php';

define('MODX_CONFIG_KEY','config');

require_once MODX_CORE_PATH . 'model/modx/modx.class.php';

$modx= new modX();
$modx->initialize('mgr');
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');

$modx->loadClass('transport.modPackageBuilder','',false, true);
$builder = new modPackageBuilder($modx);
$builder->createPackage('visioncart', '0.6.1', 'rc4');
$builder->registerNamespace('visioncart', false, true, '{core_path}components/visioncart/');
 
// Add system settings
require_once(dirname(__FILE__).'/builder.systemsettings.php');

// Add system settings
require_once(dirname(__FILE__).'/builder.plugins.php');

// Add categories+snippets+chunks and create file vehicle
require_once(dirname(__FILE__).'/builder.categories.php');

// Add files to the category vehicle and put the category vehicle into the builder
require_once(dirname(__FILE__).'/builder.files.php');

// Add modMenu and modAction
$root = dirname(dirname(__FILE__)) . '/';
$sources = array('root' => $root, 'build' => $root . '_build/', 'data' => $root . '_build/data/', 'resolvers' => $root . '_build/resolvers/', 'chunks' => $root . 'core/components/' . PKG_NAME_LOWER . '/elements/chunks/', 'snippets' => $root . 'core/components/' . PKG_NAME_LOWER . '/elements/snippets/', 'plugins' => $root . 'core/components/' . PKG_NAME_LOWER . '/elements/plugins/', 'lexicon' => $root . 'core/components/' . PKG_NAME_LOWER . '/lexicon/', 'docs' => $root . 'core/components/' . PKG_NAME_LOWER . '/docs/', 'pages' => $root . 'core/components/' . PKG_NAME_LOWER . '/elements/pages/', 'source_assets' => $root . 'assets/components/' . PKG_NAME_LOWER, 'source_core' => $root . 'core/components/' . PKG_NAME_LOWER);
unset($root);
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
require_once $sources['build'] . '/includes/functions.php';
$modx = new modX();
$modx->initialize('mgr');
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget('ECHO');
$modx->getService('error', 'error.modError');
$modx->loadClass('transport.modPackageBuilder', '', false, true);
if (!XPDO_CLI_MODE) {
    echo '<pre>';
}
$builder = new modPackageBuilder($modx);
$builder->createPackage(PKG_NAME_LOWER, PKG_VERSION, PKG_RELEASE);
$builder->registerNamespace(PKG_NAME_LOWER, false, true, PKG_NAMESPACE_PATH);
$modx->log(modX::LOG_LEVEL_INFO, 'Created Transport Package and Namespace.');
/* load system settings */
if (defined('BUILD_SETTING_UPDATE')) {
    $settings = (include $sources['data'] . 'transport.settings.php');
    if (!is_array($settings)) {
        $modx->log(modX::LOG_LEVEL_ERROR, 'Could not package in settings.');
    } else {
        $attributes = array(xPDOTransport::UNIQUE_KEY => 'key', xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => BUILD_SETTING_UPDATE);
        foreach ($settings as $setting) {
            $vehicle = $builder->createVehicle($setting, $attributes);
            $builder->putVehicle($vehicle);
        }
        $modx->log(modX::LOG_LEVEL_INFO, 'Packaged in ' . count($settings) . ' System Settings.');
    }
Ejemplo n.º 4
0
 $modx->log(modX::LOG_LEVEL_INFO, "assets_path=" . $assets_path);
 $modx->log(modX::LOG_LEVEL_INFO, "manager_path=" . $manager_path);
 $modx->log(modX::LOG_LEVEL_INFO, "base_path=" . $base_path);
 $modx->loadClass('transport.modPackageBuilder', '', false, true);
 $builder = new modPackageBuilder($modx);
 /** @var modWorkspace $workspace */
 $workspace = $modx->getObject('modWorkspace', 1);
 if (!$workspace) {
     $modx->log(modX::LOG_LEVEL_FATAL, "no workspace!");
 }
 if (!defined('PKG_NAME')) {
     define('PKG_NAME', $modx->getOption('http_host', $options, 'cloud_import'));
 }
 define('PKG_VERSION', strftime("%y%m%d.%H%M.%S", $startTime));
 define('PKG_RELEASE', $modxVersion);
 $package = $builder->createPackage(PKG_NAME, PKG_VERSION, PKG_RELEASE);
 /* Defines the classes to extract (also used for truncation) */
 $classes = array('modAccessAction', 'modAccessActionDom', 'modAccessCategory', 'modAccessContext', 'modAccessElement', 'modAccessMenu', 'modAccessPermission', 'modAccessPolicy', 'modAccessPolicyTemplate', 'modAccessPolicyTemplateGroup', 'modAccessResource', 'modAccessResourceGroup', 'modAccessTemplateVar', 'modAction', 'modActionDom', 'modActionField', 'modActiveUser', 'modCategory', 'modCategoryClosure', 'modChunk', 'modClassMap', 'modContentType', 'modContext', 'modContextResource', 'modContextSetting', 'modElementPropertySet', 'modEvent', 'modFormCustomizationProfile', 'modFormCustomizationProfileUserGroup', 'modFormCustomizationSet', 'modLexiconEntry', 'modManagerLog', 'modMenu', 'modNamespace', 'modPlugin', 'modPluginEvent', 'modPropertySet', 'modResource', 'modResourceGroup', 'modResourceGroupResource', 'modSession', 'modSnippet', 'modSystemSetting', 'modTemplate', 'modTemplateVar', 'modTemplateVarResource', 'modTemplateVarResourceGroup', 'modTemplateVarTemplate', 'modUser', 'modUserProfile', 'modUserGroup', 'modUserGroupMember', 'modUserGroupRole', 'modUserMessage', 'modUserSetting', 'modWorkspace', 'registry.db.modDbRegisterMessage', 'registry.db.modDbRegisterTopic', 'registry.db.modDbRegisterQueue', 'transport.modTransportProvider', 'transport.modTransportPackage');
 if (version_compare($modxVersion, '2.2.0', '>=')) {
     array_push($classes, 'modDashboard', 'modDashboardWidget', 'modDashboardWidgetPlacement', 'sources.modAccessMediaSource', 'sources.modMediaSource', 'sources.modMediaSourceElement', 'sources.modMediaSourceContext');
 }
 $attributes = array('vehicle_class' => 'xPDOFileVehicle');
 /* get all files from the components directory */
 $modx->log(modX::LOG_LEVEL_INFO, "Packaging " . MODX_CORE_PATH . 'components');
 $package->put(array('source' => MODX_CORE_PATH . 'components', 'target' => 'return MODX_CORE_PATH;'), array('vehicle_class' => 'xPDOFileVehicle'));
 /* get all files from the assets directory */
 $modx->log(modX::LOG_LEVEL_INFO, "Packaging " . MODX_BASE_PATH . 'assets');
 $package->put(array('source' => MODX_BASE_PATH . 'assets', 'target' => 'return MODX_BASE_PATH;'), array('vehicle_class' => 'xPDOFileVehicle'));
 /* get all files from the manager/components directory */
 $modx->log(modX::LOG_LEVEL_INFO, "Packaging " . MODX_MANAGER_PATH . 'components');
 $package->put(array('source' => MODX_MANAGER_PATH . 'components', 'target' => 'return MODX_MANAGER_PATH;'), array('vehicle_class' => 'xPDOFileVehicle'));
Ejemplo n.º 5
0
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tstart = $mtime;
set_time_limit(0);
$root = dirname(dirname(__FILE__)) . '/';
$sources = array('root' => $root, 'build' => $root . '_build/', 'elements' => $root . 'core/components/debugtoolbar/elements/', 'data' => $root . '_build/data/', 'source_core' => $root . 'core/components/debugtoolbar', 'source_assets' => $root . 'assets/components/debugtoolbar');
unset($root);
require_once dirname(__FILE__) . '/build.config.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
$modx->loadClass('transport.modPackageBuilder', '', false, true);
$builder = new modPackageBuilder($modx);
$builder->createPackage('debugtoolbar', '0.1', 'alpha');
$builder->registerNamespace('debugtoolbar', false, true, '{core_path}components/debugtoolbar/');
$settings = (include $sources['data'] . 'transport.settings.php');
$attributes = array(xPDOTransport::UNIQUE_KEY => 'key', xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => false);
foreach ($settings as $setting) {
    $vehicle = $builder->createVehicle($setting, $attributes);
    $builder->putVehicle($vehicle);
}
unset($settings, $setting, $attributes);
$category = $modx->newObject('modCategory');
$category->set('category', 'DebugToolbar');
$plugins = (include $sources['data'] . 'transport.plugins.php');
if (!is_array($plugins)) {
    $modx->log(modX::LOG_LEVEL_FATAL, 'Adding plugins failed.');
}
$attributes = array(xPDOTransport::UNIQUE_KEY => 'name', xPDOTransport::PRESERVE_KEYS => false, xPDOTransport::UPDATE_OBJECT => true, xPDOTransport::RELATED_OBJECTS => true, xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array('PluginEvents' => array(xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => false, xPDOTransport::UNIQUE_KEY => array('pluginid', 'event'))));
Ejemplo n.º 6
0
define('MODX_ROOT', $root);
$sources = array('root' => $root, 'build' => $root . '_build/', 'data' => $root . '_build/data/', 'resolvers' => $root . '_build/resolvers/', 'validators' => $root . '_build/validators/', 'subpackages' => $root . '_build/subpackages/', 'chunks' => $root . 'core/components/' . PKG_ABBR . '/elements/chunks/', 'snippets' => $root . 'core/components/' . PKG_ABBR . '/elements/snippets/', 'plugins' => $root . 'core/components/' . PKG_ABBR . '/elements/plugins/', 'lexicon' => $root . 'core/components/' . PKG_ABBR . '/lexicon/', 'docs' => $root . 'core/components/' . PKG_ABBR . '/docs/', 'pages' => $root . 'core/components/' . PKG_ABBR . '/elements/pages/', 'source_assets' => $root . 'assets/components/' . PKG_ABBR, 'source_core' => $root . 'core/components/' . PKG_ABBR);
unset($root);
/* override with your own defines here (see build.config.sample.php) */
require_once $sources['build'] . '/build.config.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
require_once $sources['build'] . '/includes/functions.php';
$modx = new modX();
$modx->initialize('mgr');
echo '<pre>';
/* used for nice formatting of log messages */
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget('ECHO');
$modx->loadClass('transport.modPackageBuilder', '', false, true);
$builder = new modPackageBuilder($modx);
$builder->createPackage(PKG_ABBR, PKG_VERSION, PKG_RELEASE);
$builder->registerNamespace(PKG_ABBR, false, true, '{core_path}components/' . PKG_ABBR . '/');
$modx->log(modX::LOG_LEVEL_INFO, 'Created Transport Package and Namespace.');
/* create category */
$category = $modx->newObject('modCategory');
$category->set('id', 1);
$category->set('category', PKG_NAME);
/* add subpackages */
$success = (include $sources['data'] . 'transport.subpackages.php');
if (!$success) {
    $modx->log(modX::LOG_LEVEL_FATAL, 'Adding subpackages failed.');
}
$modx->log(modX::LOG_LEVEL_INFO, 'Added in subpackages.');
flush();
unset($success);
/* add chunks */
Ejemplo n.º 7
0
/* get rid of time limit */
set_time_limit(0);
$root = dirname(dirname(__FILE__)) . '/';
$sources = array('root' => $root, 'build' => $root . '_build/', 'data' => $root . '_build/data/', 'docs' => $root . 'core/components/wayfinder/docs/', 'source_core' => $root . 'core/components/wayfinder');
/* override with your own defines here (see build.config.sample.php) */
require_once $sources['build'] . 'build.config.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
echo '<pre>';
/* used for nice formatting of log messages */
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget('ECHO');
$modx->loadClass('transport.modPackageBuilder', '', false, true);
$builder = new modPackageBuilder($modx);
$builder->createPackage('wayfinder', '2.1.1', 'rc1');
$builder->registerNamespace('wayfinder', false, true, '{core_path}components/wayfinder/');
/* get the source from the actual snippet in your database
 * [alternative] you could also manually create the object, grabbing the source
 * from a file
 */
$c = $modx->newObject('modSnippet');
$c->set('id', 1);
$c->set('name', 'Wayfinder');
$c->set('description', 'Wayfinder for MODx Revolution 2.0.0-beta-5 and later.');
$c->set('snippet', file_get_contents($sources['source_core'] . '/wayfinder.snippet.php'));
$c->set('category', 0);
$properties = (include $sources['data'] . 'properties.inc.php');
$c->setProperties($properties, true);
$attributes = array(xPDOTransport::UNIQUE_KEY => 'name', xPDOTransport::PRESERVE_KEYS => false, xPDOTransport::UPDATE_OBJECT => true);
$vehicle = $builder->createVehicle($c, $attributes);
Ejemplo n.º 8
0
require_once dirname(__FILE__) . '/build.config.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
$modx->setDebug(false);
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
echo '<pre>';
$modx->setLogTarget('ECHO');
error_reporting(E_ALL);
ini_set('display_errors', true);
$name = 'provisioner';
$version = '1.1.0';
$release = 'pl';
$modx->loadClass('transport.modPackageBuilder', '', false, true);
$builder = new modPackageBuilder($modx);
$builder->createPackage($name, $version, $release);
$builder->registerNamespace('provisioner', false, true, '{core_path}components/provisioner/');
$base = dirname(dirname(__FILE__)) . '/';
$sources = array('root' => $base, 'assets' => $base . 'assets/components/provisioner/', 'docs' => $base . 'assets/components/provisioner/docs/', 'core' => $base . 'core/components/provisioner/', 'lexicon' => $base . 'core/components/provisioner/lexicon/', 'model' => $base . 'core/components/provisioner/model/', 'templates' => $base . 'core/components/provisioner/templates/', 'build' => $base . '_build/', 'data' => $base . '_build/data/', 'resolvers' => $base . '_build/resolvers/', 'source_core' => $base . 'core/components/provisioner', 'source_assets' => $base . 'assets/components/provisioner');
unset($base);
$vehicles = array();
/* ACTIONS */
$menu = (require_once $sources['data'] . 'actions.data.php');
if (!$menu) {
    $modx->log(xPDO::LOG_LEVEL_FATAL, 'Menu not found!');
}
$attr = array(xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => true, xPDOTransport::UNIQUE_KEY => 'text', xPDOTransport::RELATED_OBJECTS => true, xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array('Action' => array(xPDOTransport::PRESERVE_KEYS => false, xPDOTransport::UPDATE_OBJECT => true, xPDOTransport::UNIQUE_KEY => array('namespace', 'controller'))));
$vehicle = $builder->createVehicle($menu, $attr);
$vehicles[] = $vehicle;
/* SETTINGS */
require_once $sources['data'] . 'settings.data.php';
Ejemplo n.º 9
0
/**
 * @package modx
 * @subpackage processors.workspace.builder
 */
$modx->lexicon->load('workspace', 'package_builder');
if (!$modx->hasPermission('package_builder')) {
    return $modx->error->failure($modx->lexicon('permission_denied'));
}
$_PACKAGE =& $_SESSION['modx.pb'];
/* load the modPackageBuilder class and get an instance */
$modx->log(MODX_LOG_LEVEL_INFO, 'Loading package builder.');
$modx->loadClass('transport.modPackageBuilder', '', false, true);
$builder = new modPackageBuilder($modx);
/* create a new package */
$modx->log(MODX_LOG_LEVEL_INFO, 'Creating a new package: ' . $_PACKAGE['name'] . '-' . $_PACKAGE['version'] . '-' . $_PACKAGE['release']);
$builder->createPackage($_PACKAGE['name'], $_PACKAGE['version'], $_PACKAGE['release']);
$builder->registerNamespace($_PACKAGE['namespace'], $_PACKAGE['autoselects']);
/* define some locations for file resources */
$sources = array('root' => dirname(dirname(__FILE__)) . '/', 'assets' => dirname(dirname(__FILE__)) . '/assets/');
/* set up some default attributes that define install behavior */
$attributes = array(xPDOTransport::UNIQUE_KEY => 'name', xPDOTransport::PRESERVE_KEYS => false, xPDOTransport::UPDATE_OBJECT => true, xPDOTransport::RESOLVE_FILES => true, xPDOTransport::RESOLVE_PHP => true);
$modx->log(modX::LOG_LEVEL_INFO, 'Loading vehicles into package.');
foreach ($_PACKAGE['vehicles'] as $vehicle) {
    $c = $modx->getObject($vehicle['class_key'], $vehicle['object']);
    if ($c == null) {
        continue;
    }
    if (!isset($vehicle['attributes'])) {
        $vehicle['attributes'] = array();
    }
    $attr = array_merge($attributes, $vehicle['attributes']);
Ejemplo n.º 10
0
$mtime = $mtime[1] + $mtime[0];
$tstart = $mtime;
set_time_limit(0);
$root = dirname(dirname(__FILE__)) . '/';
$sources = array('root' => $root, 'build' => $root . '_build/', 'lexicon' => $root . '_build/lexicon/', 'resolvers' => $root . '_build/resolvers/', 'data' => $root . '_build/data/', 'source_core' => $root . 'core/components/xflickr', 'source_assets' => $root . 'assets/components/xflickr', 'docs' => $root . 'core/components/xflickr/docs/');
unset($root);
/* override with your own defines here (see build.config.sample.php) */
require_once dirname(__FILE__) . '/build.config.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
$modx->setLogLevel(MODX_LOG_LEVEL_INFO);
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
$modx->loadClass('transport.modPackageBuilder', '', false, true);
$builder = new modPackageBuilder($modx);
$builder->createPackage('xflickr', '0.1', 'alpha1');
$builder->registerNamespace('xflickr', false, true, '{core_path}components/xflickr/');
/* load action/menu */
$menu = (include $sources['data'] . 'transport.menu.php');
$vehicle = $builder->createVehicle($menu, array(XPDO_TRANSPORT_PRESERVE_KEYS => true, XPDO_TRANSPORT_UPDATE_OBJECT => true, XPDO_TRANSPORT_UNIQUE_KEY => 'text', XPDO_TRANSPORT_RELATED_OBJECTS => true, XPDO_TRANSPORT_RELATED_OBJECT_ATTRIBUTES => array('Action' => array(XPDO_TRANSPORT_PRESERVE_KEYS => false, XPDO_TRANSPORT_UPDATE_OBJECT => true, XPDO_TRANSPORT_UNIQUE_KEY => array('namespace', 'controller')))));
$builder->putVehicle($vehicle);
unset($vehicle, $action);
/* load system settings */
$settings = array();
include_once $sources['data'] . 'transport.settings.php';
$attributes = array(XPDO_TRANSPORT_UNIQUE_KEY => 'key', XPDO_TRANSPORT_PRESERVE_KEYS => true, XPDO_TRANSPORT_UPDATE_OBJECT => false);
foreach ($settings as $setting) {
    $vehicle = $builder->createVehicle($setting, $attributes);
    $builder->putVehicle($vehicle);
}
unset($settings, $setting, $attributes);
Ejemplo n.º 11
0
 /**
  * Unified build script: build a MODX transport package from files contained
  * inside $pkg_root_dir
  *
  * @param string $pkg_root_dir path to local package root (w trailing slash)
  *
  * @throws Exception
  */
 public function build($pkg_root_dir)
 {
     $pkg_root_dir = self::get_dir($pkg_root_dir);
     $this->build_prep($pkg_root_dir);
     $this->config['is_build'] = true;
     // TODO
     $this->config['force_static'] = false;
     // TODO
     $required = array('package_name', 'namespace', 'version', 'release');
     foreach ($required as $k) {
         if (!$this->get($k)) {
             throw new Exception('Missing required configuration parameter: ' . $k);
         }
     }
     $this->modx->log(modX::LOG_LEVEL_INFO, 'Beginning build of package "' . $this->get('package_name') . '"');
     $this->modx->loadClass('transport.modPackageBuilder', '', false, true);
     $builder = new modPackageBuilder($this->modx);
     $sanitized_package_name = $this->get('package_name');
     $builder->createPackage($sanitized_package_name, $this->get('version'), $this->get('release'));
     $builder->registerNamespace($this->get('namespace'), false, true, '{core_path}components/' . $this->get('namespace') . '/');
     // Tests (Validators): this is run BEFORE your package code is in place
     // so you cannot reference/include package files from your validator! They won't exist when the code is run.
     $validator_file = $this->get_core_path($pkg_root_dir) . rtrim($this->get('validators_dir'), '/') . '/install.php';
     if (file_exists($validator_file)) {
         $this->modx->log(modX::LOG_LEVEL_INFO, 'Packaging validator ' . $validator_file);
         $config = $this->config;
         $config['source'] = $validator_file;
         $validator_attributes = array('vehicle_class' => 'xPDOScriptVehicle', 'source' => $validator_file, xPDOTransport::ABORT_INSTALL_ON_VEHICLE_FAIL => $this->get('abort_install_on_fail'));
         $vehicle = $builder->createVehicle($config, $validator_attributes);
         $builder->putVehicle($vehicle);
     } else {
         $this->modx->log(modX::LOG_LEVEL_DEBUG, 'No validator detected at ' . $validator_file);
     }
     $Category = $this->modx->newObject('modCategory');
     $Category->set('category', $this->get('category'));
     // Import Elements
     $chunks = self::_get_elements('modChunk', $pkg_root_dir);
     $plugins = self::_get_elements('modPlugin', $pkg_root_dir);
     $snippets = self::_get_elements('modSnippet', $pkg_root_dir);
     $tvs = self::_get_elements('modTemplateVar', $pkg_root_dir);
     $templates = self::_get_elements('modTemplate', $pkg_root_dir);
     if ($chunks) {
         $Category->addMany($chunks);
     }
     if ($plugins) {
         $Category->addMany($plugins);
     }
     if ($snippets) {
         $Category->addMany($snippets);
     }
     if ($templates) {
         $Category->addMany($templates);
     }
     if ($tvs) {
         $Category->addMany($tvs);
     }
     // TODO: skip this if there are no elements
     //if (empty($chunks) && empty($plugins) && empty($snippets) && empty($templates) && empty($tvs)) {
     $build_attributes = array();
     $build_attributes = $this->get_build_attributes($Category, 'modCategory');
     $this->modx->log(modX::LOG_LEVEL_DEBUG, 'build_attributes for ' . $Category->_class . "\n" . print_r($build_attributes, true));
     $vehicle = $builder->createVehicle($Category, $build_attributes);
     //}
     //$builder->putVehicle($vehicle);
     // Files...: TODO: these need their own builder
     // We package these from the temporary copies inside of repoman's cache.
     // Assets
     if (file_exists($this->build_assets_path) && is_dir($this->build_assets_path)) {
         $this->modx->log(modX::LOG_LEVEL_INFO, 'Packing assets from ' . $this->build_assets_path);
         $vehicle->resolve('file', array('source' => rtrim($this->build_assets_path, '/'), 'target' => "return MODX_ASSETS_PATH . 'components/';"));
     }
     // Core
     if (file_exists($this->build_core_path) && is_dir($this->build_core_path)) {
         $this->modx->log(modX::LOG_LEVEL_INFO, 'Packing core files from ' . $this->build_core_path);
         $vehicle->resolve('file', array('source' => rtrim($this->build_core_path, '/'), 'target' => "return MODX_CORE_PATH . 'components/';"));
     }
     $builder->putVehicle($vehicle);
     // Migrations: we attach our all-purpose resolver to handle migrations
     $config = $this->config;
     $config['source'] = dirname(__FILE__) . '/resolver.php';
     $attributes = array('vehicle_class' => 'xPDOScriptVehicle');
     $vehicle = $builder->createVehicle($config, $attributes);
     $builder->putVehicle($vehicle);
     // Add Version Setting
     $repoman_version_build_attributes = array(xPDOTransport::UNIQUE_KEY => 'key', xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => true);
     $VersionSetting = $this->modx->newObject('modSystemSetting');
     $VersionSetting->set('key', $this->get('namespace') . '.version');
     $VersionSetting->set('value', $this->get('version'));
     $VersionSetting->set('xtype', 'textfield');
     $VersionSetting->set('namespace', $this->get('namespace'));
     $VersionSetting->set('area', $this->get('namespace') . ':default');
     $vehicle = $builder->createVehicle($VersionSetting, $repoman_version_build_attributes);
     $builder->putVehicle($vehicle);
     // Optionally Load Seed data
     $dirs = $this->get_seed_dirs($pkg_root_dir);
     foreach ($dirs as $d) {
         $objects = $this->crawl_dir($d);
         foreach ($objects as $classname => $info) {
             foreach ($info as $k => $Obj) {
                 $build_attributes = $this->get_build_attributes($Obj, $classname);
                 $this->modx->log(modX::LOG_LEVEL_DEBUG, $classname . ' created');
                 $vehicle = $builder->createVehicle($Obj, $build_attributes);
                 $builder->putVehicle($vehicle);
             }
         }
     }
     // Package Attributes (Documents)
     $dir = $this->get_docs_path($pkg_root_dir);
     // defaults
     $docs = array('readme' => 'This package was built using Repoman (https://github.com/craftsmancoding/repoman/)', 'changelog' => 'No change log defined.', 'license' => file_get_contents(dirname(dirname(dirname(__FILE__))) . '/docs/license.txt'));
     if (file_exists($dir) && is_dir($dir)) {
         $files = array();
         $build_docs = $this->get('build_docs');
         if (!empty($build_docs) && is_array($build_docs)) {
             foreach ($build_docs as $d) {
                 $files[] = $dir . $d;
             }
         } else {
             $files = glob($dir . '*.{html,txt}', GLOB_BRACE);
         }
         foreach ($files as $f) {
             $stub = basename($f, '.txt');
             $stub = basename($stub, '.html');
             $docs[$stub] = file_get_contents($f);
             if (strtolower($stub) == 'readme') {
                 $docs['readme'] = $docs['readme'] . "\n\n" . 'This package was built using Repoman (https://github.com/craftsmancoding/repoman/)';
             }
             $this->modx->log(modX::LOG_LEVEL_INFO, "Adding doc {$stub} from {$f}");
         }
     } else {
         $this->modx->log(modX::LOG_LEVEL_INFO, 'No documents found in ' . $dir);
     }
     $builder->setPackageAttributes($docs);
     // Zip up the package
     $builder->pack();
     $zip = strtolower($sanitized_package_name) . '-' . $this->get('version') . '-' . $this->get('release') . '.transport.zip';
     $this->modx->log(modX::LOG_LEVEL_INFO, 'Build complete: ' . MODX_CORE_PATH . 'packages/' . $zip);
     if (!file_exists(MODX_CORE_PATH . 'packages/' . $zip)) {
         throw new Exception('Transport package not created: ' . $zip . ' Please review the logs.');
     }
 }
Ejemplo n.º 12
0
$root = dirname(dirname(__FILE__)) . '/';
$sources = array('root' => $root, 'build' => $root . '_build/', 'resolvers' => $root . '_build/resolvers/', 'data' => $root . '_build/data/', 'source_core' => $root . 'core/components/churchevents/', 'lexicon' => $root . 'core/components/churchevents/lexicon/', 'source_assets' => $root . 'assets/components/churchevents/', 'docs' => $root . 'core/components/churchevents/docs/');
unset($root);
/* save memory */
require_once dirname(__FILE__) . '/build.config.php';
// The MODx class:
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
/* Okay, it's time for the meat. Let's first off use $modx->loadClass to load the modPackageBuilder class. Then we'll instantiate an instance of it, and create a package.
*/
$modx->loadClass('transport.modPackageBuilder', '', false, true);
$builder = new modPackageBuilder($modx);
$builder->createPackage('churchevents', '0.3', 'beta2');
//name, version, and release
$builder->registerNamespace('churchevents', false, true, '{core_path}components/churchevents/');
// create system settings:
$settings = array();
$settings['churchevents.allowRequests'] = $modx->newObject('modSystemSetting');
$settings['churchevents.allowRequests']->fromArray(array('key' => 'churchevents.allowRequests', 'value' => false, 'xtype' => 'combo-boolean', 'namespace' => 'churchevents', 'area' => 'ChurchEvents'), '', true, true);
$attributes = array(xPDOTransport::UNIQUE_KEY => 'key', xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => false);
if (!is_array($settings)) {
    $modx->log(modX::LOG_LEVEL_FATAL, 'Adding settings failed.');
}
foreach ($settings as $setting) {
    $vehicle = $builder->createVehicle($setting, $attributes);
    $builder->putVehicle($vehicle);
}
$modx->log(modX::LOG_LEVEL_INFO, 'Packaged in ' . count($settings) . ' system settings.');
Ejemplo n.º 13
0
);

unset($root); // save memory

require_once dirname(__FILE__) . '/build.config.php';

require_once MODX_CORE_PATH . 'model/modx/modx.class.php';

$modx= new modX();
$modx->initialize('mgr');
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');

$modx->loadClass('transport.modPackageBuilder','',false, true);
$builder = new modPackageBuilder($modx);
$builder->createPackage('modmobile','0.1','alpha');
//$builder->registerNamespace('modmobile',false,true,'{core_path}components/modmobile/');

/* create category */
$category= $modx->newObject('modCategory');
$category->set('id',1);
$category->set('category','modMobile');

include $sources['data'].'transport.plugins.php';
$category->addMany($plugins);

/* create category vehicle */
$attr = array(
    xPDOTransport::UNIQUE_KEY => 'category',
    xPDOTransport::PRESERVE_KEYS => false,
    xPDOTransport::UPDATE_OBJECT => true,
Ejemplo n.º 14
0
 public function process()
 {
     //$startTime = microtime(true);
     try {
         $vaporOptions = array('excludeExtraTablePrefix' => array(), 'excludeExtraTables' => array(), 'excludeFiles' => array(MODX_BASE_PATH . 'vapor', MODX_BASE_PATH . 'phpmyadmin', MODX_BASE_PATH . 'assets', MODX_BASE_PATH . 'core'));
         if (is_readable(VAPOR_DIR . 'config.php')) {
             $vaporConfigOptions = @(include VAPOR_DIR . 'config.php');
             if (is_array($vaporConfigOptions)) {
                 $vaporOptions = array_merge($vaporOptions, $vaporConfigOptions);
             }
         }
         if (!XPDO_CLI_MODE && !ini_get('safe_mode')) {
             set_time_limit(0);
         }
         $options = array('log_level' => xPDO::LOG_LEVEL_INFO, 'log_target' => array('target' => 'FILE', 'options' => array('filename' => 'vapor-' . strftime('%Y%m%dT%H%M%S', $this->getProperty('startTime')) . '.log')), xPDO::OPT_CACHE_DB => false, xPDO::OPT_SETUP => true);
         $modx = new modX('', $options);
         $modx->setLogTarget($options['log_target']);
         $modx->setLogLevel($options['log_level']);
         $modx->setOption(xPDO::OPT_CACHE_DB, false);
         $modx->setOption(xPDO::OPT_SETUP, true);
         $modx->setDebug(-1);
         $modx->startTime = $this->getProperty('startTime');
         $modx->getVersionData();
         $modxVersion = $modx->version['full_version'];
         if (version_compare($modxVersion, '2.2.1-pl', '>=')) {
             $modx->initialize('mgr', $options);
         } else {
             $modx->initialize('mgr');
         }
         /*$modx->setLogTarget($options['log_target']);
           $modx->setLogLevel($options['log_level']);*/
         $modx->setOption(xPDO::OPT_CACHE_DB, false);
         $modx->setOption(xPDO::OPT_SETUP, true);
         $modx->setDebug(-1);
         $modxDatabase = $modx->getOption('dbname', $options, $modx->getOption('database', $options));
         $modxTablePrefix = $modx->getOption('table_prefix', $options, '');
         $core_path = realpath($modx->getOption('core_path', $options, MODX_CORE_PATH)) . '/';
         $assets_path = realpath($modx->getOption('assets_path', $options, MODX_ASSETS_PATH)) . '/';
         $manager_path = realpath($modx->getOption('manager_path', $options, MODX_MANAGER_PATH)) . '/';
         $base_path = realpath($modx->getOption('base_path', $options, MODX_BASE_PATH)) . '/';
         $modx->log(modX::LOG_LEVEL_INFO, "core_path=" . $core_path);
         $modx->log(modX::LOG_LEVEL_INFO, "assets_path=" . $assets_path);
         $modx->log(modX::LOG_LEVEL_INFO, "manager_path=" . $manager_path);
         $modx->log(modX::LOG_LEVEL_INFO, "base_path=" . $base_path);
         $modx->loadClass('transport.modPackageBuilder', '', false, true);
         $builder = new modPackageBuilder($modx);
         /** @var modWorkspace $workspace */
         $workspace = $modx->getObject('modWorkspace', 1);
         if (!$workspace) {
             $modx->log(modX::LOG_LEVEL_FATAL, "no workspace!");
         }
         $package = $builder->createPackage(PKG_NAME, PKG_VERSION, PKG_RELEASE);
         /* Defines the classes to extract (also used for truncation) */
         $classes = $this->getClassesList();
         $attributes = array('vehicle_class' => 'xPDOFileVehicle');
         /* get all files from the components directory */
         /*$modx->log(modX::LOG_LEVEL_INFO, "Packaging " . MODX_CORE_PATH . 'components');
           $package->put(
               array(
                   'source' => MODX_CORE_PATH . 'components',
                   'target' => 'return MODX_CORE_PATH;'
               ),
               array(
                   'vehicle_class' => 'xPDOFileVehicle'
               )
           );*/
         /* get all files from the assets directory */
         /*$modx->log(modX::LOG_LEVEL_INFO, "Packaging " . MODX_BASE_PATH . 'assets');
           $package->put(
               array(
                   'source' => MODX_BASE_PATH . 'assets',
                   'target' => 'return MODX_BASE_PATH;'
               ),
               array(
                   'vehicle_class' => 'xPDOFileVehicle'
               )
           );*/
         /* get all files from the manager/components directory */
         /*$modx->log(modX::LOG_LEVEL_INFO, "Packaging " . MODX_MANAGER_PATH . 'components');
           $package->put(
               array(
                   'source' => MODX_MANAGER_PATH . 'components',
                   'target' => 'return MODX_MANAGER_PATH;'
               ),
               array(
                   'vehicle_class' => 'xPDOFileVehicle'
               )
           );*/
         /* find other files/directories in the MODX_BASE_PATH */
         $excludes = array('_build', 'setup', 'assets', 'ht.access', 'index.php', 'config.core.php', dirname(MODX_CORE_PATH) . '/' === MODX_BASE_PATH ? basename(MODX_CORE_PATH) : 'core', dirname(MODX_CONNECTORS_PATH) . '/' === MODX_BASE_PATH ? basename(MODX_CONNECTORS_PATH) : 'connectors', dirname(MODX_MANAGER_PATH) . '/' === MODX_BASE_PATH ? basename(MODX_MANAGER_PATH) : 'manager');
         if (isset($vaporOptions['excludeFiles']) && is_array($vaporOptions['excludeFiles'])) {
             $excludes = array_unique($excludes + $vaporOptions['excludeFiles']);
         }
         /*if ($dh = opendir(MODX_BASE_PATH)) {
           $includes = array();
           while (($file = readdir($dh)) !== false) {
               /* ignore files/dirs starting with . or matching an exclude */
         /*if (strpos($file, '.') === 0 || in_array(strtolower($file), $excludes)) {
                       continue;
                   }
                   $includes[] = array(
                       'source' => MODX_BASE_PATH . $file,
                       'target' => 'return MODX_BASE_PATH;'
                   );
               }
               closedir($dh);
               foreach ($includes as $include) {
                   $modx->log(modX::LOG_LEVEL_INFO, "Packaging " . $include['source']);
                   $package->put(
                       $include,
                       array(
                           'vehicle_class' => 'xPDOFileVehicle'
                       )
                   );
               }
           }*/
         foreach ($this->getProperty('sources') as $source_id) {
             // Try to get mediaSource
             $loaded = $this->getSource($source_id);
             if ($loaded !== true) {
                 return $this->failure($loaded);
             }
             /* Why for??
                if (!$this->source->checkPolicy('delete')) {
                    return $this->failure($this->modx->lexicon('permission_denied'));
                }*/
             if ($properties = $this->source->getBases('') and $properties['pathIsRelative'] and $path = $properties['path']) {
                 if ($dh = opendir(MODX_BASE_PATH . $path)) {
                     $includes = array();
                     while (($file = readdir($dh)) !== false) {
                         /* ignore files/dirs starting with . or matching an exclude */
                         if (strpos($file, '.') === 0 || in_array(strtolower($file), $excludes)) {
                             continue;
                         }
                         $includes[] = array('source' => MODX_BASE_PATH . $path . $file, 'target' => "return MODX_BASE_PATH . '{$path}/';");
                     }
                     closedir($dh);
                     foreach ($includes as $include) {
                         $modx->log(modX::LOG_LEVEL_INFO, "Packaging " . $include['source']);
                         $package->put($include, array('vehicle_class' => 'xPDOFileVehicle'));
                     }
                 }
             }
         }
         if (!XPDO_CLI_MODE && !ini_get('safe_mode')) {
             set_time_limit(0);
         }
         /* package up the vapor model for use on install */
         $modx->log(modX::LOG_LEVEL_INFO, "Packaging vaporVehicle class");
         /*$package->put(
               array(
                   'source' => VAPOR_DIR . 'model/vapor',
                   'target' => "return MODX_CORE_PATH . 'components/vapor/model/';"
               ),
               array(
                   'vehicle_class' => 'xPDOFileVehicle',
                   'validate' => array(
                       array(
                           'type' => 'php',
                           'source' => VAPOR_DIR . 'scripts/validate.truncate_tables.php',
                           'classes' => $classes
                       ),
                   ),
                   'resolve' => array(
                       array(
                           'type' => 'php',
                           'source' => VAPOR_DIR . 'scripts/resolve.vapor_model.php'
                       )
                   )
               )
           );*/
         $attributes = array('preserve_keys' => true, 'update_object' => true);
         /* get the extension_packages and resolver */
         if ($this->getProperty('includeExtensionPackages')) {
             $object = $modx->getObject('modSystemSetting', array('key' => 'extension_packages'));
             if ($object) {
                 $extPackages = $object->get('value');
                 $extPackages = $modx->fromJSON($extPackages);
                 foreach ($extPackages as &$extPackage) {
                     if (!is_array($extPackage)) {
                         continue;
                     }
                     foreach ($extPackage as $pkgName => &$pkg) {
                         if (!empty($pkg['path']) && strpos($pkg['path'], '[[++') === false) {
                             if (substr($pkg['path'], 0, 1) !== '/' || strpos($pkg['path'], $base_path) !== 0 && strpos($pkg['path'], $core_path) !== 0) {
                                 $path = realpath($pkg['path']);
                                 if ($path === false) {
                                     $path = $pkg['path'];
                                 } else {
                                     $path = rtrim($path, '/') . '/';
                                 }
                             } else {
                                 $path = $pkg['path'];
                             }
                             if (strpos($path, $core_path) === 0) {
                                 $path = str_replace($core_path, '[[++core_path]]', $path);
                             } elseif (strpos($path, $assets_path) === 0) {
                                 $path = str_replace($assets_path, '[[++assets_path]]', $path);
                             } elseif (strpos($path, $manager_path) === 0) {
                                 $path = str_replace($manager_path, '[[++manager_path]]', $path);
                             } elseif (strpos($path, $base_path) === 0) {
                                 $path = str_replace($base_path, '[[++base_path]]', $path);
                             }
                             $pkg['path'] = $path;
                         }
                     }
                 }
                 $modx->log(modX::LOG_LEVEL_INFO, "Setting extension packages to: " . print_r($extPackages, true));
                 $object->set('value', $modx->toJSON($extPackages));
                 $package->put($object, array_merge($attributes, array('resolve' => array(array('type' => 'php', 'source' => VAPOR_DIR . 'scripts/resolve.extension_packages.php')))));
             }
         }
         /* loop through the classes and package the objects */
         foreach ($classes as $class) {
             if (!XPDO_CLI_MODE && !ini_get('safe_mode')) {
                 set_time_limit(0);
             }
             $instances = 0;
             $classCriteria = null;
             $classAttributes = $attributes;
             switch ($class) {
                 case 'modSession':
                     /* skip sessions */
                     continue 2;
                 case 'modSystemSetting':
                     $classCriteria = array('key:!=' => 'extension_packages');
                     break;
                 case 'modWorkspace':
                     /** @var modWorkspace $object */
                     foreach ($modx->getIterator('modWorkspace', $classCriteria) as $object) {
                         if (strpos($object->path, $core_path) === 0) {
                             $object->set('path', str_replace($core_path, '{core_path}', $object->path));
                         } elseif (strpos($object->path, $assets_path) === 0) {
                             $object->set('path', str_replace($assets_path, '{assets_path}', $object->path));
                         } elseif (strpos($object->path, $manager_path) === 0) {
                             $object->set('path', str_replace($manager_path, '{manager_path}', $object->path));
                         } elseif (strpos($object->path, $base_path) === 0) {
                             $object->set('path', str_replace($base_path, '{base_path}', $object->path));
                         }
                         if ($package->put($object, $classAttributes)) {
                             $instances++;
                         } else {
                             $modx->log(modX::LOG_LEVEL_WARN, "Could not package {$class} instance with pk: " . print_r($object->getPrimaryKey(), true));
                         }
                     }
                     $modx->log(modX::LOG_LEVEL_INFO, "Packaged {$instances} of {$class}");
                     continue 2;
                 case 'transport.modTransportPackage':
                     $modx->loadClass($class);
                     $response = $modx->call('modTransportPackage', 'listPackages', array(&$modx, $workspace->get('id')));
                     if (isset($response['collection'])) {
                         foreach ($response['collection'] as $object) {
                             $packagesDir = MODX_CORE_PATH . 'packages/';
                             if ($object->getOne('Workspace')) {
                                 $packagesDir = $object->Workspace->get('path') . 'packages/';
                             }
                             $pkgSource = $object->get('source');
                             $folderPos = strrpos($pkgSource, '/');
                             $sourceDir = $folderPos > 1 ? substr($pkgSource, 0, $folderPos + 1) : '';
                             $source = realpath($packagesDir . $pkgSource);
                             $target = 'MODX_CORE_PATH . "packages/' . $sourceDir . '"';
                             $classAttributes = array_merge($attributes, array('resolve' => array(array('type' => 'file', 'source' => $source, 'target' => "return {$target};"))));
                             if ($package->put($object, $classAttributes)) {
                                 $instances++;
                             } else {
                                 $modx->log(modX::LOG_LEVEL_WARN, "Could not package {$class} instance with pk: " . print_r($object->getPrimaryKey(), true));
                             }
                         }
                     }
                     $modx->log(modX::LOG_LEVEL_INFO, "Packaged {$instances} of {$class}");
                     continue 2;
                 case 'sources.modMediaSource':
                     foreach ($modx->getIterator('sources.modMediaSource') as $object) {
                         $classAttributes = $attributes;
                         /** @var modMediaSource $object */
                         if ($object->get('is_stream') && $object->initialize()) {
                             $sourceBases = $object->getBases('');
                             $source = $object->getBasePath();
                             if (!$sourceBases['pathIsRelative'] && strpos($source, '://') === false) {
                                 $sourceBasePath = $source;
                                 if (strpos($source, $base_path) === 0) {
                                     $sourceBasePath = str_replace($base_path, '', $sourceBasePath);
                                     $classAttributes['resolve'][] = array('type' => 'php', 'source' => VAPOR_DIR . 'scripts/resolve.media_source.php', 'target' => $sourceBasePath, 'targetRelative' => true);
                                 } else {
                                     /* when coming from Windows sources, remove "{volume}:" */
                                     if (strpos($source, ':\\') !== false || strpos($source, ':/') !== false) {
                                         $sourceBasePath = str_replace('\\', '/', substr($source, strpos($source, ':') + 1));
                                     }
                                     $target = 'dirname(MODX_BASE_PATH) . "/sources/' . ltrim(dirname($sourceBasePath), '/') . '/"';
                                     $classAttributes['resolve'][] = array('type' => 'file', 'source' => $source, 'target' => "return {$target};");
                                     $classAttributes['resolve'][] = array('type' => 'php', 'source' => VAPOR_DIR . 'scripts/resolve.media_source.php', 'target' => $sourceBasePath, 'targetRelative' => false, 'targetPrepend' => "return dirname(MODX_BASE_PATH) . '/sources/';");
                                 }
                             }
                         }
                         if ($package->put($object, $classAttributes)) {
                             $instances++;
                         } else {
                             $modx->log(modX::LOG_LEVEL_WARN, "Could not package {$class} instance with pk: " . print_r($object->getPrimaryKey(), true));
                         }
                     }
                     $modx->log(modX::LOG_LEVEL_INFO, "Packaged {$instances} of {$class}");
                     continue 2;
                 default:
                     break;
             }
             /** @var xPDOObject $object */
             foreach ($modx->getIterator($class, $classCriteria) as $object) {
                 if ($package->put($object, $classAttributes)) {
                     $instances++;
                 } else {
                     $modx->log(modX::LOG_LEVEL_WARN, "Could not package {$class} instance with pk: " . print_r($object->getPrimaryKey(), true));
                 }
             }
             $modx->log(modX::LOG_LEVEL_INFO, "Packaged {$instances} of {$class}");
         }
         /* collect table names from classes and grab any additional tables/data not listed */
         $coreTables = array();
         $extraTables = array();
         foreach ($classes as $class) {
             $coreTables[$class] = $modx->quote($modx->literal($modx->getTableName($class)));
         }
         if ($coreTables) {
             $stmt = $modx->query("SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '{$modxDatabase}' AND TABLE_NAME NOT IN (" . implode(',', $coreTables) . ")");
             $extraTables = $stmt->fetchAll(PDO::FETCH_COLUMN);
         }
         if (is_array($extraTables) && !empty($extraTables)) {
             //$modx->loadClass('vapor.vaporVehicle', VAPOR_DIR . 'model/', true, true);
             $modx->loadClass('vapor.vaporVehicle', VAPOR_DIR, true, true);
             $excludeExtraTablePrefix = isset($vaporOptions['excludeExtraTablePrefix']) && is_array($vaporOptions['excludeExtraTablePrefix']) ? $vaporOptions['excludeExtraTablePrefix'] : array();
             $excludeExtraTables = isset($vaporOptions['excludeExtraTables']) && is_array($vaporOptions['excludeExtraTables']) ? $vaporOptions['excludeExtraTables'] : array();
             foreach ($extraTables as $extraTable) {
                 if (in_array($extraTable, $excludeExtraTables)) {
                     continue;
                 }
                 if (!XPDO_CLI_MODE && !ini_get('safe_mode')) {
                     set_time_limit(0);
                 }
                 $instances = 0;
                 $object = array();
                 $attributes = array('vehicle_package' => 'vapor', 'vehicle_class' => 'vaporVehicle');
                 /* remove modx table_prefix if table starts with it */
                 $extraTableName = $extraTable;
                 if (!empty($modxTablePrefix) && strpos($extraTableName, $modxTablePrefix) === 0) {
                     $extraTableName = substr($extraTableName, strlen($modxTablePrefix));
                     $addTablePrefix = true;
                 } elseif (!empty($modxTablePrefix) || in_array($extraTableName, $excludeExtraTablePrefix)) {
                     $addTablePrefix = false;
                 } else {
                     $addTablePrefix = true;
                 }
                 $object['tableName'] = $extraTableName;
                 $modx->log(modX::LOG_LEVEL_INFO, "Extracting non-core table {$extraTableName}");
                 /* generate the CREATE TABLE statement */
                 $stmt = $modx->query("SHOW CREATE TABLE {$modx->escape($extraTable)}");
                 $resultSet = $stmt->fetch(PDO::FETCH_NUM);
                 $stmt->closeCursor();
                 if (isset($resultSet[1])) {
                     if ($addTablePrefix) {
                         $object['drop'] = "DROP TABLE IF EXISTS {$modx->escape('[[++table_prefix]]' . $extraTableName)}";
                         $object['table'] = str_replace("CREATE TABLE {$modx->escape($extraTable)}", "CREATE TABLE {$modx->escape('[[++table_prefix]]' . $extraTableName)}", $resultSet[1]);
                     } else {
                         $object['drop'] = "DROP TABLE IF EXISTS {$modx->escape($extraTableName)}";
                         $object['table'] = $resultSet[1];
                     }
                     /* collect the rows and generate INSERT statements */
                     $object['data'] = array();
                     $stmt = $modx->query("SELECT * FROM {$modx->escape($extraTable)}");
                     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                         if ($instances === 0) {
                             $fields = implode(', ', array_map(array($modx, 'escape'), array_keys($row)));
                         }
                         $values = array();
                         while (list($key, $value) = each($row)) {
                             switch (gettype($value)) {
                                 case 'string':
                                     $values[] = $modx->quote($value);
                                     break;
                                 case 'NULL':
                                 case 'array':
                                 case 'object':
                                 case 'resource':
                                 case 'unknown type':
                                     $values[] = 'NULL';
                                     break;
                                 default:
                                     $values[] = (string) $value;
                                     break;
                             }
                         }
                         $values = implode(', ', $values);
                         if ($addTablePrefix) {
                             $object['data'][] = "INSERT INTO {$modx->escape('[[++table_prefix]]' . $extraTableName)} ({$fields}) VALUES ({$values})";
                         } else {
                             $object['data'][] = "INSERT INTO {$modx->escape($extraTable)} ({$fields}) VALUES ({$values})";
                         }
                         $instances++;
                     }
                 }
                 if (!$package->put($object, $attributes)) {
                     $modx->log(modX::LOG_LEVEL_WARN, "Could not package rows for table {$extraTable}: " . print_r($object, true));
                 } else {
                     $modx->log(modX::LOG_LEVEL_INFO, "Packaged {$instances} rows for table {$extraTable}");
                 }
             }
         }
         if (!XPDO_CLI_MODE && !ini_get('safe_mode')) {
             set_time_limit(0);
         }
         if (!$package->pack()) {
             $message = "Error extracting package, could not pack transport: {$package->signature}";
             $modx->log(modX::LOG_LEVEL_ERROR, $message);
             //echo "{$message}\n";
         } else {
             $message = "Completed extracting package: {$package->signature}";
             $modx->log(modX::LOG_LEVEL_INFO, $message);
             //echo "{$message}\n";
         }
         $endTime = microtime(true);
         $msg = sprintf("Vapor execution completed without exception in %2.4fs", $endTime - $this->getProperty('startTime'));
         $modx->log(modX::LOG_LEVEL_INFO, $msg);
         return $this->success($msg, array('signature' => $package->signature));
     } catch (Exception $e) {
         if (empty($endTime)) {
             $endTime = microtime(true);
         }
         if (!empty($modx)) {
             $modx->log(modX::LOG_LEVEL_ERROR, $e->getMessage());
             $msg = sprintf("Vapor execution completed with exception in %2.4fs", $endTime - $this->getProperty('startTime'));
             $modx->log(modX::LOG_LEVEL_INFO, $msg);
             return $this->failure($msg);
         } else {
             //echo $e->getMessage() . "\n";
         }
         $msg = sprintf("Vapor execution completed with exception in %2.4fs\n", $endTime - $this->getProperty('startTime'));
         $modx->log(modX::LOG_LEVEL_INFO, $msg);
         return $this->failure($msg);
     }
     return $modx->success(printf("Vapor execution completed without exception in %2.4fs\n", $endTime - $this->getProperty('startTime')));
 }