From 957b220cd3cc0d04d9ac5fdd44ed8e73b1725aaa Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 11 Aug 2006 04:36:44 +0000 Subject: [PATCH] Closes #56, add "institution" field in creators table to deal with institutional authors - 'isInstitution' parameter added to Item.setCreator(), Creators.getID(), Creators.add() - 'isInstitution' property added to return from Creators.get() and Item.getCreator() var obj = Scholar.Items.getNewItemByType(1); obj.setField('title', 'Digital History for Dummies'); obj.setCreator(0, '', 'Center for History and New Media', 1, true); // true == institutional creator var id = obj.save(); Note: 'firstName' field is ignored when 'isInstitution' is true --- .../content/scholar/xpcom/data_access.js | 60 +++++++++++++------ .../content/scholar/xpcom/schema.js | 4 +- schema.sql | 33 +++++----- 3 files changed, 61 insertions(+), 36 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/xpcom/data_access.js b/chrome/chromeFiles/content/scholar/xpcom/data_access.js index 076b5cac9..1a4994f81 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/data_access.js +++ b/chrome/chromeFiles/content/scholar/xpcom/data_access.js @@ -223,7 +223,7 @@ Scholar.Item.prototype.getCreators = function(){ /* * Set or update the creator at the specified position */ -Scholar.Item.prototype.setCreator = function(orderIndex, firstName, lastName, creatorTypeID){ +Scholar.Item.prototype.setCreator = function(orderIndex, firstName, lastName, creatorTypeID, isInstitution){ if (this.getID() && !this._creatorsLoaded){ this._loadCreators(); } @@ -236,11 +236,14 @@ Scholar.Item.prototype.setCreator = function(orderIndex, firstName, lastName, cr lastName = ''; } + isInstitution = !!isInstitution; + // If creator at this position hasn't changed, cancel if (this._creators.has(orderIndex) && this._creators.get(orderIndex)['firstName']==firstName && this._creators.get(orderIndex)['lastName']==lastName && - this._creators.get(orderIndex)['creatorTypeID']==creatorTypeID){ + this._creators.get(orderIndex)['creatorTypeID']==creatorTypeID && + this._creators.get(orderIndex)['isInstitution']==isInstitution){ return false; } @@ -252,6 +255,7 @@ Scholar.Item.prototype.setCreator = function(orderIndex, firstName, lastName, cr creator['firstName'] = firstName; creator['lastName'] = lastName; creator['creatorTypeID'] = creatorTypeID; + creator['isInstitution'] = isInstitution; this._creators.set(orderIndex, creator); this._changedCreators.set(orderIndex); @@ -283,7 +287,7 @@ Scholar.Item.prototype.removeCreator = function(orderIndex){ } -Scholar.Item.prototype.creatorExists = function(firstName, lastName, creatorTypeID, skipIndex){ +Scholar.Item.prototype.creatorExists = function(firstName, lastName, creatorTypeID, isInstitution, skipIndex){ for (var j=0, len=this.numCreators(); j