summaryrefslogtreecommitdiff
path: root/forum/utils/editor.php
diff options
context:
space:
mode:
authordeva <deva>2011-11-01 09:32:21 +0000
committerdeva <deva>2011-11-01 09:32:21 +0000
commit42c62cb041a2b2b95c9cda0c20fcf70334fd244c (patch)
tree38371eb37ff7348585ee84438b326c25055e2cbe /forum/utils/editor.php
parent208e3b642149a9ac701a43397d31990f9b27ca79 (diff)
Rewl og krat... needs cleaning up - after port to GIT.origin
Diffstat (limited to 'forum/utils/editor.php')
-rw-r--r--forum/utils/editor.php236
1 files changed, 97 insertions, 139 deletions
diff --git a/forum/utils/editor.php b/forum/utils/editor.php
index 36fb39d..768bce9 100644
--- a/forum/utils/editor.php
+++ b/forum/utils/editor.php
@@ -1,154 +1,112 @@
-<script language="JavaScript">
-function addcontent(text) {
- document.post_form.message.value += text;
- document.post_form.message.focus();
-}
-</script>
<?php
-include_once($UTIL_DIR . "/error.php");
-include_once($UTIL_DIR . "/convert.php");
-$title = "En titel";
-$message = "Something useful";
+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";
-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) {
-
- switch($task) {
- case "new":
- $title = "Title";
- $message = "Message";
- break;
+ $title = "En titel";
+ $message = "Something useful";
- case "reply":
- $title = "Re: " . $post->title;
+ 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 = "";
- break;
+
+ switch($task) {
+ case "new":
+ $title = "Title";
+ $message = "Message";
+ break;
- case "edit":
- $title = $post->title;
- $message = $post->message;
- break;
+ case "reply":
+ if(substr($post->title, 0, 4) != "Re: ")
+ $title = "Re: " . $post->title;
+ else $title = $post->title;
+ $message = "";
+ break;
- case "quote":
- $title = "Re: " . $post->title;
- $user = $users->getUser($post->user);
- $message = "[quote title=" . $user->name . " wrote on " .date("r", $post->date) ."]" . $post->message . "[/quote]";
- break;
+ case "edit":
+ $title = $post->title;
+ $message = $post->message;
+ break;
- default:
- error("No mode supplied!");
- break;
- }
-?>
-<form style="clear: both;" name="post_form" method="post" action="?mode=edit&amp;task=<?php echo $task ?>&amp;fid=<?php echo $fid; ?>&amp;tid=<?php echo $tid; ?>&amp;pid=<?php echo $pid; ?>" onSubmit="javascript: document.post_form.btn_submit.disabled = true;">
-<?php /*
-<a href="javascript: insertTag(document.post_form.message, ';-)', '');"><img border="0" alt=";-)" src="gfx/smileys/wink.gif"/></a>
-<a href="javascript: insertTag(document.post_form.message, ';-D', '');"><img border="0" alt=";-)" src="gfx/smileys/biggrinn.gif"/></a>
-<a href="javascript: insertTag(document.post_form.message, '\\m/', '');"><img border="0" alt=";-)" src="gfx/smileys/headbanger.gif"/></a>
-<a href="javascript: insertTag(document.post_form.message, '>:O', '');"><img border="0" alt=";-)" src="gfx/smileys/growler.gif"/></a>
-<a href="javascript: insertTag(document.post_form.message, '[b]', '[/b]');"><strong>B</strong></a>
-<a href="javascript: insertTag(document.post_form.message, '[i]', '[/i]');"><em>I</em></a>
-<a href="javascript: insertTag(document.post_form.message, '[u]', '[/u]');"><u>U</u></a>
-<a href="javascript: insertTag(document.post_form.message, '[align=left]', '[/align]');">[L&nbsp;&nbsp;]</a>
-<a href="javascript: insertTag(document.post_form.message, '[align=center]', '[/align]');">[&nbsp;C&nbsp;]</a>
-<a href="javascript: insertTag(document.post_form.message, '[align=right]', '[/align]');">[&nbsp;&nbsp;R]</a>
-<a href="javascript: url_insert();">URL</a>
-<a href="javascript: email_insert();">E-Mail</a>
-<a href="javascript: image_insert();">Image</a>
-<a href="javascript: insertTag(document.post_form.message, '[quote]', '[/quote]');">"Q"</a>
-<a href="javascript: insertTag(document.post_form.message, '[code]', '[/code]');">c++</a>
+ 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;
-<select name="fnt_size" onchange="javascript:insertTag(document.post_form.message, '[size='+document.post_form.fnt_size.options[this.selectedIndex].value+']', '[/size]'); document.post_form.fnt_size.options[0].selected=true">
-<option value="" selected="selected">Size</option>
-<option value="1">1</option>
-<option value="2">2</option>
-<option value="3">3</option>
-<option value="4">4</option>
-<option value="5">5</option>
-<option value="6">6</option>
-<option value="7">7</option>
-</select>
+ default:
+ $str .= error("No mode supplied!");
+ return $str;
+ break;
+ }
-<select name="fnt_color" onchange="javascript:insertTag(document.post_form.message, '[color='+document.post_form.fnt_color.options[this.selectedIndex].value+']', '[/color]'); document.post_form.fnt_color.options[0].selected=true">
-<option value="">Color</option>
-<option value="skyblue" style="color: skyblue;">Sky Blue</option>
-<option value="royalblue" style="color: royalblue;">Royal Blue</option>
-<option value="blue" style="color: blue;">Blue</option>
-<option value="darkblue" style="color: darkblue;">Dark Blue</option>
-<option value="orange" style="color: orange;">Orange</option>
-<option value="orangered" style="color: orangered;">Orange Red</option>
-<option value="crimson" style="color: crimson;">Crimson</option>
-<option value="red" style="color: red;">Red</option>
-<option value="firebrick" style="color: firebrick;">Firebrick</option>
-<option value="darkred" style="color: darkred;">Dark Red</option>
-<option value="green" style="color: green;">Green</option>
-<option value="limegreen" style="color: limegreen;">Lime Green</option>
-<option value="seagreen" style="color: seagreen;">Sea Green</option>
-<option value="deeppink" style="color: deeppink;">Deep Pink</option>
-<option value="tomato" style="color: tomato;">Tomato</option>
-<option value="coral" style="color: coral;">Coral</option>
-<option value="purple" style="color: purple;">Purple</option>
-<option value="indigo" style="color: indigo;">Indigo</option>
-<option value="burlywood" style="color: burlywood;">Burly Wood</option>
-<option value="sandybrown" style="color: sandybrown;">Sandy Brown</option>
-<option value="sienna" style="color: sienna;">Sienna</option>
-<option value="chocolate" style="color: chocolate;">Chocolate</option>
-<option value="teal" style="color: teal;">Teal</option>
-<option value="silver" style="color: silver;">Silver</option>
-</select>
+ $str .= "<form style=\"clear: both;\" name=\"post_form\" method=\"post\" action=\"?mode=edit&amp;task=" .
+ $task . "&amp;fid=" . $fid . "&amp;tid=" . $tid . "&amp;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";
-<select name="fnt_face" onchange="javascript:insertTag(document.post_form.message, '[font='+document.post_form.fnt_face.options[this.selectedIndex].value+']', '[/font]'); document.post_form.fnt_face.options[0].selected=true">
-<option value="">Font</option>
-<option value="Arial" style="font-family: Arial;">Arial</option>
-<option value="Times" style="font-family: Times;">Times</option>
-<option value="Courier" style="font-family: Courier;">Courier</option>
-<option value="Century" style="font-family: Century;">Century</option>
-</select> */ ?>
- <p>
- Title:
- <input name="title" style="width: 300px;" value="<?php echo convert_xml($title);?>"/>
- </p>
- <p>
-<?php
-include_once($UTIL_DIR . "/smileys.php");
-global $smileys;
-foreach($smileys as $smiley) {
- $smile = $smiley[0][0];
- if($smile == "\\m/") $smile = "\\\\m/";
- echo " <a href=\"javascript:addcontent('" . $smile . "');\"><img style=\"border: 0px\" alt=\"\" src=\"gfx/smileys/" . $smiley[1] . "\"/></a>";
-}
-?>
- </p>
- <p>
- <textarea rows="20" cols="65" name="message" onkeyup="storeCaret(this);" onclick="storeCaret(this);" onselect="storeCaret(this);"><?php echo convert_xml($message); ?></textarea>
- </p>
- <p>
- <strong>To make a link, simply type the URL, and the system will
- automagically transform it into an anchor (remember the
- <em>http://</em> part)</strong>.<br/>
- Example: http://www.example.com<br/>
- </p>
- <p>
- <strong>To insert an image, simply type the URL to that image, it will
- automagically be transformed into an image, with a link to the
- original image (again, remember the <em>http://</em> part).</strong><br/>
- Example: http://www.example.com/image.jpg
- </p>
- <p>
- <button type="submit">Post</button>
- </p>
-</form>
-<?php
- if($pid != -1) $posts->show();
+ 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 {
- error("Message " . $pid . " not found!");
+ $str .= error("No message supplied!");
}
-} else {
- error("No message supplied!");
-}
+ return $str;
+}
?>