From b4bdede0d10a5e0e115be6688448d4a88b05f856 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 4 Feb 2007 20:04:26 +0000 Subject: [PATCH] Closes #298, Add condition for searching by file type "Attachment File Type" --- chrome/content/zotero/bindings/zoterosearch.xml | 15 +++++++++++++-- chrome/content/zotero/xpcom/search.js | 17 +++++++++++++++++ chrome/locale/en-US/zotero/zotero.properties | 10 ++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/bindings/zoterosearch.xml b/chrome/content/zotero/bindings/zoterosearch.xml index cda737c68..4d724a4c1 100644 --- a/chrome/content/zotero/bindings/zoterosearch.xml +++ b/chrome/content/zotero/bindings/zoterosearch.xml @@ -308,6 +308,17 @@ this.createValueMenu(types); break; + case 'fileTypeID': + var types = Zotero.FileTypes.getTypes(); + for (var i in types) { + types[i][0] = Zotero.getString('fileTypes.' + types[i]['name']); + types[i][1] = types[i]['id']; + delete types[i]['name']; + delete types[i]['id']; + } + this.createValueMenu(types); + break; + default: if (operatorsList.value=='isInTheLast') { @@ -341,8 +352,8 @@ var operatorsList = this.id('operatorsmenu'); // Drop-down menu - if (conditionsMenu.value=='collectionID' || conditionsMenu.value=='itemTypeID') - { + if (conditionsMenu.value == 'collectionID' || conditionsMenu.value == 'itemTypeID' + || conditionsMenu.value == 'fileTypeID') { this.id('valuefield').hidden = true; this.id('valuemenu').hidden = false; this.id('value-date-age').hidden = true; diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js index c96a90753..7ce06a537 100644 --- a/chrome/content/zotero/xpcom/search.js +++ b/chrome/content/zotero/xpcom/search.js @@ -645,6 +645,13 @@ Zotero.Search.prototype._buildQuery = function(){ skipOperators = true; break; + case 'fileTypeID': + condSQL += 'mimeType IN (SELECT mimeType FROM ' + + 'fileTypeMimeTypes WHERE fileTypeID IN (' + + 'SELECT fileTypeID FROM fileTypes WHERE '; + openParens = openParens + 2; + break; + case 'tag': condSQL += "tagID IN (SELECT tagID FROM tags WHERE "; openParens++; @@ -1118,6 +1125,16 @@ Zotero.SearchConditions = new function(){ field: 'itemTypeID' }, + { + name: 'fileTypeID', + operators: { + is: true, + isNot: true + }, + table: 'itemAttachments', + field: 'fileTypeID' + }, + { name: 'tagID', operators: { diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index a1a662a64..b73a6c068 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -225,6 +225,14 @@ creatorTypes.presenter = Presenter creatorTypes.guest = Guest creatorTypes.podcaster = Podcaster +fileTypes.webpage = Web Page +fileTypes.image = Image +fileTypes.pdf = PDF +fileTypes.audio = Audio +fileTypes.video = Video +fileTypes.presentation = Presentation +fileTypes.document = Document + ingester.scraping = Saving Item... ingester.scrapeComplete = Item Saved. ingester.scrapeError = Could Not Save Item. @@ -285,6 +293,8 @@ searchConditions.mapType = Map Type searchConditions.dateModified = Date Modified searchConditions.fulltextContent = Attachment Content searchConditions.programmingLanguage = Programming Language +searchConditions.audioFileType = Audio File Type +searchConditions.fileTypeID = Attachment File Type exportOptions.exportNotes = Export Notes exportOptions.exportFileData = Export Files