'
return s
def displayDrilldownExtraLabel(levelField, selectedFieldNames,
drilldownFieldNames, language, selectedFacets, sortKeys, total ):
previousUpField = ""
s = ''
upField = ""
if levelField == "drilldown.norm.date.decennium" and "drilldown.norm.date.centennium" in selectedFieldNames:
upField = "drilldown.norm.date.centennium"
elif levelField == "drilldown.norm.date.year" and "drilldown.norm.date.centennium" in selectedFieldNames:
upField = "drilldown.norm.date.centennium"
elif levelField == "drilldown.norm.date.year" and "drilldown.norm.date.decennium" in selectedFieldNames:
upField = "drilldown.norm.date.decennium"
elif levelField == "drilldown.norm.name.oneinitial" and "drilldown.norm.name.lastname" in selectedFieldNames:
upField = "drilldown.norm.name.lastname"
if upField:
for term in selectedFieldNames[upField]:
if not (upField == previousUpField):
label = drilldownFieldNames.get(upField, {'en':upField, 'nl':upField})[language]
s += displayLabel(label)
drilldownArgs = set(selectedFacets)
drilldownArgs.remove(upField + ":" + term)
query = createDrilldownQuery(drilldownArgs, sortKeys)
s += displayItem(query, term, True, upField, language, total)
previousUpField = upField
return s
def displayDrilldownFields(total, docset, arguments, language):
chooseFromTitle = websiteConfig.get('choosefrom')
selectedFacets = arguments.get('drilldown', [])
selectedFieldNames = {}
if selectedFacets:
for drilldownItem in selectedFacets:
fieldName, value = fieldAndTermSplit(drilldownItem)
if not fieldName in selectedFieldNames: selectedFieldNames[fieldName] = []
selectedFieldNames[fieldName].append(value)
yield '
'
yield '
' + chooseFromTitle +'
'
sortKeys = arguments.get('sortKeys', [''])[0]
if total < 500000:
####### TP: result set is not too large, multilevel results will be calculated
multilevelResults = any.multiLevelDrilldown(docset, ['date', 'author'])
for (fieldName, levelField), termCounts in multilevelResults:
yield displayDrilldownExtraLabel(levelField, selectedFieldNames, drilldownFieldNames,
language, selectedFacets, sortKeys, total)
label = drilldownFieldNames.get(levelField, {'en':levelField, 'nl':levelField})[language]
yield displayItemGroep(label, termCounts, selectedFacets, levelField, selectedFieldNames,
arguments, language, sortKeys)
fields = drilldownFields
else:
####### TP: result set is too large, only one level of the multilevel facests will be calculated.
fields = drilldownFieldsNoMultiLevel
drilldownResults = any.drilldown(docset, fields)
drilldownResultsAsDict = dict(drilldownResults)
for fieldName, number, sorted in fields:
termCounts = drilldownResultsAsDict.get(fieldName,[])
label = drilldownFieldNames.get(fieldName, {'en':fieldName, 'nl':fieldName})[language]
if termCounts == []:
continue
yield displayItemGroep(label, termCounts, selectedFacets, fieldName, selectedFieldNames, arguments, language, sortKeys)
yield """
%(space)s
%(space)s """ % {'space': space}
#def main(hits, httpQuery, arguments, path='', *args, **kwargs):
# anton: httpQuery mag waarschijnlijk wel helemaal weg
#
#def main(total, bitMatrixRow, httpQuery, arguments, path='', *args, **kwargs):
def main(total, docset, httpQuery, arguments, path='', *args, **kwargs):
language = path.startswith('/en/') and 'en' or 'nl'
websiteConfig.setDefaults(section='drilldown', language=language)
yield space + '
'
logger.debug('arguments:\n'+prpt.pformat(arguments))
selectedFacets = arguments.get('drilldown', [])
# selectedLabel= any.configuration().get('limitTo','Selected:')
selectedLabel= websiteConfig.get('limitTo',default='Selected:')
# next line results in: TypeError: not all arguments converted during string formatting
sortKeys = arguments.get('sortKeys', [''])[0]
if selectedFacets:
yield space + '
'
yield space + '
%s
' % selectedLabel
yield '\n
'
for drilldownItem in selectedFacets:
fieldName, value = fieldAndTermSplit(drilldownItem)
drilldownArgs = set(selectedFacets)
drilldownArgs.remove(drilldownItem)
label = drilldownFieldNames.get(fieldName, {'en':fieldName, 'nl':fieldName})[language]
query = createDrilldownQuery(drilldownArgs, sortKeys)
term = displayTerm(value, fieldName, language)
yield displayFilter(query, value, label, term)
yield """
%(space)s
%(space)s
%(space)s """ % {'space': space}
if total > 0:
yield displayDrilldownFields(total, docset, arguments, language)