我如何找出用户对我的MediaWiki扩展进行了多少编辑? [英] How do I find out how many edits a user has for my MediaWiki extension?

查看:144
本文介绍了我如何找出用户对我的MediaWiki扩展进行了多少编辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个扩展名,该扩展名允许我添加神奇的词:CURRENTUSERCURRENTUSERREALNAMECURRENTUSERLANGABBRCURRENTUSERGROUPS,现在我想添加CURRENTUSEREDITCOUNTCURRENTUSEREDITCOUNTALL. /p>

我的代码的该部分当前为:

function wfGetCustomVariable(&$parser,&$cache,&$index,&$ret) {
switch ($index) {
    case MAG_CURRENTUSER:
        $parser->disableCache(); # Mark this content as uncacheable
        $ret = $GLOBALS['wgUser']->getName();
        break; 
    case MAG_CURRENTUSERREALNAME:
        $parser->disableCache(); # Mark this content as uncacheable
        $ret = $GLOBALS['wgUser']->getRealName();
        break;
    case MAG_CURRENTUSERLANGABBR
        $parser->disableCache(); # Mark this content as uncacheable
        $ret = $GLOBALS['wgLang']->getCode();
        break;
    case MAG_CURRENTUSERGROUPS
        $parser->disableCache(); # Mark this content as uncacheable
        $array = $GLOBALS['wgUser']->getEffectiveGroups();
        $ret = implode(",", $array);
        break;
}
return true;
}

但是,我似乎找不到用于编辑计数的$ GLOBAL.我已经根据其他扩展程序进行了一些研究,这些扩展程序出于不同的原因而使用了不同的编辑次数,并且发现:

对于 CURRENTUSEREDITCOUNT :

function wfContributionseditcount( $uid ) {
if ( $uid != 0 ) {
        global $wgOut, $wgLang;
        $wgOut->addWikiText( wfMsgExt( 'contributionseditcount', array( 'parsemag' ),
        $wgLang->formatNum( User::edits( $uid ) ),
        User::whoIs( $uid ) ) );
    }
    return true;
}

CURRENTUSEREDITCOUNTALL :

public function execute( $params ) {
    global $wgOut, $wgUser;
    $skin = $wgUser->getSkin();
    $this->setHeaders();
    $this->loadRequest( $params );
    $wgOut->addHTML( $this->makeForm() );
    if( $this->target ) {
        if( User::isIP( $this->target ) ) {
            $this->showResults( $this->countEditsReal( 0, $this->target ) );
        } else {
            $id = User::idFromName( $this->target );
            if( $id ) {
                $this->showResults( $this->countEditsReal( $id, false ), $id );
            } else {
                $wgOut->addHTML( '<p>' . wfMsgHtml( 'countedits-nosuchuser', htmlspecialchars( $this->target ) ) . '</p>' );
            }
        }
    }
    $this->showTopTen( $wgOut );
    return true;
}

过去,我曾尝试自己学习PHP,并且一直在为此苦苦挣扎.我已在当地社区大学报名参加PHP班,但直到12年秋季才开始学习.我在寻找正确的位置,还是找到一个更简单的位置来查找用户的编辑计数?可能是/trunk/phase3/includes/的一部分User.php 某个地方?我应该提到这需要在运行MW 1.17.1的Wiki上运行,因此 classUser 将MW 1.18+在任何地方都无法使用.

解决方案

如果要更改编辑计数的定义,也许您应该直接更改代码,以在删除页面后减少用户的编辑计数. /p>

I'm writing an extension that will allow me to add the magic words: CURRENTUSER, CURRENTUSERREALNAME, CURRENTUSERLANGABBR, CURRENTUSERGROUPS, and now I want to add CURRENTUSEREDITCOUNT and CURRENTUSEREDITCOUNTALL.

That section of my code is currently:

function wfGetCustomVariable(&$parser,&$cache,&$index,&$ret) {
switch ($index) {
    case MAG_CURRENTUSER:
        $parser->disableCache(); # Mark this content as uncacheable
        $ret = $GLOBALS['wgUser']->getName();
        break; 
    case MAG_CURRENTUSERREALNAME:
        $parser->disableCache(); # Mark this content as uncacheable
        $ret = $GLOBALS['wgUser']->getRealName();
        break;
    case MAG_CURRENTUSERLANGABBR
        $parser->disableCache(); # Mark this content as uncacheable
        $ret = $GLOBALS['wgLang']->getCode();
        break;
    case MAG_CURRENTUSERGROUPS
        $parser->disableCache(); # Mark this content as uncacheable
        $array = $GLOBALS['wgUser']->getEffectiveGroups();
        $ret = implode(",", $array);
        break;
}
return true;
}

However, I can't seem to find the $GLOBAL for the edit counts. I've done some research based on other extensions that use different edit counts for different reasons and have found:

For CURRENTUSEREDITCOUNT:

function wfContributionseditcount( $uid ) {
if ( $uid != 0 ) {
        global $wgOut, $wgLang;
        $wgOut->addWikiText( wfMsgExt( 'contributionseditcount', array( 'parsemag' ),
        $wgLang->formatNum( User::edits( $uid ) ),
        User::whoIs( $uid ) ) );
    }
    return true;
}

and for CURRENTUSEREDITCOUNTALL:

public function execute( $params ) {
    global $wgOut, $wgUser;
    $skin = $wgUser->getSkin();
    $this->setHeaders();
    $this->loadRequest( $params );
    $wgOut->addHTML( $this->makeForm() );
    if( $this->target ) {
        if( User::isIP( $this->target ) ) {
            $this->showResults( $this->countEditsReal( 0, $this->target ) );
        } else {
            $id = User::idFromName( $this->target );
            if( $id ) {
                $this->showResults( $this->countEditsReal( $id, false ), $id );
            } else {
                $wgOut->addHTML( '<p>' . wfMsgHtml( 'countedits-nosuchuser', htmlspecialchars( $this->target ) ) . '</p>' );
            }
        }
    }
    $this->showTopTen( $wgOut );
    return true;
}

I have tried to learn PHP on my own in the past, and have struggled with it. I'm signed up for a PHP class at my local community college, but I do not start until Fall `12. Am I looking in the right place, or is there a simpler place to find the user's edit counts? Maybe as part of /trunk/phase3/includes/User.php someplace? I should mention this needs to run on a wiki running MW 1.17.1, so classUser would not work where-as it is MW 1.18+.

解决方案

If what you want is to change the definition of edit count, perhaps you should directly change the code where it reduces the user's editcount after a page is deleted.

这篇关于我如何找出用户对我的MediaWiki扩展进行了多少编辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