本文整理汇总了PHP中MWNamespace::canTalk方法的典型用法代码示例。如果您正苦于以下问题:PHP MWNamespace::canTalk方法的具体用法?PHP MWNamespace::canTalk怎么用?PHP MWNamespace::canTalk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MWNamespace
的用法示例。
在下文中一共展示了MWNamespace::canTalk方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canTalk
/**
* Could this title have a corresponding talk page?
*
* @return bool
*/
public function canTalk()
{
return MWNamespace::canTalk($this->mNamespace);
}
示例2: generateFeed
/**
* Generate the feed items given a row from the database.
* @param $rows DatabaseBase resource with recentchanges rows
* @param $feed Feed object
*/
public static function generateFeed($rows, &$feed)
{
wfProfileIn(__METHOD__);
$feed->outHeader();
# Merge adjacent edits by one user
$sorted = array();
$n = 0;
foreach ($rows as $obj) {
if ($n > 0 && $obj->rc_type == RC_EDIT && $obj->rc_namespace >= 0 && $obj->rc_cur_id == $sorted[$n - 1]->rc_cur_id && $obj->rc_user_text == $sorted[$n - 1]->rc_user_text) {
$sorted[$n - 1]->rc_last_oldid = $obj->rc_last_oldid;
} else {
$sorted[$n] = $obj;
$n++;
}
}
foreach ($sorted as $obj) {
$title = Title::makeTitle($obj->rc_namespace, $obj->rc_title);
$talkpage = MWNamespace::canTalk($obj->rc_namespace) ? $title->getTalkPage()->getFullURL() : '';
// Skip items with deleted content (avoids partially complete/inconsistent output)
if ($obj->rc_deleted) {
continue;
}
if ($obj->rc_this_oldid) {
$url = $title->getFullURL(array('diff' => $obj->rc_this_oldid, 'oldid' => $obj->rc_last_oldid));
} else {
// log entry or something like that.
$url = $title->getFullURL();
}
$item = new FeedItem($title->getPrefixedText(), FeedUtils::formatDiff($obj), $url, $obj->rc_timestamp, $obj->rc_deleted & Revision::DELETED_USER ? wfMessage('rev-deleted-user')->escaped() : $obj->rc_user_text, $talkpage);
$feed->outItem($item);
}
$feed->outFooter();
wfProfileOut(__METHOD__);
}
示例3: onArticleViewFooter
public static function onArticleViewFooter( $article ) {
global $wgOut, $wgRequest, $wgUser, $wgJsMimeType, $wgUseAjax, $wgTalkHereNamespaces;
$action = $wgRequest->getVal( 'action', 'view' );
if ( $action != 'view' && $action != 'purge' ) {
return true;
}
if ( $wgRequest->getVal( 'oldid' ) || $wgRequest->getVal( 'diff' ) ) {
return true;
}
$title = $article->getTitle();
$ns = $title->getNamespace();
if ( MWNamespace::isTalk($ns) || !MWNamespace::canTalk($ns) || !$title->exists()
|| ( $wgTalkHereNamespaces && !in_array( $ns, $wgTalkHereNamespaces ) ) ) {
return true;
}
$talk = $title->getTalkPage();
if ( !$talk || !$talk->userCanRead() ) {
return true;
}
$hastalk = $talk->exists();
$cantalk = $talk->userCan('edit');
if ( !$hastalk && !$cantalk ) {
return true;
}
$skin = $wgUser->getSkin();
$talkArticle = Article::newFromTitle( $talk, RequestContext::getMain() );
$wgOut->addHTML('<div class="talkhere" id="talkhere">');
if ($hastalk) {
//Bah, would have to call a skin-snippet here :(
$wgOut->addHTML('<div class="talkhere-head">');
$wgOut->addHTML('<h1>');
if ($talk->userCan('edit')) {
$wgOut->addHTML('<span class="editsection">');
$wgOut->addHTML( '[' . $skin->makeKnownLinkObj( $talk, wfMsg('talkhere-talkpage' ) ) . ']' );
$wgOut->addHTML('</span>');
}
$wgOut->addWikiText( wfMsg('talkhere-title', $talk->getPrefixedText() ), false );
$wgOut->addHTML('</h1>');
$headtext = wfMsg('talkhere-headtext', $title->getPrefixedText(), $talk->getPrefixedText() );
if ( $headtext ) {
$wgOut->addWikiText( $headtext );
$wgOut->addHTML('<hr/>');
}
$wgOut->addHTML('</div>'); //talkhere-head
$wgOut->addHTML('<div class="talkhere-comments">');
$talkArticle->view();
$wgOut->addHTML('</div>'); // talkhere-comments
}
$wgOut->addHTML('<div class="talkhere-foot">');
if ( $cantalk ) {
if ($hastalk) {
$wgOut->addHTML('<hr/>');
}
else {
$wgOut->addHTML('<div class="talkhere-comments talkhere-notalk">');
$wgOut->addWikiText( wfMsg('talkhere-notalk') );
$wgOut->addHTML('</div>'); // talkhere-comments
}
if ( $wgUseAjax ) $wgOut->addScript(
" <script type=\"{$wgJsMimeType}\">
var talkHereLoadingMsg = \"" . Xml::escapeJsString(wfMsg('talkhere-loading')) . "\";
var talkHereCollapseMsg = \"" . Xml::escapeJsString(wfMsg('talkhere-collapse')) . "\";
var talkHereExpandMsg = \"" . Xml::escapeJsString(wfMsg('talkhere-addcomment')) . "\";
</script>\n"
);
$returnto = $title->getPrefixedDBKey();
$talktitle = $talk->getPrefixedDBKey();
$q = 'action=edit§ion=new&wpTalkHere=1&wpReturnTo=' . urlencode($returnto);
$js = $wgUseAjax ? 'this.href="javascript:void(0);"; talkHereLoadEditor("talkhere_talklink", "talkhere_talkform", "'.Xml::escapeJsString($talktitle).'", "new", "'.Xml::escapeJsString($returnto).'"); ' : '';
$a = 'onclick="'.htmlspecialchars($js).'" id="talkhere_talklink"';
$wgOut->addHTML('<div class="talkhere-talklink">');
$wgOut->addHTML( $skin->makeKnownLinkObj( $talk, wfMsg('talkhere-addcomment' ), $q, '', '', $a ) );
$wgOut->addHTML('</div>');
$wgOut->addHTML('<div id="talkhere_talkform" style="display:none;"> </div>');
//self::showCommentForm( $title, $talk, 'new' );
}
//.........这里部分代码省略.........
示例4: buildItems
/**
* Generate the feed items given a row from the database.
* @param object $rows DatabaseBase resource with recentchanges rows
* @return array
*/
public static function buildItems($rows)
{
$items = [];
# Merge adjacent edits by one user
$sorted = [];
$n = 0;
foreach ($rows as $obj) {
if ($obj->rc_type == RC_EXTERNAL) {
continue;
}
if ($n > 0 && $obj->rc_type == RC_EDIT && $obj->rc_namespace >= 0 && $obj->rc_cur_id == $sorted[$n - 1]->rc_cur_id && $obj->rc_user_text == $sorted[$n - 1]->rc_user_text) {
$sorted[$n - 1]->rc_last_oldid = $obj->rc_last_oldid;
} else {
$sorted[$n] = $obj;
$n++;
}
}
foreach ($sorted as $obj) {
$title = Title::makeTitle($obj->rc_namespace, $obj->rc_title);
$talkpage = MWNamespace::canTalk($obj->rc_namespace) ? $title->getTalkPage()->getFullURL() : '';
// Skip items with deleted content (avoids partially complete/inconsistent output)
if ($obj->rc_deleted) {
continue;
}
if ($obj->rc_this_oldid) {
$url = $title->getFullURL(['diff' => $obj->rc_this_oldid, 'oldid' => $obj->rc_last_oldid]);
} else {
// log entry or something like that.
$url = $title->getFullURL();
}
$items[] = new FeedItem($title->getPrefixedText(), FeedUtils::formatDiff($obj), $url, $obj->rc_timestamp, $obj->rc_deleted & Revision::DELETED_USER ? wfMessage('rev-deleted-user')->escaped() : $obj->rc_user_text, $talkpage);
}
return $items;
}
示例5: testCanTalk
/**
*/
public function testCanTalk()
{
$this->assertFalse(MWNamespace::canTalk(NS_MEDIA));
$this->assertFalse(MWNamespace::canTalk(NS_SPECIAL));
$this->assertTrue(MWNamespace::canTalk(NS_MAIN));
$this->assertTrue(MWNamespace::canTalk(NS_TALK));
$this->assertTrue(MWNamespace::canTalk(NS_USER));
$this->assertTrue(MWNamespace::canTalk(NS_USER_TALK));
// User defined namespaces
$this->assertTrue(MWNamespace::canTalk(100));
$this->assertTrue(MWNamespace::canTalk(101));
}