Commit 17380c53 authored by bbaer's avatar bbaer
Browse files

Merge remote-tracking branch 'origin/dragAndDrop' into dragAndDrop

parents 3d2cab6c 1520a031
......@@ -2048,7 +2048,7 @@ The CLIENT `submit_reason` shows the user action:
Example forwardPage
^^^^^^^^^^^^^^^^^^^
* `{{SELECT IF('{{formModeGlobal:S:anumx}}'='requiredOff', 'no', 'client') }}`
* `{{SELECT IF('{{formModeGlobal:S:alnumx}}'='requiredOff', 'no', 'client') }}`
* `{{SELECT IF('{{submit_reason:CE:alnumx}}'='save', 'no', 'url'), '|http://example.com' }}`
Type: combined dynamic mode & URL/page
......@@ -2124,7 +2124,8 @@ Parameter
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
| submitButtonText | string | Show a save button at the bottom of the form, with <submitButtonText> . See `submitButtonText`_. |
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
| saveButtonActive | - | Make the 'save'-button active on *Form* load (instead of waiting for the first user change). |
| saveButtonActive | - | 0: off, 1: Make the 'save'-button active on *Form* load (instead of waiting for the first user change). |
| | | The save button is still 'gray' (record not dirty), but the user can click 'save'. |
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
| saveButtonText | string | Overwrite default from configuration_ |
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
......
......@@ -79,13 +79,14 @@ try {
$answer = $qfq->delete();
// in case everything is fine, an empty string is returned. Else an Array.
$flagSuccess = ($answer == '');
$flagSuccess = ($answer === '');
$targetUrl = Store::getVar(SIP_TARGET_URL, STORE_SIP);
$modeAnswer = Store::getVar(SIP_MODE_ANSWER, STORE_SIP);
switch ($modeAnswer) {
case MODE_JSON:
$answer = array();
if ($flagSuccess) {
$answer[API_MESSAGE] = 'Deleted';
$answer[API_REDIRECT] = API_ANSWER_REDIRECT_CLIENT;
......
<?php
/**
* Created by PhpStorm.
* User: ep
* Date: 12/23/15
* Time: 6:17 PM
*/
namespace qfq;
use qfq;
require_once(__DIR__ . '/../qfq/store/Store.php');
require_once(__DIR__ . '/../qfq/Constants.php');
require_once(__DIR__ . '/../qfq/QuickFormQuery.php');
/**
* Return JSON encoded answer
*
* status: success|error
* message: <message>
* redirect: client|url|no
* redirect-url: <url>
* field-name: <field name>
* field-message: <message>
* form-data: [ fieldname1 => value1, fieldname2 => value2, ... ]
* form-control: [ fieldname1 => status1, fieldname2 => status2, ... ] status: show|hide, enabled|disabled,
* readonly|readwrite
*
* Description:
*
* Save successful. Button 'close', 'new'. Form.forward: 'auto'. Client logic decide to redirect or not. Show message
* if no redirect. status = 'success' message = <message> redirect = 'client'
*
* Save successful. Button 'close': Form.forward: 'page'. Client redirect to url.
* status = 'success'
* message = <message>
* redirect = 'url'
* redirect-url = <URL>
*
* Save failed: Button: any. Show message and set 'alert' on _optional_ specified form element. Bring 'pill' of
* specified form element to front. status = 'error' message = <message> redirect = 'no' Optional: field-name = <field
* name> field-message = <message appearing as tooltip (or similar) near the form element>
*/
$answer = array();
$answer[API_REDIRECT] = API_ANSWER_REDIRECT_NO;
$answer[API_STATUS] = API_ANSWER_STATUS_ERROR;
$answer[API_MESSAGE] = '';
try {
$qfq = new QuickFormQuery(['bodytext' => '']);
$data = $qfq->dragAndDrop();
// $answer[API_REDIRECT] = $qfq->getForwardMode($answer[API_REDIRECT_URL]);
$answer[API_STATUS] = API_ANSWER_STATUS_SUCCESS;
$answer[API_MESSAGE] = 'load: success';
$answer[API_FORM_UPDATE] = $data[API_FORM_UPDATE];
$answer[API_ELEMENT_UPDATE] = $data[API_ELEMENT_UPDATE];
// unset($answer[API_FORM_UPDATE][API_ELEMENT_UPDATE]);
} catch (qfq\UserFormException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
$val = Store::getVar(SYSTEM_FORM_ELEMENT, STORE_SYSTEM);
if ($val !== false)
$answer[API_FIELD_NAME] = $val;
$val = Store::getVar(SYSTEM_FORM_ELEMENT_MESSAGE, STORE_SYSTEM);
if ($val !== false)
$answer[API_FIELD_MESSAGE] = $val;
} catch (qfq\CodeException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
} catch (qfq\DbException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
} catch (\Exception $e) {
$answer[API_MESSAGE] = "Generic Exception: " . $e->getMessage();
}
header("Content-Type: application/json");
echo json_encode($answer);
......@@ -86,8 +86,6 @@ abstract class AbstractBuildForm {
* @param array $feSpecAction
* @param array $feSpecNative
* @param array $db
* @throws CodeException
* @throws UserFormException
*/
public function __construct(array $formSpec, array $feSpecAction, array $feSpecNative, array $db = null) {
$this->formSpec = $formSpec;
......@@ -174,8 +172,6 @@ abstract class AbstractBuildForm {
* @param array $latestFeSpecNative
* @return array|string $mode=LOAD_FORM: The whole form as HTML, $mode=FORM_UPDATE: array of all
* formElement.dynamicUpdate-yes values/states
* @throws CodeException
* @throws DbException
* @throws UserFormException
*/
public function process($mode, $htmlElementNameIdZero = false, $latestFeSpecNative = array()) {
......@@ -251,9 +247,6 @@ abstract class AbstractBuildForm {
*
* @param string $mode
* @return string
* @throws CodeException
* @throws DbException
* @throws UserFormException
*/
public function head($mode = FORM_LOAD) {
$html = '';
......@@ -283,8 +276,6 @@ abstract class AbstractBuildForm {
*
* @return string String: <a href="?pageId&sip=....">Edit</a> <small>[sip:..., r:..., urlparam:...,
* ...]</small>
* @throws CodeException
* @throws UserFormException
*/
public function createFormEditorUrl($form, $recordId, array $param = array()) {
......@@ -330,8 +321,6 @@ abstract class AbstractBuildForm {
* Returns '<form ...>'-tag with various attributes.
*
* @return string
* @throws CodeException
* @throws DbException
*/
public function getFormTag() {
$md5 = '';
......@@ -349,8 +338,6 @@ abstract class AbstractBuildForm {
* Build MD5 from the current record. Return HTML Input element.
*
* @return string
* @throws \qfq\CodeException
* @throws \qfq\DbException
*/
public function buildInputRecordHashMd5() {
......@@ -370,8 +357,6 @@ abstract class AbstractBuildForm {
* @param $recordId
*
* @return string
* @throws \qfq\CodeException
* @throws \qfq\DbException
*/
public function buildRecordHashMd5($tableName, $recordId) {
$record = array();
......@@ -387,7 +372,6 @@ abstract class AbstractBuildForm {
* Create HTML Input vars to detect bot automatic filling of forms.
*
* @return string
* @throws CodeException
*/
public function getHoneypotVars() {
$html = '';
......@@ -412,8 +396,6 @@ abstract class AbstractBuildForm {
* Build an assoc array with standard form attributes.
*
* @return array
* @throws CodeException
* @throws DbException
*/
public function getFormTagAttributes() {
......@@ -460,8 +442,6 @@ abstract class AbstractBuildForm {
* See: https://www.w3.org/wiki/HTML/Elements/form#HTML_Attributes
*
* @return string
* @throws CodeException
* @throws DbException
*/
public function getEncType() {
......@@ -477,8 +457,6 @@ abstract class AbstractBuildForm {
* @param array|string $value
*
* @return array|string
* @throws CodeException
* @throws UserFormException
*/
private function processReportSyntax($value) {
......@@ -524,9 +502,6 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return string
* @throws CodeException
* @throws DbException
* @throws \qfq\UserFormException
*/
public function elements($recordId, $filter = FORM_ELEMENTS_NATIVE, $feIdContainer = 0, array &$json,
$modeCollectFe = FLAG_DYNAMIC_UPDATE, $htmlElementNameIdZero = false,
......@@ -697,8 +672,6 @@ abstract class AbstractBuildForm {
* @param array $formElement
*
* @return array
* @throws CodeException
* @throws UserFormException
*/
private function prepareFillStoreFireLdap(array $formElement) {
......@@ -793,8 +766,7 @@ abstract class AbstractBuildForm {
* Copy a subset of current STORE_TYPO3 variables to SIP. Set a hidden form field to submit the assigned SIP to
* save/update.
*
* @throws CodeException
* @throws UserFormException
* @return string
*/
private function prepareT3VarsForSave() {
......@@ -830,8 +802,6 @@ abstract class AbstractBuildForm {
* Get all elements from STORE_ADDITIONAL_FORM_ELEMENTS and return them as a string.
*
* @return string
* @throws CodeException
* @throws \qfq\UserFormException
*/
private function buildAdditionalFormElements() {
......@@ -846,8 +816,6 @@ abstract class AbstractBuildForm {
* @param array $json
*
* @return string <input type='hidden' name='s' value='<sip>'>
* @throws CodeException
* @throws \qfq\UserFormException
*/
public function buildHiddenSip(array &$json) {
......@@ -878,8 +846,6 @@ abstract class AbstractBuildForm {
* @param array $formElement
*
* @return array
* @throws CodeException
* @throws UserFormException
*/
private function getFormElementForJson($htmlFormElementName, $value, array $formElement) {
......@@ -955,7 +921,6 @@ abstract class AbstractBuildForm {
* @param array $feMode
*
* @return array
* @throws UserFormException
*/
private function getJsonFeMode($feMode) {
......@@ -1005,7 +970,6 @@ abstract class AbstractBuildForm {
* @param string $addClass
*
* @return string
* @throws CodeException
*/
public function buildLabel($htmlFormElementName, $label, $addClass = '') {
$attributes = Support::doAttribute('for', $htmlFormElementName);
......@@ -1021,8 +985,6 @@ abstract class AbstractBuildForm {
*
* @param $toolTipNew
* @return string
* @throws CodeException
* @throws UserFormException
*/
public function deriveNewRecordUrlFromExistingSip(&$toolTipNew) {
......@@ -1086,8 +1048,6 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return string complete rendered HTML input element.
* @throws CodeException
* @throws UserFormException
*/
public function buildInput(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$textarea = '';
......@@ -1232,7 +1192,6 @@ abstract class AbstractBuildForm {
* @param array $formElement
*
* @return string
* @throws CodeException
* @throws UserFormException
*/
private function typeAheadBuildParam(array &$formElement) {
......@@ -1338,7 +1297,6 @@ abstract class AbstractBuildForm {
* @param bool $flagOmitEmpty
*
* @return string
* @throws CodeException
*/
private function getAttributeList(array $formElement, array $attributeList, $flagOmitEmpty = true) {
$attribute = '';
......@@ -1357,7 +1315,6 @@ abstract class AbstractBuildForm {
*
* @param bool $cssDisable
* @return string
* @throws CodeException
* @throws UserFormException
*/
private function getAttributeFeMode($feMode, $cssDisable = true) {
......@@ -1414,8 +1371,7 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE*
*
* @return string
* @throws CodeException
* @throws \qfq\UserFormException
* @throws UserFormException
*/
public function buildCheckbox(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$itemKey = array();
......@@ -1470,8 +1426,7 @@ abstract class AbstractBuildForm {
* @param array $itemKey
* @param array $itemValue
*
* @throws CodeException
* @throws \qfq\UserFormException
* @throws UserFormException
*/
public function getKeyValueListFromSqlEnumSpec(array $formElement, array &$itemKey, array &$itemValue) {
$fieldType = '';
......@@ -1543,7 +1498,6 @@ abstract class AbstractBuildForm {
* @param string $fieldType
*
* @return array
* @throws CodeException
* @throws UserFormException
*/
private function getItemsForEnumOrSet($column, &$fieldType) {
......@@ -1589,7 +1543,6 @@ abstract class AbstractBuildForm {
* @param array $itemKey
* @param array $formElement
*
* @throws CodeException
* @throws UserFormException
*/
private function prepareCheckboxCheckedUncheckedValue(array $itemKey, array &$formElement) {
......@@ -1630,8 +1583,6 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return string
* @throws CodeException
* @throws UserFormException
*/
public function buildCheckboxSingle(array $formElement, $htmlFormElementName, $attribute, $value, array &$json, $mode = FORM_LOAD) {
......@@ -1665,8 +1616,6 @@ abstract class AbstractBuildForm {
* @param array $json
*
* @return string
* @throws CodeException
* @throws UserFormException
*/
public function constructCheckboxSingleButton(array $formElement, $htmlFormElementName, $attribute, $value, array &$json) {
$html = '';
......@@ -1725,8 +1674,6 @@ abstract class AbstractBuildForm {
* @param array $json
*
* @return string
* @throws CodeException
* @throws UserFormException
*/
public function constructCheckboxSinglePlain(array $formElement, $htmlFormElementName, $attribute, $value, array &$json) {
$html = '';
......@@ -1775,8 +1722,6 @@ abstract class AbstractBuildForm {
* @param array $itemValue
* @param array $json
* @return string
* @throws CodeException
* @throws UserFormException
*/
public function buildCheckboxMulti(array $formElement, $htmlFormElementName, $attributeBase, $value, array $itemKey, array $itemValue, array &$json) {
......@@ -1797,8 +1742,6 @@ abstract class AbstractBuildForm {
* @param string $htmlFormElementName
* @param string $htmlHidden
*
* @throws CodeException
* @throws UserFormException
*/
private function fillStoreAdditionalFormElementsCheckboxHidden(array $formElement, $htmlFormElementName, $htmlHidden) {
......@@ -1828,8 +1771,6 @@ abstract class AbstractBuildForm {
* @param array $json
*
* @return string
* @throws CodeException
* @throws UserFormException
*/
public function constructCheckboxMultiButton(array $formElement, $htmlFormElementName, $attributeBase, $value, array $itemKey, array $itemValue, array &$json) {
$json = array();
......@@ -1901,8 +1842,6 @@ abstract class AbstractBuildForm {
* @param array $json
*
* @return string
* @throws CodeException
* @throws UserFormException
*/
public function constructCheckboxMultiPlain(array $formElement, $htmlFormElementName, $attributeBase, $value, array $itemKey, array $itemValue, array &$json) {
$json = array();
......@@ -1991,14 +1930,14 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return string
* @throws CodeException
* @throws \qfq\UserFormException
*/
public function buildExtra(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
if ($mode === FORM_LOAD) {
$this->store->setVar($formElement[FE_NAME], $value, STORE_SIP, false);
}
return;
}
/**
......@@ -2015,8 +1954,6 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return string
* @throws CodeException
* @throws \qfq\UserFormException
*/
public function buildRadio(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
......@@ -2063,8 +2000,6 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return string
* @throws CodeException
* @throws \qfq\UserFormException
*/
private function constructRadioButton(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$itemKey = array();
......@@ -2146,8 +2081,6 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return string
* @throws CodeException
* @throws \qfq\UserFormException
*/
private function constructRadioPlain(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$attributeBase = '';
......@@ -2236,8 +2169,6 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return mixed
* @throws CodeException
* @throws \qfq\UserFormException
*/
public function buildSelect(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$itemKey = array();
......@@ -2311,7 +2242,6 @@ abstract class AbstractBuildForm {
* @param array $control Array with <th> column names / format.
*
* @return string
* @throws UserFormException
*/
private function subrecordHead($linkNew, $flagDelete, array $firstRow, array &$control) {
......@@ -2344,8 +2274,6 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return string
* @throws CodeException
* @throws \qfq\UserFormException
*/
public function buildSubrecord(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$rcText = false;
......@@ -2503,8 +2431,6 @@ abstract class AbstractBuildForm {
* @param $toolTip
* @param array $currentRow
* @return string
* @throws CodeException
* @throws UserFormException
*/
private function createFormLink(array $formElement, $targetRecordId, array $record, $symbol, $toolTip, $currentRow = array()) {
......@@ -2572,8 +2498,6 @@ abstract class AbstractBuildForm {
* @param string $formName
*
* @return string tableName for $formName
* @throws CodeException
* @throws DbException
*/
private function getFormTable($formName) {
$row = $this->dbArray[$this->dbIndexQfq]->sql("SELECT " . F_TABLE_NAME . " FROM Form AS f WHERE f.name = ?", ROW_EXPECT_0_1, [$formName]);
......@@ -2604,7 +2528,6 @@ abstract class AbstractBuildForm {
* @param array $titleRaw
*
* @return array
* @throws UserFormException
*/
private function getSubrecordColumnControl(array $titleRaw) {
$control = array();
......@@ -2682,9 +2605,6 @@ abstract class AbstractBuildForm {
* @param string $columnValue
*
* @return string
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
private function renderCell(array $control, $columnName, $columnValue) {
$link = null;
......@@ -2747,8 +2667,6 @@ abstract class AbstractBuildForm {
* parameters.
*
* @return string String: "API_DIR/delete.php?sip=...."
* @throws CodeException
* @throws UserFormException
*/
public function createDeleteUrl($formName, $recordId, $mode = RETURN_URL) {
......@@ -2776,10 +2694,7 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return string
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public function buildFile(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$attribute = '';
......@@ -2896,8 +2811,7 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return string
* @throws CodeException
* @throws \qfq\UserFormException
* @throws UserFormException
*/
public function buildAnnotate(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
......@@ -2949,8 +2863,7 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return string
* @throws CodeException
* @throws \qfq\UserFormException
* @throws UserFormException
*/
public function buildImageCut(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
......@@ -3017,8 +2930,6 @@ abstract class AbstractBuildForm {
/**
* @param string $pathFileName
* @return string SIP encoded URL
* @throws CodeException
* @throws UserFormException
*/
private function fileToSipUrl($pathFileName) {
$param[DOWNLOAD_MODE] = DOWNLOAD_MODE_FILE;
......@@ -3042,7 +2953,6 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return string
* @throws CodeException
* @throws UserFormException
*/
public function buildDateTime(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
......@@ -3155,8 +3065,6 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return string
* @throws CodeException
* @throws UserFormException
*/
public function buildDateJQW(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$arrMinMax = null;
......@@ -3239,8 +3147,6 @@ abstract class AbstractBuildForm {
* @param string $mode
*
* @return string
* @throws CodeException
* @throws UserFormException
*/
public function buildEditor(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$attribute = '';
......@@ -3391,8 +3297,6 @@ abstract class AbstractBuildForm {
*
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @return mixed
* @throws CodeException
* @throws UserFormException
*/
public function buildNote(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
......@@ -3427,9 +3331,6 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return mixed
* @throws CodeException
* @throws DbException
* @throws UserFormException
*/
public function buildFieldset(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$attribute = '';
......@@ -3496,9 +3397,6 @@ abstract class AbstractBuildForm {
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
*
* @return mixed
* @throws CodeException
* @throws DbException
* @throws UserFormException
*/
public function buildTemplateGroup(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$attribute = '';
......@@ -3611,9 +3509,6 @@ EOT;
* @param array $json
*
* @return string
* @throws CodeException
* @throws DbException
* @throws UserFormException
*/
private function templateGroupCollectFilledElements($max, $htmlDelete, array &$json) {
......@@ -3696,7 +3591,6 @@ EOT;
* Additional the maximum count of all select rows will be determined and returned.
*
* @return int max number of records in FormElement[FE_VALUE] over all FormElements.
* @throws UserFormException
*/
private function templateGroupDoValue() {
......