<?php if (!defined('VB_ENTRY')) die('Access denied.'); class vB_Xml_Import_ScreenLayout extends vB_Xml_Import { protected function import() { if (empty($this->parsedXML['page'])) { $this->parsedXML['page'] = array(); } $screenLayoutTable = $this->db->fetchTableStructure('screenlayout'); $screenLayoutTableColumns = array_diff($screenLayoutTable['structure'], array($screenLayoutTable['key'])); $screenLayouts = $this->parsedXML['screenlayout']; foreach ($screenLayouts AS $screenLayout) { if (!empty($screenLayout['sectiondata'])) { $rows = is_array($screenLayout['sectiondata']['row'][0]) ? $screenLayout['sectiondata']['row'] : array($screenLayout['sectiondata']['row']); $sectionData = array(); foreach ($rows AS $row) { $sections = is_array($row['column'][0] ?? null) ? $row['column'] : [$row['column']]; $sectionData[] = $sections; } $screenLayout['sectiondata'] = json_encode($sectionData); } else { $screenLayout['sectiondata'] = ''; } $screenLayoutId = 0; $existing = $this->db->getRow('screenlayout', array('guid' => $screenLayout['guid'])); if ($existing) { if ($this->options & self::OPTION_OVERWRITE) { $guid = $screenLayout['guid']; unset($screenLayout['guid']); $this->db->update('screenlayout', $screenLayout, array('guid' => $guid)); } $screenLayoutId = $existing['screenlayoutid']; } else { $screenLayoutId = $this->db->insert('screenlayout', $screenLayout); if (is_array($screenLayoutId)) { $screenLayoutId = array_pop($screenLayoutId); } } } } } 