Commit 4064ecd3 authored by Aaron Wells's avatar Aaron Wells Committed by Gerrit Code Review
Browse files

Backwards compatibility for pre-flexible-layout Pages

Bug 1229550

Change-Id: I3c42c63a82b662e680234029ed5254bebbf9f26c
parent 26fabf4f
......@@ -58,6 +58,7 @@ class LeapImportComment extends LeapImportArtefactPlugin {
'title' => '--',
'type' => 'portfolio',
'numrows' => 1,
'numcolumns' => 1,
'ctime' => $time,
'mtime' => $time,
'atime' => $time,
......
......@@ -802,10 +802,22 @@ class PluginImportLeap extends PluginImport {
$rows = $entry->xpath('mahara:view[1]/mahara:row');
$rowcount = count($rows);
// A flag that indicates whether this is an old-style one-row layout, or a new-style multi-row layout
$onerowlayout = false;
if ($rowcount < 1 || $rowcount > View::$maxlayoutrows) {
// Whoops, invalid number of rows
$this->trace("Invalid number of rows specified for potential view {$entry->id}, falling back to standard import", self::LOG_LEVEL_VERBOSE);
return false;
// Check for a pre-1.8 (one-row) layout
$columns = $entry->xpath('mahara:view[1]/mahara:column');
$columncount = count($columns);
if ($columncount < 1 || $columncount > 5) {
// Whoops, invalid number of rows
$this->trace("Invalid number of rows specified for potential view {$entry->id}, falling back to standard import", self::LOG_LEVEL_VERBOSE);
return false;
}
else {
$onerowlayout = true;
$rows = array($columns);
$rowcount = 1;
}
}
$layout = null;
......@@ -875,12 +887,15 @@ class PluginImportLeap extends PluginImport {
$rowindex = 1;
foreach ($rows as $row) {
$columns = $row->xpath('mahara:column');
$columncount = count($columns);
if ($columncount < 1 || $columncount > 5) {
// Whoops, invalid number of columns
$this->trace("Invalid number of columns specified for potential view {$entry->id}, falling back to standard import", self::LOG_LEVEL_VERBOSE);
return false;
// If this is the old one-row layout, we'll have handled that earlier, and have the one row's columns be in $columns
if (!$onerowlayout) {
$columns = $row->xpath('mahara:column');
$columncount = count($columns);
if ($columncount < 1 || $columncount > 5) {
// Whoops, invalid number of columns
$this->trace("Invalid number of columns specified for potential view {$entry->id}, falling back to standard import", self::LOG_LEVEL_VERBOSE);
return false;
}
}
$colindex = 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