Commit c2809cfb authored by Carsten  Rose's avatar Carsten Rose
Browse files

Sip: phpdoc

Constants, Store: added TYPO3_PAGE_TYPE to STORE_TYPO3
AbstractBuildForm: recode to use global $showDebugInfo. IMplemented deriveNewRecrdUrlFromExistingSip(). Added parameter $toolTip to createFormLink(). Rewrap Editlink
BuildFormBootstrap: recode buildButton().
QuickFormQuery: code to set session lifetime disabled: useless
parent 34fe48b5
......@@ -17,3 +17,6 @@ SHOW_DEBUG_INFO = auto
CSS_LINK_CLASS_INTERNAL = internal
CSS_LINK_CLASS_EXTERNAL = external
; QFQ with own Bootstrap: 'container'. QFQ already nested in Bootstrap of mainpage: <empty>
CSS_CLASS_MAIN_CONTAINER =
......@@ -36,6 +36,8 @@ abstract class AbstractBuildForm {
protected $pattern = array();
protected $wrap = array();
protected $symbol = array();
protected $showDebugInfo = false;
// protected $feDivClass = array(); // Wrap FormElements in <div class="$feDivClass[type]">
private $formId = null;
......@@ -54,6 +56,7 @@ abstract class AbstractBuildForm {
$this->store = Store::getInstance();
$this->db = new Database();
$this->evaluate = new Evaluate($this->store, $this->db);
$this->showDebugInfo = ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes');
// $sip = $this->store->getVar(CLIENT_SIP, STORE_CLIENT);
......@@ -183,7 +186,7 @@ abstract class AbstractBuildForm {
*/
public function createFormEditUrl() {
if ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) !== 'yes') {
if (!$this->showDebugInfo) {
return '';
}
......@@ -334,7 +337,7 @@ abstract class AbstractBuildForm {
$elementHtml = $this->$buildElementFunctionName($formElement, $htmlFormElementId, $value, $debugStack);
// debugStack as Tooltip
if ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes' && count($debugStack) > 0) {
if ($this->showDebugInfo && count($debugStack) > 0) {
$elementHtml = Support::appendTooltip($elementHtml, implode("\n", OnArray::htmlentitiesOnArray($debugStack)));
}
......@@ -354,6 +357,29 @@ abstract class AbstractBuildForm {
abstract public function doSubrecords();
/**
* Takes the current SIP ('form' and additional parameter), set SIP_RECORD_ID=0 and create a new 'NewRecordUrl'.
*
* @throws CodeException
* @throws \qfq\UserException
*/
public function deriveNewRecordUrlFromExistingSip(&$toolTipNew) {
$urlParam = $this->store->getStore(STORE_SIP);
$urlParam[SIP_RECORD_ID] = 0;
unset($urlParam[SIP_SIP]);
unset($urlParam[SIP_URLPARAM]);
$urlParam['id'] = $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3);
$urlParam['type'] = $this->store->getVar(TYPO3_PAGE_TYPE, STORE_TYPO3);
$sip = $this->store->getSipInstance();
$url = $sip->queryStringToSip(OnArray::toString($urlParam));
$toolTipNew .= "New" . PHP_EOL . PHP_EOL . OnArray::toString($urlParam, ' = ', PHP_EOL, "'");
return $url;
}
abstract public function buildRowNative($formElement, $elementHtml);
abstract public function buildRowPill($formElement, $elementHtml);
......@@ -983,9 +1009,7 @@ abstract class AbstractBuildForm {
$flagNew = false;
$flagEdit = false;
$flagDelete = false;
$toolTipDelete = '';
$linkNew = '';
$showDebugInfo = false;
$primaryRecord = $this->store->getStore(STORE_RECORD);
......@@ -994,10 +1018,8 @@ abstract class AbstractBuildForm {
}
if (isset($formElement[SUBRECORD_PARAMETER_FORM])) {
$showDebugInfo = $this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM);
$linkNew = Support::wrapTag('<th>', $this->createFormLink($formElement, 0, $primaryRecord, Support::wrapTag('<button type="button">', $this->symbol[SYMBOL_NEW]), 'New', $showDebugInfo));
$linkNew = Support::wrapTag('<th>', $this->createFormLink($formElement, 0, $primaryRecord, $this->symbol[SYMBOL_NEW], 'New'));
// Decode settings in subrecordOption
$flagNew = Support::findInSet(SUBRECORD_NEW, $formElement['subrecordOption']);
......@@ -1022,7 +1044,7 @@ abstract class AbstractBuildForm {
$rowHtml = '';
if ($flagEdit) {
$rowHtml .= Support::wrapTag('<td>', $this->createFormLink($formElement, $row[$nameColumnId], $primaryRecord, Support::wrapTag('<button type="button">', $this->symbol[SYMBOL_EDIT]), 'Edit', $showDebugInfo));
$rowHtml .= Support::wrapTag('<td>', $this->createFormLink($formElement, $row[$nameColumnId], $primaryRecord, $this->symbol[SYMBOL_EDIT], 'Edit'));
} elseif ($flagNew) {
$rowHtml .= Support::wrapTag('<td>', $rowHtml, false);
}
......@@ -1033,12 +1055,12 @@ abstract class AbstractBuildForm {
}
if ($flagDelete) {
// $rowHtml .= Support::wrapTag('<td>', $this->createDeleteLink($targetTableName, $row['id'], $this->symbol[SYMBOL_DELETE], 'Delete', $showDebugInfo));
// $this->createDeleteLink($targetTableName, $row['id'], $this->symbol[SYMBOL_DELETE], 'Delete', $showDebugInfo)
// $rowHtml .= Support::wrapTag('<td>', $this->createDeleteLink($targetTableName, $row['id'], $this->symbol[SYMBOL_DELETE], 'Delete', $this->showDebugInfo));
// $this->createDeleteLink($targetTableName, $row['id'], $this->symbol[SYMBOL_DELETE], 'Delete', $this->showDebugInfo)
// <button type="button" class="record-delete" data-sip={{SIP}}><span class="glyphicon glyphicon-trash"></span></button>
$s = $this->createDeleteUrl($targetTableName, $row['id'], RETURN_SIP);
$rowHtml .= Support::wrapTag('<td>', Support::wrapTag('<a>', Support::wrapTag("<button type='button' class='record-delete' data-sip='$s'>", '<span class="glyphicon glyphicon-trash"></span>')));
$rowHtml .= Support::wrapTag('<td>', Support::wrapTag("<button type='button' class='record-delete' data-sip='$s'>", '<span class="glyphicon glyphicon-trash"></span>'));
}
$html .= Support::wrapTag('<tr class="record">', $rowHtml, true);
......@@ -1102,7 +1124,7 @@ abstract class AbstractBuildForm {
* @return string
* @throws UserException
*/
private function createFormLink(array $formElement, $targetRecordId, array $record, $symbol, $toolTip, $showDebugInfo = false) {
private function createFormLink(array $formElement, $targetRecordId, array $record, $symbol, $toolTip) {
$queryStringArray = [
SIP_FORM => $formElement[SUBRECORD_PARAMETER_FORM],
......@@ -1125,7 +1147,7 @@ abstract class AbstractBuildForm {
}
}
if ($showDebugInfo)
if ($this->showDebugInfo)
$toolTip .= PHP_EOL . OnArray::toString($queryStringArray, ' = ', PHP_EOL, "'");
Support::appendTypo3ParameterToArray($queryStringArray);
......@@ -1140,7 +1162,7 @@ abstract class AbstractBuildForm {
$sip = $this->store->getSipInstance();
$url = $sip->queryStringToSip($queryString);
return Support::wrapTag('<a href="' . $url . '" title="' . $toolTip . '">', $symbol);
return Support::wrapTag('<a class="btn btn-default" href="' . $url . '" title="' . $toolTip . '">', $symbol);
}
/**
......@@ -1414,9 +1436,9 @@ abstract class AbstractBuildForm {
* @param $toolTip
* @return string
*/
private function createDeleteLink($table, $recordId, $symbol, $toolTip, $showDebugInfo = false) {
private function createDeleteLink($table, $recordId, $symbol, $toolTip) {
if ($showDebugInfo) {
if ($this->showDebugInfo) {
$toolTip .= PHP_EOL . "table = '$table'" . PHP_EOL . "id = '$recordId'";
}
......
......@@ -98,7 +98,6 @@ class BuildFormBootstrap extends AbstractBuildForm {
$title = Support::wrapTag('<div class="hidden-xs col-sm-6 col-md-8">', Support::wrapTag('<h3>', $this->formSpec['title']));
$button = Support::wrapTag('<div class="col-xs-12 col-sm-6 col-md-4">', $this->buildButtons());
// '<div class="row hidden-xs">
$html .= Support::wrapTag('<div class="row">', $title . $button);
......@@ -122,46 +121,51 @@ class BuildFormBootstrap extends AbstractBuildForm {
$toolTipDelete = 'Delete';
$buttonDelete = '';
$buttonNew = '';
if ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes') {
$toolTipNew .= PHP_EOL . "form = '" . $this->formSpec['name'] . "'" . PHP_EOL . "r = 0";
$toolTipDelete .= PHP_EOL . "table = '" . $this->formSpec['tableName'] . "'" . PHP_EOL . "r = '" . $this->store->getVar(SIP_RECORD_ID, STORE_SIP) . "'";
}
$sipParamString = OnArray::toString($this->store->getStore(STORE_SIP), ' = ', PHP_EOL, "'");
$formEditUrl = $this->createFormEditUrl();
$buttonDebug = <<<BUTTON
<div class="btn-group" role="group">
<button id="debug-button" type="button" class="btn btn-default navbar-btn" title="$sipParamString"><span class="glyphicon glyphicon-eye-open"></span></button>
<a href="$formEditUrl" id="form-edit-button" class="btn btn-default navbar-btn" title="Edit form"><span class="glyphicon glyphicon-wrench"></span></a>
</div>
$buttonDebug = '';
$recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP);
// Button: FormEdit
if ($this->showDebugInfo) {
$tooltipFormEdit = "Edit form" . PHP_EOL . PHP_EOL . OnArray::toString($this->store->getStore(STORE_SIP), ' = ', PHP_EOL, "'");
$urlFormEdit = $this->createFormEditUrl();
// Edit Form
$buttonDebug = <<<BUTTON
<div class="btn-group" role="group">
<a href="$urlFormEdit" id="form-edit-button" class="btn btn-default navbar-btn" title="$tooltipFormEdit"><span class="glyphicon glyphicon-wrench"></span></a>
</div>
BUTTON;
}
// Button: Delete
if (Support::findInSet(FORM_BUTTON_DELETE, $this->formSpec['showButton'])) {
if ($this->showDebugInfo && $recordId > 0) {
$toolTipDelete .= PHP_EOL . "table = '" . $this->formSpec['tableName'] . "'" . PHP_EOL . "r = '" . $recordId . "'";
}
$buttonDeleteDisabled = ($recordId > 0) ? '' : 'disabled';
$buttonDelete = <<<BUTTON
<div class="btn-group" role="group">
<button id="delete-button" type="button" class="btn btn-default navbar-btn" title="$toolTipDelete"><span class="glyphicon glyphicon-trash"></span></button>
</div>
<div class="btn-group" role="group">
<button id="delete-button" type="button" class="btn btn-default navbar-btn $buttonDeleteDisabled" title="$toolTipDelete"><span class="glyphicon glyphicon-trash"></span></button>
</div>
BUTTON;
}
// Button: New
if (Support::findInSet(FORM_BUTTON_NEW, $this->formSpec['showButton'])) {
$formNewUrl = $this->deriveNewRecordUrlFromExistingSip($toolTipNew);
$buttonNew = <<<BUTTON
<div class="btn-group" role="group">
<button id="delete-button" type="button" class="btn btn-default navbar-btn" title="$toolTipNew"><span class="glyphicon glyphicon-plus"></span></button>
</div>
<div class="btn-group" role="group">
<a href="$formNewUrl" id="form-new-button" class="btn btn-default navbar-btn" title="$toolTipNew"><span class="glyphicon glyphicon-plus"></span></a>
</div>
BUTTON;
}
$buttonFormEdit = ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes') ? $buttonDebug : '';
// <div class="btn-toolbar pull-right" role="toolbar">
$html = <<<BUTTON
<div class="btn-toolbar" role="toolbar">
$buttonFormEdit
$buttonDebug
<div class="btn-group" role="group">
<button id="save-button" type="button" class="btn btn-default navbar-btn" title="Save"><span class="glyphicon glyphicon-ok"></span></button>
<button id="close-button" type="button" class="btn btn-default navbar-btn" title="Close"><span class="glyphicon glyphicon-remove"></span></button>
......@@ -261,6 +265,7 @@ BUTTON;
public function tail() {
$html = '';
$html .= $this->buildNewSip();
$deleteUrl = '';
$formId = $this->getFormId();
......@@ -272,7 +277,9 @@ BUTTON;
$formId = $this->getFormId();
$tabId = $this->getTabId();
$deleteUrl = $this->createDeleteUrl($this->formSpec['tableName'], $this->store->getVar(SIP_RECORD_ID, STORE_SIP));
if (0 < ($recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP))) {
$deleteUrl = $this->createDeleteUrl($this->formSpec['tableName'], $recordId);
}
$html .= '</form>'; // <form class="form-horizontal" ...
$html .= <<<EOF
......
......@@ -198,6 +198,7 @@ const TYPO3_FE_USER_UID = 'feUserUid';
const TYPO3_FE_USER_GROUP = 'feUserGroup';
const TYPO3_TT_CONTENT_UID = 'ttcontentUid';
const TYPO3_PAGE_ID = 'typo3PageId';
const TYPO3_PAGE_TYPE = 'typo33PageType';
// System
const SYSTEM_DB_USER = 'DB_USER';
......
......@@ -104,8 +104,16 @@ class QuickFormQuery {
mb_internal_encoding("UTF-8");
ini_set('session.gc-maxlifetime', SESSION_LIFETIME_SECONDS);
ini_set('session.cookie_lifetime', SESSION_LIFETIME_SECONDS);
// session.cache_expire
// session.cookie_lifetime
// session.gc_maxlifetime
// $arr1['sessionname'] = session_name();
// $arr1['session.auto_start'] = ini_get('session.auto_start');
// $arr1['session.gc_maxlifetime'] = ini_get('session.gc_maxlifetime');
// $arr1['session.cookie_lifetime'] = ini_get('session.cookie_lifetime');
// $arr1['session.name'] = ini_get('session.name');
// Refresh the session even if no new data saved.
$_SESSION['LAST_ACTIVITY'] = time();
......
......@@ -44,6 +44,8 @@ class Sip {
$_SESSION = null;
@session_start();
} else {
// session_name($sessionname);
session_start();
}
......@@ -115,14 +117,15 @@ class Sip {
}
/**
* @param $param
* @param $script
* Splits the $paramArray in &$clientArray and &$sipArray. $sipArray contains all key/values pairs wich are not belong to Typo3.
*
* @param array $paramArray
* @param array $clientArray
* @param array $sipArray
* @throws CodeException
* @throws UserException
* @return string
* @throws \qfq\CodeException
*/
private function splitParamClientSip($paramArray, array &$clientArray, array &$sipArray) {
private function splitParamClientSip(array $paramArray, array &$clientArray, array &$sipArray) {
$script = '';
......@@ -189,6 +192,8 @@ class Sip {
}
/**
* Returns a new uniqid, which will be used as a SIP identifier
*
* @param bool|false $staticUniqId
* @return bool|string
*/
......
......@@ -240,6 +240,9 @@ class Store {
if (isset($GLOBALS["TSFE"]->id))
$arr[TYPO3_PAGE_ID] = $GLOBALS["TSFE"]->id;
if (isset($GLOBALS["TSFE"]->type))
$arr[TYPO3_PAGE_TYPE] = $GLOBALS["TSFE"]->type;
self::setVarArray($arr, STORE_TYPO3, true);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment