Example #1
0
def print_value(value):
    from .labels import COMMON_LABELS, GES_LABELS

    # TODO: this is only used in search package

    common_labels = {}
    common_labels.update(COMMON_LABELS)
    common_labels.update(getattr(GES_LABELS, 'indicators'))
    common_labels.update(getattr(GES_LABELS, 'targets'))
    common_labels.update(getattr(GES_LABELS, 'mrus'))
    common_labels.update(getattr(GES_LABELS, 'ktms'))

    if not value:
        return value

    if isinstance(value, string_types):
        value = value.strip()

        if value in common_labels:
            tmpl = '<span title="{}">{}</span>'
            try:
                html = convertWebIntelligentPlainTextToHtml(
                    common_labels[value])
                ret = tmpl.format(value, html)
            except UnicodeEncodeError as e:
                try:
                    ret = tmpl.format(value,
                                      common_labels[value].encode('utf-8'))
                except UnicodeEncodeError as e:
                    ret = tmpl.format(value.encode('utf-8'),
                                      common_labels[value].encode('utf-8'))
            except Exception as e:
                logger.exception("Error print_value: %r", e)
                ret = tmpl.format(value, unicode(common_labels[value]))

            return ret

        html = convertWebIntelligentPlainTextToHtml(value)

        return html

    if isinstance(value, ItemList):
        return value()

    base_values = string_types + (int, float, datetime.datetime, list)

    if not isinstance(value, base_values):

        # TODO: right now we're not showing complex, table-like values
        # Activate below to show tables
        # return self.value_template(item=value)

        return None
        # return '&lt;hidden&gt;'

    return value
Example #2
0
 def unpack_message(self, message):
     msgstr = message.as_string()
     text_body, content_type, html_body, attachments = unpackMail(msgstr)
     if text_body:
         body = convertWebIntelligentPlainTextToHtml(text_body).strip()
     else:
         # we only have an html body; convert it to text and then
         # back to different html rendering
         body = render(html_body)
         body = convertWebIntelligentPlainTextToHtml(body).strip()
     return {'body': body, 'attachments': attachments}
 def _updateMessages(self,supportmessages,usermessage,
                     lastMsgFrom,userName,userID,files):
     """
     """
     
     messagesElem = self.core.getHtmlIdSelector("jabberHelpdeskMessages")
     lastMsg = self.core.getHtmlIdSelector("lastMsg")
     if supportmessages or files:
         msgElem = ''
         
         for message in supportmessages:
             message = message.encode('utf-8')
             message = convertHtmlToWebIntelligentPlainText(message)
             message = convertWebIntelligentPlainTextToHtml(message)
             message = message.replace("<a href",'<a target="_blank" href')
             message = replaceEmoticons(message)
             message = message.decode('utf-8')
             msgElem =msgElem+ '<dd><span>%s</span></dd>'%(message)
         for (path,name,descr) in files:
             b64 = base64.encodestring(path)
             href = "%s/@@fileDownload?file=%s"%(self.context.absolute_url(),b64)
             msgElem = msgElem + '<dd>You received a file:<a href=%s target="_blank">%s</a> %s</dd>'%(href,name,descr)
         
         if (lastMsgFrom!='support') and (not usermessage):
             msgHead = '<dl id="lastMsg" class="msgCont"><dt class="msgHead"><span class="msgTL"></span>'
             msgHead = msgHead+'<span class="tile">%s</span><span class="msgTR"></span></dt>'%('support')
             
             self.core.setAttribute(lastMsg,'id','')
             self.core.insertHTMLAsLastChild(messagesElem, msgHead+msgElem+msgFoot)
             self.core.setStateVar('helpdesk-lastMsgFrom','support')
             lastMsgFrom='support'
         else:
             self.core.replaceHTML("#lastMsg .msgFoot",msgElem+msgFoot)
         self.plonekss.issuePortalMessage('','info')
     
     if usermessage:
         usermessage = convertHtmlToWebIntelligentPlainText(usermessage)
         usermessage = convertWebIntelligentPlainTextToHtml(usermessage)
         usermessage = usermessage.replace("<a href",'<a target="_blank" href')
         usermessage = replaceEmoticons(usermessage)
         usermessage = usermessage.decode('utf-8')
         msgElem = '<dd><span>%s</span></dd>'%(usermessage)
         
         if lastMsgFrom !='user':
             msgHead = '<dl id="lastMsg" class="msgCont"><dt class="msgHead"><span class="msgTL"></span>'
             msgHead = msgHead +'<span class="tile">%s</span><span class="msgTR"></span></dt>'%(userName)
             self.core.setAttribute(lastMsg,'id','')
             self.core.insertHTMLAsLastChild(messagesElem, msgHead+msgElem+msgFoot)
             self.core.setStateVar('helpdesk-lastMsgFrom','user')
         else:
             self.core.replaceHTML("#lastMsg .msgFoot",msgElem+msgFoot)
     
     if supportmessages or usermessage or files:
         self.jhkss.jh_resetScrollbar(messagesElem)
 def unpack_message(self, message):
     msgstr = message.as_string()
     text_body, content_type, html_body, attachments = unpackMail(msgstr)
     if text_body:
         body = convertWebIntelligentPlainTextToHtml(text_body).strip()
     else:
         # we only have an html body; convert it to text and then
         # back to different html rendering
         body = render(html_body)
         body = convertWebIntelligentPlainTextToHtml(body).strip()
     return {'body': body, 'attachments': attachments}
