aw schriftzug.png aw logo 60x60.png

RenderSimpleTopicCreator
TopicFunction to display a simple form to create a new topic

2019-05-02 - 09:27 | Version 4 |

Documentation

This function renders a topic creator form that holds a set of initial input elements to create a topic.

Parameters
  • TEXT: headline text; defaults to "Create a new INCLUDINGTOPIC"
  • LABEL: label of the TopicTitle field, defaults to "Title"
  • BUTTONTEXT: text on the twisty buttinm; default New
  • VALUE: initial value of the title input field (optional)
  • VALUES: map of initial values to formfields; format is <fieldName1>=<value1>;<fieldName2>=<value2>;...
  • FORM: DataForm to be used when creating a topic, defaults to INCLUDINGWEB.INCLUDINGTOPIC
  • TEMPLATE: TopicTemplate to be used (optional)
  • TYPE: initial TopicType value, defaults to values predefined in the form definition
  • PARENT: parent topic for the new topic, defaults to the BASETOPIC
  • WHITEBOARD: switch on/off the whiteboard textarea
  • EXTRA: additional formfields
  • SCRIPT: script to be used to create the topic, eg save or edit, defaults to edit
  • EDITOR: TopicView to be used as an edit_template

Implementation

%STARTINCLUDE%%IF{"'%BASEWEB%.%BASETOPIC%' allows 'CREATE'" 
   then="$percntDBCALL{\"Applications.RenderSimpleTopicCreator\"
            section=\"form\"
            TEXT=\"%TEXT{default="%TRANSLATE{"Create a new [_1]" args="%INCLUDINGTOPIC%"}%"}%\"
            LABEL=\"%LABEL{default="%TRANSLATE{"Title"}%"}%\"
            BUTTONTEXT=\"%BUTTONTEXT{default="%TRANSLATE{"New"}%"}%\"
            VALUE=\"%VALUE{default=""}%\"
            VALUES=\"%VALUES{default=""}%\"
            FORM=\"%FORM{default="%INCLUDINGWEB%.%INCLUDINGTOPIC%"}%\"
            TEMPLATE=\"%TEMPLATE%\"
            TYPE=\"%TYPE{
                  default="%RENDERFORMDEF{
                  form="%FORM{default="%INCLUDINGWEB%.%INCLUDINGTOPIC%"}%"
                  fields="TopicType"
                  format="$value"
               }%"
            }%\"
            PARENT=\"%PARENT{default="%BASETOPIC%"}%\"
            WHITEBOARD=\"%WHITEBOARD{default="on"}%\"
            EXTRA=\"%EXTRA{default="<!-- -->"}%\"
            SCRIPT=\"%SCRIPT{default="edit"}%\"
            EDITOR=\"%EDITOR{default="%FORMFIELD{"Editor" topic="%FORM{default="%INCLUDINGWEB%.%INCLUDINGTOPIC%"}%"}%"}%\"
         }$percnt"
}%%STOPINCLUDE%

form

%STARTSECTION{"form"}%%TWISTY{
    link="%BUTTON{
    "%BUTTONTEXT%"
    icon="fa-plus"
  }%%CLEAR%"
  mode="div"
}%

