[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 | |
---|
[1317] | 37 | security.declarePublic('pop') |
---|
| 38 | def pop(self, k, *args, **kwargs): |
---|
| 39 | super(SortedDict,self).pop(k, *args, **kwargs) |
---|
| 40 | if k in self.pmt: |
---|
| 41 | self.pmt.remove(k) |
---|
| 42 | |
---|
[387] | 43 | try: |
---|
| 44 | InitializeClass(SortedDict) |
---|
| 45 | except: |
---|
| 46 | pass |
---|
[424] | 47 | |
---|
| 48 | def removeSkin(self, layer): |
---|
| 49 | """Remove layers""" |
---|
| 50 | skinstool = getToolByName(self, 'portal_skins') |
---|
| 51 | for skinName in skinstool.getSkinSelections(): |
---|
| 52 | original_path = skinstool.getSkinPath(skinName) |
---|
| 53 | original_path = [l.strip() for l in original_path.split(',')] |
---|
| 54 | new_path= [] |
---|
| 55 | for l in original_path: |
---|
| 56 | if (l == layer) or (l.startswith(layer+'/')): |
---|
| 57 | continue |
---|
| 58 | new_path.append(l) |
---|
| 59 | skinstool.addSkinSelection(skinName, ','.join(new_path)) |
---|
| 60 | |
---|
| 61 | def removeActions(self): |
---|
| 62 | tool = getToolByName(self, 'portal_types') |
---|
| 63 | for ptype in tool.objectValues(): |
---|
| 64 | if ptype.getId() in ['File','Document','News Item']: |
---|
| 65 | acts = filter(lambda x: x.id == 'seo_properties', ptype.listActions()) |
---|
| 66 | action = acts and acts[0] or None |
---|
| 67 | if action != None: |
---|
| 68 | acts = list(ptype.listActions()) |
---|
| 69 | ptype.deleteActions([acts.index(a) for a in acts if a.getId()=='seo_properties']) |
---|
| 70 | |
---|
| 71 | def remove_configlets( context, conf_ids ): |
---|
| 72 | configTool = getToolByName(context, 'portal_controlpanel', None) |
---|
| 73 | if configTool: |
---|
| 74 | for id in conf_ids: |
---|
| 75 | configTool.unregisterConfiglet(id) |
---|
| 76 | |
---|
| 77 | def uninstall( context ): |
---|
[429] | 78 | if context.readDataFile('seo_uninstall.txt') is None: |
---|
| 79 | return |
---|
[424] | 80 | site = context.getSite() |
---|
| 81 | removeSkin( site, 'quintagroup.seoptimizer' ) |
---|
| 82 | removeActions( site ) |
---|
| 83 | remove_configlets( site, ('quintagroup.seoptimizer',)) |
---|
| 84 | |
---|