Example #5
0
    def addNewComment(self,uid,comment_title,comment_body,reply_commentid=''):
        """Adds a comment on the provided UID with given title, text and commenter user.
        If reply_commentid is supplied and is a valid id in the object at uid, it is set to be
        a nested reply to that comment.
        Returns UID of the freshly added comment."""

        pdt = getToolByName(self.context, 'portal_discussion', None)
        cat = getToolByName(self.context, 'uid_catalog')
        query = {'UID':uid}
        resbrains = cat.searchResults(query)
        if len(resbrains) == 1:
            contobj = resbrains[0].getObject()
            if contobj.isDiscussable() and self.can_reply(contobj) > 0:
                ditem = None
                dobj = pdt.getDiscussionFor(contobj)
                if reply_commentid != '': #This is a nested comment.
                    try:
                        ditem = dobj.getReply(reply_commentid)
                    except AttributeError:
                        raise ValueError, "The given comment ID does not exist. Please check the comment id of the comment that you are wanting to add this new comment to."
                id = dobj.createReply(title=comment_title, text=comment_body, Creator=self.current_user())
                reply = dobj.getReply(id)
                reply.cooked_text = convertWebIntelligentPlainTextToHtml(reply.text)
                if reply <> None:
                    from ubify.cyninv2theme import triggerAddOnDiscussionItem
                    triggerAddOnDiscussionItem(reply)

                if ditem is not None: #This is supposed to be a nested comment to ditem
                    reply.setReplyTo(ditem)
                return id
            else:
                raise ValueError, 'The object at given UID either does not allow comments OR you do not have permission to comment on this object.'
        else:
            #import pdb; pdb.set_trace()
            raise ValueError, 'More than 1 item found with the given UID. Since this should not happen normally, do check what the heck is going on?'
Example #6
0
    def __call__(self):
        plone.protect.CheckAuthenticator(self.request)
        field = self.context.Schema()["Remarks"]
        value = self.request['value'].strip() + "\n\n"
        existing = self.context.getRemarks(mimetype='text/x-web-intelligent').strip()

        date = TimeOrDate(self.context, DateTime(), long_format=True)
        user = getSecurityManager().getUser()
        divider = "=== %s (%s)\n" % (date, user)

        remarks = convertWebIntelligentPlainTextToHtml(divider) + \
            convertWebIntelligentPlainTextToHtml(value) + \
            convertWebIntelligentPlainTextToHtml(existing)

        self.context.setRemarks(divider + value + existing, mimetype='text/x-web-intelligent')

        return remarks.strip()
Example #7
0
def to_html(text):
    if not text:
        return text

    if len(text.split(' ')) < 10:
        return text

    return convertWebIntelligentPlainTextToHtml(text)
Example #8
0
 def Title(self):
     if self.isTemporary():
         return None
     if self.title != '':
         return self.title;
     elif self.title == '' and self.getRawDescription() != '':
         return generateDiscussionTitle(convertWebIntelligentPlainTextToHtml(self.getRawDescription()))
     else:
         return None
