[387] | 1 | from Globals import InitializeClass |
---|
| 2 | from AccessControl import ClassSecurityInfo |
---|
[424] | 3 | from Products.CMFCore.utils import getToolByName |
---|
[387] | 4 | |
---|
| 5 | def createMultiColumnList(self,slist, numCols, sort_on='title_or_id'): |
---|
| 6 | try: |
---|
| 7 | mcl = self.createMultiColumnList(slist, numCols, sort_on=sort_on) |
---|
| 8 | return mcl |
---|
| 9 | except AttributeError: |
---|
| 10 | return [slist] |
---|
| 11 | |
---|
| 12 | class SortedDict(dict): |
---|
| 13 | security = ClassSecurityInfo() |
---|
[1313] | 14 | |
---|
| 15 | security.declarePublic('items') |
---|
[387] | 16 | def items(self): |
---|
[1313] | 17 | primary_metatags = self.pmt |
---|
[387] | 18 | lst = [(name,self[name]) for name in primary_metatags \ |
---|
| 19 | if name in self.keys()] + \ |
---|
| 20 | [(name, self[name]) for name in self.keys() \ |
---|
| 21 | if name not in primary_metatags] |
---|
| 22 | return lst |
---|
| 23 | |
---|
[1313] | 24 | |
---|
| 25 | security.declarePublic('__init__') |
---|
| 26 | def __init__(self, *args, **kwargs): |
---|
| 27 | super(SortedDict,self).__init__(*args, **kwargs) |
---|
| 28 | self.pmt = [] |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | security.declarePublic('__setitem__') |
---|
| 32 | def __setitem__(self, i, y): |
---|
| 33 | super(SortedDict,self).__setitem__(i, y) |
---|
| 34 | if i not in self.pmt: |
---|
| 35 | self.pmt.append(i) |
---|
| 36 | |
---|
[387] | 37 | try: |
---|
| 38 | InitializeClass(SortedDict) |
---|
| 39 | except: |
---|
| 40 | pass |
---|
[424] | 41 | |
---|
| 42 | def removeSkin(self, layer): |
---|
| 43 | """Remove layers""" |
---|
| 44 | skinstool = getToolByName(self, 'portal_skins') |
---|
| 45 | for skinName in skinstool.getSkinSelections(): |
---|
| 46 | original_path = skinstool.getSkinPath(skinName) |
---|
| 47 | original_path = [l.strip() for l in original_path.split(',')] |
---|
| 48 | new_path= [] |
---|
| 49 | for l in original_path: |
---|
| 50 | if (l == layer) or (l.startswith(layer+'/')): |
---|
| 51 | continue |
---|
| 52 | new_path.append(l) |
---|
| 53 | skinstool.addSkinSelection(skinName, ','.join(new_path)) |
---|
| 54 | |
---|
| 55 | def removeActions(self): |
---|
| 56 | tool = getToolByName(self, 'portal_types') |
---|
| 57 | for ptype in tool.objectValues(): |
---|
| 58 | if ptype.getId() in ['File','Document','News Item']: |
---|
| 59 | acts = filter(lambda x: x.id == 'seo_properties', ptype.listActions()) |
---|
| 60 | action = acts and acts[0] or None |
---|
| 61 | if action != None: |
---|
| 62 | acts = list(ptype.listActions()) |
---|
| 63 | ptype.deleteActions([acts.index(a) for a in acts if a.getId()=='seo_properties']) |
---|
| 64 | |
---|
| 65 | def remove_configlets( context, conf_ids ): |
---|
| 66 | configTool = getToolByName(context, 'portal_controlpanel', None) |
---|
| 67 | if configTool: |
---|
| 68 | for id in conf_ids: |
---|
| 69 | configTool.unregisterConfiglet(id) |
---|
| 70 | |
---|
| 71 | def uninstall( context ): |
---|
[429] | 72 | if context.readDataFile('seo_uninstall.txt') is None: |
---|
| 73 | return |
---|
[424] | 74 | site = context.getSite() |
---|
| 75 | removeSkin( site, 'quintagroup.seoptimizer' ) |
---|
| 76 | removeActions( site ) |
---|
| 77 | remove_configlets( site, ('quintagroup.seoptimizer',)) |
---|
| 78 | |
---|