【发布时间】:2017-01-12 22:45:55
【问题描述】:
我正在更新一个 MediaWiki 扩展程序,该扩展程序显示一个类别 (CategoryGallery) 中的所有图像。
我想显示上传图片的用户的姓名,然后可能按用户过滤。
部分代码是这样的:
// Capitalize the first letter in the category argument, convert spaces to _
$params['cat'] = str_replace ( ' ', '_', ucfirst( $params['cat'] ) );
// Retrieve category members from database
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'categorylinks', 'cl_from',
array ('cl_to' => $params['cat'],
'cl_type' => 'file'));
$ids = array();
foreach ( $res as $row ) {
$ids[] = $row->cl_from;
}
// Create the gallery
$titles = Title::newFromIDs ( $ids );
$text = '';
foreach ( $titles as $title ) {
$titlePrefixedDBKey = $title->getPrefixedDBKey();
$text .= $titlePrefixedDBKey;
$text .= "|**Username**:\n";
}
$output = $parser->renderImageGallery( $text, $params )
如何检索上传照片的用户的姓名以将其显示在图片库中(我在其中放置了用户名)?
【问题讨论】:
-
$title->getFirstRevision()->getUserText() -
感谢您的帮助@Tgr!