diff --git a/assets/components/importx/js/mgr/widget.home.form.js b/assets/components/importx/js/mgr/widget.home.form.js index faf14ff..be04c0c 100644 --- a/assets/components/importx/js/mgr/widget.home.form.js +++ b/assets/components/importx/js/mgr/widget.home.form.js @@ -144,7 +144,7 @@ importX.panel.createImport = function(config) { ,border: false },{ xtype: 'textfield' - ,fieldLabel: _('resource_parent') + ,fieldLabel: _('importx.parent') ,name: 'parent' ,id: 'importx-import-parent' ,labelSeparator: '' diff --git a/core/components/importx/lexicon/en/default.inc.php b/core/components/importx/lexicon/en/default.inc.php index 3d9c989..e30f162 100644 --- a/core/components/importx/lexicon/en/default.inc.php +++ b/core/components/importx/lexicon/en/default.inc.php @@ -34,14 +34,16 @@ // Modified 2/5/2011 $_lang['importx.tab.input.desc'] = 'Paste or upload your CSV input, separating records with a newline and fields with a semi-colon (;) or the separator of your choice specified in the field below.'; $_lang['importx.tab.input.sep'] = 'When your CSV formatted entry uses a different separator, you can declare it here. Leave empty to use a semi-colon.'; -$_lang['importx.csv'] = 'Raw CSV'; -// Added 2/5/2011: +$_lang['importx.csv'] = 'Raw CSV:'; +// Added 2/5/2011: (2 items) +$_lang['importx.parent'] = 'Parent:'; // Not parent resource, as this can also be a context! $_lang['importx.csvfile'] = 'CSV file upload'; $_lang['importx.separator'] = 'Separator'; $_lang['importx.tab.settings'] = 'Default Settings'; $_lang['importx.tab.settings.desc'] = 'Specify the default settings to be used. You may override these per record by referencing the fieldname in your CSV formatted values.'; $_lang['importx.err.noparent'] = 'Please choose a Parent to import to. Specify 0 to put new resources in the root of the site.'; -$_lang['importx.err.parentnotnumeric'] = 'Parent not numeric.'; +// Modified 2/5/2011: +$_lang['importx.err.parentnotnumeric'] = 'Parent not numeric or valid context key.'; $_lang['importx.err.parentlessthanzero'] = 'Parent needs to be a positive integer.'; $_lang['importx.err.nocsv'] = 'Please add your CSV values in order for them to be processed.'; // Added 2/5/2011: diff --git a/core/components/importx/processors/startimport.php b/core/components/importx/processors/startimport.php index 5ab53df..50599b7 100644 --- a/core/components/importx/processors/startimport.php +++ b/core/components/importx/processors/startimport.php @@ -57,9 +57,14 @@ function logConsole($type,$msg) { $parent = (isset($_POST['parent']))? $_POST['parent'] : 0; if (!is_numeric($parent)) { - return logConsole('error',$modx->lexicon('importx.err.parentnotnumeric')); + if ($modx->getObject('modContext',$parent)) { + $ctx = $parent; + $parent = 0; + } else { + return logConsole('error',$modx->lexicon('importx.err.parentnotnumeric')); + } } - if ($parent < 0) { + elseif ($parent < 0) { return logConsole('error',$modx->lexicon('importx.err.parentlessthanzero')); } @@ -144,6 +149,7 @@ function logConsole($type,$msg) { $err[] = $line; } else { $lines[$line] = array_combine($headings,$curline); + if ((!isset($lines[$line]['context_key'])) && (isset($ctx))) { $lines[$line]['context_key'] = $ctx; } if ((!isset($lines[$line]['parent'])) && (isset($parent))) { $lines[$line]['parent'] = $parent; } if ((!isset($lines[$line]['published'])) && (isset($published))) { $lines[$line]['published'] = $published; } if ((!isset($lines[$line]['searchable'])) && (isset($searchable))) { $lines[$line]['searchable'] = $searchable; }