PlainSQLiteBlog/pages/edit.php

60 lines
1.3 KiB
PHP

<?php
global $c;
UserAuth::require("is_admin");
$varUser = UserAuth::getUser();
$strId = Request::getArg(0);
// if ($strId == null || strlen($strId) < 1)
// $strId = "none";
if (Request::posts("content"))
Settings::set($strId, Request::getPosted("content"));
$strContent = Settings::get($strId, "");
?>
<?php if ($strId == null || strlen($strId) < 1): ?>
<?php $varRows = Settings::get(); ?>
<div>
<label>Edit</label>
</div>
<ul>
<?php foreach ($varRows as $k => $v): ?>
<li><a href="/edit/<?= $k; ?>"><?= $k; ?></a></li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<style>
textarea {
font-family: monospace;
}
</style>
<form method="post">
<div>
<label><?= $strId; ?></label>
</div>
<div>
<textarea
class="form-control border-0 shadow-none"
name="content"
placeholder="Enter content here..."
oninput="fnResize(this);"
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"><?= $strContent; ?></textarea>
</div>
<div><input type="submit" value="Save" /></div>
</form>
<?php endif; ?>