comparison MoinMoin/wikiutil.py @ 515:1b9f0d6b9f48

fixed double CSS class attribute for nonexistent links, removed ugly formatter.url attrs keyword handling code imported from: moin--main--1.5--patch-519
author Thomas Waldmann <tw@waldmann-edv.de>
date Tue, 28 Mar 2006 21:52:01 +0000
parents ef41e35985dc
children 39da9e68875c
comparison
equal deleted inserted replaced
514:fc74944187ad 515:1b9f0d6b9f48
1078 @param params: parameter string appended to the URL after the scriptname/ 1078 @param params: parameter string appended to the URL after the scriptname/
1079 @param text: text / inner part of the <a>...</a> link - does NOT get 1079 @param text: text / inner part of the <a>...</a> link - does NOT get
1080 escaped, so you can give HTML here and it will be used verbatim 1080 escaped, so you can give HTML here and it will be used verbatim
1081 @param formatter: the formatter object to use 1081 @param formatter: the formatter object to use
1082 @param on: opening/closing tag only 1082 @param on: opening/closing tag only
1083 @keyword attrs: additional attrs (HTMLified string) 1083 @keyword attrs: additional attrs (HTMLified string) (removed in 1.5.3)
1084 @rtype: string 1084 @rtype: string
1085 @return: formatted link tag 1085 @return: formatted link tag
1086 """ 1086 """
1087 css_class = kw.get('css_class', None) 1087 if kw.has_key('css_class'):
1088 css_class = kw['css_class']
1089 del kw['css_class'] # one time is enough
1090 else:
1091 css_class = None
1088 id = kw.get('id', None) 1092 id = kw.get('id', None)
1089 if text is None: 1093 if text is None:
1090 text = params # default 1094 text = params # default
1091 if formatter: 1095 if formatter:
1092 url = "%s/%s" % (request.getScriptname(), params) 1096 url = "%s/%s" % (request.getScriptname(), params)
1097 formatter.url(0)) 1101 formatter.url(0))
1098 if on != None and not on: 1102 if on != None and not on:
1099 return '</a>' 1103 return '</a>'
1100 1104
1101 attrs = '' 1105 attrs = ''
1102 if kw.has_key('attrs'):
1103 attrs += ' ' + kw['attrs']
1104 if css_class: 1106 if css_class:
1105 attrs += ' class="%s"' % css_class 1107 attrs += ' class="%s"' % css_class
1106 if id: 1108 if id:
1107 attrs += ' id="%s"' % id 1109 attrs += ' id="%s"' % id
1108 result = '<a%s href="%s/%s">' % (attrs, request.getScriptname(), params) 1110 result = '<a%s href="%s/%s">' % (attrs, request.getScriptname(), params)