1 | from Globals import InitializeClass |
---|
2 | from AccessControl import ClassSecurityInfo |
---|
3 | from Products.CMFCore.utils import getToolByName |
---|
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() |
---|
14 | security.declarePublic('items') |
---|
15 | def items(self): |
---|
16 | primary_metatags = ['description', 'keywords'] |
---|
17 | lst = [(name,self[name]) for name in primary_metatags \ |
---|
18 | if name in self.keys()] + \ |
---|
19 | [(name, self[name]) for name in self.keys() \ |
---|
20 | if name not in primary_metatags] |
---|
21 | return lst |
---|
22 | |
---|
23 | try: |
---|
24 | InitializeClass(SortedDict) |
---|
25 | except: |
---|
26 | pass |
---|
27 | |
---|
28 | def removeSkin(self, layer): |
---|
29 | """Remove layers""" |
---|
30 | skinstool = getToolByName(self, 'portal_skins') |
---|
31 | for skinName in skinstool.getSkinSelections(): |
---|
32 | original_path = skinstool.getSkinPath(skinName) |
---|
33 | original_path = [l.strip() for l in original_path.split(',')] |
---|
34 | new_path= [] |
---|
35 | for l in original_path: |
---|
36 | if (l == layer) or (l.startswith(layer+'/')): |
---|
37 | continue |
---|
38 | new_path.append(l) |
---|
39 | skinstool.addSkinSelection(skinName, ','.join(new_path)) |
---|
40 | |
---|
41 | def removeActions(self): |
---|
42 | tool = getToolByName(self, 'portal_types') |
---|
43 | for ptype in tool.objectValues(): |
---|
44 | if ptype.getId() in ['File','Document','News Item']: |
---|
45 | acts = filter(lambda x: x.id == 'seo_properties', ptype.listActions()) |
---|
46 | action = acts and acts[0] or None |
---|
47 | if action != None: |
---|
48 | acts = list(ptype.listActions()) |
---|
49 | ptype.deleteActions([acts.index(a) for a in acts if a.getId()=='seo_properties']) |
---|
50 | |
---|
51 | def remove_configlets( context, conf_ids ): |
---|
52 | configTool = getToolByName(context, 'portal_controlpanel', None) |
---|
53 | if configTool: |
---|
54 | for id in conf_ids: |
---|
55 | configTool.unregisterConfiglet(id) |
---|
56 | |
---|
57 | def uninstall( context ): |
---|
58 | if context.readDataFile('seo_uninstall.txt') is None: |
---|
59 | return |
---|
60 | site = context.getSite() |
---|
61 | removeSkin( site, 'quintagroup.seoptimizer' ) |
---|
62 | removeActions( site ) |
---|
63 | remove_configlets( site, ('quintagroup.seoptimizer',)) |
---|
64 | |
---|