Merged r3450-3580 from 1.0 branch

This commit is contained in:
Dan Stillman 2008-10-25 07:37:47 +00:00
parent f50a5fe603
commit 0f0c531247
7 changed files with 59 additions and 33 deletions

View File

@ -37,7 +37,7 @@
ondialogcancel="Zotero_Citation_Dialog.cancel();" ondialogcancel="Zotero_Citation_Dialog.cancel();"
xmlns:html="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
style="padding: 0 5px" style="padding: 0"
persist="screenX screenY width height"> persist="screenX screenY width height">
<script src="include.js"/> <script src="include.js"/>

View File

@ -624,7 +624,7 @@ Zotero_Browser.Tab.prototype._searchFrames = function(rootDoc, searchDoc) {
* Attempts import of a file; to be run on local files only * Attempts import of a file; to be run on local files only
*/ */
Zotero_Browser.Tab.prototype._attemptLocalFileImport = function(doc) { 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 // read CSL string
var csl = Zotero.File.getContentsFromURL(doc.documentURI); var csl = Zotero.File.getContentsFromURL(doc.documentURI);
if(csl.indexOf("http://purl.org/net/xbiblio/csl") != -1) { if(csl.indexOf("http://purl.org/net/xbiblio/csl") != -1) {

View File

@ -40,7 +40,7 @@ var Zotero_Bibliography_Dialog = new function () {
document.getElementById('editor').format = "Integration"; document.getElementById('editor').format = "Integration";
if(Zotero.isWin) { 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; bibEditInterface = window.arguments[0].wrappedJSObject;
itemSet = bibEditInterface.getItemSet(); itemSet = bibEditInterface.getItemSet();

View File

@ -2160,15 +2160,15 @@ var ZoteroPane = new function()
function showAttachmentNotFoundDialog(itemID) { function showAttachmentNotFoundDialog(itemID) {
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]. var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
createInstance(Components.interfaces.nsIPromptService); createInstance(Components.interfaces.nsIPromptService);
var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_OK) var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING); + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_CANCEL);
var index = ps.confirmEx(null, var index = ps.confirmEx(null,
Zotero.getString('pane.item.attachments.fileNotFound.title'), Zotero.getString('pane.item.attachments.fileNotFound.title'),
Zotero.getString('pane.item.attachments.fileNotFound.text'), Zotero.getString('pane.item.attachments.fileNotFound.text'),
buttonFlags, null, Zotero.getString('general.locate'), buttonFlags, Zotero.getString('general.locate'), null,
null, null, {}); null, null, {});
if (index == 1) { if (index == 0) {
this.relinkAttachment(itemID); this.relinkAttachment(itemID);
} }
} }

View File

@ -149,9 +149,8 @@ Zotero.MIMETypeHandler = new function () {
var _StreamListener = function(request, contentType) { var _StreamListener = function(request, contentType) {
this._request = request; this._request = request;
this._contentType = contentType this._contentType = contentType
this._readString = ""; this._storageStream = null;
this._scriptableStream = null; this._binaryInputStream = null;
this._scriptableStreamInput = null;
} }
/** /**
@ -177,21 +176,45 @@ Zotero.MIMETypeHandler = new function () {
* done * done
*/ */
_StreamListener.prototype.onDataAvailable = function(request, context, inputStream, offset, count) { _StreamListener.prototype.onDataAvailable = function(request, context, inputStream, offset, count) {
if (inputStream != this._scriptableStreamInput) { Zotero.debug(count + " bytes available");
this._scriptableStream = Components.classes["@mozilla.org/scriptableinputstream;1"]
.createInstance(Components.interfaces.nsIScriptableInputStream); if (!this._storageStream) {
this._scriptableStream.init(inputStream); this._storageStream = Components.classes["@mozilla.org/storagestream;1"].
this._scriptableStreamInput = inputStream; 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 * Called when the request is done
*/ */
_StreamListener.prototype.onStopRequest = function(channel, context, status) { _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 { 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); this._contentType);
} catch(e) { } catch(e) {
// if there was an error, handle using nsIExternalHelperAppService // 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"]. var frontWindow = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].
getService(Components.interfaces.nsIWindowWatcher).activeWindow; getService(Components.interfaces.nsIWindowWatcher).activeWindow;
var newStreamListener = externalHelperAppService.doContent(this._contentType, var inputStream = this._storageStream.newInputStream(0);
this._request, frontWindow, false); var streamListener = externalHelperAppService.doContent(this._contentType, this._request, frontWindow, null);
if(newStreamListener) { if (streamListener) {
// create a string input stream streamListener.onStartRequest(channel, context);
var inputStream = Components.classes["@mozilla.org/io/string-input-stream;1"]. streamListener.onDataAvailable(this._request, context, inputStream, 0, this._storageStream.length);
createInstance(Components.interfaces.nsIStringInputStream); streamListener.onStopRequest(channel, context, status);
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);
} }
this._storageStream.close();
// then throw our error // then throw our error
throw e; throw e;
} }
this._storageStream.close();
} }
} }

View File

@ -169,7 +169,13 @@ var Zotero = new function(){
xmlhttp.open('GET', 'chrome://global/locale/global.dtd', false); xmlhttp.open('GET', 'chrome://global/locale/global.dtd', false);
xmlhttp.overrideMimeType('text/plain'); xmlhttp.overrideMimeType('text/plain');
xmlhttp.send(null); 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 { try {
this.getZoteroDirectory(); this.getZoteroDirectory();
@ -1725,9 +1731,8 @@ Zotero.Date = new function(){
// Regexes for multipart and SQL dates // Regexes for multipart and SQL dates
// Allow zeroes in multipart dates // Allow zeroes in multipart dates
var _multipartRE = /^\-?[0-9]{4}\-[0-9]{2}\-[0-9]{2} /; // TODO: Allow negative multipart in DB and here with \-?
//var _sqldateRE = /^\-?[0-9]{4}\-[0-9]{2}\-[0-9]{2}/; var _multipartRE = /^[0-9]{4}\-(0[0-9]|10|11|12)\-(0[0-9]|[1-2][0-9]|30|31) /;
//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])/;
var _sqldateRE = /^\-?[0-9]{4}\-(0[1-9]|10|11|12)\-(0[1-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])$/; 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])$/;

View File

@ -65,7 +65,7 @@ CREATE TABLE itemAttachments (
syncState INT DEFAULT 0, syncState INT DEFAULT 0,
storageModTime INT, storageModTime INT,
FOREIGN KEY (itemID) REFERENCES items(itemID), 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_sourceItemID ON itemAttachments(sourceItemID);
CREATE INDEX itemAttachments_mimeType ON itemAttachments(mimeType); CREATE INDEX itemAttachments_mimeType ON itemAttachments(mimeType);