156 lines
5.7 KiB
PHP
156 lines
5.7 KiB
PHP
<?
|
|
$id = get_id();
|
|
$search = get_search_args();
|
|
|
|
if ($action == 'preview')
|
|
$result = get_post_data(TRUE, TRUE);
|
|
else if ($action && is_numeric($id))
|
|
$result = get_query($id);
|
|
if (isset($result) && is_array($result))
|
|
extract($result[0], EXTR_OVERWRITE);
|
|
|
|
// Print any validation error messages
|
|
if (count($validate) !== 0) {
|
|
echo '<ul class="error-box">Please correct the following errors:';
|
|
foreach ($validate as $validate_key=>$validate_value) {
|
|
echo '<li>'.$validate_value.'</li>';
|
|
}
|
|
echo '</ul>';
|
|
}
|
|
|
|
?>
|
|
|
|
<form method="post" enctype="multipart/form-data" onsubmit="return review()" action="">
|
|
|
|
<div>
|
|
<label<?= isset($validate['title']) ? ' class="red"' : '' ?> for="title">Title:</label>
|
|
<input type="text" id="title" name="title" maxlength="150" value="<?= isset($title) ? $title : '' ?>" />
|
|
<span class="required"> *</span>
|
|
<br class="clear" />
|
|
</div>
|
|
|
|
<div>
|
|
<label<?= isset($validate['author']) ? ' class="red"' : '' ?> for="author">Author:</label>
|
|
<input type="text" name="author" id="author" value="<?= isset($author) ? $author : '' ?>" maxlength="150" />
|
|
<span class="required"> *</span>
|
|
<br class="clear" />
|
|
</div>
|
|
|
|
<div>
|
|
<label<?= isset($validate['email']) ? ' class="red"' : '' ?> for="email">Email address:</label>
|
|
<input type="text" name="email" id="email" maxlength="150" value="<?= isset($email) ? $email : ''?>" />
|
|
<br class="clear" />
|
|
<div class="note">(An email address where editors can reach the author.)</div>
|
|
<br class="clear" />
|
|
</div>
|
|
|
|
<div class="tab<?= isset($validate['story']) ? ' red' : '' ?>" onclick="showHide('text');">Text:</div>
|
|
<div class="tab<?= isset($validate['upload']) ? ' red' : '' ?>" onclick="showHide('upload');">Image:</div>
|
|
<div id="wordcounter" class="counter" style="display: none;">0 words</div>
|
|
|
|
<div class="textarea">
|
|
<div id="textparent">
|
|
<textarea name="story" id="story" rows="20" cols="50">
|
|
<?
|
|
echo (isset($story) ? $story : '')
|
|
?>
|
|
</textarea>
|
|
<br class="clear" />
|
|
<div class="note">(To get line-breaks—as in poetry—instead of paragraph breaks, hit shift-enter instead of enter.)</div>
|
|
</div>
|
|
<div class="upload" id="uploadparent" style="display: none;"><div>
|
|
<?
|
|
if (isset($file_src) || isset($img)) {
|
|
if (isset($file_src)) {
|
|
echo ' <input type="hidden" id="uploaded" name="uploaded" value="'.$file_src.'" />';
|
|
} else {
|
|
echo ' <input type="hidden" id="uploaded" name="uploaded" value="'.$id.'" />';
|
|
}
|
|
echo ' <div class="in-note">If you are happy with the image above, click Submit. Otherwise, upload a new image:</div>';
|
|
} else {
|
|
echo ' <div class="in-note">You may upload an image of 100,000 pixels instead of text:</div>';
|
|
}
|
|
?>
|
|
<br class="clear" />
|
|
<input type="file" name="upload" id="upload" />
|
|
<br class="clear" />
|
|
<?
|
|
if (isset($file_src) || isset($img)) {
|
|
echo ' <div>';
|
|
echo ' <div class="remove">';
|
|
echo ' <input id="remove_img" name="remove_img" type="hidden" value="0" />';
|
|
echo ' <a href="javascript:toggle_remove()">';
|
|
echo ' <img id="remove_img_icon" src="/graphics/trashcan.png" border="0" title="Mark photo for deletion." /></a>';
|
|
echo ' </div>';
|
|
echo ' <div class="in-note">If you wish to remove the image altogether, and replace it with text, click the bin icon: <br />';
|
|
echo ' (Click it again to restore the image.)</div>';
|
|
echo ' </div>';
|
|
}
|
|
?>
|
|
</div></div>
|
|
<br class="clear" />
|
|
</div>
|
|
|
|
<? if ($is_admin) { ?>
|
|
<div>
|
|
<label<? isset($validate['comments']) ? ' class="red"' : '' ?> for="comments">Comments:</label>
|
|
<input type="text" name="comments" id="comments" maxlength="150" value="<?= isset($comments) ? $comments : '' ?>" />
|
|
<br class="clear" />
|
|
</div>
|
|
<input type="hidden" id="editor" name="editor" value="<?= $username ?>" />
|
|
<? } else { ?>
|
|
<input type="hidden" id="editor" name="editor" value="original author" />
|
|
<? } ?>
|
|
|
|
<div style="display: none;">
|
|
<input type="hidden" id="date" name="date" value="<?= isset($date) ? $date : '' ?>" />
|
|
<input type="hidden" id="id" name="id" value="<?= isset($id) ? $id : '' ?>" />
|
|
</div>
|
|
|
|
<?
|
|
if (!$is_admin && (($action == "") || isset($validate['captcha']))) {
|
|
echo '<div><br class="clear" /></div>';
|
|
echo '<div class="g-recaptcha" data-sitekey="'.htmlspecialchars(config('RECAPTCHA_SITE_KEY')).'"></div>';
|
|
}
|
|
|
|
if ($is_admin) {
|
|
$checked = isset($hidden) && !empty($hidden) ? ' checked' : '';
|
|
echo '<div>';
|
|
echo '<label'.(isset($validate['hidden']) ? ' class="red"' : '').' for="hidden">Hidden:</label>';
|
|
echo '<input type="checkbox" name="hidden" id="hidden"'.$checked.' />';
|
|
echo '<br class="clear" />';
|
|
echo '</div>';
|
|
}
|
|
?>
|
|
<div class="submission">
|
|
<?
|
|
if (isset($queue) && $is_admin) {
|
|
echo '<button type="submit" id="preview" name="action" value="save">Save in queue</button>';
|
|
} else {
|
|
echo '<button type="submit" id="preview" name="action" value="preview">Preview</button>';
|
|
}
|
|
if ((count($validate) === 0 && $action == "preview") || ($is_admin && !$action)){
|
|
$submit_text = $is_admin ? "Submit to queue" : "Submit";
|
|
echo '<button type="submit" id="submit" name="action" value="submit">'.$submit_text.'</button>';
|
|
}
|
|
if (($id || $action == "edit") || $is_admin) {
|
|
echo '<button type="submit" id="submit" name="action" value="post">Post!</button>';
|
|
if ($id && $is_admin)
|
|
echo '<button type="submit" onclick="javascript:return do_delete();" id="delete" name="action" value="delete">Delete</button>';
|
|
}
|
|
?>
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<?
|
|
echo '<script type="text/javascript">'."\n";
|
|
if (isset($file_src) || isset($img) || isset($validate['upload'])) {
|
|
echo " showHide('upload')\n";
|
|
} else {
|
|
echo " var wordcounter = document.getElementById('wordcounter');\n";
|
|
echo " wordcounter.style.display = 'block';\n";
|
|
}
|
|
echo "</script>\n";
|
|
?>
|