2010-08-31 19:29:26 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2010-08-25 16:03:29 +02:00
|
|
|
|
|
|
|
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
|
|
|
|
|
2010-01-24 14:47:39 +01:00
|
|
|
from plone.app.discussion.interfaces import _
|
|
|
|
|
2010-06-10 15:11:33 +02:00
|
|
|
HAS_CAPTCHA = False
|
2009-08-11 11:45:34 +02:00
|
|
|
try:
|
2010-07-13 12:40:45 +02:00
|
|
|
import plone.formwidget.captcha
|
|
|
|
HAS_CAPTCHA = True
|
2009-08-11 11:45:34 +02:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2010-06-10 15:11:33 +02:00
|
|
|
HAS_RECAPTCHA = False
|
2009-08-11 11:45:34 +02:00
|
|
|
try:
|
2010-07-13 12:40:45 +02:00
|
|
|
import plone.formwidget.recaptcha
|
|
|
|
HAS_RECAPTCHA = True
|
2009-08-11 11:45:34 +02:00
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2010-06-10 15:11:33 +02:00
|
|
|
HAS_AKISMET = False
|
|
|
|
try:
|
2010-07-13 11:22:05 +02:00
|
|
|
import collective.akismet
|
2010-06-10 15:11:33 +02:00
|
|
|
HAS_AKISMET = True
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2010-09-10 15:02:56 +02:00
|
|
|
HAS_NOROBOTS = False
|
|
|
|
try:
|
|
|
|
import collective.z3cform.norobots
|
|
|
|
HAS_NOROBOTS = True
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2010-06-10 15:11:33 +02:00
|
|
|
|
2009-08-11 11:45:34 +02:00
|
|
|
def captcha_vocabulary(context):
|
|
|
|
"""Vocabulary with all available captcha implementations.
|
|
|
|
"""
|
|
|
|
terms = []
|
|
|
|
terms.append(
|
2010-08-25 16:03:29 +02:00
|
|
|
SimpleTerm(
|
2009-08-11 11:45:34 +02:00
|
|
|
value='disabled',
|
|
|
|
token='disabled',
|
2010-01-24 14:47:39 +01:00
|
|
|
title=_(u'Disabled')))
|
2009-08-11 11:45:34 +02:00
|
|
|
|
|
|
|
if HAS_CAPTCHA:
|
|
|
|
terms.append(
|
2010-08-25 16:03:29 +02:00
|
|
|
SimpleTerm(
|
2009-08-11 11:45:34 +02:00
|
|
|
value='captcha',
|
|
|
|
token='captcha',
|
|
|
|
title='Captcha'))
|
|
|
|
if HAS_RECAPTCHA:
|
|
|
|
terms.append(
|
2010-08-25 16:03:29 +02:00
|
|
|
SimpleTerm(
|
2009-08-11 11:45:34 +02:00
|
|
|
value='recaptcha',
|
|
|
|
token='recaptcha',
|
|
|
|
title='ReCaptcha'))
|
2010-06-10 15:11:33 +02:00
|
|
|
if HAS_AKISMET:
|
|
|
|
terms.append(
|
2010-08-25 16:03:29 +02:00
|
|
|
SimpleTerm(
|
2010-06-10 15:11:33 +02:00
|
|
|
value='akismet',
|
|
|
|
token='akismet',
|
|
|
|
title='Akismet'))
|
2010-09-10 15:02:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
if HAS_NOROBOTS:
|
|
|
|
terms.append(
|
|
|
|
SimpleTerm(
|
|
|
|
value='norobots',
|
|
|
|
token='norobots',
|
|
|
|
title='Norobots'))
|
2010-06-10 15:11:33 +02:00
|
|
|
|
2010-08-25 16:03:29 +02:00
|
|
|
return SimpleVocabulary(terms)
|
2009-08-11 11:45:34 +02:00
|
|
|
|
2010-08-25 16:03:29 +02:00
|
|
|
|
|
|
|
def text_transform_vocabulary(context):
|
|
|
|
"""Vocabulary with all available portal_transform transformations.
|
|
|
|
"""
|
|
|
|
terms = []
|
|
|
|
terms.append(
|
|
|
|
SimpleTerm(
|
|
|
|
value='text/plain',
|
|
|
|
token='text/plain',
|
|
|
|
title='Plain text'))
|
|
|
|
terms.append(
|
|
|
|
SimpleTerm(
|
|
|
|
value='text/x-web-intelligent',
|
|
|
|
token='text/x-web-intelligent',
|
|
|
|
title='Intelligent text'))
|
|
|
|
return SimpleVocabulary(terms)
|