Example #1
0
class ApplicationGroup(group.Group):
    """
    Fieldset for application settings.
    """

    label = _(u'Application')
    fields = field.Fields(IFacebookSettings).select('app_id')
Example #2
0
class PostToPageGroup(group.Group):
    """
    Fieldset for post-to-page settings.
    """

    label = _(u'Post to Page')
    fields = field.Fields(IFacebookSettings).select('post_to_page_available',
                                                    'page_id')
    fields['post_to_page_available'].widgetFactory = SingleCheckBoxFieldWidget
    def __call__(self):

        # Decide whether we are enabling or disabling based on the request.
        enable = self.request.get("enable", False)
        settings = self._get_settings()

        if enable:
            if ILikeButtonDisabled.providedBy(self.context):
                noLongerProvides(self.context, ILikeButtonDisabled)
            if not self.context.portal_type in settings.like_button_types:
                alsoProvides(self.context, ILikeButtonEnabled)
            IStatusMessage(self.request).addStatusMessage(_(u"Like button enabled."), type="info")
        else:
            if ILikeButtonEnabled.providedBy(self.context):
                noLongerProvides(self.context, ILikeButtonEnabled)
            if self.context.portal_type in settings.like_button_types:
                alsoProvides(self.context, ILikeButtonDisabled)
            IStatusMessage(self.request).addStatusMessage(_(u"Like button disabled."), type="info")

        return self.request.RESPONSE.redirect(self.context.absolute_url())
 def render(self):
     # make sure application ID is configured
     pprop = getToolByName(self.context, 'portal_properties')
     app_id = getattr(pprop.fb_properties, 'app_id', None)
     if not app_id:
         portal_url = getToolByName(self.context, 'portal_url')()
         IStatusMessage(self.request).addStatusMessage(_(u'You must configure your '
             u'Facebook Application ID before you can add a Feed Form portlet.'))
         return self.request.RESPONSE.redirect(portal_url + '/@@facebook-settings')
     
     return base.AddForm.render(self)
Example #5
0
class FacebookSettingsForm(group.GroupForm, form.EditForm):
    """
    Form for the campaign configlet.
    """

    label = _(u'Facebook Configuration')
    groups = (
        ApplicationGroup,
        PostToPageGroup,
        LikeButtonGroup,
    )
Example #6
0
class LikeButtonGroup(group.Group):
    """
    Fieldset for Like button settings.
    """

    label = _(u'Like Button')
    fields = field.Fields(IFacebookSettings).select(
        'like_button_available', 'like_button_types', 'like_button_layout',
        'like_button_show_faces', 'like_button_width', 'like_button_action',
        'like_button_font', 'like_button_color_scheme', 'like_button_ref')
    fields['like_button_available'].widgetFactory = SingleCheckBoxFieldWidget
    fields['like_button_types'].widgetFactory = CheckBoxFieldWidget
    fields['like_button_show_faces'].widgetFactory = SingleCheckBoxFieldWidget
    def __call__(self):

        # Decide whether we are enabling or disabling based on the request.
        enable = self.request.get('enable', False)
        settings = self._get_settings()

        if enable:
            if ILikeButtonDisabled.providedBy(self.context):
                noLongerProvides(self.context, ILikeButtonDisabled)
            if not self.context.portal_type in settings.like_button_types:
                alsoProvides(self.context, ILikeButtonEnabled)
            IStatusMessage(self.request).addStatusMessage(
                _(u'Like button enabled.'), type='info')
        else:
            if ILikeButtonEnabled.providedBy(self.context):
                noLongerProvides(self.context, ILikeButtonEnabled)
            if self.context.portal_type in settings.like_button_types:
                alsoProvides(self.context, ILikeButtonDisabled)
            IStatusMessage(self.request).addStatusMessage(
                _(u'Like button disabled.'), type='info')

        return self.request.RESPONSE.redirect(self.context.absolute_url())
    def render(self):
        # make sure application ID is configured
        pprop = getToolByName(self.context, 'portal_properties')
        app_id = getattr(pprop.fb_properties, 'app_id', None)
        if not app_id:
            portal_url = getToolByName(self.context, 'portal_url')()
            IStatusMessage(self.request).addStatusMessage(
                _(u'You must configure your '
                  u'Facebook Application ID before you can add a Feed Form portlet.'
                  ))
            return self.request.RESPONSE.redirect(portal_url +
                                                  '/@@facebook-settings')

        return base.AddForm.render(self)
