PHP Classes

File: smarty/2/plugins/prefilter.form.php

Recommend this page to a friend!
  Classes of Manuel Lemos   PHP Forms Class with HTML Generator and JavaScript Validation   smarty/2/plugins/prefilter.form.php   Download  
File: smarty/2/plugins/prefilter.form.php
Role: Auxiliary script
Content type: text/plain
Description: Smarty 2 engine pre-filter plugin for form template processing
Class: PHP Forms Class with HTML Generator and JavaScript Validation
HTML forms generation and validation.
Author: By
Last change: Added support to handle templates with logic and loop control stuctures
such as if, else, elseif, foreach, foreachelse and section.
Date: 11 years ago
Size: 1,393 bytes
 

Contents

Class file image Download
<?php

/*
 * prefilter.form.php
 *
 * @(#) $Header: /opt2/ena/metal/forms/smarty/2/plugins/prefilter.form.php,v 1.5 2006/11/19 18:19:07 mlemos Exp $
 *
 */

function smarty_prefilter_form($tpl_source, &$smarty)
{
   
$ql=preg_quote($l=$smarty->left_delimiter, '/');
   
$qr=preg_quote($r=$smarty->right_delimiter, '/');
   
$qd=preg_quote('/', '/');
   
$search=array(
       
'/'.$ql.'input\s+name=("[^"]+"|\'[^\']+\'|\S+)'.$qr.'/i',
       
'/'.$ql.'hiddeninput\s+name=("[^"]+"|\'[^\']+\'|\S+)'.$qr.'/i',
       
'/'.$ql.'label\s+for=("[^"]+"|\'[^\']+\'|\S+)'.$qr.'/i',
       
'/('.$ql.'(include|include_php|if|else|elseif|'.$qd.'if|foreach|foreachelse|'.$qd.'foreach|section'.$qd.'section).*'.$qr.')/i'
   
);
   
$replace=array(
       
$l.'/capture'.$r.$l.'insert name="formaddinputpart" input=\\1 data=$smarty.capture.formdata'.$r.$l.'capture name="formdata"'.$r,
       
$l.'/capture'.$r.$l.'insert name="formaddinputhiddenpart" input=\\1 data=$smarty.capture.formdata'.$r.$l.'capture name="formdata"'.$r,
       
$l.'/capture'.$r.$l.'insert name="formaddlabelpart" for=\\1 data=$smarty.capture.formdata'.$r.$l.'capture name="formdata"'.$r,
       
$l.'/capture'.$r.$l.'insert name="formadddatapart" data=$smarty.capture.formdata'.$r.'\\1'.$l.'capture name="formdata"'.$r
   
);
    return(
$l.'capture name="formdata"'.$r.preg_replace($search,$replace,$tpl_source).$l.'/capture'.$r.$l.'insert name="formadddatapart" data=$smarty.capture.formdata'.$r);
}

?>