def translated_portal_message(self): """ Shows a portal message with a text translated in the user's language. """ jq = JQueryProxy() from Products.CMFPlone import PloneMessageFactory as PMF msg = PMF(u'This field is required, please provide some information.') jq.set_portal_message(msg, 'info') return jq
def enhanceTags(self): """ Enhances text by extracting keywords from it @param self: the object itself @return keywords """ jq = JQueryProxy() content = self.request.form.get('text') print content dir(content) res = self.engineCall(content) dir(res) cache = {} for t in res: if t[2].istitle(): if t[2].datatype is None or t[2].datatype.endswith('string'): cache[hashlib.md5(t[2].title()).hexdigest()] = t[2].title() tags = "" for k in cache: #test = jq("#subject input[value='"+cache[k]+"']") #jq("#subject input[value='"+cache[k]+"']").attr('checked', 'checked') #print test tags += cache[k] + '\n' #print tags jq("#subject_keywords").html(tags) return jq
def _download(self): if not 'page' in self.request.form: # This should not happen. return jq jq = JQueryProxy() jq.extend_grammar({'redirect': [[str, unicode]]}) self.make_pdf() if self.errors: self.index = ZopeTwoPageTemplateFile('templates/ajax.pt') return self.add_popup(jq) jq('').redirect('%s/send_as_pdf_download?pdf_name=%s' % ( self.context.absolute_url(), self.filename)) return jq
def save(self): jq = JQueryProxy() if not self.check_form(): jq.set_portal_message(self.form_error_msg, 'error') return jq if self.errors: # Remove the previous errors. errors_selector = '#' + self.content_selector + ' .error' jq(errors_selector).addClass('dont-show') jq(errors_selector).removeClass('error') for err in self.errors: if err in self.error_mapping: jq(self.error_mapping[err]).addClass('error') jq(self.error_mapping[err]).removeClass('dont-show') jq.set_portal_message(self.error_msg, 'error') return jq new_mode = self.process_form() # We have to remove the 'form_submitted' to avoid doing the action # twice. del self.request.form['form_submitted'] self.request.form['mode'] = new_mode jq.set_portal_message(self.success_msg, 'success') return self._update_content(jq)
def contentHubCall(self, data): """ Returns result from processing data with Stanbol contentHub @param self: the object itself @param data: data to process @return results """ jq = JQueryProxy() return jq
def show_portal_message(self): """ Displays a portal message. """ jq = JQueryProxy() text = self.request.form.get('text', '') msg = '' msg_type = 'info' if text == '': msg = 'You have to enter some text' msg_type = 'error' elif len(text) < 10: msg = 'The text has ben saved, but it is a bit short' msg_type = 'warning' else: msg = 'The text has ben saved' jq.set_portal_message(msg, msg_type) return jq
def sparqlCall(self): """ JQuery.PyProxy View for SparQL console @param self: the object itself @return sparql query result """ jq = JQueryProxy() data = self.request.form.get('text') print self.request.stdin.getvalue() print data stanbol = get_stanbol(self.context) res = stanbol.sparql(data).body_string() print res res = res.replace('<', '<') res = res.replace('>', '>') jq("#sparql_result").html(res) return jq
def hide_portal_message(self): """ Removes the portal message """ jq = JQueryProxy() jq.hide_portal_message() return jq
def cancel(self): """ Shows the cancel message and updates the page. """ jq = JQueryProxy() jq.set_portal_message(self.cancel_msg, 'success') return self._update_content(jq)