Base


vBase

__construct()

Members

Name Default Function
ff \Base::instance() FatFree Framework Base instance
class_name current class name Current Class Name

val($key)

Return the value of $key if exists, null otherwise

val($key, $value)

Set $value to $key. Return $this


Controller


Houtai

tab($tab_name, $tab_model)

Generate editable tables for each tab in houtai page

Name Default Function
$tab_name The name of tab page
$tab_model Controller/model name for each tab

Log

record($parm = array())

Record activities on log for user

$parm is an array of

Name Default Function
user_id Current login user id If no user login, user_id=0
ip Current user ip Get IP by FatFree Framework
action User’s action, choose from
  • Signup
  • Signin
  • Signout
  • ForgetPassword
  • ChangePassword
  • WrongPassword
  • WrongEmail

vCommon

__construct()

Default options:

Name Default Function
datepicker false include datepicker
editor false Include wysihtml5 editor
noty false Include noty
permission null Permissions need to access a page
protected false Use password to protect a page
select2 false Include select2
tocify false Include tocify
unveil false Include unveil lazy loading
validator false Include bootstrap validator
vscript false Include vscript.js
xeditable false Include xeditable

form($parm = array())

Return form code from $parm

Use $_POST['vfrom'] if exists, otherwise use $parm

Default optoins

Name Default Function
id 0 id number, 0 for new record
model current controller class model class name. default is strtolower($this->class_name)

See controller class vForm for details

table($parm = array(), $search = array())

Return table code from $parm and $search

Use $_POST['vtable'] if exists, otherwise use $parm

$_POST[$option] options:

Name Default Function
search_text text to search in field(s)
search_field fields to search for search_text, _ALL_ for all fields

Default options

Name Default Function
model current controller class model class name. default is strtolower($this->class_name)
field_show _ALL_ fields to show
filter null data filter
option null data option
paginate 0 everything in one page

See controller class vTable for details

post($action = ‘_UNDEFINED_’)

Handle POST requests on /controller/post/action

Execute beforePost($action) before POST request and afterPost($action) after successful POST request.

POST request will not render any page unless $_POST['template'] is set.

TODO: add security check before execute POST requests.

Action options:

Action Function $_POST parameters
read Read data from DB $_POST['filter'] for data filter and $_POST['option'](group, order, limit, offset) for data options
write Insert/Update data in DB Put data to write in $_POST, in format of $_POST[$name] = $value
delete Remove data from DB Data to delete with unique_id in $_POST[$uniqu_id]
xeditable For xeditable script $_POST['pk'] for primary key, $_POST['name'] and $_POST['value'] for data set

vController

__construct()

Members

Name Default Function
view \Template() FatFree Template class
render true Whether to render the page to get page code
show true Whether to show/display/output/echo the page code
make_static false Whether to make static page while output
minify true Whether to minify the code
template layout.html Template file used to render the pagte
model model name \Model\Class_name if exists, otherwise set to null

useTable($table)

Return Class \Model\vModel($table)


vForm

__construct()

Default options:

Name Default Function
code_before null Code to be added before the form
code_after array() Code to be added after the form
data array() data for current record
field_edit _ALL_ fields show up in form to edit
field_readonly array() fields show up in form as “read only”
field_hidden array('id') fields show up in form as “hidden”
id form_$model unique form id
input_class col-sm-10 CSS class name for input field
label_class col-sm-2 CSS class name for field label
model model class name
template vform.html template for forms
unique_id id unique field name

getFormCode()

Return rendered form code.


vMail

__construct($mail = ‘_UNDEFINED_’, $smtp = ‘_UNDEFINED_’)

Members

Name Default Function
smtp \SMTP() FatFree SMTP class, null if no smtp setting
mail Mail parameters

SMTP options

Name Default Function
server SMTP server address
port SMTP server port
scheme SMTP server scheme
user SMTP username
password SMTP user password

Mail options

Name Default Function
from array() Email From: array('name'=>'email')
to array() Email To: array(array('name'=>'email'),...)
cc array() Email cc: array(array('name'=>'email'),...)
bcc array() Email bcc: array(array('name'=>'email'),...)
subject '' Email subject
attachment array() Email attachment: array('path/to/file',...)
body '' Email Body

send()

Send out the email. Return true if success, output log and return false if fail.


vTable

__construct()

Default options:

