Object oriented Smart Templates Engine
Smart Template Engine
Installation / Tips Database Engine Interface Smart Parser Engine
Step by step installation
Database (DE) mode FAQ
Templates (TE) mode FAQ
Examples
Tips
Admin interface
Actions Editor
Jump Editor
Mailing Editor
Key Fields
Syntax
How to use TE
How to use DE

(*) DE - Database Engine
(*) TE - Template Engine
     Actions editor
Level Before After
CSS
CFM
Mail
MySQL
 

    Common notes

You must use only php files here, it means that you must enter file names of your php scripts into all fields.
They will be included like @include($fcss_form ["AA"] ["CSS"] ["Before"] );

CSS - error checking stage
CFM - confirmation page output stage
MailPRC - mailing stage
MySQLPRC - work on MySQL table stage


Forms array is $FS_form and looks like:

 
Array
(
    [cfmfile] => 
    [cfmstnc] => Submit
    [errmsg] => y
    [MySQLPRC] => y
    [DBHost] => localhost
    [DBName] => tes
    [DBLogin] => test
    [DBPass] => test
    [DBTable] => test
    [InsertField] => none
    [InsertFieldValue] => 
    [UpdateField] => none
    [UpdateFieldValue] => 
    [FillField] => none
    [FillFieldValue] => 
    [TableField] => none
    [TableFieldValue] => 
    [action] => 
    [onsubmit] => 
    [CheckServerSide] => y
    [CheckClientSide] => y
    [translation] => english
    [inputs] => Array
        (
            [text] => Array
                (
                    [name] => text
                    [type] => text
                    [description] => 
                    [class] => butt_menu
                    [SType] => CHAR
                    [size] => 50
                    [values] => 
                    [required] => y
                    [emptyval] => 
                    [min] => 
                    [max] => 
                    [email] => y
                    [regexp] => 
                )

            [radio] => Array
                (
                    [name] => radio
                    [type] => radio
                    [description] => 
                    [class] => 
                    [SType] => ENUM
                    [size] => 2
                    [values] => 'r1','r2'
                )

            [combobox] => Array
                (
                    [name] => combobox
                    [type] => select
                    [description] => 
                    [class] => 
                    [SType] => CHAR
                    [size] => 4
                    [values] => 
                    [emptyval] => 
                )

            [pass] => Array
                (
                    [name] => pass
                    [type] => password
                    [description] => 
                    [class] => butt_menu
                    [SType] => CHAR
                    [size] => 50
                    [values] => 
                    [required] => y
                    [emptyval] => 
                    [numeric] => y
                    [min] => 
                    [max] => 2
                    [regexp] => 
                )

            [picture] => Array
                (
                    [name] => picture
                    [type] => file
                    [description] => 
                    [class] => 
                    [SType] => FILE
                    [size] => 0
                    [values] => 
                    [emptyval] => 
                    [IMG] => Array
                        (
                            [gif] => y
                            [jpg] => y
                            [png] => y
                            [X] => 
                            [Y] => 
                        )

                    [min] => 
                    [max] => 64000
                )

            [textarea] => Array
                (
                    [name] => textarea
                    [type] => textarea
                    [description] => 
                    [class] => 
                    [SType] => TEXT
                    [size] => 150
                    [values] => 
                    [emptyval] => 
                    [min] => 
                    [max] => 
                    [regexp] => 
                )

            [check] => Array
                (
                    [name] => check
                    [type] => checkbox
                    [description] => 
                    [class] => butt_menu
                    [SType] => BOOL
                    [size] => 1
                    [values] => 
                    [emptyval] => 
                )

            [listbox] => Array
                (
                    [name] => listbox
                    [type] => select
                    [description] => 
                    [class] => 
                    [SType] => CHAR
                    [size] => 3
                    [values] => 
                    [emptyval] => 
                )

            [submit] => Array
                (
                    [name] => submit
                    [type] => submit
                    [description] => 
                    [class] => 
                    [SType] => NO MySQL
                    [size] => 1
                    [values] => submit
                    [emptyval] => 
                    [min] => 
                    [max] => 
                    [regexp] => 
                )

        )

    [Fields] => text.radio.combobox.pass.picture.textarea.check.listbox.submit
    [Mail] => Array
        (
            [service@formparser.com] => Array
                (
                    [From] => [[text]]
                    [Subject] => [[pass]]
                    [Body] => Mail body
[[text]]
[[radio]]
[[combobox]]
[[pass]]
[[textarea]]
[[check]]
[[listbox]]
[[picture]]
                )

        )

    [Link] => Array
        (
            [test1] => Array
                (
                    [Link] => test.com
                    [Term] => '[[text]]'=='test'
                )

        )

    [KF] => Array
        (
            [ID] => Array
                (
                    [Type] => COUNTER
                    [Size] => 10
                    [Insert] => 
                    [InsVal] => 
                    [Update] => No
                    [UpdVal] => 
                )

        )

    [PRIMARY_KEY] => ID
    [AA] => Array
        (
            [CSS] => Array
                (
                    [Before] => precss.php
                    [After] => extracheck.php
                )

            [CFM] => Array
                (
                    [Before] => precfm.php
                )

            [Mail] => Array
                (
                    [Before] => premail.php
                    [After] => checkmail.php
                )

            [MySQL] => Array
                (
                    [Before] => premysql.php
                    [After] => add_mysql.php
                )

        )

    [Confirm] => n
    [MailPRC] => y
)


