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


PHP MessageGroups::getGroup方法代码示例

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


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

示例1: forItem

 public static function forItem($groupId, $code)
 {
     # Check again if already in db ( to avoid overload in big clusters )
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select('groupstats', '*', array('gs_group' => $groupId, 'gs_lang' => $code));
     if ($row = $dbr->fetchRow($res)) {
         // convert to array
         return $row;
     }
     // get group object
     $g = MessageGroups::getGroup($groupId);
     # Calculate if missing and store in the db
     $collection = $g->initCollection($code);
     $collection->filter('optional');
     // Store the count of real messages for later calculation.
     $total = count($collection);
     // Count fuzzy first
     $collection->filter('fuzzy');
     $fuzzy = $total - count($collection);
     // Count the completion percent
     $collection->filter('translated', false);
     $translated = count($collection);
     $data = array('gs_group' => $groupId, 'gs_lang' => $code, 'gs_total' => $total, 'gs_translated' => $translated, 'gs_fuzzy' => $fuzzy);
     # store result in DB
     $dbw = wfGetDB(DB_MASTER);
     $dbw->insert('groupstats', $data, __METHOD__);
     return $data;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:28,代码来源:MessageGroupStatistics.php

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

示例3: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $title = Title::newFromText($params['title']);
     if (!$title) {
         $this->dieUsage('Invalid title', 'invalidtitle');
     }
     $handle = new MessageHandle($title);
     if (!$handle->isValid()) {
         $this->dieUsage('Title does not correspond to a translatable message', 'nomessagefortitle');
     }
     if (strval($params['group']) !== '') {
         $group = MessageGroups::getGroup($params['group']);
     } else {
         $group = $handle->getGroup();
     }
     if (!$group) {
         $this->dieUsage('Invalid group', 'invalidgroup');
     }
     $data = array();
     $times = array();
     $props = $params['prop'];
     $aggregator = new QueryAggregator();
     // Figure out the intersection of supported and requested aids
     $types = $group->getTranslationAids();
     $props = array_intersect($props, array_keys($types));
     $result = $this->getResult();
     // Create list of aids, populate web services queries
     $aids = array();
     foreach ($props as $type) {
         $class = $types[$type];
         $obj = new $class($group, $handle, $this);
         if ($obj instanceof QueryAggregatorAware) {
             $obj->setQueryAggregator($aggregator);
             $obj->populateQueries();
         }
         $aids[$type] = $obj;
     }
     // Execute all web service queries asynchronously to save time
     $start = microtime(true);
     $aggregator->run();
     $times['query_aggregator'] = round(microtime(true) - $start, 3);
     // Construct the result data structure
     foreach ($aids as $type => $obj) {
         $start = microtime(true);
         try {
             $aid = $obj->getData();
         } catch (TranslationHelperException $e) {
             $aid = array('error' => $e->getMessage());
         }
         if (isset($aid['**'])) {
             $result->setIndexedTagName($aid, $aid['**']);
             unset($aid['**']);
         }
         $data[$type] = $aid;
         $times[$type] = round(microtime(true) - $start, 3);
     }
     $result->addValue(null, 'helpers', $data);
     $result->addValue(null, 'times', $times);
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:60,代码来源:ApiQueryTranslationAids.php

示例4: run

	/**
	 * @param $resultPageSet ApiPageSet
	 */
	private function run( $resultPageSet = null ) {
		$params = $this->extractRequestParams();

		$group = MessageGroups::getGroup( $params['group'] );
		if ( !$group ) {
			$this->dieUsageMsg( array( 'missingparam', 'mcgroup' ) );
		}

		$messages = $group->initCollection( $params['language'] );
		$messages->setInFile( $group->load( $params['language'] ) );

		foreach ( $params['filter'] as $filter ) {
			$value = null;
			if ( strpos( $filter, ':' ) !== false ) {
				list( $filter, $value ) = explode( ':', $filter, 2 );
			}
			/* The filtering params here are swapped wrt MessageCollection.
			 * There (fuzzy) means do not show fuzzy, which is the same as !fuzzy
			 * here and fuzzy here means (fuzzy, false) there. */
			if ( $filter[0] === '!' ) {
				$messages->filter( substr( $filter, 1 ), true, $value );
			} else {
				$messages->filter( $filter, false, $value );
			}
		}

		$messages->slice( $params['offset'], $params['limit'] + 1 );

		$messages->loadTranslations();

		$result = $this->getResult();
		$pages = array();
		$count = 0;

		$props = array_flip( $params['prop'] );
		foreach ( $messages->keys() as $mkey => $title ) {
			if ( ++$count > $params['limit'] ) {
					$this->setContinueEnumParameter( 'offset', $params['offset'] + $count - 1 );
					break;
			}

			if ( is_null( $resultPageSet ) ) {
				$data = $this->extractMessageData( $result, $props, $messages[$mkey] );
				$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $data );
				if ( !$fit ) {
					$this->setContinueEnumParameter( 'offset', $params['offset'] + $count - 1 );
					break;
				}
			} else {
				$pages[] = $title;
			}
		}

		if ( is_null( $resultPageSet ) ) {
			$result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'message' );
		} else {
			$resultPageSet->populateFromTitles( $pages );
		}

	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:63,代码来源:ApiQueryMessageCollection.php

