Public Method Details |
Bs_Form |
|
public void Bs_Form( )
|
| |
Constructor.
|
| Returns |
void |
|
&getForm |
|
public string &getForm( [ string $withErrorTable ] )
|
| |
Returns html code to send to the browser which will display the web form
with all its form fields.
|
| Parameter |
|
| string |
$withErrorTable |
= >>FALSE<< |
|
(if the error table should automatically come with it if errors occured. default is FALSE.) |
|
| Returns |
string (html code) |
| See Also |
getIncludeOnce(), getOnLoadCode() |
|
getFormTag |
|
public string getFormTag( )
|
| |
returns the form tag.
|
| Returns |
string some html code. |
|
getFormHead |
|
public string getFormHead( )
|
| |
returns the 'form head' which includes the <form> tag, [javascripts]
and hidden/internal fields.
|
| Returns |
string some html code. |
|
getFormFoot |
|
public string getFormFoot( )
|
| |
returns the 'form foot' which includes the </form> tag and the used fields (hidden).
|
| Returns |
string some html code. |
|
getUsedFields |
|
public void getUsedFields( )
|
| |
returns an html string that will be sent to the client inside the form.
it has 2 hidden fields, one for the fields used, one md5 to avoid cheating.you have to call this method after doing the $this->elementContainer->getElement()because otherwise the fields don't know yet if they will be used or not.does not move the pointer of $this->clearingHouse.
|
| Returns |
void |
|
isMultiLevel |
|
public bool isMultiLevel( )
|
| |
tells if this form is a multilevel form.
|
| Returns |
bool |
| See Also |
$this |
|
getNumbersOfLevels |
|
public int getNumbersOfLevels( )
|
| |
returns the number of levels used in that form.
if it's not a multilevel form then 1 is returned.a simple form can be seen as a 1-level form.
|
| Returns |
int |
| See Also |
$level |
|
isFirstLevel |
|
public bool isFirstLevel( )
|
| |
tells if we're in the first level of a multilevel form.
note: also returns TRUE if it's not a multilevel form causethen it's the first level aswell.
|
| Returns |
bool |
| See Also |
$level |
|
isLastLevel |
|
public bool isLastLevel( )
|
| |
tells if we're in the last level of a multilevel form.
note: also returns TRUE if it's not a multilevel form causethen it's the last level aswell.
|
| Returns |
bool |
| See Also |
$level |
|
isMultipart |
|
public bool isMultipart( )
|
| |
Tells whether this form is (or has to be treated as) a multipart form.
a multipart form is one with at least one <input type=file> field.the form turns into a multipart form when one of these conditions is true:1) the user set $this->encType to 'multipart/form-data'2) the form has at least one file field which is in use.
|
| Returns |
bool true if it's a multipart form, false if not. |
| See Also |
$this |
|
getMode |
|
public string getMode( )
|
| |
returns the form mode we're in.
|
| Returns |
string one of 'add', 'edit', 'delete', 'view'. the mode that is set, or '' if nothing is set. |
| See Also |
$this |
|
hasJavascript |
|
public bool hasJavascript( )
|
| |
tells whether the client browser has javascript support or not.
|
| Returns |
bool TRUE if the client has javascript, FALSE if not.
@throw NULL if we don't know |
| See Also |
$hasJavascript |
|
getElement |
|
public string getElement( string $elementName, [ string $what, string $optionList ] )
|
| |
returns the element of one of the elements of this form.
caution: moves the pointer of $this->clearingHouse.
|
| Parameter |
|
| string |
$elementName |
|
|
(the name of the form field or element) |
|
|
| string |
$what |
= >>'element'<< |
|
one of 'element' (default), 'caption', 'text', 'error', 'help'. |
|
|
| string |
$optionList |
= >>null<< |
|
(used to return just some of the radio options.) |
|
| Returns |
string (text or html) |
| Throws |
empty string '' if no such element. |
|
validate |
|
public bool validate( )
|
| |
validates the inputs of all fields that were sent. fills $this->errors if needed.
changes $this->state, $this->step and $this->level if needed.sets $this->usedTime if needed.caution: moves the pointer of $this->clearingHouse.
|
| Returns |
bool |
| See Also |
$this |
|
getErrorTable |
|
public string getErrorTable( [ string $title ], string $style )
|
| |
returns a basic html string (html table) filled with the error messages
to display on the website.
|
| Parameter |
|
| string |
$title |
= >>NULL,<< |
|
a string (may include html) that is set above of the html table.
$param string $style default is 'default', nothing available yet. |
|
|
| string |
$style |
|
|
Warning: documentation is missing. |
|
| Returns |
string an html string. |
| Throws |
string an empty string if no errors occured. |
|
addError |
|
public void addError( string $errorMsg, [ string $fieldName, string $fieldCaption ] )
|
| |
adds an error to this form.
if $fieldName is NULL it is considered a vector element. see $this->errors.
|
| Parameter |
|
|
|
| string |
$fieldName |
= >>NULL,<< |
|
|
|
|
| string |
$fieldCaption |
= >>NULL<< |
|
|
|
| Returns |
void |
| See Also |
$this |
|
isFieldFilledIn |
|
public bool isFieldFilledIn( string $fieldName )
|
| |
tells if the user filled in the given field *somehow*. does not tell if the
input was ok/accepted.does not move the pointer of $this->clearingHouse.
|
| Parameter |
|
|
| Returns |
bool |
| Throws |
NULL if no such field, not a field, or not capable to tell. |
|
getFieldValue |
|
public array getFieldValue( string $fieldName, [ string $valueType ] )
|
| |
returns the field value you want.
does not move the pointer of $this->clearingHouse.
|
| Parameter |
|
|
|
| string |
$valueType |
= >>'internal'<< |
|
one of 'internal' (default), 'default', 'received', 'display'. |
|
| Returns |
array a vector with exactly one element (key = 0) that holds the field value. this way of returning is needed to make a difference to 'dunno'. |
| Throws |
NULL if no such field, not a field, or not capable to tell. |
|
setValuesToDefault |
|
public void setValuesToDefault( )
|
| |
sets the fields valueInternal and valueDisplay to the same value as valueDefault is.
caution: moves the pointer of $this->clearingHouse.
|
| Returns |
void |
|
setReceivedValues |
|
public bool setReceivedValues( array &$array )
|
| |
Sets the received values to the form fields of this form.
also calls setBsFormData() if needed.!!! does not modify $step any more. 2002/05/07 --andrejcaution: moves the pointer of $this->clearingHouse.
|
| Parameter |
|
|
| Returns |
bool TRUE |
| Throws |
bs_exception |
|
setLoadedValues |
|
public void setLoadedValues( array &$array )
|
| |
Sets the loaded values to the form fields of this form.
also sets $step to 1. call setBsFormData() yourself if you need it.caution: moves the pointer of $this->clearingHouse.
|
| Parameter |
|
| array |
&$array |
|
|
(hash where key=fieldname and value=value.) |
|
| Returns |
void |
|
postLoadTrigger |
|
public void postLoadTrigger( )
|
| |
calls the post load triggers of the fields of this form.
caution: moves the pointer of $this->clearingHouse.
|
| Returns |
void |
|
seedClearingHouse |
|
public void seedClearingHouse( [ string $onlyIfNotSet ] )
|
| |
seeds the var $clearingHouse.
|
| Parameter |
|
| string |
$onlyIfNotSet |
= >>TRUE<< |
|
default is TRUE. if set to true it will only be done if $clearingHouse is not set yet. |
|
| Returns |
void |
| See Also |
$clearingHouse |
|
addIncludeOnce |
|
public bool addIncludeOnce( $scriptUrl )
|
| |
adds a javascript source file to the include-once todo list.
it's a good practise to write them the same way all the time (relative/absolute)to avoid problems.
|
| Parameter |
|
|
$scriptUrl |
|
|
Warning: documentation is missing. |
|
| Returns |
bool (TRUE if the script was added, FALSE if it was already there.) |
| See Also |
$_includeOnce, getIncludeOnce() |
|
getIncludeOnce |
|
public mixed getIncludeOnce( [ string $how ] )
|
| |
returns the include-once script files.
param $how: can be 'array' (default) or 'string'.for 'array' you get a vector with all script url's (empty array if none).for 'string' you get an html string with the script tags to echoto your browser (empty string if none).
|
| Parameter |
|
| string |
$how |
= >>'array'<< |
|
(see above) |
|
| Returns |
mixed (array or string, see param $how) |
| See Also |
$_includeOnce, addIncludeOnce() |
|
addOnLoadCode |
|
public bool addOnLoadCode( string $code )
|
| |
javascript code that needs to be executed in the onLoad event of the page.
|
| Parameter |
|
| string |
$code |
|
|
(javascript code) |
|
| Returns |
bool TRUE . |
| See Also |
$_onLoad, getOnLoadCode() |
|
getOnLoadCode |
|
public string getOnLoadCode( [ string $withCodeTags ] )
|
| |
returns the javascript code that needs to be executed in the onLoad event
of the page.if param $withCodeTags is TRUE then you'll get script tags wrapped around,everything is prepared to paste it into the html-document. example:<script type='text/javascript'><!--onload=function() {//javascript code is here}// --></script>
|
| Parameter |
|
| string |
$withCodeTags |
= >>TRUE<< |
|
(default is TRUE, see above.) |
|
| Returns |
string |
| See Also |
$_onLoad, addOnLoadCode() |
|
getInHeadCode |
|
public string getInHeadCode( )
|
| |
returns the code that should be added in the document head.
|
| Returns |
string |
| See Also |
$_inHead |
|
setPersisterID |
|
public void setPersisterID( int $persisterID )
|
| |
set the form id for all elements.
special method for the persister. rtfm.
|
| Parameter |
|
|
| Returns |
void |
| See Also |
$persisterID |
|
saveToDb |
|
public mixed saveToDb( )
|
| |
saves the received form inputs according to the settings.
if the db table doesn't exist yet, it will be created automatically.if it exists and problems occure while inserting, the table structurewill be updated.on an insert, $this->recordId will be set.
|
| Returns |
mixed (bool FALSE if nothing had to be saved, bool TRUE on a successful update, int >=1 on a successful insert (=the new record id))
@throw bs_exception if something should have been saved but failed somewhere. |
| See Also |
$saveToDb, $dbTableName |
|
doesDbTableExist |
|
public bool doesDbTableExist( [ string $dbTableName, string $useCache ] )
|
| |
tells if the db table exists. i mean the db table where the submitted
values should get persisted.
|
| Parameter |
|
| string |
$dbTableName |
= >>NULL,<< |
|
default is NULL which means get it yourself. you may pass it here if you already have it as optimization. |
|
|
| string |
$useCache |
= >>TRUE<< |
|
default is TRUE. if the table could have been created lately you better set it to FALSE. |
|
| Returns |
bool TRUE if it exists, FALSE if not
@throw Bs_Exception |
| See Also |
$this, $saveToDb, $dbTableName |
|
createDbTable |
|
public bool createDbTable( [ string $dbTableName ], array &$saveToDbArray )
|
| |
creates the db table. i mean the db table where the submitted values should get persisted.
|
| Parameter |
|
| string |
$dbTableName |
= >>NULL,<< |
|
default is NULL which means get it yourself. you may pass it here if you already have it as optimization. |
|
|
| array |
&$saveToDbArray |
|
|
the output of $this->getSaveToDbArray(). |
|
| Returns |
bool TRUE on success
@throw Bs_Exception |
| See Also |
$this, $this |
|
updateDbTableStructure |
|
public bool updateDbTableStructure( [ string $dbTableName ], array &$saveToDbArray, [ string $checkOnly ] )
|
| |
checks if the db table structure is up-to-date and updates what's needed.
|
| Parameter |
|
| string |
$dbTableName |
= >>NULL,<< |
|
default is NULL which means get it yourself. you may pass it here if you already have it as optimization. |
|
|
| array |
&$saveToDbArray |
|
|
the output of $this->getSaveToDbArray(). |
|
|
| string |
$checkOnly |
= >>FALSE<< |
|
default is FALSE. if set to true, no changes will be made. |
|
| Returns |
bool TRUE if we have made changes, FALSE if not
@throw bs_exception |
|
getSaveToDbArray |
|
public array getSaveToDbArray( )
|
| |
creates a hash with the information about which data to persist, and how.
the scructure looks like this:$hash['fieldName'] = array('valueInternal' =>'something','neededDataType' =>'varchar','neededIndex' =>FALSE,'availableDataType' =>'varchar','availableIndex' =>FALSE,'shouldModifyType' =>FALSE,'shouldAddIndex' =>FALSE,'shouldPersist' =>TRUE);so the key of the hash is the fieldname (as it should be in the db).valueInternal is what we got from the browser. mostly a string, buttake care, it might be an array (explodable fields,select fields with property 'multiple').it is a reference, so don't fuck with it.neededDataType is $dbDataType of the field, or if not set then it'swhat we made up for it. the the received value doesn'tfit into that, then we might have to use some imagination.neededIndex is TRUE if the field is set to mustBeUnique, FALSE otherwise.availableDataType is the field type that we currently have in the db.availableIndex is if there's currently an index set in the db.shouldModifyType is true if we should convert the field type. we neverdownsize anything. a few notes:char is always converted to varchar. varchar always usesthe max (255) as size. int is never downsized to tinyint, etc.shouldAddIndex as you can see, the var name is shouldADD not shouldMODIFY.we never 'downsize' here also. someone could have gone intothe db directly and set an index, so we will never remove one.all we do is add it if the field has become mutBeUniquesuddenly.shouldPersist tells us if we should persist the data we got this time.for example in edit mode we don't update some things.
|
| Returns |
array (hash, see above) |
|
getValuesArray |
|
public array getValuesArray( [ string $shouldUseOnly, string $valueType, string $withCaption, string $captionLang, string $printable, string $useLevels ] )
|
| |
returns the desired values of the submitted fields (that we should use).
does not move the pointer of $this->clearingHouse.
|
| Parameter |
|
| string |
$shouldUseOnly |
= >>TRUE,<< |
|
default is TRUE. if set to true, only the fields are returned that should be used/persisted on the serverside. |
|
|
| string |
$valueType |
= >>'valueDisplay'<< |
|
one of 'valueInternal', 'valueDisplay' (default), 'valueReceived', 'valueDefault' |
|
|
| string |
$withCaption |
= >>FALSE,<< |
|
(default is FALSE. would return a hash holding vectors where element 0 is the value and element 1 is the caption (in the current language).) |
|
|
| string |
$captionLang |
= >>null,<< |
|
(default is null. if not given then the lang setting of the form is used.) |
|
|
| string |
$printable |
= >>FALSE,<< |
|
(if you want nice human-readable output for values, set this to true. eg checkboxes return 'yes/no' instead of 0/1 values.) |
|
|
| string |
$useLevels |
= >>null<< |
|
(vector filled with integers, null means all steps.) |
|
| Returns |
array (hash where key is the internally used field name, value the value or a hash (see param $withCaption). may be an empty array if nothing is available.) |
|
getInterfaceText |
|
public string getInterfaceText( string $key, [ string $lang ] )
|
| |
returns a text string.
|
| Parameter |
|
|
|
|
| Returns |
string |
| Throws |
empty string '' if a key is not defined or a language can in no way be loaded. |
| See Also |
_loadInterfaceLanguage(), $_guiLangHash |
|