From c5adecb6e7906e1bd0283f857807ae3784093c27 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 3 Oct 2006 22:48:40 +0000 Subject: [PATCH] Update Item.toArray() to properly handle new note and attachment metadata -- it now adds 'note' for embedded notes in attachments and just calls toArray() recursively to grab URL, accessDate, etc. (I don't know if the export system will handle this properly or not.) --- chrome/content/zotero/xpcom/data_access.js | 51 +++++++++------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/chrome/content/zotero/xpcom/data_access.js b/chrome/content/zotero/xpcom/data_access.js index 8a1c6884c..d6f5adf87 100644 --- a/chrome/content/zotero/xpcom/data_access.js +++ b/chrome/content/zotero/xpcom/data_access.js @@ -1616,49 +1616,38 @@ Zotero.Item.prototype.toArray = function(){ arr['sourceItemID'] = this.getSource(); } } - // If not note, append attached notes - else { - arr['notes'] = []; - var notes = this.getNotes(); - for (var i in notes){ - var note = Zotero.Items.get(notes[i]); - arr['notes'].push({ - itemID: note.getID(), - note: note.getNote(), - tags: note.getTags(), - seeAlso: note.getSeeAlso() - }); - } - } // Attachments if (this.isAttachment()){ - // TODO: file data + // Attachments can have embedded notes + arr['note'] = this.getNote(); if (this.getSource()){ arr['sourceItemID'] = this.getSource(); } } - // If not file, append child attachments - else { - arr['attachments'] = []; - var files = this.getAttachments(); - for (var i in files){ - var file = Zotero.Items.get(files[i]); - arr['attachments'].push({ - itemID: file.getID(), - // TODO - tags: file.getTags(), - seeAlso: file.getSeeAlso() - }); - } - } - - arr['tags'] = this.getTags(); arr['seeAlso'] = this.getSeeAlso(); + // Attach children of regular items + if (this.isRegularItem()){ + // Append attached notes + arr['notes'] = []; + var notes = this.getNotes(); + for (var i in notes){ + var note = Zotero.Items.get(notes[i]); + arr['notes'].push(note.toArray()); + } + + arr['attachments'] = []; + var attachments = this.getAttachments(); + for (var i in attachments){ + var attachment = Zotero.Items.get(attachments[i]); + arr['attachments'].push(attachment.toArray()); + } + } + return arr; }