mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-19 16:02:15 +00:00
1st release
This commit is contained in:
@@ -208,6 +208,7 @@ $config['fhc_acl'] = array
|
||||
'system.tbl_webservicelog' => 'basis/webservicelog',
|
||||
'system.tbl_webservicerecht' => 'basis/webservicerecht',
|
||||
'system.tbl_webservicetyp' => 'basis/webservicetyp',
|
||||
'system.tbl_udf' => 'system/udf',
|
||||
'testtool.tbl_ablauf' => 'basis/ablauf',
|
||||
'testtool.tbl_antwort' => 'basis/antwort',
|
||||
'testtool.tbl_frage' => 'basis/frage',
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"title": "UDF",
|
||||
"type": "object",
|
||||
"tableswhitelist": {
|
||||
"type": "string",
|
||||
"enum": ["tbl_person", "tbl_prestudent", "tbl_mitarbeiter", "tbl_lehrveranstaltung", "tbl_lehreinheit"]
|
||||
},
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "array",
|
||||
},
|
||||
"placeholder": {
|
||||
"type": "array",
|
||||
},
|
||||
"title": {
|
||||
"type": "array",
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["checkbox", "textfield", "textarea", "date", "dropdown", "multipledropdown"]
|
||||
},
|
||||
"sort": {
|
||||
"type": "integer"
|
||||
},
|
||||
"defaultValue": {
|
||||
"type": "string"
|
||||
},
|
||||
"validation": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"required": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"min-length": {
|
||||
"type": "integer"
|
||||
},
|
||||
"max-length": {
|
||||
"type": "integer"
|
||||
},
|
||||
"min-value": {
|
||||
"type": "integer"
|
||||
},
|
||||
"min-value": {
|
||||
"type": "integer"
|
||||
},
|
||||
"regex": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"language": "string",
|
||||
"expression": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"listValues": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"sql": {
|
||||
"type": "string"
|
||||
},
|
||||
"enum": {
|
||||
"type": "array"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["type", "name"]
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class TestUDF extends VileSci_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Loads the widget library
|
||||
$this->load->library('WidgetLib');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data = array (
|
||||
'schema' => 'public',
|
||||
'table' => 'tbl_person',
|
||||
'field' => 'schuhgroesse'
|
||||
);
|
||||
|
||||
$this->load->view('system/testudf', $data);
|
||||
}
|
||||
}
|
||||
@@ -213,6 +213,38 @@ class WidgetLib
|
||||
return new $class($class, $data, $htmlArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function UDFWidget($args, $htmlArgs = array())
|
||||
{
|
||||
if (!empty($args[UDF_widget_tpl::SCHEMA_ARG_NAME])
|
||||
&& !empty($args[UDF_widget_tpl::TABLE_ARG_NAME])
|
||||
&& !empty($args[UDF_widget_tpl::FIELD_ARG_NAME]))
|
||||
{
|
||||
return $this->widget(
|
||||
UDF_widget_tpl::WIDGET_NAME,
|
||||
$args,
|
||||
$htmlArgs
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($args[UDF_widget_tpl::SCHEMA_ARG_NAME]))
|
||||
{
|
||||
show_error(UDF_widget_tpl::SCHEMA_ARG_NAME.' parameter is missing!');
|
||||
}
|
||||
if (empty($args[UDF_widget_tpl::TABLE_ARG_NAME]))
|
||||
{
|
||||
show_error(UDF_widget_tpl::TABLE_ARG_NAME.' parameter is missing!');
|
||||
}
|
||||
if (empty($args[UDF_widget_tpl::FIELD_ARG_NAME]))
|
||||
{
|
||||
show_error(UDF_widget_tpl::FIELD_ARG_NAME.' parameter is missing!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable cache for all partials with TTL, default TTL is 60
|
||||
* @param int $ttl
|
||||
@@ -794,4 +826,15 @@ class DropdownWidget extends Widget
|
||||
|
||||
array_unshift($this->elementsArray->retval, $element);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
abstract class UDF_widget_tpl extends Widget
|
||||
{
|
||||
const WIDGET_NAME = 'UDF_widget';
|
||||
const SCHEMA_ARG_NAME = 'schema';
|
||||
const TABLE_ARG_NAME = 'table';
|
||||
const FIELD_ARG_NAME = 'field';
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
class UDF_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = 'system.tbl_udf';
|
||||
$this->pk = array('schema', 'table');
|
||||
$this->hasSequence = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php $this->load->view("templates/header", array("title" => "UDF")); ?>
|
||||
|
||||
<body>
|
||||
|
||||
<div>
|
||||
UDFWidget:
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<?php
|
||||
echo $this->widgetlib->UDFWidget(
|
||||
array(
|
||||
UDF_widget_tpl::SCHEMA_ARG_NAME => $schema,
|
||||
UDF_widget_tpl::TABLE_ARG_NAME => $table,
|
||||
UDF_widget_tpl::FIELD_ARG_NAME => $field
|
||||
),
|
||||
array('name' => 'schuhgroesse', 'id' => 'schuhgroesseUDF')
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
<?php $this->load->view("templates/footer"); ?>
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class UDF_widget extends UDF_widget_tpl
|
||||
{
|
||||
public function display($widgetData)
|
||||
{
|
||||
$schema = $widgetData[UDF_widget_tpl::SCHEMA_ARG_NAME];
|
||||
$table = $widgetData[UDF_widget_tpl::TABLE_ARG_NAME];
|
||||
$field = $widgetData[UDF_widget_tpl::FIELD_ARG_NAME];
|
||||
|
||||
// Loads UDF model
|
||||
$this->_ci->load->model('system/UDF_model', 'UDFModel');
|
||||
|
||||
$udfResults = $this->_ci->UDFModel->loadWhere(
|
||||
array(
|
||||
'schema' => $schema,
|
||||
'table' => $table
|
||||
)
|
||||
);
|
||||
|
||||
if (isError($udfResults))
|
||||
{
|
||||
if (is_object($udfResults) && isset($udfResults->retval))
|
||||
{
|
||||
show_error($udfResults->retval);
|
||||
}
|
||||
else if (is_string($udfResults))
|
||||
{
|
||||
show_error($udfResults);
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error('UDF_widget: generic error occurred');
|
||||
}
|
||||
}
|
||||
else if (!hasData($udfResults))
|
||||
{
|
||||
show_error(sprintf('%s.%s does not contain UDF', $schema, $table));
|
||||
}
|
||||
else
|
||||
{
|
||||
$udf = $udfResults->retval[0];
|
||||
if (isset($udf->jsons))
|
||||
{
|
||||
$jsonSchema = json_decode($udf->jsons);
|
||||
if (is_object($jsonSchema))
|
||||
{
|
||||
if (isset($jsonSchema->type))
|
||||
{
|
||||
var_dump($jsonSchema);
|
||||
|
||||
if ($jsonSchema->type == 'checkbox')
|
||||
{
|
||||
|
||||
}
|
||||
else if ($jsonSchema->type == 'textfield')
|
||||
{
|
||||
|
||||
}
|
||||
else if ($jsonSchema->type == 'textarea')
|
||||
{
|
||||
|
||||
}
|
||||
else if ($jsonSchema->type == 'date')
|
||||
{
|
||||
|
||||
}
|
||||
else if ($jsonSchema->type == 'dropdown')
|
||||
{
|
||||
$dropdownWidget = new DropdownWidget();
|
||||
}
|
||||
else if ($jsonSchema->type == 'multipledropdown')
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error(sprintf('%s.%s: Attribute "type" not present in the json schema', $schema, $table));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error(sprintf('%s.%s: Not a valid json schema', $schema, $table));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
show_error(sprintf('%s.%s: Does not contain "jsons" field', $schema, $table));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user