Commit 7b9ced59 authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

Merge remote-tracking branch 'remotes/origin/crose_work' into raos_work

parents 6dc31fc5 fcb2be2e
......@@ -30,17 +30,23 @@ LOAD
* (Report)
* Process all <number>.[<number.>].sql statements
* Access code variables:
* Access variables:
* active/valid formname: [$this->store->setVar(SYSTEM_FORM, $formName, STORE_SYSTEM);]
* SIP: [$this->store->getVar('form', STORE_SIP)]
* All parameters from active SIP: [$this->store->getStore(STORE_SIP)]
* Check Contstants.php for known Store members:
* Check Contstants.php for known Store *members*.
* In QuickFormQuery.php the whole Form will be copied to `$this->formSpec` and depending on further processing, the
elements are available in `$this->feNative` and `$this->feAction`.
* The Form specificaton (table form) will be evaluated direct after loading.
* The FormElement specification will be evaluated later on in BuildForm*.php
elements are available in `$this->feSpecNative` and `$this->feSpecAction`.
* The Form specificaton (table form) will be evaluated direct after loading (no `dynamicUpdate`).
* The FormElement specification will be evaluated later in BuildForm*.php:
* $formSpec, and root elements of $feSpecAction & $feSpecNative will be read in QuickFormQuery.php.
* AbstractBuildForm.php/BuildFormBootstrap.php receives a copy during instantiating of that class.
* Processing of FormElements in AbstractBuildForm.php/BuildFormBootstrap.php typically do not change values,
especially there is no evaluation, in $feSpecAction & $feSpecNative.
* *Dynamic Update*: remember, an update(=Form load) is a complete new rendering of the form in that moment. All
values/elements/notes/debug are fresh with the latest form content.
* If a form is called without a SIP (form.permitNew='always'), than a SIP is created on the fly (as a
parameter in the form).
* Uniq SIP for mutliple tabs with r=0
......@@ -59,6 +65,13 @@ LOAD
AbstractBuildForm.php: process() > prepareT3VarsForSave() > Store.php: copyT3VarsToSip();
* *Form save*: FillStoreForm.php: process() > Store: fillTypo3StoreFromSip()
* Store: STORE_ADDITIONAL_FORM_ELEMENTS
* HTML 'hidden' elements, inside of a checkbox or radio input definition, might disturb Bootstrap CSS classes.
* Therefore HTML elements like 'hidden' can be collected in STORE_ADDITIONAL_FORM_ELEMENTS.
* When the form will be composed of all single parts, the STORE_ADDITIONAL_FORM_ELEMENTS content will be arranged before
the regular INPUT Elements.
* Formular zusammenbauen
* QuickFormQuery: doForm > loadFormSpecification - laedt den Form Record alle Form Elemente die nicht genested sind:
native, pill, fieldset, templateGroup >> $his->formNative.
......
......@@ -14,6 +14,9 @@ Administrator Manual
Preparation
-----------
Report & Form
^^^^^^^^^^^^^
The QFQ extension needs in PHP 5.x the PHP MySQL native driver. The following functions are used and are only available with the
native driver (see also: http://dev.mysql.com/downloads/connector/php-mysqlnd/):
......@@ -34,6 +37,34 @@ Preparation steps for Ubuntu 16.04::
sudo apt install php7.0-intl
Print page via wkhtmltopdf
^^^^^^^^^^^^^^^^^^^^^^^^^^
Different browser prints the same page in different variations. To prevent this, QFQ implements a small PHP wrapper `print.php`
which uses http://wkhtmltopdf.org/ (webkit based) to convert HTML to PDF. The converter is not included in QFQ and has
to be manually installed.
Hint: The Ubuntu package `wkhtmltopdf` needs a running Xserver - this does not work on a headless webserver. Best is to
install the QT version from the named website above.
In config.qfq.ini specify the:
* installed `wkhtmltopdf` binary,
* the site base URL.
Provide a `print this page`-link (replace {current pageId})::
<a href="typo3conf/ext/qfq/qfq/api/print.php?id={current pageId}">Print this page</a>
Any parameter specified after `print.php` will be delivered to `wkhtmltopdf` as part of the URL.
Typoscript code to implement a print link on every page::
10 = TEXT
10 {
wrap = <a href="typo3conf/ext/qfq/qfq/api/print.php?id=|&type=2"><span class="glyphicon glyphicon-print" aria-hidden="true"></span> Printview</a>
data = page:uid
}
Setup
-----
......@@ -162,7 +193,10 @@ config.qfq.ini
+-----------------------------+-----------------------------------------+----------------------------------------------------------------------------+
| FORM_BUTTON_ON_CHANGE_CLASS | FORM_BUTTON_ON_CHANGE_CLASS=alert-info btn-info | Color for save button after modification |
+-----------------------------+-----------------------------------------+----------------------------------------------------------------------------+
| BASE_URL_PRINT | BASE_URL_PRINT=http://example.com | URL where wkhtmltopdf will fetch the HTML (no parameter, those comes later)|
+-----------------------------+-----------------------------------------+----------------------------------------------------------------------------+
| WKHTMLTOPDF | WKHTMLTOPDF=/usr/bin/wkhtmltopdf | Binary where to find wkhtmltopdf |
+-----------------------------+-----------------------------------------+----------------------------------------------------------------------------+
Example: *typo3conf/config.qfq.ini*
......@@ -190,6 +224,8 @@ Example: *typo3conf/config.qfq.ini*
;FORM_BS_LABEL_COLUMNS = 3
;FORM_BS_INPUT_COLUMNS = 6
;FORM_BS_NOTE_COLUMNS = 3
BASE_URL_PRINT=http://example.com
WKHTMLTOPDF=/usr/bin/wkhtmltopdf
Documentation
-------------
......
......@@ -234,7 +234,7 @@ Only variables that are known in a specified store can be substituted.
+=====+========================================================================================+============================================================================+
| F | :ref:`STORE_FORM`: data not saved in database yet. | All native *FormElements*. Recent values from the Browser. |
+-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
| S | :ref:`STORE_SIP`: Client parameter 's' will indicate the current SIP, which will be | sip, r (record_id), form |
| S | :ref:`STORE_SIP`: Client parameter 's' will indicate the current SIP, which will be | sip, r (recordId), form |
| | loaded from the SESSION repo to the SIP-Store. | |
+-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
| R | :ref:`STORE_RECORD`: Record - the current record loaded in the form | All columns of the current record from the current table |
......@@ -291,7 +291,7 @@ Store: *FORM* - F
+---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| Name | Explanation |
+=================================+============================================================================================================================================+
| <FormElement name> | Name of native *FormElement*. To get, exactly and only, the specified *FormElement* (for 'p_id'): *{{p_id:F}}* |
| <FormElement name> | Name of native *FormElement*. To get, exactly and only, the specified *FormElement* (for 'pId'): *{{pId:F}}* |
+---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
.. _STORE_SIP:
......@@ -333,7 +333,7 @@ Store: *RECORD* - R
+------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
| Name | Explanation |
+========================+==================================================================================================================================================+
| <column name> | Name of a column of the primary table (as defined in the current form). To get, exactly and only, the specified form *FormElement*: *{{p_id:R}}* |
| <column name> | Name of a column of the primary table (as defined in the current form). To get, exactly and only, the specified form *FormElement*: *{{pId:R}}* |
+------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
.. _STORE_BEFORE:
......@@ -350,7 +350,7 @@ This store is handy to compare new and old values of a form.
+------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
| Name | Explanation |
+========================+==================================================================================================================================================+
| <column name> | Name of a column of the primary table (as defined in the current form). To get, exactly and only, the specified form *FormElement*: *{{p_id:R}}* |
| <column name> | Name of a column of the primary table (as defined in the current form). To get, exactly and only, the specified form *FormElement*: *{{pId:R}}* |
+------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
.. _STORE_CLIENT:
......@@ -522,7 +522,7 @@ SQL Statement
{{SELECT id, name FROM Person}}
{{SELECT id, name, IF({{feUser}}=0,'Yes','No') FROM Vorlesung WHERE sem_id={{keySemId:Y}} }}
{{SELECT id, city FROM Address AS adr WHERE adr.p_id={{SELECT id FROM Account AS acc WHERE acc.name={{feUser}} }} }}
{{SELECT id, city FROM Address AS adr WHERE adr.pId={{SELECT id FROM Account AS acc WHERE acc.name={{feUser}} }} }}
* Special case for SELECT input fields. To deliver a result array specify an '!' before the SELECT: ::
......@@ -834,7 +834,7 @@ Fields:
|checkType | enum('min|max', 'pattern', | |
| | 'number', 'email') | |
+---------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|checkPattern | 'regexp' |If $check_type=='pattern': pattern to match |
|checkPattern | 'regexp' |If $checkType=='pattern': pattern to match |
+---------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|onChange | string |List of *FormElement*-names of current form, separated by ', ', If one of the named *FormElements* |
| | | change, reload own data / status / mode |
......@@ -1561,20 +1561,20 @@ sqlBefore / sqlInsert / sqlUpdate / sqlDelete / sqlAfter
Example
'''''''
Situation 1: master.x_id=slave.id (1:1)
Situation 1: master.xId=slave.id (1:1)
* Name the action element 'x_id': than {{slaveId}} will be automatically set to the value of 'master.x_id'
* Name the action element 'xId': than {{slaveId}} will be automatically set to the value of 'master.xId'
* {{slaveId}} == 0 ? 'sqlInsert' will be fired.
* {{slaveId}} != 0 ? 'sqlUpdate' will be fired.
* In case of fireing 'sqlInsert', the 'slave.id' of the new created record are copied to master.x_id (the database will
* In case of fireing 'sqlInsert', the 'slave.id' of the new created record are copied to master.xId (the database will
be updated automatically).
* If the automatic update of the master record is not suitable, the action element should have no name or a name
which does not exist as a column of the master record. Define `slaveId={{SELECT id ...}}`
Situation 2: master.id=slave.x_id (1:n)
Situation 2: master.id=slave.xId (1:n)
* Name the action element different to any columnname of the master record (or no name).
* Determine the slaveId: `slaveId={{SELECT id FROM slave WHERE slave.xxx={{...}} LIMIT 1}}`
......@@ -1716,10 +1716,10 @@ To display a report on any given TYPO3 page, create a content element of type 'Q
A simple example
^^^^^^^^^^^^^^^^
Assume that the database has a table person with columns first_name and last_name. To create a simple list of all persons, we can do the following:
Assume that the database has a table person with columns firstName and lastName. To create a simple list of all persons, we can do the following:
::
10.sql = SELECT id AS person_id, CONCAT(first_name, " ", last_name, " ") AS name FROM person
10.sql = SELECT id AS pId, CONCAT(firstName, " ", lastName, " ") AS name FROM person
10 Stands for a *root level* of the report (see section `Structure`_). 10.sql defines a SQL query for this specific level. When the query is executed it will return a result having one single column name containing first and last name
separated by a space character.
......@@ -1739,7 +1739,7 @@ However, we can modify (wrap) the output by setting the values of various keys f
::
10.sql = SELECT id AS person_id, CONCAT(first_name, " ", last_name, " ") AS name FROM person
10.sql = SELECT id AS personId, CONCAT(firstName, " ", lastName, " ") AS name FROM person
10.sep = <br />
HTML output:
......@@ -1817,10 +1817,10 @@ See the example below:
::
10.sql = SELECT id AS _person_id, CONCAT(first_name, " ", last_name, " ") AS name FROM person
10.sql = SELECT id AS _pId, CONCAT(firstName, " ", lastName, " ") AS name FROM person
10.rsep = <br />
10.10.sql = SELECT CONCAT(postal_code, " ", city) FROM address WHERE p_id = {{10.person_id}}
10.10.sql = SELECT CONCAT(postal_code, " ", city) FROM address WHERE pId = {{10.pId}}
10.10.rbeg = (
10.10.rend = )
......@@ -1934,7 +1934,7 @@ Be careful to:
Access to upper column values
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Columns of the upper level result can be accessed via variables, eg. {{10.person_id}} will be replaced by the value in the person_id column.
Columns of the upper level result can be accessed via variables, eg. {{10.pId}} will be replaced by the value in the pId column.
+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|**Levels** |A report is divided into levels. Example 1 has 3 levels **10**, **20.25**, **20.25.10** |
......@@ -1965,10 +1965,10 @@ Report Example 1:
10.sql = SELECT CURDATE()
# Show all students from the person table
20.sql = SELECT p.id AS p_id, p.first_name, " - ", p.last_name FROM person AS p WHERE p.typ LIKE "student"
20.sql = SELECT p.id AS pId, p.firstName, " - ", p.lastName FROM person AS p WHERE p.typ LIKE "student"
# Show all the marks from the current student ordered chronological
20.25.sql = SELECT e.mark FROM exam AS e WHERE e.p_id={{20.p_id}} ORDER BY e.date
20.25.sql = SELECT e.mark FROM exam AS e WHERE e.pId={{20.pId}} ORDER BY e.date
# This query will never be fired, cause there is no direct parent called 20.30.
20.30.10.sql = SELECT 'never fired'
......@@ -2857,7 +2857,7 @@ Accessing the database
::
10.sql = SELECT p.first_name FROM exp_person AS p
10.sql = SELECT p.firstName FROM exp_person AS p
..
......@@ -2879,7 +2879,7 @@ Accessing the database
::
10.sql = SELECT p.first_name, p.last_name FROM exp_person AS p
10.sql = SELECT p.firstName, p.lastName FROM exp_person AS p
..
......@@ -2913,7 +2913,7 @@ Two columns
# Add the formating information as a coloum
10.sql = SELECT p.first_name, " " , p.last_name, "'<br /'>" FROM exp_person AS p
10.sql = SELECT p.firstName, " " , p.lastName, "'<br /'>" FROM exp_person AS p
..
......@@ -3014,29 +3014,29 @@ Two queries: nested with variables ::
10.rend = <br />
# inner query
10.10.sql = SELECT a.street FROM exp_address AS a WHERE a.pid='{{10.id}}'
10.10.sql = SELECT a.street FROM exp_address AS a WHERE a.pId='{{10.id}}'
10.10.rend = <br />
* For every record of '10', all assigned records of 10.10 will be printed.
Two queries: nested with hidden variables in a table ::
10.sql = SELECT p.id AS _p_id, p.name FROM exp_person AS p
10.sql = SELECT p.id AS _pId, p.name FROM exp_person AS p
10.rend = <br />
# inner query
10.10.sql = SELECT a.street FROM exp_address AS a WHERE a.p_id='{{10.p_id}}'
10.10.sql = SELECT a.street FROM exp_address AS a WHERE a.pId='{{10.pId}}'
10.10.rend = <br />
Same as above, but written in the nested notation ::
10 {
sql = SELECT p.id AS _p_id, p.name FROM exp_person AS p
sql = SELECT p.id AS _pId, p.name FROM exp_person AS p
rend = <br />
10 {
# inner query
sql = SELECT a.street FROM exp_address AS a WHERE a.p_id='{{10.p_id}}'
sql = SELECT a.street FROM exp_address AS a WHERE a.pId='{{10.pId}}'
rend = <br />
}
}
......
......@@ -12,6 +12,15 @@ Changes
'pattern','allbut','all') NOT NULL DEFAULT 'alnumx'
Features
--------
* print.php
* Install `wkhtmltopdf` on the webserver (http://wkhtmltopdf.org/).
* In config.qfq.ini setup BASE_URL_PRINT, WKHTMLTOPDF.
Bug Fixes
---------
......
......@@ -41,3 +41,7 @@ DATE_FORMAT = yyyy-mm-dd
;FORM_BS_LABEL_COLUMNS = 3
;FORM_BS_INPUT_COLUMNS = 6
;FORM_BS_NOTE_COLUMNS = 3
; Configure URL where `wkhtmltopdf` fetches pages and produces PDFs
BASE_URL_PRINT = http://example.com/
WKHTMLTOPDF = /opt/wkhtmltox/bin/wkhtmltopdf
......@@ -65,6 +65,8 @@ try {
$answer[API_STATUS] = API_ANSWER_STATUS_SUCCESS;
$answer[API_MESSAGE] = 'load: success';
$answer[API_FORM_UPDATE] = $data;
$answer[API_ELEMENT_UPDATE] = $data[API_ELEMENT_UPDATE];
unset($data[API_ELEMENT_UPDATE]);
} catch (qfq\UserFormException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
......
<?php
/**
* Created by PhpStorm.
* User: ep
* Date: 12/23/15
* Time: 6:17 PM
*/
namespace qfq;
use qfq;
require_once(__DIR__ . '/../qfq/store/Config.php');
require_once(__DIR__ . '/../qfq/Constants.php');
require_once(__DIR__ . '/../qfq/helper/KeyValueStringParser.php');
const PAGEID = 'id';
const PARAM_GET = 'paramGet';
const URL_PRINT = 'urlPrint';
/**
* Create a temporary file.
*
* @return string
*/
function createEmptyFile() {
return tempnam(sys_get_temp_dir(), "webkitPrintPdf");
}
/**
* Set HTML Header to initiate PDF download.
*
* @param $filename
*/
function setHeader($filename) {
header("Content-Disposition: inline; filename=\"$filename\"");
header("Content-Type: application/pdf");
header("Content-Transfer-Encoding: binary");
}
/**
* Read QFQ config. Only SYSTEM_BASE_URL_PRINT and SYSTEM_WKHTMLTOPDF will be used.
* Check and get all clean _GET Parameter. Build a URL based on SYSTEM_BASE_URL_PRINT and the delivered URL params.
*
* @return array
* @throws UserFormException
* @throws \exception
*/
function init() {
$cfg = new Config();
$config = $cfg->readConfig('');
$param = readCleanGetParam();
if (!isset($config[SYSTEM_BASE_URL_PRINT]) || $config[SYSTEM_BASE_URL_PRINT] == '') {
throw new \exception(CONFIG_INI . ' - Missing ' . SYSTEM_BASE_URL_PRINT);
}
if (!isset($config[SYSTEM_WKHTMLTOPDF]) || $config[SYSTEM_WKHTMLTOPDF] == '') {
throw new \exception(CONFIG_INI . ' - Missing ' . SYSTEM_WKHTMLTOPDF);
}
if (!is_executable($config[SYSTEM_WKHTMLTOPDF])) {
throw new \exception(CONFIG_INI . ' - ' . SYSTEM_WKHTMLTOPDF . '=' . $config[SYSTEM_WKHTMLTOPDF] . ' - not found or not executable.');
}
if (!isset($param[PAGEID]) || $param[PAGEID] == '') {
throw new \exception("Missing GET Parameter '" . PAGEID . "'.");
}
$setup = array();
$setup[URL_PRINT] = $config[SYSTEM_BASE_URL_PRINT] . '/?' . KeyValueStringParser::unparse($param, '=', '&');
$setup[PAGEID] = $param[PAGEID];
$setup[SYSTEM_WKHTMLTOPDF] = $config[SYSTEM_WKHTMLTOPDF];
return $setup;
}
;
/**
* Return an array with GET params who are clean - they do not violate $pattern.
*
* @return array
*/
function readCleanGetParam() {
$param = array();
$pattern = '^[\-_\.,;:\/a-zA-Z0-9]*$'; // ':alnum:' does not work here in FF
foreach ($_GET as $key => $value) {
if (preg_match("/$pattern/", $value) === 1) {
$param[$key] = $value;
}
}
return $param;
}
/**
* @param array $setup
* @throws \exception
*/
function page2pdf($setup) {
$rc = 0;
$file = createEmptyFile();
$cmd = $setup[SYSTEM_WKHTMLTOPDF] . " '" . $setup[URL_PRINT] . "' " . $file . " > $file.log 2>&1";
$line = system($cmd, $rc);
if ($rc == 0) {
setHeader('print.' . $setup[PAGEID] . '.pdf');
@readfile($file);
@unlink($file);
@unlink($file . '.log');
exit; // Do an extremely hard exit here to make sure there are no more additional bytes sent (makes the delivered PDF unusable).
} else {
throw new \exception("Error [RC=$rc] $line: $cmd");
}
}
/**
* Main
*/
try {
$setup = init();
page2pdf($setup);
} catch (\Exception $e) {
echo "Exception: " . $e->getMessage();
}
......@@ -23,7 +23,6 @@ require_once(__DIR__ . '/../qfq/helper/Support.php');
require_once(__DIR__ . '/../qfq/helper/OnArray.php');
require_once(__DIR__ . '/../qfq/report/Link.php');
/**
* Class AbstractBuildForm
* @package qfq
......@@ -186,10 +185,11 @@ abstract class AbstractBuildForm {
$htmlTail = $this->tail();
$htmlSubrecords = $this->doSubrecords();
}
$htmlHidden = $this->buildAdditionalFormElements();
$htmlSip = $this->buildHiddenSip($json);
return ($mode === FORM_LOAD) ? $htmlHead . $htmlElements . $htmlSip . $htmlT3vars . $htmlTail . $htmlSubrecords : $json;
return ($mode === FORM_LOAD) ? $htmlHead . $htmlHidden . $htmlElements . $htmlSip . $htmlT3vars . $htmlTail . $htmlSubrecords : $json;
}
/**
......@@ -330,7 +330,7 @@ abstract class AbstractBuildForm {
abstract public function getProcessFilter();
/**
* Process all FormElements: build corresponding HTML code. Collect and return all HTML code & JSON.
* Process all FormElements: Collect and return all HTML code & JSON.
*
* @param $recordId
* @param string $filter FORM_ELEMENTS_NATIVE | FORM_ELEMENTS_SUBRECORD | FORM_ELEMENTS_NATIVE_SUBRECORD
......@@ -351,7 +351,7 @@ abstract class AbstractBuildForm {
$html = '';
$flagOutput = false;
// The following 'FormElement.parameter' will never be used during load (fe.type='upload').
// The following 'FormElement.parameter' will never be used during load (fe.type='upload'). FE_PARAMETER has been already expanded.
$skip = [FE_SQL_UPDATE, FE_SQL_INSERT, FE_SQL_DELETE, FE_SQL_AFTER, FE_SQL_BEFORE, FE_PARAMETER];
// get current data record
......@@ -420,6 +420,7 @@ abstract class AbstractBuildForm {
$buildElementFunctionName = 'build' . $this->buildElementFunctionName[$formElement[FE_TYPE]];
$jsonElement = array();
$elementExtra = '';
// Render pure element
$elementHtml = $this->$buildElementFunctionName($formElement, $htmlFormElementName, $value, $jsonElement, $mode);
......@@ -539,6 +540,20 @@ abstract class AbstractBuildForm {
abstract public function doSubrecords();
/**
* Get all elements from STORE_ADDITIONAL_FORM_ELEMENTS and return them as a string.
*
* @return string
* @throws CodeException
* @throws \qfq\UserFormException
*/
private function buildAdditionalFormElements() {
$data = $this->store->getStore(STORE_ADDITIONAL_FORM_ELEMENTS);
return is_array($data) ? implode('', $data) : '';
}
/**
* Create a hidden sip, based on latest STORE_SIP Values. Return complete HTML 'hidden' element.
*
......@@ -560,26 +575,38 @@ abstract class AbstractBuildForm {
$sipValue = $sip->queryStringToSip($queryString, RETURN_SIP);
$json[] = $this->getJsonElementUpdate(CLIENT_SIP, $sipValue, FE_MODE_SHOW);
$json[] = $this->getFormElementForJson(CLIENT_SIP, $sipValue, [FE_MODE => FE_MODE_SHOW]);
return $this->buildNativeHidden(CLIENT_SIP, $sipValue);
}
/**
* Create an array with standard elements and add 'form-element', 'value'.
* Create an array with standard elements for 'mode' (hidden, disabled, required) and add 'form-element', 'value'.
* 'Generic Element Update': add via API_ELEMENT_UPDATE 'label' and 'note'.
* All collected data as array - will be later converted to JSON.
*
* @param $htmlFormElementName
* @param string $htmlFormElementName
* @param string|array $value
* @param string $feMode disabled|readonly|''
* @param array $formElement
* @return array
*/
private function getJsonElementUpdate($htmlFormElementName, $value, $feMode) {
private function getFormElementForJson($htmlFormElementName, $value, array $formElement) {
$json = $this->getJsonFeMode($feMode);
$json = $this->getJsonFeMode($formElement[FE_MODE]);
$json['form-element'] = $htmlFormElementName;
$json['value'] = $value;
if (isset($formElement[FE_LABEL])) {
$key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_LABEL;
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_CONTENT] = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL]);
}
if (isset($formElement[FE_NOTE])) {
$key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_NOTE;
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_CONTENT] = $formElement[FE_NOTE];
}
return $json;
}
......@@ -629,6 +656,22 @@ abstract class AbstractBuildForm {
}
}
/**
* Builds a label, typically for an html-'<input>'-element.
*
* @param string $htmlFormElementName
* @param string $label
* @return string
*/
public function buildLabel($htmlFormElementName, $label) {
$attributes = Support::doAttribute('for', $htmlFormElementName);
$attributes .= Support::doAttribute('class', 'control-label');
$html = Support::wrapTag("<label $attributes>", $label);
return $html;
}
/**
* Takes the current SIP ('form' and additional parameter), set SIP_RECORD_ID=0 and create a new 'NewRecordUrl'.
*
......@@ -664,22 +707,6 @@ abstract class AbstractBuildForm {
abstract public function buildRowSubrecord(array $formElement, $elementHtml);
/**
* Builds a label, typically for an html-'<input>'-element.
*
* @param string $htmlFormElementName
* @param string $label
* @return string
*/
public function buildLabel($htmlFormElementName, $label) {
$attributes = Support::doAttribute('for', $htmlFormElementName);
$attributes .= Support::doAttribute('class', 'control-label');
$html = Support::wrapTag("<label $attributes>", $label);
return $html;
}
/**
* Builds HTML 'input' element.
* Format: <input name="$htmlFormElementName" <type="email|input|password|url" [autocomplete="autocomplete"] [autofocus="autofocus"]
......@@ -741,7 +768,7 @@ abstract class AbstractBuildForm {