- don't export duplicate items
- don't export top-level collection name - use file name for name of collection when importing
This commit is contained in:
parent
d763b642b3
commit
983673e354
3 changed files with 23 additions and 11 deletions
|
@ -258,9 +258,21 @@ var Zotero_File_Interface = new function() {
|
|||
|
||||
function _importTranslatorsAvailable(translation, translators) {
|
||||
if(translators.length) {
|
||||
if(translation.location instanceof Components.interfaces.nsIFile) {
|
||||
var collectionName = translation.location.leafName.substr(0, translation.location.leafName.lastIndexOf("."));
|
||||
var allCollections = Zotero.getCollections();
|
||||
for(var i=0; i<allCollections.length; i++) {
|
||||
if(allCollections[i].name == collectionName) {
|
||||
collectionName += " "+(new Date()).toLocaleString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var collectionName = Zotero.getString("fileInterface.imported")+" "+(new Date()).toLocaleString();
|
||||
}
|
||||
|
||||
// create a new collection to take in imported items
|
||||
var date = new Date();
|
||||
_importCollection = Zotero.Collections.add(Zotero.getString("fileInterface.imported")+" "+date.toLocaleString());
|
||||
_importCollection = Zotero.Collections.add(collectionName);
|
||||
|
||||
// import items
|
||||
translation.setTranslator(translators[0]);
|
||||
|
|
|
@ -505,7 +505,9 @@ Zotero.Translate.ItemGetter.prototype = {
|
|||
|
||||
"setCollection":function(collection, getChildCollections) {
|
||||
// get items in this collection
|
||||
var haveItems = {};
|
||||
this._itemsLeft = collection.getChildItems();
|
||||
for each(var item in this._itemsLeft) haveItems[item.id] = true;
|
||||
if(!this._itemsLeft) {
|
||||
this._itemsLeft = [];
|
||||
}
|
||||
|
@ -514,16 +516,16 @@ Zotero.Translate.ItemGetter.prototype = {
|
|||
// get child collections
|
||||
this._collectionsLeft = Zotero.getCollections(collection.id, true);
|
||||
|
||||
if(this._collectionsLeft.length) {
|
||||
// only include parent collection if there are actually children
|
||||
this._collectionsLeft.unshift(collection);
|
||||
}
|
||||
|
||||
// get items in child collections
|
||||
for each(var collection in this._collectionsLeft) {
|
||||
var childItems = collection.getChildItems();
|
||||
if(childItems) {
|
||||
this._itemsLeft = this._itemsLeft.concat(childItems);
|
||||
for each(var item in childItems) {
|
||||
if(!haveItems[item.id]) {
|
||||
haveItems[item.id] = true;
|
||||
this._itemsLeft.push(item);;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -679,7 +681,7 @@ Zotero.Translate.ItemGetter.prototype = {
|
|||
var returnItemArray = this._attachmentToArray(returnItem);
|
||||
if(returnItemArray) return returnItemArray;
|
||||
} else {
|
||||
returnItemArray = this._itemToArray(returnItem);
|
||||
var returnItemArray = this._itemToArray(returnItem);
|
||||
|
||||
// get attachments, although only urls will be passed if exportFileData
|
||||
// is off
|
||||
|
|
|
@ -1526,8 +1526,6 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
|||
* (false)
|
||||
*/
|
||||
"addStatement":function(about, relation, value, literal) {
|
||||
this
|
||||
|
||||
if(literal) {
|
||||
// zap chars that Mozilla will mangle
|
||||
value = value.toString().replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, '');
|
||||
|
|
Loading…
Reference in a new issue