fixes #754, SVN Word plugin not working in 1687

fixes #740, possible CSL et al issues
fixes #757, CSLs without sort-algorithm option fail bibliography creation
fixes #747, fix issues with bookmarks
fixes CrossRef translator to use authentication
addresses #736, bring Zotero up to date with latest CSL revisions (new formatting attributes not yet implemented)
closes #746, edit bibliography support

new Word plug-in still needs compliation and testing on non-Mac platforms and needs to be tested for compatibility with old docs
This commit is contained in:
Simon Kornblith 2007-09-13 21:04:41 +00:00
parent f0b25656fd
commit c3e2e83df9
13 changed files with 1499 additions and 602 deletions

View File

@ -34,6 +34,7 @@ var Zotero_Citation_Dialog = new function () {
var _lastSelected = null;
var _previewShown = false;
var _suppressNextTreeSelect = false;
var _locatorIndexArray = {};
var _autoRegeneratePref;
var _acceptButton;
var _sortCheckbox;
@ -45,8 +46,8 @@ var Zotero_Citation_Dialog = new function () {
this.toggleEditor = toggleEditor;
this.treeItemSelected = treeItemSelected;
this.listItemSelected = listItemSelected;
this.addCitation = addCitation;
this.deleteCitation = deleteCitation;
this.add = add;
this.remove = remove;
this.sortCitation = sortCitation;
this.confirmRegenerate = confirmRegenerate;
this.accept = accept;
@ -66,7 +67,6 @@ var Zotero_Citation_Dialog = new function () {
// find accept button
_acceptButton = document.getElementById("add-citation-dialog").getButton("accept");
_autoRegeneratePref = Zotero.Prefs.get("integration.autoRegenerate");
// if a style with sortable citations, present checkbox
@ -74,8 +74,28 @@ var Zotero_Citation_Dialog = new function () {
_sortCheckbox = document.getElementById("keepSorted");
_sortCheckbox.hidden = false;
_sortCheckbox.checked = true;
io.citation.properties.sort = true;
}
// load locators
var locators = Zotero.CSL.Global.getLocatorStrings();
var menu = document.getElementById("locatorType");
var popup = document.getElementById("locator-type-popup");
var i = 0;
for(var value in locators) {
var locator = locators[value];
locator = locator[0].toUpperCase()+locator.substr(1);
// add to popup
var child = document.createElement("menuitem");
child.setAttribute("value", value);
child.setAttribute("label", locator);
popup.appendChild(child);
// add to array
_locatorIndexArray[value] = i;
i++;
}
menu.selectedIndex = 0;
// load (from selectItemsDialog.js)
doLoad();
@ -88,23 +108,32 @@ var Zotero_Citation_Dialog = new function () {
selectItem(io.citation.citationItems[0].itemID); // from selectItemsDialog.js
for(var property in _preserveData) {
if(io.citation.citationItems[0][property]) {
if(property == "locatorType") {
document.getElementById(property)[_preserveData[property]] = _locatorIndexArray[io.citation.citationItems[0][property]];
} else {
document.getElementById(property)[_preserveData[property]] = io.citation.citationItems[0][property];
}
}
}
} else {
// multiple citations
toggleMultipleSources();
for(var i=0; i<io.citation.citationItems.length; i++) {
_addItem(io.citation.citationItems[i].itemID);
var item = Zotero.Items.get(io.citation.citationItems[i].itemID);
if(item) {
_addItem(item);
_itemData[io.citation.citationItems[i].itemID] = io.citation.citationItems[i];
}
}
}
// show user-editable edited citation
if(io.citation.properties.custom) {
toggleEditor(io.citation.properties.custom);
io.citation.properties.custom = undefined;
}
_updateAccept();
}
}
@ -160,7 +189,7 @@ var Zotero_Citation_Dialog = new function () {
// disable boxes if item not added; otherwise, enable
_itemSelected(hasBeenAdded ? itemID : false);
// disable adding nothing, or things already added
document.getElementById("citation-add").disabled = !itemID || hasBeenAdded;
document.getElementById("add").disabled = !itemID || hasBeenAdded;
} else {
_updateAccept();
_updatePreview();
@ -175,18 +204,21 @@ var Zotero_Citation_Dialog = new function () {
var itemID = (selectedListItem ? selectedListItem.value : false);
_itemSelected(itemID);
document.getElementById("citation-delete").disabled = !itemID;
document.getElementById("remove").disabled = !itemID;
}
/*
* Adds a citation to the multipleSources list
*/
function addCitation() {
function add() {
// get selected item (from selectItemsDialog.js)
var item = getSelectedItems()[0];
_itemSelected(item.getID());
_addItem(item);
// don't let someone select it again
document.getElementById("add").disabled = true;
// allow user to press OK
_updateAccept();
_updatePreview();
@ -196,7 +228,7 @@ var Zotero_Citation_Dialog = new function () {
/*
* Deletes a citation from the multipleSources list
*/
function deleteCitation() {
function remove() {
var citationList = document.getElementById("citation-list");
var selectedListItem = citationList.getSelectedItem(0);
var itemID = selectedListItem.value;
@ -217,6 +249,7 @@ var Zotero_Citation_Dialog = new function () {
* Sorts the list of citations
*/
function sortCitation() {
io.citation.properties.sort = _sortCheckbox.checked;
if(_sortCheckbox.checked) {
_getCitation();
@ -226,22 +259,14 @@ var Zotero_Citation_Dialog = new function () {
citationList.removeChild(citationList.firstChild);
}
// add surrogate items to citation
for(var i=0; i<io.citation.citationItems.length; i++) {
io.citation.citationItems[i].item = new Zotero.CSL.Item(Zotero.Items.get(io.citation.citationItems[i].itemID));
}
io.citation.sort();
// run preview function to re-sort, if it hasn't already been
// run
if(!_previewShown) io.previewFunction();
// add items back to list
for(var i=0; i<io.citation.citationItems.length; i++) {
var item = io.citation.citationItems[i].item.zoteroItem;
var itemNode = document.createElement("listitem");
itemNode.setAttribute("value", item.getID());
itemNode.setAttribute("label", item.getField("title"));
itemNode.setAttribute("class", "listitem-iconic");
itemNode.setAttribute("image", item.getImageSrc());
document.getElementById("citation-list").appendChild(itemNode);
var item = Zotero.Items.get(io.citation.citationItems[i].itemID);
_addItem(item);
}
}
}
@ -365,13 +390,23 @@ var Zotero_Citation_Dialog = new function () {
var property = _preserveData[box];
// save property
if(_lastSelected) _itemData[_lastSelected][box] = domBox[property];
if(_lastSelected) {
if(property == "locatorType") {
_itemData[_lastSelected][box] = domBox.selectedItem.value;
} else {
_itemData[_lastSelected][box] = domBox[property];
}
}
// restore previous property
if(itemID) {
domBox.disabled = false;
if(_itemData[itemID] && _itemData[itemID][box] !== undefined) {
if(property == "locatorType") {
domBox[property] = _locatorIndexArray[_itemData[itemID][box]];
} else {
domBox[property] = _itemData[itemID][box];
}
}
} else if(itemID !== undefined) {
domBox.disabled = true;
domBox[property] = "";
@ -413,8 +448,12 @@ var Zotero_Citation_Dialog = new function () {
var citationItem = new Zotero.CSL.CitationItem();
citationItem.itemID = items[0];
for(var property in _preserveData) {
if(property == "locatorType") {
citationItem[property] = document.getElementById(property).selectedItem.value;
} else {
citationItem[property] = document.getElementById(property)[_preserveData[property]];
}
}
io.citation.citationItems = [citationItem];
}
}
@ -429,8 +468,5 @@ var Zotero_Citation_Dialog = new function () {
itemNode.setAttribute("class", "listitem-iconic");
itemNode.setAttribute("image", item.getImageSrc());
document.getElementById("citation-list").appendChild(itemNode);
// don't let someone select it again
document.getElementById("citation-add").disabled = true;
}
}

View File

@ -23,7 +23,7 @@
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/addCitationDialog.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/integration.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog
@ -44,7 +44,6 @@
<script src="addCitationDialog.js"/>
<vbox id="zotero-select-items-container" flex="1" style="padding: 1em">
<hbox flex="1">
<vbox flex="1">
<hbox flex="1">
<vbox align="stretch" flex="1">
@ -99,8 +98,8 @@
<hbox hidden="true" id="multiple-sources">
<vbox align="center" pack="center">
<toolbarbutton id="citation-add" oncommand="Zotero_Citation_Dialog.addCitation()" disabled="true"/>
<toolbarbutton id="citation-delete" oncommand="Zotero_Citation_Dialog.deleteCitation()" disabled="true"/>
<toolbarbutton id="add" oncommand="Zotero_Citation_Dialog.add()" disabled="true"/>
<toolbarbutton id="remove" oncommand="Zotero_Citation_Dialog.remove()" disabled="true"/>
</vbox>
<vbox>
<checkbox id="keepSorted" hidden="true" checked="false" oncommand="Zotero_Citation_Dialog.sortCitation()" label="&zotero.citation.keepSorted.label;"/>
@ -126,11 +125,7 @@
<vbox flex="1">
<hbox align="stretch">
<menulist onchange="Zotero_Citation_Dialog.confirmRegenerate(true)" id="locatorType">
<menupopup id="locator-type-popup">
<menuitem value="page" label="&zotero.citation.page;" selected="1"/>
<menuitem value="paragraph" label="&zotero.citation.paragraph;"/>
<menuitem value="line" label="&zotero.citation.line;"/>
</menupopup>
<menupopup id="locator-type-popup"/>
</menulist>
<textbox oninput="Zotero_Citation_Dialog.confirmRegenerate(false)" onchange="Zotero_Citation_Dialog.confirmRegenerate(true)" id="locator" flex="1"/>
</hbox>
@ -139,7 +134,6 @@
</vbox>
</hbox>
</vbox>
</hbox>
<textbox id="editor" type="styled" hidden="true" flex="1"/>

View File

@ -65,11 +65,16 @@
this._toggle = [];
// why is this necessary? because the browser takes time to
// load, but doesn't appear to fire an event when loaded.
// why does this work? no idea.
// load, but doesn't appear to fire an event when loaded,
// when recovering from being hidden. why does this work?
// no idea.
this._isLoaded = false;
var me = this;
if(this.hasAttribute("hidden")) {
window.setTimeout(function() {me._loaded()}, 1);
} else {
this._browser.contentWindow.addEventListener("load", function() {me._loaded()}, false);
}
]]></constructor>
<!-- Called when loaded. Until the browser is loaded, we can't do
@ -137,7 +142,7 @@
<setter><![CDATA[
this._readonly = val;
if(this._isLoaded) {
if(val == true) {
if(val) {
this._browser.contentDocument.designMode = "off";
} else {
this._browser.contentDocument.designMode = "on";
@ -201,7 +206,9 @@
this._browser.contentDocument.write("<body>"+html+"</body>");
this._browser.contentDocument.close();
this._browser.contentDocument.designMode = (this._readonly ? "off" : "on");
try {
this._browser.contentDocument.execCommand("styleWithCSS", false, this._styleWithCSS);
} catch(e) {}
this._updateButtons();
} else {

View File

@ -0,0 +1,169 @@
/*
***** BEGIN LICENSE BLOCK *****
Copyright (c) 2006 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://chnm.gmu.edu
Licensed under the Educational Community License, Version 1.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.opensource.org/licenses/ecl1.php
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
***** END LICENSE BLOCK *****
*/
var Zotero_Bibliography_Dialog = new function () {
var bibEditInterface;
var itemSet;
var _originalBibEntry;
var _lastSelectedItem;
this.load = load;
this.treeItemSelected = treeItemSelected;
this.listItemSelected = listItemSelected;
this.add = add;
this.remove = remove;
this.accept = accept;
/*
* initialize add citation dialog
*/
function load() {
document.getElementById('editor').format = "Integration";
if(Zotero.isWin) {
document.getElementById("zotero-select-items-container").style.border = "1px solid black";
}
bibEditInterface = window.arguments[0].wrappedJSObject;
itemSet = bibEditInterface.getItemSet();
// load (from selectItemsDialog.js)
doLoad();
// load bibliography entires
_loadItems();
}
/*
* called when an item in the item selection tree is clicked
*/
function treeItemSelected() {
// get selected item (from selectItemsDialog.js)
var items = getSelectedItems(true);
// disable add if item already in itemSet
document.getElementById("add").disabled = !items.length || itemSet.getItemsByIds([items[0]])[0];
}
/*
* called when an item in the reference list is clicked
*/
function listItemSelected() {
var selectedListItem = document.getElementById("item-list").getSelectedItem(0);
// enable remove if item is selected
document.getElementById("remove").disabled = !selectedListItem;
if(selectedListItem) {
_updatePreview(itemSet.getItemsByIds([selectedListItem.value])[0]);
} else {
_updatePreview(false);
}
}
/*
* Adds a citation to the reference list
*/
function add() {
// get selected item (from selectItemsDialog.js)
var item = getSelectedItems()[0];
bibEditInterface.add(item);
document.getElementById("add").disabled = true;
_loadItems();
}
/*
* Deletes a citation from the reference list
*/
function remove() {
var selectedListItem = document.getElementById("item-list").getSelectedItem(0);
var itemID = selectedListItem.value;
var item = itemSet.getItemsByIds([itemID])[0];
if(bibEditInterface.isCited(item)) {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var out = {};
var regenerate = promptService.confirmEx(
window,
Zotero.getString('integration.deleteCitedItem.title'),
Zotero.getString('integration.deleteCitedItem.body'),
promptService.STD_OK_CANCEL_BUTTONS+promptService.BUTTON_POS_1_DEFAULT,
null, null, null, null, out
);
if(regenerate != 0) return;
}
bibEditInterface.remove(item);
_loadItems();
}
/*
* Called on "Accept" button
*/
function accept() {
_updatePreview();
}
/*
* Updates the contents of the preview pane
*/
function _updatePreview(item) {
var editor = document.getElementById('editor');
if(_lastSelectedItem && editor.value != _originalBibEntry) {
Zotero.debug("setting bibliography for "+_lastSelectedItem.getID()+" to "+editor.value);
_lastSelectedItem.setProperty("bibliography-Integration", editor.value);
}
editor.readonly = !item;
editor.value = _originalBibEntry = (item ? bibEditInterface.preview(item) : "");
_lastSelectedItem = item;
}
/*
* loads items from itemSet
*/
function _loadItems() {
// delete all existing items from list
var itemList = document.getElementById("item-list");
while(itemList.firstChild) {
itemList.removeChild(itemList.firstChild);
}
// add new items
for(var i=0; i<itemSet.items.length; i++) {
var item = itemSet.items[i].zoteroItem;
var itemNode = document.createElement("listitem");
itemNode.setAttribute("value", item.getID());
itemNode.setAttribute("label", item.getField("title"));
itemNode.setAttribute("class", "listitem-iconic");
itemNode.setAttribute("image", item.getImageSrc());
itemList.appendChild(itemNode);
}
_updatePreview();
}
}

View File

@ -0,0 +1,115 @@
<?xml version="1.0"?>
<!--
***** BEGIN LICENSE BLOCK *****
Copyright (c) 2006 Center for History and New Media
George Mason University, Fairfax, Virginia, USA
http://chnm.gmu.edu
Licensed under the Educational Community License, Version 1.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.opensource.org/licenses/ecl1.php
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
***** END LICENSE BLOCK *****
-->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/integration.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<dialog
id="edit-bibliography-dialog"
orient="vertical"
title="&zotero.integration.editBibliography.title;"
width="750" height="450"
onload="Zotero_Bibliography_Dialog.load();"
onunload="doUnload();"
ondialogaccept="Zotero_Bibliography_Dialog.accept();"
buttons="cancel,accept"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
style="padding: 0">
<script src="include.js"/>
<script src="selectItemsDialog.js"/>
<script src="editBibliographyDialog.js"/>
<vbox id="zotero-select-items-container" flex="1" style="padding: 1em">
<vbox flex="1">
<hbox flex="1">
<vbox align="stretch" flex="1">
<hbox align="center" pack="end">
<label value="&zotero.toolbar.search.label;" control="zotero-tb-search"/>
<textbox id="zotero-tb-search" type="timed" timeout="250" oncommand="onSearch()" dir="reverse" onkeypress="if(event.keyCode == event.DOM_VK_ESCAPE) { this.value = ''; this.doCommand('cmd_zotero_search'); return false; } return true;">
<toolbarbutton id="zotero-tb-search-cancel" oncommand="this.parentNode.value='';" hidden="true"/>
</textbox>
</hbox>
<hbox flex="1" style="margin-top: 5px">
<tree id="zotero-collections-tree"
style="width: 150px;" hidecolumnpicker="true" seltype="single"
onselect="onCollectionSelected();">
<treecols>
<treecol
id="zotero-collections-name-column"
label="&zotero.collections.name_column;"
flex="1"
primary="true"/>
</treecols>
<treechildren/>
</tree>
<tree id="zotero-items-tree"
flex="1" hidecolumnpicker="true" seltype="single"
onselect="Zotero_Bibliography_Dialog.treeItemSelected();">
<treecols>
<treecol
id="zotero-items-column-title" primary="true"
label="&zotero.items.title_column;"
flex="4" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-firstCreator"
label="&zotero.items.creator_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-dateAdded" hidden="true"
label="&zotero.items.dateAdded_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol
id="zotero-items-column-dateModified" hidden="true"
label="&zotero.items.dateModified_column;"
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
</treecols>
<treechildren/>
</tree>
</hbox>
</vbox>
<hbox id="source-list">
<vbox align="center" pack="center">
<toolbarbutton id="add" oncommand="Zotero_Bibliography_Dialog.add()" disabled="true"/>
<toolbarbutton id="remove" oncommand="Zotero_Bibliography_Dialog.remove()" disabled="true"/>
</vbox>
<vbox>
<label value="&zotero.integration.references.label;"/>
<listbox id="item-list" flex="1" align="stretch" seltype="single"
style="width: 250px;" onselect="Zotero_Bibliography_Dialog.listItemSelected();"/>
</vbox>
</hbox>
</hbox>
</vbox>
<textbox id="editor" type="styled" flex="1"/>
</vbox>
</dialog>

View File

@ -121,16 +121,9 @@ Zotero.CSL.POSITION_SUBSEQUENT = 1;
Zotero.CSL.POSITION_IBID = 2;
Zotero.CSL.POSITION_IBID_WITH_LOCATOR = 3;
/*
* Constants for locator types
*/
Zotero.CSL.LOCATOR_PAGES = 0;
Zotero.CSL.LOCATOR_PARAGRAPH = 1;
Zotero.CSL.LOCATOR_LINE = 2;
Zotero.CSL.locatorTypeTerms = ["page", "paragraph", "line"];
Zotero.CSL._dateVariables = {
"date":true,
"issued":true,
"accessDate":true
}
@ -140,6 +133,12 @@ Zotero.CSL._namesVariables = {
"author":true
}
/*
* Constants for name (used for disambiguate-add-givenname)
*/
Zotero.CSL.NAME_USE_INITIAL = 1;
Zotero.CSL.NAME_USE_FULL = 2;
/*
* generate an item set
*/
@ -157,6 +156,8 @@ Zotero.CSL.prototype.createCitation = function(citationItems) {
/*
* create a citation (in-text or footnote)
*/
Zotero.CSL._firstNameRegexp = /^[a-zA-Z0-9]*/;
Zotero.CSL._textCharRegexp = /[a-zA-Z0-9]/;
Zotero.CSL.prototype.formatCitation = function(citation, format) {
var context = this._csl.citation;
if(!context) {
@ -166,17 +167,153 @@ Zotero.CSL.prototype.formatCitation = function(citation, format) {
throw "CSL: formatCitation called with empty citation";
}
var string = new Zotero.CSL.FormattedString(this, format, context.layout.@delimiter.toString());
// clone citationItems, so as not to disturb the citation
var citationItems = citation.citationItems;
// handle collapse
var cslAdded = [];
var collapse = context.option.(@name == "collapse").@value.toString();
if(collapse) {
// clone citationItems, so as not to disturb the citation
citationItems = new Array();
if(collapse == "citation-number") {
// loop through, collecting citation numbers
var citationNumbers = new Object();
for(var i=0; i<citation.citationItems.length; i++) {
var citationItem = citation.citationItems[i];
citationNumbers[citation.citationItems[i].item.getProperty("citation-number")] = i;
}
// add -1 at the end so that the last span gets added (loop below
// must be run once more)
citationNumbers[-1] = false;
var previousI = -1;
var span = [];
// loop through citation numbers and collect ranges in span
for(var i in citationNumbers) {
if(i == parseInt(previousI, 10)+1) { // could be part of a range
// including the previous number
span.push(citationNumbers[i]);
} else { // not part of a range
if(span.length) citationItems[span[0]] = citation.citationItems[span[0]];
if(span.length > 2) {
// if previous set of citations was a range, collapse them
var firstNumber = citationItems[span[0]].item.getProperty("citation-number");
citationItems[span[0]]._csl = {"citation-number":(firstNumber+"-"+(parseInt(firstNumber, 10)+span.length-1))};
cslAdded.push(span[0]);
} else if(span.length == 2) {
citationItems[span[1]] = citation.citationItems[span[1]];
}
span = [citationNumbers[i]];
}
previousI = i;
}
} else if(collapse.substr(0, 4) == "year") {
// loop through, collecting citations (sans date) in an array
var lastNames = {};
for(var i=0; i<citation.citationItems.length; i++) {
var citationString = new Zotero.CSL.FormattedString(this, format);
this._processElements(citation.citationItems[i].item, context.layout, citationString,
context, null, [{"issued":true}, {}]);
var cite = citationString.get();
// put into lastNames array
if(!lastNames[cite]) {
lastNames[cite] = [i];
} else {
lastNames[cite].push(i);
}
}
for(var i in lastNames) {
var itemsSharingName = lastNames[i];
if(itemsSharingName.length == 1) {
// if only one, don't worry about grouping
citationItems[itemsSharingName[0]] = citation.citationItems[itemsSharingName[0]];
} else {
var years = [];
// if grouping by year-suffix, we need to do more (to pull
// together various letters)
if(collapse == "year-suffix" && context.option.(@name == "disambiguate-add-year-suffix").@value == "true") {
var yearsArray = new Object();
for(var j=0; j<itemsSharingName.length; j++) {
var year = citation.citationItems[itemsSharingName[j]].item.getDate("issued");
if(year) {
year = year.getDateVariable("year");
if(year) {
// add to years
if(!yearsArray[year]) {
yearsArray[year] = [itemsSharingName[j]];
} else {
yearsArray[year].push(itemsSharingName[j]);
}
}
}
if(!year) {
// if no year, just copy
years.push("");
}
}
// loop through all years
for(var j in yearsArray) {
var citationItem = citation.citationItems[yearsArray[j][0]];
// push first year with any suffix
var year = j;
var suffix = citationItem.item.getProperty("disambiguate-add-year-suffix");
if(suffix) year += suffix;
years.push(year);
// also push subsequent years
if(yearsArray[j].length > 1) {
for(k=1; k<yearsArray[j].length; k++) {
var suffix = citation.citationItems[yearsArray[j][k]].item.getProperty("disambiguate-add-year-suffix");
if(suffix) years.push(suffix);
}
}
}
} else {
// just add years
for(var j=0; j<itemsSharingName.length; j++) {
var item = citation.citationItems[itemsSharingName[j]].item;
var year = item.getDate("issued");
if(year) {
years[j] = year.getDateVariable("year");
var suffix = item.getProperty("disambiguate-add-year-suffix");
if(suffix) years[j] += suffix;
}
}
}
citation.citationItems[itemsSharingName[0]]._csl = {"issued":{"year":years.join(", ")}};
citationItems[itemsSharingName[0]] = citation.citationItems[itemsSharingName[0]];
cslAdded.push(itemsSharingName[0]);
}
}
}
}
var string = new Zotero.CSL.FormattedString(this, format, context.layout.@delimiter.toString());
for(var i=0; i<citationItems.length; i++) {
var citationItem = citationItems[i];
if(!citationItem) continue;
var citationString = new Zotero.CSL.FormattedString(this, format);
// suppress author if requested
var ignore = citationItem.suppressAuthor ? [{"author":true}, []] : undefined;
var ignore = citationItem.suppressAuthor ? [{"author":true}, {}] : undefined;
// add prefix
if(citationItem.prefix) {
citationString.append(citationItem.prefix+" ");
var prefix = citationItem.prefix;
// add space to prefix if last char is alphanumeric
if(Zotero.CSL._textCharRegexp.test(prefix[prefix.length-1])) prefix += " ";
citationString.append(prefix);
}
this._processElements(citationItem.item, context.layout, citationString,
@ -184,7 +321,12 @@ Zotero.CSL.prototype.formatCitation = function(citation, format) {
// add suffix
if(citationItem.suffix) {
citationString.append(" "+citationItem.suffix);
var suffix = citationItem.suffix;
// add space to suffix if last char is alphanumeric
if(Zotero.CSL._textCharRegexp.test(suffix[0])) suffix = " "+suffix;
citationString.append(suffix);
}
string.concat(citationString);
@ -192,7 +334,14 @@ Zotero.CSL.prototype.formatCitation = function(citation, format) {
var returnString = new Zotero.CSL.FormattedString(this, format);
returnString.append(string.get(), context.layout, false, true);
return returnString.get();
var returnString = returnString.get();
// loop through to remove _csl property
for(var i=0; i<cslAdded.length; i++) {
citationItems[cslAdded[i]]._csl = undefined;
}
return returnString;
}
/*
@ -230,7 +379,10 @@ Zotero.CSL.prototype.formatBibliography = function(itemSet, format) {
var item = itemSet.items[i];
if(item == undefined) continue;
var string = new Zotero.CSL.FormattedString(this, format);
// try to get custom bibliography
var string = item.getProperty("bibliography-"+format);
if(!string) {
string = new Zotero.CSL.FormattedString(this, format);
this._processElements(item, context.layout, string,
context);
if(!string) {
@ -244,12 +396,13 @@ Zotero.CSL.prototype.formatBibliography = function(itemSet, format) {
}
string = string.get();
}
// add line feeds
if(format == "HTML") {
var coins = Zotero.OpenURL.createContextObject(item.zoteroItem, "1.0");
var span = (coins ? ' <span class="Z3988" title="'+coins.replace("&", "&amp;")+'"></span>' : '');
var span = (coins ? ' <span class="Z3988" title="'+coins.replace("&", "&amp;", "g")+'"></span>' : '');
if(this.class == "note" && isCitation) {
output += "<li>"+string+span+"</li>\r\n";
@ -293,26 +446,41 @@ Zotero.CSL.prototype.formatBibliography = function(itemSet, format) {
/*
* gets a term, in singular or plural form
*/
Zotero.CSL.prototype._getTerm = function(term, plural, form) {
Zotero.CSL.prototype._getTerm = function(term, plural, form, includePeriod) {
if(!form) {
form = "long";
}
if(!this._terms[form] || !this._terms[form][term]) {
Zotero.debug("CSL: WARNING: could not find term \""+term+'" with form "'+form+'"');
if(form == "verb-short") {
return this._getTerm(term, plural, "verb");
} else if(form == "symbol") {
return this._getTerm(term, plural, "short");
} else if(form != "long") {
return this._getTerm(term, plural, "long");
} else {
Zotero.debug("CSL: WARNING: could not find term \""+term+'"');
return "";
}
}
var term;
if(typeof(this._terms[form][term]) == "object") { // singular and plural forms
// are available
if(plural) {
return this._terms[form][term][1];
term = this._terms[form][term][1];
} else {
return this._terms[form][term][0];
term = this._terms[form][term][0];
}
} else {
term = this._terms[form][term];
}
return this._terms[form][term];
if((form == "short" || form == "verb-short") && includePeriod) {
term += ".";
}
return term;
}
/*
@ -328,8 +496,8 @@ Zotero.CSL.prototype._processNames = function(item, element, formattedString, co
var success = false;
var newString = formattedString.clone();
if(formattedString.format != "Sort" && variables[j] == "author"
&& context.option.(@name == "subsequent-author-substitute").length()
if(formattedString.format != "Sort" && variables[j] == "author" && context
&& context.option.(@name == "subsequent-author-substitute") == "true"
&& item.getProperty("subsequent-author-substitute")
&& context.localName() == "bibliography") {
newString.append(context.option.(@name == "subsequent-author-substitute").@value.toString());
@ -363,9 +531,12 @@ Zotero.CSL.prototype._processNames = function(item, element, formattedString, co
}
if(etAlMin && etAlUseFirst && maxCreators >= parseInt(etAlMin, 10)) {
maxCreators = parseInt(etAlUseFirst, 10);
etAlUseFirst = parseInt(etAlUseFirst, 10);
if(etAlUseFirst != maxCreators) {
maxCreators = etAlUseFirst;
useEtAl = true;
}
}
// add additional names to disambiguate
if(variables[j] == "author" && useEtAl) {
@ -376,14 +547,13 @@ Zotero.CSL.prototype._processNames = function(item, element, formattedString, co
}
}
var authorStrings = [];
var firstName, lastName;
if(child.@form == "short") {
var fullNames = item.getProperty("disambiguate-add-givenname").split(",");
}
}
var authorStrings = [];
var firstName, lastName;
// parse authors into strings
for(var i=0; i<maxCreators; i++) {
if(formattedString.format == "Sort") {
@ -397,8 +567,9 @@ Zotero.CSL.prototype._processNames = function(item, element, formattedString, co
} else {
var firstName = "";
if(child.@form != "short" || (fullNames && fullNames.indexOf(i) != -1)) {
if(child["@initialize-with"].length()) {
if(child.@form != "short" || (fullNames && fullNames[i])) {
if(child["@initialize-with"].length() && (!fullNames ||
fullNames[i] != Zotero.CSL.NAME_USE_FULL)) {
// even if initialize-with is simply an empty string, use
// initials
@ -464,7 +635,7 @@ Zotero.CSL.prototype._processNames = function(item, element, formattedString, co
}
} else if(formattedString.format != "Sort" &&
name == "label" && variables[j] != "author") {
newString.append(this._getTerm(variables[j], (maxCreators != 1), child["@form"].toString()), child);
newString.append(this._getTerm(variables[j], (maxCreators != 1), child["@form"].toString(), child["@include-period"] == "true"), child);
}
}
success = true;
@ -510,7 +681,7 @@ Zotero.CSL.prototype._processElements = function(item, element, formattedString,
if(name == "text") {
if(child["@term"].length()) {
var term = this._getTerm(child["@term"].toString(), child.@plural.length(), child.@form.toString());
var term = this._getTerm(child["@term"].toString(), child.@plural == "true", child.@form.toString(), child["@include-period"] == "true");
if(term) {
formattedString.append(term, child);
}
@ -525,11 +696,15 @@ Zotero.CSL.prototype._processElements = function(item, element, formattedString,
if(variables[j] == "locator") {
// special case for locator
var text = citationItem.locator;
var text = citationItem && citationItem.locator ? citationItem.locator : "";
} else if(citationItem && citationItem._csl && citationItem._csl[variables[j]]) {
// override if requested
var text = citationItem._csl[variables[j]];
} else if(variables[j] == "citation-number") {
// special case for citation-number
var text = item.getProperty("citation-number");
} else {
var text = item.getText(variables[j], form);
var text = item.getVariable(variables[j], form);
}
if(text) {
@ -569,17 +744,18 @@ Zotero.CSL.prototype._processElements = function(item, element, formattedString,
if(variables[j] == "locator") {
// special case for locator
var locatorType = (citationItem.locatorType ? citationItem.locatorType : 0);
var term = Zotero.CSL.locatorTypeTerms[locatorType];
var value = citationItem.locator;
var term = (citationItem && citationItem.locatorType) ? citationItem.locatorType : "page";
// if "other" specified as the term, don't do anything
if(term == "other") term = false;
var value = citationItem && citationItem.locator ? citationItem.locator : false;
} else {
var term = variables[j];
var value = item.getText(variables[j]);
var value = item.getVariable(variables[j]);
}
if(term && value) {
var isPlural = value.indexOf("-") != -1 || value.indexOf("—") != -1 || value.indexOf(",") != -1;
var text = this._getTerm(term, isPlural, child.@form.toString());
if(term !== false && value) {
var isPlural = value.indexOf("-") != -1 || value.indexOf(",") != -1;
var text = this._getTerm(term, isPlural, child.@form.toString(), child["@include-period"] == "true");
if(text) {
newString.append(text);
@ -669,6 +845,11 @@ Zotero.CSL.prototype._processElements = function(item, element, formattedString,
if(newName == "date-part") {
var part = newChild.@name.toString();
if(citationItem && citationItem._csl && citationItem._csl[variables[j]] && citationItem._csl[variables[j]][part]) {
// date is in citationItem
var string = citationItem._csl[variables[j]][part];
} else {
var string = date.getDateVariable(part).toString();
if(string == "") continue;
@ -704,6 +885,7 @@ Zotero.CSL.prototype._processElements = function(item, element, formattedString,
}
}
}
}
variableString.append(string, newChild);
}
@ -752,23 +934,41 @@ Zotero.CSL.prototype._processElements = function(item, element, formattedString,
}
// inspect variables
for each(var attribute in ["variable", "type", "position"]) {
for each(var attribute in ["variable", "type", "disambiguate", "locator", "position"]) {
if(newChild["@"+attribute].length()) {
var variables = newChild["@"+attribute].toString().split(" ");
for(var j=0; j<variables.length; j++) {
if(attribute == "variable") {
var exists = item.getText(variables[j]) !== "";
if(Zotero.CSL._dateVariables[variables[j]]) {
// getDate not false/undefined
var exists = !!item.getDate(variables[j]);
} else if(Zotero.CSL._namesVariables[variables[j]]) {
// getNames not false/undefined, not empty
var exists = item.getNames(variables[j]);
if(exists) exists = !!exists.length;
} else {
var exists = item.getVariable(variables[j]) !== "";
}
} else if(attribute == "type") {
var exists = item.isType(variables[j]);
} else if(attribute == "disambiguate") {
var exists = (variables[j] == "true" && item.getProperty("disambiguate-condition"))
|| (variables[j] == "false" && !item.getProperty("disambiguate-condition"));
} else if(attribute == "locator") {
var exists = citationItem && citationItem.locator &&
(citationItem.locatorType == variables[j]
|| (!citation.locatorType && variables[j] == "page"));
} else { // attribute == "position"
if(variables[j] == "first") {
var exists = !citationItem.position || citationItem.position == Zotero.CSL.POSITION_FIRST;
var exists = !citationItem
|| !citationItem.position
|| citationItem.position == Zotero.CSL.POSITION_FIRST;
} else if(variables[j] == "subsequent") {
var exists = citationItem.position >= Zotero.CSL.POSITION_SUBSEQUENT;
var exists = citatonItem && citationItem.position >= Zotero.CSL.POSITION_SUBSEQUENT;
} else if(variables[j] == "ibid") {
var exists = citationItem.position >= Zotero.CSL.POSITION_IBID;
var exists = citationItem && citationItem.position >= Zotero.CSL.POSITION_IBID;
} else if(variables[j] == "ibid-with-locator") {
var exists = citationItem.position == Zotero.CSL.POSITION_IBID_WITH_LOCATOR;
var exists = citationItem && citationItem.position == Zotero.CSL.POSITION_IBID_WITH_LOCATOR;
}
}
@ -817,18 +1017,48 @@ Zotero.CSL.prototype._compareItem = function(a, b, context) {
var sortB = [];
// author
if(context.option.(@name == "sort-algorithm").@value == "author-date") {
var sortA = new Zotero.CSL.SortString();
this._processElements(a, this._csl.macro.(@name == "author"), sortA);
var date = a.getDate("issued");
if(date) sortA.append(date.getDateVariable("sort"));
if(context.sort.key.length()) {
for each(var key in context.sort.key) {
var keyA = new Zotero.CSL.SortString();
var keyB = new Zotero.CSL.SortString();
var sortB = new Zotero.CSL.SortString();
this._processElements(b, this._csl.macro.(@name == "author"), sortB);
var date = b.getDate("issued");
if(date) sortB.append(date.getDateVariable("sort"));
if(key.@macro.length()) {
this._processElements(a, this._csl.macro.(@name == key.@macro), keyA);
this._processElements(b, this._csl.macro.(@name == key.@macro), keyB);
} else if(key.@variable.length()) {
var variable = key.@variable.toString();
return sortA.compare(sortB);
if(Zotero.CSL._dateVariables[variable]) { // date
var date = a.getDate(variable);
if(date) keyA.append(date.getDateVariable("sort"));
date = b.getDate(variable);
if(date) keyB.append(date.getDateVariable("sort"));
} else if(Zotero.CSL._namesVariables[key.@variable]) { // names
var element = <names><name/></names>;
element.setNamespace(Zotero.CSL.Global.ns);
this._processNames(a, element, keyA, context, null, [variable]);
this._processNames(b, element, keyB, context, null, [variable]);
} else { // text
if(variable == "citation-number") {
keyA.append(a.getProperty(variable));
keyB.append(b.getProperty(variable));
} else {
keyA.append(a.getVariable(variable));
keyB.append(b.getVariable(variable));
}
}
}
var compare = keyA.compare(keyB);
if(key.@sort == "descending") { // the compare method sorts ascending
// so we sort descending by reversing it
if(compare < 1) return 1;
if(compare > 1) return -1;
} else if(compare != 0) {
return compare;
}
}
}
return 0;
}
@ -836,7 +1066,7 @@ Zotero.CSL.prototype._compareItem = function(a, b, context) {
/*
* Compares two citations; returns true if they are different, false if they are equal
*/
Zotero.CSL.prototype._compareCitations = function(a, b) {
Zotero.CSL.prototype._compareCitations = function(a, b, context) {
if((!a && b) || (a && !b)) {
return true;
} else if(!a && !b) {
@ -845,39 +1075,19 @@ Zotero.CSL.prototype._compareCitations = function(a, b) {
var aString = new Zotero.CSL.FormattedString(this, "Text");
this._processElements(a, this._csl.citation.layout, aString,
this._csl.citation, "subsequent");
context, "subsequent");
var bString = new Zotero.CSL.FormattedString(this, "Text");
this._processElements(b, this._csl.citation.layout, bString,
this._csl.citation, "subsequent");
context, "subsequent");
return !(aString.get() == bString.get());
}
/*
* Compares the names from two items
* Returns -1 if A comes before B, 1 if B comes before A, or 0 if they are equal
*/
Zotero.CSL.prototype._compareNames = function(a, b) {
if(!a && b) {
return -1;
} else if(!b && a) {
return 1;
} else if(!b && !a) {
return 0;
}
var aString = new Zotero.CSL.SortString();
this._processElements(a, this._csl.macro.(@name == "author"), aString);
var bString = new Zotero.CSL.SortString();
this._processElements(b, this._csl.macro.(@name == "author"), bString);
return aString.compare(bString);
}
Zotero.CSL.Global = new function() {
this.init = init;
this.getMonthStrings = getMonthStrings;
this.getLocatorStrings = getLocatorStrings;
this.cleanXML = cleanXML;
this.parseLocales = parseLocales;
@ -888,6 +1098,10 @@ Zotero.CSL.Global = new function() {
.getService(Components.interfaces.nsILocaleService)
.getApplicationLocale());
var locatorTypeTerms = ["page", "book", "chapter", "column", "figure", "folio",
"issue", "line", "note", "opus", "paragraph", "part", "section",
"volume", "verse"];
/*
* initializes CSL interpreter
*/
@ -917,6 +1131,33 @@ Zotero.CSL.Global = new function() {
return Zotero.CSL.Global._defaultTerms[form]["_months"];
}
/*
* returns an array of short or long locator strings
*/
function getLocatorStrings(form) {
if(!form) form = "long";
Zotero.CSL.Global.init();
var locatorStrings = new Object();
for(var i=0; i<locatorTypeTerms.length; i++) {
var term = locatorTypeTerms[i];
var termKey = term;
if(term == "page") termKey = "";
locatorStrings[termKey] = Zotero.CSL.Global._defaultTerms[form][term];
if(!locatorStrings[termKey] && form == "symbol") {
locatorStrings[termKey] = Zotero.CSL.Global._defaultTerms["short"][term];
}
if(!locatorStrings[termKey]) {
locatorStrings[termKey] = Zotero.CSL.Global._defaultTerms["long"][term];
}
// use singular form
if(typeof(locatorStrings[termKey]) == "object") locatorStrings[termKey] = locatorStrings[termKey][0];
}
return locatorStrings;
}
/*
* removes parse instructions from XML
*/
@ -1018,6 +1259,15 @@ Zotero.CSL.Global = new function() {
}
}
// ensure parity between long and short months
var longMonths = termArray["long"]["_months"];
var shortMonths = termArray["short"]["_months"];
for(var i=0; i<longMonths.length; i++) {
if(!shortMonths[i]) {
shortMonths[i] = longMonths[i];
}
}
return termArray;
}
}
@ -1046,8 +1296,7 @@ Zotero.CSL.Citation = function(citationItems, csl) {
if(csl) {
this._csl = csl;
this._citation = csl._csl.citation;
this.sortable = this._citation.option.(@name == "sort-algorithm").length()
&& this._citation.option.(@name == "sort-algorithm").@value != "cited";
this.sortable = this._citation.sort.key.length();
} else {
this.sortable = false;
}
@ -1176,7 +1425,7 @@ Zotero.CSL.Item._zoteroFieldMap = {
/*
* Gets a text object for a specific type.
*/
Zotero.CSL.Item.prototype.getText = function(variable, form) {
Zotero.CSL.Item.prototype.getVariable = function(variable, form) {
if(!Zotero.CSL.Item._zoteroFieldMap[variable]) return "";
if(variable == "title" && form == "short") {
@ -1404,7 +1653,12 @@ Zotero.CSL.ItemSet = function(items, csl) {
this.options[option.@name.toString()] = option.@value.toString();
}
Zotero.debug((this.options["subsequent-author-substitute"] ? "subsequent-author-substitute on" : "subsequent-author-substitute off"));
for each(var thisIf in this.citation..if) {
if(thisIf.@disambiguate.length()) {
this.options["disambiguate-condition"] = true;
break;
}
}
this.items = [];
this.itemsById = {};
@ -1414,10 +1668,8 @@ Zotero.CSL.ItemSet = function(items, csl) {
// check which disambiguation options are enabled
enabledDisambiguationOptions = new Array();
for each(var option in ["disambiguate-add-year-suffix",
"disambiguate-add-givenname", "disambiguate-add-names",
"disambiguate-add-title"]) {
if(this.options[option]) {
for(var option in this.options) {
if(option.substr(0, 12) == "disambiguate" && this.options[option]) {
enabledDisambiguationOptions.push(option);
}
}
@ -1489,8 +1741,7 @@ Zotero.CSL.ItemSet.prototype.remove = function(items) {
*/
Zotero.CSL.ItemSet.prototype.resort = function() {
// sort, if necessary
if(this.bibliography.option.(@name == "sort-algorithm").length()
&& this.bibliography.option.(@name == "sort-algorithm").@value != "cited") {
if(this.bibliography.sort.key.length()) {
var me = this;
this.items = this.items.sort(function(a, b) {
@ -1498,10 +1749,8 @@ Zotero.CSL.ItemSet.prototype.resort = function() {
});
}
var changedCitations = new Array();
// first loop through to collect disambiguation data by item, so we can
// see if any items have changed
// see if any items have changed; also collect last names
if(enabledDisambiguationOptions.length) {
var oldDisambiguate = new Array();
for(var i in enabledDisambiguationOptions) {
@ -1514,41 +1763,104 @@ Zotero.CSL.ItemSet.prototype.resort = function() {
}
}
var namesByItem = new Object();
for(var i=0; i<this.items.length; i++) {
var names = this.items[i].getNames("author");
if(!names) names = this.items[i].getNames("editor");
if(!names) names = this.items[i].getNames("translator");
if(!names) continue;
namesByItem[i] = names;
}
// check where last names are the same but given names are different
if(this.options["disambiguate-add-givenname"]) {
var firstNamesByItem = new Object();
var allNames = new Object();
var nameType = new Object();
for(var i=0; i<this.items.length; i++) {
var names = namesByItem[i];
var firstNames = [];
for(var j=0; j<names.length; j++) {
// get firstName and lastName
var m = Zotero.CSL._firstNameRegexp.exec(names[j].getNameVariable("firstName"));
var firstName = m[0].toLowerCase();
firstNames.push(firstName);
if(!firstName) continue;
var lastName = names[j].getNameVariable("lastName");
// add last name
if(!allNames[lastName]) {
allNames[lastName] = [firstName];
} else if(allNames[lastName].indexOf(firstName) == -1) {
allNames[lastName].push(firstName);
}
}
firstNamesByItem[i] = firstNames;
}
// loop through last names
for(var i=0; i<this.items.length; i++) {
if(!namesByItem[i]) continue;
var nameFormat = new Array();
for(var j=0; j<namesByItem[i].length; j++) {
var lastName = namesByItem[i][j].getNameVariable("lastName");
if(nameType[lastName] === undefined) {
// determine how to format name
var theNames = allNames[lastName];
if(theNames.length > 1) {
nameType[lastName] = Zotero.CSL.NAME_USE_INITIAL;
// check initials to see if any match
var initials = new Object();
for(var k=0; k<theNames.length; k++) {
if(initials[theNames[k][0]]) {
nameType[lastName] = Zotero.CSL.NAME_USE_FULL;
}
initials[theNames[k][0]] = true;
break;
}
}
}
nameFormat[j] = nameType[lastName];
}
if(nameFormat.length) {
// if some names have special formatting, save
this.items[i].setProperty("disambiguate-add-givenname", nameFormat.join(","));
}
}
}
// loop through once to determine where items equal the previous item
if(enabledDisambiguationOptions.length) {
var citationsEqual = [];
for(var i=1; i<this.items.length; i++) {
citationsEqual[i] = me.csl._compareCitations(this.items[i-1], this.items[i]);
citationsEqual[i] = this.csl._compareCitations(this.items[i-1], this.items[i], this.citation);
}
}
var allNames = {};
var lastItem = false;
var lastNames = false;
var lastYear = false;
var citationNumber = 1;
for(var i in this.items) {
for(var i=0; i<this.items.length; i++) {
var item = this.items[i];
if(item == undefined) continue;
var year = item.getDate("issued");
if(year) year = year.getDateVariable("year");
var names = item.getNames("author");
var names = namesByItem[i];
var disambiguated = false;
// true only if names are an exact match
var exactMatch = me.csl._compareNames(item, lastItem);
if(enabledDisambiguationOptions.length && i != 0 && !citationsEqual[i]
&& year == lastYear) {
if(enabledDisambiguationOptions.length && i != 0 && citationsEqual[i] == 0) {
// some options can only be applied if there are actual authors
if(names && lastNames) {
if(exactMatch == 0) {
// copy from previous item
this._copyDisambiguation(lastItem, item);
} else {
// these options only apply if not an _exact_ match
if(this.options["disambiguate-add-names"]) {
if(names && lastNames && this.options["disambiguate-add-names"]) {
// try adding names to disambiguate
var oldAddNames = lastItem.getProperty("disambiguate-add-names");
@ -1580,50 +1892,27 @@ Zotero.CSL.ItemSet.prototype.resort = function() {
// now, loop through and see whether there's a
// dissimilarity before the end
var namesDiffer = false;
for(var j=0; j<numberOfNames; j++) {
var lastUnequal = this.options["disambiguate-add-names"]
&& names[j].getNameVariable("lastName") != lastNames[j].getNameVariable("lastName");
var firstUnequal = this.options["disambiguate-add-givenname"]
&& names[j].getNameVariable("firstName") != lastNames[j].getNameVariable("firstName");
if(lastUnequal || firstUnequal) {
if(this.options["disambiguate-add-names"]) {
namesDiffer = (names[j].getNameVariable("lastName") != lastNames[j].getNameVariable("lastName")
|| (firstNamesByItem && firstNamesByItem[i][j] != firstNamesByItem[i-1][j]));
if(this.options["disambiguate-add-names"] && namesDiffer) {
item.setProperty("disambiguate-add-names", j+1);
if(!oldAddNames || oldAddNames < j+1) {
lastItem.setProperty("disambiguate-add-names", j+1);
}
}
// if the difference is only in the first
// name, show first name
if(!lastUnequal && firstUnequal) {
oldAddGivenname = lastItem.getProperty("disambiguate-add-givenname").split(",");
if(oldAddGivenname) {
if(oldAddGivenname.indexOf(j) == -1) {
oldAddGivenname.push(j);
lastItem.setProperty("disambiguate-add-givenname", oldAddGivenname.join(","));
}
} else {
lastItem.setProperty("disambiguate-add-givenname", j);
}
item.setProperty("disambiguate-add-givenname", j);
}
// add to names before as well
for(var k=i-2; me.csl._compareNames(lastItem, this.items[k]) == 0; k--) {
this._copyDisambiguation(lastItem, this.items[k]);
}
disambiguated = true;
}
if(namesDiffer) {
break;
}
}
}
}
// add a year suffix, if the above didn't work
if(!disambiguated && year && this.options["disambiguate-add-year-suffix"]) {
if(!disambiguated && year && !namesDiffer && this.options["disambiguate-add-year-suffix"]) {
var lastDisambiguate = lastItem.getProperty("disambiguate-add-year-suffix");
if(!lastDisambiguate) {
lastItem.setProperty("disambiguate-add-year-suffix", "a");
@ -1649,12 +1938,19 @@ Zotero.CSL.ItemSet.prototype.resort = function() {
disambiguated = true;
}
// add a title, if the above didn't work
if(!disambiguated) {
lastItem.setProperty("disambiguate-add-title", true);
item.setProperty("disambiguate-add-title", true);
// use disambiguate condition if above didn't work
if(!disambiguated && this.options["disambiguate-condition"]) {
var oldCondition = lastItem.getProperty("disambiguate-condition");
lastItem.setProperty("disambiguate-condition", true);
item.setProperty("disambiguate-condition", true);
disambiguated = true;
// if we cannot disambiguate with the conditional, revert
if(me.csl._compareCitations(lastItem, item) == 0) {
if(!oldCondition) {
lastItem.setProperty("disambiguate-conditon", undefined);
}
item.setProperty("disambiguate-condition", undefined);
}
}
}
@ -1671,6 +1967,7 @@ Zotero.CSL.ItemSet.prototype.resort = function() {
}
// find changed citations
var changedCitations = new Array();
if(enabledDisambiguationOptions.length) {
for(var j in this.items) {
if(this.items[j] == undefined) continue;
@ -1770,6 +2067,13 @@ Zotero.CSL.FormattedString.prototype.append = function(string, element, dontDeli
this.append(element.@prefix.toString(), null, true);
}
if(string.length && string[0] == "." &&
Zotero.CSL.FormattedString._punctuation.indexOf(this.string[this.string.length-1]) != -1) {
// if string already ends in punctuation, preserve the existing stuff
// and don't add a period
string = string.substr(1);
}
// close quotes, etc. using punctuation
if(this.closePunctuation) {
if(Zotero.CSL.FormattedString._punctuation.indexOf(string[0]) != -1) {
@ -1879,7 +2183,7 @@ Zotero.CSL.FormattedString.prototype.append = function(string, element, dontDeli
}
// add quotes if necessary
if(element.@quotes.length()) {
if(element.@quotes == "true") {
this.string += this._openQuote;
if(this.useBritishStyleQuotes) {
@ -1896,16 +2200,7 @@ Zotero.CSL.FormattedString.prototype.append = function(string, element, dontDeli
// begins with a period, chop the period off the suffix
var suffix;
if(element && element.@suffix.length()) {
suffix = element.@suffix.toString(); // copy so as to leave original intact
if(suffix.length && suffix[0] == "." &&
Zotero.CSL.FormattedString._punctuation.indexOf(string[string.length-1]) != -1) {
// if string already ends in punctuation, preserve the existing stuff
// and don't add a period
suffix = suffix.substr(1);
}
this.append(suffix, null, true);
this.append(element.@suffix.toString(), null, true);
}
return true;
@ -1959,11 +2254,15 @@ Zotero.CSL.SortString.prototype.compare = function(b, a) {
if(aIsString && bIsString) {
if(a == b) {
return 0;
} else if(!isNaN(a % 1) && !isNaN(b % 1)) {
// both numeric
if(b > a) return -1;
return 1; // already know they're not equal
} else {
var cmp = Zotero.CSL.Global.collation.compareString(Zotero.CSL.Global.collation.kCollationCaseInSensitive, a, b);
if(cmp == 0) {
// for some reason collation service returned 0; the collation
// service sucks!
// service sucks! they can't be equal!
if(b > a) {
return -1;
} else {

View File

@ -310,19 +310,28 @@ Zotero.CSL.Compat.ItemSet.prototype.add = function(items) {
}
this.items.push(item);
returnList.push(item);
item.zoteroItem = item;
item.setProperty = function(property, value) {
item._csl[property] = value;
}
item.getProperty = function(property) {
return (item._csl[property] ? item._csl[property] : "");
}
}
return returnList;
}
Zotero.CSL.Compat.ItemSet.prototype.remove = function(items) {
for(var i in items) {
if(!item) continue;
if(items[i] instanceof Zotero.Item) {
var item = items[i];
} else {
var item = Zotero.Items.get(i);
}
if(!item) continue;
this.items.splice(this.items.indexOf(item), 1);
}
}
@ -456,8 +465,6 @@ Zotero.CSL.Compat.prototype.formatCitation = function(citation, format) {
var locator = citation.citationItems[0].locator;
if(locator) {
var locatorType = Zotero.CSL.locatorTypeTerms[citation.citationItems[0].locatorType];
// search for elements with the same serialization
var element = this._getFieldDefaults("locator");
if(!element) {
@ -469,7 +476,7 @@ Zotero.CSL.Compat.prototype.formatCitation = function(citation, format) {
if(element) {
string.append("., ");
string.appendLocator(locatorType, locator, element);
string.appendLocator(citation.citationItems[0].locatorType, locator, element);
}
}
}
@ -484,7 +491,7 @@ Zotero.CSL.Compat.prototype.formatCitation = function(citation, format) {
if(citationItem.prefix) string.append(citationItem.prefix+" ");
var citationString = this._getCitation(citationItem.item,
position, Zotero.CSL.locatorTypeTerms[citationItem.locatorType],
position, citationItem.locatorType,
citationItem.locator, format, this._cit, ignore);
string.concat(citationString);
if(citationItem.suffix) string.append(citationItem.suffix+" ");
@ -536,7 +543,10 @@ Zotero.CSL.Compat.prototype.formatBibliography = function(itemSet, format) {
for(var i in items) {
var item = items[i];
var string = this._getCitation(item, "first", false, false, format, this._bib).get();
var string = item.getProperty("bibliography-"+format);
if(!string) {
string = this._getCitation(item, "first", false, false, format, this._bib).get();
}
if(!string) {
continue;
}
@ -1085,7 +1095,7 @@ Zotero.CSL.Compat.prototype._processCreators = function(type, element, creators,
var firstName, lastName;
for(var i=0; i<maxCreators; i++) {
var firstName = "";
if(element["form"] != "short") {
if(element["form"] && element["form"] != "short") {
if(child["initialize-with"] != undefined) {
// even if initialize-with is simply an empty string, use
// initials

View File

@ -20,7 +20,7 @@
***** END LICENSE BLOCK *****
*/
const API_VERSION = 2;
const API_VERSION = 3;
Zotero.Integration = new function() {
var _contentLengthRe = /[\r\n]Content-Length: *([0-9]+)/i;
@ -363,7 +363,7 @@ Zotero.Integration.SOAP = new function() {
/*
* generates a new citation for a given item
* ACCEPTS: sessionID, bibliographyMode, citationMode, editCitationIndex(, fieldIndex, fieldName)+
* RETURNS: bibliography(, fieldIndex, fieldRename, fieldContent)+
* RETURNS: bibliography, documentData(, fieldIndex, fieldRename, fieldContent)+
*/
function update(vars) {
if(!_sessions[vars[0]]) return "ERROR:sessionExpired";
@ -372,8 +372,16 @@ Zotero.Integration.SOAP = new function() {
var bibliographyMode = vars[1];
var citationMode = vars[2];
// get whether to edit bibliography or edit a citation
var editCitationIndex = false;
var editBibliography = false;
if(vars[3] == "B") {
editBibliography = true;
} else if(vars[3] != "!") {
editCitationIndex = vars[3];
}
// first collect entire bibliography
var editCitationIndex = (vars[3] == "!" ? false : vars[3]);
var editCitation = false;
for(var i=4; i<vars.length; i+=2) {
if(vars[i+1] == "X") { // new citation has field name X
@ -392,6 +400,7 @@ Zotero.Integration.SOAP = new function() {
}
session.updateItemSet();
if(editCitationIndex) {
session.updateCitations(editCitationIndex-1);
var added = session.editCitation(editCitationIndex, editCitation);
@ -406,28 +415,41 @@ Zotero.Integration.SOAP = new function() {
}
session.updateCitations();
if(editBibliography) {
session.editBibliography();
}
// update
var output = new Array();
if((bibliographyMode == "updated" // if we want updated bib
&& session.itemSetHasChanged) // and bibliography changed
|| bibliographyMode == "true") { // or if we should generate regardless of changes
output.push(session.getBibliography());
var bibliography = session.getBibliography();
if(!bibliography) bibliography = "!";
output.push(bibliography);
} else { // otherwise, send no bibliography
output.push("!");
}
if(session.documentDataHasChanged) {
output.push(session.getDocumentData());
} else {
output.push("!");
}
// get citations
output = output.concat(session.getCitations(citationMode == "all"));
// reset citationSet
session.reset();
session.resetRequest();
return output;
}
/*
* restores a session, given all citations
* ACCEPTS: version, styleID, use-endnotes, use-bookmarks(, fieldIndex, fieldName)+
* ACCEPTS: version, documentData, styleID, use-endnotes, use-bookmarks(, fieldIndex, fieldName)+
* RETURNS: sessionID
*/
function restoreSession(vars) {
@ -436,18 +458,21 @@ Zotero.Integration.SOAP = new function() {
}
var sessionID = Zotero.randomString();
var session = _sessions[sessionID] = new Zotero.Integration.Session(vars[1], vars[2], vars[3]);
var session = _sessions[sessionID] = new Zotero.Integration.Session();
session.setStyle(vars[2], vars[3], vars[4]);
var encounteredItem = new Object();
var newField = new Object();
var regenerate = new Object();
for(var i=4; i<vars.length; i+=2) {
for(var i=5; i<vars.length; i+=2) {
session.addCitation(vars[i], vars[i+1]);
}
session.updateItemSet(session.citationsByItemID);
session.reset();
if(vars[1] != "!") session.loadDocumentData(vars[1]);
session.resetRequest();
return [sessionID];
}
@ -474,6 +499,7 @@ Zotero.Integration.SOAP = new function() {
if(vars[0] == "!") {
// no session ID; generate a new one
var sessionID = Zotero.randomString();
var session = _sessions[sessionID] = new Zotero.Integration.Session();
} else {
// session ID exists
var sessionID = vars[0];
@ -486,10 +512,8 @@ Zotero.Integration.SOAP = new function() {
}
watcher.openWindow(null, 'chrome://zotero/content/integrationDocPrefs.xul', '',
'chrome,modal'+(Zotero.isWin ? ',popup' : ''), io);
_sessions[sessionID] = new Zotero.Integration.Session(io.style, io.useEndnotes, io.useBookmarks);
session = _sessions[sessionID];
'chrome,modal'+(Zotero.isWin ? ',popup' : ''), io, true);
session.setStyle(io.style, io.useEndnotes, io.useBookmarks);
return [sessionID, io.style, session.style.class, session.style.hasBibliography ? "1" : "0", io.useEndnotes, io.useBookmarks];
}
@ -507,48 +531,19 @@ Zotero.Integration.SOAP = new function() {
}
/*
* a class to keep track of citation objects in a document
* keeps track of all session-specific variables
*/
Zotero.Integration.Citation = function(index, field) {
}
/*
* generates a new field name based on available information
*/
Zotero.Integration.Citation.prototype.regenerateFieldName = function() {
this.field = this.itemIDString+"_"+this.locatorString+"_"+Zotero.randomString();
Zotero.Integration.Session = function() {
// holds items not in document that should be in bibliography
this.uncitedItems = new Object();
this.resetRequest();
}
/*
* updates itemIDString and locatorString based on data
* changes the Session style
*/
Zotero.Integration.Citation.prototype.setData = function(itemIDs, locators, locatorTypes) {
this.itemIDs = itemIDs;
this.itemIDString = itemIDs.join("|");
this.locators = locators;
this.locatorTypes = locatorTypes;
this.locatorString = "";
for(var i in locators) {
this.locatorString += "|"+locatorTypes[i]+locators[i].replace("|", "");
}
if(this.locatorString) this.locatorString = this.locatorString.substr(1);
this.serialization = this.itemIDString+"_"+this.locatorString;
}
/*
* loads locators from locatorString, if not already loaded
*/
Zotero.Integration.Citation.prototype.loadLocators = function() {
if(this.locators) return;
}
/*
* a class to complement Zotero.Integration.Citation, to keep track of the
* order of citations
*/
Zotero.Integration.Session = function(styleID, useEndnotes, useBookmarks) {
Zotero.Integration.Session.prototype.setStyle = function(styleID, useEndnotes, useBookmarks) {
this.styleID = styleID;
this.style = Zotero.Cite.getStyle(styleID);
this.useEndnotes = useEndnotes;
@ -558,19 +553,20 @@ Zotero.Integration.Session = function(styleID, useEndnotes, useBookmarks) {
this.dateModified = new Object();
this.itemSetIsSorted = true;
this.reset();
this.loadUncitedItems();
}
/*
* resets per-request variables in the CitationSet
*/
Zotero.Integration.Session.prototype.reset = function() {
Zotero.Integration.Session.prototype.resetRequest = function() {
this.citationsByItemID = new Object();
this.citationsByIndex = new Array();
this.itemSetHasChanged = false;
this.documentDataHasChanged = false;
this.updateItemIDs = new Object();
this.updateIndices = new Object();
this.updateIndices = new Object()
}
/*
@ -689,11 +685,11 @@ Zotero.Integration.Session.prototype.completeCitation = function(object) {
* unserializes a JSON citation into a citation object (sans items)
*/
Zotero.Integration.Session.prototype.unserializeCitation = function(arg) {
if(arg[0] == "{") {
if(arg[0] == "{") { // JSON field
// create citation
var citation = this.style.createCitation();
// JSON args
// get JSON
var object = Zotero.JSON.unserialize(arg);
// copy properties
@ -704,8 +700,7 @@ Zotero.Integration.Session.prototype.unserializeCitation = function(arg) {
citation[i] = object[i];
}
}
} else {
// ye olde style args
} else { // ye olde style field
var underscoreIndex = arg.indexOf("_");
var itemIDs = arg.substr(0, underscoreIndex).split("|");
@ -754,6 +749,10 @@ Zotero.Integration.Session.prototype.previewCitation = function(citation) {
this.getCitationPositions(citation);
// sort item set
this.sortItemSet();
// sort citation if desired
if(citation.properties.sort) {
citation.sort();
}
// get preview citation
var text = this.style.formatCitation(citation, "Integration");
// delete from item set
@ -809,9 +808,16 @@ Zotero.Integration.Session.prototype.getCitationPositions = function(citation, u
var previousCitation = (previousIndex == -1 ? false : this.citationsByIndex[previousIndex]);
// if only one source, and it's the same as the last, use ibid
if(previousCitation && citation.citationItems.length == 1
if( // there must be a previous citation with one item, and this citation
// may only have one item
previousCitation && citation.citationItems.length == 1
&& previousCitation.citationItems.length == 1
&& citation.citationItems[0].item == previousCitation.citationItems[0].item) {
// the previous citation must have been a citation of the same item
&& citation.citationItems[0].item == previousCitation.citationItems[0].item
// and if the previous citation had a locator (page number, etc.)
// then this citation must have a locator, or else we should do the
// full citation (see Chicago Manual of Style)
&& (!previousCitation.citationItems[0].locator || citation.citationItems[0].locator)) {
// use ibid, but check whether to use ibid+pages
var newPosition = (citation.citationItems[0].locator == previousCitation.citationItems[0].locator
&& citation.citationItems[0].locatorType == previousCitation.citationItems[0].locatorType
@ -854,7 +860,7 @@ Zotero.Integration.Session.prototype.updateCitations = function(toIndex) {
/*
* updates the ItemSet, adding and deleting bibliography items as appropriate,
* then resorting
* then re-sorting
*/
Zotero.Integration.Session.prototype.updateItemSet = function() {
var addItems = [];
@ -864,11 +870,13 @@ Zotero.Integration.Session.prototype.updateItemSet = function() {
// see if items were deleted from Zotero
if (!Zotero.Items.get(i)) {
deleteItems.push(itemID);
if(this.citationsByItemID[i].length) {
for(var j=0; j<this.citationsByItemID[i].length; j++) {
var citation = this.citationsByItemID[i][j];
this.updateIndices[citation.properties.index] = true;
citation.properties.delete = true;
}
}
this.itemSetChanged();
}
}
@ -878,7 +886,7 @@ Zotero.Integration.Session.prototype.updateItemSet = function() {
var itemID = item.getID();
// see if items were removed
if(!this.citationsByItemID[itemID]) {
if(!this.citationsByItemID[itemID] && !this.uncitedItems[itemID]) {
deleteItems.push(itemID);
this.itemSetChanged();
continue;
@ -925,6 +933,23 @@ Zotero.Integration.Session.prototype.itemSetChanged = function() {
this.itemSetHasChanged = true;
}
/*
* edits integration bibliography
*/
Zotero.Integration.Session.prototype.editBibliography = function() {
var bibliographyEditor = new Zotero.Integration.Session.BibliographyEditInterface(this);
var io = new function() { this.wrappedJSObject = bibliographyEditor; }
this.documentDataHasChanged = true;
this.itemSetHasChanged = true;
Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher)
.openWindow(null, 'chrome://zotero/content/editBibliographyDialog.xul', '',
'chrome,modal'+(Zotero.isWin ? ',popup' : ''), io, true);
}
/*
* gets integration bibliography
*/
@ -978,3 +1003,123 @@ Zotero.Integration.Session.prototype.getCitations = function(regenerateAll) {
return output;
}
/*
* loads document data from a JSON object
*/
Zotero.Integration.Session.prototype.loadDocumentData = function(json) {
var documentData = Zotero.JSON.unserialize(json);
// set uncited
if(documentData.uncited) {
this.uncitedItems = documentData.uncited;
this.loadUncitedItems();
} else {
this.uncitedItems = new Object();
}
// set custom bibliography entries
if(documentData.custom) {
for(var itemID in documentData.custom) {
Zotero.debug("getting item "+itemID);
var item = this.itemSet.getItemsByIds([itemID])[0];
Zotero.debug(item.toSource());
item.setProperty("bibliography-Integration", documentData.custom[itemID]);
}
}
}
/*
* adds items in this.uncitedItems to itemSet, if they are not already there
*/
Zotero.Integration.Session.prototype.loadUncitedItems = function() {
for(var itemID in this.uncitedItems) {
// skip "undefined"
if(!this.uncitedItems[itemID]) continue;
// if not yet in item set, add to item set
var item = this.itemSet.getItemsByIds([itemID])[0];
if(!item) this.itemSet.add([itemID])[0];
}
}
/*
* saves document data from a JSON object
*/
Zotero.Integration.Session.prototype.getDocumentData = function() {
var documentData = {};
// add uncited if there is anything
for(var item in this.uncitedItems) {
documentData.uncited = this.uncitedItems;
break;
}
// look for custom bibliography entries
if(this.itemSet.items.length) {
for(var i=0; i<this.itemSet.items.length; i++) {
var custom = this.itemSet.items[i].getProperty("bibliography-Integration");
if(custom !== "") {
var itemID = this.itemSet.items[i].getID();
if(!documentData.custom) documentData.custom = {};
documentData.custom[itemID] = custom;
}
}
}
if(documentData.uncited || documentData.custom) {
return Zotero.JSON.serialize(documentData);
} else {
return "X"; // nothing
}
}
/*
* Interface for bibliography editor
*/
Zotero.Integration.Session.BibliographyEditInterface = function(session) {
this.session = session;
}
Zotero.Integration.Session.BibliographyEditInterface.prototype.getItemSet = function() {
return this.session.itemSet;
}
Zotero.Integration.Session.BibliographyEditInterface.prototype.isCited = function(item) {
if(this.session.citationsByItemID[item.getID()]) return true;
return false;
}
Zotero.Integration.Session.BibliographyEditInterface.prototype.add = function(item) {
// create new item
this.session.itemSet.add([item]);
this.session.uncitedItems[item.getID()] = true;
this.session.itemSetChanged();
this.session.sortItemSet();
}
Zotero.Integration.Session.BibliographyEditInterface.prototype.remove = function(item) {
// create new item
this.session.itemSet.remove([item]);
this.session.itemSetChanged();
this.session.sortItemSet();
// delete citations if necessary
var itemID = item.getID();
if(this.session.citationsByItemID[itemID]) {
for(var j=0; j<this.session.citationsByItemID[itemID].length; j++) {
var citation = this.session.citationsByItemID[itemID][j];
this.session.updateIndices[citation.properties.index] = true;
citation.properties.delete = true;
}
}
// delete uncited if neceessary
if(this.session.uncitedItems[itemID]) this.session.uncitedItems[itemID] = undefined;
}
Zotero.Integration.Session.BibliographyEditInterface.prototype.preview = function(item) {
var itemSet = this.session.style.createItemSet([item]);
return this.session.style.formatBibliography(itemSet, "Integration");
}

View File

@ -7,12 +7,48 @@
<term name="retrieved">retrieved</term>
<term name="from">from</term>
<term name="forthcoming">forthcoming</term>
<term name="references">References</term>
<term name="references">references</term>
<term name="no date">n.d.</term>
<term name="and">and</term>
<term name="et-al">et al.</term>
<!-- LONG LOCATOR FORMS -->
<term name="book">
<single>book</single>
<multiple>books</multiple>
</term>
<term name="chapter">
<single>chapter</single>
<multiple>chapters</multiple>
</term>
<term name="column">
<single>column</single>
<multiple>columns</multiple>
</term>
<term name="figure">
<single>figure</single>
<multiple>figures</multiple>
</term>
<term name="folio">
<single>folio</single>
<multiple>folios</multiple>
</term>
<term name="issue">
<single>number</single>
<multiple>numbers</multiple>
</term>
<term name="line">
<single>line</single>
<multiple>lines</multiple>
</term>
<term name="note">
<single>note</single>
<multiple>notes</multiple>
</term>
<term name="opus">
<single>opus</single>
<multiple>opera</multiple>
</term>
<term name="page">
<single>page</single>
<multiple>pages</multiple>
@ -21,28 +57,53 @@
<single>paragraph</single>
<multiple>paragraph</multiple>
</term>
<term name="line">
<single>line</single>
<multiple>line</multiple>
<term name="part">
<single>part</single>
<multiple>parts</multiple>
</term>
<term name="section">
<single>section</single>
<multiple>sections</multiple>
</term>
<term name="volume">
<single>volume</single>
<multiple>volumes</multiple>
</term>
<term name="verse">
<single>verse</single>
<multiple>verses</multiple>
</term>
<term name="volume">volume</term>
<term name="issue">number</term>
<!-- SHORT LOCATOR FORMS -->
<term name="book" form="short">bk</term>
<term name="chapter" form="short">chap</term>
<term name="column" form="short">col</term>
<term name="figure" form="short">fig</term>
<term name="folio" form="short">f</term>
<term name="issue" form="short">no</term>
<term name="opus" form="short">op</term>
<term name="page" form="short">
<single>p</single>
<multiple>pp</multiple>
</term>
<term name="paragraph" form="short">
<term name="paragraph" form="short">para</term>
<term name="part" form="short">pt</term>
<term name="section" form="short">sec</term>
<term name="verse" form="short">
<single>v</single>
<multiple>vv</multiple>
</term>
<term name="volume" form="short">vol</term>
<!-- SYMBOL LOCATOR FORMS -->
<term name="paragraph" form="symbol">
<single></single>
<multiple>¶¶</multiple>
</term>
<term name="line" form="short">
<single>line</single>
<multiple>line</multiple>
<term name="section" form="symbol">
<single>§</single>
<multiple>§§</multiple>
</term>
<term name="volume" form="short">vol</term>
<term name="issue" form="short">no</term>
<!-- LONG ROLE FORMS -->
<term name="editor">
@ -91,7 +152,6 @@
<term name="month-02" form="short">Feb</term>
<term name="month-03" form="short">Mar</term>
<term name="month-04" form="short">Apr</term>
<term name="month-05" form="short">May</term>
<term name="month-06" form="short">Jun</term>
<term name="month-07" form="short">Jul</term>
<term name="month-08" form="short">Aug</term>

View File

@ -110,6 +110,7 @@
<!ENTITY zotero.integration.docPrefs.title "Document Preferences">
<!ENTITY zotero.integration.addEditCitation.title "Add/Edit Citation">
<!ENTITY zotero.integration.editBibliography.title "Edit Bibliography">
<!ENTITY zotero.progress.title "Progress">
@ -143,3 +144,5 @@
<!ENTITY zotero.integration.prefs.formatUsing.label "Format Using:">
<!ENTITY zotero.integration.prefs.bookmarks.label "Bookmarks">
<!ENTITY zotero.integration.prefs.bookmarks.caption "Bookmarks are preserved across Microsoft Word and OpenOffice.org, but may be accidentally modified.">
<!ENTITY zotero.integration.references.label "References in Bibliography">

View File

@ -460,3 +460,6 @@ integration.referenceMarks.caption = OpenOffice.org ReferenceMarks are less like
integration.regenerate.title = Do you want to regenerate the citation?
integration.regenerate.body = The changes you have made in the citation editor will be lost.
integration.regenerate.saveBehavior = Always follow this selection.
integration.deleteCitedItem.title = Are you sure you want to remove this reference?
integration.deleteCitedItem.body = This reference is cited in the text of your document. Deleting it will remove all citations.

View File

@ -1,19 +1,26 @@
#citation-add {
#add {
list-style-image: url('chrome://zotero/skin/citation-add.png');
}
#citation-add[disabled="true"] {
#add[disabled="true"] {
list-style-image: url('chrome://zotero/skin/citation-add-gray.png');
}
#citation-delete {
#remove {
list-style-image: url('chrome://zotero/skin/citation-delete.png');
}
#citation-delete[disabled="true"] {
#remove[disabled="true"] {
list-style-image: url('chrome://zotero/skin/citation-delete-gray.png');
}
#add .toolbarbutton-text, #remove .toolbarbutton-text
{
margin: 0 !important;
padding: 0 !important;
}
#prefix, #suffix {
width: 200px;
}

View File

@ -22,8 +22,7 @@
-- Set the following timestamp to the most recent scraper update date
REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2007-09-13 12:00:00'));
REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2007-09-13 20:50:16'));
REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b4.r1', '', '2007-06-21 20:00:00', '1', '100', '4', 'Amazon.com', 'Sean Takats', '^https?://(?:www\.)?amazon',
'function detectWeb(doc, url) {
@ -12583,7 +12582,7 @@ function doSearch(item) {
}');
REPLACE INTO translators VALUES ('11645bd1-0420-45c1-badb-53fb41eeb753', '1.0.0b3.r1', '', '2006-11-27 22:45:00', 1, 100, 8, 'CrossRef', 'Simon Kornblith', 'http://partneraccess.oclc.org/',
REPLACE INTO translators VALUES ('11645bd1-0420-45c1-badb-53fb41eeb753', '1.0.0b3.r1', '', '2007-09-13 20:50:16', 1, 100, 8, 'CrossRef', 'Simon Kornblith', 'http://partneraccess.oclc.org/',
'function detectSearch(item) {
if(item.itemType == "journalArticle") {
return true;
@ -12637,6 +12636,7 @@ REPLACE INTO translators VALUES ('11645bd1-0420-45c1-badb-53fb41eeb753', '1.0.0b
item.edition = query.qr::edition_number.text().toString();
// get first page
item.pages = query.qr::first_page.text().toString();
item.complete();
return true;
}
@ -12651,7 +12651,7 @@ function doSearch(item) {
var co = Zotero.Utilities.createContextObject(item);
}
Zotero.Utilities.HTTP.doGet("http://www.crossref.org/openurl/?"+co+"&noredirect=true", function(responseText) {
Zotero.Utilities.HTTP.doGet("http://www.crossref.org/openurl?pid=zter:zter321&"+co+"&noredirect=true", function(responseText) {
processCrossRef(responseText);
Zotero.done();
});
@ -16325,8 +16325,9 @@ function doExport() {
}
}');
REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-08-28 16:45:48', 'American Psychological Association',
'<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" xml:lang="en">
REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-09-13 20:50:16', 'American Psychological Association',
'<?oxygen RNGSchema="csl.rnc" type="compact"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" xml:lang="en">
<info>
<title>American Psychological Association</title>
<id>http://purl.org/net/xbiblio/csl/styles/apa.csl</id>
@ -16337,7 +16338,8 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
</author>
<category term="psychology"/>
<category term="generic-base"/>
<updated>2007-08-14T17:41:10+00:00</updated>
<category term="author-date"/>
<updated>2007-09-06T06:36:07+00:00</updated>
</info>
<macro name="editor-translator">
<names variable="editor translator" prefix="(" suffix=")" delimiter=", ">
@ -16391,10 +16393,10 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
<macro name="title">
<choose>
<if type="book">
<text variable="title" font-style="italic"/>
<text variable="title" enforce-case="sentence" font-style="italic"/>
</if>
<else>
<text variable="title"/>
<text variable="title" enforce-case="sentence"/>
</else>
</choose>
</macro>
@ -16405,14 +16407,18 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
</group>
</macro>
<citation>
<option name="sort-algorithm" value="author-date"/>
<option name="et-al-min" value="6"/>
<option name="et-al-use-first" value="6"/>
<option name="et-al-subsequent-min" value="6"/>
<option name="et-al-use-first" value="1"/>
<option name="et-al-subsequent-min" value="3"/>
<option name="et-al-subsequent-use-first" value="1"/>
<option name="disambiguate-add-year-suffix" value="true"/>
<option name="disambiguate-add-names" value="true"/>
<option name="disambiguate-add-givenname" value="true"/>
<option name="collapse" value="year"/>
<sort>
<key macro="author"/>
<key variable="issued"/>
</sort>
<layout prefix="(" suffix=")" delimiter="; ">
<group delimiter=", ">
<text macro="author-short"/>
@ -16420,7 +16426,7 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
<date-part name="year"/>
</date>
<group>
<label variable="locator" suffix="." form="short"/>
<label variable="locator" include-period="true" form="short"/>
<text variable="locator" prefix=" "/>
</group>
</group>
@ -16428,9 +16434,12 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
</citation>
<bibliography>
<option name="hanging-indent" value="true"/>
<option name="sort-algorithm" value="author-date"/>
<option name="et-al-min" value="6"/>
<option name="et-al-use-first" value="6"/>
<sort>
<key macro="author"/>
<key variable="issued"/>
</sort>
<layout>
<text macro="author" suffix="."/>
<date variable="issued" prefix=" (" suffix=").">
@ -16448,20 +16457,22 @@ REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-
<text macro="title" prefix=" "/>
<group class="container" prefix=". ">
<text term="in" text-transform="capitalize"/>
<names variable="editor translator" prefix=" " suffix="," delimiter=", ">
<group delimiter=", " suffix=".">
<names variable="editor translator" prefix=" " delimiter=", ">
<name and="symbol" sort-separator=", " initialize-with=". "/>
<label form="short" prefix=" (" suffix=".)" text-transform="capitalize"/>
</names>
<text variable="container-title" font-style="italic" prefix=" " suffix="."/>
<text variable="collection-title" prefix=" " suffix="."/>
<group suffix=".">
<text macro="publisher" prefix=" "/>
<group delimiter=" ">
<text variable="container-title" font-style="italic"/>
<group prefix="(" suffix=")">
<label variable="page" form="short" suffix=". "/>
<label variable="page" form="short" include-period="true" suffix=" "/>
<text variable="page"/>
</group>
</group>
</group>
<text variable="collection-title" prefix=" " suffix="."/>
<text macro="publisher" prefix=" " suffix="."/>
</group>
</else-if>
<else>
<group suffix=".">
@ -17007,133 +17018,171 @@ REPLACE INTO csl VALUES('http://www.zotero.org/namespaces/CSL/chicago-note-bibli
</bibliography>
</style>');
REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/mla.csl', '2007-08-28 16:45:48', 'Modern Language Association',
'<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="../schema/trunk/csl.rnc" type="compact"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="author" xml:lang="en">
REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/mla.csl', '2007-09-13 20:50:16', 'Modern Language Association',
'<?oxygen RNGSchema="csl.rnc" type="compact"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" xml:lang="en">
<info>
<title>Modern Language Association</title>
<id>http://purl.org/net/xbiblio/csl/styles/mla.csl</id>
<link>http://purl.org/net/xbiblio/csl/styles/mla.csl</link>
<author>
<name>Bruce DArcus</name>
<email>bdarcus@sourceforge.net</email>
</author>
<contributor>
<name>Johan Kool</name>
<email>johankool@users.sourceforge.net</email>
</contributor>
<contributor>
<name>Simon Kornblith</name>
<email>simon@simonster.com</email>
</contributor>
<updated>2006-09-04T20:28:00+05:00</updated>
</author>
<category term="generic-base"/>
<updated>2007-08-14T17:41:10+00:00</updated>
</info>
<defaults>
<contributor name-as-sort-order="first">
<name and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
<macro name="editor-translator">
<names variable="editor translator" prefix="(" suffix=")" delimiter=". ">
<label form="verb-short" text-transform="capitalize" suffix=". "/>
<name and="symbol" delimiter=", "/>
</names>
</macro>
<macro name="author">
<names variable="author">
<name name-as-sort-order="first" and="text" sort-separator=", "
delimiter=", " delimiter-precedes-last="always"/>
<label form="short" prefix=", " suffix="."/>
</contributor>
<author>
<substitute>
<choose>
<editor/>
<titles/>
</choose>
<names variable="editor"/>
<names variable="translator"/>
<text macro="title"/>
</substitute>
</author>
<locator>
<number/>
</locator>
<titles>
<title/>
</titles>
<date>
<year/>
</names>
</macro>
<macro name="author-short">
<names variable="author">
<name form="short" and="symbol" delimiter=", " initialize-with=". "/>
<substitute>
<names variable="editor"/>
<names variable="translator"/>
<text macro="title-short"/>
</substitute>
</names>
</macro>
<macro name="access">
<group>
<text term="retrieved" text-transform="capitalize" suffix=" "/>
<date variable="accessed" suffix=", ">
<date-part name="month" suffix=" "/>
<date-part name="day" suffix=", "/>
<date-part name="year"/>
</date>
<access>
<date>
<day suffix=" "/>
<month suffix=" "/>
<year/>
</date>
<url prefix=" &lt;" suffix="&gt;"/>
</access>
</defaults>
<citation prefix="(" suffix=")" delimiter="; ">
<et-al min-authors="6" use-first="6" position="first"/>
<et-al min-authors="6" use-first="1" position="subsequent"/>
<layout>
<item>
<group delimiter=" ">
<author form="short">
<name and="text" sort-separator=", " delimiter=", "/>
</author>
<locator prefix=" "/>
<group>
<text term="from" suffix=" "/>
<text variable="URL"/>
</group>
</group>
</macro>
<macro name="title">
<choose>
<if type="book">
<text variable="title" text-decoration="underline"/>
</if>
<else>
<text variable="title" quotes="true"/>
</else>
</choose>
</macro>
<macro name="title-short">
<choose>
<if type="book">
<text variable="title" form="short" text-decoration="underline"/>
</if>
<else>
<text variable="title" form="short" quotes="true"/>
</else>
</choose>
</macro>
<macro name="publisher-year">
<group delimiter=", ">
<group delimiter=": ">
<text variable="publisher-place"/>
<text variable="publisher"/>
</group>
<date variable="issued">
<date-part name="year"/>
</date>
</group>
</macro>
<citation>
<option name="et-al-min" value="4"/>
<option name="et-al-use-first" value="1"/>
<option name="disambiguate-add-names" value="true"/>
<option name="disambiguate-add-givenname" value="true"/>
<layout prefix="(" suffix=")" delimiter="; ">
<group delimiter=" ">
<choose>
<if variable="author editor translator" match="any">
<text macro="author-short"/>
<choose>
<if disambiguate="true">
<text macro="title-short" prefix=", "/>
</if>
</choose>
</if>
<else>
<text macro="title-short"/>
</else>
</choose>
<text variable="locator"/>
</group>
</item>
</layout>
</citation>
<bibliography subsequent-author-substitute="---">
<sort algorithm="author-date"/>
<et-al min-authors="4" use-first="1"/>
<bibliography>
<option name="hanging-indent" value="true"/>
<option name="et-al-min" value="4"/>
<option name="et-al-use-first" value="1"/>
<sort>
<key macro="author"/>
<key variable="title"/>
</sort>
<layout>
<list>
<heading>
<text term-name="references"/>
</heading>
</list>
<item>
<text macro="author" suffix="."/>
<text macro="title" prefix=" " suffix="."/>
<choose>
<type name="book">
<author suffix="."/>
<titles font-style="italic" prefix=" " suffix="."/>
<group prefix=" " suffix="." delimiter=", ">
<edition/>
<group delimiter=": ">
<publisher><place/></publisher>
<publisher><name/></publisher>
</group>
<date/>
</group>
<access prefix=" " suffix="."/>
</type>
<type name="chapter">
<author suffix="."/>
<titles prefix=" &#8220;" suffix=".&#8221;"/>
<group class="container" prefix=" " suffix=".">
<titles relation="container" font-style="italic" suffix="."/>
<editor prefix=" " suffix=".">
<label form="short" suffix=". " text-transform="capitalize"/>
<name and="text" delimiter=", "/>
</editor>
<titles relation="collection" prefix=" " suffix="."/>
<group prefix=" " delimiter=": ">
<publisher><place/></publisher>
<publisher><name/></publisher>
</group>
<date prefix=", "/>
</group>
<pages prefix=" " suffix="."/>
<access prefix=" " suffix="."/>
</type>
<type name="article">
<author suffix="."/>
<titles prefix=" &#8220;" suffix=".&#8221;"/>
<if type="book">
<text macro="editor-translator" prefix=" " suffix="."/>
<text macro="publisher-year" prefix=" " suffix="."/>
</if>
<else-if type="chapter">
<group class="container">
<editor prefix=" " suffix="."/>
<titles relation="container" font-style="italic" prefix=" " suffix="."/>
<text variable="container-title" text-decoration="underline" prefix=" " suffix="."/>
<text macro="editor-translator" prefix=" " suffix="."/>
<text macro="publisher-year" prefix=" " suffix="."/>
</group>
<volume prefix=" "/>
<issue prefix="."/>
<group suffix=".">
<date prefix=" (" suffix=")"/>
<pages prefix=": "/>
<text variable="page" prefix=" " suffix="."/>
</else-if>
<else>
<group class="container" prefix=" " suffix="." delimiter=": ">
<group delimiter=" ">
<text variable="container-title" text-decoration="underline"/>
<choose>
<if type="article-journal">
<group delimiter=" ">
<group delimiter=".">
<text variable="volume"/>
<text variable="issue"/>
</group>
<access prefix=" " suffix="."/>
</type>
<date variable="issued" prefix="(" suffix=")">
<date-part name="year"/>
</date>
</group>
</if>
<else>
<date variable="issued">
<date-part name="day" suffix=" "/>
<date-part name="month" form="short" include-period="true" suffix=" "/>
<date-part name="year"/>
</date>
</else>
</choose>
</item>
</group>
<text variable="page"/>
</group>
</else>
</choose>
<text prefix=" " macro="access"/>
</layout>
</bibliography>
</style>');