r38163 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38162‎ | r38163 | r38164 >
Date:00:35, 29 July 2008
Author:simetrical
Status:old
Tags:
Comment:
Partially revert r38162. Caused bugs due to incredibly incomprehensible parameter list for makeKnownLinkObj. (Hint: $aprops and $style do virtually the same thing, except that the latter has a completely misleading name and documentation.)
There is no salvation possible for this method. It must die.
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -302,10 +302,7 @@
303303 * @param $query String: link target
304304 * @param $trail String: text after link
305305 * @param $prefix String: text before link text
306 - * @param $aprops Mixed: extra attributes to the a-element. If a string,
307 - * inserted literally into the HTML, with a space prepended. It can also
308 - * be an associative array. In this case the keys are attributes, and
309 - * values are *unescaped* attribute values.
 306+ * @param $aprops String: extra attributes to the a-element
310307 * @param $style String: style to apply - if empty, use getInternalLinkAttributesObj instead
311308 * @return the a-element
312309 */
@@ -331,16 +328,7 @@
332329 $style = $this->getInternalLinkAttributesObj( $nt, $text );
333330 }
334331
335 - if( is_string( $aprops ) && $aprops != '' ) {
336 - $aprops = " $aprops";
337 - } elseif( is_array( $aprops ) ) {
338 - $attributes = $aprops;
339 - $aprops = '';
340 - foreach( $attributes as $key => $value ) {
341 - $value = htmlspecialchars( $value );
342 - $aprops .= " $key=\"$value\"";
343 - }
344 - }
 332+ if ( $aprops !== '' ) $aprops = " $aprops";
345333
346334 list( $inside, $trail ) = Linker::splitTrail( $trail );
347335 $r = "<a href=\"{$u}\"{$style}{$aprops}>{$prefix}{$text}{$inside}</a>{$trail}";
@@ -1298,22 +1286,23 @@
12991287 * @return string HTML to use for edit link
13001288 */
13011289 public function doEditSectionLink( Title $nt, $section, $tooltip='' ) {
 1290+ $attribs = '';
 1291+ if( $tooltip ) {
 1292+ $attribs = wfMsgHtml( 'editsectionhint', htmlspecialchar
 1293+s( $tooltip ) );
 1294+ $attribs = " title=\"$attribs\"";
 1295+ }
 1296+
13021297 $url = $this->makeKnownLinkObj(
13031298 $nt,
13041299 htmlspecialchars(wfMsg('editsection')),
13051300 "action=edit&section=$section",
1306 - '', '', '',
1307 - array( 'title' => wfMsg( 'editsectionhint', $tooltip ) )
 1301+ '', '', '', $attribs
13081302 );
13091303
1310 - # Run the old hook. This takes up most of the function . . . hopefully
 1304+ # Run the old hook. This takes up half of the function . . . hopefully
13111305 # we can rid of it someday.
13121306 $result = null;
1313 - $attribs = '';
1314 - if( $tooltip ) {
1315 - $attribs = wfMsgHtml( 'editsectionhint', htmlspecialchars( $tooltip ) );
1316 - $attribs = " title=\"$attribs\"";
1317 - }
13181307 wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $attribs, $url, &$result ) );
13191308 if( !is_null( $result ) ) {
13201309 # For reverse compatibility, add the brackets *after* the hook is

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r38162Linker.php cleanup:...simetrical00:08, 29 July 2008

Status & tagging log