Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
b03tz committed Apr 24, 2012
0 parents commit 8817cd7
Show file tree
Hide file tree
Showing 76 changed files with 4,017 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ignore all .htaccess
.htaccess

# ignore setup config files
build.config.php
build/build.config.php
18 changes: 18 additions & 0 deletions _build/build.config.sample.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Define the MODX path constants necessary for installation
*
* @package defaultcomponent
* @subpackage build
*/
define('MODX_BASE_PATH', dirname(dirname(dirname(dirname(__FILE__)))) . '/modx/');
define('MODX_CORE_PATH', MODX_BASE_PATH . 'core/');
define('MODX_MANAGER_PATH', MODX_BASE_PATH . 'manager/');
define('MODX_CONNECTORS_PATH', MODX_BASE_PATH . 'connectors/');
define('MODX_ASSETS_PATH', MODX_BASE_PATH . 'assets/');

define('MODX_BASE_URL','/modx/');
define('MODX_CORE_URL', MODX_BASE_URL . 'core/');
define('MODX_MANAGER_URL', MODX_BASE_URL . 'manager/');
define('MODX_CONNECTORS_URL', MODX_BASE_URL . 'connectors/');
define('MODX_ASSETS_URL', MODX_BASE_URL . 'assets/');
96 changes: 96 additions & 0 deletions _build/build.scheme.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php
/**
* Build Schema script
*
* @package formsave
* @subpackage build
*/

error_reporting(E_ERROR);

$componentName = 'formsave';

$modelRoot = 'model/'.$componentName.'/';

echo ' <pre>';
if ($handle = opendir($modelRoot)) {
echo "<h2>Removing old model:</h2>";
while (false !== ($file = readdir($handle))) {
if (substr($file, 0, 1) != '.' && $file != 'remove.php') {
$result = @unlink($modelRoot.$file);

ob_start();
var_dump($result);
$content = ob_get_contents();
$content=str_replace("\n", "", $content);
ob_end_clean();

echo '('.$content.') - '.$file.' <br />';
}
}

closedir($handle);

}

if ($handle = opendir($modelRoot.'mysql')) {
while (false !== ($file = readdir($handle))) {
if (substr($file, 0, 1) != '.' && $file != 'remove.php') {
$result = @unlink($modelRoot.'mysql/'.$file);

ob_start();
var_dump($result);
$content = ob_get_contents();
$content=str_replace("\n", "", $content);
ob_end_clean();

echo '('.$content.') - mysql/'.$file.' <br />';
}
}

closedir($handle);

}

echo '<h2>Creating model:</h2>';

$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tstart = $mtime;
set_time_limit(0);

umask(0000);

require_once dirname(dirname(dirname(__FILE__))) . '/core/config/config.inc.php';
include_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx= new modX();
$modx->initialize('mgr');
$modx->loadClass('transport.modPackageBuilder','',false, true);
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');

$root = dirname(dirname(__FILE__)).'/';
$sources = array(
'root' => $root,
'core' => $root.'core/components/'.$componentName.'/',
'model' => $root.'_build/model/',
'assets' => $root.'assets/components/'.$componentName.'/',
'schema' => $root.'_build/schema/',
);

$manager= $modx->getManager();
$generator= $manager->getGenerator();

$generator->parseSchema($sources['schema'].'build.mysql.schema.xml', $sources['model']);

$mtime= microtime();
$mtime= explode(" ", $mtime);
$mtime= $mtime[1] + $mtime[0];
$tend= $mtime;
$totalTime= ($tend - $tstart);
$totalTime= sprintf("%2.4f s", $totalTime);

echo "\nExecution time: {$totalTime}\n";

exit ();
239 changes: 239 additions & 0 deletions _build/build.transport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
<?php
/**
* FormSave
*
* Copyright 2010-11 by Shaun McCormick <[email protected]>
*
* This file is part of FormSave, a simple commenting component for MODx Revolution.
*
* FormSave is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* FormSave is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* FormSave; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*
* @package formsave
*/
/**
* FormSave build script
*
* @package formsave
* @subpackage build
*/
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tstart = $mtime;
set_time_limit(0);

/* define package */
define('PKG_NAME','FormSave');
define('PKG_NAME_LOWER','formsave');
define('PKG_VERSION','1.0.0');
define('PKG_RELEASE','pl1');

/* define sources */
$root = dirname(dirname(__FILE__)).'/';
$sources= array (
'root' => $root,
'build' => $root .'_build/',
'resolvers' => $root . '_build/resolvers/',
'data' => $root . '_build/data/',
'events' => $root . '_build/data/events/',
'permissions' => $root . '_build/data/permissions/',
'properties' => $root . '_build/data/properties/',
'source_core' => $root.'core/components/'.PKG_NAME_LOWER,
'source_assets' => $root.'assets/components/'.PKG_NAME_LOWER,
'plugins' => $root.'core/components/'.PKG_NAME_LOWER.'/elements/plugins/',
'snippets' => $root.'core/components/'.PKG_NAME_LOWER.'/elements/snippets/',
'lexicon' => $root . 'core/components/'.PKG_NAME_LOWER.'/lexicon/',
'docs' => $root.'core/components/'.PKG_NAME_LOWER.'/docs/',
'model' => $root.'core/components/'.PKG_NAME_LOWER.'/model/',
);
unset($root);

