diff --git a/chrome/content/zotero/xpcom/cite.js b/chrome/content/zotero/xpcom/cite.js index cbf4fb14b..6da7e9fdb 100644 --- a/chrome/content/zotero/xpcom/cite.js +++ b/chrome/content/zotero/xpcom/cite.js @@ -495,6 +495,8 @@ Zotero.CSL.prototype._processElements = function(item, element, formattedString, if(variables[j] == "locator") { // special case for locator var text = locator; + } else if(variables[j] == "citation-number") { + var text = item.getProperty("citation-number"); } else { var text = item.getText(variables[j], form); } @@ -770,6 +772,11 @@ Zotero.CSL.Global = new function() { this.parseLocales = parseLocales; this.ns = "http://purl.org/net/xbiblio/csl"; + this.collation = Components.classes["@mozilla.org/intl/collation-factory;1"] + .getService(Components.interfaces.nsICollationFactory) + .CreateCollation(Components.classes["@mozilla.org/intl/nslocaleservice;1"] + .getService(Components.interfaces.nsILocaleService) + .getApplicationLocale()); /* * initializes CSL interpreter @@ -1192,12 +1199,6 @@ Zotero.CSL.Item.Name.prototype.getNameVariable = function(variable) { * in an item wrapper. */ Zotero.CSL.ItemSet = function(items, csl) { - var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"] - .getService(Components.interfaces.nsILocaleService); - var collationFactory = Components.classes["@mozilla.org/intl/collation-factory;1"] - .getService(Components.interfaces.nsICollationFactory); - this._collation = collationFactory.CreateCollation(localeService.getApplicationLocale()); - this.csl = csl; this.citation = csl._csl.citation; @@ -1211,6 +1212,8 @@ 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")); + this.items = []; this.itemsById = {}; @@ -1324,6 +1327,8 @@ Zotero.CSL.ItemSet.prototype.resort = function() { var lastItem = false; var lastNames = false; var lastYear = false; + var citationNumber = 1; + for(var i in this.items) { var item = this.items[i]; if(item == undefined) continue; @@ -1455,13 +1460,12 @@ Zotero.CSL.ItemSet.prototype.resort = function() { } } - if(this.options["subsequent-author-substitute"] && names && lastNames - && exactMatch) { - item.setProperty("subsequent-author-substitute", "1"); + if(this.options["subsequent-author-substitute"] && names + && exactMatch == 0) { + item.setProperty("subsequent-author-substitute", true); } - - item.setProperty("number", i+1); + item.setProperty("citation-number", citationNumber++); lastItem = item; lastNames = names; @@ -1507,37 +1511,18 @@ Zotero.CSL.ItemSet.prototype._compareItem = function(a, b) { // author if(this.bibliography.option.(@name == "sort-algorithm").@value == "author-date") { - var sortString = new Zotero.CSL.SortString(); - this.csl._processElements(a, this.csl._csl.macro.(@name == "author"), sortString); - sortA.push(sortString.get().toLowerCase()); + var sortA = new Zotero.CSL.SortString(); + this.csl._processElements(a, this.csl._csl.macro.(@name == "author"), sortA); var date = a.getDate("issued"); - if(date) sortA.push(date.getDateVariable("sort")); + if(date) sortA.append(date.getDateVariable("sort")); - sortString = new Zotero.CSL.SortString(); - this.csl._processElements(b, this.csl._csl.macro.(@name == "author"), sortString); - sortB.push(sortString.get().toLowerCase()); + var sortB = new Zotero.CSL.SortString(); + this.csl._processElements(b, this.csl._csl.macro.(@name == "author"), sortB); var date = b.getDate("issued"); - if(date) sortB.push(date.getDateVariable("sort")); - } - - var compareNum = Math.min(sortA.length, sortB.length); - for(i=0; i a) { + return -1; + } else { + return 1; + } + } + return cmp; + } + } else if(aIsString && !bIsString) { + var cmp = this.compare(b[0], a); + if(cmp == 0) { + return -1; // a before b + } + return cmp; + } else if(bIsString && !aIsString) { + var cmp = this.compare(b, a[0]); + if(cmp == 0) { + return 1; // b before a + } + return cmp; + } + + var maxLength = Math.min(b.length, a.length); + for(var i = 0; i < maxLength; i++) { + var cmp = this.compare(b[i], a[i]); + if(cmp != 0) { + return cmp; + } + } + + if(b.length > a.length) { + return -1; // a before b + } else if(b.length < a.length) { + return 1; // b before a + } + + return 0; } diff --git a/scrapers.sql b/scrapers.sql index 53f8a4f0c..97e630b8c 100644 --- a/scrapers.sql +++ b/scrapers.sql @@ -1,4 +1,4 @@ --- 254 +-- 255 -- ***** BEGIN LICENSE BLOCK ***** -- @@ -22,7 +22,7 @@ -- Set the following timestamp to the most recent scraper update date -REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2007-08-09 23:00:00')); +REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2007-08-14 09:06:19')); 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) { @@ -15601,7 +15601,7 @@ function doExport() { } }'); -REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-08-04 23:15:00', 'American Psychological Association', +REPLACE INTO csl VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2007-08-14 09:06:19', 'American Psychological Association', '