', $element);
}
/**
* Creates a button to open 'CopyForm' with the current form as source.
*
* @return string - the rendered button
*/
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');
}
/**
* Creates a link to open current form loaded in FormEditor
*
* @return string - the rendered Checkbox
*/
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 {
$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
*/
private function buildButtons() {
$buttonNew = '';
$buttonDelete = '';
$buttonClose = '';
$buttonSave = '';
$buttonEditForm = '';
$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]);
$buttonEditForm = $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];
// In debugMode every button link should show the information behind the SIP.
if ($this->showDebugInfoFlag) {
$toolTip .= PHP_EOL . "table = '" . $this->formSpec[F_TABLE_NAME] . "'" . PHP_EOL . "r = '" . $recordId . "'";
}
$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
// Specified in reverse order cause 'pull-right' inverts the order. http://getbootstrap.com/css/#helper-classes-floats
$html = '';
$html .= Support::wrapTag('
', $buttonNew);
$html .= Support::wrapTag('
', $buttonDelete);
$html .= Support::wrapTag('
', $buttonSave . $buttonClose);
$html .= Support::wrapTag('
', $buttonEditForm);
$html = Support::wrapTag('