This repository has been archived by the owner on Apr 10, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 62
/
vocabularies.py
45 lines (32 loc) · 1.59 KB
/
vocabularies.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from plone.app.imaging.utils import getAllowedSizes
from zope.component import getUtilitiesFor
from zope.interface import directlyProvides
from zope.schema.vocabulary import SimpleVocabulary
from zope.schema.interfaces import IContextSourceBinder
def shortcuts_vocabulary(context):
from Products.TinyMCE.interfaces.shortcut import ITinyMCEShortcut # circular dependency
terms = []
for name, utility in getUtilitiesFor(ITinyMCEShortcut):
terms.append(SimpleVocabulary.createTerm(name, str(name), utility.title))
return SimpleVocabulary(terms)
directlyProvides(shortcuts_vocabulary, IContextSourceBinder)
def thumbnail_sizes_vocabulary(context):
"""Builds a vocabulary of thumbnail sizes. An example item in vocabulary
would have title set to "tile (64, 64)" and value to ('tile', 64, 64).
:returns: Vocabulary items for each allowed thumbnail size."
rtype: SimpleVocabulary
"""
terms = []
# TODO: we should query utility, but it's not certain it will be there
for name, size in getAllowedSizes().iteritems():
terms.append(SimpleVocabulary.createTerm(tuple((name,) + size), str(name), u"%s %s" % (name, size)))
return SimpleVocabulary(terms)
directlyProvides(thumbnail_sizes_vocabulary, IContextSourceBinder)
def plugins_vocabulary(context):
""" A vocabulary containing all the allowed plugins for TinyMCE
"""
from Products.TinyMCE.interfaces.utility import DEFAULT_PLUGINS
plugins = DEFAULT_PLUGINS[:]
plugins.sort()
return SimpleVocabulary.fromValues(plugins)
directlyProvides(plugins_vocabulary, IContextSourceBinder)