1 | ## Controller Python Script "csshover_save" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind state=state |
---|
7 | ##bind subpath=traverse_subpath |
---|
8 | ##parameters=enabled=False, csshovering=[], sheetId='csshover.css', title='CSS Hover' |
---|
9 | ##title= |
---|
10 | ## |
---|
11 | |
---|
12 | from Products.CMFCore.utils import getToolByName |
---|
13 | from Products.qPloneDropDownMenu.utils import addCSS |
---|
14 | folder = getToolByName(context, 'portal_skins').restrictedTraverse('custom') |
---|
15 | |
---|
16 | if csshovering.find('.cssHoverCSSExists {}') == -1: csshovering = '.cssHoverCSSExists {}\n\n' + csshovering |
---|
17 | if not sheetId in folder.objectIds(): |
---|
18 | if csshovering.find('Use this configlet in IE') != -1: csshovering = " " |
---|
19 | addCSS(folder, sheetId, title, csshovering) |
---|
20 | message = 'Added %s to plone_skins custom folder. ' % sheetId |
---|
21 | else: |
---|
22 | if csshovering.find('Use this configlet in IE') == -1: |
---|
23 | getattr(folder, sheetId).manage_edit(csshovering,title) |
---|
24 | message = 'Updated %s. ' % sheetId |
---|
25 | else: message = 'Visit this page in IE to see and activate generated CSS. ' |
---|
26 | cssreg = getToolByName(context, 'portal_css', None) |
---|
27 | if cssreg is not None: |
---|
28 | stylesheet_ids = cssreg.getResourceIds() |
---|
29 | if sheetId not in stylesheet_ids: |
---|
30 | cssreg.registerStylesheet(id=sheetId, enabled=enabled) |
---|
31 | try: cssreg.moveResource(sheetId, cssreg.getResourcePosition('textLarge.css')+1) |
---|
32 | except: pass |
---|
33 | cssreg.cookResources() |
---|
34 | else: |
---|
35 | cssreg.updateStylesheet(sheetId, **{'enabled' : enabled}) |
---|
36 | cssreg.cookResources() |
---|
37 | else: |
---|
38 | message += "For activating csshover.css customize ploneCustom.css and add <dtml-var csshover.css> line before <dtml-var drop_down.css>" |
---|
39 | |
---|
40 | context.plone_utils.addPortalMessage(message) |
---|
41 | |
---|
42 | return state.set(status='success') |
---|