本文整理汇总了PHP中ContentHandler类的典型用法代码示例。如果您正苦于以下问题:PHP ContentHandler类的具体用法?PHP ContentHandler怎么用?PHP ContentHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContentHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testMakeEmptyContent
/**
* @dataProvider provideHandlers
* @param ContentHandler $handler
*/
public function testMakeEmptyContent(ContentHandler $handler)
{
$content = $handler->makeEmptyContent();
$this->assertInstanceOf(Content::class, $content);
if ($handler instanceof TextContentHandler) {
// TextContentHandler::getContentClass() is protected, so bypass
// that restriction
$testingWrapper = TestingAccessWrapper::newFromObject($handler);
$this->assertInstanceOf($testingWrapper->getContentClass(), $content);
}
$handlerClass = get_class($handler);
$contentClass = get_class($content);
$this->assertTrue($content->isValid(), "{$handlerClass}::makeEmptyContent() did not return a valid content ({$contentClass}::isValid())");
}
开发者ID:paladox,项目名称:mediawiki,代码行数:18,代码来源:ContentHandlerSanityTest.php
示例2: 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
示例3: 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
示例4: 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
示例5: testGetAutosummary
/**
* @dataProvider dataGetAutosummary
* @covers WikitextContentHandler::getAutosummary
*/
public function testGetAutosummary($old, $new, $flags, $expected)
{
$oldContent = is_null($old) ? null : new WikitextContent($old);
$newContent = is_null($new) ? null : new WikitextContent($new);
$summary = $this->handler->getAutosummary($oldContent, $newContent, $flags);
$this->assertTrue((bool) preg_match($expected, $summary), "Autosummary didn't match expected pattern {$expected}: {$summary}");
}
开发者ID:paladox,项目名称:mediawiki,代码行数:11,代码来源:WikitextContentHandlerTest.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: 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
示例8: 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
示例9: getMessageParameters
protected function getMessageParameters()
{
$lang = $this->context->getLanguage();
$params = parent::getMessageParameters();
$params[3] = ContentHandler::getLocalizedName($params[3], $lang);
$params[4] = ContentHandler::getLocalizedName($params[4], $lang);
return $params;
}
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:8,代码来源:ContentModelLogFormatter.php
示例10: updatePageContent
function updatePageContent($article, $rev, $baseID, $user)
{
global $wgHuijiPrefix, $wgSitename;
$title = $article->getId() == 1 ? $wgSitename : $article->getTitle()->getText();
$post_data = array('timestamp' => $rev->getTimestamp(), 'content' => ContentHandler::getContentText($rev->getContent(Revision::RAW)), 'sitePrefix' => $wgHuijiPrefix, 'siteName' => $wgSitename, 'id' => $article->getId(), 'title' => $title);
$post_data_string = json_encode($post_data);
curl_post_json('upsert', $post_data_string);
}
开发者ID:volvor,项目名称:SocialProfile,代码行数:8,代码来源:updateESContent.php
示例11: 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
示例12: 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
示例13: 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
示例14: 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
示例15: shouldUseSpecialHistory
/**
* Checks, if the given title supports the use of SpecialMobileHistory.
*
* @param Title $title The title to check
* @return boolean True, if SpecialMobileHistory can be used, false otherwise
*/
public static function shouldUseSpecialHistory(Title $title)
{
$contentHandler = ContentHandler::getForTitle($title);
$actionOverrides = $contentHandler->getActionOverrides();
// if history is overwritten, assume, that SpecialMobileHistory can't handle them
if (isset($actionOverrides['history'])) {
// and return false
return false;
}
return true;
}
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:17,代码来源:SpecialMobileHistory.php
示例16: 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
示例17: 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
示例18: 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
示例19: 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
示例20: 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
注:本文中的ContentHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论