| 1 | from Products.Archetypes.Extensions.utils import install_subskin |
|---|
| 2 | from Products.CMFCore.utils import getToolByName |
|---|
| 3 | try: |
|---|
| 4 | from Products.CMFCore.permissions import ManagePortal |
|---|
| 5 | except: |
|---|
| 6 | from Products.CMFCore.CMFCorePermissions import ManagePortal |
|---|
| 7 | |
|---|
| 8 | from Products.qPloneSkinDump.config import * |
|---|
| 9 | from StringIO import StringIO |
|---|
| 10 | |
|---|
| 11 | def install(self): |
|---|
| 12 | out=StringIO() |
|---|
| 13 | |
|---|
| 14 | controlpanel_tool = getToolByName(self, 'portal_controlpanel') |
|---|
| 15 | |
|---|
| 16 | controlpanel_tool.unregisterConfiglet(CONFIGURATION_CONFIGLET) |
|---|
| 17 | controlpanel_tool.registerConfiglet(id=CONFIGURATION_CONFIGLET, name='qPloneSkinDump Configuration', category='Products', |
|---|
| 18 | action='string:${portal_url}/qploneskindump_config', |
|---|
| 19 | appId=PROJECTNAME, permission=ManagePortal, imageUrl='skins_icon.gif') |
|---|
| 20 | |
|---|
| 21 | install_subskin(self, out, GLOBALS) |
|---|
| 22 | |
|---|
| 23 | out.write('Installation qPloneSkinDump successfully completed.\n') |
|---|
| 24 | return out.getvalue() |
|---|
| 25 | |
|---|
| 26 | def uninstall(self) : |
|---|
| 27 | controlpanel_tool = getToolByName(self, 'portal_controlpanel') |
|---|
| 28 | # controlpanel_tool.unregisterConfiglet(TOOL_ID) |
|---|
| 29 | controlpanel_tool.unregisterConfiglet(CONFIGURATION_CONFIGLET) |
|---|
| 30 | |
|---|
| 31 | skinstool = getToolByName(self, 'portal_skins') |
|---|
| 32 | skinLayer = PROJECTNAME.lower() |
|---|
| 33 | for skinName in skinstool.getSkinSelections(): |
|---|
| 34 | path = skinstool.getSkinPath(skinName) |
|---|
| 35 | path = [i.strip() for i in path.split(',')] |
|---|
| 36 | if skinLayer in path: |
|---|
| 37 | path.remove(skinLayer) |
|---|
| 38 | path = ','.join(path) |
|---|
| 39 | skinstool.addSkinSelection(skinName, path) |
|---|
| 40 | |
|---|