<?php function editor() { global $UTIL_DIR, $FORUMS_DIR, $users, $fid, $tid, $pid, $smileys, $task; include_once($UTIL_DIR . "/error.php"); include_once($UTIL_DIR . "/convert.php"); $str = ""; $str .= "<script language=\"JavaScript\">\n"; $str .= "function addcontent(text) {\n"; $str .= " document.post_form.message.value += text;\n"; $str .= " document.post_form.message.focus();\n"; $str .= "}\n"; $str .= "</script>\n"; $title = "En titel"; $message = "Something useful"; if($fid && $tid && $pid) { include_once("posts.php"); $posts = new Posts($FORUMS_DIR . "/" . $fid . "/" . $tid . ".xml"); if($pid != -1) $post = $posts->getPost($pid); if($post || $pid == -1) { $title = ""; $message = ""; switch($task) { case "new": $title = "Title"; $message = "Message"; break; case "reply": if(substr($post->title, 0, 4) != "Re: ") $title = "Re: " . $post->title; else $title = $post->title; $message = ""; break; case "edit": $title = $post->title; $message = $post->message; break; case "quote": if(substr($post->title, 0, 4) != "Re: ") $title = "Re: " . $post->title; else $title = $post->title; $user = $users->getUser($post->user); $message = "[quote title=" . $user->name . " wrote on " . date("r", $post->date) ."]" . $post->message . "[/quote]"; break; default: $str .= error("No mode supplied!"); return $str; break; } $str .= "<form style=\"clear: both;\" name=\"post_form\" method=\"post\" action=\"?mode=edit&task=" . $task . "&fid=" . $fid . "&tid=" . $tid . "&pid=" . $pid . "\" onSubmit=\"javascript: document.post_form.btn_submit.disabled = true;\">\n"; $str .= " <p> Title: <input name=\"title\" style=\"width: 300px;\" value=\"" . convert_xml($title) . "\"/></p>\n"; $str .= " <p>\n"; include_once($UTIL_DIR . "/smileys.php"); foreach($smileys as $smiley) { $smile = $smiley[0][0]; if($smile == "\\m/") $smile = "\\\\m/"; $str .= " <a href=\"javascript:addcontent('" . $smile . "');\"><img style=\"border: 0px\" alt=\"\" src=\"gfx/smileys/" . $smiley[1] . "\"/></a>"; } $str .= " </p>\n"; $str .= " <p>\n"; $str .= " <textarea rows=\"20\" cols=\"65\" name=\"message\" onkeyup=\"storeCaret(this);\"". " onclick=\"storeCaret(this);\" onselect=\"storeCaret(this);\">". convert_xml($message) . "</textarea>\n"; $str .= " </p>\n"; $str .= " <p>\n"; $str .= " <strong>To make a link, simply type the URL, and the system will\n"; $str .= " automagically transform it into an anchor (remember the\n"; $str .= " <em>http://</em> part)</strong>.<br/>\n"; $str .= " Example: http://www.example.com<br/>\n"; $str .= " </p>\n"; $str .= " <p>\n"; $str .= " <strong>To insert an image, simply type the URL to that image, it will\n"; $str .= " automagically be transformed into an image, with a link to the\n"; $str .= " original image (again, remember the <em>http://</em> part).</strong><br/>\n"; $str .= " Example: http://www.example.com/image.jpg\n"; $str .= " </p>\n"; $str .= " <p>\n"; $str .= " <button type=\"submit\">Post</button>\n"; $str .= " </p>\n"; $str .= "</form>\n"; if($pid != -1) $str .= $posts->show(); } else { $str .= error("Message " . $pid . " not found!"); } } else { $str .= error("No message supplied!"); } return $str; } ?>