[1] | 1 | from Products.Archetypes.Extensions.utils import install_subskin |
---|
| 2 | from Products.CMFCore.CMFCorePermissions import ManagePortal |
---|
| 3 | from Products.CMFCore.utils import getToolByName |
---|
| 4 | |
---|
| 5 | from Products.qPloneSkinDump.config import * |
---|
| 6 | from Products.qPloneSkinDump.generatingTemplate import p_sheet_id |
---|
| 7 | from StringIO import StringIO |
---|
| 8 | |
---|
| 9 | def install(self): |
---|
| 10 | out=StringIO() |
---|
| 11 | |
---|
| 12 | controlpanel_tool = getToolByName(self, 'portal_controlpanel') |
---|
| 13 | |
---|
| 14 | controlpanel_tool.unregisterConfiglet(CONFIGURATION_CONFIGLET) |
---|
| 15 | controlpanel_tool.registerConfiglet(id=CONFIGURATION_CONFIGLET, name='qPloneSkinDump Configuration', category='Products', |
---|
| 16 | action='string:${portal_url}/qploneskindump_config', |
---|
| 17 | appId=PROJECTNAME, permission=ManagePortal, imageUrl='skins_icon.gif') |
---|
| 18 | |
---|
| 19 | # generation configlet |
---|
| 20 | controlpanel_tool.unregisterConfiglet(GENERATION_CONFIGLET) |
---|
| 21 | controlpanel_tool.registerConfiglet(id=GENERATION_CONFIGLET, |
---|
| 22 | name='qPloneSkinDump Main Template Generation', |
---|
| 23 | category='Products', |
---|
| 24 | action='string:${portal_url}/qploneskindump_generate', |
---|
| 25 | condition="python:modules['Products.qPloneSkinDump.generatingTemplate'].available(here)", |
---|
| 26 | appId=PROJECTNAME, |
---|
| 27 | permission=ManagePortal, |
---|
| 28 | imageUrl='skins_icon.gif') |
---|
| 29 | |
---|
| 30 | install_subskin(self, out, GLOBALS) |
---|
| 31 | |
---|
| 32 | out.write('Installation qPloneSkinDump successfully completed.\n') |
---|
| 33 | return out.getvalue() |
---|
| 34 | |
---|
| 35 | def uninstall(self) : |
---|
| 36 | controlpanel_tool = getToolByName(self, 'portal_controlpanel') |
---|
| 37 | # controlpanel_tool.unregisterConfiglet(TOOL_ID) |
---|
| 38 | controlpanel_tool.unregisterConfiglet(CONFIGURATION_CONFIGLET) |
---|
| 39 | controlpanel_tool.unregisterConfiglet(GENERATION_CONFIGLET) |
---|
| 40 | |
---|
| 41 | skinstool = getToolByName(self, 'portal_skins') |
---|
| 42 | skinLayer = PROJECTNAME.lower() |
---|
| 43 | for skinName in skinstool.getSkinSelections(): |
---|
| 44 | path = skinstool.getSkinPath(skinName) |
---|
| 45 | path = [i.strip() for i in path.split(',')] |
---|
| 46 | if skinLayer in path: |
---|
| 47 | path.remove(skinLayer) |
---|
| 48 | path = ','.join(path) |
---|
| 49 | skinstool.addSkinSelection(skinName, path) |
---|
| 50 | |
---|
| 51 | # delete "generation_properties" property sheet from portal_properties if present |
---|
| 52 | pp = getToolByName(self, 'portal_properties') |
---|
| 53 | if p_sheet_id in pp.objectIds(): |
---|
| 54 | pp.manage_delObjects(ids=[p_sheet_id]) |
---|