source: products/quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/skins/quintagroup.seoptimizer/qseo_properties_edit.cpy @ 896

Last change on this file since 896 was 896, checked in by chervol, 17 years ago

fixed the recent portlet markup, added extra css class for the 'more...' link

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1## Controller Python Script "qseo_properties_edit"
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##title=Update SEO Properties
9##parameters=title=None,description=None,canonical=None,keywords=None,html_comment=None,robots=None,distribution=None,title_override=0,description_override=0,canonical_override=0,keywords_override=0,html_comment_override=0,robots_override=0,distribution_override=0,custommetatags=[]
10
11def setProperty(context, property, value, type='string'):
12    if context.hasProperty(property):
13        context.manage_changeProperties({property: value})
14    else:
15        context.manage_addProperty(property, value, type)
16
17delete_list = []
18
19# update custom meta tags
20property_prefix = 'qSEO_custom_'
21custom_existing = []
22for property, value in context.propertyItems():
23    if property.find(property_prefix) == 0 and len(property) > len(property_prefix):
24        custom_existing.append(property)
25
26custom_updated = []
27for tag in custommetatags:
28    meta_name, meta_content = tag['meta_name'], tag['meta_content']
29    if meta_name and meta_content:
30        setProperty(context, '%s%s' % (property_prefix, meta_name), meta_content)
31        custom_updated.append('%s%s' % (property_prefix, meta_name))
32
33#add not updated custom metatags to delete list
34for tag in custom_existing:
35    if tag not in custom_updated:
36        delete_list.append(tag)
37
38setProperty(context, 'qSEO_title', title)
39setProperty(context, 'qSEO_description', description)
40setProperty(context, 'qSEO_keywords', keywords, 'lines')
41setProperty(context, 'qSEO_html_comment', html_comment)
42setProperty(context, 'qSEO_robots', robots)
43setProperty(context, 'qSEO_distribution', distribution)
44setProperty(context, 'qSEO_canonical', canonical)
45
46if not title_override:        delete_list.append('qSEO_title')
47if not description_override:  delete_list.append('qSEO_description')
48if not keywords_override:     delete_list.append('qSEO_keywords')
49if not html_comment_override: delete_list.append('qSEO_html_comment')
50if not robots_override:       delete_list.append('qSEO_robots')
51if not distribution_override: delete_list.append('qSEO_distribution')
52if not canonical_override:    delete_list.append('qSEO_canonical')
53
54if delete_list: context.manage_delProperties(delete_list)
55
56msg ='Content SEO properties have been saved.'
57try:
58    context.plone_utils.addPortalMessage(msg)
59    return state
60except AttributeError:
61    return state.set(context=context, portal_status_message=msg)
Note: See TracBrowser for help on using the repository browser.