commit 0f0c531247e49a4dd2e0ac409a4b2379c59083da
parent f50a5fe60354d950e5865320f5e65386a57c1a32
Author: Dan Stillman <dstillman@zotero.org>
Date: Sat, 25 Oct 2008 07:37:47 +0000
Merged r3450-3580 from 1.0 branch
Diffstat:
7 files changed, 59 insertions(+), 33 deletions(-)
diff --git a/chrome/content/zotero/addCitationDialog.xul b/chrome/content/zotero/addCitationDialog.xul
@@ -37,7 +37,7 @@
ondialogcancel="Zotero_Citation_Dialog.cancel();"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- style="padding: 0 5px"
+ style="padding: 0"
persist="screenX screenY width height">
<script src="include.js"/>
diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js
@@ -624,7 +624,7 @@ Zotero_Browser.Tab.prototype._searchFrames = function(rootDoc, searchDoc) {
* Attempts import of a file; to be run on local files only
*/
Zotero_Browser.Tab.prototype._attemptLocalFileImport = function(doc) {
- if(doc.documentURI.substr(doc.documentURI.length-4).toLowerCase() == ".csl") {
+ if(doc.documentURI.match(/\.csl(\.xml)?$/i)) {
// read CSL string
var csl = Zotero.File.getContentsFromURL(doc.documentURI);
if(csl.indexOf("http://purl.org/net/xbiblio/csl") != -1) {
diff --git a/chrome/content/zotero/editBibliographyDialog.js b/chrome/content/zotero/editBibliographyDialog.js
@@ -40,7 +40,7 @@ var Zotero_Bibliography_Dialog = new function () {
document.getElementById('editor').format = "Integration";
if(Zotero.isWin) {
- document.getElementById("zotero-select-items-container").style.border = "1px solid black";
+ document.getElementsByTagName("dialog")[0].style.border = "1px solid black";
}
bibEditInterface = window.arguments[0].wrappedJSObject;
itemSet = bibEditInterface.getItemSet();
diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js
@@ -2160,15 +2160,15 @@ var ZoteroPane = new function()
function showAttachmentNotFoundDialog(itemID) {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
createInstance(Components.interfaces.nsIPromptService);
- var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_OK)
- + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING);
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
var index = ps.confirmEx(null,
Zotero.getString('pane.item.attachments.fileNotFound.title'),
Zotero.getString('pane.item.attachments.fileNotFound.text'),
- buttonFlags, null, Zotero.getString('general.locate'),
+ buttonFlags, Zotero.getString('general.locate'), null,
null, null, {});
- if (index == 1) {
+ if (index == 0) {
this.relinkAttachment(itemID);
}
}
diff --git a/chrome/content/zotero/xpcom/mimeTypeHandler.js b/chrome/content/zotero/xpcom/mimeTypeHandler.js
@@ -149,9 +149,8 @@ Zotero.MIMETypeHandler = new function () {
var _StreamListener = function(request, contentType) {
this._request = request;
this._contentType = contentType
- this._readString = "";
- this._scriptableStream = null;
- this._scriptableStreamInput = null;
+ this._storageStream = null;
+ this._binaryInputStream = null;
}
/**
@@ -177,21 +176,45 @@ Zotero.MIMETypeHandler = new function () {
* done
*/
_StreamListener.prototype.onDataAvailable = function(request, context, inputStream, offset, count) {
- if (inputStream != this._scriptableStreamInput) {
- this._scriptableStream = Components.classes["@mozilla.org/scriptableinputstream;1"]
- .createInstance(Components.interfaces.nsIScriptableInputStream);
- this._scriptableStream.init(inputStream);
- this._scriptableStreamInput = inputStream;
+ Zotero.debug(count + " bytes available");
+
+ if (!this._storageStream) {
+ this._storageStream = Components.classes["@mozilla.org/storagestream;1"].
+ createInstance(Components.interfaces.nsIStorageStream);
+ this._storageStream.init(4096, 4294967295, null); // PR_UINT32_MAX
+
+ this._binaryInputStream = Components.classes["@mozilla.org/binaryinputstream;1"].
+ createInstance(Components.interfaces.nsIBinaryInputStream);
+ this._binaryInputStream.setInputStream(inputStream);
}
- this._readString += this._scriptableStream.read(count);
+
+ var bytes = this._binaryInputStream.readBytes(count);
+ var outputStream = this._storageStream.getOutputStream(0);
+ outputStream.write(bytes, count);
}
/**
* Called when the request is done
*/
_StreamListener.prototype.onStopRequest = function(channel, context, status) {
+ Zotero.debug("charset is " + channel.contentCharset);
+
+ var inputStream = this._storageStream.newInputStream(0);
+ var charset = channel.contentCharset ? channel.contentCharset : "UTF-8";
+ const replacementChar = Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER;
+ var convStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
+ .createInstance(Components.interfaces.nsIConverterInputStream);
+ convStream.init(inputStream, charset, 1024, replacementChar);
+ var readString = "";
+ var str = {};
+ while (convStream.readString(4096, str) != 0) {
+ readString += str.value;
+ }
+ convStream.close();
+ inputStream.close();
+
try {
- _typeHandlers[this._contentType](this._readString, (this._request.name ? this._request.name : null),
+ _typeHandlers[this._contentType](readString, (this._request.name ? this._request.name : null),
this._contentType);
} catch(e) {
// if there was an error, handle using nsIExternalHelperAppService
@@ -200,21 +223,19 @@ Zotero.MIMETypeHandler = new function () {
var frontWindow = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].
getService(Components.interfaces.nsIWindowWatcher).activeWindow;
- var newStreamListener = externalHelperAppService.doContent(this._contentType,
- this._request, frontWindow, false);
- if(newStreamListener) {
- // create a string input stream
- var inputStream = Components.classes["@mozilla.org/io/string-input-stream;1"].
- createInstance(Components.interfaces.nsIStringInputStream);
- inputStream.setData(this._readString, this._readString.length);
-
- newStreamListener.onStartRequest(channel, context);
- newStreamListener.onDataAvailable(this._request, context, inputStream, 0, this._readString.length);
- newStreamListener.onStopRequest(channel, context, status);
+ var inputStream = this._storageStream.newInputStream(0);
+ var streamListener = externalHelperAppService.doContent(this._contentType, this._request, frontWindow, null);
+ if (streamListener) {
+ streamListener.onStartRequest(channel, context);
+ streamListener.onDataAvailable(this._request, context, inputStream, 0, this._storageStream.length);
+ streamListener.onStopRequest(channel, context, status);
}
+ this._storageStream.close();
// then throw our error
throw e;
}
+
+ this._storageStream.close();
}
}
\ No newline at end of file
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -169,7 +169,13 @@ var Zotero = new function(){
xmlhttp.open('GET', 'chrome://global/locale/global.dtd', false);
xmlhttp.overrideMimeType('text/plain');
xmlhttp.send(null);
- this.dir = xmlhttp.responseText.match(/(ltr|rtl)/)[0];
+ var matches = xmlhttp.responseText.match(/(ltr|rtl)/);
+ if (matches && matches[0] == 'rtl') {
+ this.dir = 'rtl';
+ }
+ else {
+ this.dir = 'ltr';
+ }
try {
this.getZoteroDirectory();
@@ -1725,9 +1731,8 @@ Zotero.Date = new function(){
// Regexes for multipart and SQL dates
// Allow zeroes in multipart dates
- var _multipartRE = /^\-?[0-9]{4}\-[0-9]{2}\-[0-9]{2} /;
- //var _sqldateRE = /^\-?[0-9]{4}\-[0-9]{2}\-[0-9]{2}/;
- //var _sqldatetimeRE = /^\-?[0-9]{4}\-[0-9]{2}\-[0-9]{2} ([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])/;
+ // TODO: Allow negative multipart in DB and here with \-?
+ var _multipartRE = /^[0-9]{4}\-(0[0-9]|10|11|12)\-(0[0-9]|[1-2][0-9]|30|31) /;
var _sqldateRE = /^\-?[0-9]{4}\-(0[1-9]|10|11|12)\-(0[1-9]|[1-2][0-9]|30|31)$/;
var _sqldatetimeRE = /^\-?[0-9]{4}\-(0[1-9]|10|11|12)\-(0[1-9]|[1-2][0-9]|30|31) ([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])$/;
diff --git a/userdata.sql b/userdata.sql
@@ -65,7 +65,7 @@ CREATE TABLE itemAttachments (
syncState INT DEFAULT 0,
storageModTime INT,
FOREIGN KEY (itemID) REFERENCES items(itemID),
- FOREIGN KEY (sourceItemID) REFERENCES items(sourceItemID)
+ FOREIGN KEY (sourceItemID) REFERENCES items(itemID)
);
CREATE INDEX itemAttachments_sourceItemID ON itemAttachments(sourceItemID);
CREATE INDEX itemAttachments_mimeType ON itemAttachments(mimeType);