commit 471af0c8ab3b38ebffe4c2b6694f4d8abcbe9a58
parent 325c78d1d25eeb9c2a3fbb5e2bb2e89af7d01a30
Author: Simon Kornblith <simon@simonster.com>
Date: Sun, 8 Jul 2012 13:15:27 -0400
Merge branch '3.0'
Conflicts:
chrome/content/zotero/xpcom/translation/translate_firefox.js
chrome/content/zotero/xpcom/translation/translate_item.js
Diffstat:
3 files changed, 34 insertions(+), 31 deletions(-)
diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js
@@ -856,10 +856,18 @@ Zotero.Integration.Document.prototype._createNewSession = function(data) {
*/
Zotero.Integration.Document.prototype._getSession = function(require, dontRunSetDocPrefs, callback) {
var dataString = this._doc.getDocumentData(),
+ data,
me = this;
- if(!dataString) {
+
+ if(dataString) {
+ try {
+ data = new Zotero.Integration.DocumentData(dataString);
+ } catch(e) {};
+ }
+
+ if(!data) {
var haveFields = false;
- var data = new Zotero.Integration.DocumentData();
+ data = new Zotero.Integration.DocumentData();
if(require) {
// check to see if fields already exist
@@ -902,7 +910,6 @@ Zotero.Integration.Document.prototype._getSession = function(require, dontRunSet
callback(true);
});
} else {
- var data = new Zotero.Integration.DocumentData(dataString);
if(data.dataVersion < DATA_VERSION) {
if(data.dataVersion == 1
&& data.prefs.fieldType == "Field"
diff --git a/chrome/content/zotero/xpcom/translation/translate_item.js b/chrome/content/zotero/xpcom/translation/translate_item.js
@@ -328,17 +328,16 @@ Zotero.Translate.ItemSaver.prototype = {
"_saveAttachmentDownload":function(attachment, parentID, attachmentCallback) {
Zotero.debug("Translate: Adding attachment", 4);
- // determine whether to save attachments at all
- var automaticSnapshots = Zotero.Prefs.get("automaticSnapshots");
- var downloadAssociatedFiles = Zotero.Prefs.get("downloadAssociatedFiles");
-
if(!attachment.url && !attachment.document) {
Zotero.debug("Translate: Not adding attachment: no URL specified", 2);
} else {
- var shouldAttach = ((attachment.document
- || (attachment.mimeType && attachment.mimeType == "text/html")) && automaticSnapshots)
- || downloadAssociatedFiles;
- if(!shouldAttach) return false;
+ // Determine whether to save an attachment
+ if(attachment.document
+ || (attachment.mimeType && attachment.mimeType == "text/html")) {
+ if(!Zotero.Prefs.get("automaticSnapshots")) return;
+ } else {
+ if(!Zotero.Prefs.get("downloadAssociatedFiles")) return;
+ }
if(attachment.document) {
attachment.document = Zotero.Translate.DOMWrapper.unwrap(attachment.document);
@@ -377,28 +376,25 @@ Zotero.Translate.ItemSaver.prototype = {
} else {
// if snapshot is not explicitly set to false, retrieve snapshot
if(attachment.document) {
- if(automaticSnapshots) {
- try {
- attachment.linkMode = "imported_url";
- Zotero.Attachments.importFromDocument(attachment.document,
- parentID, attachment.title, null, function(status, err) {
- if(status) {
- attachmentCallback(attachment, 100);
- } else {
- attachmentCallback(attachment, false, err);
- }
- }, this._libraryID);
- attachmentCallback(attachment, 0);
- } catch(e) {
- Zotero.debug("Translate: Error attaching document", 2);
- attachmentCallback(attachment, false, e);
- }
- return true;
+ try {
+ attachment.linkMode = "imported_url";
+ Zotero.Attachments.importFromDocument(attachment.document,
+ parentID, attachment.title, null, function(status, err) {
+ if(status) {
+ attachmentCallback(attachment, 100);
+ } else {
+ attachmentCallback(attachment, false, err);
+ }
+ }, this._libraryID);
+ attachmentCallback(attachment, 0);
+ } catch(e) {
+ Zotero.debug("Translate: Error attaching document", 2);
+ attachmentCallback(attachment, false, e);
}
+ return true;
// Save attachment if snapshot pref enabled or not HTML
// (in which case downloadAssociatedFiles applies)
- } else if(this._saveFiles && (automaticSnapshots || !attachment.mimeType
- || attachment.mimeType != "text/html")) {
+ } else {
var mimeType = (attachment.mimeType ? attachment.mimeType : null);
var title = (attachment.title ? attachment.title : null);
diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties
@@ -585,7 +585,7 @@ annotations.oneWindowWarning = Annotations for a snapshot may only be opened in
integration.fields.label = Fields
integration.referenceMarks.label = ReferenceMarks
integration.fields.caption = Microsoft Word Fields are less likely to be accidentally modified, but cannot be shared with OpenOffice.
-integration.fields.fileFormatNotice = The document must be saved in the .doc or .docx file format.
+integration.fields.fileFormatNotice = The document must be saved in the .doc file format.
integration.referenceMarks.caption = OpenOffice ReferenceMarks are less likely to be accidentally modified, but cannot be shared with Microsoft Word.
integration.referenceMarks.fileFormatNotice = The document must be saved in the .odt file format.