www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit c5adecb6e7906e1bd0283f857807ae3784093c27
parent 56e77619c4a7a2fc016b9fc5bc8285805df91999
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue,  3 Oct 2006 22:48:40 +0000

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.)


Diffstat:
Mchrome/content/zotero/xpcom/data_access.js | 49+++++++++++++++++++------------------------------
1 file changed, 19 insertions(+), 30 deletions(-)

diff --git 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['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 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() - }); + var attachments = this.getAttachments(); + for (var i in attachments){ + var attachment = Zotero.Items.get(attachments[i]); + arr['attachments'].push(attachment.toArray()); } } - - arr['tags'] = this.getTags(); - arr['seeAlso'] = this.getSeeAlso(); - return arr; }