Index: trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | array_shift( $params ); // don't need the parser |
155 | 155 | // set defaults |
156 | 156 | $inFormName = $inLinkStr = $inLinkType = $inQueryStr = $inTargetName = ''; |
157 | | - $popupClassString = ""; |
| 157 | + $classStr = ""; |
158 | 158 | // assign params - support unlabelled params, for backwards compatibility |
159 | 159 | foreach ( $params as $i => $param ) { |
160 | 160 | $elements = explode( '=', $param, 2 ); |
— | — | @@ -176,7 +176,7 @@ |
177 | 177 | } elseif ( $param_name == null && $value == 'popup' |
178 | 178 | && version_compare( $wgVersion, '1.16', '>=' )) { |
179 | 179 | self::loadScriptsForPopupForm( $parser ); |
180 | | - $popupClassString = 'class="popupformlink"'; |
| 180 | + $classStr = 'popupformlink'; |
181 | 181 | } |
182 | 182 | elseif ( $i == 0 ) { |
183 | 183 | $inFormName = $param; |
— | — | @@ -226,18 +226,23 @@ |
227 | 227 | if ( $inLinkType == 'button' ) { |
228 | 228 | $link_url = html_entity_decode( $link_url, ENT_QUOTES ); |
229 | 229 | $link_url = str_replace( "'", "\'", $link_url ); |
230 | | - $str = "<form $popupClassString>"; |
| 230 | + $str = "<form class=\"$classStr\">"; |
231 | 231 | $str .= Xml::element( 'input', array( |
232 | 232 | 'type' => 'button', |
233 | 233 | 'value' => $inLinkStr, |
234 | 234 | 'onclick' => "window.location.href='$link_url'", |
235 | 235 | ) ) . "</form>"; |
236 | 236 | } elseif ( $inLinkType == 'post button' ) { |
237 | | - $str = "<form action=\"$link_url\" method=\"post\" $popupClassString>"; |
| 237 | + $str = "<form action=\"$link_url\" method=\"post\" class=\"$classStr\">"; |
238 | 238 | $str .= Xml::element( 'input', array( 'type' => 'submit', 'value' => $inLinkStr ) ); |
239 | 239 | $str .= "$hidden_inputs</form>"; |
240 | 240 | } else { |
241 | | - $str = "<a href=\"$link_url\" $popupClassString>$inLinkStr</a>"; |
| 241 | + // If target page doesn't exist, make it a red link |
| 242 | + $targetTitle = Title::newFromText( $inTargetName ); |
| 243 | + if ( !$targetTitle->exists() ) { |
| 244 | + $classStr .= " new"; |
| 245 | + } |
| 246 | + $str = "<a href=\"$link_url\" class=\"$classStr\">$inLinkStr</a>"; |
242 | 247 | } |
243 | 248 | // hack to remove newline from beginning of output, thanks to |
244 | 249 | // http://jimbojw.com/wiki/index.php?title=Raw_HTML_Output_from_a_MediaWiki_Parser_Function |
— | — | @@ -253,7 +258,7 @@ |
254 | 259 | $inFormName = $inValue = $inButtonStr = $inQueryStr = ''; |
255 | 260 | $inAutocompletionSource = ''; |
256 | 261 | $inSize = 25; |
257 | | - $popupClassString = ""; |
| 262 | + $classStr = ""; |
258 | 263 | // assign params - support unlabelled params, for backwards compatibility |
259 | 264 | foreach ( $params as $i => $param ) { |
260 | 265 | $elements = explode( '=', $param, 2 ); |
— | — | @@ -282,7 +287,7 @@ |
283 | 288 | } elseif ( $param_name == null && $value == 'popup' |
284 | 289 | && version_compare( $wgVersion, '1.16', '>=' )) { |
285 | 290 | self::loadScriptsForPopupForm( $parser ); |
286 | | - $popupClassString = 'class="popupforminput"'; |
| 291 | + $classStr = 'popupforminput'; |
287 | 292 | } |
288 | 293 | elseif ( $i == 0 ) |
289 | 294 | $inFormName = $param; |
— | — | @@ -317,7 +322,7 @@ |
318 | 323 | $fs_url = $fs->getTitle()->getLocalURL(); |
319 | 324 | if ( empty( $inAutocompletionSource ) ) { |
320 | 325 | $str = <<<END |
321 | | - <form action="$fs_url" method="get" $popupClassString> |
| 326 | + <form action="$fs_url" method="get" class="$classStr"> |
322 | 327 | <p> |
323 | 328 | |
324 | 329 | END; |
— | — | @@ -325,7 +330,7 @@ |
326 | 331 | array( 'type' => 'text', 'name' => 'page_name', 'size' => $inSize, 'value' => $inValue, 'class' => 'formInput' ) ); |
327 | 332 | } else { |
328 | 333 | $str = <<<END |
329 | | - <form name="createbox" action="$fs_url" method="get" $popupClassString> |
| 334 | + <form name="createbox" action="$fs_url" method="get" class="$classStr"> |
330 | 335 | <p> |
331 | 336 | |
332 | 337 | END; |