Example #9
0
    def __call__(self):
        plone.protect.CheckAuthenticator(self.request)
        field = self.context.Schema()["Remarks"]
        value = self.request['value'].strip() + "\n\n"
        existing = self.context.getRemarks(
            mimetype='text/x-web-intelligent').strip()

        date = self.ulocalized_time(DateTime, long_format=True)
        user = getSecurityManager().getUser()
        divider = "=== %s (%s)\n" % (date, user)

        remarks = convertWebIntelligentPlainTextToHtml(divider) + \
            convertWebIntelligentPlainTextToHtml(value) + \
            convertWebIntelligentPlainTextToHtml(existing)

        self.context.setRemarks(divider + value + existing,
                                mimetype='text/x-web-intelligent')

        return remarks.strip()
Example #10
0
 def Title(self):
     if self.isTemporary():
         return None
     if self.title != '':
         return self.title
     elif self.title == '' and self.getRawDescription() != '':
         return generateDiscussionTitle(
             convertWebIntelligentPlainTextToHtml(self.getRawDescription()))
     else:
         return None
 def addnewcomment(self):        
     uid = ''
     itemindex = ''
     viewtype = ''
     lasttimestamp = ''
     lastcommentid = ''
     commentscount = ''
     inreplyto = ''
     if self.request.has_key('comcynapsecynincontextUID'):
         uid = self.request['comcynapsecynincontextUID']
     if self.request.has_key('comcynapsecyninitemindex'):
         itemindex = self.request['comcynapsecyninitemindex']
     if self.request.has_key('comcynapseviewtype'):
         viewtype = self.request['comcynapseviewtype']
     if self.request.has_key('comcynapselasttimestamp'):
         lasttimestamp = self.request['comcynapselasttimestamp']
     if self.request.has_key('comcynapselastcommentid'):
         lastcommentid = self.request['comcynapselastcommentid']
     if self.request.has_key('comcynapsecommentcount'):
         commentscount = self.request['comcynapsecommentcount']
     if self.request.has_key('inreplyto'):
         inreplyto = self.request['inreplyto']
     
     query = {'UID':uid}
     pdt = getToolByName(self.context, 'portal_discussion', None)
     cat = getToolByName(self.context, 'uid_catalog')
     resbrains = cat.searchResults(query)
     if len(resbrains) == 1:
         contobj = resbrains[0].getObject()	    
         
         if contobj.isDiscussable() and canreply(contobj):
             mtool = getToolByName(self.context, 'portal_membership')
             username = mtool.getAuthenticatedMember().getId()
             dobj = pdt.getDiscussionFor(contobj)
             if len(self.request['comcynapsecyninNewCommentBody'].strip(' ')) == 0 or self.request['comcynapsecyninNewCommentBody'].lower() == self.request['comcynapsenewcommenttitle'].lower():                    
                 raise EmptycommentError, 'No comment text provided.'
             else:
                 id = dobj.createReply(title="",text=self.request['comcynapsecyninNewCommentBody'], Creator=username)
                 reply = dobj.getReply(id)
                 reply.cooked_text = convertWebIntelligentPlainTextToHtml(reply.text)
                 if inreplyto != '':
                     replyto = dobj.getReply(inreplyto)
                     reply.setReplyTo(replyto)
                 if reply <> None:
                     from ubify.cyninv2theme import triggerAddOnDiscussionItem                        
                     triggerAddOnDiscussionItem(reply)
                     return self.fetchcomments(uid,itemindex,lasttimestamp,commentscount,lastcommentid,viewtype)
Example #12
0
    def addNewComment(self,
                      uid,
                      comment_title,
                      comment_body,
                      reply_commentid=''):
        """Adds a comment on the provided UID with given title, text and commenter user.
        If reply_commentid is supplied and is a valid id in the object at uid, it is set to be
        a nested reply to that comment.
        Returns UID of the freshly added comment."""

        pdt = getToolByName(self.context, 'portal_discussion', None)
        cat = getToolByName(self.context, 'uid_catalog')
        query = {'UID': uid}
        resbrains = cat.searchResults(query)
        if len(resbrains) == 1:
            contobj = resbrains[0].getObject()
            if contobj.isDiscussable() and self.can_reply(contobj) > 0:
                ditem = None
                dobj = pdt.getDiscussionFor(contobj)
                if reply_commentid != '':  #This is a nested comment.
                    try:
                        ditem = dobj.getReply(reply_commentid)
                    except AttributeError:
                        raise ValueError, "The given comment ID does not exist. Please check the comment id of the comment that you are wanting to add this new comment to."
                id = dobj.createReply(title=comment_title,
                                      text=comment_body,
                                      Creator=self.current_user())
                reply = dobj.getReply(id)
                reply.cooked_text = convertWebIntelligentPlainTextToHtml(
                    reply.text)
                if reply <> None:
                    from ubify.cyninv2theme import triggerAddOnDiscussionItem
                    triggerAddOnDiscussionItem(reply)

                if ditem is not None:  #This is supposed to be a nested comment to ditem
                    reply.setReplyTo(ditem)
                return id
            else:
                raise ValueError, 'The object at given UID either does not allow comments OR you do not have permission to comment on this object.'
        else:
            #import pdb; pdb.set_trace()
            raise ValueError, 'More than 1 item found with the given UID. Since this should not happen normally, do check what the heck is going on?'