<form class='createTopicForm jqValidate' action="%SCRIPTURLPATH{"%SCRIPT%"}%/%BASEWEB%/" method="post">
<div class='foswikiFormSteps'>
<input type="hidden" name="web" value="%BASEWEB%" />
<input type="hidden" name="onlynewtopic" value="on" />
<input type="hidden" name="action" value="%IF{"$WHITEBOARD='off'" then="form"}%" />
<input type="hidden" name="onlywikiname" value="off" />
<input type="hidden" name="topicparent" value="%PARENT%" />
<input type="hidden" name="templatetopic" value="%TEMPLATE{default="%FORMFIELD{"Template" topic="%FORM%"}%"}%" />
<input type="hidden" name="formtemplate" value="%FORM%" />
<input type="hidden" name="template" value="%EDITOR%" />
%DBCALL{"%WEB%.%TOPIC%" 
   section="topicnaming" 
   mode="%FORMFIELD{"TopicNamingMode" topic="%FORM%"}%"
   form="%FORM%"
   value="%VALUE%"
}%<!-- -->
%EXTRA%
%RENDERFOREDIT{
  form="%FORM%"
  topic="%TEMPLATE{default=""}%"
  fields="%FORMATLIST{"%VALUES%"
      split=";"
      pattern="(.*)=(.*)"
      format="$1"
      separator=","
  }%, no such thing"
  exclude="^(TopicType%RENDERFORDISPLAY{
                 form="%FORM%"
                 topic="%TEMPLATE{default=""}%"
                 includeattr="\bc\b"
                 format="$name"
                 header="|"
                 separator="|"
              }%)$"
  format="<input type='hidden' value='$value' name='$name' />$n"
  %FORMATLIST{"%VALUES%"
      separator=" "
      split=";"
      pattern="(.*)=(.*)"
      format="$1_value=\"$2\""
  }%
}%<!-- -->
%IF{"$'TEXT'=''"
   then="<!-- -->"
   else="<h2 >%TEXT%</h2>"
}%
%RENDERFOREDIT{
  form="%FORM%"
  topic="%TEMPLATE{default=""}%"
  fields="TopicTitle"
  excludeattr="\bH\b"
  format="<div class='foswikiFormStep'><h3>$title:$mandatory</h3>$edit<div class='foswikiFormDescription'>$description</div></div>"
  TopicTitle_value="%VALUE{default=""}%"
  TopicTitle_title="%LABEL%"
}%
%RENDERFOREDIT{
  form="%FORM%"
  topic="%TEMPLATE{default=""}%"
  exclude="^(TopicType|TopicTitle)$"
  includeattr="\bc\b"
  Summary_value=""
  format="<div class='foswikiFormStep'><h3>$title:$mandatory</h3>$edit<div class='foswikiFormDescription'>$description</div></div>"
  %FORMATLIST{"%VALUES%"
      separator=" "
      split=";"
      pattern="(.*)=(.*)"
      format="$1_value=\"$2\""
  }%
}%
%RENDERFOREDIT{
  form="%FORM%"
  topic="%TEMPLATE{default=""}%"
  fields="TopicType,WikiApplication,Summary"
  excludeattr="\bc\b"
  WikiApplication_value="%FLEXWEBLIST{include="%BASEWEB%" format="$name"}%" 
  TopicType_value="%TYPE%"
  Summary_value=""
  header=""
  footer=""
  format="<input type='hidden' name='$name' value='$value' />"
  separator="$n"
}%
  <div class="foswikiFormStep foswikiFormButtons">
    %BUTTON{"%TRANSLATE{"Submit"}%" type="submit" icon="fa-check"}%
    %CLEAR%
  </div>
</div>
</form> 

%ENDTWISTY%%JQREQUIRE{"wikiword"}%%ENDSECTION{"form"}%

%STARTSECTION{"topicnaming"}%%IF{"'%mode%'=~'^(default)?$'"
   then="<input type='hidden' name='topic' class='jqWikiWord' data-source='input[name=TopicTitle]' data-transliterate='true' value='%value%' />$n"
}%%IF{"'%mode%'='template'"
   then="<input type='hidden' name='topic' value='%FORMFIELD{"TopicNameTemplate" topic="%form%"}%' value='%value%' />$n"
}%%IF{"'%mode%'='derived'"
   then="<input type='hidden' name='topic' class='jqWikiWord' value='%value%' $percntDBQUERY{
                topic=\"%form%\"
                format=\"data-source='$formfield(TopicNameSource)' \
                         data-prefix='$formfield(TopicNamePrefix)' \
                         data-suffix='$formfield(TopicNameSuffix)' \
                         data-transliterate='$formfield(TopicNameTransliterate)'\"
              }$percnt/>"
}%%ENDSECTION{"topicnaming"}%

Test

Create a new Topic

Title:

Summary:

Calls to 'RenderSimpleTopicCreator'

Copyright

© 2006-2015 Michael Daum http://michaeldaumconsulting.com

This file is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. For more details read the LICENSE.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Impressum © Alexander Weimer GmbH