All vars inside SP.DE defines like $FS_varname, so you could use any varnames into your action scripts but $FS_

There are also several variables available in any action
$FS_STATE - can be "cgi" or "inside", depends on SP.DE running model
$FS_form_file - a name of file that calls SP.DE
$FS_vars_file - variables file name relative to form file
$FS_action_form - a name of form that was posted by user
$FS_action_stage - current SP.DE stage, can be
"CSS" - error checking
"CFM" - confirmation page output
" MailPRC" - mailing
" MySQLPRC" - work on MySQL table

All "before" actions will be included right on before calling of corresponding procedure, before any procedure code execution
For example, you can use before action to change $FS_form array:

 
    $FS_form["inputs"]["info"]["max"] =  $listing_dscr_max_len[$_SESSION["status"]];
    if ($_SESSION["status"]=='Free')
        $FS_form["inputs"]["bid"]["min"]=0;

or $_POST array with forms values

 
    if (!isset($_POST["status"]))
        $_POST["status"] = 2;

    $_POST["site_part"] = 0;
    foreach($df_ebpages as $cb => $name) {
        if (isset($_POST["sp_$cb"]))
        $_POST["site_part"] |= $_POST["sp_$cb"];
    }

In MySQL case, when your table has some field that can't be filled from form fields but depends of them, you should add such field in Key fields editor and set value source like $_ADDVALUE['table_field']. Then fill $_ADDVALUE['table_field'] in pre MySQL action script and set its name in MySQL "before" stage.


     After actions


CSS after action included after error checking and before "IF" on it.
Check $FS_error array (fields with error are keys) on errors. For instance, You may easily drop errors by $FS_error = array();

CFM after action included before confirmation page printing.
$FS_source contains unchanged confirmation source

Mail after action included in the end of procedure (before } ).
$FS_mail_result ("To" parts are keys) contains results of mail sending:
-1 - wrong parameteres ( If any of four arguments: $from, $to, $subject, $body is empty )
n - see socket errors
true - succesful

MySQL after action included after MySQL query and before Database link will be closed.
$FS_query contains table query
Use PEAR object $db to work with MySQL. SeePEAR Database Manual

 
    include_once("../incfiles/defines.inc.php");
    if (is_uploaded_file($_FILES['fbanner']['tmp_name']) && $_FILES['fbanner']['size']<=$df_logo_maxsize) {
        $banner_type = getimagesize($_FILES['fbanner']['tmp_name']);
        $fp = fopen($_FILES['fbanner']['tmp_name'],"rb");
        if ( $fp != false                             &&
             $banner_type[0]==$x[$_SESSION["status"]] &&
             $banner_type[1]==$y[$_SESSION["status"]] &&
            ($banner_type[2]==1 || $banner_type[2]==2) ) {

            $qbanner = $db->query("select ID from logos where ID=".$_SESSION["id"],$link);

            if ( !DB::isError($qbanner)) {

                $bimage = addslashes(fread($fp,$df_logo_maxsize));
                fclose($fp);

             if ($qbanner>numRows() >0) {
              $db->query("update logos set banner='$bimage',type=".$banner_type[2]." where ID=".$_SESSION["id"], $link);
             } else {
                    $db->query("insert into logos values (".$_SESSION["id"].",'$bimage',".$banner_type[2].",0)", $link);
                }
            }
        }
    }



 1997-2004 © Copyright "H-2.com"    Developed by H-2.com