Example #13
0
    def convert(self, orig, data, **kwargs):
        # "encoding" is both the encoding of orig, and the expected encoding of
        # the data in data.
        if kwargs['encoding'] not in ['utf-8', 'utf_8', 'U8', 'UTF', 'utf8']:
            raise ValueError('Only support unicode, not %s' % kwargs['encoding'])

        if os.path.isfile(TTM_BINARY):
            p = subprocess.Popen(
                [
                    TTM_BINARY,
                    '-a',   # Try to convert picture elements
                    '-e3',  # inline epsfbox w/no icon
                    '-r',   # Don't output a pre/postamble
                    '-u2',   # Unicode please
                ],
                stdin=subprocess.PIPE,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE,
            )
            (out, err) = p.communicate(input=(LATEX_PREAMBLE + orig + LATEX_POSTAMBLE))
            if '****' in err:
                # Probably an error, show it.
                data.setData('<pre class="ttm-output error">%s</pre>\n<div class="ttm-output">%s</div>' % (
                    cgi.escape(err.strip()),
                    out.strip(),
                ))
            else:
                data.setData('<div class="ttm-output">%s</div>' % (
                    out.strip(),
                ))
        else:
            out = convertWebIntelligentPlainTextToHtml(orig.decode(kwargs['encoding'])).decode('utf8')
            # Bodge back entities, to save space
            from htmlentitydefs import entitydefs
            for entity, letter in entitydefs.items():
                if entity not in ('amp', 'lt', 'gt',):
                    out = out.replace('&' + entity + ';', letter.decode('latin-1'))
            data.setData('<div class="parse-as-tex">%s</div>' % out.encode(kwargs['encoding']))
        return data
Example #14
0
newSecurityManager(None, user)

content = site.portal_catalog.unrestrictedSearchResults()
commented = []
for brain in content:
    ob = brain.getObject()
    tb = getattr(ob.aq_base, 'talkback', None)
    if tb is not None:
        commented.append(ob)

from plone.intelligenttext.transforms import convertWebIntelligentPlainTextToHtml
dis = [di for item in commented for di in item.talkback._container.values()]

bad_dis = [
    di for di in dis
    if convertWebIntelligentPlainTextToHtml(di.text) != di.cooked_text
]

for di in bad_dis:
    di.cooked_text = convertWebIntelligentPlainTextToHtml(di.text)

print "%s content items, %s commented upon, %s comments, %s updated." % (
    len(content), len(commented), len(dis), len(bad_dis))

import sys
if sys.argv[-1] == 'commit':
    transaction.commit()
    print 'Transaction committed.'
else:
    transaction.abort()
    print "Transaction aborted, you may pass 'commit' as an argument to this script."
Example #15
0
 def convert(self, orig, data, **kwargs):
     text = convertWebIntelligentPlainTextToHtml(orig, tab_width=self.tab_width)
     data.setData(text)
     return data
