Beispiel #1
0
def ImageFieldWidget(field, request):  # pylint: disable=invalid-name
    """Form image button widget factory adapter"""
    image = FieldWidget(field, ImageWidget(request))
    image.value = field.title
    # Get the full resource URL for the image:
    image.src = to_unicode(field.image)
    return image
Beispiel #2
0
 def _make_missing_term(self, value):
     """Return a term that should be displayed for the missing token"""
     uvalue = to_unicode(value)
     return SimpleTerm(value,
                       self._make_token(value),
                       title=_('Missing: ${value}',
                               mapping=dict(value=uvalue)))
Beispiel #3
0
 def items(self):
     """Items list getter"""
     if self.terms is None:
         return
     for count, term in enumerate(self.terms):
         checked = self.is_checked(term)
         item_id = '%s-%i' % (self.id, count)
         if ITitledTokenizedTerm.providedBy(term):
             translate = self.request.localizer.translate
             label = translate(term.title)
         else:
             label = to_unicode(term.value)
         yield {
             'id': item_id,
             'name': self.name,
             'value': term.token,
             'label': label,
             'checked': checked
         }
Beispiel #4
0
 def _make_token(value):
     """create a unique valid ASCII token"""
     return create_css_id(to_unicode(value))
Beispiel #5
0
 def to_widget_value(self, value):
     """See interfaces.IDataConverter"""
     if value is self.field.missing_value:
         return ''
     return to_unicode(value)
Beispiel #6
0
 def to_widget_value(self, value):
     """Convert from text lines to HTML representation."""
     # if the value is the missing value, then an empty list is produced.
     if value is self.field.missing_value:
         return ''
     return '\n'.join(to_unicode(v) for v in value)
Beispiel #7
0
 def src(self):
     """Image source"""
     return to_unicode(self.field.image)