Back to index

moin  1.9.0~rc2
EditTemplates.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - Create a list of currentpage?action=edit&template=X links
00004     for all available templates X. Used by MissingPage.
00005 
00006     @copyright: 2004 Johannes Berg <johannes@sipsolutions.de>
00007     @license: GNU GPL, see COPYING for details.
00008 """
00009 
00010 Dependencies = ["language"]
00011 
00012 def macro_EditTemplates(macro):
00013     result = ''
00014     # we don't want to spend much CPU for spiders requesting nonexisting pages
00015     if not macro.request.isSpiderAgent:
00016         # Get list of template pages readable by current user
00017         filterfn = macro.request.cfg.cache.page_template_regexact.search
00018         templates = macro.request.rootpage.getPageList(filter=filterfn)
00019         result = []
00020         if templates:
00021             templates.sort()
00022             page = macro.formatter.page
00023             # send list of template pages
00024             result.append(macro.formatter.bullet_list(1))
00025             for template in templates:
00026                 result.append(macro.formatter.listitem(1))
00027                 result.append(page.link_to(macro.request, template, querystr={'action': 'edit', 'template': template}))
00028                 result.append(macro.formatter.listitem(0))
00029             result.append(macro.formatter.bullet_list(0))
00030         result = ''.join(result)
00031     return result
00032