Alive Fields
1.01
|
Public Member Functions | |
__construct ($field, $table, $id, $loadable, $savable) | |
__destruct () | |
__toString () | |
add_filters ($filt) | |
bind ($html_element_id) | |
do_validations (&$prev_value, $key_val) | |
differentiate_options ($field, $table, $pkey) | |
do_js_includes_for_this_control () | |
generate_controller_header () | |
get_field_type_for_javascript () | |
get_js_fieldname () | |
& | get_session_object () |
get_unique_id () | |
include_basics () | |
load_unchecked ($key) | |
register_validator ($callback) | |
request_handler ($request) | |
set_dependent_fields ($arr) | |
set_filtered_fields ($filt) | |
set_property ($prop, $val) | |
set_adapter ($adapter) | |
Static Public Member Functions | |
static | add_head_output ($html_code) |
static | add_output ($js_code) |
static | flush_head_output () |
static | flush_output () |
static | instance_from_id ($id) |
static | handle_all_requests () |
static | include_js_file ($file) |
static | register_error ($string) |
static | set_default_adapter ($adapter) |
Data Fields | |
const | LOAD_NO = 0 |
const | LOAD_WHEN_FILTERED = 1 |
const | LOAD_YES = 2 |
const | SAVE_NO_CHANGE_NO = -1 |
const | SAVE_NO = 0 |
const | SAVE_YES = 1 |
const | ERROR_LOAD_DISALLOWED = "Field not loadable" |
const | ERROR_SAVE_DISALLOWED = "Field not savable" |
const | ERROR_INVALID_TOKEN = "Invalid Token In Session" |
$adapter | |
$bound_field | |
$bound_table | |
$bound_pkey | |
$filters | |
$loadable | |
$savable | |
$type_temp | |
$type | |
$filtered_fields | |
$hardcoded_loads | |
Static Public Attributes | |
static | $included_js_files |
static | $output_mode = "postponed" |
static | $cached_output |
static | $cached_head_output |
static | $basics_included |
static | $include_directory_js = "/js" |
static | $path_to_start_php = "AliveFields" |
static | $path_to_jquery = "/jquery.js" |
static | $path_to_jqueryui = "/jquery-ui.js" |
static | $path_to_controls = "/controls" |
static | $include_js_manually = false |
static | $silence_errors = false |
static | $unique_session_token |
Protected Attributes | |
$validators | |
Static Protected Attributes | |
static | $all_instances |
AcField is the PHP heart of this project.
It is the base class from which all other components derive (much in the way that AcControl is in the javascript portion). All of these classes act as controllers, handling various ajax requests and connecting themselves to your view (which is pure HTML).
__construct | ( | $ | field, |
$ | table, | ||
$ | id, | ||
$ | loadable, | ||
$ | savable | ||
) |
A control's internal value will be: SELECT $id FROM $table A control's displayed value will be: SELECT $field FROM $table WHERE $id = (loaded_value)
string | $field | The fieldname of the field which this control should represent |
string | $table | The table in which $field is stored |
string | $id | Fieldname that acts as the primary key in $table. |
CONST | $loadable | Expects Ac_Field::LOAD_NO, ::LOAD_YES, or ::LOAD_WHEN_FILTERED |
CONST | $savable | Expects Ac_Field::SAVE_NO, ::SAVE_YES, or ::SAVE_NO_CHANGE_NO |
Reimplemented in AcList.
__destruct | ( | ) |
Destructor. Provide useful error message in event of newbie mistake.
add_filters | ( | $ | filt | ) |
This function sets the filters applied *TO* this field. That is to say, the filters that *affect this field* [NOT filters from this field]. This is opposite of Set_filtered_fields
[multiple] | $filt Accepts either a single filter [assoc array] or an array of filters [multidimensional array] Each filter is an array with 3 elements: [field], [relationship], [value] e.g. UserId > 6 or Username like 'Jon' or Age = 3 |
static add_head_output | ( | $ | html_code | ) | [static] |
Add output that should be displayed in the head (namely javascript includes)
static add_output | ( | $ | js_code | ) | [static] |
Displays provided javascript appropriately.
bind | ( | $ | html_element_id | ) |
Inform the javascript class which HTML element id it should connect with.
string | $html_element_id | The id of the html element to connect this control to. |
Include the relevant javascript files necessary to power the view.
Reimplemented in AcListJoin, AcList, AcDatebox, AcListCombo, AcCheckbox, and AcTextbox.
do_validations | ( | &$ | prev_value, |
$ | key_val | ||
) |
Determine if this field meets all validator criteria
variant | $prev_value | Unvalidate value |
variant | $key_val | ID of unvalidate value's row (primary key) |
static flush_head_output | ( | ) | [static] |
Dumps includes that need to be in the HEAD of the html document
static flush_output | ( | ) | [static] |
Outputs the entire output buffer.
This is necessary because controls are declared before the document start, where obviously javascript cannot be displayed yet.
Outputs the decided headers for a controller's ajax response to the view.
get_field_type_for_javascript | ( | ) | [abstract] |
Reimplemented in AcListJoin, AcDatebox, AcListCombo, AcCheckbox, AcTextbox, and AcListSelect.
get_js_fieldname | ( | ) |
Provides the instance name of the javascript object that this class communicates with.
& get_session_object | ( | ) |
Return a unique session spot for this control to store relevant security information that can't be trusted to the client.
get_unique_id | ( | ) |
accessor
static handle_all_requests | ( | ) | [static] |
Dispatch the request to the appropriate Acfield's request_handler, so it can act as the controller.
include_basics | ( | ) |
This function sets up a dependency for the page exactly once.
static include_js_file | ( | $ | file | ) | [static] |
Includes a given javascript file
string | $file | a javascript filename |
static instance_from_id | ( | $ | id | ) | [static] |
This function returns a particular instance from an ID (useful for passing IDs through session)
Every instance of AcField is generated a unique id (integer). This allows us to have one unique number that acts as an identifier *across requests* to show us where to direct controller requests to.
This function convers such a unique id back into the relevant instance of AcField
int | $id | The id for which you seek the corresponding AcField. |
load_unchecked | ( | $ | key | ) |
Load a value of a field based on a specified key.
static register_error | ( | $ | string | ) | [static] |
outputs library-generated errors.
Alter this function as appropriate for your level of experience, error reporting system, and development/release systems.
register_validator | ( | $ | callback | ) |
This function registers a validator
request_handler | ( | $ | request | ) |
This function determine loads and executes the relevant controller for this request.
This handles the back-end power ajax requests submitted by the views, for this particular field. This acts as the controller to the view request.
Reimplemented in AcListJoin, and AcList.
set_adapter | ( | $ | adapter | ) |
Sets the backend adapter for this Ajax control Field
(implements | AcAadpter_Interface) $adapter The backed adapter to retrieve/retain AcField values. |
set_dependent_fields | ( | $ | arr | ) |
Set the list of fields that this field will call load upon when this field changes value.
array | of AcField $arr the fields to update |
set_filtered_fields | ( | $ | filt | ) |
This sets the array of filters that STEM FROM this field (not that apply to it). In this respect this function is the opposite of add_filters. Accepts an array of filters (assoc arrays) that have keys [type] = ("value" / "text") , ['control'] = the actual AcField being updated
set_property | ( | $ | prop, |
$ | val | ||
) |
Sets an attribute of the corresponding javascript class instance.
const ERROR_LOAD_DISALLOWED = "Field not loadable" |
The coder has stipulated that this field should not be loadable likely by using READ_NO.
const ERROR_SAVE_DISALLOWED = "Field not savable" |
The coder has stipulated that this field should not be savable likely by using SAVE_NO.
const SAVE_NO_CHANGE_NO = -1 |
Additionally tells the client-side control to act as read-only / locked.