Andrew's Web Libraries (AWL)
Editor Class Reference

Public Member Functions

 __construct ( $title="", $fields=null)
 
AddField ( $field, $sql="", $lookup_sql="")
 
 SetSql ( $field, $sql)
 
 SetLookup ( $field, $lookup_sql)
 
 Value ( $value_field_name)
 
 Assign ( $value_field_name, $new_value)
 
 Id ( $id=null)
 
 SetOptionList ( $field, $options, $current=null, $parameters=null)
 
 AddAttribute ( $field, $k, $v)
 
 SetBaseTable ( $base_table)
 
 SetJoins ( $join_list)
 
 Title ( $new_title=null)
 
 SetSubmitName ( $new_submit)
 
 IsSubmit ()
 
 IsUpdate ()
 
 IsCreate ()
 
 SetWhere ( $where_clause)
 
 WhereNewRecord ( $where_clause)
 
 MoreWhere ( $operator, $more_where)
 
 AndWhere ( $more_where)
 
 OrWhere ( $more_where)
 
 SetTemplate ( $template)
 
 Layout ( $template)
 
 Available ()
 
 SetRecord ( $row)
 
 Initialise ( $values)
 
 PostToValues ( $prefix='')
 
 GetRecord ( $where="")
 
 ReplaceEditorPart ($matches)
 
 Render ( $title_tag=null)
 
 Write ( $is_update=null)
 

Public Attributes

 $Title
 
 $Action
 
 $Fields
 
 $OrderedFields
 
 $BaseTable
 
 $Joins
 
 $Where
 
 $NewWhere
 
 $Order
 
 $Limit
 
 $Query
 
 $Template
 
 $RecordAvailable
 
 $Record
 
 $SubmitName
 
 $Id
 

Detailed Description

Definition at line 160 of file classEditor.php.

Constructor & Destructor Documentation

◆ __construct()

Editor::__construct (   $title = "",
  $fields = null 
)

Constructs an editor widget, with a title and fields.

The second parameter maybe passed as a string, to be interpreted as the name of a table, from which all fields will be included, or as an array of specific fields, in which case you should make sure to call SetBaseTable('tablename') so the editor knows where to find those fields!

Parameters
string$title
arrayor string $fields See above

Definition at line 189 of file classEditor.php.

Member Function Documentation

◆ AddAttribute()

Editor::AddAttribute (   $field,
  $k,
  $v 
)

Add an attribute to this field.

Parameters
unknown$field
unknown$k
unknown$v

Definition at line 299 of file classEditor.php.

◆ AddField()

& Editor::AddField (   $field,
  $sql = "",
  $lookup_sql = "" 
)

Creates a new field in the Editor, possibly initialising the SQL for calculating it's value, and lookup_sql for use in drop-down lists.

Parameters
string$fieldThe name for the field.
string$sqlThe SQL for the target list. Think: "$sql AS $field"
string$lookup_sqlThe SQL for looking up a list of possible stored values and displayed values.

Definition at line 226 of file classEditor.php.

◆ Assign()

Editor::Assign (   $value_field_name,
  $new_value 
)

Assigns the value of a field in the record currently associated with this editor.

Parameters
string$value_field_name
string$new_value

Definition at line 266 of file classEditor.php.

◆ Available()

Editor::Available ( )

Returns 'true' if we have read a row from the database (or set one through SetRecord()), 'false' otherwise.

Returns
boolean

Definition at line 432 of file classEditor.php.

◆ GetRecord()

Editor::GetRecord (   $where = "")

Read the record from the database, optionally overriding the WHERE clause.

Parameters
string$where(optional) An SQL WHERE clause to override any previous SetWhere call.
Returns
object The row that was read from the database.

Definition at line 482 of file classEditor.php.

◆ Id()

Editor::Id (   $id = null)

Sets or returns the form ID used for differentiating this form from others in the page.

Parameters
string$id

Definition at line 275 of file classEditor.php.

◆ Initialise()

Editor::Initialise (   $values)

Set some particular values to the ones from the array.

Parameters
array$valuesAn array of fieldname / value pairs

Definition at line 453 of file classEditor.php.

◆ IsCreate()

Editor::IsCreate ( )

The opposite of IsUpdate. Really.

Returns
boolean

Definition at line 362 of file classEditor.php.

◆ IsUpdate()

Editor::IsUpdate ( )

Magically knows whether you are in the processing the result of an update or a create.

Returns
boolean

Definition at line 349 of file classEditor.php.

◆ Layout()

Editor::Layout (   $template)

Like SetTemplate($template) except it surrounds the template with a ##form## ... </form> if there is not a form already in the template.

Parameters
string$template

Definition at line 420 of file classEditor.php.

◆ MoreWhere()

Editor::MoreWhere (   $operator,
  $more_where 
)

Append more stuff to the WHERE clause

Parameters
unknown$operator
unknown$more_where

Definition at line 387 of file classEditor.php.

◆ PostToValues()

Editor::PostToValues (   $prefix = '')

This will assign $_POST values to the internal Values object for each field that exists in the Fields array.

