From a2640a9b70955488f94a0c618198c9f84e9938d9 Mon Sep 17 00:00:00 2001 From: grob Date: Sat, 19 Apr 2008 09:57:57 +0000 Subject: [PATCH] added an optional name argument to Document.prototype.getFields() for retrieving all fields with the specified name --- helma/Search.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/helma/Search.js b/helma/Search.js index 2870e11b..7464200e 100644 --- a/helma/Search.js +++ b/helma/Search.js @@ -1159,16 +1159,23 @@ helma.Search.Document.prototype.getField = function(name) { }; /** - * Returns the fields of a document object. + * Returns the fields of a document object. If a name is passed as argument, + * this method returns only the fields with the given name + * @param {String} name Optional name of the fields to return * @returns An array containing all fields in this document object. * @type Array */ -helma.Search.Document.prototype.getFields = function() { - var fields = this.getDocument().getFields(); - var size = fields.size(); +helma.Search.Document.prototype.getFields = function(name) { + var fields; + if (name != null) { + fields = this.getDocument().getFields(name); + } else { + fields = this.getDocument().getFields().toArray(); + } + var size = fields.length; var result = new Array(size); for (var i=0; i