def fanbox_10_to_14(setup_tool):
    """
    Updates the installed profiles to reflect new configuration defaults.
    """
    
    # If the fbconnect profile isn't already installed, install it.
    fbconnect_profile = 'profile-collective.simplesocial:fbconnect'
    if not setup_tool.getProfileImportDate(fbconnect_profile):
        setup_tool.runAllImportStepsFromProfile(fbconnect_profile)
        IStatusMessage(setup_tool.REQUEST).addStatusMessage(
            _(u'The Facebook Like Box portlet now requires a Facebook application.' +
            ' Please visit the Facebook Settings control panel to configure one.')
        )

    portlet_name = 'collective.simplesocial.fanbox.FacebookFanBox'
    portlet = getUtility(IPortletType, name=portlet_name)
    portlet.title = 'Facebook Like Box'
Example #10
0
def fanbox_10_to_14(setup_tool):
    """
    Updates the installed profiles to reflect new configuration defaults.
    """

    # If the fbconnect profile isn't already installed, install it.
    fbconnect_profile = 'profile-collective.simplesocial:fbconnect'
    if not setup_tool.getProfileImportDate(fbconnect_profile):
        setup_tool.runAllImportStepsFromProfile(fbconnect_profile)
        IStatusMessage(setup_tool.REQUEST).addStatusMessage(
            _(u'The Facebook Like Box portlet now requires a Facebook application.'
              +
              ' Please visit the Facebook Settings control panel to configure one.'
              ))

    portlet_name = 'collective.simplesocial.fanbox.FacebookFanBox'
    portlet = getUtility(IPortletType, name=portlet_name)
    portlet.title = 'Facebook Like Box'
class IFacebookFeedForm(IPortletDataProvider):
    """A portlet

    It inherits from IPortletDataProvider because for this portlet, the
    data that is being rendered and the portlet assignment itself are the
    same.
    """

    action_title = schema.TextLine(
        title=_(u'Action Title'),
        description=_(
            u"A one-line message describing an action the user took. "
            u"The user's name and a space will be added at the beginning."),
        default=_(u'took an action.'))

    user_message_prompt = schema.TextLine(
        title=_(u'User Prompt'),
        description=_(
            u'This message will be displayed to the user, prompting them to '
            u'publish a message to their feed.'),
        default=_(u'Please consider sharing with your friends.'),
        required=False,
    )

    action_link_text = schema.TextLine(
        title=_(u'Action Link Text'),
        description=_(
            u'Text of a link which will be shown after the feed post. Optional.'
        ),
        required=False,
        missing_value=u'',
    )

    action_link_href = schema.TextLine(
        title=_(u'Action Link URL'),
        description=_(
            u'URL target of the action link shown after the feed post.'),
        required=False,
        missing_value=u'',
    )

    availability = schema.Choice(
        title=_(u'Feed Form Availability'),
        description=_(u'Choose when to show the feed form.'),
        vocabulary=SimpleVocabulary.fromItems([
            (u'Every time the item is viewed', u'view'),
            (u'Every time the item is saved', u'modified'),
        ]),
        default=u'view')
