From 630d55ae71770fcd465e028c52b8448baab7505c Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 1 Feb 2010 08:33:25 +0000 Subject: [PATCH] - Prompt for PDF tools installation if necessary when attempting to reindex PDF - Display "Reindex Item" icon even if PDF tools aren't installed (including for non-PDF attachments) - Display file modification time rather than item modification time in attachment pane --- .../content/zotero/bindings/attachmentbox.xml | 17 +++++-- chrome/content/zotero/overlay.js | 50 ++++++++++++++++++- chrome/content/zotero/recognizePDF.js | 20 +------- 3 files changed, 62 insertions(+), 25 deletions(-) diff --git a/chrome/content/zotero/bindings/attachmentbox.xml b/chrome/content/zotero/bindings/attachmentbox.xml index 02900197aa..3a4f340712 100644 --- a/chrome/content/zotero/bindings/attachmentbox.xml +++ b/chrome/content/zotero/bindings/attachmentbox.xml @@ -155,7 +155,7 @@ var urlField = this._id('url'); var accessed = this._id('accessedRow'); var pagesRow = this._id('pagesRow'); - var dateModifiedRow = this._id('dateModified'); + var dateModifiedRow = this._id('dateModifiedRow'); var indexStatusRow = this._id('indexStatusRow'); var selectButton = this._id('select-button'); @@ -259,6 +259,7 @@ var fileName = this.item.getFilename(); if (fileName) { + // TODO: localize this._id("fileName-label").value = "Filename: "; this._id("fileName").value = fileName; fileNameRow.hidden = false; @@ -294,9 +295,17 @@ if (this.displayDateModified) { this._id("dateModified-label").value = Zotero.getString('itemFields.dateModified')+': '; - this._id("dateModified").value = Zotero.Date.sqlToDate( + var mtime = this.item.attachmentModificationTime; + if (mtime) { + this._id("dateModified").value = new Date(mtime).toLocaleString(); + } + // Use the item's mod time as a backup (e.g., when sync + // passes in the mod time for the nonexistent remote file) + else { + this._id("dateModified").value = Zotero.Date.sqlToDate( this.item.getField('dateModified'), true ).toLocaleString(); + } dateModifiedRow.hidden = false; } else { @@ -497,9 +506,7 @@ var str = Zotero.getString('pane.items.menu.reindexItem'); reindexButton.setAttribute('tooltiptext', str); - if (this.editable && - Zotero.Fulltext.pdfConverterIsRegistered() && - Zotero.Fulltext.canReindex(this.item.id)) { + if (this.editable && Zotero.Fulltext.canReindex(this.item.id)) { reindexButton.setAttribute('hidden', false); } else { diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index 01f91ee669..6c02a315af 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -1229,11 +1229,57 @@ var ZoteroPane = new function() } + this.checkPDFConverter = function () { + if (Zotero.Fulltext.pdfConverterIsRegistered()) { + return true; + } + + var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); + var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING) + + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL); + var index = ps.confirmEx( + null, + // TODO: localize + "PDF Tools Not Installed", + "To use this feature, you must first install the PDF tools in " + + "the Zotero preferences.", + buttonFlags, + "Open Preferences", + null, null, null, {} + ); + if (index == 0) { + ZoteroPane.openPreferences('zotero-prefpane-search', 'pdftools-install'); + } + return false; + } + + function reindexItem() { - var itemIDs = this.getSelectedItems(true); - if (!itemIDs) { + var items = this.getSelectedItems(); + if (!items) { return; } + + var itemIDs = []; + var checkPDF = false; + for (var i=0; i