Skip to content
Browse files

handle directionality based on portal_state.is_rtl, discard setting i…

…n control panel
  • Loading branch information...
1 parent 72e1217 commit e09d006fe194fe0d05f1fd88166d914ee940aa6b @domenkozar domenkozar committed Nov 18, 2011
View
1 Products/TinyMCE/exportimport.py
@@ -15,7 +15,6 @@ class TinyMCESettingsXMLAdapter(XMLAdapterBase):
'autoresize': {'type': 'Bool', 'default': False},
'editor_width': {'type': 'Text', 'default': u'100%'},
'editor_height': {'type': 'Text', 'default': u'400'},
- 'directionality': {'type': 'Text', 'default': u'ltr'},
'contextmenu': {'type': 'Bool', 'default': True},
'content_css': {'type': 'Text', 'default': u''},
'styles': {'type': 'List', 'default': u'Heading|h2\nSubheading|h3\nLiteral|pre\nDiscreet|p|discreet\nPull-quote|div|pullquote\nCall-out|p|callout\nHighlight|span|visualHighlight\nOdd row|tr|odd\nEven row|tr|even\nHeading cell|th|\nPage break (print only)|div|pageBreak\nClear floats|div|visualClear'},
View
11 Products/TinyMCE/interfaces/utility.py
@@ -41,17 +41,6 @@ class ITinyMCELayout(Interface):
description=_(u"This option gives you the ability to specify the height of the editor in pixels. If auto resize is enabled this value is used as minimum height."),
required=False)
- directionality = schema.Choice(
- title=_(u"Writing direction"),
- description=_(u"This option specifies the default writing direction, some languages (Like Hebrew, Arabic, Urdu...) write from right to left instead of left to right."),
- missing_value=set(),
- vocabulary=SimpleVocabulary([
- SimpleTerm('auto', 'auto',
- _(u'Auto detect from content language')),
- SimpleTerm('ltr', 'ltr', _(u"Left to right")),
- SimpleTerm('rtl', 'rtl', _(u"Right to left"))]),
- required=False)
-
contextmenu = schema.Bool(
title=_(u"Enable contextmenu."),
description=_(u"This option gives you the ability to enable/disable the use of the contextmenu."),
View
1 Products/TinyMCE/profiles/default/tinymce.xml
@@ -61,7 +61,6 @@
<content_css value=""/>
<editor_width value="100%"/>
<editor_height value="400"/>
- <directionality value="ltr"/>
<contextmenu value="True"/>
<autoresize value="False"/>
<tablestyles>
View
3 Products/TinyMCE/tests/test_browser.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-from Products.TinyMCE.utility import form_adapter
from Products.TinyMCE.tests.base import IntegrationTestCase
from Products.TinyMCE.tests.base import FunctionalTestCase
@@ -78,8 +77,6 @@ def test_configuration(self):
# If we configure directivity to 'auto', the directivity is set depending
# on the content language.
- utility = form_adapter(self.portal)
- utility.directionality = 'auto'
doc = self.portal[self.document]
self.assertEqual(doc.Language(), 'en')
output = self.portal.restrictedTraverse(document_jsonconfig_url)('text')
View
19 Products/TinyMCE/utility.py
@@ -5,7 +5,7 @@
import json
from types import StringTypes
-from zope.component import getUtilitiesFor, getUtility, queryUtility
+from zope.component import getUtilitiesFor, getUtility, queryUtility, getMultiAdapter
from zope.i18n import translate
from zope.i18nmessageid import MessageFactory
from zope.interface import classProvides, implements
@@ -61,7 +61,6 @@ class TinyMCE(SimpleItem):
autoresize = FieldProperty(ITinyMCELayout['autoresize'])
editor_width = FieldProperty(ITinyMCELayout['editor_width'])
editor_height = FieldProperty(ITinyMCELayout['editor_height'])
- directionality = FieldProperty(ITinyMCELayout['directionality'])
contextmenu = FieldProperty(ITinyMCELayout['contextmenu'])
content_css = FieldProperty(ITinyMCELayout['content_css'])
styles = FieldProperty(ITinyMCELayout['styles'])
@@ -830,17 +829,11 @@ def getConfiguration(self, context=None, field=None, request=None, script_url=No
except (TypeError, ValueError):
results['toolbar_width'] = 440
- if self.directionality == 'auto':
- language = context.Language()
- if not language:
- portal_properties = getToolByName(context, "portal_properties")
- site_properties = portal_properties.site_properties
- language = site_properties.getProperty('default_language',
- None)
- directionality = (language[:2] in RIGHT_TO_LEFT) and 'rtl' or 'ltr'
- else:
- directionality = self.directionality
- results['directionality'] = directionality
+ # is_rtl handles every possible setting as far as RTL/LTR is concerned
+ # pass that to tinmyce
+ if request:
+ portal_state = getMultiAdapter((context, request), name=u'plone_portal_state')
+ results['directionality'] = portal_state.is_rtl() and 'rtl' or 'ltr'
if self.content_css and self.content_css.strip() != "":
results['content_css'] = self.content_css

0 comments on commit e09d006

Please sign in to comment.
Something went wrong with that request. Please try again.