Ajout drapeaux isIE7max.
[Epoz.git] / Extensions / Install.py
1 ###
2 # Epoz-Installer-Script for CMF/Plone
3 # Taken and adapted from CMFVisualEditor
4 ###
5
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
10
11 _globals = globals()
12
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."
24
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)
29
30 for skinName in skinstool.getSkinSelections():
31 path = skinstool.getSkinPath(skinName)
32 path = [i.strip() for i in path.split(',')]
33 try:
34 if skin_name not in path:
35 path.insert(path.index('custom') +1, skin_name)
36 except ValueError:
37 if skin_name not in path:
38 path.append(skin_name)
39
40 path = ','.join(path)
41 skinstool.addSkinSelection(skinName, path)
42
43 def install(self):
44 out = StringIO()
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)
51
52 print >>out, "Done."
53
54 return out.getvalue()