Add all the phpdocs to the domframework

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1246 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-03-24 19:44:34 +00:00
parent 1b52b410c3
commit 350aa1dea8
28 changed files with 472 additions and 148 deletions

105
form.php
View File

@@ -1,55 +1,70 @@
<?php
/** DomFramework
@package domframework
@author Dominique Fournier <dominique@fournier38.fr> */
error_reporting (E_ALL);
/** This class permit to create easily some forms to HTML (or text mode in
future).
Each field can be checked in AJAX or HTML. */
class form
{
/** This class permit to create easily some forms to HTML (or text mode in
future).
Each field can be checked in AJAX or HTML. */
/** All the fields */
private $fields = NULL;
/** The name of the form */
private $formName;
/** Allow to debug the PHP */
public $debug=0;
function __construct ($formName = "form")
/** Create a form
@param string|null $formName The form name
*/
public function __construct ($formName = "form")
{
$this->formName = $formName;
}
/** Save the fields into the structure.
Available :
- name : name of the field in the HTML page
- label : label written to the describe the field
- [titles] : text written in radio/checkboxes
- [defaults] : default values. Must be array for checkbox/select, and
string for others
- [type] : text, password, hidden, checkbox, select, radio, submit
text by default
- [multiple] : Multiple selection are possible (if the type supports it)
- [group] : define a fieldset and define the title with groupe name
Warning : all the elements of the same group must be
consecutive !
- [readonly] : put a read-only flag on the field (the user see it but
can't interract on it. The value will be sent to next
page
- [verify] : Tests to verify with error priority and associated
message (%s is replaced by field selected value). Order
test from main tests to minor tests.
\$tmpfield can be used as a copy of the current field,
to check the defaults per example
- [error] : array containing (error|warning) => message
@param array $fields The fields to be displayed
*/
public function fields ($fields)
{
/** Save the fields into the structure.
Available :
- name : name of the field in the HTML page
- label : label written to the describe the field
- [titles] : text written in radio/checkboxes
- [defaults] : default values. Must be array for checkbox/select, and
string for others
- [type] : text, password, hidden, checkbox, select, radio, submit
text by default
- [multiple] : Multiple selection are possible (if the type supports it)
- [group] : define a fieldset and define the title with groupe name
Warning : all the elements of the same group must be
consecutive !
- [readonly] : put a read-only flag on the field (the user see it but
can't interract on it. The value will be sent to next
page
- [verify] : Tests to verify with error priority and associated
message (%s is replaced by field selected value). Order
test from main tests to minor tests.
\$tmpfield can be used as a copy of the current field,
to check the defaults per example
- [error] : array containing (error|warning) => message
*/
$this->fields = $fields;
}
/** Return TRUE if the value associated to a field is correct. Return an
array with a severity and a message to explain why a field is not
correct.
Fields can be an array with just one element, then only this element is
checked
@param array $fieldsVerify The fields to verify
@param array|null $valuesVerify The values of the fields to verify
*/
public function verify (&$fieldsVerify, $valuesVerify = NULL)
{
/** Return TRUE if the value associated to a field is correct. Return an
array with a severity and a message to explain why a field is not
correct.
Fields can be an array with just one element, then only this element is
checked */
$ret = array ();
if ($this->debug)
echo "<pre>";
@@ -90,12 +105,15 @@ class form
return $ret;
}
/** Return the fields in HTML code. If $values is provided, use it in place
of default values. In case of select boxes, $values are the selected
elements
$method is the method written in method field of <form>
@param string|null $method The method to use to transmit the form (POST,
GET)
@param array|null $values The default values of the fields */
public function printHTML ($method = 'post', $values = NULL)
{
/** Return the fields in HTML code. If $values is provided, use it in place
of default values. In case of select boxes, $values are the selected
elements
$method is the method written in method field of <form> */
// TODO : textarea, file
$res = "";
$res = "<form action='#' method='$method'";
@@ -386,18 +404,33 @@ class form
}
}
/** the definition of a formfield */
class formfield
{
/** The name of the field */
public $name;
/** The label of the field */
public $label;
/** The titles of the field */
public $titles;
/** The defaults values of the field */
public $defaults;
/** The type of the field (text, password, checkbox, select)*/
public $type;
/** The multiplicity of selection of the field (available in select only)*/
public $multiple;
/** The name of group for the fields */
public $group;
/** The read-only feature of the field */
public $readonly;
/** The fonction used to verify the field by AJAX before submitting and
by PHP after submission*/
public $verify;
/** The statut of error of the field */
public $error;
/** When adding a field, the name and the label are the minimum mandatory
@param string $name Name of the field
@param string $label Label of the field */
function __construct ($name, $label)
{
$this->name = $name;