Beispiel #1
0
function editable_quality($id, $content, $title, $options)
{
    global $gDisableEditing;
    $editable = !$gDisableEditing && getCurrentUser();
    $rationale = json_decode($content["variant_quality_text"], true);
    $html = "<TABLE class=\"quality_table\">\n";
    $header_row = "<TR><TH class=\"rowlabel\" width=\"120\">Variant evidence</TH><TH width=\"1\"></TH><TH width=\"16\"></TH><TH width=\"1\"></TH><TH width=\"*\"></TH></TR>\n";
    $empty_row = "<TR><TD colspan=\"5\">&nbsp;</TD></TR>\n";
    $html .= $header_row;
    $axis_index = 0;
    global $gQualityAxes;
    foreach ($gQualityAxes as $axis => $desc) {
        if ($axis_index == 4) {
            $html .= $empty_row;
            $html .= ereg_replace("Variant evidence", "Clinical&nbsp;importance", $header_row);
        }
        if (strlen($content["variant_quality"]) <= $axis_index) {
            $score = "-";
        } else {
            $score = substr($content["variant_quality"], $axis_index, 1);
            if ($score === "!") {
                $score = "-1";
            } else {
                if (!ereg('^[0-5]$', $score)) {
                    $score = "-";
                }
            }
        }
        $html .= "<TR>\n";
        $html .= "<TD class=\"rowlabel nowrap\"><SPAN onmouseover=\"Tip('" . htmlspecialchars(ereg_replace("\n", "\\n", addslashes($desc)), ENT_QUOTES) . "',BALLOON,true,FIX,[this,0,0],FOLLOWMOUSE,false,ABOVE,true,WIDTH,-400);\" onmouseout=\"UnTip();\">{$axis}</SPAN></TD>\n";
        $cellid = "{$id}__o_{$axis_index}__";
        $cancel_cell = "<TD></TD>";
        $stars = "";
        for ($i = $editable ? "-" : -1; $i === "-" || $i <= 5; $i = $i === "-" ? -1 : $i + 1) {
            if (!$editable && $i == 0) {
                continue;
            }
            $attrs = "width=\"16\" height=\"16\" alt=\"\"";
            if ($editable) {
                $arg_i = $i === "-" ? "'-'" : $i;
                $attrs .= " onclick=\"editable_5star_click('{$cellid}',{$arg_i});\"";
            }
            if ($i != 0 && $i != "-") {
                $id_i = $i < 0 ? "N" . -$i : $i;
                $attrs .= " id=\"star{$id_i}_{$cellid}\"";
            }
            if ($i === "-") {
                $stars .= "<SPAN {$attrs} class=\"halfthere x\">&times;</SPAN>";
            } else {
                if ($i == 0 || $score == "-") {
                    $attrs .= " class=\"halfthere\"";
                }
                if ($i > 0 && $i <= $score) {
                    $stars .= "<IMG src=\"/img/star-blue16.png\" {$attrs} />";
                } else {
                    if ($i < 0 && $score < 0 && $i <= $score) {
                        $stars .= "<IMG src=\"/img/star-red16.png\" {$attrs} />";
                    } else {
                        $stars .= "<IMG src=\"/img/star-white16.png\" {$attrs} />";
                    }
                }
            }
            if ($i === "-") {
                // Show the "X" (null) button last, although I made it first
                $cancel_cell = $stars;
                $stars = "";
            }
        }
        $html .= "<TD class=\"nowrap\">{$stars}</TD>\n";
        if ($editable) {
            $html .= "<TD id=\"{$cellid}\" class=\"editable 5star\"><SPAN id=\"preview_{$cellid}\">{$score}</SPAN><INPUT type=\"hidden\" id=\"orig_{$cellid}\" name=\"orig_{$cellid}\" value=\"" . htmlentities($score) . "\"/></TD><TD>{$cancel_cell}</TD>\n";
        } else {
            if ($score) {
                $html .= "<TD>{$score}</TD><TD></TD>\n";
            } else {
                $html .= "<TD></TD><TD></TD>\n";
            }
        }
        $preview = editable_quality_preview($rationale[$axis_index]);
        $html .= "<TD class=\"left text\" rowspan=\"2\"><SPAN id=\"rationale_{$cellid}\">{$preview}</SPAN></TD>";
        $html .= "</TR>\n";
        $html .= "<TR><TD colspan=\"3\"></TD></TR>\n";
        ++$axis_index;
    }
    $html .= $empty_row;
    $html .= "</TABLE>\n";
    $html .= "<INPUT type=\"hidden\" id=\"orig_{$id}_text__\" value=\"";
    $html .= htmlentities($content[variant_quality_text]);
    $html .= "\" />";
    return $html;
}
Beispiel #2
0
                        $response["preview__{$edit_id}__{$field}__{$k}"] = htmlspecialchars($v);
                    }
                    continue;
                }
                if ($field == "variant_quality") {
                    for ($i = 0; $i < strlen($row[$field]); $i++) {
                        $response["saved__{$edit_id}__{$field}__{$i}"] = substr($row[$field], $i, 1);
                        $response["preview__{$edit_id}__{$field}__{$i}"] = substr($row[$field], $i, 1);
                    }
                    continue;
                }
                if ($field == "variant_quality_text") {
                    $saved = json_decode($row[$field], true);
                    $preview = array();
                    foreach ($saved as $s) {
                        $preview[] = editable_quality_preview($s);
                    }
                    $response["saved__{$edit_id}__{$field}"] = $saved;
                    $response["preview__{$edit_id}__{$field}"] = $preview;
                    continue;
                }
                $response["saved__{$edit_id}__{$field}"] = isset($row[$field]) ? $row[$field] : $row["d.{$field}"];
                $response["preview__{$edit_id}__{$field}"] = $gTheTextile->textileRestricted($response["saved__{$edit_id}__{$field}"]);
            }
        }
    }
}
header("Content-type: application/json");
print json_encode($response);
?>