def getContentText(self):
     res = self.context.description or \
           getattr(self.context, 'text', self.context.description)
     if IRichTextData.providedBy(res):
         if not res.cooked:
             return self.context.description
         return res.cooked
     if res:
         return res
     return u''
 def getContentText(self):
     try:
         description = IItem(self.context).description
     except TypeError:
         description = ''
     res = description or \
           getattr(self.context, 'text', description)
     if IRichTextData.providedBy(res):
         if not res.cooked:
             return description
         return res.cooked
     if res:
         return res
     return u''
    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