class ExternalizeLinkSettingsControlPanelEditForm(controlpanel.RegistryEditForm
                                                  ):
    """Settings form for collective.externalizelink
    """
    schema = IExternalizeLinkSettings
    id = "ExternalizeLinkSettingsEditForm"
    label = _(u"Externalize links settings")
    description = _(
        u"help_externalize_link_settings_editform",
        default=u"Site configuration for the collective.externalizelink add-on"
    )

    @button.buttonAndHandler(pmf('Save'), name='save')
    def handleSave(self, action):
        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("@@externalizelink-settings")

    @button.buttonAndHandler(pmf('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(ExternalizeLinkSettingsControlPanelEditForm,
              self).updateWidgets()
        self.widgets['links_selection'].rows = 5
 def handleSave(self, action):
     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("@@externalizelink-settings")
 def handleSave(self, action):
     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("@@externalizelink-settings")
Exemple #4
0
class IExternalizeLinkSettings(Interface):
    """Control panel settings for collective.externalizelink"""

    enabled = schema.Bool(
        title=_(u"Enabled"),
        description=_(u"Uncheck to disable the popups handling"),
        required=False,
        default=True,
    )

    links_selection = schema.Tuple(
        title=_(u"Links selectors"),
        description=_(
            'links_selection_help',
            default=u"jQuery selectors that identify links to be externalized.\n"
            u"Inside selectors you can use the $PORTAL_URL marker that "
            u"will be replaced with the site URL."),
        required=False,
        default=
        ('#region-content,#content a[href^="http"]:not(.link-plain):not([href^="$PORTAL_URL"])',
         ),
        missing_value=(),
        value_type=schema.TextLine(),
    )

    additional_attrs = schema.Tuple(
        title=_(u"Mark processed links"),
        description=
        _('help_additional_attrs',
          default=
          u'Add additional attributes to links that will be marked as external.\n'
          u'If the attribute is already present the value will be added to the '
          u'existing attribute.'),
        value_type=PersistentObject(IAdditionalAttrs,
                                    title=_(u"Additional attribute")),
        required=False,
        default=(),
        missing_value=(),
    )
 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))
Exemple #6
0
class IAdditionalAttrs(Interface):
    name = schema.TextLine(title=_(u"Attribute name"), required=True)
    value = schema.TextLine(title=_(u"Attribute value"), required=True)
 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))