Beispiel #1
0
class IStatisticsPortlet(IPortletDataProvider):
    """A portlet which renders statistics for cyn.in site.
    """
    count = schema.Int(title=_(u'Number of items to display'),
                       description=_(u'How many items to list?'),
                       required=True,
                       default=10)
Beispiel #2
0
def getContentItemsCount(context,path=None):
    lstinfo = []

    totalwikipages = getTotalCountForQuery(context,path,{'portal_type':'Document'})
    lstinfo.append({'id':'Wiki Pages','dispid':context.translate(_(u'lbl_stats_wiki_pages',u'Wiki Pages')),'count':totalwikipages})

    totalblogentries = getTotalCountForQuery(context,path,{'portal_type':'Blog Entry'})
    lstinfo.append({'id':'Blog Entries','dispid':context.translate(_(u'lbl_stats_blog_entries',u'Blog Entries')),'count':totalblogentries})

    totalfiles = getTotalCountForQuery(context,path,{'portal_type':'File'})
    lstinfo.append({'id':'Files','dispid':context.translate(_(u'lbl_stats_files',u'Files')),'count':totalfiles})

    totalimages = getTotalCountForQuery(context,path,{'portal_type':'Image'})
    lstinfo.append({'id':'Images','dispid':context.translate(_(u'lbl_stats_status_images',u'Images')),'count':totalimages})

    totallinks = getTotalCountForQuery(context,path,{'portal_type':'Link'})
    lstinfo.append({'id':'WebLinks','dispid':context.translate(_(u'lbl_stats_status_weblinks',u'WebLinks')),'count':totallinks})

    totalstatusmessages = getTotalCountForQuery(context,path,{'portal_type':'StatuslogItem'})
    lstinfo.append({'id':'Status Messages','dispid':context.translate(_(u'lbl_stats_status_msgs',u'Status Messages')),'count':totalstatusmessages})

    totalvideos = getTotalCountForQuery(context,path,{'portal_type':'Video'})
    lstinfo.append({'id':'Videos','dispid':context.translate(_(u'lbl_stats_videos',u'Videos')),'count':totalvideos})

    totalevents = getTotalCountForQuery(context,path,{'portal_type':'Event'})
    lstinfo.append({'id':'Events','dispid':context.translate(_(u'lbl_stats_events',u'Events')),'count':totalevents})
    
    totaldiscussions = getTotalCountForQuery(context,path,{'portal_type':'Discussion'})
    lstinfo.append({'id':'Discussions','dispid':context.translate(_(u'lbl_stats_discussions',u'Discussions')),'count':totaldiscussions})
    
    totalaudios = getTotalCountForQuery(context,path,{'portal_type':'Audio'})
    lstinfo.append({'id':'Audios','dispid':context.translate(_(u'lbl_stats_audios',u'Audios')),'count':totalaudios}) 

    return lstinfo
Beispiel #3
0
def renameScrawl(portal_types):
    blog_fti = getattr(portal_types, 'Blog Entry')
    blog_fti.title = _(u'Blog Post')
    blog_fti.description = _(u"Formatted temporal content",
                             u"Formatted temporal content")
    blog_fti.content_icon = 'blog.png'
    blog_fti.global_allow = True
Beispiel #4
0
class Audio(BaseClass):
    implements(IAudio)

    __doc__ = BaseClass.__doc__ + "(customizable version)"

    portal_type = "Audio"
    archetype_name = BaseClass.archetype_name

    assocFileExt = ('ogg', 'wav', 'mp3')
    if schema['file'] <> None:
        schema['file'].widget.label = _(u'Audio')
        schema['file'].widget.description = _(
            u'Select a .mp3 or .wav audio file.')

    schema = schema

    def manage_afterPUT(self, data, marshall_data, file, context, mimetype,
                        filename, REQUEST, RESPONSE):
        is_new = False
        title = self.Title()
        if not title:
            is_new = True
        BaseClass.manage_afterPUT(self, data, marshall_data, file, context,
                                  mimetype, filename, REQUEST, RESPONSE)
        if is_new:
            notify(ObjectInitializedEvent(self))
        else:
            notify(ObjectEditedEvent(self))
Beispiel #5
0
class AddForm(base.AddForm):
    form_fields = form.Fields(IActivityPortlet)
    label = _(u"Add Recently Active Users Portlet")
    description = _(u"A portlet that renders a tile list of recently active user's avatars within the context of the space and all contained spaces.")

    def create(self, data):
        return Assignment(count=data.get('count', 10))
class AddForm(base.AddForm):
    form_fields = form.Fields(IMyItemsPortlet)
    label = _(u"Add My Items Portlet")
    description = _(u"This portlet displays items created by current user.")

    def create(self, data):
        return Assignment(count=data.get('count', 10))
Beispiel #7
0
class AddForm(base.AddForm):
    form_fields = form.Fields(IBlogPortlet)
    label = _(u"Add Blog Portlet")
    description = _(u"This portlet displays recently modified blog posts.")

    def create(self, data):
        return Assignment(count=data.get('count', 5))
Beispiel #8
0
class AddForm(base.AddForm):
    form_fields = form.Fields(IStatisticsPortlet)
    label = _(u"Add Statistics Portlet")
    description = _(u"A portlet that renders statistical information of the collaborative activity and content within the context of the space and all contained spaces.")

    def create(self, data):
        return Assignment(count=data.get('count', 10))
Beispiel #9
0
class AddForm(base.AddForm):
    form_fields = form.Fields(IRecentUpdatesPortlet)
    label = _(u"Add Recent Updates Portlet")
    description = _(u"This portlet displays recently modified items.")

    def create(self, data):
        return Assignment(count=data.get('count', 10))
Beispiel #10
0
class AddForm(base.AddForm):
    form_fields = form.Fields(ISpaceMembersPortlet)
    label = _(u"Add Space Members Portlet")
    description = _(u"This portlet displays members for current space.")

    def create(self, data):
        return Assignment(count=data.get('count', 5),role=data.get('role','Reader'))
Beispiel #11
0
class AddForm(base.AddForm):
    form_fields = form.Fields(ITopRatedPortlet)
    label = _(u"Add Top Rated Portlet")
    description = _(
        u"A portlet that renders a list of the highest rated content within the context of the space and all contained spaces."
    )

    def create(self, data):
        return Assignment(count=data.get('count', 10))
Beispiel #12
0
class AddForm(base.AddForm):
    form_fields = form.Fields(IRecentSiteUpdatesPortlet)
    label = _(u"Add Recent Site Updates Portlet")
    description = _(
        u"A portlet that renders a list of recent content of all types from within the context of the space and all contained spaces."
    )

    def create(self, data):
        return Assignment(count=data.get('count', 10))
class AddForm(base.AddForm):
    form_fields = form.Fields(ITagsPortlet)
    label = _(u"Add Tags Portlet")
    description = _(
        u"A portlet that renders a tag cloud of tags used within the context of the space and all contained spaces."
    )

    def create(self, data):
        return Assignment(count=data.get('count', 20))
Beispiel #14
0
def CyninEdition(context):
    portal_quickinstaller = getToolByName(context, 'portal_quickinstaller')
    ubifyEdition = ""
    objProduct = portal_quickinstaller._getOb('ubify.enterprise',None)
    objondemandproduct = portal_quickinstaller._getOb('ubify.ondemand',None)
    if objProduct <> None:
        return _('cynin_enterprise_edition','enterprise edition'),'ee'
    elif objondemandproduct <> None:
        return _('cynin_ondemand_edition','on demand edition'),'od'
    else:
        return _('cynin_community_edition','free open source edition'),'ce'
Beispiel #15
0
class ISpaceMembersPortlet(IPortletDataProvider):

    displaytitle = schema.TextLine(title=_(u'Title'),required=False)
    
    count = schema.Int(title=_(u'Number of items to display'),
                       description=_(u'How many items to list.'),
                       required=True,
                       default=5)
    role = schema.Choice(title=_(u"Select Role"),
                               description=_(u"Choose a role of members to be displayed for this Space"),
                               vocabulary="ubify.cyninv2theme.portlets.ListRoles")
 def ratecontent(self):        
     ratevalue = None
     uid = None
     if self.request.form.has_key('ratevalue'):
         ratevalue = self.request.form['ratevalue']
     if self.request.form.has_key('itemUID'):
         uid = self.request.form['itemUID']
         
     if ratevalue is None:
         raise RatingError,'No rating value.'
     elif uid is None:
         raise RatingError,'No rating item.'
     else:
         pr = getToolByName(self.context, 'portal_ratings', None)
         cat = getToolByName(self.context, 'uid_catalog')
         pr.addRating(int(ratevalue), uid)
         
         query = {'UID':uid}
         resbrains = cat.searchResults(query)
         if len(resbrains) == 1:
             obj = resbrains[0].getObject()
             obj.reindexObject()
         
         myval = int(pr.getUserRating(uid))
         newval = int(pr.getRatingMean(uid))
         ratecount = pr.getRatingCount(uid)
         value_totalscore = pr.getCyninRating(uid)
         value_scorecountlist = pr.getCyninRatingCount(uid)
         value_pscore = value_scorecountlist['positivescore']
         value_pcount = value_scorecountlist['positive']
         value_nscore = value_scorecountlist['negativescore']
         value_ncount = value_scorecountlist['negative']
         
         if myval == 1:
             newtitle=_(u'hated_it',u"Hate it (-2)")
         elif myval == 2:
             newtitle=_(u'didnt_like_it',u"Dislike it (-1)")
         elif myval == 3:
             newtitle=''
         elif myval == 4:
             newtitle=_(u'liked_it',u"Like it (+1)")
         elif myval == 5:
             newtitle=_(u'loved_it',u"Love it (+2)")
         
         trans_title = self.context.translate(newtitle)
         
         if value_totalscore > 0:
             plus_sign = "+"
         else:
             plus_sign = ""
         totalscore = plus_sign + str(value_totalscore)
         
         output = trans_title + ',' + totalscore + ',' + str(value_pcount) + ',' + str(value_ncount)
         return output
Beispiel #17
0
def getTitleForRating(num):
    if num == 1:
        newtitle=_(u"hated_it",u'Hated it')
    elif num == 2:
        newtitle=_(u"didnt_like_it",u"Didn't like it")
    elif num == 3:
        newtitle=_(u"average",u"Average")
    elif num == 4:
        newtitle=_(u"liked_it",u'Liked it')
    elif num == 5:
        newtitle=_(u"loved_it",u'Loved it')
    return newtitle
Beispiel #18
0
def getSchemaSectionName(schema):
    returnvalue = 'default'
    if schema.lower() == "categorization":
        returnvalue = _(u"categorization",u"Categorization")
    elif schema.lower() == "dates":
        returnvalue = _(u"schedule",u"Schedule")
    elif schema.lower() == "ownership":
        returnvalue = _(u"ownership",u"Ownership")
    elif schema.lower() == "settings":
        returnvalue = _(u"additional_settings",u"Additional Settings")
    elif schema.lower() == "default":
        returnvalue = _(u"content",u"Content")
    return returnvalue
def getTotalUsersCount(context):
    userscount = 0
    usersdata = []
    if context.portal_type in ('ContentSpace'):
        usersdata = getUsersCountForSpace(context, (
            'Users',
            'Editors',
            'Contributors',
            'Readers',
        ))
    else:
        if many_users() == False:
            search_view = context.restrictedTraverse('@@pas_search')
            userscount = len(
                search_view.searchUsersByRequest(context.REQUEST,
                                                 sort_by='fullname'))
            usersdata.append({
                'id':
                'Users',
                'dispid':
                context.translate(_(u'lbl_stats_users', u'Users')),
                'count':
                userscount
            })
    return usersdata
Beispiel #20
0
def getUsersCountForSpace(context,roles_to_search):
    results = []
    
    listReaders = context.users_with_local_role('Reader')
    listReaders = checkIfGroupGetUsers(listReaders,context)
    
    listContributors = context.users_with_local_role('Contributor')
    listContributors = checkIfGroupGetUsers(listContributors,context)
    
    listReviewers = context.users_with_local_role('Reviewer')
    listReviewers = checkIfGroupGetUsers(listReviewers,context)

    listEditors = context.users_with_local_role('Editor')
    listEditors = checkIfGroupGetUsers(listEditors,context)

    
    for role_to_search in roles_to_search:
        objresults = []
        if role_to_search == 'Readers':
            for user in listReaders:
                if user not in listContributors and user not in listReviewers and user not in listEditors:
                    objresults.append(user)
        elif role_to_search == 'Contributors':
            for user in listContributors:
                if user not in listReviewers and user not in listEditors:
                    objresults.append(user)
        elif role_to_search == 'Reviewers':
            for user in listReviewers:
                if user not in listEditors:
                    objresults.append(user)
        elif role_to_search == 'Editors':
            objresults = listEditors
        else:   #Special case when all members will be listed priority given to managers
            listmembers = []
            listtemp = []
            
            for userEditor in listEditors:
                listtemp.append(userEditor)
                listtemp.sort()
            for userReviewer in listReviewers:
                if userReviewer not in listmembers and userReviewer not in listtemp:
                    listmembers.append(userReviewer)
            for userContributor in listContributors:
                if userContributor not in listmembers and userContributor not in listtemp:
                    listmembers.append(userContributor)
            for userReader in listReaders:
                if userReader not in listmembers and userReader not in listtemp:
                    listmembers.append(userReader)
                    
            listmembers.sort()
            listtemp.extend(listmembers)
            objresults.extend(listtemp)
    
        results.append({'id':role_to_search,'dispid':context.translate(_(role_to_search,role_to_search)),'count':len(objresults)})
    
    return results
    
    
    
 def refreshMyAreaBlock(self,messageuid,count):
     portal_state = getMultiAdapter((self.context, self.request), name=u"plone_portal_state")
     
     if portal_state.anonymous():
         return
     user_token = portal_state.member().getId()
     if user_token is None:
         return
     
     status_messages = self.context.portal_catalog.searchResults(Creator = user_token,portal_type=('StatuslogItem',),sort_on = 'created',sort_order='reverse',sort_limit=1);
     
     if len(status_messages) > 0:
         pdt = getToolByName(self.context, 'portal_discussion', None)
         newuid = status_messages[0].UID
         full_message = status_messages[0].getObject()
         newcount = 0
         message = status_messages[0].Title
         
         if full_message.isDiscussable():
             newcount = pdt.getDiscussionFor(full_message).replyCount(full_message)
         
         if newuid != messageuid or int(count) != newcount:                
             zopecommands = self.getCommandSet('zope')
             ksscore = self.getCommandSet('core')
             
             message = force_unicode(message,'utf')
             commenttext = ''
             
             if newcount < 1 or newcount > 1:
                 commenttext = _(u'text_comments',u"comments")
             elif newcount == 1:
                 commenttext = _(u'text_1_comment',u"comment")
             
             commenttext = self.context.translate(commenttext)
             commenttext = force_unicode(commenttext,'utf')
             
             selector = ksscore.getHtmlIdSelector('currentmessagediv')
             ksscore.replaceInnerHTML(selector,message)
             
             countselector = ksscore.getHtmlIdSelector('comcynapsecyninstatuscomments')
             ksscore.replaceInnerHTML(countselector,'<a href="%s">%s %s</a>' % (full_message.absolute_url(),newcount,commenttext,))
             
             kssattrselector = ksscore.getHtmlIdSelector('comcynapsecyninmyareablock')
             ksscore.setKssAttribute(kssattrselector,'messageid',str(newuid))
             ksscore.setKssAttribute(kssattrselector,'count',str(newcount))
Beispiel #22
0
def getTotalUsersCount(context):
    userscount = 0
    usersdata = []    
    if context.portal_type in ('ContentSpace'):
        usersdata = getUsersCountForSpace(context,('Users','Editors','Contributors','Readers',))        
    else:
        search_view = context.restrictedTraverse('@@pas_search')
        userscount = len(search_view.searchUsersByRequest(context.REQUEST, sort_by='fullname'))
        usersdata.append({'id':'Users','dispid':context.translate(_(u'lbl_stats_users',u'Users')),'count':userscount})
    return usersdata
class WorkflowSubMenuItem(BaseWorkflowSubMenuItem):

    title = _(u'lbl_change_state', default=u'Change State')

    @property
    def description(self):
        if self._manageSettings() or len(self._transitions()) > 0:
            return _(u'title_change_state_of_item',
                     default=u'Change the state of this item')
        else:
            return u''
Beispiel #24
0
def getSiteStatistics(context,path=None,ignoreviews=True,ignoretags=True):
    lstinfo = []
    
    lstinfo.extend(getTotalUsersCount(context))
    
    totalspaces = getTotalCountForQuery(context,path,{'portal_type':'ContentSpace'})
    lstinfo.append({'id':'Spaces','dispid':context.translate(_(u'lbl_stats_spaces',u'Spaces')),'count':totalspaces})

    if not ignoreviews:
        totalviews = getTotalCountForQuery(context,path,{'portal_type':'Topic'}) + getTotalCountForQuery(context,path,{'portal_type':'SmartView'})
        lstinfo.append({'id':'Collections','dispid':context.translate(_(u'lbl_stats_collections',u'Collections')),'count':totalviews})

    if not ignoretags:
        totaltags = getTotalCountForIndexType(context,path,'Subject')
        lstinfo.append({'id':'Tags','dispid':context.translate(_(u'lbl_stats_tags',u'Tags')),'count':totaltags})

    totalitems = getTotalCountForQuery(context,path,{'portal_type':spacesdefaultaddablenonfolderishtypes + ('StatuslogItem',)})
    lstinfo.append({'id':'Items','dispid':context.translate(_(u'lbl_stats_items',u'Items')),'count':totalitems})

    totalcomments = getTotalCountForQuery(context,path,{'portal_type':'Discussion Item'})
    lstinfo.append({'id':'Comments','dispid':context.translate(_(u'lbl_stats_comments',u'Comments')),'count':totalcomments})

    return lstinfo
 def creatediscussion(self):
     strDiscussion = ''
     strTags = ''
     discussiontitle = ''
     tagstitle = ''
     obj = None
     location = self.context
     is_discussiontitle_reqd = False
     strDiscussionTitle = ''
     
     portal_state = getMultiAdapter((self.context, self.request), name=u"plone_portal_state")
     cat = getToolByName(self.context, 'uid_catalog')
     portal = portal_state.portal()
     if self.request.has_key('com.cynapse.cynin.discussionmessageinput'):
         strDiscussion = self.request['com.cynapse.cynin.discussionmessageinput']
     if self.request.has_key('comcynapsediscussiontag'):
         strTags = self.request['comcynapsediscussiontag']
     if self.request.has_key('comcynapsediscussiontitle'):
         discussiontitle = self.request['comcynapsediscussiontitle']
     if self.request.has_key('comcynapsetagstitle'):
         tagstitle = self.request['comcynapsetagstitle']
     if self.request.has_key('comcynapseadddiscussioncontextuid'):
         locationuid = self.request['comcynapseadddiscussioncontextuid']
     else:
         locationuid = ''
         
     if self.request.has_key('com.cynapse.cynin.discussiontitle'):
         is_discussiontitle_reqd = True
         strDiscussionTitle = self.request['com.cynapse.cynin.discussiontitle']        
     
     query = {'UID':locationuid}
     resbrains = cat.searchResults(query)
     if len(resbrains) == 1:
         location = resbrains[0].getObject()
     
     if strDiscussion == '' or strDiscussion.lower() == discussiontitle.lower():            
         raise EmptydiscussionError, 'Unable to add discussion with blank text.'
     elif is_discussiontitle_reqd and (strDiscussionTitle == ''):
         raise EmptydiscussionError, 'Unable to add discussion with blank title.'
     else:
         from ubify.cyninv2theme import addDiscussion
         strActualTags = ''
         if strTags.lower() != tagstitle.lower():
             strActualTags = strTags
         obj = addDiscussion(portal,strDiscussion,strActualTags,location,strDiscussionTitle)
         if obj <> None:
             here_text = _(u'lbl_here',u'here')
             strlink = "<a href='%s'>%s</a>" % (obj.absolute_url(),self.context.translate(here_text),)
             return strlink
Beispiel #26
0
class ISmartView(Interface):    
                         
    title = schema.TextLine(title=_(u"Title"),
                            description=_(u"Name of the Advanced view"),
                            required=True)
                            
    description = schema.Text(title=_(u"Description"),
                              description=_(u"A short summary for the Advanced view"),
                              required=False)
    
    query = schema.Text(title=_(u"Custom Query"),
                              description=_("Custom query filter for representing data."),
                              required=True)
 def update(self):
     portal_state = getMultiAdapter((self.context, self.request),name=u'plone_portal_state')
     context_state = getMultiAdapter((self.context, self.request),name=u'plone_context_state')
     tools = getMultiAdapter((self.context, self.request), name=u'plone_tools')
     typetool= getToolByName(self.context, 'portal_types')
     portal_title = portal_state.portal_title()
     object_title = context_state.object_title()
     object_typename = self.context.portal_type
     object_typeobj = typetool[object_typename]
     self.typeiconname = object_typeobj.content_icon
     if object_typeobj.title == '' and self.context.portal_type.lower() == 'plone site':
         self.typetitle = plone_site_type_title
     else:
         self.typetitle = _(object_typeobj.title,object_typeobj.title)
     self.app_name = object_title
     if self.context.portal_type.lower() == 'plone site':
         self.tdescription = 'cyn.in site|A cyn.in site allows instant collaboration among peers and provides a central social computer and network.'
     else:
         self.tdescription = self.typetitle + '|' + object_typeobj.description
     self.isaddscreen = False
     if hasattr(context_state.parent(),'portal_type') and context_state.parent().portal_type == 'TempFolder':
         self.isaddscreen = True
    def update(self):
        menu = getUtility(IBrowserMenu, name='plone_contentmenu_factory')

        portal_state = getMultiAdapter((self.context, self.request),name=u'plone_portal_state')
        context_state = getMultiAdapter((self.context, self.request),name=u'plone_context_state')

        typetool= getToolByName(self.context, 'portal_types')

        object_typename = self.context.portal_type
        fti = getattr(typetool,'Plone Site')
        self.showsitehomemenu = False

        view = self.context.restrictedTraverse('@@plone')
        tabs = view.prepareObjectTabs()
        for eachtab in tabs:
            if eachtab['id'].lower() == 'edit' and eachtab['selected']:
                self.addnewitems = []
        
        available_appviews = []
        show_all_menu = False
        
        if self.context.hasProperty('availableappviews'):
            available_appviews = self.context.getProperty('availableappviews')
            
        if len(available_appviews) == 0:
            show_all_menu = True
            
        self.applications = []
        self.activitystream_item = {}
        self.dashboard_item = {}
        self.applicationviews = getAvailableAppViews(self.context)        
        
        for eachappview in self.applicationviews:
            if eachappview.id == 'activitystream':
                self.activitystream_item = {
                        'title':_(eachappview.title),
                        'id':eachappview.id,
                        'url':eachappview.url_expr.replace("string:",''),
                        'icon':eachappview.icon_expr.replace("string:",''),
                        'selected':False,
                        'visible':show_all_menu or eachappview.id in available_appviews,
                    }
            elif eachappview.id == 'dashboard':
                self.dashboard_item = {
                        'title':_(eachappview.title),
                        'id':eachappview.id,
                        'url':eachappview.url_expr.replace("string:",''),
                        'icon':eachappview.icon_expr.replace("string:",''),
                        'selected':False,
                        'visible':show_all_menu or eachappview.id in available_appviews,
                    }
            else:
                self.applications.append(
                    {
                        'title':_(eachappview.title),
                        'id':eachappview.id,
                        'url':eachappview.url_expr.replace("string:",''),
                        'icon':eachappview.icon_expr.replace("string:",''),
                        'selected':False,
                        'visible':show_all_menu or eachappview.id in available_appviews,
                    }
                )
        
        ##Decide what items to show in the Application menus, here::
        req = self.request
        last = req.physicalPathFromURL(req.getURL())[-1]
        res = [i for i in self.applications if i['url'] in last and i['url'] != '']
        self.lastpart = last
        self.dashboard_selected = False
        self.activitystream_selected = False
        
        if len(res)>0:
            selview = res[0]
            selview['selected'] = True
            self.selectedItem = selview            
        elif last in ('pastEvents','upcomingEvents'):
            calendar_applications = [k for k in self.applications if k['id'].lower() == u'calendar']
            if len(calendar_applications) > 0:
                selview = calendar_applications[0]
                selview['selected'] = True
                self.selectedItem = selview
            else:
                self.selectedItem = None
        elif last in ('placeful_workflow_configuration'):
            selview = {'title':'Workflow Policy','url':'placeful_workflow_configuration','icon':'icon-arrow_switch.png','selected':False,'visible':False,}
            self.selectedItem = selview
        elif last in ('home','dashboard'):
            self.dashboard_selected = True            
        elif last in ('app_all'):
            self.activitystream_selected = True            
        else:
            self.selectedItem = None

        
        
        self.ploneview = self.context.restrictedTraverse('@@plone');
        self.view_actions = self.ploneview.prepareObjectTabs();
        selected_views = [br for br in self.view_actions if br['selected']==True]
        if len(selected_views) > 0:
            self.manage_selectedItem = selected_views[0]
        else:
            self.manage_selectedItem = None

        if self.context.portal_type in ('ContentRoot','ContentSpace','MemberSpace','folderproj',):
            if self.context.portal_type in ('ContentRoot','MemberSpace',):
                ## Turn on Status Log view
                statuslogs = [k for k in self.applications if k['id'].lower() == 'statusmessage']                
                if len(statuslogs) > 0:
                    selview = statuslogs[0]
                    selview['visible'] = show_all_menu or selview['id'] in available_appviews
            plonecontentmenu = getUtility(IBrowserMenu,name='plone_contentmenu')
            menuitems = plonecontentmenu.getMenuItems(self.context,self.request)

            workflowMenuItem = [mi for mi in menuitems if mi.has_key('extra') and mi['extra'].has_key('state') and mi['extra'].has_key('stateTitle')]
            self.workflowmenuitems = None
            if len(workflowMenuItem) > 0:
                self.workflowmenuitems = workflowMenuItem[0]
                
        self.show_appview_nonselected = len([k for k in self.applications if k['visible']]) > 0
 def title(self):
     return _(u"Recent wiki pages")
import BTrees
import datetime
import calendar
from zope.component import queryMultiAdapter
from zope.contentprovider.interfaces import IContentProvider
from p4a.calendar import interfaces

