1.1 --- a/EventAggregatorSupport.py Wed Jan 30 18:46:41 2013 +0100
1.2 +++ b/EventAggregatorSupport.py Sat Feb 02 00:47:24 2013 +0100
1.3 @@ -54,6 +54,14 @@
1.4
1.5 # Utility functions.
1.6
1.7 +def to_plain_text(s, request):
1.8 +
1.9 + "Convert 's' to plain text."
1.10 +
1.11 + fmt = getFormatterClass(request, "plain")(request)
1.12 + fmt.setPage(request.page)
1.13 + return formatText(s, request, fmt)
1.14 +
1.15 def getLocationPosition(location, locations):
1.16
1.17 """
1.18 @@ -1507,19 +1515,22 @@
1.19 navigation_link)
1.20
1.21 def getFullDateLabel(self, date):
1.22 - page = self.page
1.23 - request = page.request
1.24 - return getFullDateLabel(request, date)
1.25 + return getFullDateLabel(self.page.request, date)
1.26
1.27 def getFullMonthLabel(self, year_month):
1.28 - page = self.page
1.29 - request = page.request
1.30 - return getFullMonthLabel(request, year_month)
1.31 + return getFullMonthLabel(self.page.request, year_month)
1.32
1.33 def getFullLabel(self, arg):
1.34 return self.resolution == "date" and self.getFullDateLabel(arg) or self.getFullMonthLabel(arg)
1.35
1.36 def _getCalendarPeriod(self, start_label, end_label, default_label):
1.37 +
1.38 + """
1.39 + Return a label describing a calendar period in terms of the given
1.40 + 'start_label' and 'end_label', with the 'default_label' being used where
1.41 + the supplied start and end labels fail to produce a meaningful label.
1.42 + """
1.43 +
1.44 output = []
1.45 append = output.append
1.46
1.47 @@ -2626,7 +2637,57 @@
1.48
1.49 return "".join(output)
1.50
1.51 + def writeMapMarker(self, marker_x, marker_y, map_x_scale, map_y_scale, location, events):
1.52 +
1.53 + "Put a marker on the map."
1.54 +
1.55 + page = self.page
1.56 + request = page.request
1.57 + fmt = request.formatter
1.58 +
1.59 + output = []
1.60 + append = output.append
1.61 +
1.62 + append(fmt.listitem(on=1, css_class="event-map-label"))
1.63 +
1.64 + # Have a positioned marker for the print mode.
1.65 +
1.66 + append(fmt.div(on=1, css_class="event-map-label-only",
1.67 + style="left:%dpx; top:%dpx; min-width:%dpx; min-height:%dpx") % (
1.68 + marker_x, marker_y, map_x_scale, map_y_scale))
1.69 + append(fmt.div(on=0))
1.70 +
1.71 + # Have a marker containing a pop-up when using the screen mode,
1.72 + # providing a normal block when using the print mode.
1.73 +
1.74 + append(fmt.div(on=1, css_class="event-map-label",
1.75 + style="left:%dpx; top:%dpx; min-width:%dpx; min-height:%dpx") % (
1.76 + marker_x, marker_y, map_x_scale, map_y_scale))
1.77 + append(fmt.div(on=1, css_class="event-map-details"))
1.78 + append(fmt.div(on=1, css_class="event-map-shadow"))
1.79 + append(fmt.div(on=1, css_class="event-map-location"))
1.80 +
1.81 + # The location may have been given as formatted text, but this will not
1.82 + # be usable in a heading, so it must be first converted to plain text.
1.83 +
1.84 + append(fmt.heading(on=1, depth=2))
1.85 + append(fmt.text(to_plain_text(location, request)))
1.86 + append(fmt.heading(on=0, depth=2))
1.87 +
1.88 + append(self.writeMapEventSummaries(events))
1.89 +
1.90 + append(fmt.div(on=0))
1.91 + append(fmt.div(on=0))
1.92 + append(fmt.div(on=0))
1.93 + append(fmt.div(on=0))
1.94 + append(fmt.listitem(on=0))
1.95 +
1.96 + return "".join(output)
1.97 +
1.98 def writeMapEventSummaries(self, events):
1.99 +
1.100 + "Write summaries of the given 'events' for the map."
1.101 +
1.102 page = self.page
1.103 request = page.request
1.104 fmt = request.formatter
1.105 @@ -2944,38 +3005,9 @@
1.106 map_x_scale, map_y_scale),
1.107 map_x_scale, map_y_scale)
1.108
1.109 - # Put a marker on the map.
1.110 -
1.111 - append(fmt.listitem(on=1, css_class="event-map-label"))
1.112 -
1.113 - # Have a positioned marker for the print mode.
1.114 -
1.115 - append(fmt.div(on=1, css_class="event-map-label-only",
1.116 - style="left:%dpx; top:%dpx; min-width:%dpx; min-height:%dpx") % (
1.117 - marker_x, marker_y, map_x_scale, map_y_scale))
1.118 - append(fmt.div(on=0))
1.119 -
1.120 - # Have a marker containing a pop-up when using the screen mode,
1.121 - # providing a normal block when using the print mode.
1.122 -
1.123 - append(fmt.div(on=1, css_class="event-map-label",
1.124 - style="left:%dpx; top:%dpx; min-width:%dpx; min-height:%dpx") % (
1.125 - marker_x, marker_y, map_x_scale, map_y_scale))
1.126 - append(fmt.div(on=1, css_class="event-map-details"))
1.127 - append(fmt.div(on=1, css_class="event-map-shadow"))
1.128 - append(fmt.div(on=1, css_class="event-map-location"))
1.129 -
1.130 - append(fmt.heading(on=1, depth=2))
1.131 - append(fmt.text(location))
1.132 - append(fmt.heading(on=0, depth=2))
1.133 -
1.134 - append(self.writeMapEventSummaries(events))
1.135 -
1.136 - append(fmt.div(on=0))
1.137 - append(fmt.div(on=0))
1.138 - append(fmt.div(on=0))
1.139 - append(fmt.div(on=0))
1.140 - append(fmt.listitem(on=0))
1.141 + # Add the map marker.
1.142 +
1.143 + append(self.writeMapMarker(marker_x, marker_y, map_x_scale, map_y_scale, location, events))
1.144
1.145 append(fmt.number_list(on=0))
1.146 append(fmt.div(on=0))