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


PHP WikiPage::getContent方法代码示例

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


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

示例1: getContentAsText

 /**
  * @since 2.1
  *
  * @param Title $title
  *
  * @return text
  */
 public function getContentAsText(Title $title)
 {
     $this->page = new \WikiPage($title);
     if (method_exists($this->page, 'getContent')) {
         $content = $this->page->getContent();
         if ($content instanceof TextContent) {
             return $content->getNativeData();
         } else {
             return '';
         }
     }
     return $this->page->getText();
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:20,代码来源:PageReader.php

示例2: doWork

 /**
  * @return bool
  */
 public function doWork()
 {
     global $wgUseFileCache;
     // @todo several of the methods called on $this->page are not declared in Page, but present
     //        in WikiPage and delegated by Article.
     $isCurrent = $this->revid === $this->page->getLatest();
     if ($this->content !== null) {
         $content = $this->content;
     } elseif ($isCurrent) {
         // XXX: why use RAW audience here, and PUBLIC (default) below?
         $content = $this->page->getContent(Revision::RAW);
     } else {
         $rev = Revision::newFromTitle($this->page->getTitle(), $this->revid);
         if ($rev === null) {
             $content = null;
         } else {
             // XXX: why use PUBLIC audience here (default), and RAW above?
             $content = $rev->getContent();
         }
     }
     if ($content === null) {
         return false;
     }
     // Reduce effects of race conditions for slow parses (bug 46014)
     $cacheTime = wfTimestampNow();
     $time = -microtime(true);
     $this->parserOutput = $content->getParserOutput($this->page->getTitle(), $this->revid, $this->parserOptions);
     $time += microtime(true);
     // Timing hack
     if ($time > 3) {
         // TODO: Use Parser's logger (once it has one)
         $logger = MediaWiki\Logger\LoggerFactory::getInstance('slow-parse');
         $logger->info('{time} {title}', ['time' => number_format($time, 2), 'title' => $this->page->getTitle()->getPrefixedDBkey(), 'trigger' => 'view']);
     }
     if ($this->cacheable && $this->parserOutput->isCacheable() && $isCurrent) {
         ParserCache::singleton()->save($this->parserOutput, $this->page, $this->parserOptions, $cacheTime, $this->revid);
     }
     // Make sure file cache is not used on uncacheable content.
     // Output that has magic words in it can still use the parser cache
     // (if enabled), though it will generally expire sooner.
     if (!$this->parserOutput->isCacheable()) {
         $wgUseFileCache = false;
     }
     if ($isCurrent) {
         $this->page->triggerOpportunisticLinksUpdate($this->parserOutput);
     }
     return true;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:51,代码来源:PoolWorkArticleView.php

示例3: getPageText

 /**
  * Gets the text contents of a page with the passed-in Title object.
  */
 public static function getPageText($title)
 {
     if (method_exists('WikiPage', 'getContent')) {
         // MW 1.21+
         $wikiPage = new WikiPage($title);
         $content = $wikiPage->getContent();
         if ($content !== null) {
             return $content->getNativeData();
         } else {
             return null;
         }
     } else {
         // MW <= 1.20
         $article = new Article($title);
         return $article->getContent();
     }
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:20,代码来源:SF_Utils.php

示例4: newFromTitle

 static function newFromTitle($title)
 {
     // see if we already have this as our main instance...
     if (self::$instance && self::$instance->mTitle == $title) {
         return self::$instance;
     }
     $wikiPage = new WikiPage($title);
     if (!$wikiPage) {
         return null;
     }
     $whow = new WikihowArticleEditor();
     $whow->mTitleObj = $wikiPage->getTitle();
     $whow->mWikiPage = $wikiPage;
     $whow->mTitle = $wikiPage->getTitle()->getText();
     $text = ContentHandler::getContentText($wikiPage->getContent(Revision::RAW));
     $whow->loadFromText($text);
     return $whow;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:18,代码来源:WikihowArticle.class.php

示例5: savePage

 function savePage(WikiPage $p)
 {
     $db = new DatabaseConnection();
     // Read values
     $ns = $p->getNs();
     $uri = $p->getUri();
     $title = $p->getTitle();
     $content = $p->getContent();
     $author = User::getActiveUserId();
     // Update
     try {
         // pull the latest revision of the page
         $rs = $db->getSingleRow('SELECT MAX(revision) AS latest FROM wiki WHERE ns=\'%s\' AND uri=\'%s\'', $ns, $uri);
         $currev = $rs ? $rs['latest'] : 0;
         // set to 0 if no record returned
         // bump revision (if no record, 0 becomes 1)
         $currev++;
         // and insert the new data
         $db->updateRow("INSERT INTO wiki SET content='%s',revision='%d',title='%s',ns='%s',uri='%s',lastedit=NOW(),author='%d'", $content, $currev, $title, $ns, $uri, $author);
     } catch (DBXException $e) {
         throw $e;
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:23,代码来源:wiki.php

示例6: deleteUnneededTaskBoxTemplates

 function deleteUnneededTaskBoxTemplates()
 {
     $results = self::getQueryResults("[[Category:Page with Task]]", array('title'), true);
     if ($results->getCount() === 0) {
         return FALSE;
     }
     while ($row = $results->getNext()) {
         $pageTitle = $row[0]->getNextObject();
         $targetTitle = Title::newFromText($pageTitle->getLongWikiText());
         if (!$targetTitle instanceof Title) {
             throw new MWException(wfMessage('tm-error-title'));
         }
         $page = new WikiPage($targetTitle);
         $content = $page->getContent();
         if (strpos($content->getNativeData(), '{{TaskBox}}') !== false) {
             $resultsTasks = self::getQueryResults("[[Category:Task(s)]] [[Entity::" . $pageTitle->getLongWikiText() . "]]", array('title'), true);
             if ($resultsTasks->getCount() === 0) {
                 $newContent = new WikitextContent(str_replace('{{TaskBox}}', '', $content->getNativeData()));
                 $page->doEditContent($newContent, wfMessage('tm-tasbox-removed'), EDIT_MINOR);
             }
         }
     }
     return TRUE;
 }
开发者ID:ATCARES,项目名称:TaskManagement,代码行数:24,代码来源:TaskManagementUtils.php

示例7: diff

         }
         $wikiList = $searchResult;
     } else {
         $message = $langWikiSearchMissingKeywords;
         $style = 'caution';
         $action = 'rqSearch';
     }
     break;
     // show differences
 // show differences
 case 'diff':
     include 'modules/wiki/lib/lib.diff.php';
     if ($wikiStore->pageExists($wikiId, $wiki_title)) {
         // older version
         $wikiPage->loadPageVersion($old);
         $old = $wikiPage->getContent();
         $oldTime = $wikiPage->getCurrentVersionMtime();
         $oldEditor = $wikiPage->getEditorId();
         // newer version
         $wikiPage->loadPageVersion($new);
         $new = $wikiPage->getContent();
         $newTime = $wikiPage->getCurrentVersionMtime();
         $newEditor = $wikiPage->getEditorId();
         // get differences
         $diff = '<table style="border: 0;">' . diff($old, $new, true, 'format_table_line') . '</table>';
     }
     break;
     // page history
     //case 'history':
     // recent changes
 // page history
开发者ID:kostastzo,项目名称:openeclass,代码行数:31,代码来源:page.php

示例8: testEditAppend

 /**
  * @dataProvider provideEditAppend
  */
 public function testEditAppend($text, $op, $append, $expected)
 {
     static $count = 0;
     $count++;
     // assume NS_HELP defaults to wikitext
     $name = "Help:ApiEditPageTest_testEditAppend_{$count}";
     // -- create page (or not) -----------------------------------------
     if ($text !== null) {
         list($re) = $this->doApiRequestWithToken(array('action' => 'edit', 'title' => $name, 'text' => $text));
         $this->assertEquals('Success', $re['edit']['result']);
         // sanity
     }
     // -- try append/prepend --------------------------------------------
     list($re) = $this->doApiRequestWithToken(array('action' => 'edit', 'title' => $name, $op . 'text' => $append));
     $this->assertEquals('Success', $re['edit']['result']);
     // -- validate -----------------------------------------------------
     $page = new WikiPage(Title::newFromText($name));
     $content = $page->getContent();
     $this->assertNotNull($content, 'Page should have been created');
     $text = $content->getNativeData();
     $this->assertEquals($expected, $text);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:25,代码来源:ApiEditPageTest.php

示例9: getPageRawTextFromPage

 static function getPageRawTextFromPage($pageTitle)
 {
     global $wgParser, $wgMemc, $wgUser;
     $wgParserOptions = new ParserOptions($wgUser);
     if ($pageTitle->isExternal()) {
         $content = $wgParser->interwikiTransclude($pageTitle, 'raw');
         $output = $wgParser->preprocess($content, $pageTitle, $wgParserOptions);
         $key = wfForeignMemcKey('huiji', '', 'page', 'getPageRaw', 'shared', $pageTitle->getFullText());
         $wgMemc->set($key, $output);
     } else {
         if (!$pageTitle->isKnown()) {
             return 'Create the page [[' . $pageTitle->getFullText() . ']]';
         } else {
             $key = wfMemcKey('page', 'getPageRaw', 'all', $pageTitle->getFullText());
             $page = new WikiPage($pageTitle);
             // get the text as static wiki text, but with already expanded templates,
             // which also e.g. to use {{#dpl}} (DPL third party extension) for dynamic menus.
             $output = $wgParser->preprocess($page->getContent()->getNativeData(), $pageTitle, $wgParserOptions);
             $wgMemc->set($key, $output);
         }
     }
     return $output;
 }
开发者ID:volvor,项目名称:bootstrap-mediawiki,代码行数:23,代码来源:HuijiSkinTemplate.php

示例10: testDoRollbackFailureSameContent

 /**
  * @covers WikiPage::doRollback
  */
 public function testDoRollbackFailureSameContent()
 {
     $admin = new User();
     $admin->setName("Admin");
     $admin->addGroup("sysop");
     #XXX: make the test user a sysop...
     $text = "one";
     $page = $this->newPage("WikiPageTest_testDoRollback");
     $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle(), CONTENT_MODEL_WIKITEXT), "section one", EDIT_NEW, false, $admin);
     $rev1 = $page->getRevision();
     $user1 = new User();
     $user1->setName("127.0.1.11");
     $user1->addGroup("sysop");
     #XXX: make the test user a sysop...
     $text .= "\n\ntwo";
     $page = new WikiPage($page->getTitle());
     $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle(), CONTENT_MODEL_WIKITEXT), "adding section two", 0, false, $user1);
     # now, do a the rollback from the same user was doing the edit before
     $resultDetails = array();
     $token = $user1->getEditToken(array($page->getTitle()->getPrefixedText(), $user1->getName()), null);
     $errors = $page->doRollback($user1->getName(), "testing revert same user", $token, false, $resultDetails, $admin);
     $this->assertEquals(array(), $errors, "Rollback failed same user");
     # now, try the rollback
     $resultDetails = array();
     $token = $admin->getEditToken(array($page->getTitle()->getPrefixedText(), $user1->getName()), null);
     $errors = $page->doRollback($user1->getName(), "testing revert", $token, false, $resultDetails, $admin);
     $this->assertEquals(array(array('alreadyrolled', 'WikiPageTest testDoRollback', '127.0.1.11', 'Admin')), $errors, "Rollback not failed");
     $page = new WikiPage($page->getTitle());
     $this->assertEquals($rev1->getSha1(), $page->getRevision()->getSha1(), "rollback did not revert to the correct revision");
     $this->assertEquals("one", $page->getContent()->getNativeData());
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:34,代码来源:WikiPageTest.php

示例11: diff

         }
         $wikiList = $searchResult;
     } else {
         $message = get_lang("Missing search keywords");
         $dialogBox->error($message);
         $action = 'rqSearch';
     }
     break;
     // show differences
 // show differences
 case 'diff':
     require_once 'lib/lib.diff.php';
     if ($wikiStore->pageExists($wikiId, $title)) {
         // older version
         $wikiPage->loadPageVersion($old);
         $old = $wikiPage->getContent();
         $oldTime = $wikiPage->getCurrentVersionMtime();
         $oldEditor = $wikiPage->getEditorId();
         // newer version
         $wikiPage->loadPageVersion($new);
         $new = $wikiPage->getContent();
         $newTime = $wikiPage->getCurrentVersionMtime();
         $newEditor = $wikiPage->getEditorId();
         // protect against dangerous html
         $old = claro_htmlspecialchars($old);
         $new = claro_htmlspecialchars($new);
         // get differences
         $diff = '<table style="border: 0;">' . diff($new, $old, true, 'format_table_line') . '</table>';
     }
     break;
     // page history
