function EditCreateForm($do, $defaultPage) { if ($_GET[editor] != 'text') { loadWysiwyg(); } $fileName = pageDataDir(getSlug($defaultPage)); $slug = $_GET[slug]; if ($do == 'edit') { $insidebar = inSidebar($defaultPage); $formAction = "?action=edit&slug={$slug}"; $fileContent = file_exists($fileName) ? htmlentities(file_get_contents($fileName)) : "no content yet"; $submitButton = 'Save Page'; $title = getTitle($defaultPage); } else { $insidebar = true; //default is sidebar $formAction = "?action=addpage"; $fileContent = ''; $submitButton = 'Add Page'; $title = ''; } echo "<form action='{$formAction}' method=post>"; echo "Page Title : <input type='text' value='{$title}' name='title'>"; echo "Type of page : \r\n\t\t\t\t<select name='insidebar'>\r\n\t\t\t\t\t<option value=1 " . ($insidebar == true ? ' selected ' : '') . ">Sidebar Page</option>\r\n\t\t\t\t\t<option value=0 " . ($insidebar == false ? ' selected ' : '') . ">Normal Page</option>\r\n\t\t\t\t</select>\r\n\t\t\t <br />Content:<br />"; echo "<textarea name=content rows=20 cols=70 id='editbox' class='editbox'>{$fileContent}</textarea>"; echo "<br /><input type=submit value='{$submitButton}' name=save>"; echo "</form>"; if (!isloadedWysiwyg()) { echo "<input type='button' onclick='makebig(\"editbox\")' value='Bigger Input'>"; echo "<input type='button' onclick='makesmall(\"editbox\")' value='Smaller Input'>"; echo "<script langua='javascript'>\r\n\t\t\t\t\tfunction makebig(id) {\r\n\t\t\t\t\tobj = document.getElementById(id);\r\n\t\t\t\t\tif( obj.rows < 40 ) obj.rows+= 5;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tfunction makesmall(id) {\r\n\t\t\t\t\tobj = document.getElementById(id);\r\n\t\t\t\t\tif( obj.rows > 15 ) obj.rows-= 5;\r\n\t\t\t\t\t}\r\n\t\t\t\t </script>"; } else { $s = $_SERVER['QUERY_STRING'] . '&editor=text'; echo "<input type='button' onclick='window.location=\"?{$s}\"' value='Text Edit'>"; } showWysiwyg(); }
function showWysiwyg() { if (!isloadedWysiwyg()) { return; } $editor = NANO_WYSIWYG_EDITOR; $editor(); }