Beispiel #1
0
    def update(self):
        super(FormatterHeaders, self).update()

        locale = self.request.locale
        configlet = getUtility(IFormatterConfiglet)
        timeformat = getattr(configlet, 'timeFormat', None)
        showSeconds = getattr(configlet, 'showSeconds', True)

        dt_formats = returnFormats(locale.dates, 'dateTime')

        gregorian = locale.dates.calendars.get('gregorian')
        month_names = gregorian.getMonthNames()
        day_names = gregorian.getDayNames()

        if gregorian.getDayTypeFromAbbreviation('Mon') == 1:
            day_names.insert(0, day_names[-1])
            del day_names[-1]

        d_formats = returnFormats(locale.dates, 'date')

        t_formats = returnFormats(locale.dates, 'time')

        if timeformat:
            dt_formats = replaceTimeFormat(dt_formats, timeformat, showSeconds)
            t_formats = replaceTimeFormat(t_formats, timeformat, showSeconds)

        includeInplaceSource(jssource % (dumps(dict(dt_formats)),
                                         dumps(dict(t_formats)),
                                         dumps(dict(d_formats)),
                                         dumps(month_names),
                                         dumps(day_names)
                                         ))
Beispiel #2
0
    def update(self):
        context = self.context
        request = self.request

        configlet = getUtility(IFormatterConfiglet)
        tz = timezone(configlet.timezone)
        if tz:
            # difference between timezone in user's browser and formatter settings
            timeZone = '(new Date().getTimezoneOffset() / 60 * -1) - %s'%timezoneToJs(tz)
        else:
            timeZone = str('new Date().getTimezoneOffset() / 60 * -1')

        calendarUrl = u'%s'%absoluteURL(context, request)
        readonly = self.checkEditing() and 'false' or 'true'
        includeInplaceSource(jssource%{
                'calendarUrl': calendarUrl,
                'readonly': readonly,
                'timezone': timeZone,
                }, ('jquery-wdcalendar', 'zojax-calendar-js',))

        catalog = getUtility(ICatalog)

        results = catalog.searchResults(
            traversablePath = {'any_of': (context,)})

        if not results:
            self.hasEvents = False
            return

        self.events = results
Beispiel #3
0
 def render(self):
     product = getUtility(ITwitterAuthenticationProduct)
     key = product.consumerKey
     secret = product.consumerSecret
     logged_in = False
     includeInplaceSource(script % dict(key=simplejson.dumps(key), secret=simplejson.dumps(secret), \
                                        logged_in=simplejson.dumps(logged_in)), ('zojax-crossposting',))
     return super(Headers, self).render()
    def update(self):
        super(GoogleFC, self).update()
        product = component.getUtility(IGoogleFCAuthenticationProduct)

        source = script % dict(siteId=product.siteId,
                               successURL='%s/login-success.html'%absoluteURL(getSite(), self.request))
        if source not in library.includes.sources:
            library.includeInplaceSource(source)
Beispiel #5
0
    def update(self):
        includeInplaceSource(jssource)
        request = self.request
        context = self.context

        context = IMembersAware(getSpace(context), None)
        if context is None:
            return

        notifications = []
        for name, notification in getAdapters((self.context,), IContentNotification):
            notifications.append((notification.title, name, notification))

        notifications.sort()
        self.notifications = [notification for title, name, notification
                              in notifications]
        members = []
        spaces = list(getUtility(ICatalog).searchResults(
            type={'any_of': ('content.space',)},
            traversablePath={'any_of': [context]}))

        spaces.append(context)
        for space in spaces:
            for member in space.members.values():
                principal = member.principal
                if principal is None or principal.id=='unknown':
                    continue
                title = member.title
                position = -1
                for pos, memb in enumerate(members):
                    if member.title in memb:
                        position = pos
                if position != -1:
                    members[position][1]['spaces'].append(space.title)
                else:
                    members.append((title, {'id': principal.id,
                                            'title': title,
                                            'spaces': [space.title]
                                            }))
        self.renderDict = self.createRenderDict(sorted(spaces, key=lambda sp: sp.title), members)
        self.members = [val[1] for val in members]
        if 'notifications.save' in request:
            checked = {}
            for id in request.get('notifications', ()):
                pid, nid = id.split(':', 1)
                data = checked.setdefault(nid, [])
                data.append(pid)

            for notification in self.notifications:
                data = checked.get(notification.type, [])
                for member in self.members:
                    if member['id'] in data:
                        notification.subscribe(member['id'])
                    else:
                        notification.unsubscribe(member['id'])

            IStatusMessage(request).add(
                _('Email notification subscriptions have been updated.'))
    def update(self):

        if IContentAcknowledgementAware.providedBy(self.context):

            includeInplaceSource(
                jssource % {
                    'uid': self.request.principal.id,
                    'oid': getUtility(IIntIds).getId(self.context)
                }, )
    def update(self):

        if IContentAcknowledgementAware.providedBy(self.context):

            includeInplaceSource(
                jssource % {
                    'uid': self.request.principal.id,
                    'oid': getUtility(IIntIds).getId(self.context)
                },)
