本文整理汇总了PHP中MessageGroups::getDynamicGroups方法的典型用法代码示例。如果您正苦于以下问题:PHP MessageGroups::getDynamicGroups方法的具体用法?PHP MessageGroups::getDynamicGroups怎么用?PHP MessageGroups::getDynamicGroups使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageGroups
的用法示例。
在下文中一共展示了MessageGroups::getDynamicGroups方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
}
示例2: 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();
}
示例3: 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();
}