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


PHP TranslateUtils::figureMessage方法代码示例

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


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

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

示例2: execute

 public function execute($par)
 {
     $request = $this->getRequest();
     $par = (string) $par;
     // Yes, the use of getVal() and getText() is wanted, see bug T22365
     $this->text = $request->getVal('wpTitle', $par);
     $this->title = Title::newFromText($this->text);
     $this->reason = $request->getText('reason');
     // Checkboxes that default being checked are tricky
     $this->doSubpages = $request->getBool('subpages', !$request->wasPosted());
     $user = $this->getUser();
     if ($this->doBasicChecks() !== true) {
         return;
     }
     $out = $this->getOutput();
     // Real stuff starts here
     if (TranslatablePage::isSourcePage($this->title)) {
         $title = $this->msg('pt-deletepage-full-title', $this->title->getPrefixedText());
         $out->setPagetitle($title);
         $this->code = '';
         $this->page = TranslatablePage::newFromTitle($this->title);
     } else {
         $page = TranslatablePage::isTranslationPage($this->title);
         if ($page) {
             $title = $this->msg('pt-deletepage-lang-title', $this->title->getPrefixedText());
             $out->setPagetitle($title);
             list(, $this->code) = TranslateUtils::figureMessage($this->title->getText());
             $this->page = $page;
         } else {
             throw new ErrorPageError('pt-deletepage-invalid-title', 'pt-deletepage-invalid-text');
         }
     }
     if (!$user->isAllowed('pagetranslation')) {
         throw new PermissionsError('pagetranslation');
     }
     // Is there really no better way to do this?
     $subactionText = $request->getText('subaction');
     switch ($subactionText) {
         case $this->msg('pt-deletepage-action-check')->text():
             $subaction = 'check';
             break;
         case $this->msg('pt-deletepage-action-perform')->text():
             $subaction = 'perform';
             break;
         case $this->msg('pt-deletepage-action-other')->text():
             $subaction = '';
             break;
         default:
             $subaction = '';
     }
     if ($subaction === 'check' && $this->checkToken() && $request->wasPosted()) {
         $this->showConfirmation();
     } elseif ($subaction === 'perform' && $this->checkToken() && $request->wasPosted()) {
         $this->performAction();
     } else {
         $this->showForm();
     }
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:58,代码来源:SpecialPageTranslationDeletePage.php

示例3: execute

 public function execute()
 {
     $hours = (int) $this->getOption('days');
     $hours = $hours ? $hours * 7 : 7 * 24;
     $top = (int) $this->getOption('top');
     $top = $top ? $top : 10;
     $bots = $this->hasOption('bots');
     $namespaces = array();
     if ($this->hasOption('ns')) {
         $input = explode(',', $this->getOption('ns'));
         foreach ($input as $namespace) {
             if (is_numeric($namespace)) {
                 array_push($namespaces, $namespace);
             }
         }
     }
     /**
      * Select set of edits to report on
      */
     $rows = TranslateUtils::translationChanges($hours, $bots, $namespaces);
     /**
      * Get counts for edits per language code after filtering out edits by FuzzyBot
      */
     $codes = array();
     global $wgTranslateFuzzyBotName;
     foreach ($rows as $_) {
         // Filter out edits by $wgTranslateFuzzyBotName
         if ($_->rc_user_text === $wgTranslateFuzzyBotName) {
             continue;
         }
         list(, $code) = TranslateUtils::figureMessage($_->rc_title);
         if (!isset($codes[$code])) {
             $codes[$code] = 0;
         }
         $codes[$code]++;
     }
     /**
      * Sort counts and report descending up to $top rows.
      */
     arsort($codes);
     $i = 0;
     foreach ($codes as $code => $num) {
         if ($i++ === $top) {
             break;
         }
         $this->output("{$code}\t{$num}\n");
     }
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:48,代码来源:languageeditstats.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 );
		$collection->loadTranslations( DB_MASTER );

		$text = $page->getParse()->getTranslationPageText( $collection );

		// Other stuff
		$user    = $this->getUser();
		$summary = $this->getSummary();
		$flags   = $this->getFlags();

		$article = new Article( $title, 0 );

		// @todo FuzzyBot hack
		PageTranslationHooks::$allowTargetEdit = true;

		// Do the edit
		$status = $article->doEdit( $text, $summary, $flags, false, $user );
		SpecialPageTranslation::superDebug( __METHOD__, 'edit', $user, $title, $flags, $status );

		PageTranslationHooks::$allowTargetEdit = false;

		// purge cache
		$page->getTranslationPercentages( true );

		return true;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:40,代码来源:RenderJob.php

示例5: translationPageHeader

 protected static function translationPageHeader(Title $title)
 {
     if (!$title->exists()) {
         return;
     }
     // Check if applicable
     $page = TranslatablePage::isTranslationPage($title);
     if ($page === false) {
         return;
     }
     list(, $code) = TranslateUtils::figureMessage($title->getText());
     // Get the translation percentage
     $pers = $page->getTranslationPercentages();
     $per = 0;
     if (isset($pers[$code])) {
         $per = $pers[$code] * 100;
     }
     $titleText = $page->getTitle()->getPrefixedText();
     // This url might get cached
     $url = wfExpandUrl($page->getTranslationUrl($code), PROTO_RELATIVE);
     // Output
     $context = RequestContext::getMain();
     $language = $context->getLanguage();
     $wrap = Html::rawElement('div', array('class' => 'mw-translate-page-info', 'lang' => $language->getCode(), 'dir' => $language->getDir()), '$1');
     $out = $context->getOutput();
     $out->wrapWikiMsg($wrap, array('tpt-translation-intro', $url, ':' . $titleText, $language->formatNum($per)));
     $out->addHTML('<hr />');
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:28,代码来源:PageTranslationHooks.php

示例6: getTranslationPages

 /**
  * Fetch the available translation pages from database
  * @return Title[]
  */
 public function getTranslationPages()
 {
     // Avoid replication lag issues
     $dbr = wfGetDB(DB_MASTER);
     $prefix = $this->getTitle()->getDBkey() . '/';
     $likePattern = $dbr->buildLike($prefix, $dbr->anyString());
     $res = $dbr->select('page', array('page_namespace', 'page_title'), array('page_namespace' => $this->getTitle()->getNamespace(), "page_title {$likePattern}"), __METHOD__);
     $titles = TitleArray::newFromResult($res);
     $filtered = array();
     // Make sure we only get translation subpages while ignoring others
     $codes = Language::fetchLanguageNames();
     $prefix = $this->getTitle()->getText();
     /** @var Title $title */
     foreach ($titles as $title) {
         list($name, $code) = TranslateUtils::figureMessage($title->getText());
         if (!isset($codes[$code]) || $name !== $prefix) {
             continue;
         }
         $filtered[] = $title;
     }
     return $filtered;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:26,代码来源:TranslatablePage.php

示例7: indexOf

	public function indexOf( $row ) {
		// We need to check that there is only one user per day.
		if ( $this->opts['count'] === 'users' ) {
			$date = $this->formatTimestamp( $row->rc_timestamp );

			if ( isset( $this->usercache[$date][$row->rc_user_text] ) ) {
				return -1;
			} else {
				$this->usercache[$date][$row->rc_user_text] = 1;
			}
		}

		// Do not consider language-less pages.
		if ( strpos( $row->rc_title, '/' ) === false ) {
			return false;
		}

		// No filters, just one key to track.
		if ( !$this->groups && !$this->codes ) {
			return 'all';
		}

		// The key-building needs to be in sync with ::labels().
		list( $key, $code ) = TranslateUtils::figureMessage( $row->rc_title );

		$groups = array();
		$codes = array();

		if ( $this->groups ) {
			/*
			 * Get list of keys that the message belongs to, and filter
			 * out those which are not requested.
			 */
			$groups = TranslateUtils::messageKeyToGroups( $row->rc_namespace, $key );
			$groups = array_intersect( $this->groups, $groups );
		}

		if ( $this->codes ) {
			$codes = array( $code );
		}

		return $this->combineTwoArrays( $groups, $codes );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:43,代码来源:SpecialTranslationStats.php

示例8: isTranslationPage

 /**
  * @param $title Title
  * @return bool|TranslatablePage
  */
 public static function isTranslationPage(Title $title)
 {
     list($key, $code) = TranslateUtils::figureMessage($title->getText());
     if ($key === '' || $code === '') {
         return false;
     }
     $codes = Language::getLanguageNames(false);
     global $wgTranslateDocumentationLanguageCode;
     unset($codes[$wgTranslateDocumentationLanguageCode]);
     if (!isset($codes[$code])) {
         return false;
     }
     $newtitle = self::changeTitleText($title, $key);
     if (!$newtitle) {
         return false;
     }
     $page = TranslatablePage::newFromTitle($newtitle);
     if ($page->getMarkedTag() === false) {
         return false;
     }
     return $page;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:26,代码来源:TranslatablePage.php

示例9: wfGetDB

$dbr = wfGetDB( DB_SLAVE );
$rows = $dbr->select( array( 'page' ),
	array( 'page_title', 'page_namespace' ),
	array(
		'page_namespace' => $wgTranslateMessageNamespaces,
	),
	__METHOD__
);

$owners = array();
$keys = array();
$codes = Language::getLanguageNames();
$invalid = array();

foreach ( $rows as $row ) {
	list( $key, $code ) = TranslateUtils::figureMessage( $row->page_title );

	if ( !$code ) {
		$code = 'en';
	}

	$mg = TranslateUtils::messageKeyToGroup( $row->page_namespace, $key );
	$ns = $wgContLang->getNsText( $row->page_namespace );

	if ( is_null( $mg ) ) {
		$keys["$ns:$key"][] = $code;
		$owner = 'xx-unknown';
	} else {
		$owner = $mg;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:30,代码来源:messageDust.php

示例10: onPageContentLanguage

	/**
	 * Set the right page content language for message group translations ("Page/xx").
	 * Hook: PageContentLanguage
	 * @param $title Title
	 * @param $pageLang
	 * @return bool
	 */
	public static function onPageContentLanguage( $title, &$pageLang ) {
		global $wgTranslateMessageNamespaces;
		// For translation pages, parse plural, grammar etc with correct language, and set the right direction
		if ( in_array( $title->getNamespace(), $wgTranslateMessageNamespaces ) ) {
			list( , $code ) = TranslateUtils::figureMessage( $title->getText() );
			$pageLang = $code;
		}
		return true;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:16,代码来源:TranslateHooks.php

示例11: translationPageHeader

 protected static function translationPageHeader(Title $title)
 {
     global $wgOut;
     if (!$title->exists()) {
         return;
     }
     // Check if applicable
     $page = TranslatablePage::isTranslationPage($title);
     if ($page === false) {
         return;
     }
     list(, $code) = TranslateUtils::figureMessage($title->getText());
     // Get the translation percentage
     $pers = $page->getTranslationPercentages();
     $per = 0;
     if (isset($pers[$code])) {
         $per = $pers[$code] * 100;
     }
     $titleText = $page->getTitle()->getPrefixedText();
     $url = $page->getTranslationUrl($code);
     // Output
     $wrap = '<div class="mw-translate-page-info">$1</div>';
     $wgOut->wrapWikiMsg($wrap, array('tpt-translation-intro', $url, $titleText, $per));
     if (floor($per) < 100) {
         $group = $page->getMessageGroup();
         $collection = $group->initCollection($code);
         $collection->filter('fuzzy', false);
         if (count($collection)) {
             $wrap = '<div class="mw-translate-page-info mw-translate-fuzzy">$1</div>';
             $wgOut->wrapWikiMsg($wrap, array('tpt-translation-intro-fuzzy'));
         }
     }
     $wgOut->addHTML('<hr />');
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:34,代码来源:PageTranslationHooks.php

示例12: execute

	public function execute() {
		global $wgContLang;

		$dbw = TranslationMemoryUpdater::getDatabaseHandle();
		if ( $dbw === null ) {
			$this->error( "Database file not configured" );
			$this->exit();
		}
		$dbw->setFlag( DBO_TRX ); // HUGE speed improvement

		$groups = MessageGroups::singleton()->getGroups();
		// TODO: encapsulate list of valid language codes
		$languages = Language::getLanguageNames( false );
		unset( $languages['en'] );

		foreach ( $groups as $id => $group ) {
			if ( $group->isMeta() ) {
				continue;
			}

			$this->output( "Processing: {$group->getLabel()} ", $id );
			$capitalized = MWNamespace::isCapitalized( $group->getNamespace() );
			$ns_text = $wgContLang->getNsText( $group->getNamespace() );

			$definitions = $group->load( $group->getSourceLanguage() );
			foreach ( $definitions as $key => $definition ) {
				// TODO: would be nice to do key normalisation closer to the message groups, to avoid transforming back and forth.
				// But how to preserve the original keys...
				$key = strtr( $key, ' ', '_' );
				$key = $capitalized ? $wgContLang->ucfirst( $key ) : $key;

				$dbr = wfGetDB( DB_SLAVE );
				$tables = array( 'page', 'revision', 'text' );
				// selectFields to stfu Revision class
				$vars = array_merge( Revision::selectTextFields(), array( 'page_title' ), Revision::selectFields() );
				$conds = array(
					'page_latest = rev_id',
					'rev_text_id = old_id',
					'page_namespace' => $group->getNamespace(),
					'page_title ' . $dbr->buildLike( "$key/", $dbr->anyString() )
				);

				$res = $dbr->select( $tables, $vars, $conds, __METHOD__ );
				// Assure that there is at least one translation
				if ( $res->numRows() < 1 ) {
					continue;
				}

				$insert = array(
					'text' => $definition,
					'context' => "$ns_text:$key",
					'length' => strlen( $definition ),
					'lang' => $group->getSourceLanguage(),
				);

				$source_id = $dbw->selectField( '`sources`', 'sid', $insert, __METHOD__ );
				if ( $source_id === false ) {
					$dbw->insert( '`sources`', $insert, __METHOD__ );
					$source_id = $dbw->insertId();
				}

				$this->output( ' ', $id );

				foreach ( $res as $row ) {
					list( , $code ) = TranslateUtils::figureMessage( $row->page_title );
					$revision = new Revision( $row );
					$insert = array(
						'text' => $revision->getText(),
						'lang' => $code,
						'time' => wfTimestamp(),
						'sid' => $source_id );
					// We only do SQlite which doesn't need to know unique indexes
					$dbw->replace( '`targets`', null, $insert, __METHOD__ );
				}
				$this->output( "{$res->numRows()}", $id );

			} // each translation>

			$dbw->commit();
		} // each group>
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:81,代码来源:tm-export.php


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