Source for file block.form.php
Documentation is available at block.form.php
* Smarty {form} block plugin
* - ipackage (optional) - package where we should direct the form after submission
* - ifile (optional) - file that is targetted
* - ianchor (optional) - move to anchor after submitting
* if neither are set, SCRIPT_NAME is used as url
* - legend if set, it will generate a fieldset using the input as legend
* @uses smarty_function_escape_special_chars()
* @todo somehow make the variable that is contained within $iselect global --> this will allow importing of outside variables not set in $_REQUEST
global $gBitSystem, $gSniffer;
if( !isset ( $pParams['method'] ) ) {
$pParams['method'] = 'post';
if( $gBitSystem->isLive() && isset ( $pParams['secure'] ) && $pParams['secure'] ) {
// This is NEEDED to enforce HTTPS secure logins!
$url = 'https://' . $_SERVER['HTTP_HOST'];
// services can add something to onsubmit
if( $gBitSmarty->get_template_vars( 'serviceOnsubmit' ) ) {
$onsubmit .= $gBitSmarty->get_template_vars( 'serviceOnsubmit' ). ";";
foreach( $pParams as $key => $val ) {
if( $key == 'ipackage' ) {
$legend = '<legend>'. tra( $val ). '</legend>';
// this is needed for backwards compatibility since we sometimes pass in a url
if( substr( $val, 0, 4 ) == 'http' ) {
if( isset ( $pParams['secure'] ) && $pParams['secure'] && ( substr( $val, 0, 5 ) != 'https' )) {
$atts .= $key. '="'. $val. '" ';
$url = $_SERVER['SCRIPT_NAME'];
} else if( $url == 'https://' . $_SERVER['HTTP_HOST'] ) {
$url .= $_SERVER['SCRIPT_NAME'];
$onsub = ( !empty( $onsubmit ) ? ' onsubmit="'. $onsubmit. '"' : '' );
$ret = '<form action="'. $url. ( !empty( $pParams['ianchor'] ) ? '#'. $pParams['ianchor'] : '' ). '" '. $atts. $onsub. '>';
$ret .= isset ( $legend ) ? '<fieldset>'. $legend : ''; // adding the div makes it easier to be xhtml compliant
$ret .= isset ( $legend ) ? '</fieldset>' : ''; // close the open tags
global $gSmartyFormHorizontal;
// global var other plugin functions will pick up to add proper col-XX-YY styling for horizontal forms
$gSmartyFormHorizontal = ( !empty( $pParams['class'] ) && strpos( $pParams['class'], 'form-horizontal' ) !== FALSE );
|