User "Reedy" posted a comment on MediaWiki.r87150.
Full URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/87150#c16447
Commit summary:
* Get a list of all subscribed hooks, and those subscribers
Essentially what SpecialVersion will give you if wgSpecialVersionShowHooks is
true
Comment:
<pre>
foreach ( $myWgHooks as $hook => $hooks ) {
$ret .= "<tr>
<td>$hook</td>
<td>" . $this->listToText(
$hooks ) . "</td>
</tr>\n";
}
<snip>
/**
* Convert an array of items into a list for display.
*
* @param $list Array of elements to display
* @param $sort Boolean: whether to sort the items in $list
*
* @return String
*/
function listToText( $list, $sort = true ) {
$cnt = count( $list );
if ( $cnt == 1 ) {
// Enforce always returning a string
return (string)self::arrayToString( $list[0] );
} elseif ( $cnt == 0 ) {
return '';
} else {
global $wgLang;
if ( $sort ) {
sort( $list );
}
return $wgLang->listToText( array_map( array(
__CLASS__, 'arrayToString' ), $list ) );
}
}
/**
* Convert an array or object to a string for display.
*
* @param $list Mixed: will convert an array to string if given and
return
* the paramater unaltered otherwise
*
* @return Mixed
*/
static function arrayToString( $list ) {
if( is_array( $list ) && count( $list ) == 1 ) {
$list = $list[0];
}
if( is_object( $list ) ) {
$class = get_class( $list );
return "($class)";
} elseif ( !is_array( $list ) ) {
return $list;
} else {
if( is_object( $list[0] ) ) {
$class = get_class( $list[0] );
} else {
$class = $list[0];
}
return "($class, {$list[1]})";
}
}
</pre>
I suppose I could array_map on the items, and check types, if not a string push
it through SpecialVersion::arrayToString()
_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview