SelfHelp WebApp  v2.0.6
A WebApp to Create WebApps for Studies in Human Sciences
UserInput Class Reference

Public Member Functions

 __construct ($db)
 
 convert_to_valid_html_id ($string)
 
 get_input_fields ($filter=array())
 
 get_input_fields_by_gender_male ()
 
 get_input_fields_by_gender_female ()
 
 get_input_fields_by_field_id ($field_id)
 
 get_input_fields_by_field_name ($field_name)
 
 get_input_fields_by_page ($keyword)
 
 get_input_fields_by_nav ($name)
 
 get_input_value_by_pattern ($pattern, $uid)
 
 get_input_value_pattern ()
 
 set_field_attrs ()
 

Private Member Functions

 fetch_input_fields ($conds=array())
 
 fetch_nav_section_page ($id_section)
 
 fetch_section_name ($id)
 
 fetch_section_page ($id_section)
 
 fetch_section_parent ($id_child)
 
 find_section_page ($id_section)
 

Private Attributes

 $db
 
 $field_attrs
 

Detailed Description

Class to deal with user inputs.

Constructor & Destructor Documentation

◆ __construct()

UserInput::__construct (   $db)
Parameters
object$dbThe db instance which grants access to the DB.
Here is the call graph for this function:

Member Function Documentation

◆ convert_to_valid_html_id()

UserInput::convert_to_valid_html_id (   $string)

Convert a string to HTML valid id

Parameters
string$stringthe string value that we want to convert to a valid HTML id
Return values
stringthe converted string which will be used as ID

◆ fetch_input_fields()

UserInput::fetch_input_fields (   $conds = array())
private

Fetches all user input fields from the database given certain conditions.

Parameters
array$condsA key => value array of db conditions where the key corresponds to the db column and the value to the db value.
Return values
arrayAn array of field items where eeach item has the following keys:
  • 'id' A unique id of the field
  • 'user_code' A unique string that connects values to a user without revealing the identity of the user.
  • 'user_gender' The gender of the user.
  • 'page' The keyword of the page where the data was entered.
  • 'nav' The name of the navigation section where the data was entered.
  • 'field_name' The name of the input field.
  • 'field_label' The label of the input field.
  • 'field_type' The type of the input field. This is either the name of the form field style or if the style is 'input' the input type.
  • 'value' The value that was entered by the user.
  • 'timestamp' The date and time when the value was entered.

Referenced by get_input_fields().

◆ fetch_nav_section_page()

UserInput::fetch_nav_section_page (   $id_section)
private

Fetch the page name to which the given navigation section belongs.

Parameters
int$id_sectionThe id of the section
Returns
string The page name or null if the name could not be found.

Referenced by find_section_page().

◆ fetch_section_name()

UserInput::fetch_section_name (   $id)
private

Fetch the name of a section.

Parameters
int$idThe id of the section
Returns
string The section name or null if the name could not be found.

Referenced by find_section_page().

◆ fetch_section_page()

UserInput::fetch_section_page (   $id_section)
private

Fetch the page name to which the given section belongs.

Parameters
int$id_sectionThe id of the section
Returns
string The page name or null if the name could not be found.

Referenced by find_section_page().

◆ fetch_section_parent()

UserInput::fetch_section_parent (   $id_child)
private

Fetch the id of the parent section.

Parameters
int$id_childThe id of the child section.
Return values
intThe id of the parent section or null if no parent could be found.

Referenced by find_section_page().

◆ find_section_page()

UserInput::find_section_page (   $id_section)
private

Find the page name and navigation section name of a given child section.

Parameters
int$id_sectionThe id of the child section.
Return values
arrayAn array with the keys "page" and "nav" where the former holds the name of the parent page and the latter the name of the parent navigation section.

Referenced by set_field_attrs().

Here is the call graph for this function:

◆ get_input_fields()

UserInput::get_input_fields (   $filter = array())

Get all input fields given a filter

