Renamed "Files" to "Attachments" -- since Files could be links as well as actually files (or both, for web page snapshots), things were getting just about as confusing as when Items were called Objects.
If you have attachments to the old terminology, feel free to file a complaint. Changed interface code too, since David is gone (or at the very least has more important things to do with his remaining time)
|
@ -46,9 +46,9 @@ ScholarItemPane = new function()
|
|||
this.modifyCreator = modifyCreator;
|
||||
this.removeNote = removeNote;
|
||||
this.addNote = addNote;
|
||||
this.removeFile = removeFile;
|
||||
this.addFileFromDialog = addFileFromDialog;
|
||||
this.addFileFromPage = addFileFromPage;
|
||||
this.removeAttachment = removeAttachment;
|
||||
this.addAttachmentFromDialog = addAttachmentFromDialog;
|
||||
this.addAttachmentFromPage = addAttachmentFromPage;
|
||||
|
||||
function onLoad()
|
||||
{
|
||||
|
@ -58,8 +58,8 @@ ScholarItemPane = new function()
|
|||
_creatorTypeMenu = document.getElementById('creatorTypeMenu');
|
||||
_notesList = document.getElementById('editpane-dynamic-notes');
|
||||
_notesLabel = document.getElementById('editpane-notes-label');
|
||||
_filesList = document.getElementById('editpane-dynamic-files');
|
||||
_filesLabel = document.getElementById('editpane-files-label');
|
||||
_attachmentsList = document.getElementById('editpane-dynamic-attachments');
|
||||
_attachmentsLabel = document.getElementById('editpane-attachments-label');
|
||||
_tagsBox = document.getElementById('editpane-tags');
|
||||
_relatedBox = document.getElementById('editpane-related');
|
||||
|
||||
|
@ -76,7 +76,7 @@ ScholarItemPane = new function()
|
|||
|
||||
var itemTypes = Scholar.ItemTypes.getTypes();
|
||||
for(var i = 0; i<itemTypes.length; i++)
|
||||
if(itemTypes[i]['name'] != 'note' && itemTypes[i]['name'] != 'file')
|
||||
if(itemTypes[i]['name'] != 'note' && itemTypes[i]['name'] != 'attachment')
|
||||
_itemTypeMenu.appendItem(Scholar.getString("itemTypes."+itemTypes[i]['name']),itemTypes[i]['id']);
|
||||
|
||||
return true;
|
||||
|
@ -186,42 +186,42 @@ ScholarItemPane = new function()
|
|||
}
|
||||
else if(index == 2)
|
||||
{
|
||||
//FILES
|
||||
while(_filesList.hasChildNodes())
|
||||
_filesList.removeChild(_filesList.firstChild);
|
||||
//ATTACHMENTS
|
||||
while(_attachmentsList.hasChildNodes())
|
||||
_attachmentsList.removeChild(_attachmentsList.firstChild);
|
||||
|
||||
var files = Scholar.Items.get(_itemBeingEdited.getFiles());
|
||||
if(files.length)
|
||||
var attachments = Scholar.Items.get(_itemBeingEdited.getAttachments());
|
||||
if(attachments.length)
|
||||
{
|
||||
for(var i = 0; i < files.length; i++)
|
||||
for(var i = 0; i < attachments.length; i++)
|
||||
{
|
||||
var icon = document.createElement('image');
|
||||
var linkMode = files[i].getFileLinkMode();
|
||||
if(linkMode == Scholar.Files.LINK_MODE_IMPORTED_FILE)
|
||||
var linkMode = attachments[i].getAttachmentLinkMode();
|
||||
if(linkMode == Scholar.Attachments.LINK_MODE_IMPORTED_FILE)
|
||||
{
|
||||
itemType = "-file";
|
||||
}
|
||||
else if(linkMode == Scholar.Files.LINK_MODE_LINKED_FILE)
|
||||
else if(linkMode == Scholar.Attachments.LINK_MODE_LINKED_FILE)
|
||||
{
|
||||
itemType = "-link";
|
||||
}
|
||||
else if(linkMode == Scholar.Files.LINK_MODE_IMPORTED_URL)
|
||||
else if(linkMode == Scholar.Attachments.LINK_MODE_IMPORTED_URL)
|
||||
{
|
||||
itemType = "-snapshot";
|
||||
}
|
||||
else if(linkMode == Scholar.Files.LINK_MODE_LINKED_URL)
|
||||
else if(linkMode == Scholar.Attachments.LINK_MODE_LINKED_URL)
|
||||
{
|
||||
itemType = "-web-link";
|
||||
}
|
||||
icon.setAttribute('src','chrome://scholar/skin/treeitem-file'+itemType+'.png');
|
||||
|
||||
var label = document.createElement('label');
|
||||
label.setAttribute('value',files[i].getField('title'));
|
||||
label.setAttribute('value',attachments[i].getField('title'));
|
||||
label.setAttribute('flex','1'); //so that the long names will flex smaller
|
||||
label.setAttribute('crop','end');
|
||||
|
||||
var box = document.createElement('box');
|
||||
box.setAttribute('onclick',"ScholarPane.selectItem('"+files[i].getID()+"')");
|
||||
box.setAttribute('onclick',"ScholarPane.selectItem('"+attachments[i].getID()+"')");
|
||||
box.setAttribute('class','clicky');
|
||||
box.appendChild(icon);
|
||||
box.appendChild(label);
|
||||
|
@ -229,17 +229,17 @@ ScholarItemPane = new function()
|
|||
var removeButton = document.createElement('label');
|
||||
removeButton.setAttribute("value","-");
|
||||
removeButton.setAttribute("class","clicky");
|
||||
removeButton.setAttribute("onclick","ScholarItemPane.removeFile("+files[i].getID()+")");
|
||||
removeButton.setAttribute("onclick","ScholarItemPane.removeAttachment("+attachments[i].getID()+")");
|
||||
|
||||
var row = document.createElement('row');
|
||||
row.appendChild(box);
|
||||
row.appendChild(removeButton);
|
||||
|
||||
_filesList.appendChild(row);
|
||||
_attachmentsList.appendChild(row);
|
||||
}
|
||||
}
|
||||
|
||||
_updateFileCount();
|
||||
_updateAttachmentCount();
|
||||
|
||||
}
|
||||
else if(index == 3)
|
||||
|
@ -471,29 +471,29 @@ ScholarItemPane = new function()
|
|||
_notesLabel.value = Scholar.getString('pane.item.notes.count.'+(c != 1 ? "plural" : "singular")).replace('%1',c) + ":";
|
||||
}
|
||||
|
||||
function _updateFileCount()
|
||||
function _updateAttachmentCount()
|
||||
{
|
||||
var c = _filesList.childNodes.length;
|
||||
var c = _attachmentsList.childNodes.length;
|
||||
|
||||
_filesLabel.value = Scholar.getString('pane.item.files.count.'+(c != 1 ? "plural" : "singular")).replace('%1',c) + ":";
|
||||
_attachmentsLabel.value = Scholar.getString('pane.item.attachments.count.'+(c != 1 ? "plural" : "singular")).replace('%1',c) + ":";
|
||||
}
|
||||
|
||||
function removeFile(id)
|
||||
function removeAttachment(id)
|
||||
{
|
||||
var file = Scholar.Items.get(id);
|
||||
if(file)
|
||||
if(confirm(Scholar.getString('pane.item.files.delete.confirm')))
|
||||
file.erase();
|
||||
var attachment = Scholar.Items.get(id);
|
||||
if(attachment)
|
||||
if(confirm(Scholar.getString('pane.item.attachments.delete.confirm')))
|
||||
attachment.erase();
|
||||
}
|
||||
|
||||
function addFileFromDialog(link)
|
||||
function addAttachmentFromDialog(link)
|
||||
{
|
||||
ScholarPane.addFileFromDialog(link, _itemBeingEdited.getID());
|
||||
ScholarPane.addAttachmentFromDialog(link, _itemBeingEdited.getID());
|
||||
}
|
||||
|
||||
function addFileFromPage(link)
|
||||
function addAttachmentFromPage(link)
|
||||
{
|
||||
ScholarPane.addFileFromPage(link, _itemBeingEdited.getID());
|
||||
ScholarPane.addAttachmentFromPage(link, _itemBeingEdited.getID());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,13 +58,13 @@
|
|||
</vbox>
|
||||
<vbox flex="1">
|
||||
<hbox align="center">
|
||||
<label id="editpane-files-label"/>
|
||||
<button id="tb-item-files-add" type="menu" label="&item.add;">
|
||||
<label id="editpane-attachments-label"/>
|
||||
<button id="tb-item-attachments-add" type="menu" label="&item.add;">
|
||||
<menupopup>
|
||||
<menuitem class="menuitem-iconic" id="tb-item-files-link" label="&toolbar.file.linked;" oncommand="ScholarItemPane.addFileFromDialog(true);"/>
|
||||
<menuitem class="menuitem-iconic" id="tb-item-files-file" label="&toolbar.file.add;" oncommand="ScholarItemPane.addFileFromDialog();"/>
|
||||
<menuitem class="menuitem-iconic" id="tb-item-files-web-link" label="&toolbar.file.weblink;" oncommand="ScholarItemPane.addFileFromPage(true);"/>
|
||||
<menuitem class="menuitem-iconic" id="tb-item-files-snapshot" label="&toolbar.file.snapshot;" oncommand="ScholarItemPane.addFileFromPage();"/>
|
||||
<menuitem class="menuitem-iconic" id="tb-item-attachments-link" label="&toolbar.attachment.linked;" oncommand="ScholarItemPane.addAttachmentFromDialog(true);"/>
|
||||
<menuitem class="menuitem-iconic" id="tb-item-attachments-file" label="&toolbar.attachment.add;" oncommand="ScholarItemPane.addAttachmentFromDialog();"/>
|
||||
<menuitem class="menuitem-iconic" id="tb-item-attachments-web-link" label="&toolbar.attachment.weblink;" oncommand="ScholarItemPane.addAttachmentFromPage(true);"/>
|
||||
<menuitem class="menuitem-iconic" id="tb-item-attachments-snapshot" label="&toolbar.attachment.snapshot;" oncommand="ScholarItemPane.addAttachmentFromPage();"/>
|
||||
</menupopup>
|
||||
</button>
|
||||
</hbox>
|
||||
|
@ -73,7 +73,7 @@
|
|||
<column flex="1"/>
|
||||
<column/>
|
||||
</columns>
|
||||
<rows id="editpane-dynamic-files" flex="1"/>
|
||||
<rows id="editpane-dynamic-attachments" flex="1"/>
|
||||
</grid>
|
||||
</vbox>
|
||||
<tagsbox id="editpane-tags" flex="1"/>
|
||||
|
|
|
@ -144,7 +144,7 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids)
|
|||
|
||||
if(!item.getSource())
|
||||
{
|
||||
//most likely, the note or file's parent was removed.
|
||||
//most likely, the note or attachment's parent was removed.
|
||||
this._showItem(new Scholar.ItemTreeView.TreeRow(item,0,false),this.rowCount);
|
||||
this._treebox.rowCountChanged(this.rowCount-1,1);
|
||||
madeChanges = true;
|
||||
|
@ -240,22 +240,22 @@ Scholar.ItemTreeView.prototype.getImageSrc = function(row, col)
|
|||
{
|
||||
var item = this._getItemAtRow(row);
|
||||
var itemType = Scholar.ItemTypes.getName(item.getType());
|
||||
if(itemType == 'file')
|
||||
if(itemType == 'attachment')
|
||||
{
|
||||
var linkMode = item.ref.getFileLinkMode();
|
||||
if(linkMode == Scholar.Files.LINK_MODE_IMPORTED_FILE)
|
||||
var linkMode = item.ref.getAttachmentLinkMode();
|
||||
if(linkMode == Scholar.Attachments.LINK_MODE_IMPORTED_FILE)
|
||||
{
|
||||
itemType = itemType + "-file";
|
||||
}
|
||||
else if(linkMode == Scholar.Files.LINK_MODE_LINKED_FILE)
|
||||
else if(linkMode == Scholar.Attachments.LINK_MODE_LINKED_FILE)
|
||||
{
|
||||
itemType = itemType + "-link";
|
||||
}
|
||||
else if(linkMode == Scholar.Files.LINK_MODE_IMPORTED_URL)
|
||||
else if(linkMode == Scholar.Attachments.LINK_MODE_IMPORTED_URL)
|
||||
{
|
||||
itemType = itemType + "-snapshot";
|
||||
}
|
||||
else if(linkMode == Scholar.Files.LINK_MODE_LINKED_URL)
|
||||
else if(linkMode == Scholar.Attachments.LINK_MODE_LINKED_URL)
|
||||
{
|
||||
itemType = itemType + "-web-link";
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ Scholar.ItemTreeView.prototype.isContainerOpen = function(row)
|
|||
|
||||
Scholar.ItemTreeView.prototype.isContainerEmpty = function(row)
|
||||
{
|
||||
return (this._getItemAtRow(row).numNotes() == 0 && this._getItemAtRow(row).numFiles() == 0);
|
||||
return (this._getItemAtRow(row).numNotes() == 0 && this._getItemAtRow(row).numAttachments() == 0);
|
||||
}
|
||||
|
||||
Scholar.ItemTreeView.prototype.getLevel = function(row)
|
||||
|
@ -323,14 +323,14 @@ Scholar.ItemTreeView.prototype.toggleOpenState = function(row)
|
|||
{
|
||||
var item = this._getItemAtRow(row).ref;
|
||||
//Get children
|
||||
var files = item.getFiles();
|
||||
var attachments = item.getAttachments();
|
||||
var notes = item.getNotes();
|
||||
|
||||
var newRows;
|
||||
if(files && notes)
|
||||
newRows = files.concat(notes);
|
||||
else if(files)
|
||||
newRows = files;
|
||||
if(attachments && notes)
|
||||
newRows = attachments.concat(notes);
|
||||
else if(attachments)
|
||||
newRows = attachments;
|
||||
else if(notes)
|
||||
newRows = notes;
|
||||
|
||||
|
@ -737,9 +737,9 @@ Scholar.ItemTreeView.TreeRow.prototype.isNote = function()
|
|||
return this.ref.isNote();
|
||||
}
|
||||
|
||||
Scholar.ItemTreeView.TreeRow.prototype.isFile = function()
|
||||
Scholar.ItemTreeView.TreeRow.prototype.isAttachment = function()
|
||||
{
|
||||
return this.ref.isFile();
|
||||
return this.ref.isAttachment();
|
||||
}
|
||||
|
||||
Scholar.ItemTreeView.TreeRow.prototype.isRegularItem = function()
|
||||
|
@ -780,10 +780,10 @@ Scholar.ItemTreeView.TreeRow.prototype.numNotes = function()
|
|||
return 0;
|
||||
}
|
||||
|
||||
Scholar.ItemTreeView.TreeRow.prototype.numFiles = function()
|
||||
Scholar.ItemTreeView.TreeRow.prototype.numAttachments = function()
|
||||
{
|
||||
if(this.isRegularItem())
|
||||
return this.ref.numFiles();
|
||||
return this.ref.numAttachments();
|
||||
else
|
||||
return 0;
|
||||
}
|
|
@ -50,9 +50,9 @@ var ScholarPane = new function()
|
|||
this.onDoubleClick = onDoubleClick;
|
||||
this.openNoteWindow = openNoteWindow;
|
||||
this.newNote = newNote;
|
||||
this.addFileFromDialog = addFileFromDialog;
|
||||
this.addFileFromPage = addFileFromPage;
|
||||
this.viewSelectedFile = viewSelectedFile;
|
||||
this.addAttachmentFromDialog = addAttachmentFromDialog;
|
||||
this.addAttachmentFromPage = addAttachmentFromPage;
|
||||
this.viewSelectedAttachment = viewSelectedAttachment;
|
||||
|
||||
/*
|
||||
* Called when the window is open
|
||||
|
@ -223,11 +223,11 @@ var ScholarPane = new function()
|
|||
document.getElementById('scholar-view-note-button').removeAttribute('sourceID');
|
||||
document.getElementById('item-pane').selectedIndex = 2;
|
||||
}
|
||||
else if(item.isFile())
|
||||
else if(item.isAttachment())
|
||||
{
|
||||
document.getElementById('scholar-file-label').setAttribute('value',item.getField('title'));
|
||||
document.getElementById('scholar-file-view').setAttribute('disabled', item.ref.getFileLinkMode() == Scholar.Files.LINK_MODE_LINKED_URL);
|
||||
document.getElementById('scholar-file-links').item = item.ref;
|
||||
document.getElementById('scholar-attachment-label').setAttribute('value',item.getField('title'));
|
||||
document.getElementById('scholar-attachment-view').setAttribute('disabled', item.ref.getAttachmentLinkMode() == Scholar.Attachments.LINK_MODE_LINKED_URL);
|
||||
document.getElementById('scholar-attachment-links').item = item.ref;
|
||||
document.getElementById('item-pane').selectedIndex = 3;
|
||||
}
|
||||
else
|
||||
|
@ -267,7 +267,7 @@ var ScholarPane = new function()
|
|||
{
|
||||
itemsView.selection.getRangeAt(i,start,end);
|
||||
for (var j=start.value; j<=end.value && !hasChildren; j++)
|
||||
if(itemsView._getItemAtRow(j).numNotes() || itemsView._getItemAtRow(j).numFiles())
|
||||
if(itemsView._getItemAtRow(j).numNotes() || itemsView._getItemAtRow(j).numAttachments())
|
||||
hasChildren = true;
|
||||
}
|
||||
}
|
||||
|
@ -443,9 +443,9 @@ var ScholarPane = new function()
|
|||
{
|
||||
document.getElementById('scholar-view-note-button').doCommand();
|
||||
}
|
||||
else if(item && item.isFile())
|
||||
else if(item && item.isAttachment())
|
||||
{
|
||||
viewSelectedFile();
|
||||
viewSelectedAttachment();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -465,31 +465,31 @@ var ScholarPane = new function()
|
|||
window.open('chrome://scholar/content/note.xul?v=1'+(id ? '&id='+id : '')+(parent ? '&coll='+parent : ''),'','chrome,resizable,centerscreen');
|
||||
}
|
||||
|
||||
function addFileFromDialog(link, id)
|
||||
function addAttachmentFromDialog(link, id)
|
||||
{
|
||||
var nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"]
|
||||
.createInstance(nsIFilePicker);
|
||||
fp.init(window, Scholar.getString('pane.item.files.select'), nsIFilePicker.modeOpen);
|
||||
fp.init(window, Scholar.getString('pane.item.attachments.select'), nsIFilePicker.modeOpen);
|
||||
|
||||
if(fp.show() == nsIFilePicker.returnOK)
|
||||
{
|
||||
var fileID;
|
||||
var attachmentID;
|
||||
if(link)
|
||||
fileID = Scholar.Files.linkFromFile(fp.file, id);
|
||||
attachmentID = Scholar.Attachments.linkFromFile(fp.file, id);
|
||||
else
|
||||
fileID = Scholar.Files.importFromFile(fp.file, id);
|
||||
attachmentID = Scholar.Attachments.importFromFile(fp.file, id);
|
||||
|
||||
if(fileID && !id)
|
||||
if(attachmentID && !id)
|
||||
{
|
||||
var c = getSelectedCollection();
|
||||
if(c)
|
||||
c.addItem(fileID);
|
||||
c.addItem(attachmentID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addFileFromPage(link, id)
|
||||
function addAttachmentFromPage(link, id)
|
||||
{
|
||||
var item;
|
||||
if(id == null)
|
||||
|
@ -504,36 +504,36 @@ var ScholarPane = new function()
|
|||
}
|
||||
}
|
||||
|
||||
var fileID;
|
||||
var attachmentID;
|
||||
if(link)
|
||||
fileID = Scholar.Files.linkFromDocument(window.content.document, id);
|
||||
attachmentID = Scholar.Attachments.linkFromDocument(window.content.document, id);
|
||||
else
|
||||
fileID = Scholar.Files.importFromDocument(window.content.document, id);
|
||||
attachmentID = Scholar.Attachments.importFromDocument(window.content.document, id);
|
||||
|
||||
if(fileID && item)
|
||||
if(attachmentID && item)
|
||||
{
|
||||
var file = Scholar.Items.get(fileID);
|
||||
if(file)
|
||||
var attachment = Scholar.Items.get(attachmentID);
|
||||
if(attachment)
|
||||
{
|
||||
item.setField('title',file.getField('title'));
|
||||
item.setField('title',attachment.getField('title'));
|
||||
item.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function viewSelectedFile()
|
||||
function viewSelectedAttachment()
|
||||
{
|
||||
if(itemsView && itemsView.selection.count == 1)
|
||||
{
|
||||
var file = getSelectedItems()[0];
|
||||
var attachment = getSelectedItems()[0];
|
||||
|
||||
if(file.getFileLinkMode() != Scholar.Files.LINK_MODE_LINKED_URL)
|
||||
if(attachment.getAttachmentLinkMode() != Scholar.Attachments.LINK_MODE_LINKED_URL)
|
||||
{
|
||||
window.loadURI(file.getLocalFileURL());
|
||||
window.loadURI(attachment.getLocalFileURL());
|
||||
}
|
||||
else
|
||||
{
|
||||
window.loadURI(file.getFileURL());
|
||||
window.loadURI(attachment.getURL());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,12 +101,12 @@
|
|||
<toolbarbutton id="tb-add" tooltiptext="&toolbar.newItem.label;" type="menu">
|
||||
<menupopup/>
|
||||
</toolbarbutton>
|
||||
<toolbarbutton id="tb-file-add" type="menu" tooltiptext="&toolbar.file.standalone;">
|
||||
<toolbarbutton id="tb-attachment-add" type="menu" tooltiptext="&toolbar.attachment.standalone;">
|
||||
<menupopup>
|
||||
<menuitem label="&toolbar.file.linked;" oncommand="ScholarPane.addFileFromDialog(true);"/>
|
||||
<menuitem label="&toolbar.file.add;" oncommand="ScholarPane.addFileFromDialog();"/>
|
||||
<menuitem label="&toolbar.file.weblink;" oncommand="ScholarPane.addFileFromPage(true);"/>
|
||||
<menuitem label="&toolbar.file.snapshot;" oncommand="ScholarPane.addFileFromPage();"/>
|
||||
<menuitem label="&toolbar.attachment.linked;" oncommand="ScholarPane.addAttachmentFromDialog(true);"/>
|
||||
<menuitem label="&toolbar.attachment.add;" oncommand="ScholarPane.addAttachmentFromDialog();"/>
|
||||
<menuitem label="&toolbar.attachment.weblink;" oncommand="ScholarPane.addAttachmentFromPage(true);"/>
|
||||
<menuitem label="&toolbar.attachment.snapshot;" oncommand="ScholarPane.addAttachmentFromPage();"/>
|
||||
</menupopup>
|
||||
</toolbarbutton>
|
||||
<toolbarbutton id="tb-note-add" tooltiptext="&toolbar.note.standalone;" oncommand="ScholarPane.newNote();"/>
|
||||
|
@ -180,7 +180,7 @@
|
|||
<tabs id="scholar-view-tabs" onselect="document.getElementById('scholar-view-item').selectedIndex = this.selectedIndex;" hidden="true">
|
||||
<tab label="&tabs.info.label;"/>
|
||||
<tab label="&tabs.notes.label;"/>
|
||||
<tab label="&tabs.files.label;"/>
|
||||
<tab label="&tabs.attachments.label;"/>
|
||||
<tab label="&tabs.tags.label;"/>
|
||||
<tab label="&tabs.related.label;"/>
|
||||
</tabs>
|
||||
|
@ -194,10 +194,10 @@
|
|||
<noteeditor id="scholar-note-editor" flex="1"/>
|
||||
<button id="scholar-view-note-button" label="¬es.separate;" oncommand="ScholarPane.openNoteWindow(this.getAttribute('noteID')); if(this.hasAttribute('sourceID')) ScholarPane.selectItem(this.getAttribute('sourceID'));"/>
|
||||
</vbox>
|
||||
<vbox id="scholar-view-file" flex="1">
|
||||
<label id="scholar-file-label"/>
|
||||
<button id="scholar-file-view" label="View File" oncommand="ScholarPane.viewSelectedFile();"/>
|
||||
<linksbox id="scholar-file-links" flex="1"/>
|
||||
<vbox id="scholar-view-attachment" flex="1">
|
||||
<label id="scholar-attachment-label"/>
|
||||
<button id="scholar-attachment-view" label="View Attachment" oncommand="ScholarPane.viewSelectedAttachment();"/>
|
||||
<linksbox id="scholar-attachment-links" flex="1"/>
|
||||
</vbox>
|
||||
</deck>
|
||||
</groupbox>
|
||||
|
|
|
@ -49,7 +49,7 @@ Scholar.Item.prototype.isPrimaryField = function(field){
|
|||
Scholar.Item.primaryFields = Scholar.DB.getColumnHash('items');
|
||||
Scholar.Item.primaryFields['firstCreator'] = true;
|
||||
Scholar.Item.primaryFields['numNotes'] = true;
|
||||
Scholar.Item.primaryFields['numFiles'] = true;
|
||||
Scholar.Item.primaryFields['numAttachments'] = true;
|
||||
}
|
||||
|
||||
return !!Scholar.Item.primaryFields[field];
|
||||
|
@ -77,7 +77,7 @@ Scholar.Item.prototype.loadFromID = function(id){
|
|||
+ 'CASE ((SELECT COUNT(*) FROM itemCreators WHERE itemID=' + id + ')>1) '
|
||||
+ "WHEN 0 THEN '' ELSE ' et al.' END AS firstCreator, "
|
||||
+ "(SELECT COUNT(*) FROM itemNotes WHERE sourceItemID=I.itemID) AS numNotes, "
|
||||
+ "(SELECT COUNT(*) FROM itemFiles WHERE sourceItemID=I.itemID) AS numFiles "
|
||||
+ "(SELECT COUNT(*) FROM itemAttachments WHERE sourceItemID=I.itemID) AS numAttachments "
|
||||
+ 'FROM items I '
|
||||
+ 'LEFT JOIN itemCreators IC ON (I.itemID=IC.itemID) '
|
||||
+ 'LEFT JOIN creators C ON (IC.creatorID=C.creatorID) '
|
||||
|
@ -778,7 +778,7 @@ Scholar.Item.prototype.updateDateModified = function(){
|
|||
|
||||
|
||||
Scholar.Item.prototype.isRegularItem = function(){
|
||||
return !(this.isNote() || this.isFile());
|
||||
return !(this.isNote() || this.isAttachment());
|
||||
}
|
||||
|
||||
|
||||
|
@ -851,12 +851,12 @@ Scholar.Item.prototype.setSource = function(sourceItemID){
|
|||
var type = 'note';
|
||||
var Type = 'Note';
|
||||
}
|
||||
else if (this.isFile()){
|
||||
var type = 'file';
|
||||
var Type = 'file';
|
||||
else if (this.isAttachment()){
|
||||
var type = 'attachment';
|
||||
var Type = 'Attachment';
|
||||
}
|
||||
else {
|
||||
throw ("setSource() can only be called on items of type 'note' or 'file'");
|
||||
throw ("setSource() can only be called on items of type 'note' or 'attachment'");
|
||||
}
|
||||
|
||||
if (!this.getID()){
|
||||
|
@ -902,8 +902,8 @@ Scholar.Item.prototype.setSource = function(sourceItemID){
|
|||
case 'note':
|
||||
oldItem.decrementNoteCount();
|
||||
break;
|
||||
case 'file':
|
||||
oldItem.decrementFileCount();
|
||||
case 'attachment':
|
||||
oldItem.decrementAttachmentCount();
|
||||
break;
|
||||
}
|
||||
Scholar.Notifier.trigger('modify', 'item', oldSourceItemID);
|
||||
|
@ -913,8 +913,8 @@ Scholar.Item.prototype.setSource = function(sourceItemID){
|
|||
case 'note':
|
||||
newItem.incrementNoteCount();
|
||||
break;
|
||||
case 'file':
|
||||
newItem.incrementFileCount();
|
||||
case 'attachment':
|
||||
newItem.incrementAttachmentCount();
|
||||
break;
|
||||
}
|
||||
Scholar.Notifier.trigger('modify', 'item', sourceItemID);
|
||||
|
@ -970,11 +970,11 @@ Scholar.Item.prototype.getSource = function(){
|
|||
if (this.isNote()){
|
||||
var Type = 'Note';
|
||||
}
|
||||
else if (this.isFile()){
|
||||
var Type = 'File';
|
||||
else if (this.isAttachment()){
|
||||
var Type = 'Attachment';
|
||||
}
|
||||
else {
|
||||
throw ("getSource() can only be called on items of type 'note' or 'file'");
|
||||
throw ("getSource() can only be called on items of type 'note' or 'attachment'");
|
||||
}
|
||||
|
||||
var sql = "SELECT sourceItemID FROM item" + Type + "s WHERE itemID=" + this.getID();
|
||||
|
@ -1003,65 +1003,66 @@ Scholar.Item.prototype.getNotes = function(){
|
|||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// Methods dealing with file items
|
||||
// Methods dealing with attachments
|
||||
//
|
||||
// save() is not required for file functions
|
||||
// save() is not required for attachment functions
|
||||
//
|
||||
///////////////////////////////////////////////////////
|
||||
Scholar.Item.prototype.incrementFileCount = function(){
|
||||
this._data['numFiles']++;
|
||||
Scholar.Item.prototype.incrementAttachmentCount = function(){
|
||||
this._data['numAttachments']++;
|
||||
}
|
||||
|
||||
|
||||
Scholar.Item.prototype.decrementFileCount = function(){
|
||||
this._data['numFiles']--;
|
||||
Scholar.Item.prototype.decrementAttachmentCount = function(){
|
||||
this._data['numAttachments']--;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine if an item is a file
|
||||
* Determine if an item is an attachment
|
||||
**/
|
||||
Scholar.Item.prototype.isFile = function(){
|
||||
return Scholar.ItemTypes.getName(this.getType())=='file';
|
||||
Scholar.Item.prototype.isAttachment = function(){
|
||||
return Scholar.ItemTypes.getName(this.getType())=='attachment';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns number of files in item
|
||||
**/
|
||||
Scholar.Item.prototype.numFiles = function(){
|
||||
if (this.isFile()){
|
||||
throw ("numFiles() cannot be called on items of type 'file'");
|
||||
Scholar.Item.prototype.numAttachments = function(){
|
||||
if (this.isAttachment()){
|
||||
throw ("numAttachments() cannot be called on items of type 'attachment'");
|
||||
}
|
||||
|
||||
if (!this.getID()){
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this._data['numFiles'];
|
||||
return this._data['numAttachments'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get an nsILocalFile for the file item, or false if the associated file doesn't exist
|
||||
* Get an nsILocalFile for the attachment, or false if the associated file
|
||||
* doesn't exist
|
||||
*
|
||||
* Note: Always returns false for items with LINK_MODE_LINKED_URL,
|
||||
* since they have no files -- use getFileURL() instead
|
||||
* since they have no files -- use getURL() instead
|
||||
**/
|
||||
Scholar.Item.prototype.getFile = function(){
|
||||
if (!this.isFile()){
|
||||
throw ("getFile() can only be called on items of type 'file'");
|
||||
if (!this.isAttachment()){
|
||||
throw ("getFile() can only be called on items of type 'attachment'");
|
||||
}
|
||||
|
||||
var sql = "SELECT linkMode, path FROM itemFiles WHERE itemID=" + this.getID();
|
||||
var sql = "SELECT linkMode, path FROM itemAttachments WHERE itemID=" + this.getID();
|
||||
var row = Scholar.DB.rowQuery(sql);
|
||||
|
||||
if (!row){
|
||||
throw ('File data not found for item ' + this.getID() + ' in getFile()');
|
||||
throw ('Attachment data not found for item ' + this.getID() + ' in getFile()');
|
||||
}
|
||||
|
||||
// No associated files for linked URLs
|
||||
if (row['linkMode']==Scholar.Files.LINK_MODE_LINKED_URL){
|
||||
if (row['linkMode']==Scholar.Attachments.LINK_MODE_LINKED_URL){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1083,26 +1084,26 @@ Scholar.Item.prototype.getFile = function(){
|
|||
/*
|
||||
* Return the URL string associated with a linked or imported URL
|
||||
*/
|
||||
Scholar.Item.prototype.getFileURL = function(){
|
||||
if (!this.isFile()){
|
||||
throw ("getFileURL() can only be called on items of type 'file'");
|
||||
Scholar.Item.prototype.getURL = function(){
|
||||
if (!this.isAttachment()){
|
||||
throw ("getURL() can only be called on items of type 'attachment'");
|
||||
}
|
||||
|
||||
var sql = "SELECT linkMode, path, originalPath FROM itemFiles "
|
||||
var sql = "SELECT linkMode, path, originalPath FROM itemAttachments "
|
||||
+ "WHERE itemID=" + this.getID();
|
||||
var row = Scholar.DB.rowQuery(sql);
|
||||
|
||||
if (!row){
|
||||
throw ('File data not found for item ' + this.getID() + ' in getFileURL()');
|
||||
throw ('Attachment data not found for item ' + this.getID() + ' in getURL()');
|
||||
}
|
||||
|
||||
switch (row['linkMode']){
|
||||
case Scholar.Files.LINK_MODE_LINKED_URL:
|
||||
case Scholar.Attachments.LINK_MODE_LINKED_URL:
|
||||
return row['path'];
|
||||
case Scholar.Files.LINK_MODE_IMPORTED_URL:
|
||||
case Scholar.Attachments.LINK_MODE_IMPORTED_URL:
|
||||
return row['originalPath'];
|
||||
default:
|
||||
throw ('getFileURL() cannot be called on files without associated URLs');
|
||||
throw ('getURL() cannot be called on attachments without associated URLs');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1111,8 +1112,8 @@ Scholar.Item.prototype.getFileURL = function(){
|
|||
* Return a file:/// URL path to files and snapshots
|
||||
*/
|
||||
Scholar.Item.prototype.getLocalFileURL = function(){
|
||||
if (!this.isFile){
|
||||
throw ("getLocalFileURL() can only be called on items of type 'file'");
|
||||
if (!this.isAttachment){
|
||||
throw ("getLocalFileURL() can only be called on items of type 'attachment'");
|
||||
}
|
||||
|
||||
var file = this.getFile();
|
||||
|
@ -1125,65 +1126,65 @@ Scholar.Item.prototype.getLocalFileURL = function(){
|
|||
|
||||
|
||||
/**
|
||||
* Get the link mode of a file item
|
||||
* Get the link mode of an attachment
|
||||
*
|
||||
* Possible return values specified as constants in Scholar.Files
|
||||
* (e.g. Scholar.Files.LINK_MODE_LINKED_FILE)
|
||||
* Possible return values specified as constants in Scholar.Attachments
|
||||
* (e.g. Scholar.Attachments.LINK_MODE_LINKED_FILE)
|
||||
**/
|
||||
Scholar.Item.prototype.getFileLinkMode = function(){
|
||||
if (!this.isFile()){
|
||||
throw ("getFileLinkMode() can only be called on items of type 'file'");
|
||||
Scholar.Item.prototype.getAttachmentLinkMode = function(){
|
||||
if (!this.isAttachment()){
|
||||
throw ("getAttachmentLinkMode() can only be called on items of type 'attachment'");
|
||||
}
|
||||
|
||||
if (this._fileLinkMode!==null){
|
||||
return this._fileLinkMode;
|
||||
}
|
||||
|
||||
var sql = "SELECT linkMode FROM itemFiles WHERE itemID=" + this.getID();
|
||||
var sql = "SELECT linkMode FROM itemAttachments WHERE itemID=" + this.getID();
|
||||
this._fileLinkMode = Scholar.DB.valueQuery(sql);
|
||||
return this._fileLinkMode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the mime type of a file item (e.g. text/plain)
|
||||
* Get the mime type of an attachment (e.g. text/plain)
|
||||
**/
|
||||
Scholar.Item.prototype.getFileMimeType = function(){
|
||||
if (!this.isFile()){
|
||||
throw ("getFileData() can only be called on items of type 'file'");
|
||||
Scholar.Item.prototype.getAttachmentMimeType = function(){
|
||||
if (!this.isAttachment()){
|
||||
throw ("getAttachmentMIMEType() can only be called on items of type 'attachment'");
|
||||
}
|
||||
|
||||
var sql = "SELECT mimeType FROM itemFiles WHERE itemID=" + this.getID();
|
||||
var sql = "SELECT mimeType FROM itemAttachments WHERE itemID=" + this.getID();
|
||||
return Scholar.DB.valueQuery(sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the character set id of a file item
|
||||
* Get the character set id of an attachment
|
||||
**/
|
||||
Scholar.Item.prototype.getFileCharset = function(){
|
||||
if (!this.isFile()){
|
||||
throw ("getFileCharset() can only be called on items of type 'file'");
|
||||
Scholar.Item.prototype.getAttachmentCharset = function(){
|
||||
if (!this.isAttachment()){
|
||||
throw ("getAttachmentCharset() can only be called on items of type 'attachment'");
|
||||
}
|
||||
|
||||
var sql = "SELECT charsetID FROM itemFiles WHERE itemID=" + this.getID();
|
||||
var sql = "SELECT charsetID FROM itemAttachments WHERE itemID=" + this.getID();
|
||||
return Scholar.DB.valueQuery(sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of file itemIDs for this item
|
||||
* Returns an array of attachment itemIDs that have this item as a source
|
||||
**/
|
||||
Scholar.Item.prototype.getFiles = function(){
|
||||
if (this.isFile()){
|
||||
throw ("getFiles() cannot be called on items of type 'file'");
|
||||
Scholar.Item.prototype.getAttachments = function(){
|
||||
if (this.isAttachment()){
|
||||
throw ("getAttachments() cannot be called on items of type 'attachment'");
|
||||
}
|
||||
|
||||
if (!this.getID()){
|
||||
return [];
|
||||
}
|
||||
|
||||
var sql = "SELECT itemID FROM itemFiles NATURAL JOIN items "
|
||||
var sql = "SELECT itemID FROM itemAttachments NATURAL JOIN items "
|
||||
+ "WHERE sourceItemID=" + this.getID() + " ORDER BY dateAdded";
|
||||
return Scholar.DB.columnQuery(sql);
|
||||
}
|
||||
|
@ -1325,22 +1326,22 @@ Scholar.Item.prototype.erase = function(deleteChildren){
|
|||
changedItems.push(sourceItemID);
|
||||
}
|
||||
}
|
||||
// File
|
||||
else if (this.isFile()){
|
||||
// Attachment
|
||||
else if (this.isAttachment()){
|
||||
// Decrement file count of source items
|
||||
var sql = "SELECT sourceItemID FROM itemFiles WHERE itemID=" + this.getID();
|
||||
var sql = "SELECT sourceItemID FROM itemAttachments WHERE itemID=" + this.getID();
|
||||
var sourceItemID = Scholar.DB.valueQuery(sql);
|
||||
if (sourceItemID){
|
||||
var sourceItem = Scholar.Items.get(sourceItemID);
|
||||
sourceItem.decrementFileCount();
|
||||
sourceItem.decrementAttachmentCount();
|
||||
changedItems.push(sourceItemID);
|
||||
}
|
||||
|
||||
// Delete associated files
|
||||
var linkMode = this.getFileLinkMode();
|
||||
var linkMode = this.getAttachmentLinkMode();
|
||||
switch (linkMode){
|
||||
case Scholar.Files.LINK_MODE_LINKED_FILE:
|
||||
case Scholar.Files.LINK_MODE_LINKED_URL:
|
||||
case Scholar.Attachments.LINK_MODE_LINKED_FILE:
|
||||
case Scholar.Attachments.LINK_MODE_LINKED_URL:
|
||||
// Links only -- nothing to delete
|
||||
break;
|
||||
default:
|
||||
|
@ -1357,7 +1358,7 @@ Scholar.Item.prototype.erase = function(deleteChildren){
|
|||
// Delete child notes and files
|
||||
else if (deleteChildren){
|
||||
var sql = "SELECT itemID FROM itemNotes WHERE sourceItemID=?1 UNION "
|
||||
+ "SELECT itemID FROM itemFiles WHERE sourceItemID=?1";
|
||||
+ "SELECT itemID FROM itemAttachments WHERE sourceItemID=?1";
|
||||
var toDelete = Scholar.DB.columnQuery(sql, [this.getID()]);
|
||||
|
||||
if (toDelete){
|
||||
|
@ -1380,13 +1381,13 @@ Scholar.Item.prototype.erase = function(deleteChildren){
|
|||
+ this.getID();
|
||||
Scholar.DB.query(sql);
|
||||
|
||||
// Files
|
||||
var sql = "SELECT itemID FROM itemFiles WHERE sourceItemID=" + this.getID();
|
||||
var childFiles = Scholar.DB.columnQuery(sql);
|
||||
if (childFiles){
|
||||
changedItems.push(childFiles);
|
||||
// Attachments
|
||||
var sql = "SELECT itemID FROM itemAttachments WHERE sourceItemID=" + this.getID();
|
||||
var childAttachments = Scholar.DB.columnQuery(sql);
|
||||
if (childAttachments){
|
||||
changedItems.push(childAttachments);
|
||||
}
|
||||
var sql = "UPDATE itemFiles SET sourceItemID=NULL WHERE sourceItemID="
|
||||
var sql = "UPDATE itemAttachments SET sourceItemID=NULL WHERE sourceItemID="
|
||||
+ this.getID();
|
||||
Scholar.DB.query(sql);
|
||||
}
|
||||
|
@ -1399,7 +1400,7 @@ Scholar.Item.prototype.erase = function(deleteChildren){
|
|||
|
||||
sql = 'DELETE FROM itemCreators WHERE itemID=' + this.getID() + ";\n";
|
||||
sql += 'DELETE FROM itemNotes WHERE itemID=' + this.getID() + ";\n";
|
||||
sql += 'DELETE FROM itemFiles WHERE itemID=' + this.getID() + ";\n";
|
||||
sql += 'DELETE FROM itemAttachments WHERE itemID=' + this.getID() + ";\n";
|
||||
sql += 'DELETE FROM itemSeeAlso WHERE itemID=' + this.getID() + ";\n";
|
||||
sql += 'DELETE FROM itemSeeAlso WHERE linkedItemID=' + this.getID() + ";\n";
|
||||
sql += 'DELETE FROM itemTags WHERE itemID=' + this.getID() + ";\n";
|
||||
|
@ -1418,8 +1419,8 @@ Scholar.Item.prototype.erase = function(deleteChildren){
|
|||
if (this.isNote()){
|
||||
sourceItem.incrementNoteCount();
|
||||
}
|
||||
else if (this.isFile()){
|
||||
sourceItem.incrementFileCount();
|
||||
else if (this.isAttachment()){
|
||||
sourceItem.incrementAttachmentCount();
|
||||
}
|
||||
}
|
||||
Scholar.DB.rollbackTransaction();
|
||||
|
@ -1466,7 +1467,7 @@ Scholar.Item.prototype.toArray = function(){
|
|||
// Skip certain fields
|
||||
case 'firstCreator':
|
||||
case 'numNotes':
|
||||
case 'numFiles':
|
||||
case 'numAttachments':
|
||||
continue;
|
||||
|
||||
// For the rest, just copy over
|
||||
|
@ -1480,7 +1481,7 @@ Scholar.Item.prototype.toArray = function(){
|
|||
arr[Scholar.ItemFields.getName(i)] = this._itemData[i];
|
||||
}
|
||||
|
||||
if (!this.isNote() && !this.isFile()){
|
||||
if (!this.isNote() && !this.isAttachment()){
|
||||
// Creators
|
||||
arr['creators'] = [];
|
||||
var creators = this.getCreators();
|
||||
|
@ -1519,11 +1520,8 @@ Scholar.Item.prototype.toArray = function(){
|
|||
}
|
||||
}
|
||||
|
||||
// Append source files
|
||||
if (this.isFile()){
|
||||
arr['fileName'] = arr['title'];
|
||||
delete arr['title'];
|
||||
|
||||
// Attachments
|
||||
if (this.isAttachment()){
|
||||
// TODO: file data
|
||||
|
||||
if (this.getSource()){
|
||||
|
@ -1531,13 +1529,13 @@ Scholar.Item.prototype.toArray = function(){
|
|||
}
|
||||
}
|
||||
|
||||
// If not file, append attached files
|
||||
// If not file, append child attachments
|
||||
else {
|
||||
arr['files'] = [];
|
||||
var files = this.getFiles();
|
||||
arr['attachments'] = [];
|
||||
var files = this.getAttachments();
|
||||
for (var i in files){
|
||||
var file = Scholar.Items.get(files[i]);
|
||||
arr['files'].push({
|
||||
arr['attachments'].push({
|
||||
itemID: file.getID(),
|
||||
// TODO
|
||||
tags: file.getTags(),
|
||||
|
@ -1820,7 +1818,7 @@ Scholar.Items = new function(){
|
|||
+ 'CASE ((SELECT COUNT(*) FROM itemCreators WHERE itemID=I.itemID)>1) '
|
||||
+ "WHEN 0 THEN '' ELSE ' et al.' END AS firstCreator, "
|
||||
+ "(SELECT COUNT(*) FROM itemNotes WHERE sourceItemID=I.itemID) AS numNotes, "
|
||||
+ "(SELECT COUNT(*) FROM itemFiles WHERE sourceItemID=I.itemID) AS numFiles "
|
||||
+ "(SELECT COUNT(*) FROM itemAttachments WHERE sourceItemID=I.itemID) AS numAttachments "
|
||||
+ 'FROM items I '
|
||||
+ 'LEFT JOIN itemCreators IC ON (I.itemID=IC.itemID) '
|
||||
+ 'LEFT JOIN creators C ON (IC.creatorID=C.creatorID) '
|
||||
|
@ -1905,7 +1903,7 @@ Scholar.Notes = new function(){
|
|||
|
||||
|
||||
|
||||
Scholar.Files = new function(){
|
||||
Scholar.Attachments = new function(){
|
||||
this.LINK_MODE_IMPORTED_FILE = 0;
|
||||
this.LINK_MODE_IMPORTED_URL = 1;
|
||||
this.LINK_MODE_LINKED_FILE = 2;
|
||||
|
@ -1925,13 +1923,13 @@ Scholar.Files = new function(){
|
|||
|
||||
Scholar.DB.beginTransaction();
|
||||
|
||||
// Create a new file item
|
||||
var fileItem = Scholar.Items.getNewItemByType(Scholar.ItemTypes.getID('file'));
|
||||
fileItem.setField('title', title);
|
||||
fileItem.save();
|
||||
var itemID = fileItem.getID();
|
||||
// Create a new attachment
|
||||
var attachmentItem = Scholar.Items.getNewItemByType(Scholar.ItemTypes.getID('attachment'));
|
||||
attachmentItem.setField('title', title);
|
||||
attachmentItem.save();
|
||||
var itemID = attachmentItem.getID();
|
||||
|
||||
// Create directory for item files within storage directory
|
||||
// Create directory for attachment files within storage directory
|
||||
var destDir = Scholar.getStorageDirectory();
|
||||
destDir.append(itemID);
|
||||
destDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0644);
|
||||
|
@ -1972,7 +1970,7 @@ Scholar.Files = new function(){
|
|||
function importFromURL(url, sourceItemID){
|
||||
var browser = Scholar.Browser.createHiddenBrowser();
|
||||
browser.addEventListener("pageshow", function(){
|
||||
Scholar.Files.importFromDocument(browser.contentDocument, sourceItemID);
|
||||
Scholar.Attachments.importFromDocument(browser.contentDocument, sourceItemID);
|
||||
browser.removeEventListener("pageshow", arguments.callee, true);
|
||||
Scholar.Browser.deleteHiddenBrowser(browser);
|
||||
}, true);
|
||||
|
@ -1995,7 +1993,7 @@ Scholar.Files = new function(){
|
|||
|
||||
// Otherwise do a head request for the mime type
|
||||
Scholar.Utilities.HTTP.doHead(url, function(obj){
|
||||
_addToDB(null, url, title, Scholar.Files.LINK_MODE_LINKED_URL,
|
||||
_addToDB(null, url, title, Scholar.Attachments.LINK_MODE_LINKED_URL,
|
||||
obj.channel.contentType, null, sourceItemID);
|
||||
});
|
||||
}
|
||||
|
@ -2027,11 +2025,11 @@ Scholar.Files = new function(){
|
|||
|
||||
Scholar.DB.beginTransaction();
|
||||
|
||||
// Create a new file item
|
||||
var fileItem = Scholar.Items.getNewItemByType(Scholar.ItemTypes.getID('file'));
|
||||
fileItem.setField('title', title);
|
||||
fileItem.save();
|
||||
var itemID = fileItem.getID();
|
||||
// Create a new attachment
|
||||
var attachmentItem = Scholar.Items.getNewItemByType(Scholar.ItemTypes.getID('attachment'));
|
||||
attachmentItem.setField('title', title);
|
||||
attachmentItem.save();
|
||||
var itemID = attachmentItem.getID();
|
||||
|
||||
// Create a new folder for this item in the storage directory
|
||||
var destDir = Scholar.getStorageDirectory();
|
||||
|
@ -2087,14 +2085,14 @@ Scholar.Files = new function(){
|
|||
|
||||
|
||||
/**
|
||||
* Create a new item of type 'file' and add the file link to the itemFiles table
|
||||
* Create a new item of type 'attachment' and add to the itemAttachments table
|
||||
*
|
||||
* Passing an itemID causes it to skip new item creation and use the specified
|
||||
* item instead -- used when importing files (since we have to know
|
||||
* the itemID before copying in a file and don't want to update the DB before
|
||||
* the file is saved)
|
||||
*
|
||||
* Returns the itemID of the new file item
|
||||
* Returns the itemID of the new attachment
|
||||
**/
|
||||
function _addToDB(file, url, title, linkMode, mimeType, charsetID, sourceItemID, itemID){
|
||||
if (url){
|
||||
|
@ -2118,32 +2116,32 @@ Scholar.Files = new function(){
|
|||
var sourceItem = Scholar.Items.get(sourceItemID);
|
||||
if (!sourceItem){
|
||||
Scholar.DB.commitTransaction();
|
||||
throw ("Cannot set file source to invalid item " + sourceItemID);
|
||||
throw ("Cannot set attachment source to invalid item " + sourceItemID);
|
||||
}
|
||||
if (sourceItem.isFile()){
|
||||
if (sourceItem.isAttachment()){
|
||||
Scholar.DB.commitTransaction();
|
||||
throw ("Cannot set file source to another file (" + sourceItemID + ")");
|
||||
throw ("Cannot set attachment source to another file (" + sourceItemID + ")");
|
||||
}
|
||||
}
|
||||
|
||||
// If an itemID is provided, use that
|
||||
if (itemID){
|
||||
var fileItem = Scholar.Items.get(itemID);
|
||||
if (!fileItem.isFile()){
|
||||
throw ("Item " + itemID + " is not a valid file item in _addToDB()");
|
||||
var attachmentItem = Scholar.Items.get(itemID);
|
||||
if (!attachmentItem.isAttachment()){
|
||||
throw ("Item " + itemID + " is not a valid attachment in _addToDB()");
|
||||
}
|
||||
}
|
||||
// Otherwise create a new file item
|
||||
// Otherwise create a new attachment
|
||||
else {
|
||||
var fileItem = Scholar.Items.getNewItemByType(Scholar.ItemTypes.getID('file'));
|
||||
fileItem.setField('title', title);
|
||||
fileItem.save();
|
||||
var attachmentItem = Scholar.Items.getNewItemByType(Scholar.ItemTypes.getID('attachment'));
|
||||
attachmentItem.setField('title', title);
|
||||
attachmentItem.save();
|
||||
}
|
||||
|
||||
var sql = "INSERT INTO itemFiles (itemID, sourceItemID, linkMode, "
|
||||
var sql = "INSERT INTO itemAttachments (itemID, sourceItemID, linkMode, "
|
||||
+ "mimeType, charsetID, path, originalPath) VALUES (?,?,?,?,?,?,?)";
|
||||
var bindParams = [
|
||||
fileItem.getID(),
|
||||
attachmentItem.getID(),
|
||||
(sourceItemID ? {int:sourceItemID} : null),
|
||||
{int:linkMode},
|
||||
{string:mimeType},
|
||||
|
@ -2159,9 +2157,9 @@ Scholar.Files = new function(){
|
|||
Scholar.Notifier.trigger('modify', 'item', sourceItemID);
|
||||
}
|
||||
|
||||
Scholar.Notifier.trigger('add', 'item', fileItem.getID());
|
||||
Scholar.Notifier.trigger('add', 'item', attachmentItem.getID());
|
||||
|
||||
return fileItem.getID();
|
||||
return attachmentItem.getID();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3274,7 +3272,7 @@ Scholar.getItems = function(parent){
|
|||
|
||||
if (!parent){
|
||||
var sql = "SELECT A.itemID FROM items A LEFT JOIN itemNotes B USING (itemID) "
|
||||
+ "LEFT JOIN itemFiles C ON (C.itemID=A.itemID) WHERE B.sourceItemID IS NULL"
|
||||
+ "LEFT JOIN itemAttachments C ON (C.itemID=A.itemID) WHERE B.sourceItemID IS NULL"
|
||||
+ " AND C.sourceItemID IS NULL";
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -398,7 +398,7 @@ Scholar.Schema = new function(){
|
|||
//
|
||||
// Change this value to match the schema version
|
||||
//
|
||||
var toVersion = 38;
|
||||
var toVersion = 39;
|
||||
|
||||
if (toVersion != _getSchemaSQLVersion()){
|
||||
throw('Schema version does not match version in _migrateSchema()');
|
||||
|
@ -422,7 +422,12 @@ Scholar.Schema = new function(){
|
|||
}
|
||||
}
|
||||
|
||||
if (i==38){
|
||||
if (i==39){
|
||||
// Clear storage directory
|
||||
var file = Scholar.getStorageDirectory();
|
||||
if (file.exists()){
|
||||
file.remove(true);
|
||||
}
|
||||
_initializeSchema();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<!ENTITY tabs.info.label "Info">
|
||||
<!ENTITY tabs.notes.label "Notes">
|
||||
<!ENTITY tabs.files.label "Files">
|
||||
<!ENTITY tabs.attachments.label "Attachments">
|
||||
<!ENTITY tabs.tags.label "Tags">
|
||||
<!ENTITY tabs.related.label "Related">
|
||||
<!ENTITY notes.separate "Edit in a separate window">
|
||||
|
@ -35,11 +35,11 @@
|
|||
<!ENTITY item.add "Add">
|
||||
|
||||
<!ENTITY toolbar.note.standalone "New Standalone Note">
|
||||
<!ENTITY toolbar.file.standalone "New Standalone File">
|
||||
<!ENTITY toolbar.file.add "Add File...">
|
||||
<!ENTITY toolbar.file.linked "Add Linked File...">
|
||||
<!ENTITY toolbar.file.snapshot "Snapshot Current Page">
|
||||
<!ENTITY toolbar.file.weblink "Link to Current Page">
|
||||
<!ENTITY toolbar.attachment.standalone "New Standalone Attachment">
|
||||
<!ENTITY toolbar.attachment.add "Add File...">
|
||||
<!ENTITY toolbar.attachment.linked "Add Linked File...">
|
||||
<!ENTITY toolbar.attachment.snapshot "Snapshot Current Page">
|
||||
<!ENTITY toolbar.attachment.weblink "Link to Current Page">
|
||||
|
||||
<!ENTITY selectitems.title "Select Items">
|
||||
<!ENTITY selectitems.intro.label "Select which items you'd like to add to your library">
|
||||
|
|
|
@ -23,10 +23,10 @@ pane.item.notes.untitled = Untitled Note
|
|||
pane.item.notes.delete.confirm = Are you sure you want to delete this note?
|
||||
pane.item.notes.count.singular = %1 note
|
||||
pane.item.notes.count.plural = %1 notes
|
||||
pane.item.files.delete.confirm = Are you sure you want to delete this file?
|
||||
pane.item.files.count.singular = %1 file
|
||||
pane.item.files.count.plural = %1 files
|
||||
pane.item.files.select = Select a File
|
||||
pane.item.attachments.delete.confirm = Are you sure you want to delete this attachment?
|
||||
pane.item.attachments.count.singular = %1 attachment
|
||||
pane.item.attachments.count.plural = %1 attachments
|
||||
pane.item.attachments.select = Select a File
|
||||
|
||||
itemFields.title = Title
|
||||
itemFields.dateAdded = Date Added
|
||||
|
@ -74,7 +74,7 @@ itemTypes.interview = Interview
|
|||
itemTypes.film = Film
|
||||
itemTypes.artwork = Artwork
|
||||
itemTypes.website = Website
|
||||
itemTypes.file = File
|
||||
itemTypes.attachment = Attachment
|
||||
|
||||
creatorTypes.author = Author
|
||||
creatorTypes.contributor = Contributor
|
||||
|
|
Before Width: | Height: | Size: 512 B After Width: | Height: | Size: 512 B |
|
@ -89,29 +89,29 @@
|
|||
list-style-image: url('chrome://scholar/skin/toolbar-note-add.png');
|
||||
}
|
||||
|
||||
#tb-file-add
|
||||
#tb-attachment-add
|
||||
{
|
||||
list-style-image: url('chrome://scholar/skin/item-files-add.png');
|
||||
list-style-image: url('chrome://scholar/skin/item-attachments-add.png');
|
||||
}
|
||||
|
||||
#tb-item-files-file
|
||||
#tb-item-attachments-file
|
||||
{
|
||||
list-style-image: url('chrome://scholar/skin/treeitem-file-file.png');
|
||||
list-style-image: url('chrome://scholar/skin/treeitem-attachment-file.png');
|
||||
}
|
||||
|
||||
#tb-item-files-link
|
||||
#tb-item-attachments-link
|
||||
{
|
||||
list-style-image: url('chrome://scholar/skin/treeitem-file-link.png');
|
||||
list-style-image: url('chrome://scholar/skin/treeitem-attachment-link.png');
|
||||
}
|
||||
|
||||
#tb-item-files-snapshot
|
||||
#tb-item-attachments-snapshot
|
||||
{
|
||||
list-style-image: url('chrome://scholar/skin/treeitem-file-snapshot.png');
|
||||
list-style-image: url('chrome://scholar/skin/treeitem-attachment-snapshot.png');
|
||||
}
|
||||
|
||||
#tb-item-files-web-link
|
||||
#tb-item-attachments-web-link
|
||||
{
|
||||
list-style-image: url('chrome://scholar/skin/treeitem-file-web-link.png');
|
||||
list-style-image: url('chrome://scholar/skin/treeitem-attachment-web-link.png');
|
||||
}
|
||||
|
||||
#tb-fullscreen
|
||||
|
|
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 294 B |
Before Width: | Height: | Size: 614 B After Width: | Height: | Size: 614 B |
Before Width: | Height: | Size: 635 B After Width: | Height: | Size: 635 B |
Before Width: | Height: | Size: 830 B After Width: | Height: | Size: 830 B |
Before Width: | Height: | Size: 620 B After Width: | Height: | Size: 620 B |
18
schema.sql
|
@ -1,4 +1,4 @@
|
|||
-- 38
|
||||
-- 39
|
||||
|
||||
DROP TABLE IF EXISTS version;
|
||||
CREATE TABLE version (
|
||||
|
@ -106,9 +106,9 @@
|
|||
DROP INDEX IF EXISTS fileTypeMimeTypes_mimeType;
|
||||
CREATE INDEX fileTypeMimeTypes_mimeType ON fileTypeMimeTypes(mimeType);
|
||||
|
||||
-- File data for file items
|
||||
DROP TABLE IF EXISTS itemFiles;
|
||||
CREATE TABLE itemFiles (
|
||||
-- Metadata for attachment items
|
||||
DROP TABLE IF EXISTS itemAttachments;
|
||||
CREATE TABLE itemAttachments (
|
||||
itemID INT,
|
||||
sourceItemID INT,
|
||||
linkMode INT,
|
||||
|
@ -120,10 +120,10 @@
|
|||
FOREIGN KEY (itemID) REFERENCES items(itemID),
|
||||
FOREIGN KEY (sourceItemID) REFERENCES items(sourceItemID)
|
||||
);
|
||||
DROP INDEX IF EXISTS itemFiles_sourceItemID;
|
||||
CREATE INDEX itemFiles_sourceItemID ON itemFiles(sourceItemID);
|
||||
DROP INDEX IF EXISTS itemFiles_mimeType;
|
||||
CREATE INDEX itemFiles_mimeType ON itemFiles(mimeType);
|
||||
DROP INDEX IF EXISTS itemAttachments_sourceItemID;
|
||||
CREATE INDEX itemAttachments_sourceItemID ON itemAttachments(sourceItemID);
|
||||
DROP INDEX IF EXISTS itemAttachments_mimeType;
|
||||
CREATE INDEX itemAttachments_mimeType ON itemAttachments(mimeType);
|
||||
|
||||
-- Individual entries for each tag
|
||||
DROP TABLE IF EXISTS tags;
|
||||
|
@ -290,7 +290,7 @@
|
|||
INSERT INTO itemTypes VALUES (11,'film');
|
||||
INSERT INTO itemTypes VALUES (12,'artwork');
|
||||
INSERT INTO itemTypes VALUES (13,'website');
|
||||
INSERT INTO itemTypes VALUES (14,'file');
|
||||
INSERT INTO itemTypes VALUES (14,'attachment');
|
||||
|
||||
INSERT INTO "fieldFormats" VALUES(1, '.*', 0);
|
||||
INSERT INTO "fieldFormats" VALUES(2, '[0-9]*', 1);
|
||||
|
|