yana

phpDocumentor v 1.4.0

Class FormCreator

Description

Form-generator
This class is a form-generator, that produces HTML-code from database structure files.
Example of usage:
  1.  $form new FormCreator();
  2.  // use database structure in file 'project'
  3.  $form->setFile('project');
  4.  // use table 'effort' from file 'project'
  5.  $form->setTable('effort');
  6.  // choose which form to create (here: a form to edit entries)
  7.  // set which columns to show
  8.  $form->setColumns(array (
  9.      "effort_id",
  10.      "effort_date",
  11.      "effort_description",
  12.      "effort_state"
  13.  ));
  14.  // limit entries to show by adding a where clause
  15.  $form->setWherearray (
  16.      array("effort_duration"2'>'),
  17.      array("effort_duration"20'<')
  18.  ));
  19.  // select a column to sort the entries
  20.  $form->setSort('effort_id');
  21.  // set the number of entries to show per page
  22.  $form->setEntriesPerPage(5);
  23.  // set what action (function) should be triggered,
  24.  // when the user clicks the "edit" button
  25.  $form->setEditAction('project_edit_effort');
  26.  // set what action (function) should be triggered,
  27.  // when the user clicks the "new" button
  28.  $form->setNewAction('project_new_effort');
  29.  // generate the HTML code of the requested form
  30.  $string $form->createForm();
  • access: public
Object
   |
   --FormCreator
Method Summary

Methods

create a new instance
FormCreator FormCreator ()
Description:
This creates and initializes a new instance of this class.
trigger wether the user should be allowed to create new entries
bool allowNewEntry (
[bool $allowNewEntry = null]
)
List of parameters:
Name Type Description
$allowNewEntry bool
Description:
Use this function to trigger the "new entry" row on edit-forms. If $allowNewEntries is true, the row will be shown, else it will be hidden.
Note that this row can be hidden automatically, if a not-nullable column is not visible to the user, making it practically impossible to add entries. However: you may overrule this behavior by calling this function and setting the value to true.
Returns the old value of the property. If you just want to read the current setting, call this function without providing any argument.
  • since: 2.9.5
  • access: public
create a form from the current instance and return it
string createForm ()
Description:
Returns the HTML-code for this form.
  • access: public
turn advanced search on / off
bool enableAdvancedSearch (
[bool $advancedSearch = true]
)
List of parameters:
Name Type Description
$advancedSearch bool
Description:
Triggers wether advanced search is to be used (true=yes, false=no). Returns bool(true) on success and bool(false) on error.
  • access: public
turn array keys on / off
bool enableArrayKeys (
[bool $arrayKeys = true]
)
List of parameters:
Name Type Description
$arrayKeys bool
Description:
Triggers wether for columns of type array the keys are to be used (true=yes, false=no). Returns bool(true) on success and bool(false) on error.
turn titles on / off
bool enableTitles (
[bool $titles = true]
)
List of parameters:
Name Type Description
$titles bool
Description:
Triggers wether fieldnames are to be shown (true=yes, false=no). Returns bool(true) on success and bool(false) on error.
  • access: public
get action for an event
bool(false)|string getAction (
string $name
)
List of parameters:
Name Type Description
$name string name of event
Description:
Returns the lower-cased name of the currently selected action, or bool(false) if none has been selected yet.
  • access: public
get state of advanced search (on / off)
bool getAdvancedSearch ()
Description:
Returns bool(true) if enabled, or bool(false) if disabled.
  • access: public
get state of array keys (on / off)
bool getArrayKeys ()
Description:
This option triggers how to display columns of type "array". If enabled the keys are visible and editable (on edit forms). If disabled the keys are hidden.
Returns bool(true) if enabled, or bool(false) if disabled.
get selected columns
array getColumns ()
Description:
  • access: public
get delete action
bool(false)|string getDeleteAction ()
Description:
get download action
bool(false)|string getDownloadAction ()
Description:
get edit action
bool(false)|string getEditAction ()
Description:
get number of entries to show per page
bool(false)|int getEntriesPerPage ()
Description:
Returns the number of the current page, or bool(false) on error.
  • access: public
get the currently selected file
bool(false)|string getFile ()
Description:
Returns the lower-cased name of the currently selected file, or bool(false) if none has been selected yet.
  • access: public
get data from posted form
array|bool(false) getFormdata (
int $form, string|DbStructure $source, string $table, [array $data = null], [array $columns = null]
)
List of parameters:
Name Type Description
$form int choose the form, the data came from (FORM_NEW, FORM_EDIT, FORM_SEARCH, FORM_ADV_SEARCH)
$source string|DbStructure name of the database structure file to use
$table string name of the database table, the data is related to
$data array provide the form data
$columns array you may limit the results to these columns (if not provided, all columns are returned)
Description:
This function can be used to collect the data submitted by a form, which was created using the Yana form generator.
It returns an array containing the converted form data or bool(false) on error.
If the argument $data is not provided, the function automatically takes it from the $_POST array instead.
Example of usage:
  1.  $args FormCreator::getFormdata(FORM_NEW"guestbook""guestbook");
  • access: public
get namespace
string|bool(false) getNamespace ()
Description:
Returns bool(false) on error.
  • since: 2.9.2
  • access: public
get new action
bool(false)|string getNewAction ()
Description:
get the currently selected page
bool(false)|int getPage ()
Description:
Returns the number of the current page, or bool(false) on error.
  • access: public
