git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrreport/trunk@2830
7aebc617-e5e2-0310-91dc-
80fb5f6d2477
$select = $td->appendElement('select', array('name' => 'condition', 'required' => 'required'));
$option = $select->appendElement('option', array('value' => '0'));
$option->appendText(wfMessage('wrreport-condition-select')->text());
$select = $td->appendElement('select', array('name' => 'condition', 'required' => 'required'));
$option = $select->appendElement('option', array('value' => '0'));
$option->appendText(wfMessage('wrreport-condition-select')->text());
- foreach (WrReport::$wrConditions as $condition_num => $condition_text) {
+ foreach (WrReport::$wrConditions as $condition_num) {
$option = $select->appendElement('option', array('value' => (string) $condition_num));
if ($condition == $condition_num) $option->setAttribute('selected', 'selected');
$option = $select->appendElement('option', array('value' => (string) $condition_num));
if ($condition == $condition_num) $option->setAttribute('selected', 'selected');
- $option->appendText($condition_text);
+ $option->appendText(WrReport::getWrConditionText($condition_num));
}
$option = $select->appendElement('option', array('value' => '-1'));
if ($condition == -1) $option->setAttribute('selected', 'selected');
}
$option = $select->appendElement('option', array('value' => '-1'));
if ($condition == -1) $option->setAttribute('selected', 'selected');
// $row['condition']
$condition_text = '---';
// $row['condition']
$condition_text = '---';
- if (isset(WrReport::$wrConditions[$row['condition']])) $condition_text = WrReport::$wrConditions[$row['condition']];
+ if (array_key_exists($row['condition'], WrReport::$wrConditions)) $condition_text = WrReport::getWrConditionText($row['condition']);
$td = $tr->appendElement('td');
if ($row['delete_date']) $td->appendElement('em')->appendText(wfMessage('wrreport-deletereport-deleted')->text());
else $td->appendText($condition_text);
$td = $tr->appendElement('td');
if ($row['delete_date']) $td->appendElement('em')->appendText(wfMessage('wrreport-deletereport-deleted')->text());
else $td->appendText($condition_text);
// -------------------
class WrReport {
// -------------------
class WrReport {
- // Conditions: array(1 => 'Sehr gut', 2 => 'Gut', 3 => 'Mittelmäßig', 4 => 'Schlecht', 5 => 'Geht nicht');
- public static $wrConditions;
+ // Conditions: 1 => 'Sehr gut', 2 => 'Gut', 3 => 'Mittelmäßig', 4 => 'Schlecht', 5 => 'Geht nicht'
+ public static $wrConditions = array(1, 2, 3, 4, 5);
- public static function initWrConditions() {
- WrReport::$wrConditions = array();
- for ($i = 1; $i != 6; ++$i) WrReport::$wrConditions[$i] = wfMessage('wrreport-condition-' . $i)->text();
+ /// Returns the translated text of a specified numeric condition
+ public static function getWrConditionText(int $condition): string {
+ return wfMessage('wrreport-condition-' . $condition)->text();
else $date = strftime('%d.%m.', $date_report);
$td = $tr->appendElement('td');
else $date = strftime('%d.%m.', $date_report);
$td = $tr->appendElement('td');
- if (isset(WrReport::$wrConditions[$condition])) {
- $td->appendElement('a', array('href' => $title->getLocalURL() . '#' . Sanitizer::escapeIdForLink(wfMessage('wrreport-reports-sectionname'))))->appendText(WrReport::$wrConditions[$condition]);
+ if (array_key_exists($condition, WrReport::$wrConditions)) {
+ $td->appendElement('a', array('href' => $title->getLocalURL() . '#' . Sanitizer::escapeIdForLink(wfMessage('wrreport-reports-sectionname'))))->appendText(WrReport::getWrConditionText($condition));
$td->appendText(' ');
$small = $td->appendElement('small');
$small->appendText($date);
$td->appendText(' ');
$small = $td->appendElement('small');
$small->appendText($date);
-WrReport::initWrConditions();