'; // External block end tag
- //
+ // HTML attributes
const LABEL = 'title';
const REGEX = 'regex';
const TITLE = 'description';
- const REQUIRED = 'udf-required';
+ const REQUIRED = 'required-field';
const MAX_VALUE = 'max-value';
const MIN_VALUE = 'min-value';
const MAX_LENGTH = 'max-length';
const MIN_LENGTH = 'min-length';
const PLACEHOLDER = 'placeholder';
+ // Alias of $this->_args[HTMLWidget::HTML_ARG_NAME] for a better code readability
+ protected $htmlParameters;
+
/**
* It gets also the htmlArgs array as parameter, it will be used to set the HTML properties
*/
@@ -61,10 +64,13 @@ class HTMLWidget extends Widget
$this->_args[HTMLWidget::HTML_ARG_NAME][$argName] = $argValue;
}
}
+
+ $this->htmlParameters =& $this->_args[HTMLWidget::HTML_ARG_NAME]; // Reference for a better code readability
}
/**
- *
+ * Prints an attribute name and eventually also the value extracted from $htmlArgs
+ * Set $isValuePresent to false the value should not be displayed
*/
public static function printAttribute($htmlArgs, $attribute, $isValuePresent = true)
{
@@ -92,7 +98,7 @@ class HTMLWidget extends Widget
}
/**
- *
+ * Prints the external block start tag
*/
public static function printStartBlock($htmlArgs)
{
@@ -104,7 +110,7 @@ class HTMLWidget extends Widget
}
/**
- *
+ * Prints the external block end tag
*/
public static function printEndBlock($htmlArgs)
{
diff --git a/application/widgets/html/TextareaWidget.php b/application/widgets/html/TextareaWidget.php
index ffb9e538d..b98c21b25 100644
--- a/application/widgets/html/TextareaWidget.php
+++ b/application/widgets/html/TextareaWidget.php
@@ -5,12 +5,12 @@
*/
class TextareaWidget extends HTMLWidget
{
- const TEXT = 'text'; //
- const ROWS = 'rows'; //
- const COLS = 'cols'; //
+ const TEXT = 'text'; // Text value
+ const ROWS = 'rows'; // Rows attribute
+ const COLS = 'cols'; // Cols attribute
/**
- *
+ * Set the text value
*/
protected function setText($text)
{
@@ -18,7 +18,7 @@ class TextareaWidget extends HTMLWidget
}
/**
- *
+ * Loads the view that renders a text area
*/
protected function loadTextareaView()
{
diff --git a/application/widgets/html/TextfieldWidget.php b/application/widgets/html/TextfieldWidget.php
index e5ad146c9..5468499e3 100644
--- a/application/widgets/html/TextfieldWidget.php
+++ b/application/widgets/html/TextfieldWidget.php
@@ -5,11 +5,11 @@
*/
class TextfieldWidget extends HTMLWidget
{
- const VALUE = 'text'; //
- const SIZE = 'size'; //
+ const VALUE = 'text'; // Text value
+ const SIZE = 'size'; // Size attribute
/**
- *
+ * Set the text value
*/
protected function setValue($value)
{
@@ -17,7 +17,7 @@ class TextfieldWidget extends HTMLWidget
}
/**
- *
+ * Loads the view that renders an input text
*/
protected function loadTextfieldView()
{
diff --git a/application/widgets/udf/CheckboxWidgetUDF.php b/application/widgets/udf/CheckboxWidgetUDF.php
index 096a7a737..7a71c8743 100644
--- a/application/widgets/udf/CheckboxWidgetUDF.php
+++ b/application/widgets/udf/CheckboxWidgetUDF.php
@@ -1,12 +1,12 @@
content() is needed
*/
public function render()
{
diff --git a/application/widgets/udf/DropdownWidgetUDF.php b/application/widgets/udf/DropdownWidgetUDF.php
index 46a3f9733..04552e953 100644
--- a/application/widgets/udf/DropdownWidgetUDF.php
+++ b/application/widgets/udf/DropdownWidgetUDF.php
@@ -1,53 +1,60 @@
content() is needed
*/
public function render($parameters)
{
- $tmpElements = array();
+ // Array that will contains the elements to be displayed in the dropdown
+ $tmpNewElements = array();
- //
+ // Loops through the given parameters
foreach($parameters as $parameter)
{
- //
+ // Every single element of the array is checked, and it could only be:
+ // - An array with two elements OR
+ // - A string or a number OR
+ // - An object with two properties: id and description
if ((is_array($parameter) && count($parameter) == 2)
|| (is_string($parameter) || is_numeric($parameter))
- || (is_object($parameter) && isset($parameter->{PARENT::ID_FIELD}) && isset($parameter->{PARENT::DESCRIPTION_FIELD})))
+ || (is_object($parameter) && isset($parameter->{DropdownWidget::ID_FIELD})
+ && isset($parameter->{DropdownWidget::DESCRIPTION_FIELD})))
{
- $element = new stdClass(); //
- //
+ $newElement = new stdClass(); // New single element
+ // If the single element is an array of two element
if (is_array($parameter) && count($parameter) == 2)
{
- $element->{PARENT::ID_FIELD} = $parameter[0]; //
- $element->{PARENT::DESCRIPTION_FIELD} = $parameter[1]; //
+ $newElement->{DropdownWidget::ID_FIELD} = $parameter[0]; //
+ $newElement->{DropdownWidget::DESCRIPTION_FIELD} = $parameter[1]; //
}
- //
+ // If the single element is a string or a number
else if (is_string($parameter) || is_numeric($parameter))
{
- $element->{PARENT::ID_FIELD} = $parameter; //
- $element->{PARENT::DESCRIPTION_FIELD} = $parameter; //
+ $newElement->{DropdownWidget::ID_FIELD} = $parameter; //
+ $newElement->{DropdownWidget::DESCRIPTION_FIELD} = $parameter; //
}
- //
- else if (is_object($parameter) && isset($parameter->{PARENT::ID_FIELD}) && isset($parameter->{PARENT::DESCRIPTION_FIELD}))
+ // If the single element is an object with two properties: id and description
+ else if (is_object($parameter) && isset($parameter->{DropdownWidget::ID_FIELD})
+ && isset($parameter->{DropdownWidget::DESCRIPTION_FIELD}))
{
- $element->{PARENT::ID_FIELD} = $parameter->{PARENT::ID_FIELD}; //
- $element->{PARENT::DESCRIPTION_FIELD} = $parameter->{PARENT::DESCRIPTION_FIELD}; //
+ $newElement->{DropdownWidget::ID_FIELD} = $parameter->{DropdownWidget::ID_FIELD}; //
+ $newElement->{DropdownWidget::DESCRIPTION_FIELD} = $parameter->{DropdownWidget::DESCRIPTION_FIELD}; //
}
- array_push($tmpElements, $element); //
+ array_push($tmpNewElements, $newElement); // Add $newElement into $tmpNewElements
}
}
+ // Set the list of elements
$this->setElementsArray(
- success($tmpElements),
+ success($tmpNewElements),
true,
- $this->_args[HTMLWidget::HTML_ARG_NAME][HTMLWidget::PLACEHOLDER],
+ $this->htmlParameters[HTMLWidget::PLACEHOLDER],
'No data found for this UDF'
);
diff --git a/application/widgets/udf/TextareaWidgetUDF.php b/application/widgets/udf/TextareaWidgetUDF.php
index d64015190..8fa3ace53 100644
--- a/application/widgets/udf/TextareaWidgetUDF.php
+++ b/application/widgets/udf/TextareaWidgetUDF.php
@@ -1,12 +1,12 @@
content() is needed
*/
public function render($parameters)
{
diff --git a/application/widgets/udf/TextfieldWidgetUDF.php b/application/widgets/udf/TextfieldWidgetUDF.php
index 2d78b0d1a..7ad9214f8 100644
--- a/application/widgets/udf/TextfieldWidgetUDF.php
+++ b/application/widgets/udf/TextfieldWidgetUDF.php
@@ -1,12 +1,12 @@
content() is needed
*/
public function render($parameters)
{
diff --git a/application/widgets/udf/UDFWidget.php b/application/widgets/udf/UDFWidget.php
index 9168c86da..830aadb6b 100644
--- a/application/widgets/udf/UDFWidget.php
+++ b/application/widgets/udf/UDFWidget.php
@@ -1,79 +1,76 @@
_loadUDF($schema, $table);
+ $udfResults = $this->_loadUDF($schema, $table); // loads UDF definition
if (hasData($udfResults))
{
- $udf = $udfResults->retval[0];
+ $udf = $udfResults->retval[0]; // only one record is loaded
if (isset($udf->jsons))
{
- $jsonSchemas = json_decode($udf->jsons);
+ $jsonSchemas = json_decode($udf->jsons); // decode the json schema
if (is_object($jsonSchemas) || is_array($jsonSchemas))
{
- //
+ // If the schema is an object then convert it into an array
if (is_object($jsonSchemas))
{
$jsonSchemasArray = array($jsonSchemas);
}
- else
+ else // keep it as it is
{
$jsonSchemasArray = $jsonSchemas;
}
- $found = false; //
+ $found = false; // used to check if the field is found or not in the json schema
- $this->_sortJsonSchemas($jsonSchemasArray); //
+ $this->_sortJsonSchemas($jsonSchemasArray); // Sort the list of UDF by sort property
- //
+ // Loops through json schemas
foreach($jsonSchemasArray as $jsonSchema)
{
- //
- if (!isset($jsonSchema->{UDFWidget::TYPE}))
+ // If the type property is not present then show an error
+ if (!isset($jsonSchema->{UDFLib::TYPE}))
{
show_error(sprintf('%s.%s: Attribute "type" not present in the json schema', $schema, $table));
break;
}
- if (!isset($jsonSchema->{UDFWidget::NAME}))
+ // If the name property is not present then show an error
+ if (!isset($jsonSchema->{UDFLib::NAME}))
{
show_error(sprintf('%s.%s: Attribute "name" not present in the json schema', $schema, $table));
break;
}
- //
- if ((isset($field) && $field == $jsonSchema->{UDFWidget::NAME}) || !isset($field))
+ // If a UDF is specified and is present in the json schemas list or no UDF is specified
+ if ((isset($field) && $field == $jsonSchema->{UDFLib::NAME}) || !isset($field))
{
- $this->_setAttributesWithPhrases($jsonSchema);
+ $this->_setAttributesWithPhrases($jsonSchema); // Set attributes using phrases
- $this->_setValidationAttributes($jsonSchema);
+ $this->_setValidationAttributes($jsonSchema); // Set validation attributes
- $this->_setNameAndId($jsonSchema);
+ $this->_setNameAndId($jsonSchema); // Set name and id attributes
- $this->_render($jsonSchema);
+ $this->_render($jsonSchema); // Render the HTML for this UDF
- //
- if (isset($field) && $field == $jsonSchema->{UDFWidget::NAME})
+ // If a UDf is specified and it was found then stop looking through this list
+ if (isset($field) && $field == $jsonSchema->{UDFLib::NAME})
{
$found = true;
break;
@@ -81,18 +78,18 @@ class UDFWidget extends HTMLWidget
}
}
- //
+ // If a UDf is specified and it was not found then show an error
if (isset($field) && !$found)
{
show_error(sprintf('%s.%s: No schema present for field: %s', $schema, $table, $field));
}
}
- else
+ else // not a valid schema
{
show_error(sprintf('%s.%s: Not a valid json schema', $schema, $table));
}
}
- else
+ else // no json column present in table tbl_udf
{
show_error(sprintf('%s.%s: Does not contain "jsons" field', $schema, $table));
}
@@ -100,42 +97,42 @@ class UDFWidget extends HTMLWidget
}
/**
- *
+ * Set the name and id attribute of the HTML element
*/
private function _setNameAndId($jsonSchema)
{
- $this->_args[HTMLWidget::HTML_ARG_NAME][HTMLWidget::HTML_ID] = $jsonSchema->{UDFWidget::NAME};
- $this->_args[HTMLWidget::HTML_ARG_NAME][HTMLWidget::HTML_NAME] = $jsonSchema->{UDFWidget::NAME};
+ $this->htmlParameters[HTMLWidget::HTML_ID] = $jsonSchema->{UDFLib::NAME};
+ $this->htmlParameters[HTMLWidget::HTML_NAME] = $jsonSchema->{UDFLib::NAME};
}
/**
- *
+ * Sort the list of UDF by sort property
*/
private function _sortJsonSchemas(&$jsonSchemasArray)
{
//
usort($jsonSchemasArray, function ($a, $b) {
//
- if (!isset($a->sort))
+ if (!isset($a->{UDFLib::SORT}))
{
- $a->sort = 9999;
+ $a->{UDFLib::SORT} = 9999;
}
- if (!isset($b->sort))
+ if (!isset($b->{UDFLib::SORT}))
{
- $b->sort = 9999;
+ $b->{UDFLib::SORT} = 9999;
}
- if ($a->sort == $b->sort)
+ if ($a->{UDFLib::SORT} == $b->{UDFLib::SORT})
{
return 0;
}
- return ($a->sort < $b->sort) ? -1 : 1;
+ return ($a->{UDFLib::SORT} < $b->{UDFLib::SORT}) ? -1 : 1;
});
}
/**
- *
+ * Loads the UDF description by the given schema and table
*/
private function _loadUDF($schema, $table)
{
@@ -173,46 +170,52 @@ class UDFWidget extends HTMLWidget
}
/**
- *
+ * Render the HTML for the UDF
*/
private function _render($jsonSchema)
{
- // Type
- if ($jsonSchema->{UDFWidget::TYPE} == 'checkbox')
+ // Checkbox
+ if ($jsonSchema->{UDFLib::TYPE} == 'checkbox')
{
$this->_renderCheckbox($jsonSchema);
}
- else if ($jsonSchema->{UDFWidget::TYPE} == 'textfield')
+ // Textfield
+ else if ($jsonSchema->{UDFLib::TYPE} == 'textfield')
{
$this->_renderTextfield($jsonSchema);
}
- else if ($jsonSchema->{UDFWidget::TYPE} == 'textarea')
+ // Textarea
+ else if ($jsonSchema->{UDFLib::TYPE} == 'textarea')
{
$this->_renderTextarea($jsonSchema);
}
- else if ($jsonSchema->{UDFWidget::TYPE} == 'date')
+ // Date
+ else if ($jsonSchema->{UDFLib::TYPE} == 'date')
{
}
- else if ($jsonSchema->{UDFWidget::TYPE} == 'dropdown')
+ // Dropdown
+ else if ($jsonSchema->{UDFLib::TYPE} == 'dropdown')
{
$this->_renderDropdown($jsonSchema);
}
- else if ($jsonSchema->{UDFWidget::TYPE} == 'multipledropdown')
+ // Multiple dropdown
+ else if ($jsonSchema->{UDFLib::TYPE} == 'multipledropdown')
{
$this->_renderDropdown($jsonSchema, true);
}
}
/**
- *
+ * Renders a dropdown element
*/
private function _renderDropdown($jsonSchema, $multiple = false)
{
+ // Selected element/s
if (isset($this->_args[UDFLib::UDFS_ARG_NAME])
- && isset($this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}]))
+ && isset($this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}]))
{
- $this->_args[DropdownWidget::SELECTED_ELEMENT] = $this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}];
+ $this->_args[DropdownWidget::SELECTED_ELEMENT] = $this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}];
}
else
{
@@ -222,22 +225,22 @@ class UDFWidget extends HTMLWidget
$dropdownWidgetUDF = new DropdownWidgetUDF($this->_name, $this->_args);
$parameters = array();
- //
- if (isset($jsonSchema->{UDFWidget::LIST_VALUES}->enum))
+ // If the list of values to show is an array
+ if (isset($jsonSchema->{UDFLib::LIST_VALUES}->enum))
{
- $parameters = $jsonSchema->{UDFWidget::LIST_VALUES}->enum;
+ $parameters = $jsonSchema->{UDFLib::LIST_VALUES}->enum;
}
- //
- else if (isset($jsonSchema->{UDFWidget::LIST_VALUES}->sql))
+ // If the list of values to show should be retrived with a SQL statement
+ else if (isset($jsonSchema->{UDFLib::LIST_VALUES}->sql))
{
- $queryResult = $this->UDFModel->execQuery($jsonSchema->{UDFWidget::LIST_VALUES}->sql);
+ $queryResult = $this->UDFModel->execQuery($jsonSchema->{UDFLib::LIST_VALUES}->sql);
if (hasData($queryResult))
{
$parameters = $queryResult->retval;
}
}
- if ($multiple)
+ if ($multiple) // multiple dropdown
{
$dropdownWidgetUDF->setMultiple();
}
@@ -246,52 +249,55 @@ class UDFWidget extends HTMLWidget
}
/**
- *
+ * Renders a textarea element
*/
private function _renderTextarea($jsonSchema)
{
+ $text = null; // text value
$textareaUDF = new TextareaWidgetUDF($this->_name, $this->_args);
- $text = null;
+ // Set text value if present in the DB
if (isset($this->_args[UDFLib::UDFS_ARG_NAME])
- && isset($this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}]))
+ && isset($this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}]))
{
- $text = $this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}];
+ $text = $this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}];
}
$textareaUDF->render($text);
}
/**
- *
+ * Renders an input text element
*/
private function _renderTextfield($jsonSchema)
{
+ $text = null; // text value
$textareaUDF = new TextfieldWidgetUDF($this->_name, $this->_args);
- $text = null;
+ // Set text value if present in the DB
if (isset($this->_args[UDFLib::UDFS_ARG_NAME])
- && isset($this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}]))
+ && isset($this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}]))
{
- $text = $this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}];
+ $text = $this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}];
}
$textareaUDF->render($text);
}
/**
- *
+ * Renders a checkbox element
*/
private function _renderCheckbox($jsonSchema)
{
+ // Set checkbox value if present in the DB
if (isset($this->_args[UDFLib::UDFS_ARG_NAME])
- && isset($this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}]))
+ && isset($this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}]))
{
- $this->_args[CheckboxWidget::VALUE_FIELD] = $this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}];
+ $this->_args[CheckboxWidget::VALUE_FIELD] = $this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFLib::NAME}];
}
else
{
- $this->_args[CheckboxWidget::VALUE_FIELD] = HTMLWidget::HTML_DEFAULT_VALUE;
+ $this->_args[CheckboxWidget::VALUE_FIELD] = CheckboxWidget::HTML_DEFAULT_VALUE;
}
$checkboxWidgetUDF = new CheckboxWidgetUDF($this->_name, $this->_args);
@@ -300,7 +306,7 @@ class UDFWidget extends HTMLWidget
}
/**
- *
+ * Sets the attributes of the HTML element using the phrases system
*/
private function _setAttributesWithPhrases($jsonSchema)
{
@@ -309,14 +315,15 @@ class UDFWidget extends HTMLWidget
|| isset($jsonSchema->{UDFLib::TITLE})
|| isset($jsonSchema->{UDFLib::PLACEHOLDER}))
{
- //
+ // Loads PhrasesLib
$this->_ci->load->library('PhrasesLib');
- //
+ // If is set the label property in the json schema
if (isset($jsonSchema->{UDFLib::LABEL}))
{
+ // Load the related phrase
$tmpResult = $this->_ci->phraseslib->getPhrases(
- UDFWidget::PHRASES_APP_NAME,
+ UDFLib::PHRASES_APP_NAME,
DEFAULT_LEHREINHEIT_SPRACHE,
$jsonSchema->{UDFLib::LABEL},
null,
@@ -325,19 +332,20 @@ class UDFWidget extends HTMLWidget
);
if (hasData($tmpResult))
{
- $this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::LABEL] = $tmpResult->retval[0]->text;
+ $this->htmlParameters[HTMLWidget::LABEL] = $tmpResult->retval[0]->text;
}
else
{
- $this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::LABEL] = null;
+ $this->htmlParameters[HTMLWidget::LABEL] = null;
}
}
- //
+ // If is set the title property in the json schema
if (isset($jsonSchema->{UDFLib::TITLE}))
{
+ // Load the related phrase
$tmpResult = $this->_ci->phraseslib->getPhrases(
- UDFWidget::PHRASES_APP_NAME,
+ UDFLib::PHRASES_APP_NAME,
DEFAULT_LEHREINHEIT_SPRACHE,
$jsonSchema->{UDFLib::TITLE},
null,
@@ -346,19 +354,20 @@ class UDFWidget extends HTMLWidget
);
if (hasData($tmpResult))
{
- $this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::TITLE] = $tmpResult->retval[0]->text;
+ $this->htmlParameters[HTMLWidget::TITLE] = $tmpResult->retval[0]->text;
}
else
{
- $this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::TITLE] = null;
+ $this->htmlParameters[HTMLWidget::TITLE] = null;
}
}
- //
+ // If is set the placeholder property in the json schema
if (isset($jsonSchema->{UDFLib::PLACEHOLDER}))
{
+ // Load the related phrase
$tmpResult = $this->_ci->phraseslib->getPhrases(
- UDFWidget::PHRASES_APP_NAME,
+ UDFLib::PHRASES_APP_NAME,
DEFAULT_LEHREINHEIT_SPRACHE,
$jsonSchema->{UDFLib::PLACEHOLDER},
null,
@@ -367,54 +376,73 @@ class UDFWidget extends HTMLWidget
);
if (hasData($tmpResult))
{
- $this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::PLACEHOLDER] = $tmpResult->retval[0]->text;
+ $this->htmlParameters[HTMLWidget::PLACEHOLDER] = $tmpResult->retval[0]->text;
}
else
{
- $this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::PLACEHOLDER] = null;
+ $this->htmlParameters[HTMLWidget::PLACEHOLDER] = null;
}
}
}
}
/**
- *
+ * Sets the validation attributes of the HTML element using the configuration inside the json schema
*/
private function _setValidationAttributes($jsonSchema)
{
- // Validation
- $this->_args[HTMLWidget::HTML_ARG_NAME][UDFWidget::REQUIRED] = null;
- $this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::REGEX] = null;
- $this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::MAX_VALUE] = null;
- $this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::MIN_VALUE] = null;
+ // Validation attributes set by default to null
+ $this->htmlParameters[HTMLWidget::REGEX] = null;
+ $this->htmlParameters[HTMLWidget::REQUIRED] = null;
+ $this->htmlParameters[HTMLWidget::MIN_VALUE] = null;
+ $this->htmlParameters[HTMLWidget::MAX_VALUE] = null;
- if (isset($jsonSchema->validation))
+ // If validation property is present in the json schema
+ if (isset($jsonSchema->{UDFLib::VALIDATION}))
{
- if (isset($jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::REGEX})
- && is_array($jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::REGEX}))
+ $jsonSchemaValidation =& $jsonSchema->{UDFLib::VALIDATION}; // Reference for a better code readability
+
+ // Front end regex
+ if (isset($jsonSchemaValidation->{UDFLib::REGEX})
+ && is_array($jsonSchemaValidation->{UDFLib::REGEX}))
{
- foreach($jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::REGEX} as $regex)
+ foreach($jsonSchemaValidation->{UDFLib::REGEX} as $regex)
{
- if ($regex->language === UDFWidget::REGEX_LANGUAGE)
+ if ($regex->language === UDFLib::FE_REGEX_LANGUAGE)
{
- $this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::REGEX] = $regex->expression;
+ $this->htmlParameters[HTMLWidget::REGEX] = $regex->expression;
}
}
}
- if (isset($jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::REQUIRED}))
+ // Required
+ if (isset($jsonSchemaValidation->{UDFLib::REQUIRED}))
{
- $this->_args[HTMLWidget::HTML_ARG_NAME][UDFWidget::REQUIRED] = $jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::REQUIRED};
+ $this->htmlParameters[HTMLWidget::REQUIRED] = $jsonSchemaValidation->{UDFLib::REQUIRED};
}
- if (isset($jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::MAX_VALUE}))
+ // Min value
+ if (isset($jsonSchemaValidation->{UDFLib::MIN_VALUE}))
{
- $this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::MAX_VALUE] = $jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::MAX_VALUE};
+ $this->htmlParameters[HTMLWidget::MIN_VALUE] = $jsonSchemaValidation->{UDFLib::MIN_VALUE};
}
- if (isset($jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::MIN_VALUE}))
+ // Max value
+ if (isset($jsonSchemaValidation->{UDFLib::MAX_VALUE}))
{
- $this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::MIN_VALUE] = $jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::MIN_VALUE};
+ $this->htmlParameters[HTMLWidget::MAX_VALUE] = $jsonSchemaValidation->{UDFLib::MAX_VALUE};
+ }
+
+ // Min length
+ if (isset($jsonSchemaValidation->{UDFLib::MIN_LENGTH}))
+ {
+ $this->htmlParameters[HTMLWidget::MIN_LENGTH] = $jsonSchemaValidation->{UDFLib::MIN_LENGTH};
+ }
+
+ // Max length
+ if (isset($jsonSchemaValidation->{UDFLib::MAX_LENGTH}))
+ {
+ $this->htmlParameters[HTMLWidget::MAX_LENGTH] = $jsonSchemaValidation->{UDFLib::MAX_LENGTH};
}
}
}
diff --git a/skin/widgets.css b/skin/widgets.css
index d0f2f5299..91b0b6889 100644
--- a/skin/widgets.css
+++ b/skin/widgets.css
@@ -14,7 +14,7 @@
display: table-cell;
}
-label[udf-required=true]::after {
+label[required-field=true]::after {
content: "*";
}