Thread:Extension talk:Ratings/Top10 ratings output

setHook( 'ratingstop', 'getRatingsTop' ); return true; }

/** * Get top N elements for some rating * * @return String: HTML */ function getRatingsTop( $input, $args, $parser ) { global $wgMemc, $wgUploadPath;

$dbr = wfGetDB( DB_SLAVE );

if (!isset($args['tag'])) { return "Tag must be specified"; }	$tag = $args['tag']; $limit = !isset($args['limit']) ? 10 : intval($args['limit']); $desc = isset($args['desc']) ? ' DESC' : '';

$res = $dbr->select(			array( 'votes', 'vote_props', 'page' ),			array( 'page_title', 'avg(vote_value) vv', 'count(vote_value) vc' ),			array( 'page_id=vote_page_id','vote_prop_id=prop_id','prop_name' => $tag, ),			__METHOD__,			array( 'GROUP BY' => 'page_namespace, page_title', 'ORDER BY' => 'vv'. $desc. ', vc DESC', 'LIMIT' => $limit )	);

$ratingsTopItems = array; foreach ( $res as $row ) { $ratingsTopItems[] = array(				'page_namespace' => $row->page_namespace,				'page_title' => $row->page_title,				'vv' => $row->vv,				'vc' => $row->vc		); }

$comments = '';

foreach ( $ratingsTopItems as $item ) { $title = Title::makeTitle(				$item['page_namespace'],				$item['page_title']		);

$comments .= ''; $comments .= 'getFullURL . '"'. ' title="' . $title->getText . '">'. $title->getText. ''; $comments .= ''; }	$comments .= '';

return $comments; }