8th release

This commit is contained in:
Paolo
2017-05-08 11:39:21 +02:00
parent 6a11cc09cf
commit 51ccee4d16
4 changed files with 77 additions and 15 deletions
+35 -9
View File
@@ -1040,10 +1040,14 @@ class CheckboxWidget 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_VALUES_ARRAY_NAME = 'VALUES_ARRAY';
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 VALUE_FIELD = 'value';
// 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 CHECKED_VALUE = 'checkedValue';
const CHECKED_ELEMENT = 'checkedElement';
/**
*
@@ -1053,9 +1057,9 @@ class CheckboxWidget extends Widget
parent::__construct($name, $args, $htmlArgs);
//
if (!isset($this->_args[CheckboxWidget::CHECKED_VALUE]))
if (!isset($this->_args[CheckboxWidget::CHECKED_ELEMENT]))
{
$this->_args[CheckboxWidget::CHECKED_VALUE] = Widget::HTML_DEFAULT_VALUE;
$this->_args[CheckboxWidget::CHECKED_ELEMENT] = Widget::HTML_DEFAULT_VALUE;
}
}
@@ -1081,7 +1085,7 @@ class CheckboxWidget extends Widget
}
else
{
$this->_args[CheckboxWidget::WIDGET_DATA_VALUES_ARRAY_NAME] = $values->retval;
$this->_args[CheckboxWidget::WIDGET_DATA_ELEMENTS_ARRAY_NAME] = $values->retval;
}
}
@@ -1104,19 +1108,41 @@ class CheckboxWidgetUDF extends CheckboxWidget
*/
public function render($parameters)
{
$tmpValues = array();
$tmpElements = array();
//
foreach($parameters as $parameter)
{
//
if (is_string($parameter) || is_numeric($parameter))
if ((is_array($parameter) && count($parameter) == 2)
|| (is_string($parameter) || is_numeric($parameter))
|| (is_object($parameter) && isset($parameter->{PARENT::VALUE_FIELD}) && isset($parameter->{PARENT::DESCRIPTION_FIELD})))
{
array_push($tmpValues, $parameter); //
$element = new stdClass(); //
//
if (is_array($parameter) && count($parameter) == 2)
{
$element->{PARENT::VALUE_FIELD} = $parameter[0]; //
$element->{PARENT::DESCRIPTION_FIELD} = $parameter[1]; //
}
//
else if (is_string($parameter) || is_numeric($parameter))
{
$element->{PARENT::VALUE_FIELD} = $parameter; //
$element->{PARENT::DESCRIPTION_FIELD} = $parameter; //
}
//
else if (is_object($parameter) && isset($parameter->{PARENT::VALUE_FIELD}) && isset($parameter->{PARENT::DESCRIPTION_FIELD}))
{
$element->{PARENT::VALUE_FIELD} = $parameter->{PARENT::VALUE_FIELD}; //
$element->{PARENT::DESCRIPTION_FIELD} = $parameter->{PARENT::DESCRIPTION_FIELD}; //
}
array_push($tmpElements, $element); //
}
}
$this->setValuesArray(success($tmpValues));
$this->setValuesArray(success($tmpElements));
$this->loadCheckboxView();
+30
View File
@@ -91,6 +91,36 @@
?>
</div>
<br/>
<div>
<?php
echo $this->widgetlib->UDFWidget(
array(
UDFWidgetTpl::SCHEMA_ARG_NAME => 'public',
UDFWidgetTpl::TABLE_ARG_NAME => 'tbl_person',
UDFWidgetTpl::FIELD_ARG_NAME => 'disagree'
),
array('id' => 'disagreeID', 'name' => 'disagreeName')
);
?>
</div>
<br/>
<div>
<?php
echo $this->widgetlib->UDFWidget(
array(
UDFWidgetTpl::SCHEMA_ARG_NAME => 'public',
UDFWidgetTpl::TABLE_ARG_NAME => 'tbl_person',
UDFWidgetTpl::FIELD_ARG_NAME => 'dunno'
),
array('id' => 'dunnoID', 'name' => 'dunnoName')
);
?>
</div>
</body>
<?php $this->load->view("templates/footer"); ?>
+6 -6
View File
@@ -15,14 +15,14 @@
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, UDFWidgetTpl::TITLE); ?>
>
<?php
$values = ${CheckboxWidget::WIDGET_DATA_VALUES_ARRAY_NAME};
$checkedValue = ${CheckboxWidget::CHECKED_VALUE};
$elements = ${CheckboxWidget::WIDGET_DATA_ELEMENTS_ARRAY_NAME};
$checkedElement = ${CheckboxWidget::CHECKED_ELEMENT};
foreach($values as $value)
foreach($elements as $element)
{
$checked = '';
if ($value == $checkedValue)
if ($element->{CheckboxWidget::VALUE_FIELD} == $checkedElement)
{
$checked = 'checked';
}
@@ -30,10 +30,10 @@
<input
type="checkbox"
<?php Widget::printAttribute(${Widget::HTML_ARG_NAME}, Widget::HTML_NAME); ?>
value="<?php echo $value; ?>"
value="<?php echo $element->{CheckboxWidget::VALUE_FIELD}; ?>"
<?php echo $checked; ?>
>
<?php echo $element->{CheckboxWidget::DESCRIPTION_FIELD}; ?>
<?php
}
?>
+6
View File
@@ -205,6 +205,12 @@ class UDFWidget extends UDFWidgetTpl
*/
private function _renderCheckbox($jsonSchema)
{
//
if (!isset($this->_args[CheckboxWidget::CHECKED_ELEMENT]))
{
$this->_args[CheckboxWidget::CHECKED_ELEMENT] = $jsonSchema->defaultValue;
}
$checkboxWidgetUDF = new CheckboxWidgetUDF($this->_name, $this->_args);
$parameters = array();