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 ...@@ -17,3 +17,6 @@ SHOW_DEBUG_INFO = auto
CSS_LINK_CLASS_INTERNAL = internal CSS_LINK_CLASS_INTERNAL = internal
CSS_LINK_CLASS_EXTERNAL = external 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 { ...@@ -36,6 +36,8 @@ abstract class AbstractBuildForm {
protected $pattern = array(); protected $pattern = array();
protected $wrap = array(); protected $wrap = array();
protected $symbol = array(); protected $symbol = array();
protected $showDebugInfo = false;
// protected $feDivClass = array(); // Wrap FormElements in <div class="$feDivClass[type]"> // protected $feDivClass = array(); // Wrap FormElements in <div class="$feDivClass[type]">
private $formId = null; private $formId = null;
...@@ -54,6 +56,7 @@ abstract class AbstractBuildForm { ...@@ -54,6 +56,7 @@ abstract class AbstractBuildForm {
$this->store = Store::getInstance(); $this->store = Store::getInstance();
$this->db = new Database(); $this->db = new Database();
$this->evaluate = new Evaluate($this->store, $this->db); $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); // $sip = $this->store->getVar(CLIENT_SIP, STORE_CLIENT);
...@@ -183,7 +186,7 @@ abstract class AbstractBuildForm { ...@@ -183,7 +186,7 @@ abstract class AbstractBuildForm {
*/ */
public function createFormEditUrl() { public function createFormEditUrl() {
if ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) !== 'yes') { if (!$this->showDebugInfo) {
return ''; return '';
} }
...@@ -334,7 +337,7 @@ abstract class AbstractBuildForm { ...@@ -334,7 +337,7 @@ abstract class AbstractBuildForm {
$elementHtml = $this->$buildElementFunctionName($formElement, $htmlFormElementId, $value, $debugStack); $elementHtml = $this->$buildElementFunctionName($formElement, $htmlFormElementId, $value, $debugStack);
// debugStack as Tooltip // 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))); $elementHtml = Support::appendTooltip($elementHtml, implode("\n", OnArray::htmlentitiesOnArray($debugStack)));
} }
...@@ -354,6 +357,29 @@ abstract class AbstractBuildForm { ...@@ -354,6 +357,29 @@ abstract class AbstractBuildForm {
abstract public function doSubrecords(); 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 buildRowNative($formElement, $elementHtml);
abstract public function buildRowPill($formElement, $elementHtml); abstract public function buildRowPill($formElement, $elementHtml);
...@@ -983,9 +1009,7 @@ abstract class AbstractBuildForm { ...@@ -983,9 +1009,7 @@ abstract class AbstractBuildForm {
$flagNew = false; $flagNew = false;
$flagEdit = false; $flagEdit = false;
$flagDelete = false; $flagDelete = false;
$toolTipDelete = '';
$linkNew = ''; $linkNew = '';
$showDebugInfo = false;
$primaryRecord = $this->store->getStore(STORE_RECORD); $primaryRecord = $this->store->getStore(STORE_RECORD);
...@@ -994,10 +1018,8 @@ abstract class AbstractBuildForm { ...@@ -994,10 +1018,8 @@ abstract class AbstractBuildForm {
} }
if (isset($formElement[SUBRECORD_PARAMETER_FORM])) { 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, $this->symbol[SYMBOL_NEW], 'New'));
$linkNew = Support::wrapTag('<th>', $this->createFormLink($formElement, 0, $primaryRecord, Support::wrapTag('<button type="button">', $this->symbol[SYMBOL_NEW]), 'New', $showDebugInfo));
// Decode settings in subrecordOption // Decode settings in subrecordOption
$flagNew = Support::findInSet(SUBRECORD_NEW, $formElement['subrecordOption']); $flagNew = Support::findInSet(SUBRECORD_NEW, $formElement['subrecordOption']);
...@@ -1022,7 +1044,7 @@ abstract class AbstractBuildForm { ...@@ -1022,7 +1044,7 @@ abstract class AbstractBuildForm {
$rowHtml = ''; $rowHtml = '';
if ($flagEdit) { 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) { } elseif ($flagNew) {
$rowHtml .= Support::wrapTag('<td>', $rowHtml, false); $rowHtml .= Support::wrapTag('<td>', $rowHtml, false);
} }
...@@ -1033,12 +1055,12 @@ abstract class AbstractBuildForm { ...@@ -1033,12 +1055,12 @@ abstract class AbstractBuildForm {
} }
if ($flagDelete) { if ($flagDelete) {
// $rowHtml .= Support::wrapTag('<td>', $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', $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> // <button type="button" class="record-delete" data-sip={{SIP}}><span class="glyphicon glyphicon-trash"></span></button>
$s = $this->createDeleteUrl($targetTableName, $row['id'], RETURN_SIP); $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); $html .= Support::wrapTag('<tr class="record">', $rowHtml, true);
...@@ -1102,7 +1124,7 @@ abstract class AbstractBuildForm { ...@@ -1102,7 +1124,7 @@ abstract class AbstractBuildForm {
* @return string * @return string
* @throws UserException * @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 = [ $queryStringArray = [
SIP_FORM => $formElement[SUBRECORD_PARAMETER_FORM], SIP_FORM => $formElement[SUBRECORD_PARAMETER_FORM],
...@@ -1125,7 +1147,7 @@ abstract class AbstractBuildForm { ...@@ -1125,7 +1147,7 @@ abstract class AbstractBuildForm {
} }
} }
if ($showDebugInfo) if ($this->showDebugInfo)
$toolTip .= PHP_EOL . OnArray::toString($queryStringArray, ' = ', PHP_EOL, "'"); $toolTip .= PHP_EOL . OnArray::toString($queryStringArray, ' = ', PHP_EOL, "'");
Support::appendTypo3ParameterToArray($queryStringArray); Support::appendTypo3ParameterToArray($queryStringArray);
...@@ -1140,7 +1162,7 @@ abstract class AbstractBuildForm { ...@@ -1140,7 +1162,7 @@ abstract class AbstractBuildForm {
$sip = $this->store->getSipInstance(); $sip = $this->store->getSipInstance();
$url = $sip->queryStringToSip($queryString); $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 { ...@@ -1414,9 +1436,9 @@ abstract class AbstractBuildForm {
* @param $toolTip * @param $toolTip
* @return string * @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'"; $toolTip .= PHP_EOL . "table = '$table'" . PHP_EOL . "id = '$recordId'";
} }
......
...@@ -98,7 +98,6 @@ class BuildFormBootstrap extends AbstractBuildForm { ...@@ -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'])); $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()); $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); $html .= Support::wrapTag('<div class="row">', $title . $button);
...@@ -122,46 +121,51 @@ class BuildFormBootstrap extends AbstractBuildForm { ...@@ -122,46 +121,51 @@ class BuildFormBootstrap extends AbstractBuildForm {
$toolTipDelete = 'Delete'; $toolTipDelete = 'Delete';
$buttonDelete = ''; $buttonDelete = '';
$buttonNew = ''; $buttonNew = '';
$buttonDebug = '';
$recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP);
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) . "'"; // Button: FormEdit
} if ($this->showDebugInfo) {
$tooltipFormEdit = "Edit form" . PHP_EOL . PHP_EOL . OnArray::toString($this->store->getStore(STORE_SIP), ' = ', PHP_EOL, "'");
$sipParamString = OnArray::toString($this->store->getStore(STORE_SIP), ' = ', PHP_EOL, "'"); $urlFormEdit = $this->createFormEditUrl();
$formEditUrl = $this->createFormEditUrl(); // Edit Form
$buttonDebug = <<<BUTTON
$buttonDebug = <<<BUTTON <div class="btn-group" role="group">
<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>
<button id="debug-button" type="button" class="btn btn-default navbar-btn" title="$sipParamString"><span class="glyphicon glyphicon-eye-open"></span></button> </div>
<a href="$formEditUrl" id="form-edit-button" class="btn btn-default navbar-btn" title="Edit form"><span class="glyphicon glyphicon-wrench"></span></a>
</div>
BUTTON; BUTTON;
}
// Button: Delete
if (Support::findInSet(FORM_BUTTON_DELETE, $this->formSpec['showButton'])) { 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 $buttonDelete = <<<BUTTON
<div class="btn-group" role="group"> <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> <button id="delete-button" type="button" class="btn btn-default navbar-btn $buttonDeleteDisabled" title="$toolTipDelete"><span class="glyphicon glyphicon-trash"></span></button>
</div> </div>
BUTTON; BUTTON;
} }
// Button: New
if (Support::findInSet(FORM_BUTTON_NEW, $this->formSpec['showButton'])) { if (Support::findInSet(FORM_BUTTON_NEW, $this->formSpec['showButton'])) {
$formNewUrl = $this->deriveNewRecordUrlFromExistingSip($toolTipNew);
$buttonNew = <<<BUTTON $buttonNew = <<<BUTTON
<div class="btn-group" role="group"> <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> <a href="$formNewUrl" id="form-new-button" class="btn btn-default navbar-btn" title="$toolTipNew"><span class="glyphicon glyphicon-plus"></span></a>
</div> </div>
BUTTON; BUTTON;
} }
$buttonFormEdit = ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes') ? $buttonDebug : '';
// <div class="btn-toolbar pull-right" role="toolbar"> // <div class="btn-toolbar pull-right" role="toolbar">
$html = <<<BUTTON $html = <<<BUTTON
<div class="btn-toolbar" role="toolbar"> <div class="btn-toolbar" role="toolbar">
$buttonFormEdit $buttonDebug
<div class="btn-group" role="group"> <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="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> <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; ...@@ -261,6 +265,7 @@ BUTTON;
public function tail() { public function tail() {
$html = ''; $html = '';
$html .= $this->buildNewSip(); $html .= $this->buildNewSip();
$deleteUrl = '';
$formId = $this->getFormId(); $formId = $this->getFormId();
...@@ -272,7 +277,9 @@ BUTTON; ...@@ -272,7 +277,9 @@ BUTTON;
$formId = $this->getFormId(); $formId = $this->getFormId();
$tabId = $this->getTabId(); $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 .= '</form>'; // <form class="form-horizontal" ...
$html .= <<<EOF $html .= <<<EOF
......
...@@ -198,6 +198,7 @@ const TYPO3_FE_USER_UID = 'feUserUid'; ...@@ -198,6 +198,7 @@ const TYPO3_FE_USER_UID = 'feUserUid';
const TYPO3_FE_USER_GROUP = 'feUserGroup'; const TYPO3_FE_USER_GROUP = 'feUserGroup';
const TYPO3_TT_CONTENT_UID = 'ttcontentUid'; const TYPO3_TT_CONTENT_UID = 'ttcontentUid';
const TYPO3_PAGE_ID = 'typo3PageId'; const TYPO3_PAGE_ID = 'typo3PageId';
const TYPO3_PAGE_TYPE = 'typo33PageType';
// System // System
const SYSTEM_DB_USER = 'DB_USER'; const SYSTEM_DB_USER = 'DB_USER';
......
...@@ -104,8 +104,16 @@ class QuickFormQuery { ...@@ -104,8 +104,16 @@ class QuickFormQuery {
mb_internal_encoding("UTF-8"); mb_internal_encoding("UTF-8");
ini_set('session.gc-maxlifetime', SESSION_LIFETIME_SECONDS); // session.cache_expire
ini_set('session.cookie_lifetime', SESSION_LIFETIME_SECONDS); // 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. // Refresh the session even if no new data saved.
$_SESSION['LAST_ACTIVITY'] = time(); $_SESSION['LAST_ACTIVITY'] = time();
......
...@@ -44,6 +44,8 @@ class Sip { ...@@ -44,6 +44,8 @@ class Sip {
$_SESSION = null; $_SESSION = null;
@session_start(); @session_start();
} else { } else {
// session_name($sessionname);
session_start(); session_start();
} }
...@@ -115,14 +117,15 @@ class Sip { ...@@ -115,14 +117,15 @@ class Sip {
} }
/** /**
* @param $param * Splits the $paramArray in &$clientArray and &$sipArray. $sipArray contains all key/values pairs wich are not belong to Typo3.
* @param $script *
* @param array $paramArray
* @param array $clientArray * @param array $clientArray
* @param array $sipArray * @param array $sipArray
* @throws CodeException * @return string
* @throws UserException * @throws \qfq\CodeException
*/ */
private function splitParamClientSip($paramArray, array &$clientArray, array &$sipArray) { private function splitParamClientSip(array $paramArray, array &$clientArray, array &$sipArray) {
$script = ''; $script = '';
...@@ -189,6 +192,8 @@ class Sip { ...@@ -189,6 +192,8 @@ class Sip {
} }
/** /**
* Returns a new uniqid, which will be used as a SIP identifier
*
* @param bool|false $staticUniqId * @param bool|false $staticUniqId
* @return bool|string * @return bool|string
*/ */
......
...@@ -240,6 +240,9 @@ class Store { ...@@ -240,6 +240,9 @@ class Store {
if (isset($GLOBALS["TSFE"]->id)) if (isset($GLOBALS["TSFE"]->id))
$arr[TYPO3_PAGE_ID] = $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); 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