Example #16
0
 def Description(self):
     return convertWebIntelligentPlainTextToHtml(self.getRawDescription())
    def replyToComment(self, viewtype, lasttimestamp, commentcount,
                       lastcommentid):
        query = {'UID': self.request['cont_uid']}
        pdt = getToolByName(self.context, 'portal_discussion', None)
        cat = getToolByName(self.context, 'uid_catalog')
        resbrains = cat.searchResults(query)
        ksscore = self.getCommandSet('core')
        zopecore = self.getCommandSet('zope')
        jq = self.getCommandSet('jquery')
        if len(resbrains) == 1:
            contobj = resbrains[0].getObject()
            if contobj.isDiscussable() and self.canreply(contobj):
                mtool = getToolByName(self.context, 'portal_membership')
                username = mtool.getAuthenticatedMember().getId()
                dobj = pdt.getDiscussionFor(contobj)
                if len(self.request['commentbody'].strip(
                        ' ')) == 0 or self.request['commentbody'].lower(
                        ) == self.request['comcynapsenewcommenttitle'].lower():
                    comcynapsecommenterrorlabel = ksscore.getHtmlIdSelector(
                        'comcynapsecommenterror' + self.request['inreplyto'])
                    ksscore.setStyle(comcynapsecommenterrorlabel, 'display',
                                     'block')
                else:
                    id = dobj.createReply(title="",
                                          text=self.request['commentbody'],
                                          Creator=username)
                    reply = dobj.getReply(id)
                    reply.cooked_text = convertWebIntelligentPlainTextToHtml(
                        reply.text)
                    replyto = dobj.getReply(self.request['inreplyto'])
                    reply.setReplyTo(replyto)
                    if reply <> None:
                        from ubify.cyninv2theme import triggerAddOnDiscussionItem
                        triggerAddOnDiscussionItem(reply)

                        #################Determine full reply to discussion to get placement peer of current comment
                        view_type = self.request['cviewtype']
                        replies = []

                        def getRs(obj, replies, counter):
                            rs = pdt.getDiscussionFor(obj).getReplies()
                            if len(rs) > 0:
                                rs.sort(lambda x, y: cmp(
                                    x.modified(), y.modified()))
                                for r in rs:
                                    replies.append({
                                        'depth': counter,
                                        'object': r
                                    })
                                    getRs(r, replies, counter=counter + 1)

                        getRs(replyto, replies, 0)

                        if len(
                                replies
                        ) > 1:  ##There are more than 1 comments already children of the comment we just replied to, so the current comment can't have been the first reply
                            prevrep = replies[0]['object']
                        else:
                            prevrep = replyto

                        for rep in replies:
                            if rep['object'].id == reply.id:
                                belowreply = prevrep
                            else:
                                prevrep = rep['object']

                        mi = mtool.getMemberInfo()
                        commenttemplate = ViewPageTemplateFile(
                            'ksstemplates/commentrow.pt')
                        commenttemplate = commenttemplate.__of__(self.context)
                        depthvalue = 0
                        if view_type == 'threadedview':
                            depthvalue = int(self.request['depth']) + 1

                        replydict = [
                            {
                                'depth': depthvalue,
                                'object': reply,
                                'view_type': view_type
                            },
                        ]
                        output = commenttemplate.render(
                            indent=int(self.request['depth']) + 2,
                            fullname=mi['fullname'],
                            avatarurl=self.context.portal_membership.
                            getPersonalPortrait(username).absolute_url(),
                            creator=username,
                            showreply=self.canreply(self.context),
                            showdelete=getSecurityManager().checkPermission(
                                'Manage portal', aq_inner(self.context)),
                            commenttime=self.context.toLocalizedTime(
                                reply.created, True),
                            replyid=reply.id,
                            replytitle=reply.Title(),
                            replybody=reply.CookedBody(),
                            replyurl=reply.absolute_url(),
                            reply_dict=replydict)

                        if view_type == 'threadedview':
                            commentscontainer = ksscore.getHtmlIdSelector(
                                'commenttable' + prevrep.id)
                            ksscore.insertHTMLAfter(commentscontainer, output)
                        else:
                            commentsoutercontainer = ksscore.getHtmlIdSelector(
                                'comcynapsecyninitemcommentscontainer')
                            ksscore.insertHTMLAsLastChild(
                                commentsoutercontainer, output)

                        taAddNewComment = ksscore.getCssSelector(
                            'textarea.commentbodyta')
                        ksscore.setAttribute(taAddNewComment, "value", "")
                        itemcountcommentcount = ksscore.getHtmlIdSelector(
                            'itemcountcommentcount')
                        countofcomments = dobj.replyCount(self.context)
                        discussionlabel = ksscore.getHtmlIdSelector(
                            'discussionlabel')
                        ksscore.replaceInnerHTML(discussionlabel,
                                                 str(countofcomments))
                        ksscore.replaceInnerHTML(itemcountcommentcount,
                                                 str(countofcomments))
                        newcomment = ksscore.getHtmlIdSelector('commenttable' +
                                                               reply.id)
                        frmreply = ksscore.getHtmlIdSelector(
                            'replyform' + self.request['inreplyto'])
                        ksscore.setStyle(frmreply, 'display', 'none')
                        comcynapsecommenterrorlabel = ksscore.getHtmlIdSelector(
                            'comcynapsecommenterror' +
                            self.request['inreplyto'])
                        ksscore.setStyle(comcynapsecommenterrorlabel,
                                         'display', 'none')
                        self.fetchnewcomments(lasttimestamp, commentcount,
                                              lastcommentid, viewtype)
