Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes | Static Private Attributes
plone.app.portlets.portlets.calendar.Renderer Class Reference
Inheritance diagram for plone.app.portlets.portlets.calendar.Renderer:
Inheritance graph
[legend]
Collaboration diagram for plone.app.portlets.portlets.calendar.Renderer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def update
def render
def getEventsForCalendar
def getEventString
def getYearAndMonthToDisplay
def getPreviousMonth
def getNextMonth
def getWeekdays
def isToday
def getReviewStateString
def getQueryString
def available

Public Attributes

 calendar
 url_quote_plus
 now
 yearmonth
 year
 month
 showPrevMonth
 showNextMonth
 prevMonthMonth
 nextMonthMonth
 monthName
 context
 request
 view
 manager
 data

Static Public Attributes

 updated = False

Private Attributes

 _ts

Static Private Attributes

tuple _template = ViewPageTemplateFile('calendar.pt')

Detailed Description

Definition at line 75 of file calendar.py.


Constructor & Destructor Documentation

def plone.app.portlets.portlets.calendar.Renderer.__init__ (   self,
  context,
  request,
  view,
  manager,
  data 
)

Reimplemented from plone.app.portlets.portlets.base.Renderer.

Definition at line 80 of file calendar.py.

00080 
00081     def __init__(self, context, request, view, manager, data):
00082         base.Renderer.__init__(self, context, request, view, manager, data)
00083         self.updated = False

Here is the caller graph for this function:


Member Function Documentation

Definition at line 112 of file calendar.py.

00112 
00113     def getEventsForCalendar(self):
00114         context = aq_inner(self.context)
00115         year = self.year
00116         month = self.month
00117         weeks = self.calendar.getEventsForCalendar(month, year)
00118         for week in weeks:
00119             for day in week:
00120                 daynumber = day['day']
00121                 if daynumber == 0:
00122                     continue
00123                 day['is_today'] = self.isToday(daynumber)
00124                 if day['event']:
00125                     cur_date = DateTime(year, month, daynumber)
00126                     localized_date = [self._ts.ulocalized_time(cur_date, context=context, request=self.request)]
00127                     day['eventstring'] = '\n'.join(localized_date+[self.getEventString(e) for e in day['eventslist']])
00128                     day['date_string'] = '%s-%s-%s' % (year, month, daynumber)
00129 
00130         return weeks

Here is the call graph for this function:

Definition at line 131 of file calendar.py.

00131 
00132     def getEventString(self, event):
00133         start = event['start'] and ':'.join(event['start'].split(':')[:2]) or ''
00134         end = event['end'] and ':'.join(event['end'].split(':')[:2]) or ''
00135         title = safe_unicode(event['title']) or u'event'
00136 
00137         if start and end:
00138             eventstring = "%s-%s %s" % (start, end, title)
00139         elif start: # can assume not event['end']
00140             eventstring = "%s - %s" % (start, title)
00141         elif event['end']: # can assume not event['start']
00142             eventstring = "%s - %s" % (title, end)
00143         else: # can assume not event['start'] and not event['end']
00144             eventstring = title
00145 
00146         return eventstring

Here is the call graph for this function:

Here is the caller graph for this function:

def plone.app.portlets.portlets.calendar.Renderer.getNextMonth (   self,
  year,
  month 
)

Definition at line 187 of file calendar.py.

00187 
00188     def getNextMonth(self, year, month):
00189         if month==12:
00190             month, year = 1, year + 1
00191         else:
00192             month+=1
00193         return (year, month)

Definition at line 180 of file calendar.py.

00180 
00181     def getPreviousMonth(self, year, month):
00182         if month==0 or month==1:
00183             month, year = 12, year - 1
00184         else:
00185             month-=1
00186         return (year, month)

Definition at line 215 of file calendar.py.

00215 
00216     def getQueryString(self):
00217         request = self.request
00218         query_string = request.get('orig_query',
00219                                    request.get('QUERY_STRING', None))
00220         if len(query_string) == 0:
00221             query_string = ''
00222         else:
00223             query_string = '%s&' % query_string
00224         return query_string
00225 

Definition at line 211 of file calendar.py.

00211 
00212     def getReviewStateString(self):
00213         states = self.calendar.getCalendarStates()
00214         return ''.join(map(lambda x : 'review_state=%s&' % self.url_quote_plus(x), states))

Returns a list of Messages for the weekday names.

