1 | ## Controller Python Script "silo_navigation_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 Folder Property |
---|
9 | ##parameters= menu_ids='' |
---|
10 | # |
---|
11 | |
---|
12 | from Products.CMFCore.utils import getToolByName |
---|
13 | from Products.qSiloGroup.utils import isStructuralFolder, getDefaultPage |
---|
14 | |
---|
15 | silo_items = [] |
---|
16 | for id in menu_ids: |
---|
17 | default_page = '' |
---|
18 | if getattr(context.aq_explicit, id, None): |
---|
19 | item = getattr(context.aq_explicit, id) |
---|
20 | else: |
---|
21 | continue |
---|
22 | if isStructuralFolder(item): |
---|
23 | ids = {} |
---|
24 | for i in item.objectIds(): |
---|
25 | ids[i] = 1 |
---|
26 | page = getDefaultPage(item) |
---|
27 | if page and ids.has_key(page): |
---|
28 | default_page = page |
---|
29 | if default_page == '': |
---|
30 | site_properties = getToolByName(context, 'portal_properties').site_properties |
---|
31 | for page in site_properties.getProperty('default_page', []): |
---|
32 | if page and ids.has_key(page): |
---|
33 | default_page = page |
---|
34 | break |
---|
35 | silo_items.append(id+'|'+default_page+'|'+context.REQUEST.get(id+'_title','')) |
---|
36 | if context.hasProperty('silo_items'): |
---|
37 | context.manage_changeProperties({'silo_items': silo_items}) |
---|
38 | else: |
---|
39 | context.manage_addProperty('silo_items', silo_items, type='lines') |
---|
40 | |
---|
41 | return state.set(status='success', portal_status_message='Silo Navigation property have been saved.') |
---|