<%! import DateTime import time sx1=time.time() %> <%namespace file="/functions/partials" name="partials" import="*"/> <%namespace file="/functions/report_editor_util" name="report_editor_util" import="*"/> <%inherit file="site" /> <%def name="main_content()"> <% now = DateTime.DateTime() #site.REQUEST.set('_viewMode', 1) request = object.REQUEST filterquery = site.REQUEST['QUERY_STRING'] test = '' count=0 num_per_page = 20 items = [] ll = [] query = site.param('query', '', type="js") year = site.param('y', 0) fromyear = object.val('from-year') or '' showdate = int(object.val('showdate') or 0) if filterquery: hasrequest = 1 else: hasrequest = 0 try: year = int(year) except: year = 0 try: fromyear = int(fromyear) except: fromyear = 2016 fromyear = fromyear-1 path = '/customer/www/imr' basepath = '/customer/www' objpath = object.url(localized=False) path = basepath + objpath cat = '' #templates = ['report-article'] templates = ['report-article', 'report-file', 'article', 'feature-article', 'tema' ] querystring = {'path':path,'template':templates, 'lang':'en', 'sort_on':'inx_publishDate' , 'sort_order':'descending', 'count':3000 } if query: import re query = re.sub(u'[^0-9a-zæøå -]', '', query, flags=re.IGNORECASE) _query = query if len(query) > 4 and query.find(' and ') == -1 and query.find(' or ') == -1 and query.find('"') == -1 and query.find('*') == -1: _query = '*' + query + '*' if query: querystring['SearchableText'] = _query datestart = None dateend = None if year and isinstance(year, int): datestart = 0 dateend = 0 try: start = DateTime.DateTime('%s.%s.01' % (year, 01)) last = DateTime.DateTime('%s.%s.31 23:59' % (year, 12)) datestart = int(start.timeTime()) dateend = int(last.timeTime()) num_per_page = 20 start = int(site.param('start','0')) if datestart and dateend: querystring['inx_publishDate'] = {'query':[datestart, dateend], 'range':'min:max'} except: pass # url extension padd = '' if year: padd = '&query;=' + query + '&y;=' + str(year) else: padd = '&query;=' + query # pagination limit = 30 start = int(site.param('start','0')) list = [] templates_filter = "" for t in templates: templates_filter += '"%s"|' % t templates_filter = templates_filter[:-1] result = partials.fetchFromSphinx('@path=\"%s\" @template %s' % (path, templates_filter),\ start_lime_loopup=start,\ search_term = site.param('query', default='', type="js"),\ end_lime_loopup=start+limit,\ limit=5000,\ where=("datePublished > %s and datePublished < %s" % (datestart, dateend) ) if datestart and dateend else "" ) list = result["result"] lenlist = result["cnt_tot_results"] %> % if site.param('test') == '1': ${querystring} ${len(items)} ${len(_items)} ${object.absolute_url(True)} ${object.fallback('de')} % endif

${object.val('longtitle') or object.val('title')}

${object.val('abstract') or object.val('teaser')}

År

% for y in xrange(now.year(),fromyear, -1): % endfor
${object.val('filtertext')}

${site.i18n('site-result')}: ${query} %if lenlist < 1000: (${lenlist}) %endif %if lenlist > limit: ${site.i18n('site-showing')} ${start+1} - %if (start+limit) > lenlist: ${lenlist} %else: ${start+limit} %endif %endif

% if list:
%for idx, item in enumerate(list):
% if item.val('template') in ['report-article', 'report-file']: ${partials.renderListItemReport(item)} %else: ${partials.renderListItem(item,showdate, disable_image_lazyloading=len(list) <= 6 or idx < 6 )} %endif
%endfor
% endif
%if lenlist > limit:
${partials.renderPagination(object, lenlist, limit, padd=padd)}
%endif