def __call__(self, context):
     
     terms = [SimpleTerm(u'subtree', _(u'...to the whole subtree')),
              SimpleTerm(u'context', _(u'...only to the context')),
              SimpleTerm(u'context_and_children', _(u'...to the context and non-folderish children')),
              ]
     return SimpleVocabulary(terms)
 def __call__(self, context):
     
     terms = [SimpleTerm(u'header', u'header', _('position_header',
                                                   default=u'...in the header of the page')),
              SimpleTerm(u'footer', u'footer', _('position_footer',
                           default=u'...in the footer of the page')),
              ]
     return SimpleVocabulary(terms)
class IErrorCodeValuePair(Interface):
    message = schema.ASCIILine(title=_(u"Error message"), required=True)
    message_snippet = schema.SourceText(title=_(u"Code to include"),
                                        required=False)
    position = schema.Choice(
        title=_(u"Include code in..."),
        required=True,
        default=u'footer',
        vocabulary=u"collective.analyticspanel.vocabularies.positions")
예제 #4
0
    def __call__(self, context):

        terms = [
            SimpleTerm(u'subtree', _(u'...to the whole subtree')),
            SimpleTerm(u'context', _(u'...only to the context')),
            SimpleTerm(u'context_and_children',
                       _(u'...to the context and non-folderish children')),
        ]
        return SimpleVocabulary(terms)
 def __call__(self, context):
     
     terms = [SimpleTerm(u'subtree', u'subtree', _('scope_whole_subtree',
                                                   default=u'...to the whole subtree')),
              SimpleTerm(u'context', u'context', _('scope_context_only',
                                                   default=u'...only to the context')),
              SimpleTerm(u'context_and_children', u'context_and_children',
                         _('scope_context_and_not_folderish',
                           default=u'...to the context and non-folderish children')),
              ]
     return SimpleVocabulary(terms)
    def __call__(self, context):

        terms = [
            SimpleTerm(
                u'header', u'header',
                _('position_header', default=u'...in the header of the page')),
            SimpleTerm(
                u'footer', u'footer',
                _('position_footer', default=u'...in the footer of the page')),
        ]
        return SimpleVocabulary(terms)
예제 #7
0
class IAnalyticsAdvancedSettings(Interface):
    """Settings used in the control panel for analyticspanel: advanced panel
    """

    folderish_types = schema.Tuple(
            title=_(u"Folderish types"),
            description=_("help_folderish_types",
                          default=u'Defines there which portal types must be treat as "folderish"'),
            required=False,
            value_type=FOLDER_TYPES_VALUESTYPE,
            default=(u'Folder',),
    )
    def __call__(self, context):

        terms = [
            SimpleTerm(
                u'subtree', u'subtree',
                _('scope_whole_subtree', default=u'...to the whole subtree')),
            SimpleTerm(
                u'context', u'context',
                _('scope_context_only', default=u'...only to the context')),
            SimpleTerm(
                u'context_and_children', u'context_and_children',
                _('scope_context_and_not_folderish',
                  default=u'...to the context and non-folderish children')),
        ]
        return SimpleVocabulary(terms)
 def handleCancel(self, action):
     IStatusMessage(self.request).addStatusMessage(
         _(u"Edit cancelled"), "info"
     )
     self.request.response.redirect(
         "%s/%s" % (self.context.absolute_url(), self.control_panel_view)
     )
예제 #10
0
class ISitePathValuePair(Interface):
    path = schema.TextLine(title=_(u"Site path"), required=True)
    path_snippet = schema.SourceText(title=_(u"Code to include"),
                                     required=False)
    apply_to = schema.Choice(
        title=_(u"Apply rule to..."),
        description=_(
            'help_apply_to',
            default=u'Choose a policy for applying this rule.\n'
            u'When using "context and children" note that the rule will be '
            u'applied to the context and all non-folderish children.\n'
            u'This make sense only with folderish context.\n'
            u'See "Advanced settings" section for defining what is a folder '
            u'for your site.'),
        required=True,
        default=u'subtree',
        vocabulary=u"collective.analyticspanel.vocabularies.apply_to_choices")
 def handleSave(self, action):
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     changes = self.applyChanges(data)
     IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"),
                                                   "info")
     self.context.REQUEST.RESPONSE.redirect("@@analytics-settings")
예제 #12
0
 def handleSave(self, action):
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     changes = self.applyChanges(data)
     IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"),
                                                   "info")
     self.context.REQUEST.RESPONSE.redirect("@@analytics-settings")
예제 #13
0
class AnalyticsSettingsEditForm(controlpanel.RegistryEditForm):
    """Media settings form.
    """
    schema = IAnalyticsSettingsSchema
    fields = field.Fields(IAnalyticsSettings)
    groups = (FormAdvanced, )
    id = "AnalyticsSettingsEditForm"
    label = _(u"Analytics settings")
    description = _(
        u"help_analytics_settings_editform",
        default=
        u"Manage JavaScript code and analytics snippets inclusion for the site"
    )

    @button.buttonAndHandler(_('Save'), name='save')
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return
        changes = self.applyChanges(data)
        IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"),
                                                      "info")
        self.context.REQUEST.RESPONSE.redirect("@@analytics-settings")

    @button.buttonAndHandler(_('Cancel'), name='cancel')
    def handleCancel(self, action):
        IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled"),
                                                      "info")
        self.request.response.redirect(
            "%s/%s" % (self.context.absolute_url(), self.control_panel_view))

    def updateWidgets(self):
        super(AnalyticsSettingsEditForm, self).updateWidgets()
        fix_widget_style(self.widgets['general_code'])
        fix_widget_style(self.widgets['general_header_code'])
        for main_widget in self.widgets['error_specific_code'].widgets:
            error_widgets = main_widget.subform.widgets
            fix_widget_style(error_widgets['message_snippet'])
        for main_widget in self.widgets['path_specific_code'].widgets:
            path_widgets = main_widget.subform.widgets
            path_widgets['path'].style = u'width: 100%'
            fix_widget_style(path_widgets['path_snippet'])
 def handleSave(self, action):
     for k, v in self.request.form.items():
         if ".AA" in k:
             self.request.form[k.replace('.AA', '.0')] = v
             del self.request.form[k]
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     self.applyChanges(data)
     IStatusMessage(self.request).addStatusMessage(
         _(u"Changes saved"), "info"
     )
     self.context.REQUEST.RESPONSE.redirect("@@analytics-settings")