get result rows
array &getRows ()
Description:
This function returns a reference to the rows that will be displayed. You may use this to modify the result before it is send to the browser.
Example:
  1.  $rows =$form->getRows();
  2.  foreach ($rows as $i => $row)
  3.  {
  4.      $rows[$i]['FOO'$row['BAR'"\n" $row['FOO'];
  5.      unset($rows[$i]['BAR']);
  6.  }
Returns an empty array on error.
  • since: 2.9.6
  • access: public
get search action
bool(false)|string getSearchAction ()
Description:
get the name of the column the resultset is ordered by
bool(false)|string getSort ()
Description:
Returns the lower-cased column name, or bool(false) if none has been set yet.
  • access: public
get the currently selected table
bool(false)|string getTable ()
Description:
Returns the lower-cased name of the currently selected table, or bool(false) if none has been selected yet.
  • access: public
get the currently selected template file
bool(false)|string getTemplate ()
Description:
Returns the filename of the template that is currently, selected, or bool(false) if none has been set.
  • access: public
get state of titles (on / off)
bool getTitles ()
Description:
Triggers wether fieldnames are to be shown (true=yes, false=no). Returns bool(true) if enabled, or bool(false) if disabled.
  • access: public
get the currently set where clause
bool(false)|string|array getWhere ()
Description:
Returns the current where clause, or bool(false) if none has been set yet.
  • access: public
check if a filter is set on a column
bool hasFilter (
string $column
)
List of parameters:
Name Type Description
$column string name of column to check
Description:
Returns bool(true) if a filter has been set on the column and bool(false) otherwise.
  • since: 2.9.5
  • access: public
check if resultset is sorted in descending order
bool isDescending ()
Description:
Returns bool(true) if sorted descending and bool(false) otherwise.
  • access: public
set action for an event
bool setAction (
string $name, string $value
)
List of parameters:
Name Type Description
$name string
$value string
Description:
Returns bool(true) on success and bool(false) on error.
  • access: public
select columns to view in form
bool setColumns (
[array $columns = null]
)
List of parameters:
Name Type Description
$columns array
Description:
Returns bool(true) on success and bool(false) on error.
  • access: public
set delete action
bool setDeleteAction (
string $action
)
List of parameters:
Name Type Description
$action string
Description:
set download action
bool setDownloadAction (
string $action
)
List of parameters:
Name Type Description
$action string
Description:
set edit action
bool setEditAction (
string $action
)
List of parameters:
Name Type Description
$action string
Description:
set number of entries per page
bool setEntriesPerPage (
[int $entries = null]
)
List of parameters:
Name Type Description
$entries int number of entries per page
Description:
The number of entries per page needs to greater 0, defaults to 5.
Returns bool(true) on success and bool(false) on error.
Note that 'get' and 'session' vars may overrule this setting.
  • access: public
set source file
bool setFile (
string $file
)
List of parameters:
Name Type Description
$file string
Description:
Returns bool(true) on success and bool(false) on error.
  • access: public
set new action
bool setNewAction (
string $action
)
List of parameters:
Name Type Description
$action string
Description:
set current page
bool setPage (
int $page
)
List of parameters:
Name Type Description
$page int number of start page
Description:
The first page is 0, the second is 1, aso., defaults to 0.
Returns bool(true) on success and bool(false) on error.
Note that 'get' and 'session' vars may overrule this setting.
  • access: public
set search action
bool setSearchAction (
string $action
)
List of parameters:
Name Type Description
$action string
Description:
set column to sort the resultset by
bool setSort (
[string $orderBy = ''], [bool $desc = null]
)
List of parameters:
Name Type Description
$orderBy string column name (defaults to primary key)
$desc bool sort descending (true=yes, false=no, defaults to false)
Description:
Note that 'get' and 'session' vars overrule this setting.
Returns bool(true) on success and bool(false) on error.
  • access: public
set source table
bool setTable (
string $table
)
List of parameters:
Name Type Description
$table string
Description:
Returns bool(true) on success and bool(false) on error.
  • access: public
select a template for output
bool setTemplate (
int|string $template, int $layout
)
List of parameters:
Name Type Description
$template int|string
$layout int does only apply if $template is a string
Description:
You may use either a filename, or one of the following constants:
  • FORM_VIEW
  • FORM_EDIT
  • FORM_NEW
  • FORM_SEARCH
Returns bool(true) on success and bool(false) on error. Issues an E_USER_WARNING, if the template is unknown.
Note that the argument $layout can be overruled by 'get' and 'session' vars.
  • access: public
set where clause (filter)
bool setWhere (
[string|array $where = null], [bool $replace = false]
)
List of parameters:
Name Type Description
$where string|array
$replace bool
Description:
The syntax is as follows: column1=value1,column2=value2,...,columnN=valueN
The alternative is as follows: array(array(0=>column1,1=>value1,2=>operator1),...) Where "operator" can be one of the following: '=', 'LIKE', '<', '>', '!=', '<=', '>='
To unset the where clause, call this function without providing a parameter.
Returns bool(true) on success and bool(false) on error.
  • access: public
inherited from base classes

Inherited From Object

Documentation generated on Sat, 03 Jan 2009 22:22:25 +0100 by phpDocumentor 1.4.0

yana author: Thomas MeyerHomepage: www.yanaframework.net