closes #223, citing the same item multiple times should produce only one bibliography entry

This commit is contained in:
Simon Kornblith 2006-08-29 17:29:35 +00:00
parent bdebc8dffa
commit d8171f775c
3 changed files with 26 additions and 13 deletions

Binary file not shown.

View File

@ -108,9 +108,19 @@ CSL = function(csl) {
* set items - convert to array and pre-process
*/
CSL.prototype.setItems = function(items) {
// create a serialized string of all of the unique items
var serializedItemString = "";
this._items = items;
this._uniqueItems = new Array();
var existingItems = new Object();
for each(var item in items) {
serializedItemString += item.getID()+",";
var itemID = item.getID();
if(!existingItems[itemID]) {
existingItems[itemID] = true;
this._uniqueItems.push(item);
serializedItemString += itemID+",";
}
}
Scholar.debug("CSL: items set to "+serializedItemString);
@ -118,7 +128,6 @@ CSL.prototype.setItems = function(items) {
if(serializedItemString != this._serializedItemString) {
// only re-process if there are new items
this._serializedItemString = serializedItemString;
this._items = items;
this._preprocessItems();
}
}
@ -192,8 +201,8 @@ CSL.prototype.createBibliography = function(format) {
output += "\r\n";
}
for(var i in this._items) {
var item = this._items[i];
for(var i in this._uniqueItems) {
var item = this._uniqueItems[i];
var string = this._getCitation(item, format, this._bib);
@ -991,8 +1000,8 @@ CSL.prototype._lpad = function(string, pad, length) {
*/
CSL.prototype._preprocessItems = function() {
// get data necessary to generate citations before sorting
for(var i in this._items) {
var item = this._items[i];
for(var i in this._uniqueItems) {
var item = this._uniqueItems[i];
if(!item._csl) {
// namespace everything in item._csl so there's no chance of overlap
@ -1016,9 +1025,9 @@ CSL.prototype._preprocessItems = function() {
// sort by sort order
if(this._bib.sortOrder) {
Scholar.debug("CSL: sorting this._items");
Scholar.debug("CSL: sorting items");
var me = this;
this._items.sort(function(a, b) {
this._uniqueItems.sort(function(a, b) {
return me._compareItem(a, b);
});
}
@ -1027,8 +1036,8 @@ CSL.prototype._preprocessItems = function() {
var usedCitations = new Array();
var lastAuthor;
for(var i in this._items) {
var item = this._items[i];
for(var i in this._uniqueItems) {
var item = this._uniqueItems[i];
var author = this._getFieldValue("author",
this._getFieldDefaults("author"),

View File

@ -5930,15 +5930,19 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '200
<name>Simon Kornblith</name>
<email>simon@simonster.com</email>
</contributor>
<updated>2006-08-19T17:12:00-05:00</updated>
<contributor>
<name>Johan Kool</name>
<email>johankool@users.sourceforge.net</email>
</contributor>
<updated>2006-08-24T16:30:00+01:00</updated>
</info>
<defaults>
<contributor name-as-sort-order="no">
<name and="symbol" initialize-with="."/>
<name and="symbol" initialize-with="." delimiter=", "/>
<label term-set="roles-short" prefix=", " text-transform="capitalize" suffix="."/>
</contributor>
<author name-as-sort-order="all">
<name and="symbol" sort-separator=", " initialize-with="."/>
<name and="symbol" sort-separator=", " initialize-with="." delimiter=", "/>
<label term-set="roles-short" prefix=" (" suffix=".)" text-transform="capitalize"/>
<substitute>
<choose>