Parameters
array$filterThe filter array can be empty or have any of the following keys:
  • 'id' Selects a field with a given id.
  • 'gender' This can either be set to 'male' or 'female'.
  • 'field_name' Selects all fields with the given name.
  • 'form_name' Selects all fields from the given form name.
  • 'page' Selects all fields on a given page.
  • 'nav' Selects all fields in a given navigation sections.
  • 'id_section' Selects all fields with given section id.
  • 'id_user' Selects all fields from a given user id.
  • 'removed' Selects all fields matching the removed flag
Return values
arrayThe selected user input fields. See UserInput::fetch_input_fields() for more details.

Referenced by get_input_fields_by_field_id(), get_input_fields_by_field_name(), get_input_fields_by_gender_female(), get_input_fields_by_gender_male(), get_input_fields_by_nav(), get_input_fields_by_page(), and get_input_value_by_pattern().

Here is the call graph for this function:

◆ get_input_fields_by_field_id()

UserInput::get_input_fields_by_field_id (   $field_id)

Get all input fields that match a field section id.

Parameters
int$field_idThe field_id to match.
Return values
arrayThe selected user input fields. See UserInput::fetch_input_fields() for more details.
Here is the call graph for this function:

◆ get_input_fields_by_field_name()

UserInput::get_input_fields_by_field_name (   $field_name)

Get all input fields that match a field name.

Parameters
string$field_nameThe field_name to match.
Return values
arrayThe selected user input fields. See UserInput::fetch_input_fields() for more details.
Here is the call graph for this function:

◆ get_input_fields_by_gender_female()

UserInput::get_input_fields_by_gender_female ( )

Get all input fields submitted by female users.

Return values
arrayThe selected user input fields. See UserInput::fetch_input_fields() for more details.
Here is the call graph for this function:

◆ get_input_fields_by_gender_male()

UserInput::get_input_fields_by_gender_male ( )

Get all input fields submitted by male users.

Return values
arrayThe selected user input fields. See UserInput::fetch_input_fields() for more details.
Here is the call graph for this function:

◆ get_input_fields_by_nav()

UserInput::get_input_fields_by_nav (   $name)

Get all input fields that are placed on a given navigation section.

Parameters
string$nameThe navigation section name to match. All navigation sections containing the given name are considered.
Return values
arrayThe selected user input fields. See UserInput::fetch_input_fields() for more details.
Here is the call graph for this function:

◆ get_input_fields_by_page()

UserInput::get_input_fields_by_page (   $keyword)

Get all input fields that are placed on a given page.

Parameters
string$keywordThe page keyword to match.
Return values
arrayThe selected user input fields. See UserInput::fetch_input_fields() for more details.
Here is the call graph for this function:

◆ get_input_value_by_pattern()

UserInput::get_input_value_by_pattern (   $pattern,
  $uid 
)

Get the user input value of an input field specified by a pattern.

Parameters
string$patternA field identifier of the form @<form_name>#<field_name>.
int$uidThe id of a user.
Return values
mixedOn success, the value corresponding to the requested form field, null in case of a bad pattern syntax, and the empty string if no value was found.
Here is the call graph for this function:

◆ get_input_value_pattern()

UserInput::get_input_value_pattern ( )

Returns the regular expression to find a form field

Return values
stringthe regular expression that finds a field identifier of the form @<form_name>#<field_name>.

◆ set_field_attrs()

UserInput::set_field_attrs ( )

Collect attributes for each existing user input field. The following attributes are set:

  • 'page' The name of the parent page of the field.
  • 'nav' The name of the parent navigation section
  • 'name' The name of the field
  • 'type' The type of the field

Referenced by __construct().

Here is the call graph for this function:

Member Data Documentation

◆ $db

UserInput::$db
private

The db instance which grants access to the DB.

Referenced by __construct().

◆ $field_attrs

UserInput::$field_attrs
private

The collection of input field attributes. See UserInput::set_field_attrs.


The documentation for this class was generated from the following file: