def update(self):
        super(SubsiteLogoViewlet, self).update()

        navroot = api.portal.get_navigation_root(self.context)
        is_subsite = bool(navroot.portal_type == 'ftw.subsite.Subsite')

        self.navigation_root_url = self.portal_state.navigation_root_url()

        subsite_logo = getattr(navroot, 'logo', None)
        subsite_logo_alt_text = getattr(navroot, 'logo_alt_text', None)

        if is_subsite and subsite_logo and subsite_logo.data:
            # we are in a subsite
            context = self.context
            if not IContentish.providedBy(context):
                context = context.aq_parent
            navigation_root_path = getNavigationRoot(context)
            scale = navroot.restrictedTraverse(
                navigation_root_path + '/@@images')

            self.logo_tag = scale.scale('logo', scale="logo").tag(
                alt=subsite_logo_alt_text, title=None)
            self.title = self.context.restrictedTraverse(
                getNavigationRoot(self.context)).Title()
            self.is_subsitelogo = True
        else:
            # standard plone logo
            portal = api.portal.get()
            logoName = navroot.restrictedTraverse('base_properties').logoName
            logo_alt_text = portal.getProperty('logo_alt_text', '')
            self.logo_tag = portal.restrictedTraverse(logoName).tag(
                alt=logo_alt_text, title='')
            self.title = self.portal_state.portal_title()
Beispiel #2
0
    def update(self):
        super(SubsiteLogoViewlet, self).update()

        portal = self.portal_state.portal()
        self.navigation_root_url = self.portal_state.navigation_root_url()

        subsite_logo = getattr(self.context, 'logo', None)
        subsite_logo_alt_text = getattr(self.context, 'logo_alt_text', None)

        if subsite_logo and subsite_logo.data:
            # we are in a subsite
            context = self.context
            if not IContentish.providedBy(context):
                context = context.aq_parent
            navigation_root_path = getNavigationRoot(context)
            scale = portal.restrictedTraverse(navigation_root_path +
                                              '/@@images')

            self.logo_tag = scale.scale('logo', scale="logo").tag(
                alt=subsite_logo_alt_text, title=None)
            self.title = self.context.restrictedTraverse(
                getNavigationRoot(self.context)).Title()
            self.is_subsitelogo = True
        else:
            # standard plone logo
            logoName = portal.restrictedTraverse('base_properties').logoName
            logo_alt_text = portal.getProperty('logo_alt_text', '')
            self.logo_tag = portal.restrictedTraverse(logoName).tag(
                alt=logo_alt_text, title='')
            self.title = self.portal_state.portal_title()
Beispiel #3
0
    def subsite_logo_behaviour(self):
        # Copy of ftw.subsite.viewlets.subsitelogoviewlet
        nav_root = api.portal.get_navigation_root(self.context)
        nav_root_title = nav_root.Title()
        self.navigation_root_url = nav_root.absolute_url()

        if IBaseObject.providedBy(nav_root):
            subsite_logo = nav_root.getLogo()
            subsite_logo_alt_text = nav_root_title

        else:
            subsite_logo = getattr(self.context, 'logo', None)
            subsite_logo_alt_text = getattr(self.context, 'logo_alt_text',
                                            None)

        if subsite_logo and subsite_logo.data:
            # we are in a subsite
            context = self.context
            if not IContentish.providedBy(context):
                context = context.aq_parent
            scale = nav_root.restrictedTraverse('@@images')

            self.logo_tag = scale.scale('logo', scale="logo").tag(
                alt=subsite_logo_alt_text, title=None)
            self.title = nav_root_title
        else:
            # onegov default
            self.onegov_logo_behaviour()
Beispiel #4
0
    def subsite_logo_behaviour(self):
        # Copy of ftw.subsite.viewlets.subsitelogoviewlet
        nav_root = api.portal.get_navigation_root(self.context)
        nav_root_title = nav_root.Title()
        self.navigation_root_url = nav_root.absolute_url()

        if IBaseObject.providedBy(nav_root):
            subsite_logo = nav_root.getLogo()
            subsite_logo_alt_text = nav_root_title

        else:
            subsite_logo = getattr(self.context, 'logo', None)
            subsite_logo_alt_text = getattr(self.context,
                                            'logo_alt_text',
                                            None)

        if subsite_logo and subsite_logo.data:
            # we are in a subsite
            context = self.context
            if not IContentish.providedBy(context):
                context = context.aq_parent
            scale = nav_root.restrictedTraverse('@@images')

            self.logo_tag = scale.scale('logo', scale="logo").tag(
                alt=subsite_logo_alt_text, title=None)
            self.title = nav_root_title
        else:
            # onegov default
            self.onegov_logo_behaviour()
    def add(self):
        request = self.request
        view = request.get('view', '')
        portal = getToolByName(self.context, 'portal_url').getPortalObject()
        site = getNavigationRootObject(self.context, portal)
        ISuggestionsStorage(site).add_suggestion(
                id=IUUID(self.context),
                type='uid',
                view=view,
                date=datetime.now())

        if IFolderish.providedBy(self.context):
            IStatusMessage(self.request).addStatusMessage(
                        _("The folder has been added to suggestions"))
        elif IContentish.providedBy(self.context):
            IStatusMessage(self.request).addStatusMessage(
                        _("The document has been added to suggestions"))
        else:
            IStatusMessage(self.request).addStatusMessage(
                        _("The element has been added to suggestions"))

        self.request.response.redirect(self.context.absolute_url() + '/' + view)
 def allowed(self):
     context_state = getMultiAdapter((self.context, self.request), name="plone_context_state")
     folder = context_state.folder()
     return IContentish.providedBy(folder)