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


PHP Revision::loadFromTitle方法代码示例

本文整理汇总了PHP中Revision::loadFromTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::loadFromTitle方法的具体用法?PHP Revision::loadFromTitle怎么用?PHP Revision::loadFromTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Revision的用法示例。


在下文中一共展示了Revision::loadFromTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getWikitext

 /**
  * Utility method to return the wikitext for an article
  */
 protected static function getWikitext(&$dbr, $title)
 {
     $rev = Revision::loadFromTitle($dbr, $title);
     if (!$rev) {
         return false;
     }
     $wikitext = $rev->getText();
     return $wikitext;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:12,代码来源:Randomizer.body.php

示例2: extractFromNamespace

/**
 * Extracts pages from the given namespace. Creates for
 * every page an article with the given extension containing all
 * the wiki markup.
 * 
 * @param $type namespace
 * @param $fext file extension
 */
function extractFromNamespace($type, $fext)
{
    global $helpDirectory, $dbr;
    print "\nExtracting pages from namespace {$type}...";
    $helpPages = smwfGetSemanticStore()->getPages(array($type));
    foreach ($helpPages as $hp) {
        print "\nExtract: " . $hp->getText() . "...";
        $rev = Revision::loadFromTitle($dbr, $hp);
        $wikitext = $rev->getText();
        $fname = rawurlencode($hp->getDBKey());
        $handle = fopen($helpDirectory . "/" . $fname . "." . $fext, "w");
        fwrite($handle, $wikitext);
        fclose($handle);
        extractImages($hp);
        print "done!";
    }
    print "\n\nAll pages from namespace {$type} extracted!\n";
}
开发者ID:seedbank,项目名称:old-repo,代码行数:26,代码来源:SMW_extractPages.php

示例3: mergeChangesIntoContent

 /**
  * Attempts to do 3-way merge of edit content with a base revision
  * and current content, in case of edit conflict, in whichever way appropriate
  * for the content type.
  *
  * @since 1.21
  *
  * @param Content $editContent
  *
  * @return bool
  */
 private function mergeChangesIntoContent(&$editContent)
 {
     wfProfileIn(__METHOD__);
     $db = wfGetDB(DB_MASTER);
     // This is the revision the editor started from
     $baseRevision = $this->getBaseRevision();
     $baseContent = $baseRevision ? $baseRevision->getContent() : null;
     if (is_null($baseContent)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     // The current state, we want to merge updates into it
     $currentRevision = Revision::loadFromTitle($db, $this->mTitle);
     $currentContent = $currentRevision ? $currentRevision->getContent() : null;
     if (is_null($currentContent)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $handler = ContentHandler::getForModelID($baseContent->getModel());
     $result = $handler->merge3($baseContent, $editContent, $currentContent);
     if ($result) {
         $editContent = $result;
         wfProfileOut(__METHOD__);
         return true;
     }
     wfProfileOut(__METHOD__);
     return false;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:39,代码来源:EditPage.php

示例4: onUploadComplete

 /**
  * @since 1.1
  *
  * @param UploadForm $image
  *
  * @return true
  */
 public function onUploadComplete(UploadForm $image)
 {
     global $wgServerName, $wgScriptPath, $wgServer, $wgVersion;
     $urlServer = 'http://' . $wgServerName . $wgScriptPath;
     // $classe = get_class($image);
     if (compareMWVersion($wgVersion, '1.16.0') == -1) {
         $localfile = $image->mLocalFile;
     } else {
         $localfile = $image->getLocalFile();
     }
     $path = utils::prepareString($localfile->mime, $localfile->size, $wgServer . urldecode($localfile->url));
     if (!file_exists($path)) {
         $dbr = wfGetDB(DB_SLAVE);
         $lastRevision = Revision::loadFromTitle($dbr, $localfile->getTitle());
         if ($lastRevision->getPrevious() == null) {
             $rev_id = 0;
         } else {
             $rev_id = $lastRevision->getPrevious()->getId();
         }
         $revID = $lastRevision->getId();
         $model = DSMWRevisionManager::loadModel($rev_id);
         $patch = new DSMWPatch(false, true, null, $urlServer, $rev_id, null, null, null, $localfile->mime, $localfile->size, urldecode($localfile->url), null);
         $patch->storePage($localfile->getTitle(), $revID);
         // stores the patch in a wikipage
         DSMWRevisionManager::storeModel($revID, $sessionId = session_id(), $model, $blobCB = 0);
     }
     return true;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:35,代码来源:DSMW.hooks.php

示例5: deleteFeed

 /**
  *replaces the deleted semantic attribute in the feed page (pullfeed:.... or
  * pushfeed:....)
  * This aims to "virtualy" delete the article, it will no longer appear in the
  * special page (Special:ArticleAdminPage)
  *
  * @param <String> $feed
  * @return <boolean>
  */
 function deleteFeed($feed)
 {
     // if the browser page is refreshed, feed keeps the same value
     // but [[deleted::false| ]] isn't found and nothing is done
     preg_match("/^(.+?)_*:_*(.*)\$/S", $feed, $m);
     $articleName = $m[2];
     if ($m[1] == "PullFeed") {
         $title = Title::newFromText($articleName, PULLFEED);
     } elseif ($m[1] == "PushFeed") {
         $title = Title::newFromText($articleName, PUSHFEED);
     } else {
         throw new MWException(__METHOD__ . ': no valid namespace detected');
     }
     // get PushFeed by name
     $dbr = wfGetDB(DB_SLAVE);
     $revision = Revision::loadFromTitle($dbr, $title);
     $pageContent = $revision->getText();
     $dbr = wfGetDB(DB_SLAVE);
     $revision = Revision::loadFromTitle($dbr, $title);
     $pageContent = $revision->getText();
     // update deleted Value
     $result = str_replace("[[deleted::false| ]]", "[[deleted::true| ]]", $pageContent);
     if ($result == "") {
         return true;
     }
     $pageContent = $result;
     // save update
     $article = new Article($title);
     $article->doEdit($pageContent, $summary = "");
     return true;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:40,代码来源:ArticleAdminPage.php

示例6: updatePullFeed

/**
 *In a pullfeed page, the value of [[hasPullHead::]] has to be updated with the
 *ChangeSetId of the last pulled ChangeSet
 *
 * @param <String> $name Pullfeed name (with namespace)
 * @param <String> $CSID ChangeSetID (without namespace)
 * @return <boolean> returns true if the update is successful
 */
function updatePullFeed($name, $CSID)
{
    // split NS and name
    preg_match("/^(.+?)_*:_*(.*)\$/S", $name, $m);
    $articleName = $m[2];
    // get PushFeed by name
    $title = Title::newFromText($articleName, PULLFEED);
    $dbr = wfGetDB(DB_SLAVE);
    $revision = Revision::loadFromTitle($dbr, $title);
    $pageContent = $revision->getText();
    // get hasPushHead Value if exists
    $start = "[[hasPullHead::";
    $val1 = strpos($pageContent, $start);
    if ($val1 !== false) {
        // if there is an occurence of [[hasPushHead::
        $startVal = $val1 + strlen($start);
        $end = "]]";
        $endVal = strpos($pageContent, $end, $startVal);
        $value = substr($pageContent, $startVal, $endVal - $startVal);
        // update hasPullHead Value
        $result = str_replace($value, $CSID, $pageContent);
        $pageContent = $result;
        if ($result == "") {
            return false;
        }
    } else {
        // no occurence of [[hasPushHead:: , we add
        $pageContent .= ' hasPullHead: [[hasPullHead::' . $CSID . ']]';
    }
    // save update
    $article = new Article($title);
    $article->doEdit($pageContent, $summary = "");
    return true;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:42,代码来源:SemanticFunctions.php

示例7: PureWikiDeletionUndeleteHook

 /**
  * Add blanked pages back to the blank_page table when they are undeleted
  */
 public static function PureWikiDeletionUndeleteHook($title, $create)
 {
     $dbr = wfGetDB(DB_SLAVE);
     $myRevision = Revision::loadFromTitle($dbr, $title);
     if ($myRevision->getRawText() == "") {
         $dbw = wfGetDB(DB_MASTER);
         $blank_row = array('blank_page_id' => $title->getArticleID(), 'blank_user_id' => $myRevision->getRawUser(), 'blank_user_name' => $myRevision->getRawUserText(), 'blank_timestamp' => $myRevision->getTimeStamp(), 'blank_summary' => $myRevision->getRawComment(), 'blank_parent_id' => $myRevision->getParentId());
         $dbw->insert('blanked_page', $blank_row);
     }
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:14,代码来源:PureWikiDeletion.hooks.php

示例8: mergeChangesInto

 /**
  * @private
  * @todo document
  *
  * @parma $editText string
  *
  * @return bool
  */
 function mergeChangesInto(&$editText)
 {
     wfProfileIn(__METHOD__);
     $db = wfGetDB(DB_MASTER);
     // This is the revision the editor started from
     $baseRevision = $this->getBaseRevision();
     if (is_null($baseRevision)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $baseText = $baseRevision->getText();
     // The current state, we want to merge updates into it
     $currentRevision = Revision::loadFromTitle($db, $this->mTitle);
     if (is_null($currentRevision)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $currentText = $currentRevision->getText();
     $result = '';
     if (wfMerge($baseText, $editText, $currentText, $result)) {
         $editText = $result;
         wfProfileOut(__METHOD__);
         return true;
     } else {
         wfProfileOut(__METHOD__);
         return false;
     }
 }
开发者ID:slackfaith,项目名称:deadbrain_site,代码行数:36,代码来源:EditPage.php

示例9: getWikitext

 /**
  * Utility method to return the wikitext for an article
  */
 public static function getWikitext(&$dbr, $title)
 {
     global $wgTitle;
     if (!$title) {
         return false;
     }
     // an optimization if $title is $wgTitle
     if ($wgTitle && $wgTitle->getText() == $title->getText()) {
         $whow = WikihowArticleEditor::newFromCurrent();
         $wikitext = $whow->mLoadText;
     } else {
         $rev = Revision::loadFromTitle($dbr, $title);
         if (!$rev) {
             return false;
         }
         $wikitext = $rev->getText();
     }
     return $wikitext;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:22,代码来源:Wikitext.class.php

示例10: newRev

function newRev($article)
{
    global $wgCanonicalNamespaceNames;
    $indexNS = 0;
    $dbr = wfGetDB(DB_SLAVE);
    $article = str_replace(" ", "_", $article);
    preg_match("/^(.+?)_*:_*(.*)\$/S", $article, $tmp);
    $articleWithoutNS = $tmp[2];
    $NS = $tmp[1];
    if (in_array($NS, $wgCanonicalNamespaceNames)) {
        foreach ($wgCanonicalNamespaceNames as $key => $value) {
            if ($NS == $value) {
                $indexNS = $key;
            }
        }
    }
    $title = Title::newFromText($article);
    if (!$title->exists()) {
        $article = new Article($title);
        $article->doEdit('', '');
    } else {
        $lastRevision = Revision::loadFromTitle($dbr, $title);
        $rev_id = $lastRevision->getPrevious()->getId();
        $revID = $lastRevision->getId();
        $model = manager::loadModel($rev_id);
        $article = new Article($title);
        $article->quickEdit($model->getText(), '');
    }
}
开发者ID:hala54,项目名称:DSMW,代码行数:29,代码来源:IntegrationFunctions.php

示例11: loadPerson

 private function loadPerson($titleText)
 {
     $xml = null;
     $title = Title::newFromText($titleText, NS_PERSON);
     $revision = Revision::loadFromTitle($this->dbr, $title);
     // use load instead of new because I don't want to ever access DB_MASTER
     if ($revision) {
         $xml = StructuredData::getXml('person', $revision->getText());
     }
     return $xml;
 }
开发者ID:k-hasan-19,项目名称:wiki,代码行数:11,代码来源:GetPedigreeData.php

示例12: getArticleWikiText

 /**
  * Grab the wikitext for the article record
  */
 private function getArticleWikiText()
 {
     // cache this if it was already pulled
     if ($this->wikitext) {
         return $this->wikitext;
     }
     if (!$this->title || !$this->title->exists()) {
         //throw new Exception('ArticleMetaInfo: title not found');
         return '';
     }
     $good = GoodRevision::newFromTitle($this->title, $this->articleID);
     $revid = $good ? $good->latestGood() : 0;
     $dbr = $this->getDB();
     $rev = Revision::loadFromTitle($dbr, $this->title, $revid);
     if (!$rev) {
         //throw new Exception('ArticleMetaInfo: could not load revision');
         return '';
     }
     $this->wikitext = $rev->getText();
     return $this->wikitext;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:24,代码来源:ArticleMetaInfo.class.php

示例13: getWikitext

 /**
  * Utility method to return the wikitext for an article
  */
 public static function getWikitext(&$dbr, $title)
 {
     global $wgTitle;
     if (!$title) {
         return false;
     }
     // try to see if the wikihow article editor instance already has this title loaded
     $whow = WikihowArticleEditor::wikiHowArticleIfMatchingTitle($title);
     if ($whow) {
         $wikitext = $whow->mLoadText;
     } else {
         $rev = Revision::loadFromTitle($dbr, $title);
         if (!$rev) {
             return false;
         }
         $wikitext = $rev->getText();
     }
     return $wikitext;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:22,代码来源:Wikitext.class.php

示例14: loadPedigree

 private function loadPedigree()
 {
     // read the person
     if ($this->title->getNamespace() == NS_PERSON) {
         $revision = Revision::loadFromTitle($this->dbr, $this->title);
         // use load instead of new because I don't want ShowPedigree to ever access DB_MASTER
         if ($revision) {
             $xml = StructuredData::getXml('person', $revision->getText());
             if ($xml) {
                 foreach ($xml->spouse_of_family as $spouseFamily) {
                     $pos = ShowPedigree::SPOUSE_FAMILY_BASE + $this->numSpouseFamilies;
                     $this->loadFamily((string) $spouseFamily['title'], $pos, 0);
                     if (@$this->families[$pos]['exists']) {
                         $this->numSpouseFamilies += 1;
                     } else {
                         $this->families[$pos] = null;
                     }
                 }
                 $this->loadFamily((string) $xml->child_of_family['title'], 1, ShowPedigree::MAX_FAMILIES);
                 if ($this->numSpouseFamilies == 0) {
                     // no spouse families exist; get information on self from the person page (put into ['husband'] - it shouldn't matter)
                     $this->loadSelf($this->families[ShowPedigree::SPOUSE_FAMILY_BASE]['husband'], $xml);
                 }
             }
         }
         $selfTitle = @$this->families[ShowPedigree::SPOUSE_FAMILY_BASE]['husband']['title'];
         if ($selfTitle) {
             $this->selfTag = $selfTitle == $this->title->getText() ? 'husband' : 'wife';
             $this->spouseTag = $this->selfTag == 'husband' ? 'wife' : 'husband';
         }
     } else {
         $this->loadFamily($this->title->getText(), 1, ShowPedigree::MAX_FAMILIES);
         $this->selfTag = '';
         $this->spouseTag = '';
     }
 }
开发者ID:k-hasan-19,项目名称:wiki,代码行数:36,代码来源:SpecialShowPedigree.php

示例15: followRedirects

 /**
  * Follow redirect (if any) in the text and return the target article.
  * Set the error if there is an error in the redirects.
  *
  * @param String $text
  * @param int $ns namespace of starting page
  * @param String $error
  * @param bool $redirTargetMustExist
  * @param bool $returnArticle if true, this function returns an article; otherwise it returns a revision
  * @return Revision/Article the final target of the redirects if there is a redirect and it exists
  */
 private static function followRedirects($text, $titleString, $ns, &$error, $redirTargetMustExist = false, $returnArticle = false, $useMDB = false)
 {
     $rt = Title::newFromRedirect($text);
     $ra = null;
     // Revision or Article
     if ($rt) {
         $seenTitles = array();
         $t = Title::newFromText($titleString, $ns);
         $seenTitles[] = $t->getPrefixedText();
     }
     // while redirected, follow redir but avoid loops and don't stray outside the namespace (redirecting mysource to source and source to repo is ok)
     while ($rt) {
         if ($rt->getInterwiki() != '' || $rt->getNamespace() != $ns && !($ns == NS_MYSOURCE && $rt->getNamespace() == NS_SOURCE) && !($ns == NS_SOURCE && ($rt->getNamespace() == NS_REPOSITORY || $rt->getNamespace() == NS_MAIN))) {
             // !!! this is ugly; should check outside of namespace in caller, not here
             $error = "Redirect is outside of namespace";
             return null;
         }
         if (!$rt->exists()) {
             if ($redirTargetMustExist) {
                 $error = "Redirect target does not exist";
             }
             return null;
         }
         $rtString = $rt->getPrefixedText();
         if (in_array($rtString, $seenTitles)) {
             $error = "Loop in redirects";
             return null;
         }
         $seenTitles[] = $rtString;
         if ($returnArticle) {
             $newTitle =& Title::makeTitle($rt->getNamespace(), $rt->getDBkey());
             $ra = new Article($newTitle, 0);
             $text =& $ra->fetchContent();
         } else {
             if ($useMDB) {
                 $dbw =& wfGetDb(DB_MASTER);
                 $ra = Revision::loadFromTitle($dbw, $rt);
             } else {
                 $ra = Revision::newFromTitle($rt);
             }
             $text =& $ra->getText();
         }
         $rt = Title::newFromRedirect($text);
     }
     return $ra;
 }
开发者ID:k-hasan-19,项目名称:wiki,代码行数:57,代码来源:StructuredData.php


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