function metaform() { if (isset($_REQUEST['form_name'])) { $GLOBALS['form_name'] = format_varname($_REQUEST['form_name']); $GLOBALS['singular'] = format_varname($_REQUEST['singular']); tem_set('singular', $GLOBALS['singular']); $GLOBALS['opt_email'] = format_yesno($_REQUEST['opt_email']); tem_set('opt_email', $GLOBALS['opt_email']); $GLOBALS['opt_db'] = format_yesno($_REQUEST['opt_db']); tem_set('opt_db', $GLOBALS['opt_db']); $GLOBALS['opt_listing'] = format_yesno($_REQUEST['opt_listing']); tem_set('opt_listing', $GLOBALS['opt_listing']); $GLOBALS['opt_display'] = format_yesno($_REQUEST['opt_display']); tem_set('opt_display', $GLOBALS['opt_display']); $GLOBALS['opt_http_pass'] = format_yesno($_REQUEST['opt_http_pass']); tem_set('opt_http_pass', $GLOBALS['opt_http_pass']); } else { $GLOBALS['form_name'] = 'some_form'; } if (isset($_REQUEST['fields'])) { if (isset($_REQUEST['view_sql'])) { view_sql(); exit; } elseif (isset($_REQUEST['view_php'])) { view_php(); exit; } elseif (isset($_REQUEST['view_html'])) { view_html(); exit; } elseif (isset($_REQUEST['view_email'])) { view_email(); exit; } elseif (isset($_REQUEST['download_tar'])) { download_tar(); exit; } elseif (isset($_REQUEST['preview'])) { preview(); exit; } elseif (isset($_REQUEST['edit'])) { tem_set('fields', $_REQUEST['fields']); tem_set('form_name', $GLOBALS['form_name']); # fall through } else { die("Sorry... couldn't tell which button you pressed"); } } set_form_action(); tem_load('code/wfpl/metaform/main.html'); list_available_types(); tem_output(); }
function format_setting($name, $value, $ratings, $gradecategories, $groupmodes, $groupings, $indentmenu, $sectionmenu, $positionmenu, $uploadlimitmenu, $conditiongradeitemidmenu, $conditioncmidmenu, $conditioncmcompletionmenu, $conditionfieldnamemenu, $conditionfieldoperatormenu, $conditiongroupidmenu, $conditiongroupingidmenu, $conditionactionmenu, $completiontrackingmenu, $completionfields, $competencyrulemenu, $filters, $filtermenu, $filterdefaulton, $filterdefaultoff) { $plugin = 'block_taskchain_navigation'; switch ($name) { case 'availablefrom': case 'availableuntil': $name = get_string($name, $plugin); $value = $value ? userdate($value) : get_string('disable'); break; case 'availablecutoff': $name = get_string('cutoffdate', 'assign'); $value = $value ? userdate($value) : get_string('disable'); break; case 'visible': $name = get_string('visible'); $value = format_yesno($value, 'show', 'hide'); break; case 'rating': $name = get_string('rating', 'rating'); $value = $ratings[$value]; break; case 'maxgrade': $name = get_string('maximumgrade', $plugin); $value = $value . '%'; break; case 'gradepass': $name = get_string('gradepass', 'grades'); $value = $value . '%'; break; case 'gradecat': $name = get_string('gradecategory', 'grades'); $value = $gradecategories[$value]; break; case 'gradeitemhidden': $name = get_string('gradeitemhidden', $plugin); $value = format_yesno($value); break; case 'extracredit': $name = get_string('extracredit', 'grades'); $value = format_yesno($value); break; case 'regrade': $name = get_string('regrade', $plugin); $value = format_yesno($value); break; case 'groupmode': $name = get_string('groupmode'); $value = $groupmodes[$value]; break; case 'groupingid': $name = get_string('grouping', 'group'); $value = $groupings[$value]; break; case 'groupmembersonly': $name = get_string('groupmembersonly', 'group'); $value = format_yesno($value); break; case 'indent': $name = get_string('indent', $plugin); $value = $indentmenu[$value]; break; case 'section': $name = get_string('section'); $value = $sectionmenu[$value]; break; case 'position': $name = get_string('position', $plugin); $value = $positionmenu[$value]; break; case 'uploadlimit': $name = get_string('activityuploadlimit', $plugin); $value = $uploadlimitmenu[$value]; break; case 'removeconditions': $name = get_string('removeconditions', $plugin); $value = format_yesno($value); break; case 'conditiondate': $strman = get_string_manager(); $plugin = 'availability_date'; if ($strman->string_exists('pluginname', $plugin)) { // Moodle >= 2.7 $name = get_string('pluginname', $plugin); $from = 'short_from'; $until = 'short_until'; } else { // Moodle <= 2.6 $name = get_string('availability'); $plugin = 'condition'; $from = 'requires_date'; $until = 'requires_date_before'; } foreach ($value as $i => $v) { $str = $v->d == '>=' ? $from : $until; $str = get_string($str, $plugin, userdate($v->t)); $value[$i] = html_writer::tag('p', $str); } $value = implode('', $value); break; case 'conditionfield': $strman = get_string_manager(); if ($strman->string_exists('title', 'availability_grade')) { // Moodle >= 2.7 $name = get_string('conditiontitle', 'availability_profile'); } else { // Moodle <= 2.6 $name = get_string('availablefrom', 'condition'); } foreach ($value as $i => $v) { $value[$i] = html_writer::start_tag('p') . $conditionfieldnamemenu[$v->sf] . ' ' . $conditionfieldoperatormenu[$v->op] . ' ' . $v->v . html_writer::end_tag('p'); } $value = implode('', $value); break; case 'conditiongrade': $strman = get_string_manager(); if ($strman->string_exists('title', 'availability_grade')) { // Moodle >= 2.7 $name = get_string('title', 'availability_grade'); $grademin = get_string('option_min', 'availability_grade'); $grademax = get_string('option_max', 'availability_grade'); } else { // Moodle <= 2.6 $name = get_string('gradecondition', 'condition'); $grademin = get_string('grade_atleast', 'condition'); $grademax = get_string('grade_upto', 'condition'); } foreach ($value as $i => $v) { $value[$i] = html_writer::start_tag('p') . ltrim($conditiongradeitemidmenu[$v->id], '│└ ') . ' ' . $grademin . ' ' . $v->min . '% ' . $grademax . ' ' . $v->max . '%' . html_writer::end_tag('p'); } $value = implode('', $value); break; case 'conditiongroupid': foreach ($value as $i => $v) { $value[$i] = html_writer::tag('p', $conditiongroupidmenu[$v]); } $value = implode('', $value); break; case 'conditiongroupingid': foreach ($value as $i => $v) { $value[$i] = html_writer::tag('p', $conditiongroupingidmenu[$v]); } $value = implode('', $value); break; case 'conditionaction': $name = get_string('display', 'form'); foreach ($value as $i => $v) { $value[$i] = html_writer::tag('p', $conditionactionmenu[$v]); } $value = implode('', $value); break; case 'conditioncm': $strman = get_string_manager(); if ($strman->string_exists('activitycompletion', 'completion')) { // Moodle >= 2.7 $name = get_string('activitycompletion', 'completion'); } else { // Moodle <= 2.6 $name = get_string('completioncondition', 'condition'); } foreach ($value as $i => $v) { $str = array(); if ($v->ungraded) { $str[] = get_string('conditioncmungraded', $plugin); } if ($v->resources) { $str[] = get_string('conditioncmresources', $plugin); } if ($v->labels) { $str[] = get_string('conditioncmlabels', $plugin); } if ($str = implode(', ', $str)) { $str = block_taskchain_navigation::textlib('strtolower', " ({$str})"); } $value[$i] = html_writer::tag('p', $conditioncmidmenu[$v->cm] . "{$str} " . $conditioncmcompletionmenu[$v->e]); } $value = implode('', $value); break; case 'conditioncmlabels': case 'conditioncmresources': case 'conditioncmungraded': $name = get_string($name, $plugin); $value = format_yesno($value); break; case 'removecompletion': case 'erasecompletion': $name = get_string($name, $plugin); $value = format_yesno($value); break; case 'completiontracking': $name = get_string('completion', 'completion'); $value = $completiontrackingmenu[$value]; break; case 'completiondate': $name = get_string('completionexpected', 'completion'); $value = $value ? userdate($value) : get_string('disable'); break; case 'competencyrule': $name = get_string('uponcoursemodulecompletion', 'tool_lp'); $value = $competencyrulemenu[$value]; break; default: if (array_key_exists($name, $completionfields)) { $field = $completionfields[$name]; $name = $field->text; switch ($field->type) { case 'checkbox': $value = format_yesno($value); break; case 'duration': list($value, $unit) = convert_seconds_to_duration($value); $value .= ' ' . get_duration_units($unit); break; case 'select': $i = 1; $num = $value; $value = array(); while (($ii = pow(2, $i)) && $ii <= $num) { if ($ii & $num) { $value[] = strip_tags($field->options[$ii]); } $i++; } $value = array_filter($value); $value = implode(', ', $value); break; case 'textbox': $value = number_format($value); break; } } else { if (substr($name, 0, 6) == 'filter') { $name = substr($name, 6); switch ($value) { case TEXTFILTER_ON: case TEXTFILTER_OFF: $value = $filtermenu[$value]; break; case TEXTFILTER_INHERIT: if ($filters[$name]->inheritedstate == TEXTFILTER_ON) { $value = $filterdefaulton; } else { $value = $filterdefaultoff; } break; } $name = filter_get_name($name); } } } return array($name, $value); }