本文整理汇总了PHP中print_badge_image函数的典型用法代码示例。如果您正苦于以下问题:PHP print_badge_image函数的具体用法?PHP print_badge_image怎么用?PHP print_badge_image使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_badge_image函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_badge_management
protected function render_badge_management(badge_management $badges)
{
$paging = new paging_bar($badges->totalcount, $badges->page, $badges->perpage, $this->page->url, 'page');
// New badge button.
$n['type'] = $this->page->url->get_param('type');
$n['id'] = $this->page->url->get_param('id');
$htmlnew = $this->output->single_button(new moodle_url('newbadge.php', $n), get_string('newbadge', 'badges'));
$htmlpagingbar = $this->render($paging);
$table = new html_table();
$table->attributes['class'] = 'collection';
$sortbyname = $this->helper_sortable_heading(get_string('name'), 'name', $badges->sort, $badges->dir);
$sortbystatus = $this->helper_sortable_heading(get_string('status', 'badges'), 'status', $badges->sort, $badges->dir);
$table->head = array($sortbyname, $sortbystatus, get_string('bcriteria', 'badges'), get_string('awards', 'badges'), get_string('actions'));
$table->colclasses = array('name', 'status', 'criteria', 'awards', 'actions');
foreach ($badges->badges as $b) {
$style = !$b->is_active() ? array('class' => 'dimmed') : array();
$forlink = print_badge_image($b, $this->page->context) . ' ' . html_writer::start_tag('span') . $b->name . html_writer::end_tag('span');
$name = html_writer::link(new moodle_url('/badges/overview.php', array('id' => $b->id)), $forlink, $style);
$status = $b->statstring;
$criteria = self::print_badge_criteria($b, 'short');
if (has_capability('moodle/badges:viewawarded', $this->page->context)) {
$awards = html_writer::link(new moodle_url('/badges/recipients.php', array('id' => $b->id)), $b->awards);
} else {
$awards = $b->awards;
}
$actions = self::print_badge_table_actions($b, $this->page->context);
$row = array($name, $status, $criteria, $awards, $actions);
$table->data[] = $row;
}
$htmltable = html_writer::table($table);
return $htmlnew . $htmlpagingbar . $htmltable . $htmlpagingbar;
}
示例2: set_data
/**
* Load in existing data as form defaults
*
* @param stdClass|array $default_values object or array of default values
*/
public function set_data($badge)
{
$default_values = array();
parent::set_data($badge);
if (!empty($badge->expiredate)) {
$default_values['expiry'] = 1;
$default_values['expiredate'] = $badge->expiredate;
} else {
if (!empty($badge->expireperiod)) {
$default_values['expiry'] = 2;
$default_values['expireperiod'] = $badge->expireperiod;
}
}
$default_values['currentimage'] = print_badge_image($badge, $badge->get_context(), 'large');
parent::set_data($default_values);
}
示例3: require_login
require_login($badge->courseid);
$navurl = new moodle_url('/badges/index.php', array('type' => $badge->type, 'id' => $badge->courseid));
$PAGE->set_pagelayout('standard');
navigation_node::override_active_url($navurl);
} else {
$PAGE->set_pagelayout('admin');
navigation_node::override_active_url($navurl, true);
}
$PAGE->set_context($context);
$PAGE->set_url('/badges/recipients.php', array('id' => $badgeid, 'sort' => $sortby, 'dir' => $sorthow));
$PAGE->set_heading($badge->name);
$PAGE->set_title($badge->name);
$PAGE->navbar->add($badge->name);
$output = $PAGE->get_renderer('core', 'badges');
echo $output->header();
echo $OUTPUT->heading(print_badge_image($badge, $context, 'small') . ' ' . $badge->name);
echo $output->print_badge_status_box($badge);
$output->print_badge_tabs($badgeid, $context, 'awards');
// Add button for badge manual award.
if ($badge->has_manual_award_criteria() && has_capability('moodle/badges:awardbadge', $context) && $badge->is_active()) {
$url = new moodle_url('/badges/award.php', array('id' => $badge->id));
echo $OUTPUT->box($OUTPUT->single_button($url, get_string('award', 'badges')), 'clearfix mdl-align');
}
$namefields = get_all_user_name_fields(true, 'u');
$sql = "SELECT b.userid, b.dateissued, b.uniquehash, {$namefields}\n FROM {badge_issued} b INNER JOIN {user} u\n ON b.userid = u.id\n WHERE b.badgeid = :badgeid AND u.deleted = 0\n ORDER BY {$sortby} {$sorthow}";
$totalcount = $DB->count_records('badge_issued', array('badgeid' => $badge->id));
if ($badge->has_awards()) {
$users = $DB->get_records_sql($sql, array('badgeid' => $badge->id), $page * BADGE_PERPAGE, BADGE_PERPAGE);
$recipients = new badge_recipients($users);
$recipients->sort = $sortby;
$recipients->dir = $sorthow;
示例4: print_badge_overview
/**
* Print badge overview.
*
* No functional changes, but this override is required due to incorrect use
* of the self:: scope (as opposed to static:: or $this->) in core.
*
* @param \badge $badge
* @param \context $context
*/
public function print_badge_overview($badge, $context)
{
$detailstable = new html_table();
$detailstable->attributes = array('class' => 'clearfix', 'id' => 'badgedetails');
$detailstable->data[] = array(get_string('name') . ":", $badge->name);
$detailstable->data[] = array(get_string('description', 'badges') . ":", $badge->description);
$detailstable->data[] = array(get_string('createdon', 'search') . ":", userdate($badge->timecreated));
$detailstable->data[] = array(get_string('badgeimage', 'badges') . ":", print_badge_image($badge, $context, 'large'));
$issuertable = new html_table();
$issuertable->attributes = array('class' => 'clearfix', 'id' => 'badgeissuer');
$issuertable->data[] = array(get_string('issuername', 'badges') . ":", $badge->issuername);
$issuertable->data[] = array(get_string('contact', 'badges') . ":", html_writer::tag('a', $badge->issuercontact, array('href' => 'mailto:' . $badge->issuercontact)));
$expiry = '';
if ($badge->can_expire()) {
if ($badge->expiredate) {
$expiry .= get_string('expiredate', 'badges', userdate($badge->expiredate));
} else {
if ($badge->expireperiod) {
if ($badge->expireperiod < 60) {
$expiry .= get_string('expireperiods', 'badges', round($badge->expireperiod, 2));
} else {
if ($badge->expireperiod < 60 * 60) {
$expiry .= get_string('expireperiodm', 'badges', round($badge->expireperiod / 60, 2));
} else {
if ($badge->expireperiod < 60 * 60 * 24) {
$expiry .= get_string('expireperiodh', 'badges', round($badge->expireperiod / 60 / 60, 2));
} else {
$expiry .= get_string('expireperiod', 'badges', round($badge->expireperiod / 60 / 60 / 24, 2));
}
}
}
}
}
} else {
$expiry .= get_string('noexpiry', 'badges');
}
$criteria = '';
if ($badge->has_criteria()) {
$criteria .= $this->print_badge_criteria($badge);
} else {
$criteria .= get_string('nocriteria', 'badges');
if (has_capability('moodle/badges:configurecriteria', $context)) {
$criteria .= $this->output->single_button(new moodle_url('/badges/criteria.php', array('id' => $badge->id)), get_string('addcriteria', 'badges'), 'POST', array('class' => 'activatebadge'));
}
}
$awards = '';
if (has_capability('moodle/badges:viewawarded', $context)) {
$awards .= html_writer::start_tag('fieldset', array('class' => 'generalbox'));
$awards .= html_writer::tag('legend', get_string('awards', 'badges'), array('class' => 'bold'));
if ($badge->has_awards()) {
$url = new moodle_url('/badges/recipients.php', array('id' => $badge->id));
$a = new stdClass();
$a->link = $url->out();
$a->count = count($badge->get_awards());
$awards .= get_string('numawards', 'badges', $a);
} else {
$awards .= get_string('noawards', 'badges');
}
if (has_capability('moodle/badges:awardbadge', $context) && $badge->has_manual_award_criteria() && $badge->is_active()) {
$awards .= $this->output->single_button(new moodle_url('/badges/award.php', array('id' => $badge->id)), get_string('award', 'badges'), 'POST', array('class' => 'activatebadge'));
}
$awards .= html_writer::end_tag('fieldset');
}
return html_writer::start_tag('fieldset', array('class' => 'generalbox')) . html_writer::tag('legend', get_string('badgedetails', 'badges'), array('class' => 'bold')) . html_writer::table($detailstable) . html_writer::end_tag('fieldset') . html_writer::start_tag('fieldset', array('class' => 'generalbox')) . html_writer::tag('legend', get_string('issuerdetails', 'badges'), array('class' => 'bold')) . html_writer::table($issuertable) . html_writer::end_tag('fieldset') . html_writer::start_tag('fieldset', array('class' => 'generalbox')) . html_writer::tag('legend', get_string('issuancedetails', 'badges'), array('class' => 'bold')) . $expiry . html_writer::end_tag('fieldset') . html_writer::start_tag('fieldset', array('class' => 'generalbox')) . html_writer::tag('legend', get_string('bcriteria', 'badges'), array('class' => 'bold')) . $criteria . html_writer::end_tag('fieldset') . $awards;
}