I am a bit stuck,
I created a Build script and it looks like it is working.
At the moment it creates a category.
But if I try to creater a snippet I get no errors, but the script is not running.
Code:
build.transport.php
<?php
/**
* MODULAR build script
*
* @package modular
* @subpackage build
*/
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tstart = $mtime;
set_time_limit(0); /* makes sure our script doesnt timeout */
$root = dirname(dirname(__FILE__)).'/';
$sources= array (
'root' => $root,
'build' => $root .'_build/',
'resolvers' => $root . '_build/resolvers/',
'data' => $root . '_build/data/',
'source_core' => $root.'core/components/modular',
'source_assets' => $root.'assets/templates/main',
'docs' => $root.'core/components/modular/docs/',
);
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('modular','0.1','alpha1');
$builder->registerNamespace('modular',false,true,'{core_path}components/modular/');
/* load action/menu */
$action = include $sources['data'].'transport.action.php';
$vehicle= $builder->createVehicle($action,array (
XPDO_TRANSPORT_PRESERVE_KEYS => false,
XPDO_TRANSPORT_UPDATE_OBJECT => true,
XPDO_TRANSPORT_UNIQUE_KEY => array ('namespace','controller'),
XPDO_TRANSPORT_RELATED_OBJECTS => true,
XPDO_TRANSPORT_RELATED_OBJECT_ATTRIBUTES => array (
'Menus' => array (
XPDO_TRANSPORT_PRESERVE_KEYS => false,
XPDO_TRANSPORT_UPDATE_OBJECT => true,
XPDO_TRANSPORT_UNIQUE_KEY => array ('action', 'text'),
),
),
));
$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);
/* create category */
$category= $modx->newObject('modCategory');
$category->set('id',1);
$category->set('category','MODULAR');
/* create the snippet */
$snippet= $modx->newObject('modSnippet');
$snippet->set('id',0);
$snippet->set('name', 'include');
$snippet->set('description', 'Includes template code dynamically.');
$snippet->set('snippet',file_get_contents($sources['source_core'].'/snippet.include.php');
/* add chunks */
$chunks = include $sources['data'].'transport.chunks.php';
if (is_array($chunks)) {
$category->addMany($chunks);
} else { $modx->log(MODX_LOG_LEVEL_FATAL,'Adding chunks failed.'); }
/* create category vehicle */
$attr = array(
XPDO_TRANSPORT_UNIQUE_KEY => 'category',
XPDO_TRANSPORT_PRESERVE_KEYS => false,
XPDO_TRANSPORT_UPDATE_OBJECT => true,
XPDO_TRANSPORT_RELATED_OBJECTS => true,
XPDO_TRANSPORT_RELATED_OBJECT_ATTRIBUTES => array (
'modSnippet' => array(
XPDO_TRANSPORT_PRESERVE_KEYS => false,
XPDO_TRANSPORT_UPDATE_OBJECT => true,
XPDO_TRANSPORT_UNIQUE_KEY => 'name',
),
'modChunk' => array (
XPDO_TRANSPORT_PRESERVE_KEYS => false,
XPDO_TRANSPORT_UPDATE_OBJECT => true,
XPDO_TRANSPORT_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'] . 'setupoptions.resolver.php',
));
$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'),
'setup-options' => array(
'source' => $sources['build'].'setup.options.php',
),
));
$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 ();
The ERROR I get:
Parse error: syntax error, unexpected ';' in /home/mennopp/domains/nieuwe-website-ontwerpen.nl/public_html/modular/modular/Source Files/trunk/_build/build.transport.php on line 88
Line 88 is the final line of the /* create the snippet */ block, but what is wrong with it?
If I remove the /* create the snippet */ block the script runs fine...
Also, after I remove the /* create the snippet */ block the category is created fine, so the script runs and works, but the add chunk function is not working (gives no errors)
the transport.chunks.php code:
<?php
/**
* @package modular
* @subpackage build
*/
$chunks = array();
$chunks[1]= $modx->newObject('modChunk');
$chunks[1]->fromArray(array(
'id' => 1,
'name' => 'GalAlbumRowTpl',
'description' => 'Slider album row template.',
'snippet' => file_get_contents($sources['data'].'chunks/chunk.GalAlbumRowTpl.txt'),
),'',true,true);
return $chunks;
The chunk.GalAlbumRowTpl.txt code:
<div class="albumPreview">
<h3><a href="[[~[[*id]]? &[[+albumRequestVar]]=`[[+id]]`]]">[[+name]]</a></h3>
<div class="thumb">
<a href="[[~[[*id]]? &[[+albumRequestVar]]=`[[+id]]`]]"><img src="[[+image]]" alt="[[+name]]" /></a>
</div>
<div class="desc">
<p>[[+description]]</p>
</div>
</div>
I checked all the paths, the look fine. But my site is in a subfolder, could that be the problem?
UPDATE:
If I use the code from here:
http://modxcms.com/assets/tutorials/3pc/build.transport.phps (the create the snippet block) it gives the same error