%META:TOPICINFO{author="vinod" date="1091689125" format="1.0" version="1.8"}%
%META:TOPICPARENT{name="WebHome"}%
---+ Namespace Manager Add-On

This addon serves two mutually exclusive purposes:
	* Allows form-fills to create new topics. It supports create and view, create and edit workflows. It supports templates (with forms), forms and attachments as part of this functionality.
	* Allows flexible redirection of undefined topics which match one of the specified regular expression to corresponding actions specified. Examples of such actions (not all are yet supported) are: 
		* Redirect namespace such as =Main.USER_john= to a template. =ShowUserInfoTemplate= which will pull the information from database.
		* Create namespaces such as =Myinfo.MyLastModifiedTopics= and redirect them to searches (using a template)
		* Force a new topic such as =TaskXyz= to be created against a specific template meant for this purpose, without first going through a form.
		* As a standard default action: complete control over topic creation process (such as create only, create and edit etc.)


---++ Settings

%RED%Important Note: %ENDCOLOR% Please put =newtopic= script in the .htaccess with relevant access control requirements.

---+++ Usage 1: Form-fills for new topics
No settings.

---+++ Usage 2: Topic redirection table
Topic redirection table is used to specify the namespace redirections to actions, when user clicks on undefined topic link (usually a '?' infront of wiki word; can be changed with patches in TWiki:Codev/NewTopicLinkStylePatch to make this feature useable.) See the documentation in usage section below in Usage section.

%EDITTABLE{format="|select, 1, Enabled, Disabled|text, 30|select, 1, none, usetemplate, create, view, edit, oops|text, 20|text, 20|text, 20|text, 20|" changerows="on" }%
| *Enabled?* | *Pattern* | *Action* | *Arg1* | *Arg2* | *Arg3* | *Remarks* |
| Enabled | ^TWiki.ExampleNo[\d]+OfNamespaceManager | oops | TWiki.ExampleHandlerOfNamespaceManager |  |  | All topics with specified names directed to template |

Default action: Redirects to =edit= script (i.e. twiki standard for undefined links).


---++ Usage: Form fill approach to create topics

Design a Form in HTML as part of twiki topic, with action as =newtopic= which is provided by this plugin. (Full path to this twiki binary should be used.) The form variables can be:

*Standard Paramters*
| *Variable* | *Required/Optional* | *Type* | *Description* | *Default* |
| =topic=  | Required | string | Topic name | none |
| =web=  | Required | string | Web name | none |
| =text= | Required | string/textarea | Main text content | "" |
| =templatetopic= | Optional | string | Template for the new topic |  |
| =filepath= | Optional | File | Upload file interface |  |
| =filecomment= | Optional | String | Comment that goes with file |  |
| =createlink= | Optional | radio | Create a link at bottom of topic |  |
| =hidefile= | Optional | radio | Don't show the file in attachment table |

And any number of *User Defined Parameters* can be used. They can be referenced in the new template or topic with standard syntax =%<nop>URLPARAM{param}%=.

Notes:
	* Sometime =filename= param is required for uploaded file. (Not explored fully, not sure of use cases).
	* A variable =%PUTATTACHMENTHERE%= can be used in the template to provide a space hoder for =createlink= option.
	* Document attached to a template topic is (currently) ignored.
	* A form can be attached to template and its parameters can be defined within this topic creation form.


---+++ Demo
	* See example form: ExampleManagerTopicCreationForm, and corresponding template: NamespaceManagerExampleTemplate.

---++ Usage: Topic Redirection Table

A site-wide _topic redirection table_ is defined in this Addon topic, and defines Namespace-to-action Mapping. Currently any table row in this topic with first column matching " Enabled " is treated as a redirection definition. The columns are:

| *Column name* | *Purpose* | *Examples* |
| Enabled/Disabled | Only those which are enabled are considered |  |
| Pattern | Matches with string =$web.$topic= using perl regexp | ^TWiki.ExampleTopics[\w]+ |
| Action  | Currently available options: =showtemplate=, =edit=, =create= |  |
| Args	 | Comma separated list of args, depending on arguments (See table below) |  |

Action specific arguments and implementation information. New topic and web are defined using variables $newtopic and $newweb. Arguments will be in $web.$topic format.

| *action* | *Description* | *Argument 1* | *Argument 2* | *Argument 3* |
| =view=	| Redirect to =view= of =$arg1=. If no =arg1= is specified, same topic is used. | topic | |  |
| =create= | Create a =$newweb.$newtopic= using =$arg1= as new template, and then redirect to =view= of =$newweb.$newtopic=. | template | |  |
| =edit= | Create a =$newweb.$newtopic= using =$arg1= as new template, and then redirect to =edit= of =$newweb.$newtopic=. | template | |  |
| =usetemplate=	| Redirect to =view= of topic =$arg1=. | template | |  |
| =oops= | Show oops message for not being able to create the message | message | | |
| =execute= (Planned) | Execute the named script =$arg1= in =../scripts= directory, and make the output available to Template $arg2 as variable =executeresult= | script name | Template |  |

Variables available in redirected scripts:
| *Variable* | *Description* |
| =$virtualtopic= | The original (undefined) topic name which was redirected |
| =$virtualweb= | The original (undefined) web name which was redirected |

Currently only one action is supported: mapping to specified template. The intended topic name and web will be made available as URL parameters =virtualtopic= and =virtualweb= to this template.

---+++ Demo: Redirecting to template

Example: Test it with:
%SCRIPTURL%/newtopic/TWiki/ExampleNo99OfNamespaceManager


---++ Add-On Installation Instructions

__Note:__ You do not need to install anything on the browser to use this add-on. The following instructions are for the administrator who installs the add-on on the server where TWiki is running. 

	* Download the ZIP file from the Add-on Home (see below)
	* Unzip ==%TOPIC%.zip== in your twiki installation directory. Content:
	  | *File:* | *Description:* |
	  | ==data/TWiki/%TOPIC%.txt== | Plugin topic |
	  | ==data/TWiki/%TOPIC%.txt,v== |  |
	  | ==data/TWiki/NamespaceManagerExampleTemplate.txt== | Example template |
	  | ==data/TWiki/NamespaceManagerExampleTemplate.txt,v== |  |
	  | ==data/TWiki/NamespaceManagerAttachedForm.txt== | Example form attached to template |
	  | ==data/TWiki/NamespaceManagerAttachedForm.txt,v== |  |
	  | ==bin/newtopic== | Add-on script |
	  | ==templates/oopsnewtopic.tmpl== | Add-on script |

	* Test if the installation was successful:
		* Redirection of topics: Use the links above to see if redirection worked.
		* Form creation usage: Use the example form specified earlier to create new topic.

---++ Add-On Info

|  Add-on Author: | TWiki:Main/VinodKulkarni |
|  Add-on Version: | 03 Aug 2004 (v0.9) - Tested on TWiki:Codev/TWikibeta20040507 |
|  Change History: | <!-- versions below in reverse order -->&nbsp; |
|  03 Aug 2004: | Initial version |
|  CPAN Dependencies: | none |
|  Other Dependencies: | none |
|  Perl Version: | 5.005 |
|  License: | GPL |
|  Add-on Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% |
|  Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev |

__Related Topic:__ %TWIKIWEB%.TWikiAddOns

-- TWiki:Main/VinodKulkarni - 03 Aug 2004

%META:TOPICMOVED{by="vinod" date="1091609302" from="TWiki.NoEditAddOn" to="TWiki.NamespaceManagerAddOn"}%
