2 # Epoz-Installer-Script for CMF/Plone
3 # Taken and adapted from CMFVisualEditor
6 from Products
.Epoz
import cmfepoz_globals
7 from StringIO
import StringIO
8 from Products
.CMFCore
.utils
import getToolByName
9 from Products
.CMFCore
.DirectoryView
import addDirectoryViews
13 def install_plone(self
, out
):
14 """ add Epoz to 'my preferences' """
15 portal_props
=getToolByName(self
,'portal_properties')
16 site_props
=getattr(portal_props
,'site_properties', None)
17 attrname
='available_editors'
18 if site_props
is not None:
19 editors
=list(site_props
.getProperty(attrname
))
20 if 'Epoz' not in editors
:
21 editors
.append('Epoz')
22 site_props
._updateProperty
(attrname
, editors
)
23 print >>out
, "Added 'Epoz' to available editors in Plone."
25 def install_subskin(self
, out
, skin_name
, globals=cmfepoz_globals
):
26 skinstool
=getToolByName(self
, 'portal_skins')
27 if skin_name
not in skinstool
.objectIds():
28 addDirectoryViews(skinstool
, 'epoz', globals)
30 for skinName
in skinstool
.getSkinSelections():
31 path
= skinstool
.getSkinPath(skinName
)
32 path
= [i
.strip() for i
in path
.split(',')]
34 if skin_name
not in path
:
35 path
.insert(path
.index('custom') +1, skin_name
)
37 if skin_name
not in path
:
38 path
.append(skin_name
)
41 skinstool
.addSkinSelection(skinName
, path
)
45 print >>out
, "Installing Epoz"
46 install_subskin(self
, out
, 'epoz_core')
47 install_subskin(self
, out
, 'epoz_i18n')
48 install_subskin(self
, out
, 'epoz_images')
49 install_subskin(self
, out
, 'epoz_plone')
50 install_plone(self
, out
)