Commit 0856b7c4 authored by Carsten  Rose's avatar Carsten Rose
Browse files

#3253: STORE_TYPO3: steht waehrend Update / Save nicht zur Verfuegung - wird...

#3253: STORE_TYPO3: steht waehrend Update / Save nicht zur Verfuegung - wird aber benoetigt. Bsp: feUser, beUser, pageId, ...

CODING.md: described implementation.
Store.php: fixed setting of STORE_SYSTEM / showDebugInfo during API call.
parent 13d39fbe
...@@ -34,7 +34,7 @@ LOAD ...@@ -34,7 +34,7 @@ LOAD
* active/valid formname: [$this->store->setVar(SYSTEM_FORM, $formName, STORE_SYSTEM);] * active/valid formname: [$this->store->setVar(SYSTEM_FORM, $formName, STORE_SYSTEM);]
* SIP: [$this->store->getVar('form', STORE_SIP)] * SIP: [$this->store->getVar('form', STORE_SIP)]
* All parameters from active SIP: [$this->store->getStore(STORE_SIP)] * All parameters from active SIP: [$this->store->getStore(STORE_SIP)]
* Check Contstants.php for known Store members * Check Contstants.php for known Store members:
* In QuickFormQuery.php the whole Form will be copied to `$this->formSpec` and depending on further processing, the * In QuickFormQuery.php the whole Form will be copied to `$this->formSpec` and depending on further processing, the
elements are available in `$this->feNative` and `$this->feAction`. elements are available in `$this->feNative` and `$this->feAction`.
...@@ -50,18 +50,27 @@ LOAD ...@@ -50,18 +50,27 @@ LOAD
the record again and again. Unfortunately, the initial created SIP (before 'form load') is not uniqe anymore (multiple the record again and again. Unfortunately, the initial created SIP (before 'form load') is not uniqe anymore (multiple
tabs might contain a saved 'new record'). To guarantee correct saving of r=0 records, a unique on the fly generated SIP tabs might contain a saved 'new record'). To guarantee correct saving of r=0 records, a unique on the fly generated SIP
is creatd during form load - individually per browser tab. is creatd during form load - individually per browser tab.
* Faking the STORE_TYPO3 for API calls:
* Formular zusammenbausen * The PHP code api/save.php, api/load.php is called directly, without any TYPO3 Framework. Therefore the Typo3 information
* QuickFormQuery: doForm > loadFormSpecification - laedt alle Elemente die nicht genested sind: native, pill, fieldset, templateGroup >> $his->formNative 'pageId', 'feUser*', 'beUser*', 'ttContentUid', ... is not directly available.
* Damit wird '(BuildFormBootstrap / AbstractBuildForm) > process()' aufgerufen. * *Form load*: an additional hidden Formelement '_sipForTypo3Vars' will be created with a subset of the current
* Hier wird AbstractBuildForm->elements() aufgerufen (ein Aufruf fuer alle root elemente). STORE_TYPO3 values. The workaround with the SIP is usefull, cause the same form can be shown on different places (QFQ records) -
* Pro native Element (inkl. pill, fieldset, templateGroup) wird $builElementFunctionName aufgerufen. this is not very likely, but might happen. The 'on the fly rendered' SIP helps to deliver the status.
- buildText() AbstractBuildForm.php: process() > prepareT3VarsForSave() > Store.php: copyT3VarsToSip();
- .... * *Form save*: FillStoreForm.php: process() > Store: fillTypo3StoreFromSip()
- buildFieldSet() << von hier werden alle zum aktuellen 'FieldSet' gehoerenden SubElemente abgearbeitet - via AbstractBuildForm->elements() (damit schliesst sich der Kreis und wird rekursiv)
- buildPill() << von hier werden alle zum aktuellen 'Pill' gehoerenden SubElemente abgearbeitet - via AbstractBuildForm->elements() (damit schliesst sich der Kreis und wird rekursiv) * Formular zusammenbauen
- buildTemplateGroup() << von hier werden alle zum aktuellen 'Pill' gehoerenden SubElemente abgearbeitet - via AbstractBuildForm->elements() (damit schliesst sich der Kreis und wird rekursiv) * QuickFormQuery: doForm > loadFormSpecification - laedt alle Elemente die nicht genested sind: native, pill, fieldset, templateGroup >> $his->formNative
>> * Damit wird '(BuildFormBootstrap / AbstractBuildForm) > process()' aufgerufen.
* Hier wird AbstractBuildForm->elements() aufgerufen (ein Aufruf fuer alle root elemente).
* Pro native Element (inkl. pill, fieldset, templateGroup) wird $builElementFunctionName aufgerufen.
- buildText()
- ....
- buildFieldSet() << von hier werden alle zum aktuellen 'FieldSet' gehoerenden SubElemente abgearbeitet - via AbstractBuildForm->elements() (damit schliesst sich der Kreis und wird rekursiv)
- buildPill() << von hier werden alle zum aktuellen 'Pill' gehoerenden SubElemente abgearbeitet - via AbstractBuildForm->elements() (damit schliesst sich der Kreis und wird rekursiv)
- buildTemplateGroup() << von hier werden alle zum aktuellen 'Pill' gehoerenden SubElemente abgearbeitet - via AbstractBuildForm->elements() (damit schliesst sich der Kreis und wird rekursiv)
>>
SAVE SAVE
---- ----
* Via wrapper api/save.php * Via wrapper api/save.php
......
...@@ -300,7 +300,10 @@ class Store { ...@@ -300,7 +300,10 @@ class Store {
private static function adjustConfig(array $config) { private static function adjustConfig(array $config) {
// Adjust config // Adjust config
if ($config[SYSTEM_SHOW_DEBUG_INFO] === 'auto') { if ($config[SYSTEM_SHOW_DEBUG_INFO] === 'auto') {
$config[SYSTEM_SHOW_DEBUG_INFO] = (isset($GLOBALS["TSFE"]->beUserLogin) && $GLOBALS["TSFE"]->beUserLogin === true) ? 'yes' : 'no'; $rc = self::beUserLoggdIn();
if ($rc !== false) {
$config[SYSTEM_SHOW_DEBUG_INFO] = $rc;
}
} }
// make SQL PATH absolute. This is necessary to work in different directories correctly. // make SQL PATH absolute. This is necessary to work in different directories correctly.
...@@ -311,6 +314,20 @@ class Store { ...@@ -311,6 +314,20 @@ class Store {
return $config; return $config;
} }
/**
* @return bool|string
*/
private static function beUserLoggdIn() {
if (isset($GLOBALS["TSFE"])) {
$rc = (isset($GLOBALS["TSFE"]->beUserLogin) && $GLOBALS["TSFE"]->beUserLogin === true) ? 'yes' : 'no';
} else {
$rc = false;
}
return $rc;
}
/** /**
* Iterate over all Parameter which have to exist in the config. Throw an array if any is missing. * Iterate over all Parameter which have to exist in the config. Throw an array if any is missing.
* *
...@@ -716,6 +733,29 @@ class Store { ...@@ -716,6 +733,29 @@ class Store {
return $tmpParam; return $tmpParam;
} }
/**
* Returns a complete $store.
*
* @param $store
* @return array
* @throws UserFormException
* @throws \qfq\CodeException
*/
public static function getStore($store) {
// Check valid Storename
if (!isset(self::$sanitizeStore[$store]))
throw new UserFormException("Unknown Store: $store", ERROR_UNNOWN_STORE);
if ($store === STORE_ZERO)
throw new CodeException("getStore() for STORE_ZERO is impossible - there are no values saved.", ERROR_GET_STORE_ZERO);
if (isset(self::$raw[$store])) {
return self::$raw[$store];
}
return array();
}
/** /**
* Returns a pointer to this class. * Returns a pointer to this class.
* *
...@@ -741,6 +781,10 @@ class Store { ...@@ -741,6 +781,10 @@ class Store {
} }
/** /**
* Saves a subset of STORE_TYPO3 vars as a SIP. The SIP will be transmitted as hidden form element.
*
* More docs: CODING.md > 'Faking the STORE_TYPO3 for API calls'
*
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
*/ */
...@@ -763,6 +807,9 @@ class Store { ...@@ -763,6 +807,9 @@ class Store {
} }
/** /**
* Get stored STORE_TYPO3 vars from SIP and restore the store.
*
* More docs: CODING.md > 'Faking the STORE_TYPO3 for API calls'
* *
* @param string $sipTypo3Vars * @param string $sipTypo3Vars
*/ */
...@@ -777,29 +824,12 @@ class Store { ...@@ -777,29 +824,12 @@ class Store {
$typo3VarsArray = self::$sip->getVarsFromSip($sipTypo3Vars); $typo3VarsArray = self::$sip->getVarsFromSip($sipTypo3Vars);
self::setStore($typo3VarsArray, STORE_TYPO3, true); self::setStore($typo3VarsArray, STORE_TYPO3, true);
}
/**
* Returns a complete $store.
*
* @param $store
* @return array
* @throws UserFormException
* @throws \qfq\CodeException
*/
public static function getStore($store) {
// Check valid Storename
if (!isset(self::$sanitizeStore[$store]))
throw new UserFormException("Unknown Store: $store", ERROR_UNNOWN_STORE);
if ($store === STORE_ZERO) // If necessary, update SYSTEM_SHOW_DEBUG_INFO
throw new CodeException("getStore() for STORE_ZERO is impossible - there are no values saved.", ERROR_GET_STORE_ZERO); if (self::getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) == 'auto') {
$val = ($typo3VarsArray[TYPO3_BE_USER_LOGGED_IN] == 'yes') ? 'yes' : 'no';
if (isset(self::$raw[$store])) { self::setVar(SYSTEM_SHOW_DEBUG_INFO, $val, STORE_SYSTEM);
return self::$raw[$store];
} }
return array();
} }
} }
......
Supports Markdown
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