commit 983673e354615f3393e1fd4ff77e788d660ba731
parent d763b642b357696582942a16e904c7e341534943
Author: Simon Kornblith <simon@simonster.com>
Date: Sat, 6 Nov 2010 22:20:53 +0000
- don't export duplicate items
- don't export top-level collection name
- use file name for name of collection when importing
Diffstat:
3 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js
@@ -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]);
diff --git a/chrome/content/zotero/xpcom/translation/item_local.js b/chrome/content/zotero/xpcom/translation/item_local.js
@@ -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
diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js
@@ -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, '');