class IFacebookSettings(Interface):

    app_id = schema.TextLine(
        title=_(u'Application ID'),
        description=_(u'Enter the application ID for your'
                      u' Facebook application.'),
    )

    post_to_page_available = schema.Bool(
        title=_(u"Allow site managers to post updates to a"
                u" Facebook Page"),
        default=True,
    )

    page_id = schema.ASCIILine(
        title=_(u'Page'),
        description=_(u"Select the Facebook Page you want to post to."),
        required=False,
    )

    like_button_available = schema.Bool(
        title=_(u"Display Like buttons on this site"),
        default=True,
    )

    like_button_types = schema.List(
        title=_(u'Content Types'),
        description=_(u"Display Like buttons on these content types"
                      u" by default."),
        value_type=schema.Choice(
            vocabulary='plone.app.vocabularies.ReallyUserFriendlyTypes', ),
        default=['Document', 'Event', 'News Item'],
    )

    like_button_layout = schema.Choice(
        title=_(u'Layout'),
        vocabulary=SimpleVocabulary.fromItems([
            (_(u'Standard'), u'standard'),
            (_(u'Button Count'), u'button_count'),
            (_(u'Box Count'), u'box_count'),
        ]),
        default=u'standard',
    )

    like_button_show_faces = schema.Bool(
        title=_(u"Show Faces"),
        description=_(u"Display profile pictures beneath the Like button."),
        default=True,
    )

    like_button_width = schema.Int(
        title=_(u'Width'),
        description=_(u"Enter the width of the Like button area in pixels."),
        default=450,
    )

    like_button_action = schema.Choice(
        title=_(u'Action'),
        description=_(u'Choose the verb to be displayed in the Like button.'),
        vocabulary=SimpleVocabulary.fromItems([
            (_(u'Like'), u'like'),
            (_(u'Recommend'), u'recommend'),
        ]),
        default=u'like',
    )

    like_button_font = schema.Choice(
        title=_(u'Font'),
        vocabulary=SimpleVocabulary.fromItems([
            (_(u'Default'), u''),
            (_(u'Arial'), u'arial'),
            (_(u'Lucida Grande'), u'lucida grande'),
            (_(u'Segoe UI'), u'segoe ui'),
            (_(u'Tahoma'), u'tahoma'),
            (_(u'Trebuchet MS'), u'trebuchet ms'),
            (_(u'Verdana'), u'verdana'),
        ]),
        default=u'',
    )

    like_button_color_scheme = schema.Choice(
        title=_(u'Color Scheme'),
        vocabulary=SimpleVocabulary.fromItems([
            (_(u'Light'), u'light'),
            (_(u'Dark'), u'dark'),
        ]),
        default=u'light',
    )

    like_button_ref = schema.ASCIILine(
        title=_(u'Referral Label'),
        max_length=49,
        description=_(u'To track referrals from Facebook, enter the value'
                      u' that will be used for the fb_ref parameter.'),
        required=False,
    )
class IFacebookFanBox(IPortletDataProvider):
    """A portlet

    It inherits from IPortletDataProvider because for this portlet, the
    data that is being rendered and the portlet assignment itself are the
    same.
    """

    href = schema.TextLine(
        title=_(u'Facebook Page URL'),
        description=_(u'Enter the URL of the Facebook page.'),
    )

    width = schema.Int(
        title=_(u'Width'),
        description=_(u'Enter the width of the box in pixels.'),
        min=0,
        default=200,
    )

    height = schema.Int(
        title=_(u'Height'),
        description=_(u'Enter the height of the box in pixels, or leave this'
                      u' field blank for automatic sizing.'),
        min=0,
        required=False,
    )

    colorscheme = schema.Choice(
        title=_(u'Color Scheme'),
        vocabulary=SimpleVocabulary.fromItems([
            (_(u'Light'), u'light'),
            (_(u'Dark'), u'dark'),
        ]),
        default=u'light',
    )

    show_faces = schema.Bool(
        title=_(u'Display faces'),
        description=_(
            u'Displays profile pictures of users who like the page.'),
        default=True,
    )

    show_stream = schema.Bool(
        title=_(u'Display stream'),
        description=_(u'Displays the public activity stream for the page.'),
        default=True,
    )

    show_header = schema.Bool(
        title=_(u'Display header'),
        description=_(u'Displays the header "Find us on Facebook."'),
        default=True,
    )