Definition at line 194 of file calendar.py.

00194 
00195     def getWeekdays(self):
00196         """Returns a list of Messages for the weekday names."""
00197         weekdays = []
00198         # list of ordered weekdays as numbers
00199         for day in self.calendar.getDayNumbers():
00200             weekdays.append(PLMF(self._ts.day_msgid(day, format='s'),
00201                                  default=self._ts.weekday_english(day, format='a')))
00202 
00203         return weekdays

Definition at line 147 of file calendar.py.

00147 
00148     def getYearAndMonthToDisplay(self):
00149         session = None
00150         request = self.request
00151 
00152         # First priority goes to the data in the REQUEST
00153         year = request.get('year', None)
00154         month = request.get('month', None)
00155 
00156         # Next get the data from the SESSION
00157         if self.calendar.getUseSession():
00158             session = request.get('SESSION', None)
00159             if session:
00160                 if not year:
00161                     year = session.get('calendar_year', None)
00162                 if not month:
00163                     month = session.get('calendar_month', None)
00164 
00165         # Last resort to today
00166         if not year:
00167             year = self.now[0]
00168         if not month:
00169             month = self.now[1]
00170 
00171         year, month = int(year), int(month)
00172 
00173         # Store the results in the session for next time
00174         if session:
00175             session.set('calendar_year', year)
00176             session.set('calendar_month', month)
00177 
00178         # Finally return the results
00179         return year, month

Returns True if the given day and the current month and year equals
   today, otherwise False.

Definition at line 204 of file calendar.py.

00204 
00205     def isToday(self, day):
00206         """Returns True if the given day and the current month and year equals
00207            today, otherwise False.
00208         """
00209         return self.now[2]==day and self.now[1]==self.month and \
00210                self.now[0]==self.year

Here is the caller graph for this function:

Reimplemented from plone.app.portlets.portlets.base.Renderer.

Definition at line 109 of file calendar.py.

00109 
00110     def render(self):
00111         return xhtml_compress(self._template())

Here is the call graph for this function:

Reimplemented from plone.app.portlets.portlets.base.Renderer.

Definition at line 84 of file calendar.py.

00084 
00085     def update(self):
00086         if self.updated:
00087             return
00088         self.updated = True
00089 
00090         context = aq_inner(self.context)
00091         self.calendar = getToolByName(context, 'portal_calendar')
00092         self._ts = getToolByName(context, 'translation_service')
00093         self.url_quote_plus = url_quote_plus
00094 
00095         self.now = localtime()
00096         self.yearmonth = yearmonth = self.getYearAndMonthToDisplay()
00097         self.year = year = yearmonth[0]
00098         self.month = month = yearmonth[1]
00099 
00100         self.showPrevMonth = yearmonth > (self.now[0]-1, self.now[1])
00101         self.showNextMonth = yearmonth < (self.now[0]+1, self.now[1])
00102 
00103         self.prevMonthYear, self.prevMonthMonth = self.getPreviousMonth(year, month)
00104         self.nextMonthYear, self.nextMonthMonth = self.getNextMonth(year, month)
00105 
00106         self.monthName = PLMF(self._ts.month_msgid(month),
00107                               default=self._ts.month_english(month))

Here is the caller graph for this function:


Member Data Documentation

tuple plone.app.portlets.portlets.calendar.Renderer._template = ViewPageTemplateFile('calendar.pt') [static, private]

Definition at line 77 of file calendar.py.

Definition at line 91 of file calendar.py.

Definition at line 90 of file calendar.py.

Reimplemented in plone.app.portlets.portlets.classic.Renderer.

Definition at line 75 of file base.py.

Reimplemented in plone.app.portlets.portlets.classic.Renderer.

Definition at line 80 of file base.py.

Definition at line 79 of file base.py.

Definition at line 97 of file calendar.py.

Definition at line 105 of file calendar.py.

Definition at line 103 of file calendar.py.

Definition at line 94 of file calendar.py.

Definition at line 102 of file calendar.py.

Definition at line 76 of file base.py.

Definition at line 100 of file calendar.py.

Definition at line 99 of file calendar.py.

Definition at line 78 of file calendar.py.

Definition at line 92 of file calendar.py.

Definition at line 77 of file base.py.

Definition at line 96 of file calendar.py.

Definition at line 95 of file calendar.py.


The documentation for this class was generated from the following file: