本文整理汇总了PHP中single_button::add_action方法的典型用法代码示例。如果您正苦于以下问题:PHP single_button::add_action方法的具体用法?PHP single_button::add_action怎么用?PHP single_button::add_action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类single_button
的用法示例。
在下文中一共展示了single_button::add_action方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: close_window_button
/**
* Returns HTML to display a simple button to close a window
*
* @param string $text The lang string for the button's label (already output from get_string())
* @return string html fragment
*/
public function close_window_button($text='') {
if (empty($text)) {
$text = get_string('closewindow');
}
$button = new single_button(new moodle_url('#'), $text, 'get');
$button->add_action(new component_action('click', 'close_window'));
return $this->container($this->render($button), 'closewindow');
}
示例2: review_link
/**
* Output either a link to the review page for an attempt, or a button to
* open the review in a popup window.
*
* @param moodle_url $url of the target page.
* @param bool $reviewinpopup whether a pop-up is required.
* @param array $popupoptions options to pass to the popup_action constructor.
* @return string HTML to output.
*/
public function review_link($url, $reviewinpopup, $popupoptions) {
if ($reviewinpopup) {
$button = new single_button($url, get_string('review', 'quiz'));
$button->add_action(new popup_action('click', $url, 'quizpopup', $popupoptions));
return $this->render($button);
} else {
return html_writer::link($url, get_string('review', 'quiz'),
array('title' => get_string('reviewthisattempt', 'quiz')));
}
}
示例3: print_start_attempt_button
public function print_start_attempt_button($canpreview, $buttontext, $unfinished)
{
global $OUTPUT;
$url = $this->_readerobj->start_attempt_url();
$button = new single_button($url, $buttontext);
$button->class .= ' quizstartbuttondiv';
if (!$unfinished) {
$strconfirmstartattempt = $this->confirm_start_attempt_message();
if ($strconfirmstartattempt) {
$button->add_action(new confirm_action($strconfirmstartattempt, null, get_string('startattempt', 'quiz')));
}
}
$warning = '';
if ($this->securewindow_required($canpreview)) {
$button->class .= ' quizsecuremoderequired';
$button->add_action(new popup_action('click', $url, 'quizpopup', securewindow_access_rule::$popupoptions));
$warning = html_writer::tag('noscript', $OUTPUT->heading(get_string('noscript', 'quiz')));
}
return $OUTPUT->render($button) . $warning;
}
示例4: notice
// Get previous cert record
if (!($certrecord = $DB->get_record('iomadcertificate_issues', array('userid' => $USER->id, 'iomadcertificateid' => $iomadcertificate->id)))) {
notice(get_string('noiomadcertificatesissued', 'iomadcertificate'), "{$CFG->wwwroot}/course/view.php?id={$course->id}");
die;
}
// Load the specific iomadcertificatetype
require "{$CFG->dirroot}/mod/iomadcertificate/type/{$iomadcertificate->iomadcertificatetype}/iomadcertificate.php";
if ($action) {
// Remove full-stop at the end if it exists, to avoid "..pdf" being created and being filtered by clean_filename
$certname = rtrim($iomadcertificate->name, '.');
$filename = clean_filename("{$certname}.pdf");
$pdf->Output($filename, 'I');
// open in browser
exit;
}
echo $OUTPUT->header();
if (has_capability('mod/iomadcertificate:manage', $context)) {
$numusers = count(iomadcertificate_get_issues($iomadcertificate->id, 'ci.timecreated ASC', '', $cm));
$url = html_writer::tag('a', get_string('viewiomadcertificateviews', 'iomadcertificate', $numusers), array('href' => $CFG->wwwroot . '/mod/iomadcertificate/report.php?id=' . $cm->id));
echo html_writer::tag('div', $url, array('class' => 'reportlink'));
}
if (!empty($iomadcertificate->intro)) {
echo $OUTPUT->box(format_module_intro('iomadcertificate', $iomadcertificate, $cm->id), 'generalbox', 'intro');
}
echo html_writer::tag('p', get_string('viewed', 'iomadcertificate') . '<br />' . userdate($certrecord->timecreated), array('style' => 'text-align:center'));
$link = new moodle_url('/mod/iomadcertificate/review.php?id=' . $cm->id . '&action=get');
$linkname = get_string('reviewiomadcertificate', 'iomadcertificate');
$button = new single_button($link, $linkname);
$button->add_action(new popup_action('click', $link, array('height' => 600, 'width' => 800)));
echo html_writer::tag('div', $OUTPUT->render($button), array('style' => 'text-align:center'));
echo $OUTPUT->footer($course);
示例5: modify_allocation_group
/**
* Output the ratingallocate modfify allocation
*/
public function modify_allocation_group($ratingallocateid, $coursemoduleid, $status, $algorithmstatus, $runalgorithmbycron)
{
global $PAGE;
$output = '';
$output .= $this->heading(get_string('modify_allocation_group', ratingallocate_MOD_NAME), 2);
$output .= $this->box_start();
// The instance is called ready if it is in one of the two following status.
$isready = $status === ratingallocate::DISTRIBUTION_STATUS_READY || $status === ratingallocate::DISTRIBUTION_STATUS_READY_ALLOC_STARTED;
//The algorithm may not run manually if the algorithm is currently running or if it is not started and should be started using the cron.
$algorithmmayrun = !($algorithmstatus === \mod_ratingallocate\algorithm_status::running || $algorithmstatus === \mod_ratingallocate\algorithm_status::notstarted && $runalgorithmbycron);
$starturl = new moodle_url($PAGE->url, array('action' => ACTION_START_DISTRIBUTION));
// Get description dependent on status
$descriptionbaseid = 'modify_allocation_group_desc_';
$description = get_string($descriptionbaseid . $status, ratingallocate_MOD_NAME);
$output .= $this->format_text($description);
$output .= html_writer::empty_tag('br', array());
$button = new single_button($starturl, get_string('start_distribution', ratingallocate_MOD_NAME), 'get');
// Enable only if the instance is ready and the algorithm may run manually
$button->disabled = !$isready;
//&& $algorithmmayrun);
$button->tooltip = get_string('start_distribution_explanation', ratingallocate_MOD_NAME);
$button->add_action(new confirm_action(get_string('confirm_start_distribution', ratingallocate_MOD_NAME)));
$output .= $this->render($button);
$output .= $this->single_button(new moodle_url('/mod/ratingallocate/view.php', array('id' => $coursemoduleid, 'ratingallocateid' => $ratingallocateid, 'action' => ACTION_MANUAL_ALLOCATION)), get_string('manual_allocation_form', ratingallocate_MOD_NAME), 'get', array('disabled' => !$isready));
$output .= $this->box_end();
return $output;
}
示例6: view_default
public function view_default(moodle_url $url, $canmanage)
{
global $CFG, $OUTPUT, $USER;
if (!$url->get_param('action')) {
echo $OUTPUT->header();
if ($canmanage) {
$this->show_tabs($url);
}
// Check if the user can view the certificate
if (!$canmanage && ($msg = $this->can_issue($USER))) {
notice($msg, $CFG->wwwroot . '/course/view.php?id=' . $this->get_course()->id, $this->get_course());
die;
}
if (!empty($this->get_instance()->intro)) {
echo $OUTPUT->box(format_module_intro('simplecertificate', $this->get_instance(), $this->coursemodule->id), 'generalbox', 'intro');
}
if ($attempts = $this->get_attempts()) {
echo $this->print_attempts($attempts);
}
if (!$canmanage) {
$this->add_to_log('view');
}
if ($this->get_instance()->delivery != 3 || $canmanage) {
// Create new certificate record, or return existing record
$certrecord = $this->get_issue();
switch ($this->get_instance()->delivery) {
case self::OUTPUT_FORCE_DOWNLOAD:
$str = get_string('opendownload', 'simplecertificate');
break;
case self::OUTPUT_SEND_EMAIL:
$str = get_string('openemail', 'simplecertificate');
break;
default:
$str = get_string('openwindow', 'simplecertificate');
break;
}
echo html_writer::tag('p', $str, array('style' => 'text-align:center'));
$linkname = get_string('getcertificate', 'simplecertificate');
$link = new moodle_url('/mod/simplecertificate/view.php', array('id' => $this->coursemodule->id, 'action' => 'get'));
$button = new single_button($link, $linkname);
$button->add_action(new popup_action('click', $link, 'view' . $this->coursemodule->id, array('height' => 600, 'width' => 800)));
echo html_writer::tag('div', $OUTPUT->render($button), array('style' => 'text-align:center'));
}
echo $OUTPUT->footer();
} else {
// Output to pdf
if ($this->get_instance()->delivery != 3 || $canmanage) {
$this->output_pdf($this->get_issue($USER));
}
}
}
示例7: array
// Export button
if ($canexport) {
if ($exporturl === '') {
echo $OUTPUT->single_button(new moodle_url('/mod/groupselect/view.php', array('id' => $cm->id, 'export' => true)), get_string('export', 'mod_groupselect'));
} else {
echo '<div class="export_url" >';
echo $OUTPUT->action_link($exporturl, get_string('export_download', 'mod_groupselect'));
echo '</div> <br>';
}
}
// Assign button
if ($canassign and count($groups) > 0) {
$action = new confirm_action(get_string('assigngroup_confirm', 'mod_groupselect'), 'openpopup');
$action->jsfunctionargs['callbackargs'] = array(null, array('url' => new moodle_url('/mod/groupselect/view.php', array('id' => $cm->id, 'assign' => true))));
$button = new single_button(new moodle_url('/mod/groupselect/view.php', array('id' => $cm->id, 'assign' => true)), get_string('assigngroup', 'mod_groupselect'));
$button->add_action($action);
echo $OUTPUT->render($button);
}
if (empty($groups)) {
echo $OUTPUT->notification(get_string('nogroups', 'mod_groupselect'));
} else {
if ($problems) {
foreach ($problems as $problem) {
echo $OUTPUT->notification($problem, 'notifyproblem');
}
}
$data = array();
$actionpresent = false;
$assigned_relation = $DB->get_records_sql("SELECT g.id AS rid, g.teacherid AS id, g.groupid\n \t\t\t\t\t\t\t\t\t\t\tFROM {groupselect_groups_teachers} g\n \t\t\t\t\t\t\t\t\t \tWHERE g.instance_id = ?", array('instance_id' => $id));
$assigned_teacher_ids = array();
foreach ($assigned_relation as $r) {
示例8: make_review_link
/**
* Make a link to the review page for an attempt.
*
* @param string $linktext the desired link text.
* @param int $attemptid the attempt id.
* @return string HTML for the link.
*/
public function make_review_link($linktext, $attemptid) {
global $OUTPUT;
$url = $this->_quizobj->review_url($attemptid);
$button = new single_button($url, $linktext);
$button->add_action(new popup_action('click', $url, 'quizpopup', self::$popupoptions));
return $OUTPUT->render($button);
}
示例9: summary_page_controls
/**
* Creates any controls a the page should have.
*
* @param quiz_attempt $attemptobj
*/
public function summary_page_controls($attemptobj) {
$output = '';
// countdown timer
$output .= $this->countdown_timer();
// Finish attempt button.
$options = array(
'attempt' => $attemptobj->get_attemptid(),
'finishattempt' => 1,
'timeup' => 0,
'slots' => '',
'sesskey' => sesskey(),
);
$button = new single_button(
new moodle_url($attemptobj->processattempt_url(), $options),
get_string('submitallandfinish', 'quiz'));
$button->id = 'responseform';
$button->add_action(new confirm_action(get_string('confirmclose', 'quiz'), null,
get_string('submitallandfinish', 'quiz')));
$output .= $this->container($this->container($this->render($button),
'controls'), 'submitbtns mdl-align');
return $output;
}
示例10: array
$user_total++;
}
}
}
$prozent = 100 / $total * $user_total;
//echo 'total: '.$total.', '.$USER->username.': '.$user_total.', %: '.$prozent;
if ($prozent >= $min_prozent) {
// zertifikat anzeigen
$module_context = context_module::instance($cert_cm->id);
require_capability('mod/simplecertificate:view', $module_context);
$url = new moodle_url('/mod/simplecertificate/view.php', array('id' => $cert_cm->id, 'tab' => 0, 'page' => 0, 'perpage' => 30));
$canmanage = 0;
//has_capability('mod/simplecertificate:manage', $module_context);
$link = new moodle_url('/mod/simplecertificate/view.php', array('id' => $cert_cm->id, 'action' => 'get'));
$button = new single_button($link, get_string('certificate', 'block_oc_mooc_nav'));
$button->add_action(new popup_action('click', $link, 'view' . $cert_cm->id, array('height' => 600, 'width' => 800)));
echo html_writer::tag('h2', html_writer::tag('div', get_string('certificate', 'block_oc_mooc_nav'), array('class' => 'oc_badges_text')));
echo html_writer::tag('div', get_string('cert_descr', 'block_oc_mooc_nav', $min_prozent));
echo html_writer::tag('div', $OUTPUT->render($button), array('style' => 'text-align:left'));
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
echo html_writer::tag('h2', html_writer::tag('div', get_string('course_badges', 'block_oc_mooc_nav'), array('class' => 'oc_badges_text')));
echo html_writer::tag('div', get_string('badge_overview_description', 'block_oc_mooc_nav'));
echo '<br />';
echo '<div>' . html_writer::link(new moodle_url('/user/profile.php', array('id' => $USER->id)), get_string('profile_badges', 'block_oc_mooc_nav')) . '<br />';
echo html_writer::link(new moodle_url('/badges/mybackpack.php'), get_string('badge_options', 'block_oc_mooc_nav')) . '</div><br />';
// Eigene, in diesem Kurs erworbene Badges
$out = html_writer::tag('div', get_string('overview', 'block_oc_mooc_nav'), array('class' => 'oc_badges_text'));
echo html_writer::tag('h2', $out);
ob_start();
示例11: array
$table->class = 'generaltable';
$table->head = array(get_string('issued', 'customcert'));
$table->align = array('left');
$table->attributes = array('style' => 'width:20%; margin:auto');
foreach ($issues as $issue) {
$row = array();
$row[] = userdate($issue->timecreated);
$table->data[$issue->id] = $row;
}
$issuelist = $header . html_writer::table($table) . "<br />";
}
// Create the button to download the customcert.
$linkname = get_string('getcustomcert', 'customcert');
$link = new moodle_url('/mod/customcert/view.php', array('id' => $cm->id, 'action' => 'download'));
$downloadbutton = new single_button($link, $linkname);
$downloadbutton->add_action(new popup_action('click', $link, 'customcertpopup', array('height' => 600, 'width' => 800)));
$downloadbutton = html_writer::tag('div', $OUTPUT->render($downloadbutton), array('style' => 'text-align:center'));
// Output all the page data.
echo $OUTPUT->header();
groups_print_activity_menu($cm, $pageurl);
echo $reportlink;
echo $intro;
echo $issuelist;
echo $downloadbutton;
echo $OUTPUT->footer($course);
exit;
} else {
// Output to pdf
// Create new customcert issue record if one does not already exist.
if (!$DB->record_exists('customcert_issues', array('userid' => $USER->id, 'customcertid' => $customcert->id))) {
$customcertissue = new stdClass();