Smarty
[ class tree: Smarty ] [ index: Smarty ] [ all elements ]

Source for file block.form.php

Documentation is available at block.form.php

  1. <?php
  2. /**
  3.  * Smarty plugin
  4.  * @package Smarty
  5.  * @subpackage plugins
  6.  */
  7.  
  8. /**
  9.  * Smarty {form} block plugin
  10.  *
  11.  * Type:     block
  12.  * Name:     form
  13.  * Input:
  14.  *           - ipackage    (optional) - package where we should direct the form after submission
  15.  *           - ifile       (optional) - file that is targetted
  16.  *           - ianchor     (optional) - move to anchor after submitting
  17.  *                         if neither are set, SCRIPT_NAME is used as url
  18.  *           - legend      if set, it will generate a fieldset using the input as legend
  19.  * @uses smarty_function_escape_special_chars()
  20.  * @todo somehow make the variable that is contained within $iselect global --> this will allow importing of outside variables not set in $_REQUEST
  21.  */
  22. function smarty_block_form$pParams$pContent&$gBitSmarty{
  23.     global $gBitSystem$gSniffer;
  24.  
  25.     if$pContent {
  26.         if!isset$pParams['method') ) {
  27.             $pParams['method''post';
  28.         }
  29.         $atts '';
  30.         if$gBitSystem->isLive(&& isset$pParams['secure'&& $pParams['secure'{
  31.             // This is NEEDED to enforce HTTPS secure logins!
  32.             $url 'https://' $_SERVER['HTTP_HOST'];
  33.         else {
  34.             $url '';
  35.         }
  36.         $onsubmit '';
  37.  
  38.         // services can add something to onsubmit
  39.         if$gBitSmarty->get_template_vars'serviceOnsubmit' ) ) {
  40.             $onsubmit .= $gBitSmarty->get_template_vars'serviceOnsubmit' ).";";
  41.         }
  42.  
  43.         foreach$pParams as $key => $val {
  44.             switch$key {
  45.                 case 'ifile':
  46.                 case 'ipackage':
  47.                     if$key == 'ipackage' {
  48.                         if$val == 'root' {
  49.                             $url .= BIT_ROOT_URL.$pParams['ifile'];
  50.                         else {
  51.                             $url .= constantstrtoupper$val ).'_PKG_URL' ).$pParams['ifile'];
  52.                         }
  53.                     }
  54.                     break;
  55.                 case 'legend':
  56.                     if!empty$val ) ) {
  57.                         $legend '<legend>'.tra$val ).'</legend>';
  58.                     }
  59.                     break;
  60.                 // this is needed for backwards compatibility since we sometimes pass in a url
  61.                 case 'action':
  62.                     ifsubstr$val0== 'http' {
  63.                         ifisset$pParams['secure'&& $pParams['secure'&& substr$val0!= 'https' )) {
  64.                             $val preg_replace'/^http/''https'$val );
  65.                         }
  66.                         $url $val;
  67.                     else {
  68.                         $url .= $val;
  69.                     }
  70.                     break;
  71.                 case 'ianchor':
  72.                 case 'secure':
  73.                     break;
  74.                 case 'onsubmit':
  75.                     if!empty$val ) ) {
  76.                         $onsubmit .= $val.";";
  77.                     }
  78.                     break;
  79.                 default:
  80.                     if!empty$val ) ) {
  81.                         $atts .= $key.'="'.$val.'" ';
  82.                     }
  83.                     break;
  84.             }
  85.         }
  86.  
  87.         ifempty$url )) {
  88.             $url $_SERVER['SCRIPT_NAME'];
  89.         else if$url == 'https://' $_SERVER['HTTP_HOST'{
  90.             $url .= $_SERVER['SCRIPT_NAME'];
  91.         }
  92.  
  93.         $onsub !empty$onsubmit ' onsubmit="'.$onsubmit.'"' '' );
  94.         $ret '<form action="'.$url.!empty$pParams['ianchor''#'.$pParams['ianchor''' ).'" '.$atts.$onsub.'>';
  95.         $ret .= isset$legend '<fieldset>'.$legend '';        // adding the div makes it easier to be xhtml compliant
  96.         $ret .= $pContent;
  97.         $ret .= isset$legend '</fieldset>' '';            // close the open tags
  98.         $ret .= '</form>';
  99.         return $ret;
  100.     else {
  101.         global $gSmartyFormHorizontal;
  102.         // global var other plugin functions will pick up to add proper col-XX-YY styling for horizontal forms
  103.         $gSmartyFormHorizontal !empty$pParams['class'&& strpos$pParams['class']'form-horizontal' !== FALSE );
  104.     }
  105. }
  106. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:11 +0000 by phpDocumentor 1.5.0-lsces