本文整理汇总了PHP中html_writer::checkbox方法的典型用法代码示例。如果您正苦于以下问题:PHP html_writer::checkbox方法的具体用法?PHP html_writer::checkbox怎么用?PHP html_writer::checkbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类html_writer
的用法示例。
在下文中一共展示了html_writer::checkbox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scorm_print_launch
/**
* Displays the entry form and toc if required.
*
* @param stdClass $user user object
* @param stdClass $scorm scorm object
* @param string $action base URL for the organizations select box
* @param stdClass $cm course module object
*/
function scorm_print_launch ($user, $scorm, $action, $cm) {
global $CFG, $DB, $PAGE, $OUTPUT, $COURSE;
if ($scorm->updatefreq == SCORM_UPDATE_EVERYTIME) {
scorm_parse($scorm, false);
}
$organization = optional_param('organization', '', PARAM_INT);
if ($scorm->displaycoursestructure == 1) {
echo $OUTPUT->box_start('generalbox boxaligncenter toc', 'toc');
echo html_writer::div(get_string('contents', 'scorm'), 'structurehead');
}
if (empty($organization)) {
$organization = $scorm->launch;
}
if ($orgs = $DB->get_records_select_menu('scorm_scoes', 'scorm = ? AND '.
$DB->sql_isempty('scorm_scoes', 'launch', false, true).' AND '.
$DB->sql_isempty('scorm_scoes', 'organization', false, false),
array($scorm->id), 'sortorder, id', 'id,title')) {
if (count($orgs) > 1) {
$select = new single_select(new moodle_url($action), 'organization', $orgs, $organization, null);
$select->label = get_string('organizations', 'scorm');
$select->class = 'scorm-center';
echo $OUTPUT->render($select);
}
}
$orgidentifier = '';
if ($sco = scorm_get_sco($organization, SCO_ONLY)) {
if (($sco->organization == '') && ($sco->launch == '')) {
$orgidentifier = $sco->identifier;
} else {
$orgidentifier = $sco->organization;
}
}
$scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe.
if (!file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php')) {
$scorm->version = 'scorm_12';
}
require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php');
$result = scorm_get_toc($user, $scorm, $cm->id, TOCFULLURL, $orgidentifier);
$incomplete = $result->incomplete;
// Do we want the TOC to be displayed?
if ($scorm->displaycoursestructure == 1) {
echo $result->toc;
echo $OUTPUT->box_end();
}
// Is this the first attempt ?
$attemptcount = scorm_get_attempt_count($user->id, $scorm);
// Do not give the player launch FORM if the SCORM object is locked after the final attempt.
if ($scorm->lastattemptlock == 0 || $result->attemptleft > 0) {
echo html_writer::start_div('scorm-center');
echo html_writer::start_tag('form', array('id' => 'scormviewform',
'method' => 'post',
'action' => $CFG->wwwroot.'/mod/scorm/player.php'));
if ($scorm->hidebrowse == 0) {
print_string('mode', 'scorm');
echo ': '.html_writer::empty_tag('input', array('type' => 'radio', 'id' => 'b', 'name' => 'mode', 'value' => 'browse')).
html_writer::label(get_string('browse', 'scorm'), 'b');
echo html_writer::empty_tag('input', array('type' => 'radio',
'id' => 'n', 'name' => 'mode',
'value' => 'normal', 'checked' => 'checked')).
html_writer::label(get_string('normal', 'scorm'), 'n');
} else {
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'mode', 'value' => 'normal'));
}
if ($scorm->forcenewattempt == 1) {
if ($incomplete === false) {
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'newattempt', 'value' => 'on'));
}
} else if (!empty($attemptcount) && ($incomplete === false) && (($result->attemptleft > 0)||($scorm->maxattempt == 0))) {
echo html_writer::empty_tag('br');
echo html_writer::checkbox('newattempt', 'on', false, '', array('id' => 'a'));
echo html_writer::label(get_string('newattempt', 'scorm'), 'a');
}
if (!empty($scorm->popup)) {
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'display', 'value' => 'popup'));
}
echo html_writer::empty_tag('br');
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'scoid', 'value' => $scorm->launch));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'cm', 'value' => $cm->id));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'currentorg', 'value' => $orgidentifier));
echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('enter', 'scorm')));
echo html_writer::end_tag('form');
echo html_writer::end_div();
//.........这里部分代码省略.........
示例2: display_search_field
function display_search_field($value = '')
{
global $CFG, $DB;
if (is_array($value)) {
$content = $value['checked'];
$allrequired = $value['allrequired'] ? true : false;
} else {
$content = array();
$allrequired = false;
}
$str = '';
$found = false;
foreach (explode("\n", $this->field->param1) as $checkbox) {
$checkbox = trim($checkbox);
if (in_array($checkbox, $content)) {
$str .= html_writer::checkbox('f_' . $this->field->id . '[]', s($checkbox), true, $checkbox);
} else {
$str .= html_writer::checkbox('f_' . $this->field->id . '[]', s($checkbox), false, $checkbox);
}
$found = true;
}
if (!$found) {
return '';
}
$str .= html_writer::checkbox('f_' . $this->field->id . '_allreq', null, $allrequired, get_string('selectedrequired', 'data'));
return $str;
}
示例3: display_options_adv
/**
* Print HTML to display the "Also show old questions" checkbox
*/
public function display_options_adv()
{
echo \html_writer::start_div();
echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'showhidden', 'value' => '0', 'id' => 'showhidden_off'));
echo \html_writer::checkbox('showhidden', '1', !$this->hide, get_string('showhidden', 'question'), array('id' => 'showhidden_on', 'class' => 'searchoptions'));
echo \html_writer::end_div() . "\n";
}
示例4: destination_courses_selector
public function destination_courses_selector(moodle_url $nextstageurl, destination_courses_search $courses = null, $courseid)
{
$html = html_writer::start_tag('div', array('class' => 'import-course-selector backup-restore'));
$html .= html_writer::start_tag('form', array('method' => 'post', 'action' => $nextstageurl->out_omit_querystring()));
foreach ($nextstageurl->params() as $key => $value) {
$html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
}
$html .= html_writer::start_tag('div', array('class' => 'ics-existing-group backup-section'));
$html .= $this->output->heading(get_string('selectgroups', 'local_syncgroups'), 2, array('class' => 'header'));
$html .= html_writer::start_tag('ul');
$groups = groups_get_all_groups($courseid, 0, 0, 'g.id, g.name');
foreach ($groups as $group) {
$html .= html_writer::start_tag('li') . html_writer::checkbox('groups[]', $group->id, false, $group->name) . html_writer::end_tag('li');
}
$html .= html_writer::end_tag('ul');
$html .= html_writer::end_tag('div');
// We only allow import adding for now. Enforce it here.
$html .= html_writer::start_tag('div', array('class' => 'ics-existing-course backup-section'));
$html .= $this->output->heading(get_string('syncgroupsto', 'local_syncgroups'), 2, array('class' => 'header'));
$html .= $this->backup_detail_pair(get_string('selectacourse', 'backup'), $this->render($courses));
$html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('continue'))));
$html .= html_writer::end_tag('div');
$html .= html_writer::end_tag('form');
$html .= html_writer::end_tag('div');
return $html;
}
示例5: display_search_field
function display_search_field($value = 0)
{
$selectors = html_writer::select_time('days', 'f_' . $this->field->id . '_d', $value['timestamp']) . html_writer::select_time('months', 'f_' . $this->field->id . '_m', $value['timestamp']) . html_writer::select_time('years', 'f_' . $this->field->id . '_y', $value['timestamp']);
$datecheck = html_writer::checkbox('f_' . $this->field->id . '_z', 1, $value['usedate']);
$str = $selectors . ' ' . $datecheck . ' ' . get_string('usedate', 'data');
return $str;
}
示例6: block_poll_get_response_checks
function block_poll_get_response_checks($options, $selected)
{
foreach ($options as $option) {
$arr[] = html_writer::checkbox('', '', $option->id == $selected, '', array('onclick' => 'this.checked=' . ($option->id == $selected ? 'true' : 'false')));
}
return $arr;
}
示例7: _print_checkbox
/** Display an standard html checkbox with an optional label
* NOTE: this version is from Moodle 1.9x it *SUPPORTS* script tags for onclick
* (unlike the version in /lib/deprecatedlib.php)
*
* @param string $name The name of the checkbox
* @param string $value The valus that the checkbox will pass when checked
* @param boolean $checked The flag to tell the checkbox initial state
* @param string $label The label to be showed near the checkbox
* @param string $alt The info to be inserted in the alt tag
*/
function _print_checkbox($name, $value, $checked = true, $label = '', $alt = '', $script = '', $return = false)
{
if (defined('USE_OLD_CHECKBOX')) {
static $idcounter = 0;
if (!$name) {
$name = 'unnamed';
}
if ($alt) {
$alt = strip_tags($alt);
} else {
$alt = 'checkbox';
}
if ($checked) {
$strchecked = ' checked="checked"';
} else {
$strchecked = '';
}
$htmlid = 'auto-cb' . sprintf('%04d', ++$idcounter);
$output = '<span class="checkbox ' . $name . "\">";
$output .= '<input name="' . $name . '" id="' . $htmlid . '" type="checkbox" value="' . $value . '" alt="' . $alt . '"' . $strchecked . ' ' . (!empty($script) ? ' onclick="' . $script . '" ' : '') . ' />';
if (!empty($label)) {
$output .= ' <label for="' . $htmlid . '">' . $label . '</label>';
}
$output .= '</span>' . "\n";
if (empty($return)) {
echo $output;
} else {
return $output;
}
} else {
$output = html_writer::checkbox($name, $value, $checked, $label, empty($script) ? null : array('onclick' => $script));
if (empty($return)) {
echo $output;
} else {
return $output;
}
}
}
示例8: get_string
$createassigncheckbox = html_writer::checkbox('create_assign', 1, false, get_string('createmoodleassignments', 'turnitintooltwo'), array("class" => "create_assignment_checkbox"));
$createassign = html_writer::tag('div', $createassigncheckbox, array("class" => "create_assign_checkbox_container"));
$createbutton = html_writer::tag('button', get_string('createmoodlecourses', 'turnitintooltwo'), array("id" => "create_classes_button"));
$output .= $OUTPUT->box($categoryselectlabel . " " . $categoryselect . $createassign . $createbutton, 'create_checkboxes navbar');
$table = new html_table();
$table->id = "courseBrowserTable";
$rows = array();
// Make up json array for drop down in table.
$integrationidsjson = array();
foreach ($tiiintegrationids as $k => $v) {
$integrationidsjson[] = array('value' => $k, 'label' => $v);
}
$output .= html_writer::script('var integration_ids = ' . json_encode($integrationidsjson));
// Do the table headers.
$cells = array();
$cells[0] = new html_table_cell(html_writer::checkbox('selectallcb', 1, false));
$cells[1] = new html_table_cell(get_string('coursetitle', 'turnitintooltwo'));
$cells[2] = new html_table_cell(get_string('integration', 'turnitintooltwo'));
$cells[3] = new html_table_cell(get_string('ced', 'turnitintooltwo'));
$cells[4] = new html_table_cell(get_string('turnitinid', 'turnitintooltwo'));
$cells[5] = new html_table_cell(get_string('moodlelinked', 'turnitintooltwo'));
$cells[6] = new html_table_cell(' ');
$table->head = $cells;
$output .= $OUTPUT->box(html_writer::table($table), '');
$output .= turnitintooltwo_show_edit_course_end_date_form();
break;
case "multiple_class_recreation":
if (!confirm_sesskey()) {
throw new moodle_exception('invalidsesskey', 'error');
}
$PAGE->set_pagelayout('embedded');
示例9: get_string
}
$formheader = get_string('retest', 'tool_unittest');
} else {
$displaypath = '';
echo $OUTPUT->header();
$formheader = get_string('rununittests', 'tool_unittest');
}
// Print the form for adjusting options.
echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter');
echo $OUTPUT->heading($formheader);
echo '<form method="get" action="index.php">';
echo '<fieldset class="invisiblefieldset">';
echo '<p>' . html_writer::checkbox('showpasses', 1, $showpasses, get_string('showpasses', 'tool_unittest')) . '</p>';
echo '<p>' . html_writer::checkbox('showsearch', 1, $showsearch, get_string('showsearch', 'tool_unittest')) . '</p>';
if (moodle_coverage_recorder::can_run_codecoverage()) {
echo '<p>' . html_writer::checkbox('codecoverage', 1, $codecoverage, get_string('codecoverageanalysis', 'tool_unittest')) . '</p>';
} else {
echo '<p>';
print_string('codecoveragedisabled', 'tool_unittest');
echo '<input type="hidden" name="codecoverage" value="0" /></p>';
}
echo '<p>';
echo '<label for="path">', get_string('onlytest', 'tool_unittest'), '</label> ';
echo '<input type="text" id="path" name="path" value="', $displaypath, '" size="40" />';
echo '</p>';
echo '<input type="submit" value="' . get_string('runtests', 'tool_unittest') . '" />';
echo '</fieldset>';
echo '</form>';
echo $OUTPUT->box_end();
$otherpages = array();
$otherpages['PDF lib test'] = new moodle_url('/admin/tool/unittest/other/pdflibtestpage.php');
示例10: config_form
//.........这里部分代码省略.........
if (!isset($config->oauth2displaybuttons)) {
$config->oauth2displaybuttons = 1;
}
// IPinfoDB.
echo '<tr>
<td align="right"><label for="googleipinfodbkey">';
print_string('auth_googleipinfodbkey_key', 'auth_googleoauth2');
echo '</label></td><td>';
echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'googleipinfodbkey', 'name' => 'googleipinfodbkey', 'class' => 'googleipinfodbkey', 'value' => $config->googleipinfodbkey));
if (isset($err["googleipinfodbkey"])) {
echo $OUTPUT->error_text($err["googleipinfodbkey"]);
}
echo '</td><td>';
print_string('auth_googleipinfodbkey', 'auth_googleoauth2', (object) array('website' => $CFG->wwwroot));
echo '</td></tr>';
// User prefix.
echo '<tr>
<td align="right"><label for="googleuserprefix">';
print_string('auth_googleuserprefix_key', 'auth_googleoauth2');
echo '</label></td><td>';
echo html_writer::empty_tag('input', array('type' => 'text', 'id' => 'googleuserprefix', 'name' => 'googleuserprefix', 'class' => 'googleuserprefix', 'value' => $config->googleuserprefix));
if (isset($err["googleuserprefix"])) {
echo $OUTPUT->error_text($err["googleuserprefix"]);
}
echo '</td><td>';
print_string('auth_googleuserprefix', 'auth_googleoauth2');
echo '</td></tr>';
// Display buttons.
echo '<tr>
<td align="right"><label for="oauth2displaybuttons">';
print_string('oauth2displaybuttons', 'auth_googleoauth2');
echo '</label></td><td>';
$checked = empty($config->oauth2displaybuttons) ? '' : 'checked';
echo html_writer::checkbox('oauth2displaybuttons', 1, $checked, '', array('type' => 'checkbox', 'id' => 'oauth2displaybuttons', 'class' => 'oauth2displaybuttons'));
if (isset($err["oauth2displaybuttons"])) {
echo $OUTPUT->error_text($err["oauth2displaybuttons"]);
}
echo '</td><td>';
$code = '<code><?php require_once($CFG->dirroot . \'/auth/googleoauth2/lib.php\');
auth_googleoauth2_display_buttons(); ?></code>';
print_string('oauth2displaybuttonshelp', 'auth_googleoauth2', $code);
echo '</td></tr>';
// Block field options.
// Hidden email options - email must be set to: locked.
echo html_writer::empty_tag('input', array('type' => 'hidden', 'value' => 'locked', 'name' => 'lockconfig_field_lock_email'));
// Display other field options.
foreach ($userfields as $key => $userfield) {
if ($userfield == 'email') {
unset($userfields[$key]);
}
}
print_auth_lock_options('googleoauth2', $userfields, get_string('auth_fieldlocks_help', 'auth'), false, false);
echo '</table>';
// Calculate how many login per providers.
$providerstats = (object) $this->get_stats();
$strothermoodle = get_string('othermoodle', 'auth_googleoauth2');
$strstattitle = get_string('stattitle', 'auth_googleoauth2', $providerstats);
echo '
<center>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
示例11: authorize_print_action_button
function authorize_print_action_button($orderid, $do, $suborderid = 0, $confirm = false, $unenrol = false, $nobutton = false, $extrahtml = '')
{
global $CFG, $OUTPUT;
global $authstrs;
$ret = '<form action="' . $CFG->wwwroot . '/enrol/authorize/index.php' . '" method="post"><div>' . '<input type="hidden" name="order" value="' . $orderid . '" />' . '<input type="hidden" name="do" value="' . $do . '" />' . '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
if (!empty($suborderid)) {
$ret .= '<input type="hidden" name="suborder" value="' . $suborderid . '" />';
}
if (!empty($confirm)) {
$ret .= '<input type="hidden" name="confirm" value="1" />';
}
if (!empty($unenrol)) {
$ret .= html_writer::checkbox('unenrol', 1, false, $unenrol) . '<br />';
}
$ret .= $extrahtml;
$ret .= '<input type="submit" value="' . $authstrs->{$do} . '" />' . '</div></form>';
if (!empty($nobutton)) {
$ret .= '<form method="get" action="index.php"><div><input type="hidden" name="order" value="' . $orderid . '" /><input type="submit" value="' . $nobutton . '" /></div></form>';
}
return $ret;
}
示例12: turnitintooltwo_getusers
/**
* Get users for unlinking/relinking. Called from ajax.php via turnitintooltwo.js.
*
* @global type $DB
* @return array return array of users to display
*/
function turnitintooltwo_getusers()
{
global $DB;
$config = turnitintooltwo_admin_config();
$return = array();
$idisplaystart = optional_param('iDisplayStart', 0, PARAM_INT);
$idisplaylength = optional_param('iDisplayLength', 10, PARAM_INT);
$secho = optional_param('sEcho', 1, PARAM_INT);
$displaycolumns = array('tu.userid', 'tu.turnitin_uid', 'mu.lastname', 'mu.firstname', 'mu.email');
$queryparams = array();
// Add sort to query.
$isortcol[0] = optional_param('iSortCol_0', null, PARAM_INT);
$isortingcols = optional_param('iSortingCols', 0, PARAM_INT);
$queryorder = "";
if (!is_null($isortcol[0])) {
$queryorder = " ORDER BY ";
$startorder = $queryorder;
for ($i = 0; $i < intval($isortingcols); $i++) {
$isortcol[$i] = optional_param('iSortCol_' . $i, null, PARAM_INT);
$bsortable[$i] = optional_param('bSortable_' . $isortcol[$i], null, PARAM_TEXT);
$ssortdir[$i] = optional_param('sSortDir_' . $i, null, PARAM_TEXT);
if ($bsortable[$i] == "true") {
$queryorder .= $displaycolumns[$isortcol[$i]] . " " . $ssortdir[$i] . ", ";
}
}
if ($queryorder == $startorder) {
$queryorder = "";
} else {
$queryorder = substr_replace($queryorder, "", -2);
}
}
// Add search to query.
$ssearch = optional_param('sSearch', '', PARAM_TEXT);
$querywhere = ' WHERE ( ';
for ($i = 0; $i < count($displaycolumns); $i++) {
$bsearchable[$i] = optional_param('bSearchable_' . $i, null, PARAM_TEXT);
if (!is_null($bsearchable[$i]) && $bsearchable[$i] == "true" && $ssearch != '') {
$include = true;
if ($i <= 1) {
if (!is_int($ssearch) || is_null($ssearch)) {
$include = false;
}
}
if ($include) {
$querywhere .= $DB->sql_like($displaycolumns[$i], ':search_term_' . $i, false) . " OR ";
$queryparams['search_term_' . $i] = '%' . $ssearch . '%';
}
}
}
if ($querywhere == ' WHERE ( ') {
$querywhere = "";
} else {
$querywhere = substr_replace($querywhere, "", -3);
$querywhere .= " )";
}
$query = "SELECT tu.id AS id, tu.userid AS userid, tu.turnitin_uid AS turnitin_uid, tu.turnitin_utp AS turnitin_utp, " . "mu.firstname AS firstname, mu.lastname AS lastname, mu.email AS email " . "FROM {turnitintooltwo_users} tu " . "LEFT JOIN {user} mu ON tu.userid = mu.id " . $querywhere . $queryorder;
$users = $DB->get_records_sql($query, $queryparams, $idisplaystart, $idisplaylength);
$totalusers = count($DB->get_records_sql($query, $queryparams));
$return["aaData"] = array();
foreach ($users as $user) {
$checkbox = html_writer::checkbox('userids[]', $user->id, false, '', array("class" => "browser_checkbox"));
$pseudoemail = "";
if (!empty($config->enablepseudo)) {
$pseudouser = new TiiPseudoUser(turnitintooltwo_user::get_pseudo_domain());
$pseudouser->setEmail($user->email);
$pseudoemail = $pseudouser->getEmail();
}
$return["aaData"][] = array($checkbox, $user->turnitin_uid == 0 ? '' : $user->turnitin_uid, format_string($user->lastname), format_string($user->firstname), $pseudoemail);
}
$return["sEcho"] = $secho;
$return["iTotalRecords"] = count($users);
$return["iTotalDisplayRecords"] = $totalusers;
return $return;
}
示例13: get_action_icon_selectallnone
/**
*
*/
protected function get_action_icon_selectallnone()
{
global $PAGE;
$PAGE->requires->js_init_call('M.mod_dataform.util.init_select_allnone', array('preset'));
return html_writer::checkbox('presetselectallnone', null, false, null, array('id' => 'id_presetselectallnone'));
}
示例14: manage_messagingoptions
/**
* Display the interface for messaging options
*
* @param mixed $processors array of objects containing message processors
* @param mixed $providers array of objects containing message providers
* @param mixed $preferences array of objects containing current preferences
* @param mixed $defaultpreferences array of objects containing site default preferences
* @return string The text to render
*/
public function manage_messagingoptions($processors, $providers, $preferences, $defaultpreferences)
{
// Filter out enabled, available system_configured and user_configured processors only.
$readyprocessors = array_filter($processors, create_function('$a', 'return $a->enabled && $a->configured && $a->object->is_user_configured();'));
// Start the form. We're not using mform here because of our special formatting needs ...
$output = html_writer::start_tag('form', array('method' => 'post', 'class' => 'mform'));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
/// Settings table...
$output .= html_writer::start_tag('fieldset', array('id' => 'providers', 'class' => 'clearfix'));
$output .= html_writer::nonempty_tag('legend', get_string('providers_config', 'message'), array('class' => 'ftoggler'));
// Display the messging options table
$table = new html_table();
$table->attributes['class'] = 'generaltable';
$table->data = array();
$table->head = array('');
foreach ($readyprocessors as $processor) {
$table->head[] = get_string('pluginname', 'message_' . $processor->name);
}
$number_procs = count($processors);
// Populate the table with rows
foreach ($providers as $provider) {
$preferencebase = $provider->component . '_' . $provider->name;
$headerrow = new html_table_row();
$providername = get_string('messageprovider:' . $provider->name, $provider->component);
$providercell = new html_table_cell($providername);
$providercell->header = true;
$providercell->colspan = $number_procs + 1;
$providercell->attributes['class'] = 'c0';
$headerrow->cells = array($providercell);
$table->data[] = $headerrow;
foreach (array('loggedin', 'loggedoff') as $state) {
$optionrow = new html_table_row();
$optionname = new html_table_cell(get_string($state . 'description', 'message'));
$optionname->attributes['class'] = 'c0';
$optionrow->cells = array($optionname);
foreach ($readyprocessors as $processor) {
// determine the default setting
$permitted = MESSAGE_DEFAULT_PERMITTED;
$defaultpreference = $processor->name . '_provider_' . $preferencebase . '_permitted';
if (isset($defaultpreferences->{$defaultpreference})) {
$permitted = $defaultpreferences->{$defaultpreference};
}
// If settings are disallowed, just display the message that
// the setting is not permitted, if not use user settings or
// force them.
if ($permitted == 'disallowed') {
if ($state == 'loggedoff') {
// skip if we are rendering the second line
continue;
}
$cellcontent = html_writer::nonempty_tag('div', get_string('notpermitted', 'message'), array('class' => 'dimmed_text'));
$optioncell = new html_table_cell($cellcontent);
$optioncell->rowspan = 2;
$optioncell->attributes['class'] = 'disallowed';
} else {
// determine user preferences and use then unless we force
// the preferences.
$disabled = array();
if ($permitted == 'forced') {
$checked = true;
$disabled['disabled'] = 1;
} else {
$checked = false;
// See if hser has touched this preference
if (isset($preferences->{$preferencebase . '_' . $state})) {
// User have some preferneces for this state in the database, use them
$checked = isset($preferences->{$preferencebase . '_' . $state}[$processor->name]);
} else {
// User has not set this preference yet, using site default preferences set by admin
$defaultpreference = 'message_provider_' . $preferencebase . '_' . $state;
if (isset($defaultpreferences->{$defaultpreference})) {
$checked = (int) in_array($processor->name, explode(',', $defaultpreferences->{$defaultpreference}));
}
}
}
$elementname = $preferencebase . '_' . $state . '[' . $processor->name . ']';
// prepare language bits
$processorname = get_string('pluginname', 'message_' . $processor->name);
$statename = get_string($state, 'message');
$labelparams = array('provider' => $providername, 'processor' => $processorname, 'state' => $statename);
$label = get_string('sendingviawhen', 'message', $labelparams);
$cellcontent = html_writer::label($label, $elementname, true, array('class' => 'accesshide'));
$cellcontent .= html_writer::checkbox($elementname, 1, $checked, '', array_merge(array('id' => $elementname), $disabled));
$optioncell = new html_table_cell($cellcontent);
$optioncell->attributes['class'] = 'mdl-align';
}
$optionrow->cells[] = $optioncell;
}
$table->data[] = $optionrow;
}
}
//.........这里部分代码省略.........
示例15: show_file_errors_table
public function show_file_errors_table($page = 0)
{
global $CFG, $OUTPUT;
$limit = 100;
$offset = $page * $limit;
$plagiarismpluginturnitin = new plagiarism_plugin_turnitin();
$filescount = $plagiarismpluginturnitin->get_file_upload_errors(0, 0, true);
$files = $plagiarismpluginturnitin->get_file_upload_errors($offset, $limit);
$baseurl = new moodle_url('/plagiarism/turnitin/settings.php', array('do' => 'errors'));
$pagingbar = $OUTPUT->paging_bar($filescount, $page, $limit, $baseurl);
// Do the table headers.
$cells = array();
$selectall = html_writer::checkbox('errors_select_all', false, false, '', array("class" => "select_all_checkbox"));
$cells["checkbox"] = new html_table_cell($selectall);
$cells["id"] = new html_table_cell(get_string('id', 'plagiarism_turnitin'));
$cells["user"] = new html_table_cell(get_string('student', 'plagiarism_turnitin'));
$cells["user"]->attributes['class'] = 'left';
$cells["course"] = new html_table_cell(get_string('course', 'plagiarism_turnitin'));
$cells["module"] = new html_table_cell(get_string('module', 'plagiarism_turnitin'));
$cells["file"] = new html_table_cell(get_string('file'));
$cells["error"] = new html_table_cell(get_string('error'));
$cells["delete"] = new html_table_cell(' ');
$cells["delete"]->attributes['class'] = 'centered_cell';
$table = new html_table();
$table->head = $cells;
$i = 0;
$rows = array();
if (count($files) == 0) {
$cells = array();
$cells["checkbox"] = new html_table_cell(get_string('semptytable', 'plagiarism_turnitin'));
$cells["checkbox"]->colspan = 8;
$cells["checkbox"]->attributes['class'] = 'centered_cell';
$rows[0] = new html_table_row($cells);
} else {
foreach ($files as $k => $v) {
$cells = array();
if (!empty($v->moduletype) && $v->moduletype != "forum") {
$cm = get_coursemodule_from_id($v->moduletype, $v->cm);
$checkbox = html_writer::checkbox('check_' . $k, $k, false, '', array("class" => "errors_checkbox"));
$cells["checkbox"] = new html_table_cell($checkbox);
$cells["id"] = new html_table_cell($k);
$cells["user"] = new html_table_cell($v->firstname . " " . $v->lastname . " (" . $v->email . ")");
$courselink = new moodle_url($CFG->wwwroot . '/course/view.php', array('id' => $v->courseid));
$cells["course"] = new html_table_cell(html_writer::link($courselink, $v->coursename, array('title' => $v->coursename)));
$modulelink = new moodle_url($CFG->wwwroot . '/mod/' . $v->moduletype . '/view.php', array('id' => $v->cm));
$cells["module"] = new html_table_cell(html_writer::link($modulelink, $cm->name, array('title' => $cm->name)));
if ($v->submissiontype == "file") {
$fs = get_file_storage();
if ($file = $fs->get_file_by_hash($v->identifier)) {
$cells["file"] = new html_table_cell(html_writer::link($CFG->wwwroot . '/pluginfile.php/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . '/' . $file->get_itemid() . '/' . $file->get_filename(), $OUTPUT->pix_icon('fileicon', 'open ' . $file->get_filename(), 'plagiarism_turnitin') . " " . $file->get_filename()));
} else {
$cells["file"] = get_string('filedoesnotexist', 'plagiarism_turnitin');
}
} else {
$cells["file"] = str_replace('_', ' ', ucfirst($v->submissiontype));
}
$errorcode = $v->errorcode;
// Deal with legacy error issues.
if (is_null($errorcode)) {
$errorcode = 0;
if ($v->submissiontype == 'file') {
if (is_object($file) && $file->get_filesize() > TURNITINTOOLTWO_MAX_FILE_UPLOAD_SIZE) {
$errorcode = 2;
}
}
}
// Show error message if there is one.
$errormsg = $v->errormsg;
if ($errorcode == 0) {
$errorstring = is_null($errormsg) ? get_string('ppsubmissionerrorseelogs', 'plagiarism_turnitin') : $errormsg;
} else {
$errorstring = get_string('errorcode' . $v->errorcode, 'plagiarism_turnitin', display_size(TURNITINTOOLTWO_MAX_FILE_UPLOAD_SIZE));
}
$cells["error"] = $errorstring;
$fnd = array("\n", "\r");
$rep = array('\\n', '\\r');
$string = str_replace($fnd, $rep, get_string('deleteconfirm', 'plagiarism_turnitin'));
$attributes["onclick"] = "return confirm('" . $string . "');";
$cells["delete"] = new html_table_cell(html_writer::link($CFG->wwwroot . '/plagiarism/turnitin/settings.php?do=errors&action=deletefile&id=' . $k, $OUTPUT->pix_icon('delete', get_string('deletesubmission', 'plagiarism_turnitin'), 'plagiarism_turnitin'), $attributes));
$cells["delete"]->attributes['class'] = 'centered_cell';
$rows[$i] = new html_table_row($cells);
$i++;
}
}
if ($i == 0) {
$cells = array();
$cells["checkbox"] = new html_table_cell(get_string('semptytable', 'plagiarism_turnitin'));
$cells["checkbox"]->colspan = 8;
$cells["checkbox"]->attributes['class'] = 'centered_cell';
$rows[0] = new html_table_row($cells);
} else {
$table->id = "ppErrors";
}
}
$table->data = $rows;
$output = html_writer::table($table);
return $pagingbar . $output . $pagingbar;
}