當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Revision::countByPageId方法代碼示例

本文整理匯總了PHP中Revision::countByPageId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Revision::countByPageId方法的具體用法?PHP Revision::countByPageId怎麽用?PHP Revision::countByPageId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Revision的用法示例。


在下文中一共展示了Revision::countByPageId方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: broken_testDoRollback

 /**
  * @todo FIXME: this is a better rollback test than the one below, but it
  * keeps failing in jenkins for some reason.
  */
 public function broken_testDoRollback()
 {
     $admin = new User();
     $admin->setName("Admin");
     $text = "one";
     $page = $this->newPage("WikiPageTest_testDoRollback");
     $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle()), "section one", EDIT_NEW, false, $admin);
     $user1 = new User();
     $user1->setName("127.0.1.11");
     $text .= "\n\ntwo";
     $page = new WikiPage($page->getTitle());
     $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle()), "adding section two", 0, false, $user1);
     $user2 = new User();
     $user2->setName("127.0.2.13");
     $text .= "\n\nthree";
     $page = new WikiPage($page->getTitle());
     $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle()), "adding section three", 0, false, $user2);
     # we are having issues with doRollback spuriously failing. Apparently
     # the last revision somehow goes missing or not committed under some
     # circumstances. So, make sure the last revision has the right user name.
     $dbr = wfGetDB(DB_SLAVE);
     $this->assertEquals(3, Revision::countByPageId($dbr, $page->getId()));
     $page = new WikiPage($page->getTitle());
     $rev3 = $page->getRevision();
     $this->assertEquals('127.0.2.13', $rev3->getUserText());
     $rev2 = $rev3->getPrevious();
     $this->assertEquals('127.0.1.11', $rev2->getUserText());
     $rev1 = $rev2->getPrevious();
     $this->assertEquals('Admin', $rev1->getUserText());
     # now, try the actual rollback
     $admin->addGroup("sysop");
     #XXX: make the test user a sysop...
     $token = $admin->getEditToken(array($page->getTitle()->getPrefixedText(), $user2->getName()), null);
     $errors = $page->doRollback($user2->getName(), "testing revert", $token, false, $details, $admin);
     if ($errors) {
         $this->fail("Rollback failed:\n" . print_r($errors, true) . ";\n" . print_r($details, true));
     }
     $page = new WikiPage($page->getTitle());
     $this->assertEquals($rev2->getSha1(), $page->getRevision()->getSha1(), "rollback did not revert to the correct revision");
     $this->assertEquals("one\n\ntwo", $page->getContent()->getNativeData());
 }
開發者ID:Habatchii,項目名稱:wikibase-for-mediawiki,代碼行數:45,代碼來源:WikiPageTest.php

示例2: countByTitle

 /**
  * Get count of revisions per page...not very efficient
  * @param Database $db
  * @param Title $title
  */
 static function countByTitle($db, $title)
 {
     $id = $title->getArticleId();
     if ($id) {
         return Revision::countByPageId($db, $id);
     }
     return 0;
 }
開發者ID:josephdye,項目名稱:wikireader,代碼行數:13,代碼來源:Revision.php

示例3: getRevCount

 private function getRevCount(ApiResult $result)
 {
     $res = $result->getData();
     $db = $this->getDB();
     if (isset($res['query']) && isset($res['query']['pages'])) {
         foreach ($this->getPageSet()->getGoodTitles() as $page_id => $oTitle) {
             if (isset($res['query']['pages'][$page_id])) {
                 $revcount = Revision::countByPageId($db, $page_id);
                 $result->addValue(array("query", "pages", $page_id), "revcount", intval($revcount));
             }
         }
     }
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:13,代碼來源:WikiaApiQueryPageinfo.php


注:本文中的Revision::countByPageId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。