本文整理汇总了PHP中Revision::loadFromPageId方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::loadFromPageId方法的具体用法?PHP Revision::loadFromPageId怎么用?PHP Revision::loadFromPageId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revision
的用法示例。
在下文中一共展示了Revision::loadFromPageId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
function execute( $par ) {
global $wgRequest, $wgOut,$wgUser;
if ( !$this->userCanExecute($wgUser) ) {
$this->displayRestrictionError();
return;
}
$dbr = wfGetDB( DB_SLAVE );
$dbw = wfGetDB( DB_MASTER );
$page_row=array(
'page_id',
'page_namespace'
);
$result=$dbr->select( 'page', $page_row );
while ($myRow=$dbr->fetchRow($result)){
$myId=$myRow['page_id'];
$myNamespace=$myRow['page_namespace'];
if ($myNamespace!=NS_FILE){
$myRevision=Revision::loadFromPageId($dbr,$myId);
$myText=$myRevision->getRawText();
if ($myText==""){
while ($myPrevious=$myRevision->getPrevious()){
if ($myPrevious->getRawText()==''){
$myRevision=$myPrevious;
}
else {
break;
}
}
$blank_row=array(
'blank_page_id' => $myId,
'blank_user_id'
=> $myRevision->getRawUser(),
'blank_user_name'
=> $myRevision->getRawUserText(),
'blank_timestamp'
=> $myRevision->getTimeStamp(),
'blank_summary'
=> $myRevision->getRawComment(),
'blank_parent_id'
=> $myRevision->getParentId(),
);
$checkPresence=$dbr->selectRow('blanked_page',
'blank_page_id'
,array("blank_page_id" => $myId));
if (!$checkPresence){
$dbw->insert('blanked_page',$blank_row);
$mTitle=Title::newFromID($myId);
Article::onArticleDelete( $mTitle );
$mTitle->resetArticleID( 0 );
}
}
}
}
$output = wfMsg( 'purewikideletion-population-done' );
$wgOut->addWikiText($output);
}
示例2: mwSearchUpdateMove
/**
* @param $from
* @param $to Title
* @param $user
* @param $pageid
* @param $redirid
* @return bool
*/
function mwSearchUpdateMove($from, $to, $user, $pageid, $redirid)
{
global $wgDBname;
$db = wfGetDB(DB_MASTER);
$pageRevision = Revision::loadFromPageId($db, $pageid);
if (!is_null($pageRevision)) {
MWSearchUpdater::updatePage($wgDBname, $to, $pageRevision->getText());
}
$redirText = '#REDIRECT [[' . $to->getPrefixedText() . "]]\n";
MWSearchUpdater::updatePage($wgDBname, $from, $redirText);
return true;
}
示例3: getArticleDetails
/**
* Load wikitext and get article URL
*/
public function getArticleDetails($id)
{
$dbr = WikiVisualTranscoder::getDB('read');
$rev = Revision::loadFromPageId($dbr, $id);
if ($rev) {
$text = $rev->getText();
$title = $rev->getTitle();
$url = WikiVisualTranscoder::makeWikihowURL($title);
return array($text, $url, $title);
} else {
return array('', '', null);
}
}
示例4: execute
function execute($par)
{
global $wgOut, $wgRequest;
if (!self::isAuthorized()) {
$wgOut->setRobotpolicy('noindex,nofollow');
$wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
return;
}
$dbr = wfGetDB(DB_SLAVE);
$r = Revision::loadFromPageId($dbr, $wgRequest->getVal('pageid'));
if ($r) {
$title = $r->getTitle()->getText();
Misc::outputFile("{$title}.txt", $r->getText(), "application/force-download");
}
return;
}
示例5: sendModNotification
function sendModNotification(&$rcid, &$article)
{
$articleTitle = null;
if ($article) {
$articleTitle = $article->getTitle();
}
try {
if ($articleTitle && $articleTitle->getArticleID() != 0) {
$dbw = wfGetDB(DB_MASTER);
$r = Revision::loadFromPageId($dbw, $articleTitle->getArticleID());
$u = User::newFromId($r->getUser());
AuthorEmailNotification::notifyMod($article, $u, $r);
}
} catch (Exception $e) {
}
return true;
}
示例6: setup
protected function setup($par)
{
global $wgRequest, $wgUser;
// Options
$opts = new FormOptions();
$this->opts = $opts;
// bind
$opts->add('page1', '');
$opts->add('page2', '');
$opts->add('rev1', '');
$opts->add('rev2', '');
$opts->add('action', '');
// Set values
$opts->fetchValuesFromRequest($wgRequest);
$title1 = Title::newFromText($opts->getValue('page1'));
$title2 = Title::newFromText($opts->getValue('page2'));
if ($title1 && $title1->exists() && $opts->getValue('rev1') == '') {
$pda = new Article($title1);
$pdi = $pda->getID();
$pdLastRevision = Revision::loadFromPageId(wfGetDB(DB_SLAVE), $pdi);
$opts->setValue('rev1', $pdLastRevision->getId());
} elseif ($opts->getValue('rev1') != '') {
$pdrev = Revision::newFromId($opts->getValue('rev1'));
if ($pdrev) {
$opts->setValue('page1', $pdrev->getTitle()->getPrefixedText());
}
}
if ($title2 && $title2->exists() && $opts->getValue('rev2') == '') {
$pda = new Article($title2);
$pdi = $pda->getID();
$pdLastRevision = Revision::loadFromPageId(wfGetDB(DB_SLAVE), $pdi);
$opts->setValue('rev2', $pdLastRevision->getId());
} elseif ($opts->getValue('rev2') != '') {
$pdrev = Revision::newFromId($opts->getValue('rev2'));
if ($pdrev) {
$opts->setValue('page2', $pdrev->getTitle()->getPrefixedText());
}
}
// Store some objects
$this->skin = $wgUser->getSkin();
}
示例7: outputCategoryReport
function outputCategoryReport()
{
global $wgRequest, $wgOut;
$cat = str_replace("http://www.wikihow.com/Category:", "", trim(Misc::getUrlDecodedData($wgRequest->getVal('data'))));
$catArr = array($cat);
$cats = CategoryInterests::getSubCategoryInterests($catArr);
$cats[] = $cat;
$cats = '"' . join('","', $cats) . '"';
$sql = 'SELECT
page_id, page_title, page_counter
FROM page p
INNER JOIN categorylinks c ON c.cl_from = page_id
WHERE page_namespace = 0 and page_is_redirect = 0 AND c.cl_to IN (' . $cats . ')';
$dbr = wfGetDB(DB_SLAVE);
$res = $dbr->query($sql);
$articles = array();
while ($row = $dbr->fetchObject($res)) {
$altsData = "";
if ($this->slowQuery) {
$r = Revision::loadFromPageId($dbr, $row->page_id);
$wikitext = $r->getText();
//$imgs = $this->hasImages($wikitext);
$altsData = $this->hasAlternateMethods($wikitext) ? "Yes" : "No";
$sizeData = $this->getArticleSize($r);
}
//$output .= join("\t", array_values(get_object_vars($row))) . "\t$imgs\t$altsData\t$sizeData\n";
$row = array_values(get_object_vars($row));
$row[1] = Misc::makeUrl($row[1]);
$articles[] = $row;
}
if ($wgRequest->getVal('format') == 'csv') {
$output = $this->getCategoryReportCSV($articles);
$this->sendFile($cat, $output);
} else {
$output = $this->getCategoryReportHtml($articles);
$this->sendHtml($output);
}
}
示例8: wfNotifyRequesterOnNab
function wfNotifyRequesterOnNab($article_id)
{
$dbw = wfGetDB(DB_MASTER);
$res = $dbw->select(array('suggested_notify', 'page'), array('sn_notify', 'page_title', 'page_namespace'), array('sn_page=page_id', 'page_id' => $article_id));
// Only send an email if the article doesn't suck (bug 557)
$templateRegExp = "@{{(Copyvio|Copyviobot|accuracy|nfd|stub){1}@im";
$r = Revision::loadFromPageId($dbw, $article_id);
if (!is_null($r) && preg_match($templateRegExp, $r->getText()) === 0) {
$emails = array();
while ($row = $dbw->fetchObject($res)) {
$title = Title::makeTitle($row->page_namespace, $row->page_title);
$arr = split(',', $row->sn_notify);
foreach ($arr as $e) {
$emails[trim($e)] = $title;
}
}
if (sizeof($emails) > 0) {
wfSendRequestNotificationEmail($emails);
}
}
$dbw->delete('suggested_notify', array('sn_page' => $article_id));
return true;
}
示例9: getPageText
public static function getPageText($marriagedate, $marriageplace, $titleString, $pageids = NULL, $husbandTitle = '', $wifeTitle = '', $childTitle = '')
{
// standardize marriage place
$placeTitles = array();
if ($marriageplace && mb_strpos($marriageplace, '|') === false) {
$placeTitles[] = $marriageplace;
}
if ($placeTitles) {
$correctedTitles = PlaceSearcher::correctPlaceTitles($placeTitles);
$correctedPlace = @$correctedTitles[$marriageplace];
if ($correctedPlace) {
$marriageplace = strcasecmp($marriageplace, $correctedPlace) == 0 ? $correctedPlace : $correctedPlace . '|' . $marriageplace;
}
}
$result = "<family>\n";
$db =& wfGetDB(DB_MASTER);
// get latest version
$imageId = 0;
$husbands = '';
$wives = '';
$children = '';
$images = '';
if ($pageids) {
foreach ($pageids as $pageid) {
$revision = Revision::loadFromPageId($db, $pageid);
if ($revision) {
if ($revision->getTitle()->getNamespace() == NS_PERSON) {
$text = $revision->getText();
$xml = StructuredData::getXml('person', $text);
if (isset($xml)) {
$personTitle = StructuredData::escapeXml($revision->getTitle()->getText());
$spouseTag = Person::getSpouseTagFromGender((string) $xml->gender);
foreach ($xml->spouse_of_family as $family) {
if ((string) $family['title'] == $titleString) {
if ($spouseTag == 'husband') {
$husbands .= "<husband title=\"" . $personTitle . "\"/>\n";
} else {
$wives .= "<wife title=\"" . $personTitle . "\"/>\n";
}
}
}
foreach ($xml->child_of_family as $family) {
if ((string) $family['title'] == $titleString) {
$children .= '<child title="' . $personTitle . "\"/>\n";
}
}
}
} else {
if ($revision->getTitle()->getNamespace() == NS_IMAGE) {
$text = $revision->getText();
$xml = StructuredData::getXml('image_data', $text);
if (isset($xml)) {
$imageTitle = StructuredData::escapeXml($revision->getTitle()->getText());
foreach ($xml->family as $family) {
if ((string) $family['title'] == $titleString) {
$imageId++;
$images .= '<image id="I' . $imageId . '" filename="' . $imageTitle . "\"/>\n";
}
}
}
}
}
}
}
}
if ($husbandTitle) {
$husbands .= "<husband title=\"" . StructuredData::escapeXml($husbandTitle) . "\"/>\n";
}
if ($wifeTitle) {
$wives .= "<husband title=\"" . StructuredData::escapeXml($wifeTitle) . "\"/>\n";
}
if ($childTitle) {
$children .= "<husband title=\"" . StructuredData::escapeXml($childTitle) . "\"/>\n";
}
$result .= $husbands;
$result .= $wives;
$result .= $children;
if ($marriagedate || $marriageplace) {
$result .= '<event_fact type="Marriage" date="' . StructuredData::escapeXml($marriagedate) . '" place="' . StructuredData::escapeXml($marriageplace) . "\"/>\n";
}
$result .= $images;
$result .= "</family>\n";
return $result;
}
示例10: updateSearchIndexForPage
/**
* Update the searchindex table for a given pageid
* @param $dbw Database: a database write handle
* @param $pageId Integer: the page ID to update.
*/
public function updateSearchIndexForPage($dbw, $pageId)
{
// Get current revision
$rev = Revision::loadFromPageId($dbw, $pageId);
$title = null;
if ($rev) {
$titleObj = $rev->getTitle();
$title = $titleObj->getPrefixedDBkey();
$this->output("{$title}...");
# Update searchindex
$u = new SearchUpdate($pageId, $titleObj->getText(), $rev->getText());
$u->doUpdate();
$this->output("\n");
}
return $title;
}
示例11: buildMovePackage
public function buildMovePackage($oTitle, $oUser, $page_id = null, $redirect_id = null)
{
wfProfileIn(__METHOD__);
if (!$oTitle instanceof Title) {
Wikia::log(__METHOD__, "error", "Cannot send log using scribe ({$this->app->wg->CityId}): invalid title object");
wfProfileOut(__METHOD__);
return true;
}
$oRevision = Revision::newFromTitle($oTitle);
if (!is_object($oRevision) && !empty($redirect_id)) {
$db = wfGetDB(DB_MASTER);
$oRevision = Revision::loadFromPageId($db, $redirect_id);
}
if (!$oRevision instanceof Revision) {
Wikia::log(__METHOD__, "error", "Cannot send log using scribe ({$this->app->wg->CityId}): invalid revision object");
wfProfileOut(__METHOD__);
return true;
}
if (empty($page_id)) {
$page_id = $oRevision->getPage();
}
if (empty($page_id) || $page_id < 0) {
$page_id = $oTitle->getArticleId();
}
$oPage = WikiPage::newFromID($page_id);
if (!$oPage instanceof WikiPage) {
Wikia::log(__METHOD__, "error", "Cannot send log using scribe ({$this->app->wg->CityId}): invalid WikiPage object");
wfProfileOut(__METHOD__);
return true;
}
wfProfileOut(__METHOD__);
return $this->buildEditPackage($oPage, $oUser, $oRevision);
}
示例12: loadLastEdit
/**
* Loads everything except the text
* This isn't necessary for all uses, so it's only done if needed.
*/
protected function loadLastEdit()
{
if (-1 != $this->mUser) {
return;
}
# New or non-existent articles have no user information
$id = $this->getID();
if (0 == $id) {
return;
}
$this->mLastRevision = Revision::loadFromPageId(wfGetDB(DB_MASTER), $id);
if (!is_null($this->mLastRevision)) {
$this->mUser = $this->mLastRevision->getUser();
$this->mUserText = $this->mLastRevision->getUserText();
$this->mTimestamp = $this->mLastRevision->getTimestamp();
$this->mComment = $this->mLastRevision->getComment();
$this->mMinorEdit = $this->mLastRevision->isMinor();
$this->mRevIdFetched = $this->mLastRevision->getId();
}
}
示例13: calcPageStats
public function calcPageStats(&$statsToCalc, &$row)
{
$dbr = $this->getWikiDB();
$t = Title::newFromId($row->page_id);
$goodRevision = GoodRevision::newFromTitle($t, $row->page_id);
$revId = 0;
if ($goodRevision) {
$revId = $goodRevision->latestGood();
}
$r = $revId > 0 ? Revision::loadFromId($dbr, $revId) : Revision::loadFromPageId($dbr, $row->page_id);
$fields = array();
if ($r && $t && $t->exists()) {
foreach ($statsToCalc as $stat => $isOn) {
if ($isOn) {
$statCalculator = $this->getStatClass($stat);
$fields = array_merge($fields, $statCalculator->calc($dbr, $r, $t, $row));
}
}
}
return $fields;
}
示例14: articleInUse
/**
* articleInUse
* check to see if {{inuse}} or {{in use}} is in the article
* returns boolean
**/
function articleInUse($aid)
{
$dbr = wfGetDB(DB_SLAVE);
$r = Revision::loadFromPageId($dbr, $aid);
if (strpos($r->getText(), '{{inuse') === false) {
$result = false;
} else {
$result = true;
}
return $result;
}
示例15: newKnownCurrent
/**
* Load a revision based on a known page ID and current revision ID from the DB
*
* This method allows for the use of caching, though accessing anything that normally
* requires permission checks (aside from the text) will trigger a small DB lookup.
* The title will also be lazy loaded, though setTitle() can be used to preload it.
*
* @param IDatabase $db
* @param int $pageId Page ID
* @param int $revId Known current revision of this page
* @return Revision|bool Returns false if missing
* @since 1.28
*/
public static function newKnownCurrent(IDatabase $db, $pageId, $revId)
{
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
return $cache->getWithSetCallback($cache->makeGlobalKey('revision', $db->getWikiID(), $pageId, $revId), $cache::TTL_WEEK, function ($curValue, &$ttl, array &$setOpts) use($db, $pageId, $revId) {
$setOpts += Database::getCacheSetOptions($db);
$rev = Revision::loadFromPageId($db, $pageId, $revId);
// Reflect revision deletion and user renames
if ($rev) {
$rev->mTitle = null;
// mutable; lazy-load
$rev->mRefreshMutableFields = true;
}
return $rev ?: false;
// don't cache negatives
});
}