class IAnalyticsSettings(Interface):
    """Settings used in the control panel for analyticspanel: general panel
    """

    general_code = schema.Text(
        title=pmf(u"JavaScript for web statistics support"),
        description=pmf(
            u"For enabling web statistics support from external providers (for e.g. Google Analytics). "
            u"Paste the code snippets provided. It will be included in the rendered HTML as entered near the end of the page."
        ),
        default=u"",
        missing_value=u"",
        required=False,
    )

    error_specific_code = schema.Tuple(
        title=_(u'JavaScript to be included when an error message is get'),
        description=_(
            'help_error_specific_code',
            default=
            u"Replace default code included when an error message returned is "
            "one of the following values.\n"
            "For example: use \"NotFound\" for change JavaScript included inside NotFound page."
        ),
        value_type=PersistentObject(IErrorCodeValuePair,
                                    title=_(u"Error message related snippet")),
        required=False,
        default=(),
        missing_value=(),
    )

    path_specific_code = schema.Tuple(
        title=_(u"JavaScript to be included inside specific site's paths"),
        description=_(
            'help_path_specific_code',
            default=
            u'Put there an absolute site path, and the statistics code you want to use '
            u'there instead of the default ones.\n'
            u'The most specific path will be used.\n'
            u'Example: /folder/subfolder'),
        value_type=PersistentObject(ISitePathValuePair,
                                    title=_(u"Site path related snippet")),
        required=False,
        default=(),
        missing_value=(),
    )
예제 #16
0
class IAnalyticsSettings(Interface):
    """Settings used in the control panel for analyticspanel: general panel
    """
    
    general_header_code = schema.Text(
            title=_('general_header_code_label',
                    default=u"JavaScript for web statistics support (in the header of the page)"),
            description=_('general_header_code_desciption',
                          default=u"For enabling web statistics support from external providers (for e.g. Google Analytics). "
                                  u"Paste the code snippets provided. "
                                  u"It will be included in the rendered HTML as entered near the beginning of the page's BODY.\n"
                                  u"Commonly this is the best place where to put modern analytics code."),
            default=u"",
            missing_value=u"",
            required=False,
    )

    general_code = schema.Text(
            title=_('general_footer_code_label',
                    default=u"JavaScript for web statistics support (in the footer of the page)"),
            description=_('general_footer_code_desciption',
                          u"For enabling web statistics support from external providers (for e.g. Google Analytics). "
                          u"Paste the code snippets provided.\n"
                          u"It will be included in the rendered HTML as entered near the end of the page.\n"
                          u"Historically Plone put it's analytics code here and this can still be the best place for "
                          u"old analytics software that block the page rendering."),
            default=u"",
            missing_value=u"",
            required=False,
    )

    error_specific_code = schema.Tuple(
            title=_(u'JavaScript to be included when an error message is get'),
            description=_('help_error_specific_code',
                          default=u"Replace default code included when an error message returned is "
                                   "one of the following values.\n"
                                   "For example: use \"NotFound\" for change JavaScript included inside NotFound page."),
            value_type=PersistentObject(IErrorCodeValuePair, title=_(u"Error message related snippet")),
            required=False,
            default=(),
            missing_value=(),
    )

    path_specific_code = schema.Tuple(
            title=_(u"JavaScript to be included inside specific site's paths"),
            description=_('help_path_specific_code',
                          default=u'Put there an absolute site path, and the statistics code you want to use '
                                  u'there instead of the default ones.\n'
                                  u'The most specific path will be used.\n'
                                  u'Example: /folder/subfolder'),
            value_type=PersistentObject(ISitePathValuePair, title=_(u"Site path related snippet")),
            required=False,
            default=(),
            missing_value=(),
    )

    respect_donottrack = schema.Bool(
            title=_(u'Respect "Do Not Track" browser setting'),
            description=_('help_respect_donottrack',
                          default=u"Do not send analytics if user activated the DNT header.\n"
                                  u"See https://en.wikipedia.org/wiki/Do_Not_Track"),
            default=False,
    )

    respect_optout = schema.Bool(
            title=_(u'Respect \"analytics-optout\" cookie'),
            description=_('help_respect_optout',
                          default=u"If a cookie named \"analytics-optout\" exists and is valued \"true\" "
                                  u"do not send analytics data."),
            default=False,
    )
class FormAdvanced(group.Group):
    label = _(u"Advanced settings")
    fields = field.Fields(IAnalyticsAdvancedSettings)
 def handleCancel(self, action):
     IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled"),
                                                   "info")
     self.request.response.redirect("%s/%s" % (self.context.absolute_url(),
                                               self.control_panel_view))
예제 #19
0
class IErrorCodeValuePair(Interface):
    message = schema.ASCIILine(title=_(u"Error message"), required=True)
    message_snippet = schema.SourceText(title=_(u"Code to include"),
                                        required=False)