class IUserCloudPortlet(IPortletDataProvider): portletTitle = schema.TextLine( title = _(u"Portlet title"), description = _(u"The title of the tagcloud."), required = True, default = u"User Cloud") levels = schema.Int( title = _(u"Number of different sizes"), description = _(u"This number will also determine the biggest size."), required = True, min = 1, max = 6, default = 5) count = schema.Int( title = _(u"Maximum number of shown tags."), description = _(u"If greater than zero this number will limit the " \ "tags shown."), required = True, min = 0, default = 30) refreshInterval = schema.Int( title = _(u"Refresh interval"), description = _(u"The maximum time in seconds for which the portal"\ " will cache the results. Be careful not to use low values."), required = True, min = 1, default = 3600, )
def getTags(self): tagOccs = self.getTagOccurrences() # If count has been set sort by occurences and keep the "count" first if self.count: sortedOccs = sorted(tagOccs.items(), key=itemgetter(1), reverse=True)[:self.count] tagOccs = dict(sortedOccs) thresholds = self.getThresholds(tagOccs.values()) tags = list(tagOccs.keys()) tags.sort() res = [] for tag in tags: d = {} size = self.getTagSize(tagOccs[tag], thresholds) if size == 0: continue d["text"] = tag d["class"] = "cloud" + str(size) href= self.portal_url + \ "/?user="******"href"]=href d["count"] = translate( _(u'${count} items', mapping={'count': tagOccs[tag]}), context=self.request) res.append(d) return res
def getTags(self): tagOccs = self.getTagOccurrences() # If count has been set sort by occurences and keep the "count" first if self.count: sortedOccs = sorted(tagOccs.items(), key=itemgetter(1), reverse=True)[:self.count] tagOccs = dict(sortedOccs) thresholds = self.getThresholds(tagOccs.values()) tags = list(tagOccs.keys()) tags.sort() res = [] for tag in tags: d = {} size = self.getTagSize(tagOccs[tag], thresholds) if size == 0: continue d["text"] = tag d["class"] = "cloud" + str(size) href= self.portal_url + \ "/@@search?Subject%3Alist="+url_quote(tag) #Add type restrictions to search link href = href + "".join([ "&portal_type%3Alist=" + url_quote(ptype) for ptype in self.restrictTypes ]) #Add workflow restrictions to search link href = href + "".join([ "&review_state%3Alist=" + url_quote(wstate) for wstate in self.wfStates ]) #Add path to search link if self.root: href = href + "&path=%s" % getNavigationRoot( self.context, relativeRoot=self.root) d["href"] = href d["count"] = translate(_(u'${count} items', mapping={'count': tagOccs[tag]}), context=self.request) res.append(d) return res
def getTags(self): tagOccs = self.getTagOccurrences() # If count has been set sort by occurences and keep the "count" first if self.count: sortedOccs = sorted(tagOccs.items(), key=itemgetter(1), reverse=True)[:self.count] tagOccs = dict(sortedOccs) thresholds = self.getThresholds(tagOccs.values()) tags = list(tagOccs.keys()) tags.sort() res = [] for tag in tags: d = {} size = self.getTagSize(tagOccs[tag], thresholds) if size == 0: continue d["text"] = tag d["class"] = "cloud" + str(size) href= self.portal_url + \ "/search?Subject%3Alist="+url_quote(tag) #Add type restrictions to search link href = href+ "".join(["&portal_type%3Alist="+url_quote(ptype) for ptype in self.restrictTypes]) #Add workflow restrictions to search link href = href+ "".join(["&review_state%3Alist="+url_quote(wstate) for wstate in self.wfStates]) #Add path to search link if self.root: href = href+"&path=%s"%getNavigationRoot(self.context, relativeRoot=self.root) d["href"]=href d["count"] = translate( _(u'${count} items', mapping={'count': tagOccs[tag]}), context=self.request) res.append(d) return res
class ITagCloudPortlet(IPortletDataProvider): portletTitle = schema.TextLine( title=_(u"Portlet title"), description=_(u"The title of the tagcloud."), required=True, default=u"Tag Cloud") levels = schema.Int( title=_(u"Number of different sizes"), description=_(u"This number will also determine the biggest size."), required=True, min=1, max=6, default=5) count = schema.Int( title = _(u"Maximum number of shown tags."), description = _(u"If greater than zero this number will limit the " \ "tags shown."), required = True, min = 0, default = 0) restrictSubjects = schema.List( required = False, title = _(u"Restrict by keywords"), description = _(u"Restrict the keywords searched. Leaving " \ "this empty will include all keywords"), value_type = schema.Choice(vocabulary = 'qi.portlet.TagClouds.subjects')) filterSubjects = schema.List( required = False, title = _(u"Filter by keywords"), description = _(u"Filter the keywords searched. Only items " \ "categorized with at least all the keywords selected here " \ "will be searched. The keywords selected here will be " \ "omitted from the tag clouds. Leaving the field empty will " \ "disable filtering"), value_type = schema.Choice(vocabulary = 'qi.portlet.TagClouds.subjects'), ) restrictTypes = schema.List( required = False, title = _(u"Restrict by types"), description = _(u"Restrict the content types. Leaving this empty " \ "will include all user-friendly content types."), value_type = schema.Choice(vocabulary = 'plone.app.vocabularies.ReallyUserFriendlyTypes'), ) root = schema.Choice( title=_(u"Root node"), description=_(u"You may search for and choose a folder " \ "to act as the root of the navigation tree. " \ "Leave blank to use the Plone site root."), required=False, source=CatalogSource(is_folderish=True) ) wfStates = schema.List( required = True, title = _(u"Workflow states to show"), description = _(u"Which workflow states to include in the " \ "search."), value_type = schema.Choice(vocabulary = 'plone.app.vocabularies.WorkflowStates')) refreshInterval = schema.Int( title = _(u"Refresh interval"), description = _(u"The maximum time in seconds for which the portal"\ " will cache the results. Be careful not to use low values."), required = True, min = 1, default = 3600, )