/* override with your own defines here (see build.config.sample.php) */
require_once $sources['build'] . 'includes/functions.php';
require_once $sources['build'] . '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('ECHO'); echo '<pre>'; flush();

$modx->loadClass('transport.modPackageBuilder','',false, true);
$builder = new modPackageBuilder($modx);
$builder->createPackage(PKG_NAME_LOWER,PKG_VERSION,PKG_RELEASE);
$builder->registerNamespace(PKG_NAME_LOWER,false,true,'{core_path}components/'.PKG_NAME_LOWER.'/');
$modx->getService('lexicon','modLexicon');
$modx->lexicon->load('formsave:properties');

/* load action/menu */
$menu = include $sources['data'].'transport.menu.php';
$vehicle= $builder->createVehicle($menu,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'),
),
),
));
$builder->putVehicle($vehicle);
unset($vehicle,$action);

/* load system settings
$settings = include_once $sources['data'].'transport.settings.php';
$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.'); flush();
unset($settings,$setting,$attributes);*/

/* package in default access policy
$attributes = array (
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UNIQUE_KEY => array('name'),
xPDOTransport::UPDATE_OBJECT => true,
);
$policies = include $sources['data'].'transport.policies.php';
if (!is_array($policies)) { $modx->log(modX::LOG_LEVEL_FATAL,'Adding policies failed.'); }
foreach ($policies as $policy) {
$vehicle = $builder->createVehicle($policy,$attributes);
$builder->putVehicle($vehicle);
}
$modx->log(modX::LOG_LEVEL_INFO,'Packaged in '.count($policies).' Access Policies.'); flush();
unset($policies,$policy,$attributes);*/

/* package in default access policy template
$templates = include dirname(__FILE__).'/data/transport.policytemplates.php';
$attributes = array (
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UNIQUE_KEY => array('name'),
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::RELATED_OBJECTS => true,
xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array (
'Permissions' => array (
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::UNIQUE_KEY => array ('template','name'),
),
)
);
if (is_array($templates)) {
foreach ($templates as $template) {
$vehicle = $builder->createVehicle($template,$attributes);
$builder->putVehicle($vehicle);
}
$modx->log(modX::LOG_LEVEL_INFO,'Packaged in '.count($templates).' Access Policy Templates.'); flush();
} else {
$modx->log(modX::LOG_LEVEL_ERROR,'Could not package in Access Policy Templates.');
}
unset ($templates,$template,$idx,$ct,$attributes);*/

/* add plugins
$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'),
),
),
);
foreach ($plugins as $plugin) {
$vehicle = $builder->createVehicle($plugin, $attributes);
$builder->putVehicle($vehicle);
}
$modx->log(modX::LOG_LEVEL_INFO,'Packaged in '.count($plugins).' plugins.'); flush();
unset($plugins,$plugin,$attributes);*/

/* create category */
$category= $modx->newObject('modCategory');
$category->set('id',1);
$category->set('category',PKG_NAME);
$modx->log(modX::LOG_LEVEL_INFO,'Packaged in category.'); flush();

/* add snippets */
$snippets = include $sources['data'].'transport.snippets.php';
if (is_array($snippets)) {
$category->addMany($snippets,'Snippets');
} else { $modx->log(modX::LOG_LEVEL_FATAL,'Adding snippets failed.'); }
$modx->log(modX::LOG_LEVEL_INFO,'Packaged in '.count($snippets).' snippets.'); flush();
unset($snippets);

/* create category vehicle */
$attr = array(
xPDOTransport::UNIQUE_KEY => 'category',
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::RELATED_OBJECTS => true,
xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array (
'Snippets' => array(
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::UNIQUE_KEY => 'name',
),
)
);
$vehicle = $builder->createVehicle($category,$attr);
$vehicle->resolve('file',array(
'source' => $sources['source_core'],
'target' => "return MODX_CORE_PATH . 'components/';",
));
$vehicle->resolve('file',array(
'source' => $sources['source_assets'],
'target' => "return MODX_ASSETS_PATH . 'components/';",
));
$vehicle->resolve('php',array(
'source' => $sources['resolvers'] . 'dbchanges.resolver.php',
));
$modx->log(modX::LOG_LEVEL_INFO,'Packaged in resolvers.'); flush();
$builder->putVehicle($vehicle);

/* now pack in the license file, readme and setup options */
$builder->setPackageAttributes(array(
'license' => file_get_contents($sources['docs'] . 'license.txt'),
'readme' => file_get_contents($sources['docs'] . 'readme.txt'),
'changelog' => file_get_contents($sources['docs'] . 'changelog.txt')
));
$modx->log(modX::LOG_LEVEL_INFO,'Packaged in package attributes.'); flush();

$modx->log(modX::LOG_LEVEL_INFO,'Packing...'); flush();
$builder->pack();

$mtime= microtime();
$mtime= explode(" ", $mtime);
$mtime= $mtime[1] + $mtime[0];
$tend= $mtime;
$totalTime= ($tend - $tstart);
$totalTime= sprintf("%2.4f s", $totalTime);

$modx->log(modX::LOG_LEVEL_INFO,"\n<br />Package Built.<br />\nExecution time: {$totalTime}\n");

exit ();
Loading

0 comments on commit 8817cd7

Please sign in to comment.