Definition at line 466 of file classEditor.php.

◆ Render()

Editor::Render (   $title_tag = null)

Render the templated component. The heavy lifting is done by the callback...

Definition at line 658 of file classEditor.php.

◆ ReplaceEditorPart()

Editor::ReplaceEditorPart (   $matches)

Replace parts into the form template. Parts that are replaceable are listed below:

form## A <form ...> tag. You should close this with or use Layout($template) which will take care of it for you.

submit## A <input type="submit" ...> tag for the form.

f.options## A list of options explicitly specified

f.select## A select list from the lookup SQL specified

f.checkbox## A checkbox, perhaps with a "_label" attribute

f.input## A normal input field.

f.file## A file upload field.

f.money## A money input field.

f.date## A date input field.

f.textarea## A textarea

f.hidden## A hidden input field

f.password## An input field for entering passwords without them being echoed to the screen

f.enc## Just print the value with special chars escaped for use in URLs.

f.submit## An <input type="submit" where you specify the field name.

Most of these begin with "f", which should be replaced by the name of the field. Many also take an option after the name as well, so (for example) you can force the current value in ##options## or ##select## by setting ##field.select.current##. The input, file, money & date all accept the third parameter as a size value, so ##fieldname.date.14## would be a 14-character-wide date field. Similarly a textarea allows for a COLSxROWS value, so ##myfield.textarea.80x5## would be an 80-column textarea, five rows high.

For ##fieldname.password.fakevalue## you can set the 'fake' value used to populate the password field so that you can check for this on submit to be able to tell whether the password field has been edited.

Other attributes are added to the <input ...> tag based on any SetAttributes() that may have been applied.

Parameters
array$matchesThe matches found which preg_replace_callback is calling us for.
Returns
string What we want to replace this match with.
Todo:
It might be nice to construct a form ID

Definition at line 536 of file classEditor.php.

◆ SetBaseTable()

Editor::SetBaseTable (   $base_table)

Set the base table for the row query.

Parameters
unknown$base_table

Definition at line 308 of file classEditor.php.

◆ SetJoins()

Editor::SetJoins (   $join_list)

Set any joins

Parameters
unknown$join_list

Definition at line 316 of file classEditor.php.

◆ SetLookup()

Editor::SetLookup (   $field,
  $lookup_sql 
)

Set the SQL for looking up a list of possible stored values and displayed values.

Parameters
string$field
string$lookup_sql

Definition at line 246 of file classEditor.php.

◆ SetOptionList()

Editor::SetOptionList (   $field,
  $options,
  $current = null,
  $parameters = null 
)

Set the explicit options & parameters for a list of stored/displayed values. See the description under EditorField::SetOptionList() for full details.

Parameters
string$field
array$optionsA key => value array of valid store => display values.
string$currentThe key of the current row
string$parametersSet maxwidth & whether displayed values are translated.

Definition at line 289 of file classEditor.php.

◆ SetRecord()

Editor::SetRecord (   $row)

Set a database row to load the field values from.

Parameters
object$row
Returns
object The row that was passed in.

Definition at line 442 of file classEditor.php.

◆ SetSql()

Editor::SetSql (   $field,
  $sql 
)

Set the SQL for this field for the target list. Think: "$sql AS $field"

Parameters
string$field
string$sql

Definition at line 237 of file classEditor.php.

◆ SetSubmitName()

Editor::SetSubmitName (   $new_submit)

Set the name of the SUBMIT button

Parameters
unknown$new_submit

Definition at line 337 of file classEditor.php.

◆ SetTemplate()

Editor::SetTemplate (   $template)

Set this to be the form display template. It's better to use Layout($template) in general.

Deprecated:
Parameters
string$template

Definition at line 409 of file classEditor.php.

◆ SetWhere()

Editor::SetWhere (   $where_clause)

Set the row selection criteria

Parameters
unknown$where_clause

Definition at line 370 of file classEditor.php.

◆ Title()

Editor::Title (   $new_title = null)

Accessor for the Title for the editor, which could set the title also.

Parameters
string$new_titleThe new title for the browser
Returns
string The current title for the browser

Definition at line 327 of file classEditor.php.

◆ Value()

Editor::Value (   $value_field_name)

Gets the value of a field in the record currently assigned to this editor.

Parameters
string$value_field_name

Definition at line 256 of file classEditor.php.

◆ WhereNewRecord()

Editor::WhereNewRecord (   $where_clause)

Set the criteria used to find the new row after it got created.

Parameters
unknown$where_clause

Definition at line 378 of file classEditor.php.

◆ Write()

Editor::Write (   $is_update = null)

Write the record. You might want to consider calling Editor::WhereNewRecord() before this if it might be creating a new record.

Parameters
boolean$is_updateExplicitly tell the write whether it's an update or insert. Generally it should be able to figure it out though.
Todo:
Our old approach will not work for translation. We need to have a hidden field containing the submittype. Probably we should add placeholders like ##form##, ##script## etc. which the editor can use for internal purposes.

Definition at line 680 of file classEditor.php.


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