87 lines
2.2 KiB
PHP
87 lines
2.2 KiB
PHP
<?php
|
|
|
|
function getQuestion(
|
|
$question,
|
|
$includePermalink=1,
|
|
$isAdmin=0,
|
|
$isResponding=0,
|
|
$adminPassword=""
|
|
) {
|
|
$q = htmlspecialchars($question["text"]);
|
|
$q .= "<div class=\"time\">{$question['time']}</div>";
|
|
|
|
if ($question["responsetext"]) {
|
|
$q .= "<div class=\"response\">" . htmlspecialchars($question['responsetext']);
|
|
$q .= "<div class=\"time\">{$question['responsetime']}</div></div>";
|
|
}
|
|
|
|
if ($isResponding) {
|
|
if ($question["responsetext"]) {
|
|
$q .= "<h3>enter your edits</h3>";
|
|
} else {
|
|
$q .= "<h3>enter a response</h3>";
|
|
}
|
|
|
|
$q .= "
|
|
<form class=\"frm\" action=\"index.php\">
|
|
<input hidden name=\"id\" value=\"{$question['id']}\">
|
|
<input hidden name=\"page\" value=\"respond\">
|
|
<input hidden name=\"pw\" value=\"{$adminPassword}\">
|
|
<input id=\"passinput\" name=\"text\" value=\"{$question['responsetext']}\" autofocus required><br>
|
|
<button class=\"submitbutton\" type=\"submit\">send</button>
|
|
</form>
|
|
";
|
|
}
|
|
|
|
if ($includePermalink === 1) {
|
|
$q .= "<a class=\"permalink\" href=\"fetch.php?id={$question['id']}\">permalink</a>";
|
|
}
|
|
|
|
if ($isAdmin === 1) {
|
|
if ($question["ispublic"] === "t") {
|
|
$q .= "<a class=\"permalink\" href=\"index.php?page=respond&id={$question['id']}&pw={$adminPassword}\">";
|
|
|
|
if ($question["isrespondedto"] === "t") {
|
|
$q .= "edit response";
|
|
} else {
|
|
$q .= "respond";
|
|
}
|
|
|
|
$q .= "</a>";
|
|
} else {
|
|
$q .= "<a class=\"permalink\" href=\"index.php?page=mark&action=";
|
|
|
|
if ($question["isprivread"] === "t") {
|
|
$q .= "unread";
|
|
} else {
|
|
$q .= "read";
|
|
}
|
|
|
|
$q .= "&id={$question['id']}&pw={$adminPassword}\">mark ";
|
|
|
|
if ($question["isprivread"] === "t") {
|
|
$q .= "unread";
|
|
} else {
|
|
$q .= "read";
|
|
}
|
|
|
|
$q .= "</a>";
|
|
}
|
|
|
|
$q .= " / <a class=\"permalink\" href=\"index.php?page=delete&id={$question['id']}&pw={$adminPassword}\">delete</a>";
|
|
}
|
|
|
|
if ($question["iscwed"] === "t") {
|
|
$open = "";
|
|
|
|
if ($isResponding) {
|
|
$open = " open";
|
|
}
|
|
|
|
$q = "<details{$open}><summary>cw: " . htmlspecialchars($question["cw"]) . "</summary>{$q}</details>";
|
|
}
|
|
|
|
return "<div class=\"question\">{$q}</div>";
|
|
}
|
|
|
|
?>
|