Beispiel #8
0
 def update(self):
     base_resource_url = '%s/@@/jquery-uploadify/' % absoluteURL(getSite(), self.request)
     url = self.request.getURL()
     params = {
         'uploader_url': base_resource_url + 'uploadify.swf',
         'script_url': '%s/bulk-upload-process' % absoluteURL(self.context, self.request),
         'ticket': issueTicket(url),
         'button_text': translate(self.buttonText, context=self.request),
         'cancel_image_url': base_resource_url + 'cancel.png',
     }
     includeInplaceSource(INIT_TEMPLATE % params, ('jquery-uploadify',))
Beispiel #9
0
    def update(self):
        include('zojax.photoalbum')

        product = getUtility(IPhotoAlbumProduct)

        self.lightbox = product.lightbox
        if self.lightbox:
            try:
                self.context.listPhotos().next()
                includeInplaceSource(lightboxinit, required=('jquery-lightbox',))
            except:
                pass

        title, self.width, self.height = sizes['thumbnail']
        self.url = absoluteURL(self.context, self.request)
Beispiel #10
0
    def update(self):
        context, request = self.context, self.request

        configlet = getUtility(IFormatterConfiglet)
        tz = timezone(configlet.timezone)
        if tz:
            # difference between timezone in user's browser and formatter settings
            timeZone = '(new Date().getTimezoneOffset() / 60 * -1) - %s'%timezoneToJs(tz)
        else:
            timeZone = str('new Date().getTimezoneOffset() / 60 * -1')

        apiUrl = u'%s/CalendarAPI/'%absoluteURL(context, request)
        includeInplaceSource(jssource%{
                'apiUrl': apiUrl,
                'timezone': timeZone,
                }, ('jquery-wdcalendar', 'zojax-calendar-edit',))
Beispiel #11
0
    def render(self):
        if self.mode == interfaces.DISPLAY_MODE:
            self.value = date(*(time.strptime(self.value, '%m/%d/%y'))[0:3])
            return super(DateWidget, self).render()

        if not self.value and self.field.required:
            value = date.today().strftime('%m/%d/%y')
        else:
            value = self.value

        includeInplaceSource(jssource%{
                'id': self.id,
                'name': self.name,
                'value': value,
                'klass': self.klass,
                'format': 'm/d/y',
                }, ('extjs-widgets',))

        return super(DateWidget, self).render()
    def render(self):
        if self.mode == interfaces.DISPLAY_MODE:
            self.value = datetime.time(*(time.strptime(self.value, '%H:%M:%S'))[0:3])
            return super(TimeWidget, self).render()

        if not self.value and self.field.required:
            tz = ITZInfo(self.request, utc)
            dt = datetime.datetime.now(tz)
            value = dt.strftime('%H:%M:%S')
        else:
            value = self.value

        includeInplaceSource(jssource%{
                'id': self.id,
                'name': self.name,
                'value': value,
                'klass': self.klass,
                'format': 'H:i:s',
                }, ('extjs-widgets',))

        return super(TimeWidget, self).render()
    def render(self):
        component.getUtility(IGoogleMapConfiglet).includeJsSource()
        location = 'false'
        value = self.value
        if value:
            value = component.getMultiAdapter((self.field, self), interfaces.IDataConverter).toFieldValue(self.value).getValue()

        includeInplaceSource(jssource%{
                'id': self.id,
                'mapId': self.mapId,
                'addressId': self.addressId,
                'geocodeButtonId': self.geocodeButtonId,
                'name': self.name,
                'type': 'google.maps.MapTypeId.%s'%self.field.type,
                'klass': self.klass,
                'value': simplejson.dumps(value),
                'message': simplejson.dumps(translate(self.placeMessage)),
                'readonly': str(self.readonly \
                                or self.mode == interfaces.DISPLAY_MODE).lower(),
                }, ('googlemap-widgets',))

        return super(MapLocationWidget, self).render()
    def render(self):
        if self.mode == interfaces.DISPLAY_MODE:
            tz = ITZInfo(getRequest(), utc)
            self.value = datetime(
                tzinfo=tz, *(time.strptime(self.value, '%Y-%m-%d %H:%M'))[0:6])
            return super(DatetimeWidget, self).render()

        dates = self.request.locale.dates
        formatter = dates.getFormatter('dateTime', 'short')

        tformat = dates.getFormatter('time', 'short').getPattern()
        if tformat[-1] == 'a':
            tformat = 'g:i A'
        else:
            tformat = 'H:i'

        if len(self.value) > 16:
            self.value = self.value[:16]

        if self.value:
            value = self.value
        else:
            tz = ITZInfo(self.request, utc)
            dt = datetime.now(tz)
            # dt = dt.replace(minute=0, second=0, microsecond=0)
            value = dt.strftime('%Y-%m-%d %H:%M')

        includeInplaceSource(jssource%{
                'id': self.id,
                'name': self.name,
                'value': value,
                'klass': self.klass,
                'tformat': tformat,
                }, ('extjs-widgets',))

        return super(DatetimeWidget, self).render()
 def render(self):
     includeInplaceSource("<script type='text/javascript'>$(document).ready(makeOnline());$('#online_number').ready(getOnlineNumber('online_number'));</script>")
     return super(OnlineUsersPortlet, self).render()
