source: products/qSEOptimizer/tags/1.5.0/skins/qSEOptimizer/prefs_qseo_setup.cpy @ 1

Last change on this file since 1 was 1, checked in by myroslav, 18 years ago

Building directory structure

File size: 1.9 KB
Line 
1## Script (Python) "prefs_seo_config"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters= portalTypes=[], exposeDCMetaTags=None, additionalKeywords=[], default_custom_metatags=[]
8##title=add action tab for selected portal types
9##
10from Products.CMFCore.utils import getToolByName
11
12portal_props = getToolByName(context, 'portal_properties')
13site_props = getToolByName(portal_props, 'site_properties')
14seo_props = getToolByName(portal_props, 'seo_properties')
15site_props.manage_changeProperties(exposeDCMetaTags=exposeDCMetaTags)
16seo_props.manage_changeProperties(additional_keywords=additionalKeywords)
17seo_props.manage_changeProperties(default_custom_metatags=default_custom_metatags)
18
19pt = getToolByName(context, 'portal_types')
20for ptype in pt.objectValues():
21    try:
22        #for Plone-2.5 and higher
23        acts = filter(lambda x: x.id == 'seo_properties', ptype.listActions())
24        action = acts and acts[0] or None
25    except AttributeError:
26        action = ptype.getActionById('seo_properties', default=None )
27
28    if ptype.getId() in portalTypes:
29        if action is None:
30            ptype.addAction('seo_properties',
31                            'SEO Properties',
32                            'string:${object_url}/qseo_properties_edit_form',
33                            '',
34                            'Modify portal content',
35                            'object',
36                            visible=1)
37    else:
38        if action !=None:
39            actions = list(ptype.listActions())
40            ptype.deleteActions([actions.index(a) for a in actions if a.getId()=='seo_properties'])
41
42
43msg = "Search Engine Optimizer configuration updated."
44try:
45    context.plone_utils.addPortalMessage(msg)
46    return state
47except AttributeError:
48    return state.set(context=context, portal_status_message=msg)
Note: See TracBrowser for help on using the repository browser.