本文整理汇总了PHP中badge::get_aggregation_method方法的典型用法代码示例。如果您正苦于以下问题:PHP badge::get_aggregation_method方法的具体用法?PHP badge::get_aggregation_method怎么用?PHP badge::get_aggregation_method使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类badge
的用法示例。
在下文中一共展示了badge::get_aggregation_method方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_badge_criteria
/**
* Returns information about badge criteria in a list form.
*
* @param badge $badge Badge objects
* @param string $short Indicates whether to print full info about this badge
* @return string $output HTML string to output
*/
public function print_badge_criteria(badge $badge, $short = '')
{
$agg = $badge->get_aggregation_methods();
if (empty($badge->criteria)) {
return get_string('nocriteria', 'badges');
}
$overalldescr = '';
$overall = $badge->criteria[BADGE_CRITERIA_TYPE_OVERALL];
if (!$short && !empty($overall->description)) {
$overalldescr = $this->output->box(format_text($overall->description, $overall->descriptionformat, array('context' => $badge->get_context())), 'criteria-description');
}
// Get the condition string.
if (count($badge->criteria) == 2) {
$condition = '';
if (!$short) {
$condition = get_string('criteria_descr', 'badges');
}
} else {
$condition = get_string('criteria_descr_' . $short . BADGE_CRITERIA_TYPE_OVERALL, 'badges', core_text::strtoupper($agg[$badge->get_aggregation_method()]));
}
unset($badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]);
$items = array();
// If only one criterion left, make sure its description goe to the top.
if (count($badge->criteria) == 1) {
$c = reset($badge->criteria);
if (!$short && !empty($c->description)) {
$overalldescr = $this->output->box(format_text($c->description, $c->descriptionformat, array('context' => $badge->get_context())), 'criteria-description');
}
if (count($c->params) == 1) {
$items[] = get_string('criteria_descr_single_' . $short . $c->criteriatype, 'badges') . $c->get_details($short);
} else {
$items[] = get_string('criteria_descr_' . $short . $c->criteriatype, 'badges', core_text::strtoupper($agg[$badge->get_aggregation_method($c->criteriatype)])) . $c->get_details($short);
}
} else {
foreach ($badge->criteria as $type => $c) {
$criteriadescr = '';
if (!$short && !empty($c->description)) {
$criteriadescr = $this->output->box(format_text($c->description, $c->descriptionformat, array('context' => $badge->get_context())), 'criteria-description');
}
if (count($c->params) == 1) {
$items[] = get_string('criteria_descr_single_' . $short . $type, 'badges') . $c->get_details($short) . $criteriadescr;
} else {
$items[] = get_string('criteria_descr_' . $short . $type, 'badges', core_text::strtoupper($agg[$badge->get_aggregation_method($type)])) . $c->get_details($short) . $criteriadescr;
}
}
}
return $overalldescr . $condition . html_writer::alist($items, array(), 'ul');
}
示例2: print_badge_criteria
public function print_badge_criteria(badge $badge, $short = '')
{
$output = "";
$agg = $badge->get_aggregation_methods();
if (empty($badge->criteria)) {
return get_string('nocriteria', 'badges');
} else {
if (count($badge->criteria) == 2) {
if (!$short) {
$output .= get_string('criteria_descr', 'badges');
}
} else {
$output .= get_string('criteria_descr_' . $short . BADGE_CRITERIA_TYPE_OVERALL, 'badges', strtoupper($agg[$badge->get_aggregation_method()]));
}
}
$items = array();
unset($badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]);
foreach ($badge->criteria as $type => $c) {
if (count($c->params) == 1) {
$items[] = get_string('criteria_descr_single_' . $short . $type, 'badges') . $c->get_details($short);
} else {
$items[] = get_string('criteria_descr_' . $short . $type, 'badges', strtoupper($agg[$badge->get_aggregation_method($type)])) . $c->get_details($short);
}
}
$output .= html_writer::alist($items, array(), 'ul');
return $output;
}
示例3: print_badge_criteria
/**
* Print badge criteria.
*
* Modelled after core_badges_renderer::print_badge_critera(), except that
* we dispatch rendering of criteria to our own renderer methods as opposed
* to calling award_criteria::get_details() wherever possible.
*
* @param \badge $badge
* @param string $short
*
* @return string
*/
public function print_badge_criteria(badge $badge, $short = '')
{
$output = '';
$aggregationmethods = $badge->get_aggregation_methods();
if (!$badge->criteria) {
return static::string('nocriteria');
} elseif (count($badge->criteria) === 2) {
if (!$short) {
$output .= static::string('criteria_descr');
}
} else {
$stringname = 'criteria_descr_' . $short . BADGE_CRITERIA_TYPE_OVERALL;
$output .= static::string($stringname, core_text::strtoupper($aggregationmethods[$badge->get_aggregation_method()]));
}
unset($badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]);
$items = array();
foreach ($badge->criteria as $type => $criteria) {
$items[] = $this->print_badge_criteria_single($badge, $aggregationmethods, $type, $criteria, $short);
}
$output .= html_writer::alist($items, array(), 'ul');
return $output;
}