-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Plone 4.3 with p.a.widgets 1.x edit modals
see issue #719
- Loading branch information
Showing
4 changed files
with
60 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import pkg_resources | ||
|
||
try: | ||
pkg_resources.get_distribution('plone.app.widgets') | ||
except pkg_resources.DistributionNotFound: | ||
pass | ||
else: | ||
from Acquisition import aq_parent | ||
from Products.CMFCore.utils import getToolByName | ||
from collective.cover.tiles.richtext import IRichTextTile | ||
from plone.app.widgets.base import dict_merge | ||
from plone.app.widgets.dx import RichTextWidget | ||
from plone.app.widgets.utils import get_tinymce_options | ||
from z3c.form.interfaces import IFieldWidget, IFormLayer | ||
from z3c.form.util import getSpecification | ||
from z3c.form.widget import FieldWidget | ||
from zope.component import adapter | ||
from zope.interface import implementer | ||
|
||
|
||
class TileRichTextWidget(RichTextWidget): | ||
""" """ | ||
|
||
def _base_args(self): | ||
args = { | ||
'pattern': self.pattern, | ||
'pattern_options': self.pattern_options.copy(), | ||
} | ||
context = aq_parent(self.wrapped_context()) | ||
args['name'] = self.name | ||
properties = getToolByName(context, 'portal_properties') | ||
charset = properties.site_properties.getProperty( | ||
'default_charset', 'utf-8') | ||
value = self.value and self.value.raw_encoded or '' | ||
args['value'] = (self.request.get( | ||
self.field.getName(), value)).decode(charset) | ||
|
||
args.setdefault('pattern_options', {}) | ||
merged = dict_merge( | ||
get_tinymce_options(context, self.field, self.request), | ||
args['pattern_options']) | ||
args['pattern_options'] = merged | ||
|
||
return args | ||
|
||
|
||
@adapter(getSpecification(IRichTextTile['text']), IFormLayer) | ||
@implementer(IFieldWidget) | ||
def TileRichTextFieldWidget(field, request): | ||
return FieldWidget(field, TileRichTextWidget(request)) |