Beispiel #16
0
 def render(self):
     product = self.product
     key = self.product.apiKey
     channel = '%s/xd_receiver.htm'%absoluteURL(getSite(), self.request)
     includeInplaceSource(script % dict(key=simplejson.dumps(key), channel=simplejson.dumps(channel)), ('zojax-crossposting',))
     return super(Headers, self).render()
Beispiel #17
0
 def update(self):
     super(RPXNow, self).update()
     product = component.getUtility(IRPXNowAuthenticationProduct)
     source = script
     if source not in library.includes.sources:
         library.includeInplaceSource(source)
 def render(self):
     if not self.request.has_key(self.configlet.cookie) and self.isAvailable():
         includeInplaceSource(jssource%self.configlet.cookie)
         return htmlcode % (self.configlet.color, self.configlet.message)
     return ''
 def includeJsSource(self):
     if not self.enabled:
         return
     source = mapsource % {}
     if source not in includes.sources:
         includeInplaceSource(source)
    def render(self):
        if self.mode == interfaces.DISPLAY_MODE:
            if IRichTextData.providedBy(self.value):
                self.value = removeAllProxies(self.value).cooked
            return super(ExtJSEditorWidget, self).render()

        if IRichTextData.providedBy(self.value):
            value = removeAllProxies(self.value).text
        else:
            value = unicode(self.value)

        url1 = url2 = mediaUrl1 = mediaUrl2 = contentUrl = ''
        site = getSite()
        ids = getUtility(IIntIds)
        siteUrl = absoluteURL(site, self.request)
        context = self.context
        contextId = ids.queryId(removeAllProxies(context))
        siteId = ids.queryId(removeAllProxies(site))
        
        if contextId and checkPermission('zojax.AddContentAttachment', context):
            url1 = '%s/@@content.attachments/%s/imageManagerAPI/'%(siteUrl, contextId)
            mediaUrl1 = '%s/@@content.attachments/%s/mediaManagerAPI/'%(siteUrl, contextId)
        
        space = IPersonalSpace(self.request.principal, None)
        if space is not None and checkPermission('zojax.AddContentAttachment', space):
            spaceId = ids.getId(space)
            url2 = '%s/@@content.attachments/%s/imageManagerAPI/'%(siteUrl, spaceId)
            mediaUrl2 = '%s/@@content.attachments/%s/mediaManagerAPI/'%(siteUrl, spaceId)
        
        if contextId:
            contentUrl = '%s/@@content.browser/%s/contentManagerAPI/'%(siteUrl, contextId)
        else:
            contentUrl = '%s/@@content.browser/%s/contentManagerAPI/'%(siteUrl, siteId)
        
        configlet = getUtility(IExtJsEditor)
        includeInplaceSource(jssource%{
                'id': self.id,
                'width': repr(self.style_width),
                'height': repr(self.style_height),
                'url1': url1,
                'url2': url2,
                'mediaConfig': simplejson.dumps(dict(mediaUrl1=mediaUrl1,
                                                     mediaUrl2=mediaUrl2,
                                                     kaltura=dict(partnerId=configlet.kalturaPartnerId,
                                                                  userSecret=configlet.kalturaUserSecret,
                                                                  adminSecret=configlet.kalturaAdminSecret,
                                                                  serviceUrl=configlet.kalturaServiceUrl,
                                                                  serviceBase=configlet.kalturaServiceBase,
                                                                  userId=configlet.kalturaUserId),
                                                     wistia = dict(mediaPath=configlet.wistiaApiProxyUrl),
                                                     youtube = dict()
                                                     )),
                'linkConfig': simplejson.dumps(dict(contentUrl=contentUrl, rootTitle=getattr(IItem(site, None),'title',''))),
                'autoUpload': str(configlet.autoUpload).lower(),
                'imgmax': dict(width=configlet.imageMaxWidth,
                               height=configlet.imageMaxHeight),
                }, ('extjs-widgets',))

        html = """<div><textarea id="%(id)s" name="%(name)s" class="%(klass)s"
style="height: %(height)spx; width: %(width)spx">%(value)s</textarea></div>"""%{
            'id': self.id,
            'name': self.name,
            'value': value.strip(),
            'klass': self.klass,
            'width': repr(self.style_width),
            'height': repr(self.style_height),
            }

        return html
Beispiel #21
0
def displayhtml(public_key):
    includeInplaceSource(
        "<script src='https://www.google.com/recaptcha/api.js'></script>")

    return '<div class="g-recaptcha" data-sitekey="%(PublicKey)s"></div>' % {
        'PublicKey': public_key, }