Note: this is only for alpha-4 and later.
1. Should there also be a lexicon file, transferred via a resolver?
Nope. It depends on how you’re building the package, either stand-alone via a script, or in the Revo interface.
If you’re using the GUI, all you have to do is make sure that the lexicon entries are assigned the correct namespace (ie, if you were making spform, you’d create an spform namespace, and then import your foci into there.) Then, when building, make sure the modLexiconFocus and modLexiconEntry auto-includes are selected. It will then autopackage them in.
If you’re doing it via a script (recommended), then you’d put the lexicons in a directory somewhere (we recommend _build/lexicon/), and run the modPackageBuilder->buildLexicon($path) function. TinyMCE’s looks like this:
$modx->loadClass('transport.modPackageBuilder','',false, true);
$builder = new modPackageBuilder($modx);
$builder->create('tinymce','2.1.0','beta');
$builder->registerNamespace('tinymce',false,true);
$sources= array (
'assets' => dirname(dirname(__FILE__)) . '/assets/',
'root' => dirname(dirname(__FILE__)) . '/',
);
$c= $modx->newObject('modPlugin');
$c->set('name', 'TinyMCE');
$c->set('description', 'TinyMCE 2.1.0-beta plugin for MODx Revolution');
$c->set('plugincode', file_get_contents($sources['root'] . 'tinymce.plugin.php'));
$c->set('category', 0);
$attributes= array(
XPDO_TRANSPORT_UNIQUE_KEY => 'name',
XPDO_TRANSPORT_PRESERVE_KEYS => true,
XPDO_TRANSPORT_UPDATE_OBJECT => true,
);
$vehicle = $builder->createVehicle($c, $attributes);
$vehicle->resolve('php',array(
'source' => dirname(__FILE__) . '/scripts/add_plugin_events.php',
));
$vehicle->resolve('file',array(
'source' => $sources['assets'] . 'plugins/tinymce',
'target' => "return MODX_ASSETS_PATH . 'plugins/';",
));
$builder->putVehicle($vehicle);
// load lexicon strings
$builder->buildLexicon($sources['root'].'_build/lexicon/');
// load system settings
$settings = array();
include_once dirname(__FILE__).'/data/transport.settings.php';
$attributes= array(
XPDO_TRANSPORT_UNIQUE_KEY => 'key',
XPDO_TRANSPORT_PRESERVE_KEYS => true,
XPDO_TRANSPORT_UPDATE_OBJECT => true,
);
foreach ($settings as $setting) {
$vehicle = $builder->createVehicle($setting,$attributes);
$builder->putVehicle($vehicle);
}
$builder->pack();
Are lexicon entry variables required to be called $_lang or can they have snippet-specific variable names ($spform_lang). I know there’s no point to this any more with namespaces and foci, but I have a lot of entries that already have those names.
Currently they are required to be $_lang. We’ll see about changing that later, but you’re right - it’s arbitrary now.