Name Default Function
template vtable.html table template
model model class name
filter null data filter
option null data options
id '' table id
class 'table table-bordered table-hover' CSS table class
caption array() table caption
colgroup array() table colgroup
header array() table header
body array() table table
footer array() table footer
unique_id id unique field name
allow_add 0 show the add button
allow_edit 0 show the edit button
allow_remove 0 show the remove button
paginate 0 items per page. 0 for no page (everything in one page)
search null fields to search, null=no search box; _ALL_=all fields; array for fields names
add_button_text New text for “Add” button
edit_button_text '' text for “Edit” button
remove_button_text '' text for “Remove” button
disable_button array() disable edit or remove button in certain row, in format of array(‘row_num’=>array(‘edit’=>true, ‘remove’=>true)
field_hidden array('id') fields hide in pop-up forms
field_edit _ALL_ fields showed in pop-up form, use array if not ‘ALL
field_readonly array() fields showed in pop-up form as readonly
field_show _ALL_ field to show in the table, use array if not ‘ALL

getTableCode()

Return rendered table code.


vUser

__construct()

Members

Name Default Function
permission_control false Whether permission control is available

$_SESSION['user'] for a logged in user

Name Type Function
profile array array of login user profile
login true true for logged in, false otherwise
expire time current login expire time time()+$expire, set by login_expire global
permission array current user permissions, login by default

Model


vModel

Members

Name Default Function
db db handler \DB\SQL\Mapper($this->dblink,$this->table)
table same as class name table name
dblink db global db parameters
unique_id "id" unique id for table

__construct($table, $dblink)

Name Default Function
table null table name
dblink null \DB\SQL

loadOne($filter, $option)

Load one record from database, use $this->db->load(), and return $this->db

Name Default Function
filter null data filter
option array() data option

getColByID($id, $col)

Return column value(s) by unique_id value

Name Default Function
id $this->unique_id value
col _ALL_ column name, _ALL_ for all columns

listByID($name, $filter, $option)

Return an array in format of array(‘unique_id’=>value)

Name Default Function
name name of field to get value
filter null data filter
option null data option

getDB($filter, $option, $cols, $bycol, $adhoc)

Find data in database and return in array

Name Default Function
filter null data filter
option null data option
cols _ALL_ columns to get from database, _ALL_ for all columns
bycol false whether to show result by columns
adhoc null adhoc fields

saveDB($data, $filter, $option, $cols)

Save a record of data to database. If exists, update the record. If not, insert a new record.

Name Default Function
data array() dat to insert/update in format of array('col'=>'value',...)
filter null data filter, _NEW_ for insert new record
option null data option
cols _ALL_ columns to update/insert in format of array('insert'=>array('col1','col2'...), 'update'=>array('col1','col2'...))

multipleDB($column_multiple, $data, $filter, $option, $cols)

Update select multiple to database.

Name Default Function
column_multiple the name of the field contains multiple value
data array() dat to insert/update in format of array('col'=>'value',...)
filter null data filter
option null data option
cols _ALL_ columns to update/insert in format of array('insert'=>array('col1','col2'...), 'update'=>array('col1','col2'...))

removeDB($filter, $option)

Remove data record from database

Name Default Function
filter null data filter
option null data option

vCommon

Members

Name Default Function
fields array() Fields for model
show '_ALL_' show all or an array of fields

__construct($fields, $table)

Name Default Function
fields null fields for model
table null data table in database

field

Default field properties

Name Default Function
name '' same as coumn name in database
display '' name to display in forms and tables
input 'input' type in forms, e.g. select, textarea, input
type 'text' input type if input="input"
path 'files/' file location if input type=”file” wrt ROOT
option array() if input=”select” or type=”radio” etc
before '' show before the value
after '' show after the value
help null text in help block under the input field
align null text align in table
decode null decode the data retrieve from database to more readable format, can be the name of array(),php function or member function
encode null encode the data from input before saving to database, can be the name of array(),php function or member function

Others


DBAPI

POST request

Data to send with POST request

Name Default Function
api_id ID for API
api_key key for api_id
table table name in database
action choose from SELECT,INSERT,UPDATE & DELETE
filter null data filter
option null data option
data record data, required for INSERT & UPDATE
column '*' columns to SELECT, optional for SELECT action

Response

Response in JSON formatted data

Name Default Function
code result code, similar to HTTP code
type result type, one of error,warning & success
message result message
data return data for SELECT, last inserted record id for INSERT, no set for other actions