forked from science-ation/science-ation
- Add a type field to each config variable. The type field is used to tell the
editor what type of variable to expect. It can be yesno, enum, text (default), number (unimplemented), or blank (default behaviour of the current system). In response, the editor will use pull down lists instead of text boxes for things like "Yes", and "No", or enumerated fields. - Update the descriptions and type of existing variables.
This commit is contained in:
parent
82b8b75b25
commit
018725aebf
@ -35,6 +35,8 @@ function config_editor_load($category, $year)
|
||||
$var[$r->var]['desc'] = $r->description;
|
||||
$var[$r->var]['category'] = $r->category;
|
||||
$var[$r->var]['ord'] = $r->ord;
|
||||
$var[$r->var]['type'] = $r->type;
|
||||
$var[$r->var]['type_values'] = $r->type_values;
|
||||
}
|
||||
return $var;
|
||||
}
|
||||
@ -124,7 +126,61 @@ function config_editor($category, $year, $array_name, $self)
|
||||
print("<tr>");
|
||||
print("<td>{$var[$k]['desc']}</td>");
|
||||
print("<td>");
|
||||
print("<input size=\"$size\" type=\"text\" name=\"${array_name}[$k]\" value=\"".htmlspecialchars($var[$k]['val'])."\">\n");
|
||||
|
||||
$val = htmlspecialchars($var[$k]['val']);
|
||||
$name = "${array_name}[$k]";
|
||||
|
||||
switch($var[$k]['type']) {
|
||||
case "yesno":
|
||||
print("<select name=\"$name\">");
|
||||
$sel = ($val == 'yes') ? 'selected=selected' : '';
|
||||
print("<option $sel value=\"yes\">Yes</option>");
|
||||
$sel = ($val == 'no') ? 'selected=selected' : '';
|
||||
print("<option $sel value=\"no\">No</option>");
|
||||
print("</select>");
|
||||
break;
|
||||
case "enum":
|
||||
$values = $var[$k]['type_values'];
|
||||
/* Split values */
|
||||
/* The PERL regex here matches any string of the form
|
||||
* key=val| , where the = and 'val' and '|' are
|
||||
* optional. val is allowed to contain spaces. Using
|
||||
* preg_match_all runs this regex multiple times, and
|
||||
* creates arrays for each subpattern that matches.
|
||||
* For example, "aa=Aye|bb=Bee Bee|cc|dd=Dee"
|
||||
* Would construct the following Array of Arrays:
|
||||
* Array ( [0] => Array ( [0] => "aa=Aye|",
|
||||
[1] => "bb=Bee Bee|",
|
||||
[2] => "cc|",
|
||||
[3] => "dd=Dee" ),
|
||||
[1] => Array ( [0] => "aa",
|
||||
[1] => "bb",
|
||||
[2] => "cc",
|
||||
[3] => "dd" ),
|
||||
[2] => Array ( [0] => "Aye",
|
||||
[1] => "Bee Bee",
|
||||
[2] => "",
|
||||
[3] => "Dee" ) )
|
||||
* neat eh? :) We use [1] and [2] to form the keys and
|
||||
* values that we show the user */
|
||||
|
||||
preg_match_all("/([^\|=]+)(?:=([^\|]+))?\|?/", $values, $regs);
|
||||
// print_r($regs);
|
||||
print("<select name=\"$name\">");
|
||||
for($x=0; $x<count($regs[1]); $x++) {
|
||||
$e_key = trim($regs[1][$x]);
|
||||
$e_val = trim($regs[2][$x]);
|
||||
if($e_val == "") $e_val = $e_key;
|
||||
|
||||
$sel = ($val == $e_key) ? 'selected=selected' : '';
|
||||
print("<option $sel value=\"$e_key\">$e_val</option>");
|
||||
}
|
||||
print("</select>");
|
||||
break;
|
||||
default:
|
||||
print("<input size=\"$size\" type=\"text\" name=\"$name\" value=\"$val\">\n");
|
||||
break;
|
||||
}
|
||||
echo "</td></tr>";
|
||||
}
|
||||
print("</table>");
|
||||
|
@ -1 +1 @@
|
||||
36
|
||||
37
|
||||
|
29
db/db.update.37.sql
Normal file
29
db/db.update.37.sql
Normal file
@ -0,0 +1,29 @@
|
||||
-- Add type and type_values fields to the config editor.
|
||||
ALTER TABLE `config` ADD `type` ENUM( '', 'yesno', 'number', 'text', 'enum' ) NOT NULL AFTER `category` ,
|
||||
ADD `type_values` TINYTEXT NOT NULL AFTER `type` ;
|
||||
|
||||
UPDATE `config` SET `type` = 'yesno',
|
||||
`description` = 'Ask for students special food requirements. Should be ''Yes'' if you plan on providing food to the students.' WHERE `var`='participant_student_foodreq';
|
||||
|
||||
UPDATE `config` set `type` = 'yesno', `description` = 'Specify whether to use the division selector flowchart questions to help decide on the division' WHERE `var`='usedivisionselector';
|
||||
UPDATE `config` set `type` = 'yesno' WHERE `var`='participant_student_personal';
|
||||
UPDATE `config` set `type` = 'yesno', `description` = 'Ask for students their T-Shirt size' WHERE `var`='participant_student_tshirt';
|
||||
UPDATE `config` set `type` = 'yesno', `description` = 'Ask for mentorship information' WHERE `var`='participant_mentor';
|
||||
UPDATE `config` set `type` = 'yesno', `description` = 'Ask if the project requires a table' WHERE `var`='participant_project_table';
|
||||
UPDATE `config` set `type` = 'yesno', `description` = 'Ask if the project requires electricity' WHERE `var`='participant_project_electricity';
|
||||
UPDATE `config` set `type` = 'yesno' WHERE `var`='tours_enable';
|
||||
UPDATE `config` set `type` = 'yesno', `description` = 'Allows for the setup of different divisions for each category' WHERE `var`='filterdivisionbycategory';
|
||||
|
||||
UPDATE `config` SET `type` = 'enum', `type_values` = 'student=Student|project=Project', `description` = 'Registration fee is per student, or per project?' WHERE `var` = 'regfee_per';
|
||||
|
||||
UPDATE `config` SET `type` = 'enum', `type_values` = 'open=Open|singlepassword=Single Password|schoolpassword=School Password|invite=Invite|openorinvite=Open or Invite', `description`='The type of Participant Registration to use' WHERE `var` = 'participant_registration_type';
|
||||
|
||||
UPDATE `config` SET `type` = 'enum', `type_values` = 'open=Open|singlepassword=Single Password|invite=Invite', `description` = 'The type of Judge Registration to use' WHERE `var` = 'judge_registration_type';
|
||||
|
||||
UPDATE `config` SET `type` = 'enum', `type_values` = 'open=Open|payment_pending=Payment Pending|complete=Complete', `description` = 'The status a project must have have to be considered eligible for judge scheduling. ' WHERE `var` = 'project_status' ;
|
||||
|
||||
UPDATE `config` SET `type` = 'enum', `type_values` = 'none=None|date=By Date|registration=With Registration', `description` = 'Self nominations for special awards are due either with registration ("With Registration"), or on a specific date. If "By Date" is used, it must be configured under "Important Dates" section. If you do not wish to allow students to self-nominate for special awards, set to "None"' WHERE `var` = 'specialawardnomination';
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user