[dokuwiki] Re: Simpler way of adding pages and name spaces.
- From: James Eric Lawson <cire@xxxxxxxxxxxxxxxx>
- To: dokuwiki@xxxxxxxxxxxxx
- Date: Thu, 25 Aug 2005 15:15:47 -0700
I embed the html form in a dokuwiki page that details what to put in the
various fields. I'll just post the form here, without the instructions.
For simple page/namespace creation, of course, you only need a couple of
fields. Below, you'll find the html form, and below it, I'll put the
action, the nsr.php script, but note that the script is a
use-it-at-your-own-risk item--it's not secure. I'm somewhat new at php, so
criticism of the script, or the approach, is appropriate, if you're so
inclined.
HTML Form (embedded in a dokuwiki page):
<html>
<script language="javascript" type="text/javascript" charset="utf-8">
// <!--
function checkForm(TheForm) {
// ModelName, wikitext, Category, KeyTerms, AuthorName, AuthorEmail
if (TheForm.ModelName.value.length == 0) {
TheForm.ModelName.value = prompt("You forgot to enter the model name!");
return false;
}
if (TheForm.wikitext.value.length == 0) {
TheForm.wikitext.value = prompt("You forgot to enter the brief
description!");
return false;
}
if (TheForm.Category.value.length == 0) {
TheForm.Category.value = prompt("You forgot to enter the category!");
return false;
}
if (TheForm.KeyTerms.value.length == 0) {
TheForm.KeyTerms.value = prompt("You forgot to enter the key terms!");
return false;
}
if (TheForm.AuthorName.value.length == 0) {
TheForm.AuthorName.value = prompt("You forgot to enter the provider's
name!");
return false;
}
if (TheForm.AuthorEmail.value.length == 0) {
TheForm.AuthorEmail.value = prompt("You forgot to enter the provider's
email!");
return false;
}
return true;
} // end function checkForm
// -->
</script>
<form name="editform" method="post" action="/model/nsr.php"
enctype="multipart/form-data" accept-charset="utf-8" onsubmit="return
checkForm(this)">
<input type="hidden" name="id" value="" />
<input type="hidden" name="rev" value="" />
<input type="hidden" name="date" value="" />
<input type="hidden" name="prefix" value="" />
<input type="hidden" name="suffix" value="" />
<p>Model Name
<input type="text" name="ModelName" tabindex="1" /></p>
<p>Brief Description <br /> <textarea name="wikitext" id="wikitext"
cols="70" rows="2" class="edit" onchange="textChanged = true;"
onkeyup="summaryCheck();" tabindex="2">
</textarea>
</p>
<p>Category
<select name="Category" tabindex="3">
<option> </option>
<option>Cellular and Molecular Physiology</option>
<option>Integrative Physiology</option>
<option>Test Category</option>
</select></p>
<p>Sub-Category
<select name="Subcategory" tabindex="4">
<option> </option>
<option>Cellular Diffusion and Transport</option>
<option>Cellular Energetics</option>
<option>Cellular Electrophysiology</option>
<option>Gas Transport</option>
<option>Cardiovascular Physiology</option>
<option>Respiratory System</option>
<option>Metabolism</option>
<option>Test Subcategory</option>
</select>
<p>Key Terms
<input type="text" name="KeyTerms" tabindex="5" /></p>
<p>Provider Name
<input type="text" name="AuthorName" tabindex="6" /></p>
<p>Provider Email
<input type="text" name="AuthorEmail" tabindex="7" /></p>
<p><input type="submit" value="Save" name="do" title="ALT+A" accesskey="a"
onclick="textChanged=false" onkeypress="textChanged=false" tabindex="8" /></p>
</form>
</html>
PHP Script (nsr.php; use at your own risk):
<?php
/**
* Script for NSR-specific dokuwiki functions.
*
*/
// do the work
createModelEntry();
// include doku.php in the new context
include 'doku.php';
exit(0);
/**
* Specialized NSR functions
*/
// create and populate model entry page context
function createModelEntry() {
// values for SERVER, etc.
$wdokuphp = "/home/httpd/html/PHYSIOME/model/doku.php";
$wshrtdokuphp = "/model/doku.php";
// get some initial values for and from POST array
$wname = $_POST['ModelName'];
$wtxt = $_POST['wikitext'];
$wcat = $_POST['Category'];
$wsubcat = $_POST['Subcategory'];
$wdiag = $_POST['IllustrativeDiagram'];
$wsolu = $_POST['RepresentativeSolution'];
$wkeyt = $_POST['KeyTerms'];
$wproj = $_POST['JSimProject']; // model code or project file
$wauth = $_POST['AuthorName'];
$wmail = $_POST['AuthorEmail'];
// get some other initial values for and from REQUEST array
$wpagehit = $_REQUEST['pageHit'];
$wphpbb2 = $_REQUEST['phpbb2mysql_data'];
$wdokuwiki = $_REQUEST['DokuWiki'];
// compose the wiki id and put the model name in the wiki text
if (!empty($wname)) {
$wid = $wname.":model_index";
} else {
goBack(); // go back and get the model name
}
if (!empty($wtxt)) {
$wtxt = "====== ".$wname." ======\n\n".$wtxt;
} else {
goBack(); // go back and get the brief description
}
if (!empty($wsubcat)) {
$wid = $wsubcat.":".$wid; // may or may not exist
}
if (!empty($wcat)) {
$wid = $wcat.":".$wid;
} else {
goBack(); // go back and get the category
}
// fill out the wiki text
$wtxt .= "\n{{ name_of_diagram_image?100%|Illustrative Diagram}}";
$wtxt .= "\n\n[[url_of_applet_page|Run JSim Applet]]";
$wtxt .= "\n\n[[model_detail#Equations|Equations]]";
$wtxt .= "\n\nCode: {{name_of_mod_file|View}} the .mod file ";
$wtxt .= "or {{name_of_proj_file|download}} the JSim project file.";
$wtxt .= "\n\n{{ name_of_example_solution_image?100%|Example Solution}}";
$wtxt .= "\n\n[[model_detail#References]]";
$wtxt .= "\n\n[[model_detail#Related Models]]";
$wtxt .= "\n\n[[model_detail#Key Terms]]: ".$wkeyt;
$wtxt .=
"\n\n[[http://nsr.bioeng.washington.edu/PLN/Members/butterw/JSIMDOC1.6/Contents.stx/User_Intro.stx|JSim
Tutorial]]";
$wtxt .= "\n\n".$wauth." [[".$wmail."]]";
// newarray contains all the POST elements expected by dokuwiki
$newParray = array(
"id" => $wid,
"rev" => "",
"date" => "",
"prefix" => "",
"suffix" => "",
"wikitext" => $wtxt,
"do" => "Save",
"summary" => "created");
// replace POST superglobal array
$_POST = $newParray;
// newRarray contains all the REQUEST elements expected by dokuwiki
$newRarray = array(
"id" => $wid,
"rev" => "",
"date" => "",
"prefix" => "",
"suffix" => "",
"wikitext" => $wtxt,
"do" => "Save",
"summary" => "created",
"pageHit" => $wpagehit,
"phpbb2mysql_data" => $wphpbb2,
"DokuWiki" => $wdokuwiki);
// replace REQUEST superglobal array
$_REQUEST = $newRarray;
// replace some SERVER superglobal array values
$_SERVER['SCRIPT_FILENAME'] = $wdokuphp;
$_SERVER['REQUEST_URI'] = $shrtdokuphp;
$_SERVER['SCRIPT_NAME'] = $shrtdokuphp;
$_SERVER['PHP_SELF'] = $shrtdokuphp;
$_SERVER['PATH_TRANSLATED'] = $wdokuphp;
}
/**
* General purpose NSR functions
*/
function goBack() {
echo "<html>\n<pre>Use the back button to go back and fill in ";
echo "all the fields.</pre>\n</html>";
exit;
}
?>
Alex Polite wrote:
On 8/25/05, James Eric Lawson <cire@xxxxxxxxxxxxxxxx> wrote:
I embed a custom html form in a dokuwiki page; the html form action is to
run a custom php script which invokes doku.php after changing some $_POST
and $_REQUEST array values, etc. The result is page/namespace creation in
dokuwiki. This is more difficult for you, but easier for your coworkers.
It has served well as an introduction to the usual wiki page/namespace
creation processes. Let me know if you want more details.
Sounds very interesting. Could you please post the code?
alex
--
James Eric Lawson <cire@xxxxxxxxxxxxxxxx>
Senior Computer Specialist, Research Publications Editor
University of Washington, Box 357962, Seattle WA USA 98195
-------------------------------------------------------------------------
Poetry is a subject as precise as geometry. -- Gustave Flaubert
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist
- Follow-Ups:
- [dokuwiki] Re: Simpler way of adding pages and name spaces.
- From: Alex Polite
- References:
- [dokuwiki] Simpler way of adding pages and name spaces.
- From: Alex Polite
- [dokuwiki] Re: Simpler way of adding pages and name spaces.
- From: James Eric Lawson
- [dokuwiki] Re: Simpler way of adding pages and name spaces.
- From: Alex Polite
Other related posts:
- » [dokuwiki] Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
- » [dokuwiki] Re: Simpler way of adding pages and name spaces.
On 8/25/05, James Eric Lawson <cire@xxxxxxxxxxxxxxxx> wrote:
I embed a custom html form in a dokuwiki page; the html form action is to run a custom php script which invokes doku.php after changing some $_POST and $_REQUEST array values, etc. The result is page/namespace creation in dokuwiki. This is more difficult for you, but easier for your coworkers. It has served well as an introduction to the usual wiki page/namespace creation processes. Let me know if you want more details.
Sounds very interesting. Could you please post the code?
alex
-- James Eric Lawson <cire@xxxxxxxxxxxxxxxx> Senior Computer Specialist, Research Publications Editor University of Washington, Box 357962, Seattle WA USA 98195 ------------------------------------------------------------------------- Poetry is a subject as precise as geometry. -- Gustave Flaubert -- DokuWiki mailing list - more info at http://wiki.splitbrain.org/wiki:mailinglist
- [dokuwiki] Re: Simpler way of adding pages and name spaces.
- From: Alex Polite
- [dokuwiki] Simpler way of adding pages and name spaces.
- From: Alex Polite
- [dokuwiki] Re: Simpler way of adding pages and name spaces.
- From: James Eric Lawson
- [dokuwiki] Re: Simpler way of adding pages and name spaces.
- From: Alex Polite