本文整理汇总了PHP中Quiz::getColor方法的典型用法代码示例。如果您正苦于以下问题:PHP Quiz::getColor方法的具体用法?PHP Quiz::getColor怎么用?PHP Quiz::getColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quiz
的用法示例。
在下文中一共展示了Quiz::getColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseTextField
function parseTextField($input)
{
global $wqInputId;
$wqInputId++;
$title = $state = $size = $maxlength = $class = $style = $value = $disabled = $a_inputBeg = $a_inputEnd = $big = '';
# determine size and maxlength of the input.
if (array_key_exists(3, $input)) {
$size = $input[3];
if ($size < 3) {
$size = 'size="1"';
} elseif ($size < 12) {
$size = 'size="' . ($size - 2) . '"';
} else {
$size = 'size="' . ($size - 1) . '"';
}
$maxlength = 'maxlength="' . $input[3] . '"';
}
# Syntax error if there is no input text.
if (empty($input[1])) {
$value = 'value="???"';
$state = 'error';
} else {
if ($this->mBeingCorrected) {
$value = trim($this->mRequest->getVal($wqInputId));
$a_inputBeg = '<a class="input" href="#nogo"><span class="correction">';
$state = 'NA';
$title = 'title="' . wfMsgHtml('quiz_colorNA') . '"';
}
$class = 'class="numbers"';
foreach (preg_split('` *\\| *`', trim($input[1]), -1, PREG_SPLIT_NO_EMPTY) as $possibility) {
if ($state == '' || $state == 'NA' || $state == 'wrong') {
if (preg_match('`^(-?\\d+\\.?\\d*)(-(-?\\d+\\.?\\d*)| (\\d+\\.?\\d*)(%))?$`', str_replace(',', '.', $possibility), $matches)) {
if (array_key_exists(5, $matches)) {
$strlen = $size = $maxlength = '';
} elseif (array_key_exists(3, $matches)) {
$strlen = strlen($matches[1]) > strlen($matches[3]) ? strlen($matches[1]) : strlen($matches[3]);
} else {
$strlen = strlen($matches[1]);
}
if ($this->mBeingCorrected && !empty($value)) {
$value = str_replace(',', '.', $value);
if (is_numeric($value) && (array_key_exists(5, $matches) && $value >= $matches[1] - $matches[1] * $matches[4] / 100 && $value <= $matches[1] + $matches[1] * $matches[4] / 100 || array_key_exists(3, $matches) && $value >= $matches[1] && $value <= $matches[3] || $value == $possibility)) {
$state = 'right';
$title = 'title="' . wfMsgHtml('quiz_colorRight') . '"';
} else {
$state = 'wrong';
$title = 'title="' . wfMsgHtml('quiz_colorWrong') . '"';
}
}
} else {
$strlen = preg_match('` \\(i\\)$`', $possibility) ? mb_strlen($possibility) - 4 : mb_strlen($possibility);
$class = 'class="words"';
if ($this->mBeingCorrected && !empty($value)) {
if ($value == $possibility || preg_match('`^' . $value . ' \\(i\\)$`i', $possibility) || !$this->mCaseSensitive && preg_match('`^' . $value . '$`i', $possibility)) {
$state = 'right';
$title = 'title="' . wfMsgHtml('quiz_colorRight') . '"';
} else {
$state = 'wrong';
$title = 'title="' . wfMsgHtml('quiz_colorWrong') . '"';
}
}
}
if (array_key_exists(3, $input) && $strlen > $input[3]) {
# The textfield is too short for the answer
$state = 'error';
$value = "<_{$possibility}_ >";
}
}
if ($this->mBeingCorrected) {
$a_inputBeg .= "{$possibility}<br />";
}
}
$value = empty($value) ? '' : 'value="' . str_replace('"', '"', $value) . '"';
if ($this->mBeingCorrected) {
$a_inputBeg .= '</span>';
$a_inputEnd = '</a>';
$big = '<em>▼</em>';
}
}
if ($state == 'error' || $this->mBeingCorrected) {
global $wgContLang;
$border = $wgContLang->isRTL() ? 'border-right' : 'border-left';
$style = "style=\"{$border}:3px solid " . Quiz::getColor($state) . '; "';
$this->setState(empty($value) ? 'new_NA' : $state);
if ($state == 'error') {
$size = '';
$maxlength = '';
$disabled = 'disabled="disabled"';
$title = 'title="' . wfMsgHtml('quiz_colorError') . '"';
}
}
return $output = "{$a_inputBeg}<span {$style}><input {$class} type=\"text\" name=\"{$wqInputId}\" {$title} {$size} {$maxlength} {$value} {$disabled} autocomplete=\"off\" />{$big}</span>{$a_inputEnd}";
}
示例2: parseTextField
function parseTextField($input)
{
global $wqInputId;
$wqInputId++;
$title = $state = $size = $maxlength = $class = $style = $value = $disabled = $a_inputBeg = $a_inputEnd = $big = "";
# determine size and maxlength of the input.
if (array_key_exists(3, $input)) {
$size = $input[3];
if ($size < 3) {
$size = "size=\"1\"";
} elseif ($size < 12) {
$size = "size=\"" . ($size - 2) . "\"";
} else {
$size = "size=\"" . ($size - 1) . "\"";
}
$maxlength = "maxlength=\"" . $input[3] . "\"";
}
# Syntax error if there is no input text.
if (empty($input[1])) {
$value = "value=\"???\"";
$state = "error";
} else {
if ($this->mBeingCorrected) {
$value = trim($this->mRequest->getVal($wqInputId));
$a_inputBeg = "<a class=\"input\" href=\"#nogo\"><span class=\"correction\">";
$state = "NA";
$title = "title=\"" . wfMsgHtml('quiz_colorNA') . "\"";
}
$class = "class=\"numbers\"";
foreach (preg_split('` *\\| *`', trim($input[1]), -1, PREG_SPLIT_NO_EMPTY) as $possibility) {
if ($state == "" || $state == "NA" || $state == "wrong") {
if (preg_match('`^(-?\\d+\\.?\\d*)(-(-?\\d+\\.?\\d*)| (\\d+\\.?\\d*)(%))?$`', str_replace(',', '.', $possibility), $matches)) {
if (array_key_exists(5, $matches)) {
$strlen = $size = $maxlength = "";
} elseif (array_key_exists(3, $matches)) {
$strlen = strlen($matches[1]) > strlen($matches[3]) ? strlen($matches[1]) : strlen($matches[3]);
} else {
$strlen = strlen($matches[1]);
}
if ($this->mBeingCorrected && !empty($value)) {
$value = str_replace(',', '.', $value);
if (is_numeric($value) && (array_key_exists(5, $matches) && $value >= $matches[1] - $matches[1] * $matches[4] / 100 && $value <= $matches[1] + $matches[1] * $matches[4] / 100 || array_key_exists(3, $matches) && $value >= $matches[1] && $value <= $matches[3] || $value == $possibility)) {
$state = "right";
$title = "title=\"" . wfMsgHtml('quiz_colorRight') . "\"";
} else {
$state = "wrong";
$title = "title=\"" . wfMsgHtml('quiz_colorWrong') . "\"";
}
}
} else {
$strlen = preg_match('` \\(i\\)$`', $possibility) ? mb_strlen($possibility) - 4 : mb_strlen($possibility);
$class = "class=\"words\"";
if ($this->mBeingCorrected && !empty($value)) {
if ($value == $possibility || preg_match('`^' . $value . ' \\(i\\)$`i', $possibility) || !$this->mCaseSensitive && preg_match('`^' . $value . '$`i', $possibility)) {
$state = "right";
$title = "title=\"" . wfMsgHtml('quiz_colorRight') . "\"";
} else {
$state = "wrong";
$title = "title=\"" . wfMsgHtml('quiz_colorWrong') . "\"";
}
}
}
if (array_key_exists(3, $input) && $strlen > $input[3]) {
# The textfield is too short for the answer
$state = "error";
$value = "<_{$possibility}_ >";
}
}
if ($this->mBeingCorrected) {
$a_inputBeg .= "{$possibility}<br/>";
}
}
$value = empty($value) ? "" : "value=\"" . str_replace('"', """, $value) . "\"";
if ($this->mBeingCorrected) {
$a_inputBeg .= "</span>";
$a_inputEnd = "</a>";
$big = "<em>▼</em>";
}
}
if ($state == "error" || $this->mBeingCorrected) {
$style = "style=\"border-left:3px solid " . Quiz::getColor($state) . "; \"";
$this->setState(empty($value) ? "new_NA" : $state);
if ($state == "error") {
$size = "";
$maxlength = "";
$disabled = "disabled=\"disabled\"";
$title = "title=\"" . wfMsgHtml('quiz_colorError') . "\"";
}
}
return $output = "{$a_inputBeg}<span {$style}><input {$class} type=\"text\" name=\"{$wqInputId}\" {$title} {$size} {$maxlength} {$value} {$disabled} autocomplete=\"off\" />{$big}</span>{$a_inputEnd}";
}