from zope.i18n.locales import locales
from zope.i18n.interfaces import  IUserPreferredLanguages

from ubify.policy import CyninMessageFactory as _


DAYS = [
        _(u'Monday'),
        _(u'Tuesday'),
        _(u'Wednesday'),
        _(u'Thursday'),
        _(u'Friday'),
        _(u'Saturday'),
        _(u'Sunday'),
        ]

MONTHS = [
          _(u'N/A'),
          _(u'January'),
          _(u'February'),
          _(u'March'),
          _(u'April'),
          _(u'May'),
          _(u'June'),
 def title(self):
     return _(u"Recent images")
 def title(self):
     return _(u"Recent files")
    def fiddle(self,schema):

        if schema.has_key('location'):
            schema.changeSchemataForField('location', 'settings')
        if schema.has_key('language'):
            schema.changeSchemataForField('language', 'settings')
        if schema.has_key('rights'):
            schema.changeSchemataForField('rights', 'settings')
            schema['rights'].widget.visible = {'edit': 'invisible', 'view': 'visible'}

        fields = [i for i in schema.values() if isinstance(i,atapi.LinesField) and
                                       isinstance(i.widget, atapi.KeywordWidget)]

        for field in fields:
            oldlabel = content_categories_label_name
            olddesc  = field.widget.description
            field.widget = TagSuggestWidget(label=oldlabel,description = _(u'Enter comma (,) separated tags. Example: \"important, related to productx, basic, advanced\". If an autohint selection tip appears, press tab to select the first one, or type further to shorten the hint list.'),role_based_add = True)

        if schema.has_key('contributors'):
            schema['contributors'].widget.visible = {'edit': 'invisible', 'view': 'visible'}

        if schema.has_key('creators'):
            schema['creators'].widget.visible = {'edit': 'invisible', 'view': 'visible'}

        if schema.has_key('tableContents'):
            schema['tableContents'].default = 1;

        if schema.has_key('excludeFromNav'):
            schema['excludeFromNav'].widget.visible = {'edit': 'invisible', 'view': 'visible'}

        if schema.has_key('location') and self.context.portal_type != 'Event':
            schema['location'].widget.label = content_location_label_name

        if self.context.portal_type == 'Blog Entry':
            if schema.has_key('image'):
                schema['image'].widget.visible = {'edit': 'invisible', 'view': 'visible'}
            if schema.has_key('imageCaption'):
                schema['imageCaption'].widget.visible = {'edit': 'invisible', 'view': 'visible'}

        if schema.has_key('eventType'):
            schema.changeSchemataForField('eventType', 'categorization')
            schema.moveField('eventType', before='relatedItems')

        if schema.has_key('remoteUrl'):
            schema['remoteUrl'].widget.maxlength = False

        if self.context.portal_type in ('ContentSpace','MemberSpace','ContentRoot') and schema.has_key('allowDiscussion'):
            schema['allowDiscussion'].widget.visible = {'edit': 'invisible', 'view': 'visible'}
            
        if self.context.portal_type in ('ContentSpace','ContentRoot'):
            if schema.has_key('effectiveDate'):
                schema['effectiveDate'].widget.visible = {'edit': 'invisible', 'view': 'visible'}
            if schema.has_key('expirationDate'):
                schema['expirationDate'].widget.visible = {'edit': 'invisible', 'view': 'visible'}
            if schema.has_key('location'):
                schema['location'].widget.visible = {'edit': 'invisible', 'view': 'visible'}
            if schema.has_key('language'):
                schema['language'].widget.visible = {'edit': 'invisible', 'view': 'visible'}
            
        if self.context.portal_type in ('Discussion',):
            try:
                portal_url = getToolByName(self.context,'portal_url')
                if portal_url <> None:                    
                    portal = portal_url.getPortalObject()
                    if portal <> None:
                        portal_prop = portal.portal_properties
                        if hasattr(portal_prop,'site_properties'):
                            site_prop = getattr(portal_prop,'site_properties')
                            if hasattr(site_prop,'allow_discussion_title') and getattr(site_prop,'allow_discussion_title') == True:                        
                                if schema['title'] <> None and schema['title'].widget <> None:
                                    schema["title"].widget.visible = {"edit": "visible", "view": "invisible"}
                                    schema['title'].required = True
            except:
                pass
#
#You can also contact Cynapse at:
#802, Building No. 1,
#Dheeraj Sagar, Malad(W)
#Mumbai-400064, India
###############################################################################
from zope.interface import implements

from zope.component.factory import Factory

from plone.locking.interfaces import ITTWLockable
from plone.app.content.interfaces import INameFromTitle
from plone.app.content.container import Container
from Products.ATContentTypes.content.folder import ATFolder

from ubify.policy import CyninMessageFactory as _
from ubify.smartview.interfaces import ISmartView

class SmartView(ATFolder):
    implements(ISmartView, ITTWLockable, INameFromTitle)
    portal_type = "SmartView"
    
    title = u""
    description = u""
    query = u""
    
    def __init__(self, id=None):
        super(SmartView, self).__init__(id)        
    
smartviewFactory = Factory(SmartView, title=_(u"Create a new Advanced View"))
 def title(self):
     return _(u"Recent events")
 def title(self):
     return _(u"Recent files")
 def title(self):
     return _(u"My Items")
Beispiel #38
0
def getAppTitleForContext(context):
    tempid = _(u"activity_stream",u"Activity Stream")
    ptype = context.portal_type
    if ptype == 'Document':
        tempid = _(u"wiki",u"Wiki")
    elif ptype == 'File':
        tempid = _(u"files",u"Files")
    elif ptype == 'Image':
        tempid = _(u"images",u"Images")
    elif ptype == 'Link':
        tempid = _(u"links",u"Links")
    elif ptype == 'Blog Entry':
        tempid = _(u"blogs",u"Blogs")
    elif ptype == 'Event':
        tempid = _(u"calendar",u"Calendar")
    elif ptype == 'StatuslogItem':
        tempid = _(u"statuslog",u"Status Log")
    elif ptype == 'Video':
        tempid = _(u"videos",u"Videos")
    elif ptype == 'Discussion':
        tempid = _(u"Discussions",u"Discussions")
    elif ptype == 'Audio':
        tempid = _(u"Audios",u"Audios")

    return tempid
Beispiel #39
0
class IRecentSiteUpdatesPortlet(IPortletDataProvider):

    count = schema.Int(title=_(u'Number of items to display'),
                       description=_(u'How many items to list?'),
                       required=True,
                       default=10)
Beispiel #40
0
    strErrorMessage = ""
    ilen = len(mdatas)
    if ilen > 1:
        for ival in range(1,ilen):
            try:
                performCheck(context,mdatas[ival - 1])
            except PasteError, msg:
                strErrorMessage = strErrorMessage + msg + " "
    elif ilen == 1:
        try:
            performCheck(context,mdatas[ilen - 1])
        except PasteError, msg:
            strErrorMessage = strErrorMessage + msg + " "

    if strErrorMessage <> "":
        strErrorMessage = _(u"error_cannot_paste",u"Cannot paste Folders between different applications.Disallowed to paste item(s).")
        raise PasteError,strErrorMessage

def performCheck(context,mdata):
    strURL = "/".join(mdata)

    rootObject = context.portal_url.getPortalObject()
    copiedObject = rootObject.restrictedTraverse(strURL)
    if copiedObject.portal_type == 'Folder':
        parentObject = copiedObject.getParentNode()
        try:
            getApplication(copiedObject,context,rootObject)
        except PasteError, msg:
            raise PasteError,msg

def getApplication(source,dest,root):
 def title(self):
     return _(u"Space Members in role " + self.role)
def getjsondata(context,records=10,type=None):
    site_encoding = context.plone_utils.getSiteEncoding()
    strpath = "/".join(context.getPhysicalPath())
    portal = context.portal_url.getPortalObject()
    
    try:
        from ubify.policy.config import contentroot_details
        rootid = contentroot_details['id']                
        objRoot = getattr(portal,rootid)
        if context == objRoot:
            strpath = "/".join(portal.getPhysicalPath())            
        else:
            strpath = "/".join(context.getPhysicalPath())            
    except AttributeError:
        strpath = "/".join(context.getPhysicalPath())
        
    if type is None:
        raise "No chart type was passed"
    elif type.lower() == "topcontributors":
        chart = template('')
        plot = HBar()
        results = getTopContributors(context,strpath)[:records]
        results.sort(lambda x,y: cmp(x['count'],y['count']),reverse=True)
        objvalues = [k['count'] for k in results if k['count'] > 0]

        users = [j['userid'] for j in results if j['count'] > 0]
        users.reverse()

        xlabels = x_axis_labels()
        xlabels.set_colour("#666666")
        chartsteps = 1.0
        if len(objvalues) > 0:
            chartsteps = getchartsteps(objvalues[-1],objvalues[0])
        chart.set_x_axis(offset = False, labels = xlabels,steps = chartsteps,colour="#cccccc",grid_colour="#f1f1f1")
        chart.set_y_axis(offset=True,labels = users,colour="#666666",grid_colour="#f1f1f1")

        for val in objvalues:
            #plot.append_values(hbar_value((0, val), tooltip = '#right# contributions', colour = '#4092D8'))
            plot.append_values(
                               hbar_value((0, val), 
                               tooltip = '#right# %s' % (context.translate(_(u'lbl_stats_tooltip_contributions',u'contributions'))),
                               colour = '#4092D8')
            )
        chart.add_element(plot)
        chart.set_tooltip(stroke=1,colour="#1f1f1f",bg_colour="#292929",title_style="font-size:12px;color:#ffffff;font-weight:bold",body_style="font-size:12px;color:#ffffff",behaviour="hover")

        chart.set_bg_colour("#FFFFFF")
        return chart.encode()

    elif type.lower() == "topcommenters":
        chart = template('')
        plot = HBar()
        results = getTopCommenter(context,strpath)[:records]
        results.sort(lambda x,y: cmp(x['count'],y['count']),reverse=True)
        objvalues = [k['count'] for k in results if k['count'] > 0]

        users = [j['userid'] for j in results if j['count'] > 0]
        users.reverse()

        xlabels = x_axis_labels()
        xlabels.set_colour("#666666")
        chartsteps = 1.0
        if len(objvalues) > 0:
            chartsteps = getchartsteps(objvalues[-1],objvalues[0])
        chart.set_x_axis(offset = False, labels = xlabels,steps = chartsteps,colour="#cccccc",grid_colour="#f1f1f1")
        chart.set_y_axis(offset=True,labels = users,colour="#666666",grid_colour="#f1f1f1")
        
        for val in objvalues:
            #plot.append_values(hbar_value((0, val), tooltip = '#right# comments', colour = '#57AC0B'))
            #if len(val) == 1:
            #   tooltip_comment = '#right# %s' % (context.translate(_(u'lbl_stats_tooltip_comment',u'comment'))),
            #if len(val) > 1:
            #   tooltip_comment = '#right# %s' % (context.translate(_(u'lbl_stats_tooltip_comments',u'comments'))),
            plot.append_values(
                               hbar_value((0, val), 
                                          #tooltip = '#right# %s' % (tooltip_comment),                                             
                                          tooltip = '#right# %s' % (context.translate(_(u'lbl_stats_tooltip_comments',u'comments'))),
                                          colour = '#57AC0B')
            )
        chart.add_element(plot)
        chart.set_tooltip(stroke=1,colour="#1f1f1f",bg_colour="#292929",title_style="font-size:12px;color:#ffffff;font-weight:bold",body_style="font-size:12px;color:#ffffff",behaviour="hover")

        chart.set_bg_colour("#FFFFFF")
        return chart.encode()

    elif type.lower() == "contentstats":
        #For pie chart
        results = [k for k in getContentItemsCount(context,strpath) if k['count'] > 0]
        results.sort(lambda x,y: cmp(x['count'],y['count']),reverse=True)

        chart = template('')
        plot = Pie(start_angle = 35, animate = True, values = [pie_value(val = k['count'],label = (k['id'],None, None)) for k in results],colours = ['#4092D8', '#57AC0B', '#CC0000', '#862DFF', '#FF6600',  '#00FFF6','#FF37D2', '#5251ff', '#F0EA80', '#abff00',], label_colour = '#666666')
#        plot.set_tooltip('#label#: #val# of #total#<br>#percent# of 100%')
#        plot = Pie(
#		start_angle = 35, 
#		animate = True, 
#		values = [pie_value(val = k['count'],
#		label = (k['id'],None, None)) for k in results],
#		colours = ['#4092D8', '#57AC0B', '#CC0000', '#862DFF', '#FF6600', '#00FFF6','#FF37D2', '#5251ff', '#F0EA80', '#abff00',], 
#		label_colour = '#666666'
#	)
        msg = '#label#: #val# %s #total#<br>#percent# %s' % (context.translate(_(u'lbl_stats_val_of_total',u'of')),
                                                             context.translate(_(u'lbl_stats_val_of_100',u'of 100%'))
                                                            )
        plot.set_tooltip(msg)
        plot.set_gradient_fill(True)
        plot.set_no_labels(False)

        chart.add_element(plot)
        chart.set_tooltip(stroke=1,colour="#1f1f1f",bg_colour="#292929",title_style="font-size:12px;color:#ffffff;font-weight:bold",body_style="font-size:12px;color:#ffffff",behaviour="hover")
        chart.set_bg_colour("#FFFFFF")
        return chart.encode()

    else:
        raise "Unknown chart type was passed"
class EditForm(base.EditForm):
    form_fields = form.Fields(IFilesPortlet)
    label = _(u"Edit Files Portlet")
    description = _(u"This portlet displays recently modified files.")
 def title(self):
     return _(u"Top Rated")
from Acquisition import aq_base, aq_inner, aq_parent
from ubify.coretypes.config import *
from AccessControl import ModuleSecurityInfo
from ubify.spaces.config import PLACEFUL_WORKFLOW_POLICY,SPACE_PLACEFUL_WORKFLOW_POLICY
from ubify.policy import CyninMessageFactory as _
from ubify.cyninv2theme import getAdminUser, getCurrentUser

#constants defined for lastchangeaction
last_change_action_add = 'created'
last_change_action_edit = 'modified'
last_change_action_workflowstate_change = 'workflowstatechanged'
last_change_action_comment = 'commented'


last_change_action_mapping = {
                                last_change_action_add : _(u'last_change_created',u'created'),
                                last_change_action_edit : _(u'last_change_edited','edited'),
                                last_change_action_workflowstate_change : _(u'last_change_workflowed','workflowed'),
                                last_change_action_comment : _(u'last_change_discussed','discussed'),
}

def initialize(context):

    import ubify.coretypes.content
    from Products.ATContentTypes.permission import permissions

    content_types, constructors, ftis = process_types(
        listTypes(PROJECTNAME), PROJECTNAME)

    allTypes = zip(content_types, constructors)
def renameScrawl(portal_types):
    blog_fti = getattr(portal_types, 'Blog Entry')
    blog_fti.title = 'Blog Post'
    blog_fti.description = _(u"Formatted temporal content",u"Formatted temporal content")
    blog_fti.icon_expr = 'string:$portal_url/blog.png'
    blog_fti.global_allow = True
Beispiel #47
0
class EditForm(base.EditForm):
    form_fields = form.Fields(IRecentUpdatesPortlet)
    label = _(u"Edit Recent Updates Portlet")
    description = _(u"This portlet displays recently modified items.")
 def title(self):
     return _(u"Recent Comments")
Beispiel #49
0
class EditForm(base.EditForm):
    form_fields = form.Fields(IRecentSiteUpdatesPortlet)
    label = _(u"Edit Recent Site Updates Portlet")
    description = _(
        u"A portlet that renders a list of recent content of all types from within the context of the space and all contained spaces."
    )
 def title(self):
     return _(u"Recent blog posts")
Beispiel #51
0
 def title(self):
     return _(u"Recent Site Updates")
 def title(self):
     return _(u"Recent Updates")