Commit f7f94cc5 authored by Nigel McNie's avatar Nigel McNie
Browse files

Trivial first efforts at parent class import/export routines for blockinstances.

Seems to work for a few blocktypes, namely ones like externalvideo, and
the simple ones like mygroups.

They'll need improving to handle artefact IDs, which need to be mapped
to entries in the export.
Signed-off-by: default avatarNigel McNie <>
parent 619f3cba
......@@ -287,8 +287,30 @@ abstract class PluginBlocktype extends Plugin {
* @return array The configuration required to import the block again later
public static function export_blockinstance_config(BlockInstance $bi) {
// TODO: a default implementation might just turn $bi->get('configdata') into an array
return array();
// TODO: check the quoting of json_encoded quotes in output
// TODO: encode artefactids properly
$configdata = $bi->get('configdata');
if (is_array($configdata)) {
// Unset a bunch of stuff that we don't want to export. These fields
// weren't being cleaned up before blockinstances were being saved
// previously, so we make sure they're not going to be in the result
foreach ($configdata as &$value) {
if (is_array($value) || is_object($value)) {
$value = json_encode($value);
else {
$configdata = array();
return $configdata;
......@@ -305,6 +327,19 @@ abstract class PluginBlocktype extends Plugin {
// TODO: a default implementation might just create a new blockinstance
// with the config shunted into configdata - but with artefactids
// replaced with new ones
// TODO: unsetting these for now, will want them to be references to
// artefacts in the export
if (isset($config['config']['artefactids'])) $config['config']['artefactids'] = array();
$bi = new BlockInstance(0,
'blocktype' => $config['type'],
'configdata' => $config['config'],
return $bi;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment