Skip to content

Commit

Permalink
Closes #9: Re-use "parent" field to allow specifying a context when i…
Browse files Browse the repository at this point in the history
…t should go to the root.
  • Loading branch information
Mark-H committed May 2, 2011
1 parent 40b5a58 commit a233ae9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion assets/components/importx/js/mgr/widget.home.form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
Expand Down
8 changes: 5 additions & 3 deletions core/components/importx/lexicon/en/default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 8 additions & 2 deletions core/components/importx/processors/startimport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

Expand Down Expand Up @@ -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; }
Expand Down

0 comments on commit a233ae9

Please sign in to comment.