[1] | 1 | from StringIO import StringIO |
---|
| 2 | from Products.CMFCore.utils import getToolByName |
---|
| 3 | from Products.Archetypes.Extensions.utils import install_subskin |
---|
| 4 | from Products.qRSS2Syndication.config import GLOBALS |
---|
| 5 | |
---|
| 6 | def removeSkin(self, skins = []): |
---|
| 7 | if skins: |
---|
| 8 | skinstool = getToolByName(self, 'portal_skins') |
---|
| 9 | for skinName in skinstool.getSkinSelections(): |
---|
| 10 | path = skinstool.getSkinPath(skinName) |
---|
| 11 | path = [i.strip() for i in path.split(',')] |
---|
| 12 | for s in skins: |
---|
| 13 | if s in path: |
---|
| 14 | path.remove(s) |
---|
| 15 | path = ','.join(path) |
---|
| 16 | skinstool.addSkinSelection(skinName, path) |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | def install(self): |
---|
| 20 | out = StringIO() |
---|
| 21 | |
---|
| 22 | # Add actionInfo icon to portal_actionicons. Delete old version before adding, if exist one. |
---|
| 23 | actionicons_tool = getToolByName(self, 'portal_actionicons') |
---|
| 24 | if actionicons_tool.queryActionInfo('plone', 'rss2syndication'): |
---|
| 25 | actionicons_tool.removeActionIcon('plone','rss2syndication') |
---|
| 26 | actionicons_tool.addActionIcon(category='plone', action_id='rss2syndication', |
---|
| 27 | icon_expr='rss2_icon.png', title='RSS2 Syndication') |
---|
| 28 | |
---|
| 29 | # Add actionInfo action to portal_actions. Delete old versions before adding, if exist one. |
---|
| 30 | action_tool = getToolByName(self, 'portal_actions') |
---|
| 31 | actions_id = [a.id for a in action_tool._actions] |
---|
| 32 | selections = [actions_id.index(a) for a in actions_id if a in ('rss2syndication','setup_rss2')] |
---|
| 33 | action_tool.deleteActions(selections=selections) |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | action_tool.addAction(id='rss2syndication', name='RSS2 Syndication', action='string:$object_url/RSS2', |
---|
| 37 | condition='python: folder==object and portal.portal_syndication.isSyndicationAllowed(object)', permission=('View',), category='document_actions') |
---|
| 38 | action_tool.addAction(id='setup_rss2', name='RSS2 Setup', action='string:$object_url/setup_rss2', |
---|
| 39 | condition='python:portal.portal_syndication.isSyndicationAllowed(object)', permission=('Manage properties',), category='folder') |
---|
| 40 | |
---|
| 41 | install_subskin(self,out,GLOBALS) |
---|
| 42 | |
---|
| 43 | print >> out, "\nSuccessfully installed qRSS2Syndication." |
---|
| 44 | return out.getvalue() |
---|
| 45 | |
---|
| 46 | def uninstall(self): |
---|
| 47 | action_tool = getToolByName(self, 'portal_actions') |
---|
| 48 | |
---|
| 49 | actions_id = [a.id for a in action_tool._actions] |
---|
| 50 | selections = [actions_id.index(a) for a in actions_id if a in ('rss2syndication','setup_rss2')] |
---|
| 51 | action_tool.deleteActions(selections=selections) |
---|
| 52 | |
---|
| 53 | actioniconstool = getToolByName(self, 'portal_actionicons') |
---|
| 54 | if actioniconstool.queryActionInfo('plone', 'rss2syndication'): |
---|
| 55 | actioniconstool.removeActionIcon('plone','rss2syndication') |
---|
| 56 | |
---|
| 57 | removeSkin(self, ('grss2syndication',)) |
---|
| 58 | |
---|
| 59 | return 'qRSS2Syndication actionProvider successfully uninstalled' |
---|