comparison MoinMoin/wikiutil.py @ 471:9b6ba709da88

added header element ids: userhome, userprefs, login, logout imported from: moin--main--1.5--patch-475
author Thomas Waldmann <tw@waldmann-edv.de>
date Mon, 13 Mar 2006 20:05:27 +0000
parents e5609b8b7647
children ca35d9e6d63e
comparison
equal deleted inserted replaced
470:957d482215ac 471:9b6ba709da88
986 986
987 987
988 def link_tag(request, params, text=None, formatter=None, on=None, **kw): 988 def link_tag(request, params, text=None, formatter=None, on=None, **kw):
989 """ Create a link. 989 """ Create a link.
990 990
991 TODO: cleanup css_class
992
991 @param request: the request object 993 @param request: the request object
992 @param params: parameter string appended to the URL after the scriptname/ 994 @param params: parameter string appended to the URL after the scriptname/
993 @param text: text / inner part of the <a>...</a> link - does NOT get 995 @param text: text / inner part of the <a>...</a> link - does NOT get
994 escaped, so you can give HTML here and it will be used verbatim 996 escaped, so you can give HTML here and it will be used verbatim
995 @param formatter: the formatter object to use 997 @param formatter: the formatter object to use
997 @keyword attrs: additional attrs (HTMLified string) 999 @keyword attrs: additional attrs (HTMLified string)
998 @rtype: string 1000 @rtype: string
999 @return: formatted link tag 1001 @return: formatted link tag
1000 """ 1002 """
1001 css_class = kw.get('css_class', None) 1003 css_class = kw.get('css_class', None)
1004 id = kw.get('id', None)
1002 if text is None: 1005 if text is None:
1003 text = params # default 1006 text = params # default
1004 if formatter: 1007 if formatter:
1005 url = "%s/%s" % (request.getScriptname(), params) 1008 url = "%s/%s" % (request.getScriptname(), params)
1006 if on != None: 1009 if on != None:
1014 attrs = '' 1017 attrs = ''
1015 if kw.has_key('attrs'): 1018 if kw.has_key('attrs'):
1016 attrs += ' ' + kw['attrs'] 1019 attrs += ' ' + kw['attrs']
1017 if css_class: 1020 if css_class:
1018 attrs += ' class="%s"' % css_class 1021 attrs += ' class="%s"' % css_class
1022 if id:
1023 attrs += ' id="%s"' % id
1019 result = '<a%s href="%s/%s">' % (attrs, request.getScriptname(), params) 1024 result = '<a%s href="%s/%s">' % (attrs, request.getScriptname(), params)
1020 if on: 1025 if on:
1021 return result 1026 return result
1022 else: 1027 else:
1023 return "%s%s</a>" % (result, text) 1028 return "%s%s</a>" % (result, text)