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


PHP WikiPage::factory方法代码示例

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


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

示例1: testParsing

 public function testParsing()
 {
     $title = Title::newFromText('MediaWiki:Ugakey/nl');
     $page = WikiPage::factory($title);
     $content = ContentHandler::makeContent('$1 van $2', $title);
     $status = $page->doEditContent($content, __METHOD__);
     $value = $status->getValue();
     /**
      * @var Revision $rev
      */
     $rev = $value['revision'];
     $revision = $rev->getId();
     $dbw = wfGetDB(DB_MASTER);
     $conds = array('rt_page' => $title->getArticleID(), 'rt_type' => RevTag::getType('fuzzy'), 'rt_revision' => $revision);
     $index = array_keys($conds);
     $dbw->replace('revtag', array($index), $conds, __METHOD__);
     $handle = new MessageHandle($title);
     $this->assertTrue($handle->isValid(), 'Message is known');
     $this->assertTrue($handle->isFuzzy(), 'Message is fuzzy after database fuzzying');
     // Update the translation without the fuzzy string
     $content = ContentHandler::makeContent('$1 van $2', $title);
     $page->doEditContent($content, __METHOD__);
     $this->assertFalse($handle->isFuzzy(), 'Message is unfuzzy after edit');
     $content = ContentHandler::makeContent('!!FUZZY!!$1 van $2', $title);
     $page->doEditContent($content, __METHOD__);
     $this->assertTrue($handle->isFuzzy(), 'Message is fuzzy after manual fuzzying');
     // Update the translation without the fuzzy string
     $content = ContentHandler::makeContent('$1 van $2', $title);
     $page->doEditContent($content, __METHOD__);
     $this->assertFalse($handle->isFuzzy(), 'Message is unfuzzy after edit');
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:31,代码来源:TranslationFuzzyUpdaterTest.php

示例2: execute

 public function execute()
 {
     $user = $this->getUser();
     $params = $this->extractRequestParams();
     // WikiPage::doRollback needs a Web UI token, so get one of those if we
     // validated based on an API rollback token.
     $token = $params['token'];
     if ($user->matchEditToken($token, 'rollback', $this->getRequest())) {
         $token = $this->getUser()->getEditToken($this->getWebUITokenSalt($params), $this->getRequest());
     }
     $titleObj = $this->getRbTitle($params);
     $pageObj = WikiPage::factory($titleObj);
     $summary = $params['summary'];
     $details = array();
     $retval = $pageObj->doRollback($this->getRbUser($params), $summary, $token, $params['markbot'], $details, $user);
     if ($retval) {
         // We don't care about multiple errors, just report one of them
         $this->dieUsageMsg(reset($retval));
     }
     $watch = 'preferences';
     if (isset($params['watchlist'])) {
         $watch = $params['watchlist'];
     }
     // Watch pages
     $this->setWatch($watch, $titleObj, 'watchrollback');
     $info = array('title' => $titleObj->getPrefixedText(), 'pageid' => intval($details['current']->getPage()), 'summary' => $details['summary'], 'revid' => intval($details['newid']), 'old_revid' => intval($details['current']->getID()), 'last_revid' => intval($details['target']->getID()));
     $this->getResult()->addValue(null, $this->getModuleName(), $info);
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:28,代码来源:ApiRollback.php

示例3: execute

 public function execute()
 {
     $this->println('Adding missing file links for attachments.');
     try {
         $dbr = \wfGetDB(DB_SLAVE);
         $res = $dbr->select('page_attachment_data', '*');
         if (!$res->numRows()) {
             $this->println('No attachments found.  No links added.');
             break;
         } else {
             foreach ($res as $row) {
                 $linkFromPageId = $row->attached_to_page_id;
                 $linkToFileId = $row->attachment_page_id;
                 $linkToFileTitle = \Title::newFromId($linkToFileId);
                 $linkToFileDatabaseKey = $linkToFileTitle->getDBkey();
                 if (!$this->isLinkExist($linkFromPageId, $linkToFileDatabaseKey)) {
                     $linkFromPageTitle = \Title::newFromId($linkFromPageId);
                     $linkToFileName = $linkToFileTitle->getText();
                     $this->println('Adding missing link from page [' . $linkFromPageTitle . '] to attachment file [' . $linkToFileName . ']');
                     $linkToFileWikiPage = \WikiPage::factory($linkToFileTitle);
                     $linkToFileWikiPage->doPurge();
                     $this->addLink($linkFromPageId, $linkToFileDatabaseKey);
                 }
             }
             $this->println('Finished adding file links.');
         }
     } catch (Exception $e) {
         $this->println('Failed to add file links.  Error: [' . $e->getMessage() . ']');
     }
 }
开发者ID:mediawiki-extensions,项目名称:mediawiki-page-attachment,代码行数:30,代码来源:AddMissingFileLinks.php

示例4: execute

 public function execute()
 {
     global $wgUser;
     $this->output("Checking existence of old default messages...");
     $dbr = $this->getDB(DB_REPLICA);
     $res = $dbr->select(['page', 'revision'], ['page_namespace', 'page_title'], ['page_namespace' => NS_MEDIAWIKI, 'page_latest=rev_id', 'rev_user_text' => 'MediaWiki default']);
     if ($dbr->numRows($res) == 0) {
         # No more messages left
         $this->output("done.\n");
         return;
     }
     # Deletions will be made by $user temporarly added to the bot group
     # in order to hide it in RecentChanges.
     $user = User::newFromName('MediaWiki default');
     if (!$user) {
         $this->error("Invalid username", true);
     }
     $user->addGroup('bot');
     $wgUser = $user;
     # Handle deletion
     $this->output("\n...deleting old default messages (this may take a long time!)...", 'msg');
     $dbw = $this->getDB(DB_MASTER);
     foreach ($res as $row) {
         wfWaitForSlaves();
         $dbw->ping();
         $title = Title::makeTitle($row->page_namespace, $row->page_title);
         $page = WikiPage::factory($title);
         $error = '';
         // Passed by ref
         // FIXME: Deletion failures should be reported, not silently ignored.
         $page->doDeleteArticle('No longer required', false, 0, true, $error, $user);
     }
     $this->output("done!\n", 'msg');
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:34,代码来源:deleteDefaultMessages.php

示例5: createWorkflowLoader

 /**
  * @param Title $pageTitle
  * @param UUID|null $workflowId
  * @return WorkflowLoader
  * @throws InvalidInputException
  * @throws CrossWikiException
  */
 public function createWorkflowLoader(Title $pageTitle, $workflowId = null)
 {
     if ($pageTitle === null) {
         throw new InvalidInputException('Invalid article requested', 'invalid-title');
     }
     if ($pageTitle && $pageTitle->isExternal()) {
         throw new CrossWikiException('Interwiki to ' . $pageTitle->getInterwiki() . ' not implemented ', 'default');
     }
     // @todo: ideally, workflowId is always set and this stuff is done in the places that call this
     if ($workflowId === null) {
         if ($pageTitle->getNamespace() === NS_TOPIC) {
             // topic page: workflow UUID is page title
             $workflowId = self::uuidFromTitle($pageTitle);
         } else {
             // board page: workflow UUID is inside content model
             $page = \WikiPage::factory($pageTitle);
             $content = $page->getContent();
             if ($content instanceof BoardContent) {
                 $workflowId = $content->getWorkflowId();
             }
         }
     }
     if ($workflowId === null) {
         // no existing workflow found, create new one
         $workflow = Workflow::create($this->defaultWorkflowName, $pageTitle);
     } else {
         $workflow = $this->loadWorkflowById($pageTitle, $workflowId);
     }
     return new WorkflowLoader($workflow, $this->blockFactory->createBlocks($workflow), $this->submissionHandler);
 }
开发者ID:TarLocesilion,项目名称:mediawiki-extensions-Flow,代码行数:37,代码来源:WorkflowLoaderFactory.php

示例6: execute

 public function execute()
 {
     global $wgUser;
     $username = $this->getOption('username', false);
     if ($username === false) {
         $user = User::newSystemUser('ScriptImporter', ['steal' => true]);
     } else {
         $user = User::newFromName($username);
     }
     $wgUser = $user;
     $baseUrl = $this->getArg(1);
     $pageList = $this->fetchScriptList();
     $this->output('Importing ' . count($pageList) . " pages\n");
     foreach ($pageList as $page) {
         $title = Title::makeTitleSafe(NS_MEDIAWIKI, $page);
         if (!$title) {
             $this->error("{$page} is an invalid title; it will not be imported\n");
             continue;
         }
         $this->output("Importing {$page}\n");
         $url = wfAppendQuery($baseUrl, ['action' => 'raw', 'title' => "MediaWiki:{$page}"]);
         $text = Http::get($url, [], __METHOD__);
         $wikiPage = WikiPage::factory($title);
         $content = ContentHandler::makeContent($text, $wikiPage->getTitle());
         $wikiPage->doEditContent($content, "Importing from {$url}", 0, false, $user);
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:27,代码来源:importSiteScripts.php

示例7: testMessage

 public function testMessage()
 {
     $user = new MockSuperUser();
     $user->setId(123);
     $title = Title::newFromText('MediaWiki:translated/fi');
     $page = WikiPage::factory($title);
     $content = ContentHandler::makeContent('pupuliini', $title);
     $status = $page->doEditContent($content, __METHOD__, 0, false, $user);
     $value = $status->getValue();
     $rev = $value['revision'];
     $revision = $rev->getId();
     $group = MessageGroups::getGroup('test-group');
     $collection = $group->initCollection('fi');
     $collection->loadTranslations();
     /** @var TMessage $translated */
     $translated = $collection['translated'];
     $this->assertInstanceof('TMessage', $translated);
     $this->assertEquals('translated', $translated->key());
     $this->assertEquals('bunny', $translated->definition());
     $this->assertEquals('pupuliini', $translated->translation());
     $this->assertEquals('SuperUser', $translated->getProperty('last-translator-text'));
     $this->assertEquals(123, $translated->getProperty('last-translator-id'));
     $this->assertEquals('translated', $translated->getProperty('status'), 'message status is translated');
     $this->assertEquals($revision, $translated->getProperty('revision'));
     /** @var TMessage $untranslated */
     $untranslated = $collection['untranslated'];
     $this->assertInstanceof('TMessage', $untranslated);
     $this->assertEquals(null, $untranslated->translation(), 'no translation is null');
     $this->assertEquals(false, $untranslated->getProperty('last-translator-text'));
     $this->assertEquals(false, $untranslated->getProperty('last-translator-id'));
     $this->assertEquals('untranslated', $untranslated->getProperty('status'), 'message status is untranslated');
     $this->assertEquals(false, $untranslated->getProperty('revision'));
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:33,代码来源:MessageCollectionTest.php

示例8: replaceVideoGalleryTag

 public function replaceVideoGalleryTag($pageId, $test = null)
 {
     global $wgTitle;
     $wgTitle = Title::newFromID($pageId);
     if (!$wgTitle) {
         $this->error("Invalid title", true);
     }
     $page = WikiPage::factory($wgTitle);
     # Read the text
     $text = $page->getText();
     $text = preg_replace('/<(\\/?)videogallery([^>]*)>/', '<$1gallery$2>', $text);
     $summary = 'Updating <videogallery> to <gallery>';
     # Do the edit
     $this->output("Replacing page (" . $wgTitle->getDBkey() . ") ... ");
     if ($test) {
         $this->output("(test: no changes) done\n");
     } else {
         $status = $page->doEdit($text, $summary, EDIT_MINOR | EDIT_FORCE_BOT | EDIT_SUPPRESS_RC);
         if ($status->isOK()) {
             $this->output("done\n");
         } else {
             $this->output("failed\n");
             return 0;
         }
         if (!$status->isGood()) {
             $this->output($status->getWikiText() . "\n");
         }
     }
     return 1;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:wikiMigrateVideoGallery.php

示例9: run

 function run()
 {
     // Initialization
     $title = $this->title;
     list(, $code) = TranslateUtils::figureMessage($title->getPrefixedText());
     // Return the actual translation page...
     $page = TranslatablePage::isTranslationPage($title);
     if (!$page) {
         var_dump($this->params);
         var_dump($title);
         throw new MWException("Oops, this should not happen!");
     }
     $group = $page->getMessageGroup();
     $collection = $group->initCollection($code);
     $text = $page->getParse()->getTranslationPageText($collection);
     // Other stuff
     $user = $this->getUser();
     $summary = $this->getSummary();
     $flags = $this->getFlags();
     $page = WikiPage::factory($title);
     // @todo FuzzyBot hack
     PageTranslationHooks::$allowTargetEdit = true;
     $content = ContentHandler::makeContent($text, $page->getTitle());
     $page->doEditContent($content, $summary, $flags, false, $user);
     PageTranslationHooks::$allowTargetEdit = false;
     return true;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:27,代码来源:TranslateRenderJob.php

示例10: getDefinitions

 /**
  * @see BaseDependencyContainer::registerDefinitions
  *
  * @since  1.9
  *
  * @return array
  */
 protected function getDefinitions()
 {
     return array('ParserData' => $this->getParserData(), 'NamespaceExaminer' => $this->getNamespaceExaminer(), 'JobFactory' => function (DependencyBuilder $builder) {
         return new \SMW\MediaWiki\Jobs\JobFactory();
     }, 'ContentParser' => function (DependencyBuilder $builder) {
         return new ContentParser($builder->getArgument('Title'));
     }, 'RequestContext' => function (DependencyBuilder $builder) {
         $instance = new \RequestContext();
         if ($builder->hasArgument('Title')) {
             $instance->setTitle($builder->getArgument('Title'));
         }
         if ($builder->hasArgument('Language')) {
             $instance->setLanguage($builder->getArgument('Language'));
         }
         return $instance;
     }, 'WikiPage' => function (DependencyBuilder $builder) {
         return \WikiPage::factory($builder->getArgument('Title'));
     }, 'TitleCreator' => function (DependencyBuilder $builder) {
         return new TitleCreator(new PageCreator());
     }, 'PageCreator' => function (DependencyBuilder $builder) {
         return new PageCreator();
     }, 'MessageFormatter' => function (DependencyBuilder $builder) {
         return new MessageFormatter($builder->getArgument('Language'));
     });
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:32,代码来源:SharedDependencyContainer.php

示例11: addDBData

 function addDBData()
 {
     $this->tablesUsed[] = 'page';
     $this->tablesUsed[] = 'revision';
     $this->tablesUsed[] = 'text';
     try {
         $title = Title::newFromText('BackupDumperTestP1');
         $page = WikiPage::factory($title);
         list($this->revId1_1, $this->textId1_1) = $this->addRevision($page, "BackupDumperTestP1Text1", "BackupDumperTestP1Summary1");
         $this->pageId1 = $page->getId();
         $title = Title::newFromText('BackupDumperTestP2');
         $page = WikiPage::factory($title);
         list($this->revId2_1, $this->textId2_1) = $this->addRevision($page, "BackupDumperTestP2Text1", "BackupDumperTestP2Summary1");
         list($this->revId2_2, $this->textId2_2) = $this->addRevision($page, "BackupDumperTestP2Text2", "BackupDumperTestP2Summary2");
         list($this->revId2_3, $this->textId2_3) = $this->addRevision($page, "BackupDumperTestP2Text3", "BackupDumperTestP2Summary3");
         list($this->revId2_4, $this->textId2_4) = $this->addRevision($page, "BackupDumperTestP2Text4 some additional Text  ", "BackupDumperTestP2Summary4 extra ");
         $this->pageId2 = $page->getId();
         $title = Title::newFromText('BackupDumperTestP3');
         $page = WikiPage::factory($title);
         list($this->revId3_1, $this->textId3_1) = $this->addRevision($page, "BackupDumperTestP3Text1", "BackupDumperTestP2Summary1");
         list($this->revId3_2, $this->textId3_2) = $this->addRevision($page, "BackupDumperTestP3Text2", "BackupDumperTestP2Summary2");
         $this->pageId3 = $page->getId();
         $page->doDeleteArticle("Testing ;)");
         $title = Title::newFromText('BackupDumperTestP1', NS_TALK);
         $page = WikiPage::factory($title);
         list($this->revId4_1, $this->textId4_1) = $this->addRevision($page, "Talk about BackupDumperTestP1 Text1", "Talk BackupDumperTestP1 Summary1");
         $this->pageId4 = $page->getId();
     } catch (Exception $e) {
         // We'd love to pass $e directly. However, ... see
         // documentation of exceptionFromAddDBData in
         // DumpTestCase
         $this->exceptionFromAddDBData = $e;
     }
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:34,代码来源:backup_PageTest.php

示例12: execute

 public function execute()
 {
     $userName = $this->getOption('u', 'Maintenance script');
     $reason = $this->getOption('r', '');
     $cascade = $this->hasOption('cascade');
     $protection = "sysop";
     if ($this->hasOption('semiprotect')) {
         $protection = "autoconfirmed";
     } elseif ($this->hasOption('unprotect')) {
         $protection = "";
     }
     $user = User::newFromName($userName);
     if (!$user) {
         $this->error("Invalid username", true);
     }
     // @todo FIXME: This is reset 7 lines down.
     $restrictions = array('edit' => $protection, 'move' => $protection);
     $t = Title::newFromText($this->getArg());
     if (!$t) {
         $this->error("Invalid title", true);
     }
     $restrictions = array();
     foreach ($t->getRestrictionTypes() as $type) {
         $restrictions[$type] = $protection;
     }
     # un/protect the article
     $this->output("Updating protection status... ");
     $page = WikiPage::factory($t);
     $status = $page->doUpdateRestrictions($restrictions, array(), $cascade, $reason, $user);
     if ($status->isOK()) {
         $this->output("done\n");
     } else {
         $this->output("failed\n");
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:35,代码来源:protect.php

示例13: execute

 public function execute()
 {
     $this->output("Looking for pages with page_latest set to 0...\n");
     $dbw = wfGetDB(DB_MASTER);
     $result = $dbw->select('page', array('page_id', 'page_namespace', 'page_title'), array('page_latest' => 0), __METHOD__);
     $n = 0;
     foreach ($result as $row) {
         $pageId = intval($row->page_id);
         $title = Title::makeTitle($row->page_namespace, $row->page_title);
         $name = $title->getPrefixedText();
         $latestTime = $dbw->selectField('revision', 'MAX(rev_timestamp)', array('rev_page' => $pageId), __METHOD__);
         if (!$latestTime) {
             $this->output(wfWikiID() . " {$pageId} [[{$name}]] can't find latest rev time?!\n");
             continue;
         }
         $revision = Revision::loadFromTimestamp($dbw, $title, $latestTime);
         if (is_null($revision)) {
             $this->output(wfWikiID() . " {$pageId} [[{$name}]] latest time {$latestTime}, can't find revision id\n");
             continue;
         }
         $id = $revision->getId();
         $this->output(wfWikiID() . " {$pageId} [[{$name}]] latest time {$latestTime}, rev id {$id}\n");
         if ($this->hasOption('fix')) {
             $page = WikiPage::factory($title);
             $page->updateRevisionOn($dbw, $revision);
         }
         $n++;
     }
     $this->output("Done! Processed {$n} pages.\n");
     if (!$this->hasOption('fix')) {
         $this->output("This was a dry run; rerun with --fix to update page_latest.\n");
     }
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:33,代码来源:attachLatest.php

示例14: execute

 /**
  * Purges the cache of a page
  */
 public function execute()
 {
     $params = $this->extractRequestParams();
     $forceLinkUpdate = $params['forcelinkupdate'];
     $pageSet = $this->getPageSet();
     $pageSet->execute();
     $result = array();
     self::addValues($result, $pageSet->getInvalidTitles(), 'invalid', 'title');
     self::addValues($result, $pageSet->getSpecialTitles(), 'special', 'title');
     self::addValues($result, $pageSet->getMissingPageIDs(), 'missing', 'pageid');
     self::addValues($result, $pageSet->getMissingRevisionIDs(), 'missing', 'revid');
     self::addValues($result, $pageSet->getMissingTitles(), 'missing');
     self::addValues($result, $pageSet->getInterwikiTitlesAsResult());
     foreach ($pageSet->getGoodTitles() as $title) {
         $r = array();
         ApiQueryBase::addTitleInfo($r, $title);
         $page = WikiPage::factory($title);
         $page->doPurge();
         // Directly purge and skip the UI part of purge().
         $r['purged'] = '';
         if ($forceLinkUpdate) {
             if (!$this->getUser()->pingLimiter()) {
                 global $wgEnableParserCache;
                 $popts = $page->makeParserOptions('canonical');
                 # Parse content; note that HTML generation is only needed if we want to cache the result.
                 $content = $page->getContent(Revision::RAW);
                 $p_result = $content->getParserOutput($title, $page->getLatest(), $popts, $wgEnableParserCache);
                 # Update the links tables
                 $updates = $content->getSecondaryDataUpdates($title, null, true, $p_result);
                 DataUpdate::runUpdates($updates);
                 $r['linkupdate'] = '';
                 if ($wgEnableParserCache) {
                     $pcache = ParserCache::singleton();
                     $pcache->save($p_result, $page, $popts);
                 }
             } else {
                 $error = $this->parseMsg(array('actionthrottledtext'));
                 $this->setWarning($error['info']);
                 $forceLinkUpdate = false;
             }
         }
         $result[] = $r;
     }
     $apiResult = $this->getResult();
     $apiResult->setIndexedTagName($result, 'page');
     $apiResult->addValue(null, $this->getModuleName(), $result);
     $values = $pageSet->getNormalizedTitlesAsResult($apiResult);
     if ($values) {
         $apiResult->addValue(null, 'normalized', $values);
     }
     $values = $pageSet->getConvertedTitlesAsResult($apiResult);
     if ($values) {
         $apiResult->addValue(null, 'converted', $values);
     }
     $values = $pageSet->getRedirectTitlesAsResult($apiResult);
     if ($values) {
         $apiResult->addValue(null, 'redirects', $values);
     }
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:62,代码来源:ApiPurge.php

示例15: addDBDataOnce

 public function addDBDataOnce()
 {
     $info = $this->insertPage(self::$pageName);
     $title = $info['title'];
     $page = WikiPage::factory($title);
     self::$pageRev = $page->getRevision();
     self::$revUser = User::newFromId(self::$pageRev->getUser(Revision::RAW));
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:8,代码来源:CategoryMembershipChangeTest.php


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