Zotero Commons updates:
- Store one item per IA bucket, with attachments stored as objects - Use proper mediatype field based on Zotero item type - Commons list is now pulled dynamically based on RDF stored at IA, without need for corresponding local item (which may have been deleted, etc.) - Once available, OCRed PDFs can be pulled down by right-clicking on Commons and selecting Refresh - Downloaded OCRed PDFs are now named the same as the existing attachment, with "(OCR)" appended - The relations table is used to link downloaded OCRed PDFs to the IA file, so the downloaded file can be renamed without triggering another download - The Commons view is marked for automatic refresh after an item is uploaded - Added some progress notifications, though more are probably needed - Other things Also: - Added Zotero.File.getBinaryContents(file) - Erase an item's relations when the item is deleted, and purge orphaned ones - Zotero.URI.eraseByPathPrefix(prefix) no longer prepends 'http://zotero.org' (which has been moved to Zotero.URI.defaultPrefix) - New function Zotero.URI.eraseByURI(prefix) Known Issues: - Slow (some IA changes should be able to speed it up) - Identifier format is likely temporary - Sometimes it stops during setTimeout() calls for no apparent reason whatsoever - Didn't test items with multiple attachments - Not sure if Commons view will auto-refresh if you switch to it before the upload is done - IA translator not yet updated - Deleting items not supported by IA - Date Added/Date Modified don't show up properly in Zotero for Commons items
This commit is contained in:
parent
a678cfa5b9
commit
453fed88bd
12 changed files with 1084 additions and 703 deletions
|
@ -1343,7 +1343,7 @@ var ZoteroPane = new function()
|
|||
}
|
||||
var itemGroup = this.itemsView._itemGroup;
|
||||
|
||||
if (!itemGroup.isTrash() && !this.canEdit()) {
|
||||
if (!itemGroup.isTrash() && !itemGroup.isCommons() && !this.canEdit()) {
|
||||
this.displayCannotEditLibraryMessage();
|
||||
return;
|
||||
}
|
||||
|
@ -1383,6 +1383,9 @@ var ZoteroPane = new function()
|
|||
else if (itemGroup.isShare()) {
|
||||
return;
|
||||
}
|
||||
else if (itemGroup.isCommons()) {
|
||||
var prompt = toDelete;
|
||||
}
|
||||
// Do nothing in trash view if any non-deleted items are selected
|
||||
else if (itemGroup.isTrash()) {
|
||||
var start = {};
|
||||
|
@ -1462,47 +1465,25 @@ var ZoteroPane = new function()
|
|||
}
|
||||
}
|
||||
|
||||
this.createCommonsBucket = function() {
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
|
||||
var bucketName = { value: '' };
|
||||
// TODO localize
|
||||
var result = promptService.prompt(window,
|
||||
"New Bucket",
|
||||
"Enter a name for this bucket:", bucketName, "", {});
|
||||
|
||||
if (result && bucketName.value) {
|
||||
Zotero.Commons.createBucket(bucketName.value);
|
||||
}
|
||||
}
|
||||
|
||||
this.refreshCommonsBucket = function() {
|
||||
this.refreshCommons = function() {
|
||||
if (this.collectionsView
|
||||
&& this.collectionsView.selection
|
||||
&& this.collectionsView.selection.count > 0
|
||||
&& this.collectionsView.selection.count == 1
|
||||
&& this.collectionsView.selection.currentIndex != -1) {
|
||||
var bucket = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex);
|
||||
if (bucket && bucket.isBucket()) {
|
||||
this.itemsView._itemGroup.ref._items = null;
|
||||
this.itemsView.refresh();
|
||||
var itemGroup = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex);
|
||||
if (itemGroup && itemGroup.isCommons()) {
|
||||
var self = this;
|
||||
Zotero.Commons.syncBucketList(function () {
|
||||
self.itemsView.refresh();
|
||||
self.itemsView.sort();
|
||||
|
||||
// On a manual refresh, also check for new OCRed files
|
||||
Zotero.Commons.syncFiles();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.removeCommonsBucket = function() {
|
||||
if (this.collectionsView
|
||||
&& this.collectionsView.selection
|
||||
&& this.collectionsView.selection.count > 0
|
||||
&& this.collectionsView.selection.currentIndex != -1) {
|
||||
var bucket = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex);
|
||||
if (bucket && bucket.isBucket()) {
|
||||
Zotero.Commons.removeBucket(bucket.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function editSelectedCollection()
|
||||
{
|
||||
if (!this.canEdit()) {
|
||||
|
@ -1802,10 +1783,7 @@ var ZoteroPane = new function()
|
|||
exportFile: 9,
|
||||
loadReport: 10,
|
||||
emptyTrash: 11,
|
||||
createCommonsBucket: 12,
|
||||
syncBucketList: 13,
|
||||
removeCommonsBucket: 14,
|
||||
refreshCommonsBucket: 15
|
||||
refreshCommons: 12
|
||||
};
|
||||
|
||||
var itemGroup = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex);
|
||||
|
@ -1873,14 +1851,8 @@ var ZoteroPane = new function()
|
|||
else if (itemGroup.isTrash()) {
|
||||
show = [m.emptyTrash];
|
||||
}
|
||||
// Header
|
||||
else if (itemGroup.isHeader()) {
|
||||
if (itemGroup.ref.id == 'commons-header') {
|
||||
show = [m.createCommonsBucket, m.syncBucketList];
|
||||
}
|
||||
}
|
||||
else if (itemGroup.isBucket()) {
|
||||
show = [m.removeCommonsBucket, m.refreshCommonsBucket];
|
||||
else if (itemGroup.isCommons()) {
|
||||
show = [m.refreshCommons];
|
||||
}
|
||||
// Group
|
||||
else if (itemGroup.isGroup()) {
|
||||
|
@ -2261,7 +2233,7 @@ var ZoteroPane = new function()
|
|||
return;
|
||||
}
|
||||
|
||||
if (tree.id == 'zotero-collections-tree') {
|
||||
if (tree.id == 'zotero-collections-tree') {
|
||||
// Ignore triple clicks for collections
|
||||
if (event.detail != 2) {
|
||||
return;
|
||||
|
@ -2295,15 +2267,12 @@ var ZoteroPane = new function()
|
|||
ZoteroPane.loadURI(uri);
|
||||
event.stopPropagation();
|
||||
}
|
||||
else if(itemGroup.ref.id == 'commons-header') {
|
||||
ZoteroPane.loadURI(Zotero.Commons.uri);
|
||||
event.stopPropagation();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemGroup.isBucket()) {
|
||||
ZoteroPane.loadURI(itemGroup.ref.uri);
|
||||
if (itemGroup.isCommons()) {
|
||||
// TODO: take to a search of the user's buckets?
|
||||
//ZoteroPane.loadURI(itemGroup.ref.uri);
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
@ -2325,6 +2294,18 @@ var ZoteroPane = new function()
|
|||
var item = ZoteroPane.getSelectedItems()[0];
|
||||
if (item) {
|
||||
if (item.isRegularItem()) {
|
||||
// Double-click on Commons item should load IA page
|
||||
var itemGroup = ZoteroPane.collectionsView._getItemAtRow(
|
||||
ZoteroPane.collectionsView.selection.currentIndex
|
||||
);
|
||||
|
||||
if (itemGroup.isCommons()) {
|
||||
var bucket = Zotero.Commons.getBucketFromItem(item);
|
||||
ZoteroPane.loadURI(bucket.uri);
|
||||
event.stopPropagation();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!viewOnDoubleClick) {
|
||||
return;
|
||||
}
|
||||
|
@ -2879,6 +2860,8 @@ var ZoteroPane = new function()
|
|||
return this.addItemFromPage(itemType, saveSnapshot, row);
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
Zotero.MIME.getMIMETypeFromURL(url, function (mimeType, hasNativeHandler) {
|
||||
// If native type, save using a hidden browser
|
||||
if (hasNativeHandler) {
|
||||
|
@ -2943,7 +2926,16 @@ var ZoteroPane = new function()
|
|||
var collectionID = false;
|
||||
}
|
||||
|
||||
Zotero.Attachments.importFromURL(url, false, false, false, collectionID, null, libraryID);
|
||||
var attachmentItem = Zotero.Attachments.importFromURL(url, false, false, false, collectionID, mimeType, libraryID);
|
||||
|
||||
// importFromURL() doesn't trigger the notifier until
|
||||
// after download is complete
|
||||
//
|
||||
// TODO: add a callback to importFromURL()
|
||||
setTimeout(function () {
|
||||
self.selectItem(attachmentItem.id);
|
||||
}, 1001);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,10 +107,7 @@
|
|||
<menuitem label="&zotero.toolbar.export.label;" oncommand="Zotero_File_Interface.exportFile()"/>
|
||||
<menuitem oncommand="Zotero_Report_Interface.loadCollectionReport()"/>
|
||||
<menuitem label="&zotero.toolbar.emptyTrash.label;" oncommand="ZoteroPane.emptyTrash();"/>
|
||||
<menuitem label="Create Bucket" oncommand="ZoteroPane.createCommonsBucket();"/><!--TODO localize -->
|
||||
<menuitem label="Sync Bucket List with IA" oncommand="Zotero.Commons.syncBucketList();"/><!--TODO localize -->
|
||||
<menuitem label="Remove Bucket from List" oncommand="ZoteroPane.removeCommonsBucket();"/><!--TODO localize -->
|
||||
<menuitem label="Refresh Bucket" oncommand="ZoteroPane.refreshCommonsBucket();"/><!--TODO localize -->
|
||||
<menuitem label="Refresh" oncommand="ZoteroPane.refreshCommons();"/><!--TODO localize -->
|
||||
</popup>
|
||||
<popup id="zotero-itemmenu" onpopupshowing="ZoteroPane.buildItemContextMenu();">
|
||||
<menuitem label="&zotero.items.menu.showInLibrary;" oncommand="ZoteroPane.selectItem(this.parentNode.getAttribute('itemID'), true)"/>
|
||||
|
|
|
@ -39,7 +39,7 @@ Zotero.CollectionTreeView = function()
|
|||
this._treebox = null;
|
||||
this.itemToSelect = null;
|
||||
this._highlightedRows = {};
|
||||
this._unregisterID = Zotero.Notifier.registerObserver(this, ['collection', 'search', 'share', 'group', 'bucket']);
|
||||
this._unregisterID = Zotero.Notifier.registerObserver(this, ['collection', 'search', 'share', 'group', 'commons']);
|
||||
this.showDuplicates = false;
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ Zotero.CollectionTreeView.prototype.refresh = function()
|
|||
|
||||
var groups = Zotero.Groups.getAll();
|
||||
if (groups.length) {
|
||||
this._showItem(new Zotero.ItemGroup('separator', false));
|
||||
this._showItem(new Zotero.ItemGroup('separator'));
|
||||
var header = {
|
||||
id: "group-libraries-header",
|
||||
label: "Group Libraries", // TODO: localize
|
||||
|
@ -234,30 +234,15 @@ Zotero.CollectionTreeView.prototype.refresh = function()
|
|||
|
||||
var shares = Zotero.Zeroconf.instances;
|
||||
if (shares.length) {
|
||||
this._showItem(new Zotero.ItemGroup('separator', false));
|
||||
this._showItem(new Zotero.ItemGroup('separator'));
|
||||
for each(var share in shares) {
|
||||
this._showItem(new Zotero.ItemGroup('share', share));
|
||||
}
|
||||
}
|
||||
|
||||
var buckets = Zotero.Commons.buckets;
|
||||
if(buckets) {
|
||||
this._showItem(new Zotero.ItemGroup('separator', false));
|
||||
var header = {
|
||||
id: "commons-header",
|
||||
label: "Commons", // TODO: localize
|
||||
expand: function (buckets) {
|
||||
if (!buckets) {
|
||||
var buckets = Zotero.Commons.buckets;
|
||||
}
|
||||
|
||||
for(var i = 0, len = buckets.length; i < len; i++) {
|
||||
self._showItem(new Zotero.ItemGroup('bucket', buckets[i]), 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
this._showItem(new Zotero.ItemGroup('header', header), null, null, true);
|
||||
header.expand(buckets);
|
||||
if (Zotero.Commons.enabled) {
|
||||
this._showItem(new Zotero.ItemGroup('separator'));
|
||||
this._showItem(new Zotero.ItemGroup('commons'), null, null, true);
|
||||
}
|
||||
|
||||
this._refreshHashMap();
|
||||
|
@ -278,7 +263,11 @@ Zotero.CollectionTreeView.prototype.reload = function()
|
|||
|
||||
for (var i=0; i<this.rowCount; i++) {
|
||||
if (this.isContainer(i) && this.isContainerOpen(i)) {
|
||||
openCollections.push(this._getItemAtRow(i).ref.id);
|
||||
var itemGroup = this._getItemAtRow(i);
|
||||
if (!itemGroup.isCollection()) {
|
||||
continue;
|
||||
}
|
||||
openCollections.push(itemGroup.ref.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,7 +376,7 @@ Zotero.CollectionTreeView.prototype.notify = function(action, type, ids)
|
|||
this.rememberSelection(savedSelection);
|
||||
}
|
||||
else if (action == 'modify' || action == 'refresh') {
|
||||
if (type != 'bucket') {
|
||||
if (type != 'commons') {
|
||||
this.reload();
|
||||
}
|
||||
this.rememberSelection(savedSelection);
|
||||
|
@ -433,7 +422,7 @@ Zotero.CollectionTreeView.prototype.notify = function(action, type, ids)
|
|||
this.rememberSelection(savedSelection);
|
||||
break;
|
||||
|
||||
case 'bucket':
|
||||
case 'commons':
|
||||
this.reload();
|
||||
}
|
||||
}
|
||||
|
@ -522,14 +511,15 @@ Zotero.CollectionTreeView.prototype.getImageSrc = function(row, col)
|
|||
if (source.ref.id == 'group-libraries-header') {
|
||||
collectionType = 'groups';
|
||||
}
|
||||
else if (source.ref.id == 'commons-header') {
|
||||
collectionType = 'commons';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'group':
|
||||
collectionType = 'library';
|
||||
break;
|
||||
|
||||
case 'commons':
|
||||
collectionType = 'commons';
|
||||
break;
|
||||
}
|
||||
return "chrome://zotero/skin/treesource-" + collectionType + ".png";
|
||||
}
|
||||
|
@ -537,7 +527,7 @@ Zotero.CollectionTreeView.prototype.getImageSrc = function(row, col)
|
|||
Zotero.CollectionTreeView.prototype.isContainer = function(row)
|
||||
{
|
||||
var itemGroup = this._getItemAtRow(row);
|
||||
return itemGroup.isLibrary(true) || itemGroup.isCollection() || itemGroup.isHeader() || itemGroup.isBucket();
|
||||
return itemGroup.isLibrary(true) || itemGroup.isCollection() || itemGroup.isHeader() || itemGroup.isCommons();
|
||||
}
|
||||
|
||||
Zotero.CollectionTreeView.prototype.isContainerOpen = function(row)
|
||||
|
@ -557,9 +547,6 @@ Zotero.CollectionTreeView.prototype.isContainerEmpty = function(row)
|
|||
if (itemGroup.isHeader()) {
|
||||
return false;
|
||||
}
|
||||
if (itemGroup.isBucket()) {
|
||||
return true;
|
||||
}
|
||||
if (itemGroup.isGroup()) {
|
||||
return !itemGroup.ref.hasCollections();
|
||||
}
|
||||
|
@ -617,8 +604,6 @@ Zotero.CollectionTreeView.prototype.toggleOpenState = function(row)
|
|||
if (itemGroup.type == 'header') {
|
||||
itemGroup.ref.expand();
|
||||
}
|
||||
else if(itemGroup.type == 'bucket') {
|
||||
}
|
||||
else {
|
||||
if (itemGroup.isLibrary()) {
|
||||
count = itemGroup.ref.expand();
|
||||
|
@ -1063,12 +1048,14 @@ Zotero.CollectionTreeView.prototype.canDrop = function(row, orient, dragData)
|
|||
{
|
||||
var itemGroup = this._getItemAtRow(row); //the collection we are dragging over
|
||||
|
||||
if (!itemGroup.editable) {
|
||||
if (!itemGroup.editable
|
||||
// Commons can be dropped on but not edited
|
||||
&& !itemGroup.isCommons()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dataType == 'zotero/item') {
|
||||
if(itemGroup.isBucket()) {
|
||||
if(itemGroup.isCommons()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1236,8 +1223,8 @@ Zotero.CollectionTreeView.prototype.drop = function(row, orient)
|
|||
var targetLibraryID = null;
|
||||
}
|
||||
|
||||
if(itemGroup.isBucket()) {
|
||||
itemGroup.ref.uploadItems(ids);
|
||||
if(itemGroup.isCommons()) {
|
||||
Zotero.Commons.uploadItems(ids);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1638,9 +1625,9 @@ Zotero.ItemGroup.prototype.isShare = function()
|
|||
return this.type == 'share';
|
||||
}
|
||||
|
||||
Zotero.ItemGroup.prototype.isBucket = function()
|
||||
Zotero.ItemGroup.prototype.isCommons = function()
|
||||
{
|
||||
return this.type == 'bucket';
|
||||
return this.type == 'commons';
|
||||
}
|
||||
|
||||
Zotero.ItemGroup.prototype.isTrash = function()
|
||||
|
@ -1667,7 +1654,7 @@ Zotero.ItemGroup.prototype.isWithinGroup = function () {
|
|||
}
|
||||
|
||||
Zotero.ItemGroup.prototype.__defineGetter__('editable', function () {
|
||||
if (this.isTrash() || this.isShare()) {
|
||||
if (this.isTrash() || this.isShare() || this.isCommons()) {
|
||||
return false;
|
||||
}
|
||||
if (!this.isWithinGroup()) {
|
||||
|
@ -1726,9 +1713,6 @@ Zotero.ItemGroup.prototype.getName = function()
|
|||
|
||||
case 'share':
|
||||
return this.ref.name;
|
||||
|
||||
case 'bucket':
|
||||
return this.ref.name;
|
||||
|
||||
case 'trash':
|
||||
return Zotero.getString('pane.collections.trash');
|
||||
|
@ -1739,6 +1723,9 @@ Zotero.ItemGroup.prototype.getName = function()
|
|||
case 'header':
|
||||
return this.ref.label;
|
||||
|
||||
case 'commons':
|
||||
return "Commons";
|
||||
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
@ -1751,8 +1738,8 @@ Zotero.ItemGroup.prototype.getChildItems = function()
|
|||
case 'share':
|
||||
return this.ref.getAll();
|
||||
|
||||
case 'bucket':
|
||||
return this.ref.getItems();
|
||||
case 'commons':
|
||||
return Zotero.Commons.getItems();
|
||||
|
||||
case 'header':
|
||||
return [];
|
||||
|
@ -1865,7 +1852,7 @@ Zotero.ItemGroup.prototype.getChildTags = function() {
|
|||
case 'share':
|
||||
return false;
|
||||
|
||||
case 'bucket':
|
||||
case 'commons':
|
||||
return false;
|
||||
|
||||
case 'header':
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -338,7 +338,7 @@ Zotero.Group.prototype.erase = function() {
|
|||
Zotero.DB.query(sql, this.libraryID);
|
||||
|
||||
var prefix = "groups/" + this.id;
|
||||
Zotero.Relations.eraseByPathPrefix(prefix);
|
||||
Zotero.Relations.eraseByURIPrefix(Zotero.URI.defaultPrefix + prefix);
|
||||
|
||||
// Delete group
|
||||
sql = "DELETE FROM groups WHERE groupID=?";
|
||||
|
|
|
@ -741,7 +741,7 @@ Zotero.Item.prototype.setField = function(field, value, loadIn) {
|
|||
}
|
||||
|
||||
if (!Zotero.ItemFields.isValidForType(fieldID, this.itemTypeID)) {
|
||||
var msg = '"' + field + "' is not a valid field for type " + this.itemTypeID;
|
||||
var msg = "'" + field + "' is not a valid field for type " + this.itemTypeID;
|
||||
|
||||
if (loadIn) {
|
||||
Zotero.debug(msg + " -- ignoring value '" + value + "'", 2);
|
||||
|
@ -1240,7 +1240,7 @@ Zotero.Item.prototype.save = function() {
|
|||
|
||||
if (Zotero.ItemFields.getID('accessDate') == fieldID
|
||||
&& this.getField(fieldID) == 'CURRENT_TIMESTAMP') {
|
||||
value = Zotero.DB.transactionDateTime;
|
||||
value = Zotero.DB.transactionDateTime;
|
||||
}
|
||||
|
||||
var dataType = ZU.getSQLDataType(value);
|
||||
|
@ -3944,7 +3944,10 @@ Zotero.Item.prototype.erase = function() {
|
|||
//Zotero.Fulltext.clearItemContent(this.id);
|
||||
}
|
||||
|
||||
|
||||
// Remove relations
|
||||
var relation = Zotero.URI.getItemURI(this);
|
||||
Zotero.Relations.eraseByURIPrefix(relation);
|
||||
|
||||
Zotero.DB.query('DELETE FROM annotations WHERE itemID=?', this.id);
|
||||
Zotero.DB.query('DELETE FROM highlights WHERE itemID=?', this.id);
|
||||
Zotero.DB.query('DELETE FROM deletedItems WHERE itemID=?', this.id);
|
||||
|
|
|
@ -31,8 +31,6 @@ Zotero.Relations = new function () {
|
|||
owl: 'http://www.w3.org/2002/07/owl#'
|
||||
};
|
||||
|
||||
var _prefix = "http://zotero.org/";
|
||||
|
||||
this.get = function (id) {
|
||||
if (typeof id != 'number') {
|
||||
throw ("id '" + id + "' must be an integer in Zotero.Relations.get()");
|
||||
|
@ -165,13 +163,40 @@ Zotero.Relations = new function () {
|
|||
}
|
||||
|
||||
|
||||
this.eraseByPathPrefix = function (prefix) {
|
||||
prefix = _prefix + prefix + '%';
|
||||
this.eraseByURIPrefix = function (prefix) {
|
||||
prefix = prefix + '%';
|
||||
sql = "DELETE FROM relations WHERE subject LIKE ? OR object LIKE ?";
|
||||
Zotero.DB.query(sql, [prefix, prefix]);
|
||||
}
|
||||
|
||||
|
||||
this.eraseByURI = function (uri) {
|
||||
sql = "DELETE FROM relations WHERE subject=? OR object=?";
|
||||
Zotero.DB.query(sql, [uri, uri]);
|
||||
}
|
||||
|
||||
|
||||
this.purge = function () {
|
||||
var sql = "SELECT subject FROM relations UNION SELECT object FROM relations";
|
||||
var uris = Zotero.DB.columnQuery(sql);
|
||||
if (uris) {
|
||||
var prefix = Zotero.URI.defaultPrefix;
|
||||
Zotero.DB.beginTransaction();
|
||||
for each(var uri in uris) {
|
||||
// Skip URIs that don't begin with the default prefix,
|
||||
// since they don't correspond to local items
|
||||
if (uri.indexOf(prefix) == -1) {
|
||||
continue;
|
||||
}
|
||||
if (!Zotero.URI.getURIItem(uri)) {
|
||||
this.eraseByURI(uri);
|
||||
}
|
||||
}
|
||||
Zotero.DB.commitTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.xmlToRelation = function (xml) {
|
||||
var relation = new Zotero.Relation;
|
||||
var libraryID = xml.@libraryID.toString();
|
||||
|
@ -196,7 +221,7 @@ Zotero.Relations = new function () {
|
|||
var [prefix, value] = uri.split(':');
|
||||
if (prefix && value) {
|
||||
if (!_namespaces[prefix]) {
|
||||
throw ("Invalid prefix '" + prefix + "' in Zotero.Relations.add()");
|
||||
throw ("Invalid prefix '" + prefix + "' in Zotero.Relations._getPrefixAndValue()");
|
||||
}
|
||||
return [prefix, value];
|
||||
}
|
||||
|
|
|
@ -137,6 +137,21 @@ Zotero.File = new function(){
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return the contents of a file as a byte array
|
||||
*/
|
||||
this.getBinaryContents = function (bfile) {
|
||||
var istream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIFileInputStream);
|
||||
istream.init(bfile, -1, -1, false);
|
||||
var bstream = Components.classes["@mozilla.org/binaryinputstream;1"]
|
||||
.createInstance(Components.interfaces.nsIBinaryInputStream);
|
||||
bstream.setInputStream(istream);
|
||||
return bstream.readBytes(bstream.available());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return the contents of a URL as a string
|
||||
*
|
||||
|
|
|
@ -52,7 +52,7 @@ Zotero.ItemTreeView = function(itemGroup, sourcesOnly)
|
|||
this._dataItems = [];
|
||||
this.rowCount = 0;
|
||||
|
||||
this._unregisterID = Zotero.Notifier.registerObserver(this, ['item', 'collection-item', 'share-items', 'bucket']);
|
||||
this._unregisterID = Zotero.Notifier.registerObserver(this, ['item', 'collection-item', 'share-items', 'commons']);
|
||||
}
|
||||
|
||||
|
||||
|
@ -260,6 +260,7 @@ Zotero.ItemTreeView.prototype.refresh = function()
|
|||
*/
|
||||
Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
|
||||
{
|
||||
Zotero.debug('=============');
|
||||
if (!this._treebox || !this._treebox.treeBody) {
|
||||
Components.utils.reportError("Treebox didn't exist in itemTreeView.notify()");
|
||||
return;
|
||||
|
@ -269,7 +270,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
|
|||
Zotero.debug("Item row map didn't exist in itemTreeView.notify()");
|
||||
return;
|
||||
}
|
||||
|
||||
Zotero.debug(1);
|
||||
var itemGroup = this._itemGroup;
|
||||
|
||||
var madeChanges = false;
|
||||
|
@ -284,9 +285,10 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
|
|||
this.refresh();
|
||||
}
|
||||
}
|
||||
else if (type == 'bucket') {
|
||||
if (itemGroup.isBucket()) {
|
||||
else if (type == 'commons') {
|
||||
if (itemGroup.isCommons()) {
|
||||
this.refresh();
|
||||
this.sort();
|
||||
}
|
||||
}
|
||||
else if (savedSelection.length == 1 && savedSelection[0] == ids[0]) {
|
||||
|
@ -455,6 +457,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
|
|||
}
|
||||
else if(action == 'add')
|
||||
{
|
||||
Zotero.debug(2);
|
||||
// If saved search or trash, just re-run search
|
||||
if (itemGroup.isSearch() || itemGroup.isTrash()) {
|
||||
this.refresh();
|
||||
|
@ -499,6 +502,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
|
|||
|
||||
if(madeChanges)
|
||||
{
|
||||
Zotero.debug(3);
|
||||
// If adding and this is the active window, select the item
|
||||
if(action == 'add' && ids.length===1 && activeWindow)
|
||||
{
|
||||
|
@ -511,7 +515,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
|
|||
|
||||
// Reset to Info tab
|
||||
this._ownerDocument.getElementById('zotero-view-tabbox').selectedIndex = 0;
|
||||
|
||||
Zotero.debug(4);
|
||||
this.selectItem(ids[0]);
|
||||
}
|
||||
// If single item is selected and was modified
|
||||
|
@ -540,6 +544,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
|
|||
}
|
||||
else
|
||||
{
|
||||
Zotero.debug(4);
|
||||
var previousRow = this._itemRowMap[ids[0]];
|
||||
|
||||
if (sort) {
|
||||
|
@ -1112,6 +1117,8 @@ Zotero.ItemTreeView.prototype.sort = function(itemID)
|
|||
*/
|
||||
Zotero.ItemTreeView.prototype.selectItem = function(id, expand, noRecurse)
|
||||
{
|
||||
Zotero.debug('=============');
|
||||
Zotero.debug(Zotero.suppressUIUpdates);
|
||||
// Don't change selection if UI updates are disabled (e.g., during sync)
|
||||
if (Zotero.suppressUIUpdates) {
|
||||
return;
|
||||
|
@ -1267,8 +1274,8 @@ Zotero.ItemTreeView.prototype.deleteSelection = function (force)
|
|||
else if (itemGroup.isCollection()) {
|
||||
itemGroup.ref.removeItems(ids);
|
||||
}
|
||||
else if (itemGroup.isBucket()) {
|
||||
itemGroup.ref.deleteItems(ids);
|
||||
else if (itemGroup.isCommons()) {
|
||||
Zotero.Commons.deleteItems(ids);
|
||||
}
|
||||
this._treebox.endUpdateBatch();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
|
||||
Zotero.URI = new function () {
|
||||
this.__defineGetter__('defaultPrefix', function () 'http://zotero.org/');
|
||||
|
||||
var _baseURI = ZOTERO_CONFIG.BASE_URI;
|
||||
var _apiURI = ZOTERO_CONFIG.API_URI;
|
||||
|
||||
|
@ -166,12 +168,12 @@ Zotero.URI = new function () {
|
|||
if (itemURI.indexOf(localUserURI) == 0) {
|
||||
itemURI = itemURI.substr(localUserURI.length);
|
||||
var libraryType = 'user';
|
||||
var libraryTypeID = null;
|
||||
var libraryID = null;
|
||||
}
|
||||
}
|
||||
*/
|
||||
var libraryType = 'user';
|
||||
var libraryTypeID = null;
|
||||
var libraryID = null;
|
||||
}
|
||||
|
||||
// If not found, try global URI
|
||||
|
@ -186,7 +188,7 @@ Zotero.URI = new function () {
|
|||
throw ("Invalid library URI '" + itemURI + "' in Zotero.URI.getURIItem()");
|
||||
}
|
||||
var libraryType = matches[1].substr(0, matches[1].length-1);
|
||||
var libraryTypeID = matches[2];
|
||||
var libraryID = matches[2];
|
||||
itemURI = itemURI.replace(typeRE, '');
|
||||
}
|
||||
|
||||
|
@ -202,7 +204,10 @@ Zotero.URI = new function () {
|
|||
}
|
||||
|
||||
if (libraryType == 'group') {
|
||||
var libraryID = Zotero.Groups.getLibraryIDFromGroupID(libraryTypeID);
|
||||
if (!Zotero.Libraries.exists(libraryID)) {
|
||||
return false;
|
||||
}
|
||||
var libraryID = Zotero.Groups.getLibraryIDFromGroupID(libraryID);
|
||||
return Zotero.Items.getByLibraryAndKey(libraryID, itemKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1033,6 +1033,8 @@ var Zotero = new function(){
|
|||
* Returns true if an object (or associative array) has at least one value
|
||||
*/
|
||||
function hasValues(obj) {
|
||||
Zotero.debug("WARNING: Zotero.isEmpty() is deprecated! Use Zotero.Utilities.isEmpty(obj)", 2);
|
||||
|
||||
for (var i in obj) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1239,6 +1241,8 @@ var Zotero = new function(){
|
|||
Zotero.Tags.purge();
|
||||
Zotero.Fulltext.purgeUnusedWords();
|
||||
Zotero.Items.purge();
|
||||
// DEBUG: this might not need to be permanent
|
||||
Zotero.Relations.purge();
|
||||
|
||||
if (!skipStoragePurge && Zotero.Utilities.prototype.probability(10)) {
|
||||
Zotero.Sync.Storage.purgeDeletedStorageFiles('zfs');
|
||||
|
|
|
@ -110,7 +110,6 @@ pref("extensions.zotero.zeroconf.server.enabled", false);
|
|||
|
||||
// Zotero Commons
|
||||
pref("extensions.zotero.commons.enabled", false);
|
||||
pref("extensions.zotero.commons.buckets", '');
|
||||
pref("extensions.zotero.commons.accessKey", '');
|
||||
pref("extensions.zotero.commons.secretKey", '');
|
||||
|
||||
|
|
Loading…
Reference in a new issue