Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ Changelog
- Make sure `MeetingItem.otherMeetingConfigsClonableToFieldXXX` fields are
displayed in Schema defined order on the item edit and view.
[gbastien]
- Adapted code to be able to use `collective.ckeditor 4.11+`.
[gbastien]

4.2 (2023-03-06)
----------------
Expand Down
18 changes: 0 additions & 18 deletions src/Products/PloneMeeting/ckeditor/ckeditorview.py

This file was deleted.

8 changes: 0 additions & 8 deletions src/Products/PloneMeeting/ckeditor/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,4 @@
name="cke_imagerotate"
directory="imagerotate" />

<browser:page
name="ckeditor_plone_config.js"
for="*"
class=".ckeditorview.PMCKeditorView"
layer="Products.PloneMeeting.interfaces.IPloneMeetingLayer"
attribute="getCK_plone_config"
permission="zope.Public" />

</configure>
25 changes: 15 additions & 10 deletions src/Products/PloneMeeting/migrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,16 @@ def _before_reinstall(self):
"""Before self.reinstall hook that let's a subplugin knows that the profile
will be executed and may launch some migration steps before PM ones."""
# save CKeditor custom styles
cke_props = self.portal.portal_properties.ckeditor_properties
self.menuStyles = cke_props.menuStyles
self.menuStyles = api.portal.get_registry_record(
"collective.ckeditor.browser.ckeditorsettings.ICKEditorSchema.menuStyles")

def _after_reinstall(self):
"""After self.reinstall hook that let's a subplugin knows that the profile
has been executed and may launch some migration steps before PM ones."""
# set back CKeditor custom styles
cke_props = self.portal.portal_properties.ckeditor_properties
cke_props.menuStyles = self.menuStyles
api.portal.set_registry_record(
"collective.ckeditor.browser.ckeditorsettings.ICKEditorSchema.menuStyles",
self.menuStyles)