示例5: execute

 public function execute()
 {
     $user = $this->getUser();
     $requestParams = $this->extractRequestParams();
     $group = MessageGroups::getGroup($requestParams['group']);
     $code = $requestParams['language'];
     if (!$group || MessageGroups::isDynamic($group)) {
         $this->dieUsageMsg(array('missingparam', 'group'));
     }
     $stateConfig = $group->getMessageGroupStates()->getStates();
     if (!$stateConfig) {
         $this->dieUsage('Message group review not in use', 'disabled');
     }
     if (!$user->isAllowed(self::$right)) {
         $this->dieUsage('Permission denied', 'permissiondenied');
     }
     if ($user->isBlocked()) {
         $this->dieUsage('You have been blocked', 'blocked');
     }
     $requestParams = $this->extractRequestParams();
     $languages = Language::fetchLanguageNames();
     if (!isset($languages[$code])) {
         $this->dieUsageMsg(array('missingparam', 'language'));
     }
     $targetState = $requestParams['state'];
     if (!isset($stateConfig[$targetState])) {
         $this->dieUsage('The requested state is invalid', 'invalidstate');
     }
     if (is_array($stateConfig[$targetState]) && isset($stateConfig[$targetState]['right']) && !$user->isAllowed($stateConfig[$targetState]['right'])) {
         $this->dieUsage('Permission denied', 'permissiondenied');
     }
     self::changeState($group, $code, $targetState, $user);
     $output = array('review' => array('group' => $group->getId(), 'language' => $code, 'state' => $targetState));
     $this->getResult()->addValue(null, $this->getModuleName(), $output);
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:35,代码来源:ApiGroupReview.php

示例6: execute

 public function execute()
 {
     global $wgUser, $wgTranslateWorkflowStates;
     if (!$wgTranslateWorkflowStates) {
         $this->dieUsage('Message group review not in use', 'disabled');
     }
     if (!$wgUser->isallowed(self::$right)) {
         $this->dieUsage('Permission denied', 'permissiondenied');
     }
     $requestParams = $this->extractRequestParams();
     $group = MessageGroups::getGroup($requestParams['group']);
     if (!$group) {
         $this->dieUsageMsg(array('missingparam', 'group'));
     }
     $languages = Language::getLanguageNames(false);
     if (!isset($languages[$requestParams['language']])) {
         $this->dieUsageMsg(array('missingparam', 'language'));
     }
     $dbr = wfGetDB(DB_SLAVE);
     $groupid = $group->getId();
     $currentState = $dbr->selectField('translate_groupreviews', 'tgr_state', array('tgr_group' => $groupid, 'tgr_lang' => $requestParams['language']), __METHOD__);
     if ($currentState == $requestParams['state']) {
         $this->dieUsage('The requested state is identical to the current state', 'sameworkflowstate');
     }
     $dbw = wfGetDB(DB_MASTER);
     $table = 'translate_groupreviews';
     $row = array('tgr_group' => $groupid, 'tgr_lang' => $requestParams['language'], 'tgr_state' => $requestParams['state']);
     $index = array('tgr_group', 'tgr_language');
     $res = $dbw->replace($table, array($index), $row, __METHOD__);
     $logger = new LogPage('translationreview');
     $logParams = array($requestParams['language'], $group->getLabel(), $currentState, $requestParams['state']);
     $logger->addEntry('group', SpecialPage::getTitleFor('Translate', $groupid), '', $logParams, $wgUser);
     $output = array('review' => array('group' => $group->getId(), 'language' => $requestParams['language'], 'state' => $requestParams['state']));
     $this->getResult()->addValue(null, $this->getModuleName(), $output);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:35,代码来源:ApiGroupReview.php

示例7: setGroup

	/**
	 * Group is either MessageGroup object or group id.
	 * @param $group MessagerGroup|string
	 */
	public function setGroup( $group ) {
		if ( $group instanceof MessageGroup ) {
			$this->group = $group;
		} else {
			$this->group = MessageGroups::getGroup( $group );
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:11,代码来源:MessageWebImporter.php

示例8: __construct

	/**
	 * Contructs a new cache object for given group and language code.
	 * @param $group \types{String,FileBasedMessageGroup} Group object or id.
	 * @param $code \string Language code. Default value 'en'.
	 */
	public function __construct( $group, $code = 'en' ) {
		if ( is_object( $group ) ) {
			$this->group = $group;
		} else {
			$this->group = MessageGroups::getGroup( $group );
		}
		$this->code = $code;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:13,代码来源:MessageGroupCache.php

示例9: forGroup

	/**
	 * Returns stats for all languages in given group.
	 * @param $id string Group id
	 * @return Array
	 */
	public static function forGroup( $id ) {
		$group = MessageGroups::getGroup( $id );
		if ( $group === null ) {
			return array();
		}
		$stats = self::forGroupInternal( $group );
		return $stats[$id];
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:13,代码来源:MessageGroupStats.php

示例10: isValidValue

 protected function isValidValue($value)
 {
     $group = MessageGroups::getGroup($value);
     if ($group) {
         $this->target = $group->getId();
     }
     return (bool) $group;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:8,代码来源:SpecialMessageGroupStats.php

示例11: testHaveSingleSourceLanguage

 public function testHaveSingleSourceLanguage()
 {
     $this->setMwGlobals(array('wgTranslateGroupFiles' => array(__DIR__ . '/data/MixedSourceLanguageGroups.yaml')));
     MessageGroups::singleton()->recache();
     $enGroup1 = MessageGroups::getGroup('EnglishGroup1');
     $enGroup2 = MessageGroups::getGroup('EnglishGroup2');
     $teGroup1 = MessageGroups::getGroup('TeluguGroup1');
     $this->assertEquals('en', MessageGroups::haveSingleSourceLanguage(array($enGroup1, $enGroup2)));
     $this->assertEquals('', MessageGroups::haveSingleSourceLanguage(array($enGroup1, $enGroup2, $teGroup1)));
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:10,代码来源:MessageGroupsTest.php

示例12: getMessageGroup

 /**
  * Tries to determine to which group this message belongs. It tries to get
  * group id from loadgroup GET-paramater, but fallbacks to messageIndex file
  * if no valid group was provided.
  *
  * @return MessageGroup which the key belongs to, or null.
  */
 protected function getMessageGroup(MessageHandle $handle, $groupId)
 {
     $mg = MessageGroups::getGroup($groupId);
     # If we were not given (a valid) group
     if ($mg === null) {
         $groupId = MessageIndex::getPrimaryGroupId($handle);
         $mg = MessageGroups::getGroup($groupId);
     }
     return $mg;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:17,代码来源:TranslationHelpers.php

示例13: getData

 protected function getData()
 {
     $params = $this->extractRequestParams();
     $group = MessageGroups::getGroup($params['group']);
     if (!$group) {
         $this->dieUsageMsg(array('missingparam', 'mcgroup'));
     } elseif (MessageGroups::isDynamic($group)) {
         $this->dieUsage('Dynamic message groups are not supported here', 'invalidparam');
     }
     return MessageGroupStats::forGroup($group->getId());
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:11,代码来源:ApiQueryMessageGroupStats.php

示例14: getGroupsWithTransitions

 public static function getGroupsWithTransitions(MessageHandle $handle)
 {
     $listeners = array();
     foreach ($handle->getGroupIds() as $id) {
         $group = MessageGroups::getGroup($id);
         // No longer exists?
         if (!$group) {
             continue;
         }
         $conds = $group->getMessageGroupStates()->getConditions();
         if ($conds) {
             $listeners[$id] = $conds;
         }
     }
     return $listeners;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:16,代码来源:MessageGroupStatesUpdaterJob.php

示例15: formatTranslation

 protected function formatTranslation(StashedTranslation $translation)
 {
     $title = $translation->getTitle();
     $handle = new MessageHandle($title);
     // Prepare for the worst
     $definition = '';
     $comparison = '';
     if ($handle->isValid()) {
         $groupId = MessageIndex::getPrimaryGroupId($handle);
         $group = MessageGroups::getGroup($groupId);
         $key = $handle->getKey();
         $definition = $group->getMessage($key, $group->getSourceLanguage());
         $comparison = $group->getMessage($key, $handle->getCode());
     }
     return array('title' => $title->getPrefixedText(), 'definition' => $definition, 'translation' => $translation->getValue(), 'comparison' => $comparison, 'metadata' => $translation->getMetadata());
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:16,代码来源:ApiTranslationStash.php


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