1.1 --- a/EventAggregatorSupport.py Sun Nov 18 19:22:17 2012 +0100
1.2 +++ b/EventAggregatorSupport.py Sun Nov 18 21:16:00 2012 +0100
1.3 @@ -1280,8 +1280,8 @@
1.4
1.5 def __init__(self, page, calendar_name, raw_calendar_start, raw_calendar_end,
1.6 original_calendar_start, original_calendar_end, calendar_start, calendar_end,
1.7 - first, last, category_names, remote_sources, template_name, parent_name, mode,
1.8 - resolution, name_usage, map_name):
1.9 + first, last, category_names, remote_sources, search_pattern, template_name,
1.10 + parent_name, mode, resolution, name_usage, map_name):
1.11
1.12 """
1.13 Initialise the view with the current 'page', a 'calendar_name' (which
1.14 @@ -1294,9 +1294,9 @@
1.15 navigation in the user interface), along with the 'first' and 'last'
1.16 months of event coverage.
1.17
1.18 - The additional 'category_names', 'remote_sources', 'template_name',
1.19 - 'parent_name' and 'mode' parameters are used to configure the links
1.20 - employed by the view.
1.21 + The additional 'category_names', 'remote_sources', 'search_pattern',
1.22 + 'template_name', 'parent_name' and 'mode' parameters are used to
1.23 + configure the links employed by the view.
1.24
1.25 The 'resolution' affects the view for certain modes and is also used to
1.26 parameterise links.
1.27 @@ -1323,8 +1323,11 @@
1.28 self.name_usage = name_usage
1.29 self.map_name = map_name
1.30
1.31 + # Search-related parameters for links.
1.32 +
1.33 self.category_name_parameters = "&".join([("category=%s" % name) for name in category_names])
1.34 self.remote_source_parameters = "&".join([("source=%s" % source) for source in remote_sources])
1.35 + self.search_pattern = search_pattern
1.36
1.37 # Calculate the duration in terms of the highest common unit of time.
1.38
1.39 @@ -1449,6 +1452,7 @@
1.40 ("template", self.template_name or ""),
1.41 ("names", self.name_usage),
1.42 ("map", self.map_name or ""),
1.43 + ("search", self.search_pattern or ""),
1.44 ]
1.45
1.46 url = self.page.url(self.page.request,
1.47 @@ -1557,9 +1561,10 @@
1.48
1.49 # Generate the links.
1.50
1.51 - download_dialogue_link = "action=EventAggregatorSummary&parent=%s&resolution=%s%s%s" % (
1.52 + download_dialogue_link = "action=EventAggregatorSummary&parent=%s&resolution=%s&search=%s%s%s" % (
1.53 self.parent_name or "",
1.54 self.resolution,
1.55 + self.search_pattern,
1.56 self.category_name_parameters and "&%s" % self.category_name_parameters,
1.57 self.remote_source_parameters and "&%s" % self.remote_source_parameters
1.58 )
1.59 @@ -3220,6 +3225,31 @@
1.60 </script>
1.61 """
1.62
1.63 +# Event selection from request parameters.
1.64 +
1.65 +def getEventsUsingParameters(category_names, search_pattern, remote_sources,
1.66 + calendar_start, calendar_end, resolution, request):
1.67 +
1.68 + "Get the events according to the resolution of the calendar."
1.69 +
1.70 + if search_pattern:
1.71 + results = getPagesForSearch(search_pattern, request)
1.72 + else:
1.73 + results = []
1.74 +
1.75 + results += getAllCategoryPages(category_names, request)
1.76 + pages = getPagesFromResults(results, request)
1.77 + events = getEventsFromResources(getEventPages(pages))
1.78 + events += getEventsFromResources(getEventResources(remote_sources, calendar_start, calendar_end, request))
1.79 + all_shown_events = getEventsInPeriod(events, getCalendarPeriod(calendar_start, calendar_end))
1.80 + earliest, latest = getEventLimits(all_shown_events)
1.81 +
1.82 + # Get a concrete period of time.
1.83 +
1.84 + first, last = getConcretePeriod(calendar_start, calendar_end, earliest, latest, resolution)
1.85 +
1.86 + return all_shown_events, first, last
1.87 +
1.88 # Event-only formatting.
1.89
1.90 def formatEvent(event, request, fmt, write=None):