', $element);
}
/**
* Creates a button to open 'CopyForm' with the current form as source.
*
* @return string - the rendered button
* @throws \CodeException
* @throws \UserFormException
*/
private function buildButtonCopyForm() {
// Show copy icon only on form 'form' and only if there is a form loaded (id>0)
if ($this->formSpec[COLUMN_ID] != 1) {
return '';
}
// current loaded form.
$formId = $this->store->getVar(COLUMN_ID, STORE_RECORD . STORE_ZERO);
$queryStringArray = [
'id' => $this->store->getVar(SYSTEM_EDIT_FORM_PAGE, STORE_SYSTEM),
'form' => 'copyForm',
'r' => 0,
'idSrc' => $formId,
];
$queryString = Support::arrayToQueryString($queryStringArray);
$sip = $this->store->getSipInstance();
$url = $sip->queryStringToSip($queryString);
$toolTip = "Duplicate form" . PHP_EOL . PHP_EOL . OnArray::toString($queryStringArray, ' = ', PHP_EOL, "'");
$status = ($formId == 0) ? 'disabled' : '';
return $this->buildButtonAnchor($url, 'form-view-' . $this->formSpec[F_ID], '', $toolTip, GLYPH_ICON_DUPLICATE, $status, 'btn btn-default navbar-btn');
}
/**
* Builds a button to open the formLog. The formLog appears on the same page as the form, but the form is not rendered and the log is shown.
*
* @return string
* @throws \CodeException
* @throws \UserFormException
* @throws \UserReportException
*/
private function buildLogForm() {
$pageAlias = $this->store::getVar(TYPO3_PAGE_ALIAS, STORE_TYPO3);
$baseUrl = 'p:' . $pageAlias . '&form=' . $this->formSpec[F_NAME];
$baseMisc = '|b|G:glyphicon-bell|s|c:btn btn-default navbar-btn';
$baseTooltip = '|o:Set form in debugmode and show actions from ';
$stateAll = ($this->formSpec[FORM_LOG_FILE_ALL] == '') ? '' : ' btn-warning';
$stateSession = ($this->formSpec[FORM_LOG_FILE_SESSION] == '') ? '' : ' btn-warning';
$formLogAll = $this->link->renderLink($baseUrl . "&" . FORM_LOG_MODE . "=" . FORM_LOG_ALL . $baseMisc . $stateAll . $baseTooltip . 'all user');
$formLogSession = $this->link->renderLink($baseUrl . "&" . FORM_LOG_MODE . "=" . FORM_LOG_SESSION . $baseMisc . $stateSession . $baseTooltip . 'current user');
return $formLogAll . $formLogSession;
}
/**
* Creates a link to open current form loaded in FormEditor
*
* @return string - the rendered Checkbox
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
*/
private function buildViewForm() {
$form = false;
$url = '';
$status = '';
switch ($this->formSpec[F_NAME]) {
case 'form':
$form = $this->store->getVar(F_NAME, STORE_RECORD);
break;
case 'formElement':
if (false !== ($formId = $this->store->getVar(FE_FORM_ID, STORE_SIP . STORE_RECORD))) {
$row = $this->dbArray[$this->dbIndexQfq]->sql("SELECT `f`.`name` FROM `Form` AS f WHERE `id`=" . $formId, ROW_EXPECT_1);
$form = current($row);
}
break;
default:
return '';
}
if ($form === false) {
$toolTip = "Form not 'form' or 'formElement'";
$status = 'disabled';
} else {
$requiredNew = $this->store->getVar(F_REQUIRED_PARAMETER_NEW, STORE_RECORD . STORE_EMPTY);
if (trim($requiredNew) !== '') {
$toolTip = "Form has 'required new' parameters and therefore cannot be previewed.";
$status = 'disabled';
} else {
$queryStringArray = [
'id' => $this->store->getVar(SYSTEM_EDIT_FORM_PAGE, STORE_SYSTEM),
'form' => $form,
'r' => 0,
];
$queryString = Support::arrayToQueryString($queryStringArray);
$sip = $this->store->getSipInstance();
$url = $sip->queryStringToSip($queryString);
$toolTip = "View current form with r=0" . PHP_EOL . PHP_EOL . OnArray::toString($queryStringArray, ' = ', PHP_EOL, "'");
}
}
return $this->buildButtonAnchor($url, 'form-view-' . $this->formSpec[F_ID], '', $toolTip, GLYPH_ICON_VIEW, $status, 'btn btn-default navbar-btn');
}
/**
* Build Buttons panel on top right corner of form.
* Simulate Submit Button: http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml
*
* @return string
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
* @throws \UserReportException
*/
private function buildButtons() {
$buttonNew = '';
$buttonDelete = '';
$buttonClose = '';
$buttonSave = '';
$buttonDebugForm = '';
$recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP);
// Button: FormEdit
if ($this->showDebugInfoFlag) {
$toolTip = "Edit form" . PHP_EOL . PHP_EOL . OnArray::toString($this->store->getStore(STORE_SIP), ' = ', PHP_EOL, "'");
$url = $this->createFormEditorUrl(FORM_NAME_FORM, $this->formSpec[F_ID]);
$buttonDebugForm = $this->buildLogForm() .
$this->buildViewForm() .
$this->buildShowEditFormElementCheckbox() .
$this->buildButtonCopyForm() .
$this->buildButtonAnchor($url, 'form-edit-button', '', $toolTip, GLYPH_ICON_TOOL, '', 'btn btn-default navbar-btn');
}
// Button: Save
if (Support::findInSet(FORM_BUTTON_SAVE, $this->formSpec[F_SHOW_BUTTON]) && $this->formSpec[F_SUBMIT_BUTTON_TEXT] === '') {
$toolTip = $this->formSpec[F_SAVE_BUTTON_TOOLTIP];
if ($toolTip == 'Save') {
if ($recordId == 0) {
$toolTip .= PHP_EOL . 'Create new record';
} else {
$toolTip .= PHP_EOL . 'Record id: ' . $recordId;
$toolTip .= PHP_EOL . 'Created: ' . $this->store->getVar('created', STORE_RECORD . STORE_EMPTY);;
$toolTip .= PHP_EOL . 'Modified: ' . $this->store->getVar('modified', STORE_RECORD . STORE_EMPTY);;
}
}
// In debugMode every button link should show the information behind the SIP.
if ($this->showDebugInfoFlag) {
$toolTip .= PHP_EOL . "Table: " . $this->formSpec[F_TABLE_NAME];
}
$buttonSave = $this->buildButtonCode('save-button', $this->formSpec[F_SAVE_BUTTON_TEXT], $toolTip,
$this->formSpec[F_SAVE_BUTTON_GLYPH_ICON], '', $this->formSpec[F_BUTTON_ON_CHANGE_CLASS], $this->formSpec[F_SAVE_BUTTON_CLASS]);
}
// Button: Close
if (Support::findInSet(FORM_BUTTON_CLOSE, $this->formSpec[F_SHOW_BUTTON])) {
$buttonClose = $this->buildButtonCode('close-button', $this->formSpec[F_CLOSE_BUTTON_TEXT],
$this->formSpec[F_CLOSE_BUTTON_TOOLTIP],
$this->formSpec[F_CLOSE_BUTTON_GLYPH_ICON], '', '', $this->formSpec[F_CLOSE_BUTTON_CLASS]);
}
// Button: Delete
if (Support::findInSet(FORM_BUTTON_DELETE, $this->formSpec[F_SHOW_BUTTON])) {
$toolTip = $this->formSpec[F_DELETE_BUTTON_TOOLTIP];
if ($this->showDebugInfoFlag && $recordId > 0) {
$toolTip .= PHP_EOL . "form = '" . $this->formSpec[F_FINAL_DELETE_FORM] . "'" . PHP_EOL . "r = '" . $recordId . "'";
}
$disabled = ($recordId > 0) ? '' : 'disabled';
$buttonDelete = $this->buildButtonCode('delete-button', $this->formSpec[F_DELETE_BUTTON_TEXT], $toolTip,
$this->formSpec[F_DELETE_BUTTON_GLYPH_ICON], $disabled, '', $this->formSpec[F_DELETE_BUTTON_CLASS]);
}
// Button: New
if (Support::findInSet(FORM_BUTTON_NEW, $this->formSpec[F_SHOW_BUTTON])) {
$url = $this->deriveNewRecordUrlFromExistingSip($toolTip);
$buttonNew = $this->buildButtonAnchor($url, 'form-new-button', $this->formSpec[F_NEW_BUTTON_TEXT],
$this->formSpec[F_NEW_BUTTON_TOOLTIP], $this->formSpec[F_NEW_BUTTON_GLYPH_ICON], '', $this->formSpec[F_NEW_BUTTON_CLASS]);
}
// Arrangement: Edit Form / Save / Close / Delete / New
$html = '';
$html .= Support::wrapTag('
', $buttonDebugForm, true);
$html .= Support::wrapTag('
', $buttonSave . $buttonClose, true);
$html .= Support::wrapTag('
', $buttonDelete, true);
$html .= Support::wrapTag('
', $buttonNew, true);
$html = Support::wrapTag('