"fix for bug #622: 'XML Import' doesn't work right"

This commit is contained in:
Ralf Becker 2007-05-14 10:41:11 +00:00
parent 9b61188549
commit aa1a87f328
2 changed files with 4 additions and 6 deletions

View File

@ -320,7 +320,7 @@
$msg = $ok ? lang('Template saved') : lang('Error: while saving !!!'); $msg = $ok ? lang('Template saved') : lang('Error: while saving !!!');
if ($ok) unset($preserv['import']); if ($ok) unset($preserv['import']);
} }
elseif (isset($_GET['name']) || isset($content['name'])) elseif (!$content['import_xml'] && (isset($_GET['name']) || isset($content['name'])))
{ {
if ($_GET['name']) if ($_GET['name'])
{ {

View File

@ -428,7 +428,7 @@
* *
* @param object &$etempl eTemplate object to set * @param object &$etempl eTemplate object to set
* @param string $data the XML * @param string $data the XML
* @param array/string array with names of imported templates or error-message * @return array/string array with names of imported templates or error-message
*/ */
function import(&$etempl,$data) function import(&$etempl,$data)
{ {
@ -498,9 +498,8 @@
switch ($type) switch ($type)
{ {
case 'close': case 'close':
if (!count($parents) || $parent['.is_root']) // templ import complet => save it if (!count($parents)) // templ import complet => save it
{ {
unset($parent['.is_root']);
unset($parent); $parents = array(); unset($parent); $parents = array();
$etempl->fix_old_template_format(); // set the depricated compat vars $etempl->fix_old_template_format(); // set the depricated compat vars
// save tmpl to the cache, as the file may contain more then one tmpl // save tmpl to the cache, as the file may contain more then one tmpl
@ -525,7 +524,7 @@
{ {
$etempl->init($attr); $etempl->init($attr);
$etempl->children = array(); // init adds one grid by default $etempl->children = array(); // init adds one grid by default
$parent = &$etempl->children; $parent = &$etempl; // parent is the template-object itself!
} }
if ($tag == 'grid') if ($tag == 'grid')
{ {
@ -541,7 +540,6 @@
'rows' => 0, 'rows' => 0,
'size' => $size, 'size' => $size,
); );
if ($is_root) $grid['.is_root'] = true; // we need to remember we have no template as parent
soetemplate::add_child($parent,$grid); soetemplate::add_child($parent,$grid);
$parents[count($parents)] = &$parent; $parents[count($parents)] = &$parent;
$parent = &$grid; $parent = &$grid;