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


PHP ContentHandler::makeContent方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: getDefinitions

 public function getDefinitions()
 {
     $groups = MessageGroups::getAllGroups();
     $keys = array();
     /**
      * @var $g MessageGroup
      */
     foreach ($groups as $g) {
         $states = $g->getMessageGroupStates()->getStates();
         foreach (array_keys($states) as $state) {
             $keys["Translate-workflow-state-{$state}"] = $state;
         }
     }
     $defs = TranslateUtils::getContents(array_keys($keys), $this->getNamespace());
     foreach ($keys as $key => $state) {
         if (!isset($defs[$key])) {
             // @todo Use jobqueue
             $title = Title::makeTitleSafe($this->getNamespace(), $key);
             $page = new WikiPage($title);
             $content = ContentHandler::makeContent($state, $title);
             $page->doEditContent($content, wfMessage('translate-workflow-autocreated-summary', $state)->inContentLanguage()->text(), 0, false, FuzzyBot::getUser());
         } else {
             // Use the wiki translation as definition if available.
             // getContents returns array( content, last author )
             list($content, ) = $defs[$key];
             $keys[$key] = $content;
         }
     }
     return $keys;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:30,代码来源:WorkflowStatesMessageGroup.php

示例5: 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

示例6: updatePage

 /**
  * Updates $title with the provided $text
  * @param Title title
  * @param string $text
  */
 public static function updatePage($title, $text)
 {
     $user = new User();
     $page = WikiPage::factory($title);
     $content = ContentHandler::makeContent($text, $page->getTitle());
     $page->doEditContent($content, "summary", 0, false, $user);
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:12,代码来源:MassMessageTest.php

示例7: editPageText

 /**
  * @param string $text new page text
  *
  * @return int|null
  */
 private function editPageText($text)
 {
     $page = WikiPage::factory($this->title);
     $editResult = $page->doEditContent(ContentHandler::makeContent($text, $this->title), __METHOD__);
     /** @var Revision $revision */
     $revision = $editResult->value['revision'];
     $this->runJobs();
     return $revision->getId();
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:14,代码来源:CategoryMembershipChangeJobTest.php

示例8: doPatrolledPageEdit

 private function doPatrolledPageEdit(User $user, LinkTarget $target, $content, $summary, User $patrollingUser)
 {
     $title = Title::newFromLinkTarget($target);
     $page = WikiPage::factory($title);
     $status = $page->doEditContent(ContentHandler::makeContent($content, $title), $summary, 0, false, $user);
     /** @var Revision $rev */
     $rev = $status->value['revision'];
     $rc = $rev->getRecentChange();
     $rc->doMarkPatrolled($patrollingUser, false, []);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:10,代码来源:ApiQueryWatchlistIntegrationTest.php

示例9: update

 /**
  * Add or update message contents
  */
 function update($translation, $user)
 {
     $savePage = function ($title, $text) {
         $wikiPage = new WikiPage($title);
         $content = ContentHandler::makeContent($text, $title);
         $result = $wikiPage->doEditContent($content, '/* PR admin */', EDIT_FORCE_BOT);
         return $wikiPage;
     };
     $savePage($this->getTitle(), $translation);
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-Promoter,代码行数:13,代码来源:AdMessage.php

示例10: testPrefixNormalizationSearchBug

 /**
  *Test bug 25702
  *Prefixes of API search requests are not handled with case sensitivity and may result
  *in wrong search results
  */
 public function testPrefixNormalizationSearchBug()
 {
     $title = Title::newFromText('Category:Template:xyz');
     $page = WikiPage::factory($title);
     $page->doEditContent(ContentHandler::makeContent('Some text', $page->getTitle()), 'inserting content');
     $result = $this->doApiRequest(['action' => 'query', 'list' => 'allpages', 'apnamespace' => NS_CATEGORY, 'apprefix' => 'Template:x']);
     $this->assertArrayHasKey('query', $result[0]);
     $this->assertArrayHasKey('allpages', $result[0]['query']);
     $this->assertNotEquals(0, count($result[0]['query']['allpages']), 'allpages list does not contain page Category:Template:xyz');
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:15,代码来源:ApiQueryAllPagesTest.php

示例11: doEdits

 /**
  * @return int[] Revision ids
  */
 protected function doEdits()
 {
     $title = $this->getTitle();
     $page = WikiPage::factory($title);
     $strings = array("it is a kitten", "two kittens", "three kittens", "four kittens");
     $revisions = array();
     foreach ($strings as $string) {
         $content = ContentHandler::makeContent($string, $title);
         $page->doEditContent($content, 'edit page');
         $revisions[] = $page->getLatest();
     }
     return $revisions;
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:16,代码来源:DifferenceEngineTest.php

示例12: execute

	public function execute() {
		global $wgUser, $wgTitle;

		$userName = $this->getOption( 'user', 'Maintenance script' );
		$summary = $this->getOption( 'summary', '' );
		$minor = $this->hasOption( 'minor' );
		$bot = $this->hasOption( 'bot' );
		$autoSummary = $this->hasOption( 'autosummary' );
		$noRC = $this->hasOption( 'no-rc' );

		$wgUser = User::newFromName( $userName );
		$context = RequestContext::getMain();
		$context->setUser( $wgUser );
		if ( !$wgUser ) {
			$this->error( "Invalid username", true );
		}
		if ( $wgUser->isAnon() ) {
			$wgUser->addToDatabase();
		}

		$wgTitle = Title::newFromText( $this->getArg() );
		if ( !$wgTitle ) {
			$this->error( "Invalid title", true );
		}
		$context->setTitle( $wgTitle );

		$page = WikiPage::factory( $wgTitle );

		# Read the text
		$text = $this->getStdin( Maintenance::STDIN_ALL );
		$content = ContentHandler::makeContent( $text, $wgTitle );

		# Do the edit
		$this->output( "Saving... " );
		$status = $page->doEditContent( $content, $summary,
			( $minor ? EDIT_MINOR : 0 ) |
			( $bot ? EDIT_FORCE_BOT : 0 ) |
			( $autoSummary ? EDIT_AUTOSUMMARY : 0 ) |
			( $noRC ? EDIT_SUPPRESS_RC : 0 ) );
		if ( $status->isOK() ) {
			$this->output( "done\n" );
			$exit = 0;
		} else {
			$this->output( "failed\n" );
			$exit = 1;
		}
		if ( !$status->isGood() ) {
			$this->output( $status->getWikiText() . "\n" );
		}
		exit( $exit );
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:51,代码来源:edit.php

示例13: makePage

 /**
  * Helper function for addDBData -- adds a simple page to the database
  *
  * @param string $title Title of page to be created
  * @param string $lang Language and content of the created page
  * @param string|null $content Content of the created page, or null for a generic string
  */
 protected function makePage($title, $lang, $content = null)
 {
     global $wgContLang;
     if ($content === null) {
         $content = $lang;
     }
     if ($lang !== $wgContLang->getCode()) {
         $title = "{$title}/{$lang}";
     }
     $title = Title::newFromText($title, NS_MEDIAWIKI);
     $wikiPage = new WikiPage($title);
     $contentHandler = ContentHandler::makeContent($content, $title);
     $wikiPage->doEditContent($contentHandler, "{$lang} translation test case");
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:21,代码来源:MessageCacheTest.php

示例14: addRevision

 /**
  * Adds a revision to a page, while returning the resuting revision's id
  *
  * @param $page WikiPage: page to add the revision to
  * @param $text string: revisions text
  * @param $text string: revisions summare
  *
  * @throws MWExcepion
  */
 protected function addRevision(Page $page, $text, $summary)
 {
     $status = $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle()), $summary);
     if ($status->isGood()) {
         $value = $status->getValue();
         $revision = $value['revision'];
         $revision_id = $revision->getId();
         $text_id = $revision->getTextId();
         if ($revision_id > 0 && $text_id > 0) {
             return array($revision_id, $text_id);
         }
     }
     throw new MWException("Could not determine revision id (" . $status->getWikiText() . ")");
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:23,代码来源:DumpTestCase.php

示例15: addRevision

 /**
  * Adds a revision to a page, while returning the resuting revision's id
  *
  * @param Page $page Page to add the revision to
  * @param string $text Revisions text
  * @param string $summary Revisions summary
  * @param string $model The model ID (defaults to wikitext)
  *
  * @throws MWException
  * @return array
  */
 protected function addRevision(Page $page, $text, $summary, $model = CONTENT_MODEL_WIKITEXT)
 {
     $status = $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle(), $model), $summary);
     if ($status->isGood()) {
         $value = $status->getValue();
         $revision = $value['revision'];
         $revision_id = $revision->getId();
         $text_id = $revision->getTextId();
         if ($revision_id > 0 && $text_id > 0) {
             return [$revision_id, $text_id];
         }
     }
     throw new MWException("Could not determine revision id (" . $status->getWikiText(false, false, 'en') . ")");
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:25,代码来源:DumpTestCase.php


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