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();"
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"/>

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
*/
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) {

View file

@ -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();

View file

@ -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);
}
}

View file

@ -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();
}
}

View file

@ -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])$/;

View file

@ -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);