当前位置: 首页>>代码示例>>PHP>>正文


PHP MWNamespace::canTalk方法代码示例

本文整理汇总了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);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:9,代码来源:Title.php

示例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__);
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:39,代码来源:ChangesFeed.php

示例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&section=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;">&#160;</div>');
			//self::showCommentForm( $title, $talk, 'new' );
		}
//.........这里部分代码省略.........
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:101,代码来源:TalkHereHooks.php

示例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;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:39,代码来源:ChangesFeed.php

示例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));
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:14,代码来源:MWNamespaceTest.php


注:本文中的MWNamespace::canTalk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。