Generate text for storage

generate_text_for_storage –– Store custom parsed text on user-facing pages.

Description
Grab data from the user, manipulate the input according to the parameters then it returns the information meant to be sent to the database This function is located in the  file.
 * 1) string[] generate_text_for_storage(string &$text, string &$uid, string &$bitfield, int &$flags, bool $allow_bbcode = false, bool $allow_urls = false, bool $allow_smilies = false)

Parameters
IN means that it expects information to be stored in the variable when the function is called (most common use of parameters) OUT means that it will discard the information that is sent to the function and the variable is changed inside the function INOUT means that the function will use the contents in the variable and it will also change those contents

Return Values
Returns an array of strings with the errors that occurred while parsing Note that if there are no errors the array will be empty.

Example #1 bbcode_options
This example shows the "standard" option where BBCode, magic urls and smilies are allowed

$errors = generate_text_for_storage($some_text, $new_uid, $new_bitfield, $bbcode_options, true, true, true);

if(sizeof($errors)){ // Errors occured, show them to the user. // PARSE_ERRORS variable must be defined in the template $template->assign_vars(array( 'PARSE_ERRORS'     => implode(' ', $errors), ));

}else{ // No parse errors; save the text in my table $sql = 'INSERT INTO '. YOUR_TABLE. ' ' . $db->sql_build_array('INSERT', array( 'text'		=> $some_text, 'uid'		=> $new_uid, 'bitfield'	=> $new_bitfield);		$db->sql_query($sql); }

Option Text Flags

 * The OPTION_FLAG_* constants are defined as: define('OPTION_FLAG_BBCODE', 1); define('OPTION_FLAG_SMILIES', 2); define('OPTION_FLAG_LINKS', 4); Adding these constants together will result in all three options being enabled.