开发者ID:rhertzog,项目名称:lcs,代码行数:31,代码来源:page.php

示例12: getContentObject

 /**
  * @param Content|null $def_content The default value to return
  *
  * @return Content|null Content on success, $def_content for invalid sections
  *
  * @since 1.21
  */
 protected function getContentObject($def_content = null)
 {
     global $wgOut, $wgRequest, $wgUser, $wgContLang;
     $content = false;
     // For message page not locally set, use the i18n message.
     // For other non-existent articles, use preload text if any.
     if (!$this->mTitle->exists() || $this->section == 'new') {
         if ($this->mTitle->getNamespace() == NS_MEDIAWIKI && $this->section != 'new') {
             # If this is a system message, get the default text.
             $msg = $this->mTitle->getDefaultMessageText();
             $content = $this->toEditContent($msg);
         }
         if ($content === false) {
             # If requested, preload some text.
             $preload = $wgRequest->getVal('preload', $this->section === 'new' ? 'MediaWiki:addsection-preload' : '');
             $params = $wgRequest->getArray('preloadparams', array());
             $content = $this->getPreloadedContent($preload, $params);
         }
         // For existing pages, get text based on "undo" or section parameters.
     } else {
         if ($this->section != '') {
             // Get section edit text (returns $def_text for invalid sections)
             $orig = $this->getOriginalContent($wgUser);
             $content = $orig ? $orig->getSection($this->section) : null;
             if (!$content) {
                 $content = $def_content;
             }
         } else {
             $undoafter = $wgRequest->getInt('undoafter');
             $undo = $wgRequest->getInt('undo');
             if ($undo > 0 && $undoafter > 0) {
                 $undorev = Revision::newFromId($undo);
                 $oldrev = Revision::newFromId($undoafter);
                 # Sanity check, make sure it's the right page,
                 # the revisions exist and they were not deleted.
                 # Otherwise, $content will be left as-is.
                 if (!is_null($undorev) && !is_null($oldrev) && !$undorev->isDeleted(Revision::DELETED_TEXT) && !$oldrev->isDeleted(Revision::DELETED_TEXT)) {
                     $content = $this->page->getUndoContent($undorev, $oldrev);
                     if ($content === false) {
                         # Warn the user that something went wrong
                         $undoMsg = 'failure';
                     } else {
                         $oldContent = $this->page->getContent(Revision::RAW);
                         $popts = ParserOptions::newFromUserAndLang($wgUser, $wgContLang);
                         $newContent = $content->preSaveTransform($this->mTitle, $wgUser, $popts);
                         if ($newContent->equals($oldContent)) {
                             # Tell the user that the undo results in no change,
                             # i.e. the revisions were already undone.
                             $undoMsg = 'nochange';
                             $content = false;
                         } else {
                             # Inform the user of our success and set an automatic edit summary
                             $undoMsg = 'success';
                             # If we just undid one rev, use an autosummary
                             $firstrev = $oldrev->getNext();
                             if ($firstrev && $firstrev->getId() == $undo) {
                                 $userText = $undorev->getUserText();
                                 if ($userText === '') {
                                     $undoSummary = wfMessage('undo-summary-username-hidden', $undo)->inContentLanguage()->text();
                                 } else {
                                     $undoSummary = wfMessage('undo-summary', $undo, $userText)->inContentLanguage()->text();
                                 }
                                 if ($this->summary === '') {
                                     $this->summary = $undoSummary;
                                 } else {
                                     $this->summary = $undoSummary . wfMessage('colon-separator')->inContentLanguage()->text() . $this->summary;
                                 }
                                 $this->undidRev = $undo;
                             }
                             $this->formtype = 'diff';
                         }
                     }
                 } else {
                     // Failed basic sanity checks.
                     // Older revisions may have been removed since the link
                     // was created, or we may simply have got bogus input.
                     $undoMsg = 'norev';
                 }
                 // Messages: undo-success, undo-failure, undo-norev, undo-nochange
                 $class = ($undoMsg == 'success' ? '' : 'error ') . "mw-undo-{$undoMsg}";
                 $this->editFormPageTop .= $wgOut->parse("<div class=\"{$class}\">" . wfMessage('undo-' . $undoMsg)->plain() . '</div>', true, true);
             }
             if ($content === false) {
                 $content = $this->getOriginalContent($wgUser);
             }
         }
     }
     return $content;
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:96,代码来源:EditPage.php

示例13: view

 function view($u = null)
 {
     global $wgOut, $wgTitle, $wgUser, $wgRequest;
     $diff = $wgRequest->getVal('diff');
     $rcid = $wgRequest->getVal('rcid');
     $this->user = $u ? $u : User::newFromName($wgTitle->getDBKey());
     if (!$u && $this->mTitle->getNamespace() != NS_USER || !$this->user || isset($diff) || isset($rcid)) {
         return Article::view();
     }
     if ($this->user->getID() == 0) {
         header('HTTP/1.1 404 Not Found');
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->showErrorPage('nosuchuser', 'Noarticletext_user');
         return;
     }
     $this->isPageOwner = $wgUser->getID() == $this->user->getID();
     if ($this->user->isBlocked() && $this->isPageOwner) {
         $wgOut->blockedPage();
         return;
     }
     $wgOut->setRobotpolicy('index,follow');
     $skin = $this->getContext()->getSkin();
     //user settings
     $checkStats = $this->user->getOption('profilebox_stats') == 1;
     $checkStartedEdited = $this->user->getOption('profilebox_startedEdited') == 1;
     $profileStats = new ProfileStats($this->user);
     $badgeData = $profileStats->getBadges();
     $wgOut->addHTML(ProfileBox::getDisplayBadge($badgeData));
     if (!$u) {
         $skin->addWidget($this->getRCUserWidget());
     }
     if ($checkStats || $checkStartedEdited) {
         $createdData = $profileStats->getArticlesCreated(0);
     }
     //stats
     if ($checkStats) {
         $stats = ProfileBox::fetchStats("User:" . $this->user->getName());
         $wgOut->addHTML(ProfileBox::getStatsDisplay($stats, $this->user->getName(), count($createdData)));
     }
     //articles created
     if ($checkStartedEdited) {
         $wgOut->addHTML(ProfileBox::getDisplayCreatedData($createdData, 5));
         //thumbed up edits
         $thumbsData = $profileStats->fetchThumbsData(0);
         $wgOut->addHTML(ProfileBox::getDisplayThumbData($thumbsData, 5));
     }
     $this->mTitle = $u ? Title::newFromText('User:' . $this->user->getName()) : $wgTitle;
     $wp = new WikiPage($this->mTitle);
     $popts = $wgOut->parserOptions();
     $popts->setTidy(true);
     $content = $wp->getContent();
     if ($content) {
         $parserOutput = $content->getParserOutput($this->mTitle, null, $popts, false)->getText();
         $html = WikihowArticleHTML::processArticleHTML($parserOutput, array('no-ads' => true, 'ns' => NS_USER));
         $wgOut->addHTML($html);
     }
     //contributions and views
     $contributions = $profileStats->getContributions();
     $views = ProfileBox::getPageViews();
     $wgOut->addHTML(ProfileBox::getFinalStats($contributions, $views));
     if (!$u) {
         $wgOut->addHTML("<div class='clearall'></div>");
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:64,代码来源:WikihowUserPage.class.php

示例14: getDataForSearchIndex

 /**
  * Return fields to be indexed by search engine
  * as representation of this document.
  * Overriding class should call parent function or take care of calling
  * the SearchDataForIndex hook.
  * @param WikiPage     $page Page to index
  * @param ParserOutput $output
  * @param SearchEngine $engine Search engine for which we are indexing
  * @return array Map of name=>value for fields
  * @since 1.28
  */
 public function getDataForSearchIndex(WikiPage $page, ParserOutput $output, SearchEngine $engine)
 {
     $fieldData = [];
     $content = $page->getContent();
     if ($content) {
         $searchDataExtractor = new ParserOutputSearchDataExtractor();
         $fieldData['category'] = $searchDataExtractor->getCategories($output);
         $fieldData['external_link'] = $searchDataExtractor->getExternalLinks($output);
         $fieldData['outgoing_link'] = $searchDataExtractor->getOutgoingLinks($output);
         $fieldData['template'] = $searchDataExtractor->getTemplates($output);
         $text = $content->getTextForSearchIndex();
         $fieldData['text'] = $text;
         $fieldData['source_text'] = $text;
         $fieldData['text_bytes'] = $content->getSize();
     }
     Hooks::run('SearchDataForIndex', [&$fieldData, $this, $page, $output, $engine]);
     return $fieldData;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:29,代码来源:ContentHandler.php

示例15: getContent

 /**
  * Get the content for the given page and the requested section.
  *
  * @param WikiPage $page
  * @param int $pageId
  * @return Content
  */
 private function getContent(WikiPage $page, $pageId = null)
 {
     $content = $page->getContent(Revision::RAW);
     // XXX: really raw?
     if ($this->section !== false && $content !== null) {
         $content = $this->getSectionContent($content, !is_null($pageId) ? 'page id ' . $pageId : $page->getTitle()->getPrefixedText());
     }
     return $content;
 }
开发者ID:huatuoorg,项目名称:mediawiki,代码行数:16,代码来源:ApiParse.php


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