Example #18
0
site = app.unrestrictedTraverse(SITE)
setSite(site)
user = app.acl_users.getUser('admin').__of__(site.acl_users)
newSecurityManager(None, user)

content = site.portal_catalog.unrestrictedSearchResults()
commented = []
for brain in content:
    ob = brain.getObject()
    tb = getattr(ob.aq_base, 'talkback', None)
    if tb is not None:
        commented.append(ob)

from plone.intelligenttext.transforms import convertWebIntelligentPlainTextToHtml
dis = [di for item in commented for di in item.talkback._container.values()]

bad_dis = [di for di in dis if convertWebIntelligentPlainTextToHtml(di.text) != di.cooked_text]

for di in bad_dis:
    di.cooked_text = convertWebIntelligentPlainTextToHtml(di.text)

print "%s content items, %s commented upon, %s comments, %s updated." % (len(content), len(commented), len(dis), len(bad_dis))

import sys
if sys.argv[-1] == 'commit':
    transaction.commit()
    print 'Transaction committed.'
else:
    transaction.abort()
    print "Transaction aborted, you may pass 'commit' as an argument to this script."
Example #19
0
 def richDesTitle(self):
     return convertWebIntelligentPlainTextToHtml(self.context.title)
Example #20
0
def CookedBody(self, stx_level=None, setlevel=0):
    return convertWebIntelligentPlainTextToHtml(self.text)
Example #21
0
 def richDesTitle(self):
     return convertWebIntelligentPlainTextToHtml(self.context.title)
    def replyToComment(self,viewtype,lasttimestamp,commentcount,lastcommentid):
        query = {'UID':self.request['cont_uid']}
        pdt = getToolByName(self.context, 'portal_discussion', None)
        cat = getToolByName(self.context, 'uid_catalog')
        resbrains = cat.searchResults(query)
	ksscore = self.getCommandSet('core')
        zopecore = self.getCommandSet('zope')
        jq = self.getCommandSet('jquery')
        if len(resbrains) == 1:
            contobj = resbrains[0].getObject()
            if contobj.isDiscussable() and self.canreply(contobj):
                mtool = getToolByName(self.context, 'portal_membership')
                username = mtool.getAuthenticatedMember().getId()
                dobj = pdt.getDiscussionFor(contobj)
                if len(self.request['commentbody'].strip(' ')) == 0 or self.request['commentbody'].lower() == self.request['comcynapsenewcommenttitle'].lower():
                    comcynapsecommenterrorlabel = ksscore.getHtmlIdSelector('comcynapsecommenterror'+ self.request['inreplyto'])
		    ksscore.setStyle(comcynapsecommenterrorlabel,'display','block')		    
                else:
                    id = dobj.createReply(title="", text=self.request['commentbody'], Creator=username)
                    reply = dobj.getReply(id)
                    reply.cooked_text = convertWebIntelligentPlainTextToHtml(reply.text)
                    replyto = dobj.getReply(self.request['inreplyto'])
                    reply.setReplyTo(replyto)
                    if reply <> None:
                        from ubify.cyninv2theme import triggerAddOnDiscussionItem
                        triggerAddOnDiscussionItem(reply)

                        #################Determine full reply to discussion to get placement peer of current comment
                        view_type = self.request['cviewtype']
                        replies = []
                        def getRs(obj, replies, counter):
                            rs = pdt.getDiscussionFor(obj).getReplies()
                            if len(rs) > 0:
                                rs.sort(lambda x, y: cmp(x.modified(), y.modified()))
                                for r in rs:
                                    replies.append({'depth':counter, 'object':r})
                                    getRs(r, replies, counter=counter + 1)

                        getRs(replyto, replies, 0)

                        if len(replies) > 1: ##There are more than 1 comments already children of the comment we just replied to, so the current comment can't have been the first reply
                            prevrep = replies[0]['object']
                        else:
                            prevrep = replyto

                        for rep in replies:
                            if rep['object'].id == reply.id:
                                belowreply = prevrep
                            else:
                                prevrep = rep['object']

                        mi = mtool.getMemberInfo();
                        commenttemplate = ViewPageTemplateFile('ksstemplates/commentrow.pt')
                        commenttemplate = commenttemplate.__of__(self.context)
                        depthvalue = 0
                        if view_type == 'threadedview':
                            depthvalue = int(self.request['depth']) + 1
                            
                        replydict = [{'depth': depthvalue, 'object': reply,'view_type':view_type},]
                        output = commenttemplate.render(indent=int(self.request['depth'])+2,fullname = mi['fullname'], avatarurl=self.context.portal_membership.getPersonalPortrait(username).absolute_url(),creator=username,showreply=self.canreply(self.context),showdelete=getSecurityManager().checkPermission('Manage portal',aq_inner(self.context)),commenttime=self.context.toLocalizedTime(reply.created,True),replyid=reply.id,replytitle=reply.Title(),replybody=reply.CookedBody(),replyurl=reply.absolute_url(),reply_dict=replydict)
                        
                        if view_type == 'threadedview':
                            commentscontainer = ksscore.getHtmlIdSelector('commenttable' + prevrep.id)
                            ksscore.insertHTMLAfter(commentscontainer,output)
                        else:
                            commentsoutercontainer = ksscore.getHtmlIdSelector('comcynapsecyninitemcommentscontainer')
                            ksscore.insertHTMLAsLastChild(commentsoutercontainer,output)
                        
                        taAddNewComment = ksscore.getCssSelector('textarea.commentbodyta')
                        ksscore.setAttribute(taAddNewComment,"value","")
                        itemcountcommentcount = ksscore.getHtmlIdSelector('itemcountcommentcount')
                        countofcomments = dobj.replyCount(self.context)
                        discussionlabel = ksscore.getHtmlIdSelector('discussionlabel')
                        ksscore.replaceInnerHTML(discussionlabel,str(countofcomments))
                        ksscore.replaceInnerHTML(itemcountcommentcount,str(countofcomments))
                        newcomment = ksscore.getHtmlIdSelector('commenttable' + reply.id)
                        frmreply = ksscore.getHtmlIdSelector('replyform' + self.request['inreplyto'])			
			ksscore.setStyle(frmreply,'display','none')
			comcynapsecommenterrorlabel = ksscore.getHtmlIdSelector('comcynapsecommenterror'+ self.request['inreplyto'])
			ksscore.setStyle(comcynapsecommenterrorlabel,'display','none')
                        self.fetchnewcomments(lasttimestamp,commentcount,lastcommentid,viewtype)
 def Description(self):        
     return convertWebIntelligentPlainTextToHtml(self.getRawDescription())
