Commit 69f3d801 authored by Nigel McNie's avatar Nigel McNie
Browse files

Export and import view layout and owner format.


Signed-off-by: default avatarNigel McNie <nigel@catalyst.net.nz>
parent 60dcbc6d
......@@ -206,6 +206,8 @@ class PluginExportLeap extends PluginExport {
* Export the views
*/
private function export_views() {
$layouts = get_records_assoc('view_layout');
foreach ($this->get('views') as $view) {
$config = $this->rewrite_artefact_ids($view->export_config('leap'));
$this->smarty->assign('title', $config['title']);
......@@ -217,7 +219,19 @@ class PluginExportLeap extends PluginExport {
$this->smarty->assign('contenttype', 'html');
$this->smarty->assign('content', $view->build_columns());
$this->smarty->assign('viewdata', $config['columns']);
$this->smarty->assign('ownerformat', $config['ownerformat']);
if (isset($layouts[$config['layout']])) {
$layout = $config['layout'];
}
else {
// This line ruthlessly stolen from lib/upgrade.php - the only
// place where view layouts are canonically specified
$layout = ($config['numcolumns'] == 2 ? 1 : ($config['numcolumns'] == 3 ? 4 : 7));
}
if (isset($layouts[$layout])) {
$this->smarty->assign('layout', $layouts[$layout]->widths);
}
$ownerformat = ($config['ownerformat']) ? $config['ownerformat'] : FORMAT_NAME_DISPLAYNAME;
$this->smarty->assign('ownerformat', $ownerformat);
$this->smarty->assign('leaptype', 'selection');
$tags = array();
......
{include file="export:leap:entry.tpl" skipfooter=true}
{if $ownerformat} <mahara:ownerformat>{$ownerformat|escape}</mahara:ownerformat>
{/if}
<mahara:view>
<mahara:view{if $layout} mahara:layout="{$layout|escape}"{/if} mahara:ownerformat="{$ownerformat|escape}">
{foreach from=$viewdata item=column}
<mahara:column>
{foreach from=$column item=blockinstance}
......@@ -14,5 +12,4 @@
</mahara:column>
{/foreach}
</mahara:view>
<mahara:viewlayout>TODO</mahara:viewlayout>
{include file="export:leap:entryfooter.tpl"}
......@@ -565,6 +565,7 @@ class PluginImportLeap extends PluginImport {
*/
private function import_entry_as_mahara_view(SimpleXMLElement $entry) {
static $blocktypes_installed = null;
static $viewlayouts = null;
$viewelement = $entry->xpath('mahara:view[1]');
if (count($viewelement) != 1) {
......@@ -572,6 +573,21 @@ class PluginImportLeap extends PluginImport {
return false;
}
if (is_null($viewlayouts)) {
$viewlayouts = get_records_assoc('view_layout', '', '', '', 'widths, id');
}
$maharaattributes = PluginImportLeap::get_attributes($viewelement[0], PluginImportLeap::NS_MAHARA);
$layout = null;
if (isset($viewlayouts[$maharaattributes['layout']])) {
$layout = $viewlayouts[$maharaattributes['layout']]->id;
}
$ownerformat = intval($maharaattributes['ownerformat']);
if (!$ownerformat) {
$ownerformat = FORMAT_NAME_DISPLAYNAME;
}
$columns = $entry->xpath('mahara:view[1]/mahara:column');
$columncount = count($columns);
if ($columncount < 1 || $columncount > 5) {
......@@ -584,11 +600,11 @@ class PluginImportLeap extends PluginImport {
'title' => (string)$entry->title,
'description' => (string)$entry->summary,
'type' => 'portfolio', // TODO
'layout' => null, // TODO
'layout' => $layout,
'tags' => self::get_entry_tags($entry),
'numcolumns' => $columncount,
'owner' => $this->get('usr'),
'ownerformat' => FORMAT_NAME_DISPLAYNAME, // TODO
'ownerformat' => $ownerformat,
);
$col = 1;
......
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