mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-23 18:02:18 +00:00
- New directory application/widgets/html/ for widgets to render HTML
elements - All the widgets classes to render HTML elements moved from WidgetLib to application/widgets/html/ - New directory application/widgets/udf/ for widgets to render UDF - All the UDF widgets classes moved from WidgetLib to application/widgets/udf/ - HTMLWidget is now the main class to render HTML widget - UDFWidget is now the mail class to render UDF - Removed UDFWidgetTpl - Added function loadResource to fhc helper - Changed method widget of WidgetLib (using loadResource) - Moved UDFWidget method from WidgetLib to UDFLib - Slimmed down class Widget present in WidgetLib - Controller system/UDf now uses UDFLib - View application/views/system/udf.php now uses UDFLib - Updated udf and html widgets to adapt them to the new libs
This commit is contained in:
@@ -11,8 +11,8 @@ class UDF extends VileSci_Controller
|
||||
// Load session library
|
||||
$this->load->library('session');
|
||||
|
||||
// Loads the widget library
|
||||
$this->load->library('WidgetLib');
|
||||
// Loads the UDF library
|
||||
$this->load->library('UDFLib');
|
||||
|
||||
//
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* FH-Complete
|
||||
*
|
||||
@@ -10,8 +11,7 @@
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
*/
|
||||
if (! defined('BASEPATH'))
|
||||
exit('No direct script access allowed');
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* FHC Helper
|
||||
@@ -25,7 +25,6 @@ if (! defined('BASEPATH'))
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* generateToken() - generates a new token for diffent use
|
||||
* - reading Messages from external
|
||||
@@ -75,4 +74,66 @@ function var_dump_to_error_log($parameter)
|
||||
$ob_get_contents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
error_log(str_replace("\n", '', $ob_get_contents));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function loadResource($path, $resources = null, $subdir = false)
|
||||
{
|
||||
$_ci = & get_instance();
|
||||
|
||||
//
|
||||
if (strrpos($path, '/') < strlen($path) - 1)
|
||||
{
|
||||
$path .= '/';
|
||||
}
|
||||
|
||||
//
|
||||
$tmpResources = $resources;
|
||||
if ($resources == null)
|
||||
{
|
||||
$tmpResources = array();
|
||||
}
|
||||
else if (!is_array($resources))
|
||||
{
|
||||
$tmpResources = array($resources);
|
||||
}
|
||||
|
||||
//
|
||||
$tmpPaths = array($path);
|
||||
// NOTE: Used @ to prevent ugly error messages
|
||||
if (is_dir($path) && ($dirHandler = @opendir($path)) !== false)
|
||||
{
|
||||
while (($entry = readdir($dirHandler)) !== false)
|
||||
{
|
||||
//
|
||||
if ($subdir === true && $entry != '.' && $entry != '..' && is_dir($entry))
|
||||
{
|
||||
$tmpPaths[] = $entry;
|
||||
}
|
||||
//
|
||||
if ($resources == null && is_file($path.$entry))
|
||||
{
|
||||
if ($entry != ($tmpName = str_replace('.php', '', $entry)))
|
||||
{
|
||||
$tmpResources[] = $tmpName;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dirHandler);
|
||||
}
|
||||
|
||||
//
|
||||
foreach($tmpResources as $tmpResource)
|
||||
{
|
||||
foreach($tmpPaths as $tmpPath)
|
||||
{
|
||||
$fileName = $tmpPath.$tmpResource.'.php';
|
||||
if (file_exists($fileName))
|
||||
{
|
||||
include_once($fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Library to manage UDF
|
||||
*/
|
||||
class UDFLib
|
||||
{
|
||||
const WIDGET_NAME = 'UDFWidget';
|
||||
const SCHEMA_ARG_NAME = 'schema';
|
||||
const TABLE_ARG_NAME = 'table';
|
||||
const FIELD_ARG_NAME = 'field';
|
||||
const UDFS_ARG_NAME = 'udfs';
|
||||
|
||||
// HTML components
|
||||
const TITLE = 'description';
|
||||
const LABEL = 'title';
|
||||
const PLACEHOLDER = 'placeholder';
|
||||
const DEFAULT_VALUE = 'defaultValue';
|
||||
|
||||
// Validation attributes
|
||||
const REGEX = 'regex';
|
||||
const REQUIRED = 'required';
|
||||
const MAX_VALUE = 'max-value';
|
||||
const MIN_VALUE = 'min-value';
|
||||
const MAX_LENGTH = 'max-length';
|
||||
const MIN_LENGTH = 'min-length';
|
||||
|
||||
private $_ci;
|
||||
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->_ci = & get_instance();
|
||||
|
||||
$this->_ci->load->helper('fhc');
|
||||
|
||||
// Loads the widget library
|
||||
$this->_ci->load->library('WidgetLib');
|
||||
|
||||
// Loads widgets to render HTML elements
|
||||
// NOTE: the first one to be loaded must be HTMLWidget
|
||||
loadResource(APPPATH . 'widgets/udf');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function UDFWidget($args, $htmlArgs = array())
|
||||
{
|
||||
if (!empty($args[UDFLib::SCHEMA_ARG_NAME]) && !empty($args[UDFLib::TABLE_ARG_NAME]))
|
||||
{
|
||||
//
|
||||
if (empty($args[UDFLib::FIELD_ARG_NAME]) && !isset($htmlArgs[HTMLWidget::EXTERNAL_BLOCK]))
|
||||
{
|
||||
$htmlArgs[HTMLWidget::EXTERNAL_BLOCK] = true;
|
||||
}
|
||||
|
||||
return $this->_ci->widgetlib->widget(
|
||||
UDFLib::WIDGET_NAME,
|
||||
$args,
|
||||
$htmlArgs
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($args[UDFLib::SCHEMA_ARG_NAME]))
|
||||
{
|
||||
show_error(UDFLib::SCHEMA_ARG_NAME.' parameter is missing!');
|
||||
}
|
||||
if (empty($args[UDFLib::TABLE_ARG_NAME]))
|
||||
{
|
||||
show_error(UDFLib::TABLE_ARG_NAME.' parameter is missing!');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,9 @@ if (!defined("BASEPATH")) exit("No direct script access allowed");
|
||||
|
||||
class WidgetLib
|
||||
{
|
||||
const DIR_HTML_WIDGETS = 'html';
|
||||
const HTML_WIDGET_NAME = 'HTMLWidget';
|
||||
|
||||
/* default values */
|
||||
private $_template = 'template';
|
||||
private $_parser = FALSE;
|
||||
@@ -45,8 +48,15 @@ class WidgetLib
|
||||
{
|
||||
$this->_ci = & get_instance();
|
||||
|
||||
// set the default widget path with APPPATH
|
||||
$this->_ci->load->helper('fhc');
|
||||
|
||||
// Set the default widget path with APPPATH
|
||||
$this->_widget_path = APPPATH . 'widgets/';
|
||||
|
||||
// Loads widgets to render HTML elements
|
||||
// NOTE: the first one to be loaded must be HTMLWidget
|
||||
loadResource($this->_widget_path.WidgetLib::DIR_HTML_WIDGETS, WidgetLib::HTML_WIDGET_NAME);
|
||||
loadResource($this->_widget_path.WidgetLib::DIR_HTML_WIDGETS);
|
||||
|
||||
if (!empty($config))
|
||||
$this->initialize($config);
|
||||
@@ -184,65 +194,15 @@ class WidgetLib
|
||||
*/
|
||||
public function widget($name, $data = array(), $htmlArgs = array())
|
||||
{
|
||||
$class = str_replace('.php', '', trim($name, '/'));
|
||||
//
|
||||
loadResource($this->_widget_path, $name, true);
|
||||
|
||||
// determine path and widget class name
|
||||
$path = $this->_widget_path;
|
||||
if (($last_slash = strrpos($class, '/')) !== FALSE) {
|
||||
$path += substr($class, 0, $last_slash);
|
||||
$class = substr($class, $last_slash + 1);
|
||||
if (!class_exists($name))
|
||||
{
|
||||
show_error("Widget '" . $name . "' was not found.");
|
||||
}
|
||||
|
||||
// new widget
|
||||
if (!class_exists($class)) {
|
||||
// try both lowercase and capitalized versions
|
||||
foreach (array(ucfirst($class), strtolower($class)) as $class) {
|
||||
if (file_exists($path . $class . '.php')) {
|
||||
include_once ($path . $class . '.php');
|
||||
|
||||
// found the file, stop looking
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists($class)) {
|
||||
show_error("Widget '" . $class . "' was not found.");
|
||||
}
|
||||
|
||||
return new $class($class, $data, $htmlArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function UDFWidget($args, $htmlArgs = array())
|
||||
{
|
||||
if (!empty($args[UDFWidgetTpl::SCHEMA_ARG_NAME]) && !empty($args[UDFWidgetTpl::TABLE_ARG_NAME]))
|
||||
{
|
||||
//
|
||||
if (empty($args[UDFWidgetTpl::FIELD_ARG_NAME]) && !isset($htmlArgs[Widget::EXTERNAL_BLOCK]))
|
||||
{
|
||||
$htmlArgs[Widget::EXTERNAL_BLOCK] = true;
|
||||
}
|
||||
|
||||
return $this->widget(
|
||||
UDFWidgetTpl::WIDGET_NAME,
|
||||
$args,
|
||||
$htmlArgs
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($args[UDFWidgetTpl::SCHEMA_ARG_NAME]))
|
||||
{
|
||||
show_error(UDFWidgetTpl::SCHEMA_ARG_NAME.' parameter is missing!');
|
||||
}
|
||||
if (empty($args[UDFWidgetTpl::TABLE_ARG_NAME]))
|
||||
{
|
||||
show_error(UDFWidgetTpl::TABLE_ARG_NAME.' parameter is missing!');
|
||||
}
|
||||
}
|
||||
return new $name($name, $data, $htmlArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -635,35 +595,10 @@ class Partial
|
||||
}
|
||||
|
||||
/**
|
||||
* The mother of all widgets
|
||||
* it represent a generic HTML element
|
||||
* General widget element
|
||||
*/
|
||||
class Widget extends Partial
|
||||
{
|
||||
// The name of the array present in the data array given to the view that will render this widget
|
||||
const HTML_ARG_NAME = 'HTML';
|
||||
const HTML_DEFAULT_VALUE = ''; // Default value of the html element
|
||||
const HTML_NAME = 'name'; // HTML name attribute
|
||||
const HTML_ID = 'id'; // HTML id attribute
|
||||
|
||||
const EXTERNAL_BLOCK = 'externalBlock'; //
|
||||
const EXTERNAL_START_BLOCK_HTML_TAG = '<div>'; //
|
||||
const EXTERNAL_END_BLOCK_HTML_TAG = '</div>'; //
|
||||
|
||||
/**
|
||||
* It gets also the htmlArgs array as parameter, it will be used to set the HTML properties
|
||||
*/
|
||||
public function __construct($name, $args = array(), $htmlArgs = array())
|
||||
{
|
||||
parent::__construct($name, $args);
|
||||
|
||||
// Initialising HTML properties
|
||||
$this->_setHtmlProperties($htmlArgs);
|
||||
|
||||
// Loads helper message to manage returning messages
|
||||
$this->load->helper('message');
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-PHPdoc)
|
||||
* @see Partial::content()
|
||||
@@ -690,456 +625,4 @@ class Widget extends Partial
|
||||
|
||||
return parent::content();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialising html properties, such as the id and name attributes of the HTML element
|
||||
*/
|
||||
private function _setHtmlProperties($htmlArgs)
|
||||
{
|
||||
// If $htmlArgs wasn't already stored in $this->_args
|
||||
if (!isset($this->_args[Widget::HTML_ARG_NAME]))
|
||||
{
|
||||
$this->_args[Widget::HTML_ARG_NAME] = array();
|
||||
|
||||
// Avoids that elements in a HTML page have the same name or id
|
||||
$randomIdentifier = uniqid(rand(0, 1000));
|
||||
$this->_args[Widget::HTML_ARG_NAME][Widget::HTML_ID] = $randomIdentifier;
|
||||
$this->_args[Widget::HTML_ARG_NAME][Widget::HTML_NAME] = $randomIdentifier;
|
||||
|
||||
foreach($htmlArgs as $argName => $argValue)
|
||||
{
|
||||
$this->_args[Widget::HTML_ARG_NAME][$argName] = $argValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function printAttribute($htmlArgs, $attribute, $isValuePresent = true)
|
||||
{
|
||||
if ($attribute != null)
|
||||
{
|
||||
if (isset($htmlArgs[$attribute]))
|
||||
{
|
||||
if ($isValuePresent === true)
|
||||
{
|
||||
$value = $htmlArgs[$attribute];
|
||||
|
||||
if (is_bool($value))
|
||||
{
|
||||
$value = $value ? 'true' : 'false';
|
||||
}
|
||||
|
||||
echo sprintf('%s="%s"', $attribute, $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $attribute;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function printStartBlock($htmlArgs)
|
||||
{
|
||||
if (isset($htmlArgs[Widget::EXTERNAL_BLOCK])
|
||||
&& $htmlArgs[Widget::EXTERNAL_BLOCK] === true)
|
||||
{
|
||||
echo Widget::EXTERNAL_START_BLOCK_HTML_TAG;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function printEndBlock($htmlArgs)
|
||||
{
|
||||
if (isset($htmlArgs[Widget::EXTERNAL_BLOCK])
|
||||
&& $htmlArgs[Widget::EXTERNAL_BLOCK] === true)
|
||||
{
|
||||
echo Widget::EXTERNAL_END_BLOCK_HTML_TAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* It exends the Widget class to represent an HTML dropdown
|
||||
*/
|
||||
class DropdownWidget extends Widget
|
||||
{
|
||||
// The name of the element of the data array given to the view
|
||||
// this element is an array of elements to be place inside the dropdown
|
||||
const WIDGET_DATA_ELEMENTS_ARRAY_NAME = 'ELEMENTS_ARRAY';
|
||||
// Name of the property that will be used to store the value attribute of the option tag
|
||||
const ID_FIELD = 'id';
|
||||
// Name of the property that will be used to store the value between the option tags
|
||||
const DESCRIPTION_FIELD = 'description';
|
||||
// The name of the element of the data array given to the view
|
||||
// this element is used to tell what element of the dropdown is selected
|
||||
const SELECTED_ELEMENT = 'selectedElement';
|
||||
//
|
||||
const HTML_DEFAULT_VALUE = 'null';
|
||||
|
||||
const SIZE = 'size'; //
|
||||
const MULTIPLE = 'multiple'; //
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct($name, $args = array(), $htmlArgs = array())
|
||||
{
|
||||
parent::__construct($name, $args, $htmlArgs);
|
||||
|
||||
//
|
||||
if (!isset($this->_args[DropdownWidget::SELECTED_ELEMENT]))
|
||||
{
|
||||
$this->_args[DropdownWidget::SELECTED_ELEMENT] = DropdownWidget::HTML_DEFAULT_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setMultiple()
|
||||
{
|
||||
$this->_args[Widget::HTML_ARG_NAME][DropdownWidget::MULTIPLE] = DropdownWidget::MULTIPLE;
|
||||
$this->_args[Widget::HTML_ARG_NAME][Widget::HTML_NAME] .= '[]';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function isMultipleDropdown()
|
||||
{
|
||||
$isMultipleDropdown = false;
|
||||
|
||||
if (isset($this->_args[Widget::HTML_ARG_NAME][DropdownWidget::MULTIPLE])
|
||||
&& $this->_args[Widget::HTML_ARG_NAME][DropdownWidget::MULTIPLE] == DropdownWidget::MULTIPLE)
|
||||
{
|
||||
$isMultipleDropdown = true;
|
||||
}
|
||||
|
||||
return $isMultipleDropdown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct select to the model used to load a list of elemets for this dropdown
|
||||
* @param model $model the model used to load elements
|
||||
* @param string $idName the name of the field that will used to be the value of the option tag
|
||||
* @param string $descriptionName the name of the field that will used to be displayed in the dropdown
|
||||
*/
|
||||
protected function addSelectToModel($model, $idName, $descriptionName)
|
||||
{
|
||||
$model->addSelect(
|
||||
sprintf(
|
||||
'%s AS %s, %s AS %s',
|
||||
$idName,
|
||||
DropdownWidget::ID_FIELD,
|
||||
$descriptionName,
|
||||
DropdownWidget::DESCRIPTION_FIELD
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the array used to populate the dropdown
|
||||
* @param array $elements list used to populate this dropdown
|
||||
* @param boolean $emptyElement if an empty element must be added at the beginning of the dropdown
|
||||
* @param string $stdDescription description of the empty element
|
||||
* @param string $noDataDescription description if no data are found
|
||||
* @param string $id value of the attribute value of the empty element
|
||||
*/
|
||||
protected function setElementsArray(
|
||||
$elements, $emptyElement = false, $stdDescription = '' , $noDataDescription = 'No data found' , $id = DropdownWidget::HTML_DEFAULT_VALUE
|
||||
)
|
||||
{
|
||||
$tmpElements = array();
|
||||
|
||||
if (isError($elements))
|
||||
{
|
||||
if (is_object($elements) && isset($elements->retval))
|
||||
{
|
||||
show_error($elements->retval);
|
||||
}
|
||||
else if (is_string($elements))
|
||||
{
|
||||
show_error($elements);
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error('Generic error occurred');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($emptyElement === true && $this->isMultipleDropdown() == false)
|
||||
{
|
||||
$tmpElements = $this->addElementAtBeginning(
|
||||
$elements,
|
||||
$stdDescription,
|
||||
$noDataDescription,
|
||||
$id
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmpElements = $elements->retval;
|
||||
}
|
||||
|
||||
$this->_args[DropdownWidget::WIDGET_DATA_ELEMENTS_ARRAY_NAME] = $tmpElements;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an element to the beginning of the array
|
||||
*/
|
||||
protected function addElementAtBeginning($elements, $stdDescription, $noDataDescription, $id)
|
||||
{
|
||||
$element = new stdClass();
|
||||
$element->{DropdownWidget::ID_FIELD} = $id;
|
||||
$element->{DropdownWidget::DESCRIPTION_FIELD} = $stdDescription;
|
||||
|
||||
if (!hasData($elements))
|
||||
{
|
||||
$element->{DropdownWidget::DESCRIPTION_FIELD} = $noDataDescription;
|
||||
}
|
||||
|
||||
array_unshift($elements->retval, $element);
|
||||
|
||||
return $elements->retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the dropdown view with all the elements to be displayed
|
||||
*/
|
||||
protected function loadDropDownView()
|
||||
{
|
||||
$this->view('widgets/dropdown', $this->_args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class DropdownWidgetUDF extends DropdownWidget
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function render($parameters)
|
||||
{
|
||||
$tmpElements = array();
|
||||
|
||||
//
|
||||
foreach($parameters as $parameter)
|
||||
{
|
||||
//
|
||||
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})))
|
||||
{
|
||||
$element = new stdClass(); //
|
||||
//
|
||||
if (is_array($parameter) && count($parameter) == 2)
|
||||
{
|
||||
$element->{PARENT::ID_FIELD} = $parameter[0]; //
|
||||
$element->{PARENT::DESCRIPTION_FIELD} = $parameter[1]; //
|
||||
}
|
||||
//
|
||||
else if (is_string($parameter) || is_numeric($parameter))
|
||||
{
|
||||
$element->{PARENT::ID_FIELD} = $parameter; //
|
||||
$element->{PARENT::DESCRIPTION_FIELD} = $parameter; //
|
||||
}
|
||||
//
|
||||
else if (is_object($parameter) && isset($parameter->{PARENT::ID_FIELD}) && isset($parameter->{PARENT::DESCRIPTION_FIELD}))
|
||||
{
|
||||
$element->{PARENT::ID_FIELD} = $parameter->{PARENT::ID_FIELD}; //
|
||||
$element->{PARENT::DESCRIPTION_FIELD} = $parameter->{PARENT::DESCRIPTION_FIELD}; //
|
||||
}
|
||||
|
||||
array_push($tmpElements, $element); //
|
||||
}
|
||||
}
|
||||
|
||||
$this->setElementsArray(
|
||||
success($tmpElements),
|
||||
true,
|
||||
$this->_args[Widget::HTML_ARG_NAME][UDFWidgetTpl::PLACEHOLDER],
|
||||
'No data found for this UDF'
|
||||
);
|
||||
|
||||
$this->loadDropDownView();
|
||||
|
||||
echo $this->content();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* It exends the Widget class to represent an HTML textarea
|
||||
*/
|
||||
class TextareaWidget extends Widget
|
||||
{
|
||||
const TEXT = 'text'; //
|
||||
const ROWS = 'rows'; //
|
||||
const COLS = 'cols'; //
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function setText($text)
|
||||
{
|
||||
$this->_args[TextareaWidget::TEXT] = $text;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function loadTextareaView()
|
||||
{
|
||||
$this->view('widgets/textarea', $this->_args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class TextareaWidgetUDF extends TextareaWidget
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function render($parameters)
|
||||
{
|
||||
if ($parameters != null)
|
||||
{
|
||||
$this->setText($parameters);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setText('');
|
||||
}
|
||||
|
||||
$this->loadTextareaView();
|
||||
|
||||
echo $this->content();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* It exends the Widget class to represent an HTML textarea
|
||||
*/
|
||||
class TextfieldWidget extends Widget
|
||||
{
|
||||
const VALUE = 'text'; //
|
||||
const SIZE = 'size'; //
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function setValue($value)
|
||||
{
|
||||
$this->_args[TextfieldWidget::VALUE] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function loadTextfieldView()
|
||||
{
|
||||
$this->view('widgets/textfield', $this->_args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class TextfieldWidgetUDF extends TextfieldWidget
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function render($parameters)
|
||||
{
|
||||
if ($parameters != null)
|
||||
{
|
||||
$this->setValue($parameters);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setValue('');
|
||||
}
|
||||
|
||||
$this->loadTextfieldView();
|
||||
|
||||
echo $this->content();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* It exends the Widget class to represent an HTML dropdown
|
||||
*/
|
||||
class CheckboxWidget extends Widget
|
||||
{
|
||||
// Name of the property that will be used to store the value attribute of the option tag
|
||||
const VALUE_FIELD = 'value';
|
||||
// Name of the property that will be used to store the value between the option tags
|
||||
const DESCRIPTION_FIELD = 'description';
|
||||
// Value of value attribute of the checkbox
|
||||
const CHECKBOX_VALUE = 'true';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function loadCheckboxView()
|
||||
{
|
||||
$this->view('widgets/checkbox', $this->_args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class CheckboxWidgetUDF extends CheckboxWidget
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->loadCheckboxView();
|
||||
|
||||
echo $this->content();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined here because these constants can be used
|
||||
* in the views also
|
||||
*/
|
||||
abstract class UDFWidgetTpl extends Widget
|
||||
{
|
||||
const WIDGET_NAME = 'UDFWidget';
|
||||
const SCHEMA_ARG_NAME = 'schema';
|
||||
const TABLE_ARG_NAME = 'table';
|
||||
const FIELD_ARG_NAME = 'field';
|
||||
const UDFS_ARG_NAME = 'udfs';
|
||||
|
||||
// HTML components
|
||||
const TITLE = 'description';
|
||||
const LABEL = 'title';
|
||||
const PLACEHOLDER = 'placeholder';
|
||||
const DEFAULT_VALUE = 'defaultValue';
|
||||
|
||||
// Validation attributes
|
||||
const REGEX = 'regex';
|
||||
const REQUIRED = 'required';
|
||||
const MAX_VALUE = 'max-value';
|
||||
const MIN_VALUE = 'min-value';
|
||||
const MAX_LENGTH = 'max-length';
|
||||
const MIN_LENGTH = 'min-length';
|
||||
}
|
||||
@@ -62,11 +62,11 @@
|
||||
?>
|
||||
<div class="div-cell">
|
||||
<?php
|
||||
echo $this->widgetlib->UDFWidget(
|
||||
echo $this->udflib->UDFWidget(
|
||||
array(
|
||||
UDFWidgetTpl::SCHEMA_ARG_NAME => 'public',
|
||||
UDFWidgetTpl::TABLE_ARG_NAME => 'tbl_person',
|
||||
UDFWidgetTpl::UDFS_ARG_NAME => $personUdfs
|
||||
UDFLib::SCHEMA_ARG_NAME => 'public',
|
||||
UDFLib::TABLE_ARG_NAME => 'tbl_person',
|
||||
UDFLib::UDFS_ARG_NAME => $personUdfs
|
||||
)
|
||||
);
|
||||
?>
|
||||
@@ -83,11 +83,11 @@
|
||||
?>
|
||||
<div class="div-cell">
|
||||
<?php
|
||||
echo $this->widgetlib->UDFWidget(
|
||||
echo $this->udflib->UDFWidget(
|
||||
array(
|
||||
UDFWidgetTpl::SCHEMA_ARG_NAME => 'public',
|
||||
UDFWidgetTpl::TABLE_ARG_NAME => 'tbl_prestudent',
|
||||
UDFWidgetTpl::UDFS_ARG_NAME => $prestudentUdfs
|
||||
UDFLib::SCHEMA_ARG_NAME => 'public',
|
||||
UDFLib::TABLE_ARG_NAME => 'tbl_prestudent',
|
||||
UDFLib::UDFS_ARG_NAME => $prestudentUdfs
|
||||
)
|
||||
);
|
||||
?>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<?php Widget::printStartBlock(${Widget::HTML_ARG_NAME}); ?>
|
||||
<?php HTMLWidget::printStartBlock(${HTMLWidget::HTML_ARG_NAME}); ?>
|
||||
|
||||
<div class="div-table">
|
||||
<div class="div-row">
|
||||
<?php
|
||||
if (isset(${Widget::HTML_ARG_NAME}[UDFWidgetTpl::LABEL]))
|
||||
if (isset(${HTMLWidget::HTML_ARG_NAME}[HTMLWidget::LABEL]))
|
||||
{
|
||||
?>
|
||||
<div class="div-cell-label valign-middle width-150px">
|
||||
<label
|
||||
for="<?php echo ${Widget::HTML_ARG_NAME}[Widget::HTML_ID]; ?>"
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidget::REQUIRED); ?>
|
||||
for="<?php echo ${HTMLWidget::HTML_ARG_NAME}[HTMLWidget::HTML_ID]; ?>"
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::REQUIRED); ?>
|
||||
>
|
||||
<?php echo ${Widget::HTML_ARG_NAME}[UDFWidgetTpl::LABEL]; ?>
|
||||
<?php echo ${HTMLWidget::HTML_ARG_NAME}[HTMLWidget::LABEL]; ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
@@ -20,11 +20,11 @@
|
||||
<div class="div-cell-data width-30px">
|
||||
<input
|
||||
type="checkbox"
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, Widget::HTML_ID); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, Widget::HTML_NAME); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidget::REQUIRED); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidgetTpl::REGEX); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidgetTpl::TITLE); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::HTML_ID); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::HTML_NAME); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::REQUIRED); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::REGEX); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::TITLE); ?>
|
||||
<?php
|
||||
$checked = '';
|
||||
if (${CheckboxWidget::VALUE_FIELD} === true)
|
||||
@@ -39,4 +39,4 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php Widget::printEndBlock(${Widget::HTML_ARG_NAME}); ?>
|
||||
<?php HTMLWidget::printEndBlock(${HTMLWidget::HTML_ARG_NAME}); ?>
|
||||
@@ -1,22 +1,22 @@
|
||||
<?php Widget::printStartBlock(${Widget::HTML_ARG_NAME}); ?>
|
||||
<?php HTMLWidget::printStartBlock(${HTMLWidget::HTML_ARG_NAME}); ?>
|
||||
|
||||
<div class="div-table">
|
||||
<div class="div-row">
|
||||
<?php
|
||||
if (isset(${Widget::HTML_ARG_NAME}[UDFWidgetTpl::LABEL]))
|
||||
if (isset(${HTMLWidget::HTML_ARG_NAME}[HTMLWidget::LABEL]))
|
||||
{
|
||||
$align = "valign-middle";
|
||||
if (isset(${Widget::HTML_ARG_NAME}[DropdownWidget::MULTIPLE]))
|
||||
if (isset(${HTMLWidget::HTML_ARG_NAME}[DropdownWidget::MULTIPLE]))
|
||||
{
|
||||
$align = "valign-top";
|
||||
}
|
||||
?>
|
||||
<div class="div-cell width-150px <?php echo $align; ?>">
|
||||
<label
|
||||
for="<?php echo ${Widget::HTML_ARG_NAME}[Widget::HTML_ID]; ?>"
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidget::REQUIRED); ?>
|
||||
for="<?php echo ${HTMLWidget::HTML_ARG_NAME}[HTMLWidget::HTML_ID]; ?>"
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::REQUIRED); ?>
|
||||
>
|
||||
<?php echo ${Widget::HTML_ARG_NAME}[UDFWidgetTpl::LABEL]; ?>
|
||||
<?php echo ${HTMLWidget::HTML_ARG_NAME}[HTMLWidget::LABEL]; ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
@@ -24,15 +24,15 @@
|
||||
?>
|
||||
<div class="div-cell width-150px">
|
||||
<select
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, Widget::HTML_ID); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, Widget::HTML_NAME); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, DropdownWidget::SIZE); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, DropdownWidget::MULTIPLE, false); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidget::REQUIRED); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidgetTpl::MAX_VALUE); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidgetTpl::MIN_VALUE); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidgetTpl::REGEX); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidgetTpl::TITLE); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::HTML_ID); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::HTML_NAME); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, DropdownWidget::SIZE); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, DropdownWidget::MULTIPLE, false); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::REQUIRED); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::MAX_VALUE); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::MIN_VALUE); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::REGEX); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::TITLE); ?>
|
||||
>
|
||||
<?php
|
||||
$elements = ${DropdownWidget::WIDGET_DATA_ELEMENTS_ARRAY_NAME};
|
||||
@@ -71,4 +71,4 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php Widget::printEndBlock(${Widget::HTML_ARG_NAME}); ?>
|
||||
<?php HTMLWidget::printEndBlock(${HTMLWidget::HTML_ARG_NAME}); ?>
|
||||
@@ -1,17 +1,17 @@
|
||||
<?php Widget::printStartBlock(${Widget::HTML_ARG_NAME}); ?>
|
||||
<?php HTMLWidget::printStartBlock(${HTMLWidget::HTML_ARG_NAME}); ?>
|
||||
|
||||
<div class="div-table">
|
||||
<div class="div-row">
|
||||
<?php
|
||||
if (isset(${Widget::HTML_ARG_NAME}[UDFWidgetTpl::LABEL]))
|
||||
if (isset(${HTMLWidget::HTML_ARG_NAME}[HTMLWidget::LABEL]))
|
||||
{
|
||||
?>
|
||||
<div class="div-cell width-150px valign-top">
|
||||
<label
|
||||
for="<?php echo ${Widget::HTML_ARG_NAME}[Widget::HTML_ID]; ?>"
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidget::REQUIRED); ?>
|
||||
for="<?php echo ${HTMLWidget::HTML_ARG_NAME}[HTMLWidget::HTML_ID]; ?>"
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::REQUIRED); ?>
|
||||
>
|
||||
<?php echo ${Widget::HTML_ARG_NAME}[UDFWidgetTpl::LABEL]; ?>
|
||||
<?php echo ${HTMLWidget::HTML_ARG_NAME}[HTMLWidget::LABEL]; ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
@@ -19,17 +19,17 @@
|
||||
?>
|
||||
<div class="div-cell width-150px">
|
||||
<textarea
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, Widget::HTML_ID); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, Widget::HTML_NAME); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, TextareaWidget::ROWS); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, TextareaWidget::COLS); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidget::REQUIRED); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidgetTpl::PLACEHOLDER); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidgetTpl::REGEX); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidgetTpl::TITLE); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::HTML_ID); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::HTML_NAME); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, TextareaWidget::ROWS); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, TextareaWidget::COLS); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::REQUIRED); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::PLACEHOLDER); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::REGEX); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::TITLE); ?>
|
||||
><?php echo ${TextareaWidget::TEXT}; ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php Widget::printEndBlock(${Widget::HTML_ARG_NAME}); ?>
|
||||
<?php HTMLWidget::printEndBlock(${HTMLWidget::HTML_ARG_NAME}); ?>
|
||||
@@ -1,17 +1,17 @@
|
||||
<?php Widget::printStartBlock(${Widget::HTML_ARG_NAME}); ?>
|
||||
<?php HTMLWidget::printStartBlock(${HTMLWidget::HTML_ARG_NAME}); ?>
|
||||
|
||||
<div class="div-table">
|
||||
<div class="div-row">
|
||||
<?php
|
||||
if (isset(${Widget::HTML_ARG_NAME}[UDFWidgetTpl::LABEL]))
|
||||
if (isset(${HTMLWidget::HTML_ARG_NAME}[HTMLWidget::LABEL]))
|
||||
{
|
||||
?>
|
||||
<div class="div-cell width-150px valign-middle">
|
||||
<label
|
||||
for="<?php echo ${Widget::HTML_ARG_NAME}[Widget::HTML_ID]; ?>"
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidget::REQUIRED); ?>
|
||||
for="<?php echo ${HTMLWidget::HTML_ARG_NAME}[HTMLWidget::HTML_ID]; ?>"
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::REQUIRED); ?>
|
||||
>
|
||||
<?php echo ${Widget::HTML_ARG_NAME}[UDFWidgetTpl::LABEL]; ?>
|
||||
<?php echo ${HTMLWidget::HTML_ARG_NAME}[HTMLWidget::LABEL]; ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
@@ -20,17 +20,17 @@
|
||||
<div class="div-cell width-150px">
|
||||
<input
|
||||
type="text"
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, Widget::HTML_ID); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, Widget::HTML_NAME); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, TextfieldWidget::SIZE); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidget::REQUIRED); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidgetTpl::PLACEHOLDER); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidgetTpl::REGEX); ?>
|
||||
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidgetTpl::TITLE); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::HTML_ID); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::HTML_NAME); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, TextfieldWidget::SIZE); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::REQUIRED); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::PLACEHOLDER); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::REGEX); ?>
|
||||
<?php HTMLWidget::printAttribute(${HTMLWidget::HTML_ARG_NAME}, HTMLWidget::TITLE); ?>
|
||||
value="<?php echo ${TextfieldWidget::VALUE}; ?>"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php Widget::printEndBlock(${Widget::HTML_ARG_NAME}); ?>
|
||||
<?php HTMLWidget::printEndBlock(${HTMLWidget::HTML_ARG_NAME}); ?>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* It exends the Widget class to represent an HTML dropdown
|
||||
*/
|
||||
class CheckboxWidget extends HTMLWidget
|
||||
{
|
||||
// Name of the property that will be used to store the value attribute of the option tag
|
||||
const VALUE_FIELD = 'value';
|
||||
// Name of the property that will be used to store the value between the option tags
|
||||
const DESCRIPTION_FIELD = 'description';
|
||||
// Value of value attribute of the checkbox
|
||||
const CHECKBOX_VALUE = 'true';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function loadCheckboxView()
|
||||
{
|
||||
$this->view('widgets/checkbox', $this->_args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* It exends the Widget class to represent an HTML dropdown
|
||||
*/
|
||||
class DropdownWidget extends HTMLWidget
|
||||
{
|
||||
// The name of the element of the data array given to the view
|
||||
// this element is an array of elements to be place inside the dropdown
|
||||
const WIDGET_DATA_ELEMENTS_ARRAY_NAME = 'ELEMENTS_ARRAY';
|
||||
// Name of the property that will be used to store the value attribute of the option tag
|
||||
const ID_FIELD = 'id';
|
||||
// Name of the property that will be used to store the value between the option tags
|
||||
const DESCRIPTION_FIELD = 'description';
|
||||
// The name of the element of the data array given to the view
|
||||
// this element is used to tell what element of the dropdown is selected
|
||||
const SELECTED_ELEMENT = 'selectedElement';
|
||||
//
|
||||
const HTML_DEFAULT_VALUE = 'null';
|
||||
|
||||
const SIZE = 'size'; //
|
||||
const MULTIPLE = 'multiple'; //
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct($name, $args = array(), $htmlArgs = array())
|
||||
{
|
||||
parent::__construct($name, $args, $htmlArgs);
|
||||
|
||||
//
|
||||
if (!isset($this->_args[DropdownWidget::SELECTED_ELEMENT]))
|
||||
{
|
||||
$this->_args[DropdownWidget::SELECTED_ELEMENT] = DropdownWidget::HTML_DEFAULT_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setMultiple()
|
||||
{
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][DropdownWidget::MULTIPLE] = DropdownWidget::MULTIPLE;
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][HTMLWidget::HTML_NAME] .= '[]';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function isMultipleDropdown()
|
||||
{
|
||||
$isMultipleDropdown = false;
|
||||
|
||||
if (isset($this->_args[HTMLWidget::HTML_ARG_NAME][DropdownWidget::MULTIPLE])
|
||||
&& $this->_args[HTMLWidget::HTML_ARG_NAME][DropdownWidget::MULTIPLE] == DropdownWidget::MULTIPLE)
|
||||
{
|
||||
$isMultipleDropdown = true;
|
||||
}
|
||||
|
||||
return $isMultipleDropdown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct select to the model used to load a list of elemets for this dropdown
|
||||
* @param model $model the model used to load elements
|
||||
* @param string $idName the name of the field that will used to be the value of the option tag
|
||||
* @param string $descriptionName the name of the field that will used to be displayed in the dropdown
|
||||
*/
|
||||
protected function addSelectToModel($model, $idName, $descriptionName)
|
||||
{
|
||||
$model->addSelect(
|
||||
sprintf(
|
||||
'%s AS %s, %s AS %s',
|
||||
$idName,
|
||||
DropdownWidget::ID_FIELD,
|
||||
$descriptionName,
|
||||
DropdownWidget::DESCRIPTION_FIELD
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the array used to populate the dropdown
|
||||
* @param array $elements list used to populate this dropdown
|
||||
* @param boolean $emptyElement if an empty element must be added at the beginning of the dropdown
|
||||
* @param string $stdDescription description of the empty element
|
||||
* @param string $noDataDescription description if no data are found
|
||||
* @param string $id value of the attribute value of the empty element
|
||||
*/
|
||||
protected function setElementsArray(
|
||||
$elements, $emptyElement = false, $stdDescription = '' , $noDataDescription = 'No data found' , $id = DropdownWidget::HTML_DEFAULT_VALUE
|
||||
)
|
||||
{
|
||||
$tmpElements = array();
|
||||
|
||||
if (isError($elements))
|
||||
{
|
||||
if (is_object($elements) && isset($elements->retval))
|
||||
{
|
||||
show_error($elements->retval);
|
||||
}
|
||||
else if (is_string($elements))
|
||||
{
|
||||
show_error($elements);
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error('Generic error occurred');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($emptyElement === true && $this->isMultipleDropdown() == false)
|
||||
{
|
||||
$tmpElements = $this->addElementAtBeginning(
|
||||
$elements,
|
||||
$stdDescription,
|
||||
$noDataDescription,
|
||||
$id
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmpElements = $elements->retval;
|
||||
}
|
||||
|
||||
$this->_args[DropdownWidget::WIDGET_DATA_ELEMENTS_ARRAY_NAME] = $tmpElements;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an element to the beginning of the array
|
||||
*/
|
||||
protected function addElementAtBeginning($elements, $stdDescription, $noDataDescription, $id)
|
||||
{
|
||||
$element = new stdClass();
|
||||
$element->{DropdownWidget::ID_FIELD} = $id;
|
||||
$element->{DropdownWidget::DESCRIPTION_FIELD} = $stdDescription;
|
||||
|
||||
if (!hasData($elements))
|
||||
{
|
||||
$element->{DropdownWidget::DESCRIPTION_FIELD} = $noDataDescription;
|
||||
}
|
||||
|
||||
array_unshift($elements->retval, $element);
|
||||
|
||||
return $elements->retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the dropdown view with all the elements to be displayed
|
||||
*/
|
||||
protected function loadDropDownView()
|
||||
{
|
||||
$this->view('widgets/dropdown', $this->_args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Represents a generic HTML element
|
||||
*/
|
||||
class HTMLWidget extends Widget
|
||||
{
|
||||
// The name of the array present in the data array given to the view that will render this widget
|
||||
const HTML_ARG_NAME = 'HTML';
|
||||
const HTML_DEFAULT_VALUE = ''; // Default value of the html element
|
||||
const HTML_NAME = 'name'; // HTML name attribute
|
||||
const HTML_ID = 'id'; // HTML id attribute
|
||||
|
||||
//
|
||||
const EXTERNAL_BLOCK = 'externalBlock'; //
|
||||
const EXTERNAL_START_BLOCK_HTML_TAG = '<div>'; //
|
||||
const EXTERNAL_END_BLOCK_HTML_TAG = '</div>'; //
|
||||
|
||||
//
|
||||
const LABEL = 'title';
|
||||
const REGEX = 'regex';
|
||||
const TITLE = 'description';
|
||||
const REQUIRED = 'udf-required';
|
||||
const MAX_VALUE = 'max-value';
|
||||
const MIN_VALUE = 'min-value';
|
||||
const MAX_LENGTH = 'max-length';
|
||||
const MIN_LENGTH = 'min-length';
|
||||
const PLACEHOLDER = 'placeholder';
|
||||
|
||||
/**
|
||||
* It gets also the htmlArgs array as parameter, it will be used to set the HTML properties
|
||||
*/
|
||||
public function __construct($name, $args = array(), $htmlArgs = array())
|
||||
{
|
||||
parent::__construct($name, $args);
|
||||
|
||||
// Initialising HTML properties
|
||||
$this->_setHtmlProperties($htmlArgs);
|
||||
|
||||
// Loads helper message to manage returning messages
|
||||
$this->load->helper('message');
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialising html properties, such as the id and name attributes of the HTML element
|
||||
*/
|
||||
private function _setHtmlProperties($htmlArgs)
|
||||
{
|
||||
// If $htmlArgs wasn't already stored in $this->_args
|
||||
if (!isset($this->_args[HTMLWidget::HTML_ARG_NAME]))
|
||||
{
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME] = array();
|
||||
|
||||
// Avoids that elements in a HTML page have the same name or id
|
||||
$randomIdentifier = uniqid(rand(0, 1000));
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][HTMLWidget::HTML_ID] = $randomIdentifier;
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][HTMLWidget::HTML_NAME] = $randomIdentifier;
|
||||
|
||||
foreach($htmlArgs as $argName => $argValue)
|
||||
{
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][$argName] = $argValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function printAttribute($htmlArgs, $attribute, $isValuePresent = true)
|
||||
{
|
||||
if ($attribute != null)
|
||||
{
|
||||
if (isset($htmlArgs[$attribute]))
|
||||
{
|
||||
if ($isValuePresent === true)
|
||||
{
|
||||
$value = $htmlArgs[$attribute];
|
||||
|
||||
if (is_bool($value))
|
||||
{
|
||||
$value = $value ? 'true' : 'false';
|
||||
}
|
||||
|
||||
echo sprintf('%s="%s"', $attribute, $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $attribute;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function printStartBlock($htmlArgs)
|
||||
{
|
||||
if (isset($htmlArgs[HTMLWidget::EXTERNAL_BLOCK])
|
||||
&& $htmlArgs[HTMLWidget::EXTERNAL_BLOCK] === true)
|
||||
{
|
||||
echo HTMLWidget::EXTERNAL_START_BLOCK_HTML_TAG;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function printEndBlock($htmlArgs)
|
||||
{
|
||||
if (isset($htmlArgs[HTMLWidget::EXTERNAL_BLOCK])
|
||||
&& $htmlArgs[HTMLWidget::EXTERNAL_BLOCK] === true)
|
||||
{
|
||||
echo HTMLWidget::EXTERNAL_END_BLOCK_HTML_TAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* It exends the Widget class to represent an HTML textarea
|
||||
*/
|
||||
class TextareaWidget extends HTMLWidget
|
||||
{
|
||||
const TEXT = 'text'; //
|
||||
const ROWS = 'rows'; //
|
||||
const COLS = 'cols'; //
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function setText($text)
|
||||
{
|
||||
$this->_args[TextareaWidget::TEXT] = $text;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function loadTextareaView()
|
||||
{
|
||||
$this->view('widgets/textarea', $this->_args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* It exends the Widget class to represent an HTML textarea
|
||||
*/
|
||||
class TextfieldWidget extends HTMLWidget
|
||||
{
|
||||
const VALUE = 'text'; //
|
||||
const SIZE = 'size'; //
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function setValue($value)
|
||||
{
|
||||
$this->_args[TextfieldWidget::VALUE] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function loadTextfieldView()
|
||||
{
|
||||
$this->view('widgets/textfield', $this->_args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class CheckboxWidgetUDF extends CheckboxWidget
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->loadCheckboxView();
|
||||
|
||||
echo $this->content();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class DropdownWidgetUDF extends DropdownWidget
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function render($parameters)
|
||||
{
|
||||
$tmpElements = array();
|
||||
|
||||
//
|
||||
foreach($parameters as $parameter)
|
||||
{
|
||||
//
|
||||
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})))
|
||||
{
|
||||
$element = new stdClass(); //
|
||||
//
|
||||
if (is_array($parameter) && count($parameter) == 2)
|
||||
{
|
||||
$element->{PARENT::ID_FIELD} = $parameter[0]; //
|
||||
$element->{PARENT::DESCRIPTION_FIELD} = $parameter[1]; //
|
||||
}
|
||||
//
|
||||
else if (is_string($parameter) || is_numeric($parameter))
|
||||
{
|
||||
$element->{PARENT::ID_FIELD} = $parameter; //
|
||||
$element->{PARENT::DESCRIPTION_FIELD} = $parameter; //
|
||||
}
|
||||
//
|
||||
else if (is_object($parameter) && isset($parameter->{PARENT::ID_FIELD}) && isset($parameter->{PARENT::DESCRIPTION_FIELD}))
|
||||
{
|
||||
$element->{PARENT::ID_FIELD} = $parameter->{PARENT::ID_FIELD}; //
|
||||
$element->{PARENT::DESCRIPTION_FIELD} = $parameter->{PARENT::DESCRIPTION_FIELD}; //
|
||||
}
|
||||
|
||||
array_push($tmpElements, $element); //
|
||||
}
|
||||
}
|
||||
|
||||
$this->setElementsArray(
|
||||
success($tmpElements),
|
||||
true,
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][HTMLWidget::PLACEHOLDER],
|
||||
'No data found for this UDF'
|
||||
);
|
||||
|
||||
$this->loadDropDownView();
|
||||
|
||||
echo $this->content();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class TextareaWidgetUDF extends TextareaWidget
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function render($parameters)
|
||||
{
|
||||
if ($parameters != null)
|
||||
{
|
||||
$this->setText($parameters);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setText('');
|
||||
}
|
||||
|
||||
$this->loadTextareaView();
|
||||
|
||||
echo $this->content();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class TextfieldWidgetUDF extends TextfieldWidget
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function render($parameters)
|
||||
{
|
||||
if ($parameters != null)
|
||||
{
|
||||
$this->setValue($parameters);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setValue('');
|
||||
}
|
||||
|
||||
$this->loadTextfieldView();
|
||||
|
||||
echo $this->content();
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,10 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class UDFWidget extends UDFWidgetTpl
|
||||
class UDFWidget extends HTMLWidget
|
||||
{
|
||||
const NAME = 'name';
|
||||
const TYPE = 'type';
|
||||
const REQUIRED = 'udf-required';
|
||||
const VALIDATION = 'validation';
|
||||
const LIST_VALUES = 'listValues';
|
||||
const REGEX_LANGUAGE = 'js';
|
||||
@@ -16,12 +15,12 @@ class UDFWidget extends UDFWidgetTpl
|
||||
|
||||
public function display($widgetData)
|
||||
{
|
||||
$schema = $widgetData[UDFWidgetTpl::SCHEMA_ARG_NAME];
|
||||
$table = $widgetData[UDFWidgetTpl::TABLE_ARG_NAME];
|
||||
$schema = $widgetData[UDFLib::SCHEMA_ARG_NAME];
|
||||
$table = $widgetData[UDFLib::TABLE_ARG_NAME];
|
||||
|
||||
if (isset($widgetData[UDFWidgetTpl::FIELD_ARG_NAME]))
|
||||
if (isset($widgetData[UDFLib::FIELD_ARG_NAME]))
|
||||
{
|
||||
$field = $widgetData[UDFWidgetTpl::FIELD_ARG_NAME];
|
||||
$field = $widgetData[UDFLib::FIELD_ARG_NAME];
|
||||
}
|
||||
|
||||
$udfResults = $this->_loadUDF($schema, $table);
|
||||
@@ -105,8 +104,8 @@ class UDFWidget extends UDFWidgetTpl
|
||||
*/
|
||||
private function _setNameAndId($jsonSchema)
|
||||
{
|
||||
$this->_args[Widget::HTML_ARG_NAME][Widget::HTML_ID] = $jsonSchema->{UDFWidget::NAME};
|
||||
$this->_args[Widget::HTML_ARG_NAME][Widget::HTML_NAME] = $jsonSchema->{UDFWidget::NAME};
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][HTMLWidget::HTML_ID] = $jsonSchema->{UDFWidget::NAME};
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][HTMLWidget::HTML_NAME] = $jsonSchema->{UDFWidget::NAME};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,10 +209,10 @@ class UDFWidget extends UDFWidgetTpl
|
||||
*/
|
||||
private function _renderDropdown($jsonSchema, $multiple = false)
|
||||
{
|
||||
if (isset($this->_args[UDFWidgetTpl::UDFS_ARG_NAME])
|
||||
&& isset($this->_args[UDFWidgetTpl::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}]))
|
||||
if (isset($this->_args[UDFLib::UDFS_ARG_NAME])
|
||||
&& isset($this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}]))
|
||||
{
|
||||
$this->_args[DropdownWidget::SELECTED_ELEMENT] = $this->_args[UDFWidgetTpl::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}];
|
||||
$this->_args[DropdownWidget::SELECTED_ELEMENT] = $this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -254,10 +253,10 @@ class UDFWidget extends UDFWidgetTpl
|
||||
$textareaUDF = new TextareaWidgetUDF($this->_name, $this->_args);
|
||||
$text = null;
|
||||
|
||||
if (isset($this->_args[UDFWidgetTpl::UDFS_ARG_NAME])
|
||||
&& isset($this->_args[UDFWidgetTpl::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}]))
|
||||
if (isset($this->_args[UDFLib::UDFS_ARG_NAME])
|
||||
&& isset($this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}]))
|
||||
{
|
||||
$text = $this->_args[UDFWidgetTpl::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}];
|
||||
$text = $this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}];
|
||||
}
|
||||
|
||||
$textareaUDF->render($text);
|
||||
@@ -271,10 +270,10 @@ class UDFWidget extends UDFWidgetTpl
|
||||
$textareaUDF = new TextfieldWidgetUDF($this->_name, $this->_args);
|
||||
$text = null;
|
||||
|
||||
if (isset($this->_args[UDFWidgetTpl::UDFS_ARG_NAME])
|
||||
&& isset($this->_args[UDFWidgetTpl::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}]))
|
||||
if (isset($this->_args[UDFLib::UDFS_ARG_NAME])
|
||||
&& isset($this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}]))
|
||||
{
|
||||
$text = $this->_args[UDFWidgetTpl::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}];
|
||||
$text = $this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}];
|
||||
}
|
||||
|
||||
$textareaUDF->render($text);
|
||||
@@ -285,14 +284,14 @@ class UDFWidget extends UDFWidgetTpl
|
||||
*/
|
||||
private function _renderCheckbox($jsonSchema)
|
||||
{
|
||||
if (isset($this->_args[UDFWidgetTpl::UDFS_ARG_NAME])
|
||||
&& isset($this->_args[UDFWidgetTpl::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}]))
|
||||
if (isset($this->_args[UDFLib::UDFS_ARG_NAME])
|
||||
&& isset($this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}]))
|
||||
{
|
||||
$this->_args[CheckboxWidget::VALUE_FIELD] = $this->_args[UDFWidgetTpl::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}];
|
||||
$this->_args[CheckboxWidget::VALUE_FIELD] = $this->_args[UDFLib::UDFS_ARG_NAME][$jsonSchema->{UDFWidget::NAME}];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_args[CheckboxWidget::VALUE_FIELD] = Widget::HTML_DEFAULT_VALUE;
|
||||
$this->_args[CheckboxWidget::VALUE_FIELD] = HTMLWidget::HTML_DEFAULT_VALUE;
|
||||
}
|
||||
|
||||
$checkboxWidgetUDF = new CheckboxWidgetUDF($this->_name, $this->_args);
|
||||
@@ -306,73 +305,73 @@ class UDFWidget extends UDFWidgetTpl
|
||||
private function _setAttributesWithPhrases($jsonSchema)
|
||||
{
|
||||
// Description, title and placeholder
|
||||
if (isset($jsonSchema->{UDFWidgetTpl::LABEL})
|
||||
|| isset($jsonSchema->{UDFWidgetTpl::TITLE})
|
||||
|| isset($jsonSchema->{UDFWidgetTpl::PLACEHOLDER}))
|
||||
if (isset($jsonSchema->{UDFLib::LABEL})
|
||||
|| isset($jsonSchema->{UDFLib::TITLE})
|
||||
|| isset($jsonSchema->{UDFLib::PLACEHOLDER}))
|
||||
{
|
||||
//
|
||||
$this->_ci->load->library('PhrasesLib');
|
||||
|
||||
//
|
||||
if (isset($jsonSchema->{UDFWidgetTpl::LABEL}))
|
||||
if (isset($jsonSchema->{UDFLib::LABEL}))
|
||||
{
|
||||
$tmpResult = $this->_ci->phraseslib->getPhrases(
|
||||
UDFWidget::PHRASES_APP_NAME,
|
||||
DEFAULT_LEHREINHEIT_SPRACHE,
|
||||
$jsonSchema->{UDFWidgetTpl::LABEL},
|
||||
$jsonSchema->{UDFLib::LABEL},
|
||||
null,
|
||||
null,
|
||||
'no'
|
||||
);
|
||||
if (hasData($tmpResult))
|
||||
{
|
||||
$this->_args[Widget::HTML_ARG_NAME][UDFWidgetTpl::LABEL] = $tmpResult->retval[0]->text;
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::LABEL] = $tmpResult->retval[0]->text;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_args[Widget::HTML_ARG_NAME][UDFWidgetTpl::LABEL] = null;
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::LABEL] = null;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (isset($jsonSchema->{UDFWidgetTpl::TITLE}))
|
||||
if (isset($jsonSchema->{UDFLib::TITLE}))
|
||||
{
|
||||
$tmpResult = $this->_ci->phraseslib->getPhrases(
|
||||
UDFWidget::PHRASES_APP_NAME,
|
||||
DEFAULT_LEHREINHEIT_SPRACHE,
|
||||
$jsonSchema->{UDFWidgetTpl::TITLE},
|
||||
$jsonSchema->{UDFLib::TITLE},
|
||||
null,
|
||||
null,
|
||||
'no'
|
||||
);
|
||||
if (hasData($tmpResult))
|
||||
{
|
||||
$this->_args[Widget::HTML_ARG_NAME][UDFWidgetTpl::TITLE] = $tmpResult->retval[0]->text;
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::TITLE] = $tmpResult->retval[0]->text;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_args[Widget::HTML_ARG_NAME][UDFWidgetTpl::TITLE] = null;
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::TITLE] = null;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (isset($jsonSchema->{UDFWidgetTpl::PLACEHOLDER}))
|
||||
if (isset($jsonSchema->{UDFLib::PLACEHOLDER}))
|
||||
{
|
||||
$tmpResult = $this->_ci->phraseslib->getPhrases(
|
||||
UDFWidget::PHRASES_APP_NAME,
|
||||
DEFAULT_LEHREINHEIT_SPRACHE,
|
||||
$jsonSchema->{UDFWidgetTpl::PLACEHOLDER},
|
||||
$jsonSchema->{UDFLib::PLACEHOLDER},
|
||||
null,
|
||||
null,
|
||||
'no'
|
||||
);
|
||||
if (hasData($tmpResult))
|
||||
{
|
||||
$this->_args[Widget::HTML_ARG_NAME][UDFWidgetTpl::PLACEHOLDER] = $tmpResult->retval[0]->text;
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::PLACEHOLDER] = $tmpResult->retval[0]->text;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_args[Widget::HTML_ARG_NAME][UDFWidgetTpl::PLACEHOLDER] = null;
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::PLACEHOLDER] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -384,38 +383,38 @@ class UDFWidget extends UDFWidgetTpl
|
||||
private function _setValidationAttributes($jsonSchema)
|
||||
{
|
||||
// Validation
|
||||
$this->_args[Widget::HTML_ARG_NAME][UDFWidget::REQUIRED] = null;
|
||||
$this->_args[Widget::HTML_ARG_NAME][UDFWidgetTpl::REGEX] = null;
|
||||
$this->_args[Widget::HTML_ARG_NAME][UDFWidgetTpl::MAX_VALUE] = null;
|
||||
$this->_args[Widget::HTML_ARG_NAME][UDFWidgetTpl::MIN_VALUE] = null;
|
||||
$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;
|
||||
|
||||
if (isset($jsonSchema->validation))
|
||||
{
|
||||
if (isset($jsonSchema->{UDFWidget::VALIDATION}->{UDFWidgetTpl::REGEX})
|
||||
&& is_array($jsonSchema->{UDFWidget::VALIDATION}->{UDFWidgetTpl::REGEX}))
|
||||
if (isset($jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::REGEX})
|
||||
&& is_array($jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::REGEX}))
|
||||
{
|
||||
foreach($jsonSchema->{UDFWidget::VALIDATION}->{UDFWidgetTpl::REGEX} as $regex)
|
||||
foreach($jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::REGEX} as $regex)
|
||||
{
|
||||
if ($regex->language === UDFWidget::REGEX_LANGUAGE)
|
||||
{
|
||||
$this->_args[Widget::HTML_ARG_NAME][UDFWidgetTpl::REGEX] = $regex->expression;
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::REGEX] = $regex->expression;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($jsonSchema->{UDFWidget::VALIDATION}->{UDFWidgetTpl::REQUIRED}))
|
||||
if (isset($jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::REQUIRED}))
|
||||
{
|
||||
$this->_args[Widget::HTML_ARG_NAME][UDFWidget::REQUIRED] = $jsonSchema->{UDFWidget::VALIDATION}->{UDFWidgetTpl::REQUIRED};
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][UDFWidget::REQUIRED] = $jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::REQUIRED};
|
||||
}
|
||||
|
||||
if (isset($jsonSchema->{UDFWidget::VALIDATION}->{UDFWidgetTpl::MAX_VALUE}))
|
||||
if (isset($jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::MAX_VALUE}))
|
||||
{
|
||||
$this->_args[Widget::HTML_ARG_NAME][UDFWidgetTpl::MAX_VALUE] = $jsonSchema->{UDFWidget::VALIDATION}->{UDFWidgetTpl::MAX_VALUE};
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::MAX_VALUE] = $jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::MAX_VALUE};
|
||||
}
|
||||
|
||||
if (isset($jsonSchema->{UDFWidget::VALIDATION}->{UDFWidgetTpl::MIN_VALUE}))
|
||||
if (isset($jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::MIN_VALUE}))
|
||||
{
|
||||
$this->_args[Widget::HTML_ARG_NAME][UDFWidgetTpl::MIN_VALUE] = $jsonSchema->{UDFWidget::VALIDATION}->{UDFWidgetTpl::MIN_VALUE};
|
||||
$this->_args[HTMLWidget::HTML_ARG_NAME][UDFLib::MIN_VALUE] = $jsonSchema->{UDFWidget::VALIDATION}->{UDFLib::MIN_VALUE};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user