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


PHP MessageGroups::getAllGroups方法代码示例

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


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

示例1: testAPIFilterAccuracy

 public function testAPIFilterAccuracy()
 {
     $ids = array('MadeUpGroup');
     $ids += array_keys(MessageGroups::getAllGroups());
     foreach ($ids as $id) {
         list($data) = $this->doApiRequest(array('action' => 'query', 'meta' => 'messagegroups', 'mgprop' => 'id|label|class|namespace|exists', 'mgfilter' => $id, 'continue' => ''));
         if ($id === 'MadeUpGroup') {
             // Check structure (shouldn't find anything)
             $this->assertArrayNotHasKey('warnings', $data);
             $this->assertArrayHasKey('query', $data);
             $this->assertCount(1, $data['query']);
             $this->assertArrayHasKey('messagegroups', $data['query']);
             $this->assertCount(0, $data['query']['messagegroups']);
             continue;
         }
         // Check structure (filter is unique given these names)
         $this->assertArrayNotHasKey('warnings', $data);
         $this->assertArrayHasKey('query', $data);
         $this->assertCount(1, $data['query']);
         $this->assertArrayHasKey('messagegroups', $data['query']);
         $this->assertCount(1, $data['query']['messagegroups']);
         // Check content
         $item = $data['query']['messagegroups'][0];
         $this->assertCount(5, $item);
         $this->assertSame($item['id'], $id);
         $this->assertSame($item['label'], 'thelabel');
         $this->assertSame($item['exists'], true);
         $this->assertStringEndsWith('id', $item['id']);
         // theid, anotherid
         $this->assertSame($item['namespace'], 5);
         $this->assertSame($item['class'], 'WikiMessageGroup');
     }
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:33,代码来源:ApiQueryMessageGroupsTest.php

示例2: execute

 public function execute($parameters)
 {
     $this->setHeaders();
     $out = $this->getOutput();
     // Check permissions
     if ($this->getUser()->isAllowed('translate-manage')) {
         $this->hasPermission = true;
     }
     $groups = MessageGroups::getAllGroups();
     uasort($groups, array('MessageGroups', 'groupLabelSort'));
     $aggregates = array();
     $pages = array();
     foreach ($groups as $group) {
         if ($group instanceof WikiPageMessageGroup) {
             $pages[] = $group;
         } elseif ($group instanceof AggregateMessageGroup) {
             $subgroups = TranslateMetadata::getSubgroups($group->getId());
             if ($subgroups !== false) {
                 $aggregates[] = $group;
             }
         }
     }
     if (!count($pages)) {
         // @todo Use different message
         $out->addWikiMsg('tpt-list-nopages');
         return;
     }
     $this->showAggregateGroups($aggregates, $pages);
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:29,代码来源:SpecialAggregateGroups.php

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

示例4: execute

 public function execute()
 {
     $groups = MessageGroups::getAllGroups();
     $result = $this->getResult();
     foreach ($groups as $id => $g) {
         $a = array();
         $a['id'] = $id;
         $a['label'] = $g->getLabel();
         $a['description'] = $g->getDescription();
         $a['class'] = get_class($g);
         $a['exists'] = $g->exists();
         // TODO: Add a continue?
         $fit = $result->addValue(array('query', $this->getModuleName()), null, $a);
         if (!$fit) {
             // Even if we're not going to give a continue, no point carrying on if the result is full
             break;
         }
     }
     $result->setIndexedTagName_internal(array('query', $this->getModuleName()), 'group');
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:20,代码来源:ApiQueryMessageGroups.php

示例5: getExamples

 public function getExamples()
 {
     global $wgTranslateWorkflowStates;
     $groups = MessageGroups::getAllGroups();
     $group = key($groups);
     $state = current((array) $wgTranslateWorkflowStates);
     return array("api.php?action=groupreview&group={$group}&language=de&state={$state}");
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:8,代码来源:ApiGroupReview.php

示例6: getExamples

 public function getExamples()
 {
     $groups = MessageGroups::getAllGroups();
     $group = key($groups);
     return array("api.php?action=query&meta=messagegroupstats&mgsgroup={$group} List of translation completion statistics for group {$group}");
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:6,代码来源:ApiQueryMessageGroupStats.php

示例7: getExamples

 public function getExamples()
 {
     $groups = MessageGroups::getAllGroups();
     $group = key($groups);
     return array('api.php?action=query&meta=siteinfo&siprop=languages List of supported languages', "api.php?action=query&list=messagecollection&mcgroup={$group} List of non-optional message definitions for group {$group}", "api.php?action=query&list=messagecollection&mcgroup={$group}&mclanguage=fi&mcprop=definition|translation|tags&mcfilter=optional List of optional messages in Finnish with tags for group {$group}", "api.php?action=query&generator=messagecollection&gmcgroup={$group}&gmclanguage=nl&prop=revisions More information about latest translation revisions for group {$group}");
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:6,代码来源:ApiQueryMessageCollection.php

示例8: clearMetadata

 protected function clearMetadata()
 {
     // remove the entries from metadata table.
     $groupId = $this->page->getMessageGroupId();
     TranslateMetadata::set($groupId, 'prioritylangs', false);
     TranslateMetadata::set($groupId, 'priorityforce', false);
     TranslateMetadata::set($groupId, 'priorityreason', false);
     // remove the page from aggregate groups, if present in any of them.
     $groups = MessageGroups::getAllGroups();
     foreach ($groups as $group) {
         if ($group instanceof AggregateMessageGroup) {
             $subgroups = TranslateMetadata::get($group->getId(), 'subgroups');
             if ($subgroups !== false) {
                 $subgroups = explode(',', $subgroups);
                 $subgroups = array_flip($subgroups);
                 if (isset($subgroups[$groupId])) {
                     unset($subgroups[$groupId]);
                     $subgroups = array_flip($subgroups);
                     TranslateMetadata::set($group->getId(), 'subgroups', implode(',', $subgroups));
                 }
             }
         }
     }
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:24,代码来源:SpecialPageTranslationDeletePage.php

示例9: groupSelector

 protected function groupSelector()
 {
     $groups = MessageGroups::getAllGroups();
     uasort($groups, array('MessageGroups', 'groupLabelSort'));
     $dynamic = MessageGroups::getDynamicGroups();
     $groups = array_keys(array_merge($dynamic, $groups));
     $selected = $this->options['group'];
     $selector = new XmlSelect('group', 'group');
     $selector->setDefault($selected);
     foreach ($groups as $id) {
         $group = MessageGroups::getGroup($id);
         $hide = MessageGroups::getPriority($group) === 'discouraged';
         if (!$group->exists() || $hide && $id !== $selected) {
             continue;
         }
         $selector->addOption($group->getLabel(), $id);
     }
     return $selector->getHTML();
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:19,代码来源:SpecialTranslate.php

示例10: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $filter = $params['filter'];
     $groups = array();
     // Parameter root as all for all pages subgroups
     if ($params['root'] === 'all') {
         $allGroups = MessageGroups::getAllGroups();
         foreach ($allGroups as $group) {
             if ($group instanceof WikiPageMessageGroup) {
                 $groups[] = $group;
             }
         }
     } elseif ($params['format'] === 'flat') {
         if ($params['root'] !== '') {
             $group = MessageGroups::getGroup($params['root']);
             if ($group) {
                 $groups[$params['root']] = $group;
             }
         } else {
             $groups = MessageGroups::getAllGroups();
             foreach (MessageGroups::getDynamicGroups() as $id => $unused) {
                 $groups[$id] = MessageGroups::getGroup($id);
             }
         }
         // Not sorted by default, so do it now
         // Work around php bug: https://bugs.php.net/bug.php?id=50688
         wfSuppressWarnings();
         usort($groups, array('MessageGroups', 'groupLabelSort'));
         wfRestoreWarnings();
     } elseif ($params['root'] !== '') {
         // format=tree from now on, as it is the only other valid option
         $group = MessageGroups::getGroup($params['root']);
         if ($group instanceof AggregateMessageGroup) {
             $groups = MessageGroups::subGroups($group);
             // The parent group is the first, ignore it
             array_shift($groups);
         }
     } else {
         $groups = MessageGroups::getGroupStructure();
         foreach (MessageGroups::getDynamicGroups() as $id => $unused) {
             $groups[$id] = MessageGroups::getGroup($id);
         }
     }
     // Do not list the sandbox group. The code that knows it
     // exists can access it directly.
     if (isset($groups['!sandbox'])) {
         unset($groups['!sandbox']);
     }
     $props = array_flip($params['prop']);
     $result = $this->getResult();
     $matcher = new StringMatcher('', $filter);
     /**
      * @var MessageGroup $mixed
      */
     foreach ($groups as $mixed) {
         if ($filter !== array() && !$matcher->match($mixed->getId())) {
             continue;
         }
         $a = $this->formatGroup($mixed, $props);
         $result->setIndexedTagName($a, 'group');
         // @todo Add a continue?
         $fit = $result->addValue(array('query', $this->getModuleName()), null, $a);
         if (!$fit) {
             $this->setWarning('Could not fit all groups in the resultset.');
             // Even if we're not going to give a continue, no point carrying on
             // if the result is full
             break;
         }
     }
     if (defined('ApiResult::META_CONTENT')) {
         $result->addIndexedTagName(array('query', $this->getModuleName()), 'group');
     } else {
         $result->setIndexedTagName_internal(array('query', $this->getModuleName()), 'group');
     }
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:76,代码来源:ApiQueryMessageGroups.php

示例11: groupSelector

	public static function groupSelector( $default = false ) {
		$groups = MessageGroups::getAllGroups();
		$selector = new XmlSelect( 'group', 'group', $default );

		foreach ( $groups as $id => $class ) {
			if ( MessageGroups::getGroup( $id )->exists() ) {
				$selector->addOption( $class->getLabel(), $id );
			}
		}

		return $selector;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:12,代码来源:TranslateUtils.php

示例12: moveMetadata

 protected function moveMetadata($oldGroupId, $newGroupId)
 {
     $prioritylangs = TranslateMetadata::get($oldGroupId, 'prioritylangs');
     $priorityforce = TranslateMetadata::get($oldGroupId, 'priorityforce');
     $priorityreason = TranslateMetadata::get($oldGroupId, 'priorityreason');
     TranslateMetadata::set($oldGroupId, 'prioritylangs', false);
     TranslateMetadata::set($oldGroupId, 'priorityforce', false);
     TranslateMetadata::set($oldGroupId, 'priorityreason', false);
     if ($prioritylangs) {
         TranslateMetadata::set($newGroupId, 'prioritylangs', $prioritylangs);
     }
     if ($priorityforce) {
         TranslateMetadata::set($newGroupId, 'priorityforce', $priorityforce);
     }
     if ($priorityreason !== false) {
         TranslateMetadata::set($newGroupId, 'priorityreason', $priorityreason);
     }
     // make the changes in aggregate groups metadata, if present in any of them.
     $groups = MessageGroups::getAllGroups();
     foreach ($groups as $group) {
         if ($group instanceof AggregateMessageGroup) {
             $subgroups = TranslateMetadata::get($group->getId(), 'subgroups');
             if ($subgroups !== false) {
                 $subgroups = explode(',', $subgroups);
                 $subgroups = array_flip($subgroups);
                 if (isset($subgroups[$oldGroupId])) {
                     $subgroups[$newGroupId] = $subgroups[$oldGroupId];
                     unset($subgroups[$oldGroupId]);
                     $subgroups = array_flip($subgroups);
                     TranslateMetadata::set($group->getId(), 'subgroups', implode(',', $subgroups));
                 }
             }
         }
     }
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:35,代码来源:SpecialPageTranslationMovePage.php

示例13: getAllPages

 public static function getAllPages()
 {
     $groups = MessageGroups::getAllGroups();
     $pages = array();
     foreach ($groups as $group) {
         if ($group instanceof WikiPageMessageGroup) {
             $pages[$group->getId()] = $group->getTitle()->getPrefixedText();
         }
     }
     return $pages;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:11,代码来源:ApiAggregateGroups.php

示例14: groupSelector

 protected function groupSelector()
 {
     $activeId = false;
     if ($this->group) {
         $activeId = $this->group->getId();
     }
     $groups = MessageGroups::getAllGroups();
     $dynamic = MessageGroups::getDynamicGroups();
     $groups = array_keys(array_merge($groups, $dynamic));
     $selected = $this->options['group'];
     $selector = new XmlSelect('group', 'group');
     $selector->setDefault($selected);
     foreach ($groups as $id) {
         if ($id === $activeId) {
             $activeId = false;
         }
         $group = MessageGroups::getGroup($id);
         $hide = MessageGroups::getPriority($group) === 'discouraged';
         if (!$group->exists() || $hide) {
             continue;
         }
         $selector->addOption($group->getLabel(), $id);
     }
     if ($activeId) {
         $selector->addOption($this->group->getLabel(), $activeId);
     }
     return $selector->getHTML();
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:28,代码来源:SpecialTranslate.php

示例15: getAllowedValues

	protected function getAllowedValues() {
		$groups = MessageGroups::getAllGroups();
		return array_keys( $groups );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:4,代码来源:SpecialMessageGroupStats.php


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