Example #24
0
 def cookReply(self, reply, text_format=None):
     """ TODO We need this because currently we can not easily change the
         text_format on document objects.  Discussions in plone are going
         to use plain-text for now.  stx is too confusing.
     """
     reply.cooked_text = convertWebIntelligentPlainTextToHtml(reply.text)
Example #25
0
 def description(self):
     return convertWebIntelligentPlainTextToHtml(self.context.description)
Example #26
0
def CookedBody(self, stx_level=None, setlevel=0):
    return convertWebIntelligentPlainTextToHtml(self.text)
Example #27
0
def getWebIntelligentTextToHTML(text):
    return convertWebIntelligentPlainTextToHtml(text)
Example #28
0
 def bio(self):
     return convertWebIntelligentPlainTextToHtml(self.context.bio)
Example #29
0
 def detail(self):
     return convertWebIntelligentPlainTextToHtml(self.context.detail)
 def convert(self, orig, data, **kwargs):
     text = convertWebIntelligentPlainTextToHtml(orig, tab_width=self.tab_width)
     data.setData(text)
     return data
 def description(self):
     return convertWebIntelligentPlainTextToHtml(self.context.description)
 def detail(self):
     return convertWebIntelligentPlainTextToHtml(self.context.detail)
 def bio(self):
     return convertWebIntelligentPlainTextToHtml(self.context.bio)
Example #34
0
 def cookReply(self, reply, text_format=None):
     """ TODO We need this because currently we can not easily change the
         text_format on document objects.  Discussions in plone are going
         to use plain-text for now.  stx is too confusing.
     """
     reply.cooked_text = convertWebIntelligentPlainTextToHtml(reply.text)
    def transform(self, data, options=None):
        if self._validate(data) is None:
            return None

        html = convertWebIntelligentPlainTextToHtml(u''.join(data))
        return TransformResult(StringIter(unicode(html, 'utf-8')))