def getWorkflows(self, meta_types=['Meeting',
'MeetingItem',
Expand Down Expand Up @@ -598,27 +599,31 @@ def addCKEditorStyle(self, style_name, style_element, style_type="class", style_
- p_style_type is the type of style, by default "class", could be "style" also;
- p_style_value is the style value (class name or style definition)."""
logger.info("Adding style '%s' to CKEditor styles..." % style_name)
cke_props = self.portal.portal_properties.ckeditor_properties
if cke_props.menuStyles.find(style_name) == -1:
menuStyles = api.portal.get_registry_record(
"collective.ckeditor.browser.ckeditorsettings.ICKEditorSchema.menuStyles")
if menuStyles.find(style_name) == -1:
# msgid always starts with ckeditor_style_ and ends with style_name
msg_style_name = translate(
'ckeditor_style_{0}'.format(style_name),
domain='PloneMeeting',
context=self.request)
menuStyles = cke_props.menuStyles
style = u"{{ name : '{0}'\t\t, element : '{1}', attributes : " \
u"{{ '{2}' : '{3}' }} }},\n]".format(
msg_style_name, style_element, style_type, style_value)
# last element, check if we need a ',' before or not...
strippedMenuStyles = menuStyles.replace(u' ', u'').replace(u'\n', u'').replace(u'\r', u'')
strippedMenuStyles = menuStyles.replace(u' ', u'').replace(
u'\n', u'').replace(u'\r', u'')
if u',]' not in strippedMenuStyles:
menuStyles = menuStyles.replace(u'\n]', u']')
style = u",\n" + style
menuStyles = menuStyles.replace(u']', style)
cke_props.menuStyles = menuStyles
api.portal.set_registry_record(
"collective.ckeditor.browser.ckeditorsettings.ICKEditorSchema.menuStyles",
menuStyles)
self.warn(logger, "Style '{0}' was added...".format(style_name))
else:
logger.info("Style '{0}' already exists and was not added...".format(style_name))
logger.info("Style '{0}' already exists and was not added...".format(
style_name))
logger.info('Done.')

def _already_migrated(self, done=True):
Expand Down
5 changes: 5 additions & 0 deletions src/Products/PloneMeeting/migrations/migrate_to_4200.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from Products.PloneMeeting.MeetingConfig import PROPOSINGGROUPPREFIX
from Products.PloneMeeting.migrations import logger
from Products.PloneMeeting.migrations import Migrator
from Products.PloneMeeting.migrations.migrate_to_4206 import Migrate_To_4206
from Products.PloneMeeting.profiles import MeetingConfigDescriptor
from Products.PloneMeeting.setuphandlers import columnInfos
from Products.PloneMeeting.setuphandlers import indexInfos
Expand Down Expand Up @@ -874,6 +875,10 @@ def run(self, extra_omitted=[]):
logger.info('Migrating to PloneMeeting 4200...')

if self.is_in_part('a'): # main step, everything but update local roles and refresh catalog
# first thing, fix ckeditor_properties and upgrade it
Migrate_To_4206(self.portal)._fixCKeditorConfig()
self.upgradeProfile('collective.ckeditor:default')

self._fixPODTemplatesInstructions()
self._fixFacetedFilters()

Expand Down
12 changes: 9 additions & 3 deletions src/Products/PloneMeeting/migrations/migrate_to_4201.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

from Products.CPUtils.Extensions.utils import configure_ckeditor
from Products.PloneMeeting.migrations import logger
from Products.PloneMeeting.migrations import Migrator

Expand Down Expand Up @@ -27,9 +28,14 @@ def _fixWFsUsingReturnedToProposingGroupWFAdaptation(self):

def _disableWscForCKeditor(self):
'''The link 'Check spell' in Scayt button is broken, hide it.'''
logger.info('CKeditor, adding "wsc" to the removePlugins property...')
cke_props = self.portal.portal_properties.ckeditor_properties
cke_props.removePlugins = (u'wsc',)
logger.info('CKeditor, adding "wsc" to the removePlugins...')
configure_ckeditor(
self.portal,
custom='plonemeeting',
forceTextPaste=0,
scayt=1,
removeWsc=1,
use_registry=True)
logger.info('Done.')

def run(self, extra_omitted=[], from_migration_to_4200=False):
Expand Down
2 changes: 1 addition & 1 deletion src/Products/PloneMeeting/migrations/migrate_to_4205.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def run(self, extra_omitted=[], from_migration_to_4200=False):
# not necessary if executing the full upgrade to 4200
if not from_migration_to_4200:
# will upgrade collective.documentgenerator and collective.messagesviewlet
self.upgradeAll(omit=['Products.PloneMeeting:default'])
self.upgradeAll()
self._updateConfigCommitteesAndVotesResult()
self._updateMeetingCommittees()
self._updateLocalRolesItemBeforeStateValidated()
Expand Down
42 changes: 42 additions & 0 deletions src/Products/PloneMeeting/migrations/migrate_to_4206.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-

from Products.PloneMeeting.migrations import logger
from Products.PloneMeeting.migrations import Migrator


class Migrate_To_4206(Migrator):

def _fixCKeditorConfig(self):
"""Make sure CKeditor config is correct before executing migration from
ckeditor_properties to registry."""
logger.info('Fixing CKeditor properties...')
cke_props = self.portal.portal_properties.get("ckeditor_properties", None)
if cke_props is not None:
cke_props.properties_overloaded = ('width', 'height')
if cke_props.bodyClass is None:
cke_props.bodyClass = ''
if cke_props.width is None:
cke_props.width = ''
if isinstance(cke_props.height, unicode):
cke_props.height = str(cke_props.height)

logger.info('Done.')

def run(self, extra_omitted=[], from_migration_to_4200=False):

logger.info('Migrating to PloneMeeting 4206...')

self._fixCKeditorConfig()
# will upgrade collective.ckeditor
self.upgradeAll()
logger.info('Migrating to PloneMeeting 4206... Done.')


def migrate(context):
'''This migration function will:

1) Fix CKeditor ckeditor_properties and upgrade collective.ckeditor.
'''
migrator = Migrate_To_4206(context)
migrator.run()
migrator.finish()
4 changes: 0 additions & 4 deletions src/Products/PloneMeeting/overrides.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,6 @@
zcml:condition="not-have plone-5" />
</configure>

<adapter
for="z3c.form.interfaces.IWidget"
factory=".widgets.pm_richtext.PMZ3CFormWidgetSettings" />

<adapter
for="Products.Five.BrowserView"
factory=".browser.overrides.pm_default_popup_template"
Expand Down
8 changes: 8 additions & 0 deletions src/Products/PloneMeeting/profiles.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,12 @@
handler="Products.PloneMeeting.migrations.migrate_to_4205.migrate"
profile="Products.PloneMeeting:default" />

<genericsetup:upgradeStep
title="Go to PloneMeeting 4206"
description="Go to PloneMeeting 4206"
source="4205"
destination="4206"
handler="Products.PloneMeeting.migrations.migrate_to_4206.migrate"
profile="Products.PloneMeeting:default" />

</configure>
8 changes: 0 additions & 8 deletions src/Products/PloneMeeting/profiles/default/propertiestool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,4 @@
</property>
</object>

<object name="ckeditor_properties" meta_type="Plone Property Sheet">
<property name="plugins" type="lines" purge="False">
<element value="tableresize;/++resource++ckeditor/plugins/tableresize/plugin.js"/>
<element value="nonbreaking;/++resource++cke_nonbreaking/plugin.js"/>
<element value="imagerotate;/++resource++cke_imagerotate/plugin.js"/>
</property>
</object>

</object>
119 changes: 69 additions & 50 deletions src/Products/PloneMeeting/setuphandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,88 +428,107 @@ def _configureCKeditor(site):
CKeditor custom styles are kept during migrations using the _before_reinstall/_after_reinstall hooks.'''
logger.info('Defining CKeditor as the new default editor for every users and configuring it (styles)...')
# this will install collective.ckeditor if it is not already the case...
configure_ckeditor(site, custom='plonemeeting', forceTextPaste=0, scayt=1, removeWsc=1)
configure_ckeditor(site, custom='plonemeeting', forceTextPaste=0, scayt=1, removeWsc=1, use_registry=True)
# remove every styles defined by default and add the custom styles if not already done...
cke_props = site.portal_properties.ckeditor_properties
if cke_props.menuStyles.find(CKEDITOR_MENUSTYLES_CUSTOMIZED_MSG) == -1:
enc = site.portal_properties.site_properties.getProperty('default_charset')
menuStyles = api.portal.get_registry_record(
"collective.ckeditor.browser.ckeditorsettings.ICKEditorSchema.menuStyles")
if menuStyles.find(CKEDITOR_MENUSTYLES_CUSTOMIZED_MSG) == -1:
msg_highlight_red = translate('ckeditor_style_highlight_in_red',
domain='PloneMeeting',
context=site.REQUEST).encode('utf-8')
context=site.REQUEST)
msg_highlight_blue = translate('ckeditor_style_highlight_in_blue',
domain='PloneMeeting',
context=site.REQUEST).encode('utf-8')
context=site.REQUEST)
msg_highlight_green = translate('ckeditor_style_highlight_in_green',
domain='PloneMeeting',
context=site.REQUEST).encode('utf-8')
context=site.REQUEST)
msg_highlight_yellow = translate('ckeditor_style_highlight_in_yellow',
domain='PloneMeeting',
context=site.REQUEST).encode('utf-8')
context=site.REQUEST)
msg_x_small = translate('ckeditor_style_x_small',
domain='PloneMeeting',
context=site.REQUEST).encode('utf-8')
context=site.REQUEST)
msg_small = translate('ckeditor_style_small',
domain='PloneMeeting',
context=site.REQUEST).encode('utf-8')
context=site.REQUEST)
msg_large = translate('ckeditor_style_large',
domain='PloneMeeting',
context=site.REQUEST).encode('utf-8')
context=site.REQUEST)
msg_x_large = translate('ckeditor_style_x_large',
domain='PloneMeeting',
context=site.REQUEST).encode('utf-8')
context=site.REQUEST)
msg_table_optimization = translate('ckeditor_style_table_optimization',
domain='PloneMeeting',
context=site.REQUEST).encode('utf-8')
context=site.REQUEST)
msg_table_no_optimization = translate('ckeditor_style_table_no_optimization',
domain='PloneMeeting',
context=site.REQUEST).encode('utf-8')
context=site.REQUEST)
msg_indent = translate('ckeditor_style_indent_first_line',
domain='PloneMeeting',
context=site.REQUEST).encode('utf-8')
context=site.REQUEST)
msg_page_break = translate('ckeditor_style_page_break',
domain='PloneMeeting',
context=site.REQUEST).encode('utf-8')

menuStyles = unicode(
"[\n{0}\n{{ name : '{1}'\t\t, element : 'span', attributes : {{ 'class' : 'highlight-red' }} }},\n"
"{{ name : '{2}'\t\t, element : 'span', attributes : {{ 'class' : 'highlight-blue' }} }},\n"
"{{ name : '{3}'\t\t, element : 'span', attributes : {{ 'class' : 'highlight-green' }} }},\n"
"{{ name : '{4}'\t\t, element : 'span', attributes : {{ 'class' : 'highlight-yellow' }} }},\n"
"{{ name : '{5}'\t\t, element : 'p', attributes : {{ 'class' : 'xSmallText' }} }},\n"
"{{ name : '{6}'\t\t, element : 'p', attributes : {{ 'class' : 'smallText' }} }},\n"
"{{ name : '{7}'\t\t, element : 'p', attributes : {{ 'class' : 'largeText' }} }},\n"
"{{ name : '{8}'\t\t, element : 'p', attributes : {{ 'class' : 'xLargeText' }} }},\n"
"{{ name : '{9}'\t\t, element : 'table', styles : {{ 'table-layout' : 'auto' }} }},\n"
"{{ name : '{10}'\t\t, element : 'table', styles : {{ 'table-layout' : 'fixed' }} }},\n"
"{{ name : '{11}'\t\t, element : 'p', attributes : {{ 'style' : 'text-indent: 40px;' }} }},\n"
"{{ name : '{12}'\t\t, element : 'p', attributes : {{ 'class' : 'page-break' }} }},\n]\n".
format(CKEDITOR_MENUSTYLES_CUSTOMIZED_MSG,
msg_highlight_red,
msg_highlight_blue,
msg_highlight_green,
msg_highlight_yellow,
msg_x_small,
msg_small,
msg_large,
msg_x_large,
msg_table_optimization,
msg_table_no_optimization,
msg_indent,
msg_page_break), enc)
cke_props.menuStyles = menuStyles
context=site.REQUEST)
menuStyles = \
u"[\n{0}\n{{ name : '{1}'\t\t, element : 'span', attributes : {{ 'class' : 'highlight-red' }} }},\n" \
u"{{ name : '{2}'\t\t, element : 'span', attributes : {{ 'class' : 'highlight-blue' }} }},\n" \
u"{{ name : '{3}'\t\t, element : 'span', attributes : {{ 'class' : 'highlight-green' }} }},\n" \
u"{{ name : '{4}'\t\t, element : 'span', attributes : {{ 'class' : 'highlight-yellow' }} }},\n" \
u"{{ name : '{5}'\t\t, element : 'p', attributes : {{ 'class' : 'xSmallText' }} }},\n" \
u"{{ name : '{6}'\t\t, element : 'p', attributes : {{ 'class' : 'smallText' }} }},\n" \
u"{{ name : '{7}'\t\t, element : 'p', attributes : {{ 'class' : 'largeText' }} }},\n" \
u"{{ name : '{8}'\t\t, element : 'p', attributes : {{ 'class' : 'xLargeText' }} }},\n" \
u"{{ name : '{9}'\t\t, element : 'table', styles : {{ 'table-layout' : 'auto' }} }},\n" \
u"{{ name : '{10}'\t\t, element : 'table', styles : {{ 'table-layout' : 'fixed' }} }},\n" \
u"{{ name : '{11}'\t\t, element : 'p', attributes : {{ 'style' : 'text-indent: 40px;' }} }},\n" \
u"{{ name : '{12}'\t\t, element : 'p', attributes : {{ 'class' : 'page-break' }} }},\n]\n".format(
CKEDITOR_MENUSTYLES_CUSTOMIZED_MSG,
msg_highlight_red,
msg_highlight_blue,
msg_highlight_green,
msg_highlight_yellow,
msg_x_small,
msg_small,
msg_large,
msg_x_large,
msg_table_optimization,
msg_table_no_optimization,
msg_indent,
msg_page_break)
api.portal.set_registry_record(
"collective.ckeditor.browser.ckeditorsettings.ICKEditorSchema.menuStyles", menuStyles)
# make sure we use resolveuid for images so URL is always correct even if item id changed
cke_props.allow_link_byuid = True
api.portal.set_registry_record(
"collective.ckeditor.browser.ckeditorsettings.ICKEditorSchema.allow_link_byuid", True)
# make sure force paste as plain text is disabled
cke_props.forcePasteAsPlainText = False
api.portal.set_registry_record(
"collective.ckeditor.browser.ckeditorsettings.ICKEditorSchema.forcePasteAsPlainText", False)
# disable folder creation thru CKeditor to avoid
# having the add folder icon when adding an image
cke_props.allow_folder_creation = False
api.portal.set_registry_record(
"collective.ckeditor.browser.ckeditorsettings.ICKEditorSchema.allow_folder_creation", False)
# set 500px for editor height everywhere
cke_props.height = '500px'
api.portal.set_registry_record(
"collective.ckeditor.browser.ckeditorsettings.ICKEditorSchema.height", '500px')
# do not use 'rows' of the field widget for editor height
cke_props.properties_overloaded = (u'width', u'height')
api.portal.set_registry_record(
"collective.ckeditor.browser.ckeditorsettings.ICKEditorSchema.overloadable_properties",
['width', 'height'])
# use Moono-Lisa skin
cke_props.skin = u'moono-lisa'
api.portal.set_registry_record(
"collective.ckeditor.browser.ckeditorsettings.ICKEditorSchema.skin", 'moono-lisa')
# configure extra plugins
plugins = list(api.portal.get_registry_record(
"collective.ckeditor.browser.ckeditorsettings.ICKEditorSchema.plugins"))
extra_plugins = [
"tableresize;/++resource++ckeditor/plugins/tableresize/plugin.js",
"nonbreaking;/++resource++cke_nonbreaking/plugin.js",
"imagerotate;/++resource++cke_imagerotate/plugin.js"]
for extra_plugin in extra_plugins:
if extra_plugin not in plugins:
plugins.append(extra_plugin)
api.portal.set_registry_record(
"collective.ckeditor.browser.ckeditorsettings.ICKEditorSchema.plugins", plugins)
logger.info('Done.')


Expand Down
Loading