Commit 11e9b770 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Constants.php,QuickFormQuery.php: Introduced new variables, Bodytext: no var...

Constants.php,QuickFormQuery.php: Introduced new variables, Bodytext: no var 'form=' or empty var 'form' are now allowed. If given, no form will be load -nothing happens.
parent 7271172a
......@@ -473,3 +473,7 @@ const COLUMN_CREATED = 'created';
const INDEX_PHP = 'index.php';
// QuickFormQuery.php
const T3DATA_BODYTEXT = 'bodytext';
const T3DATA_UID = 'uid';
......@@ -134,21 +134,24 @@ class QuickFormQuery {
set_error_handler("\\qfq\\ErrorHandler::exception_error_handler");
if (!isset($t3data['bodytext']))
$t3data['bodytext'] = '';
if (!isset($t3data['uid']))
$t3data['uid'] = 0;
if (!isset($t3data[T3DATA_BODYTEXT])) {
$t3data[T3DATA_BODYTEXT] = '';
}
if (!isset($t3data[T3DATA_UID])) {
$t3data[T3DATA_UID] = 0;
}
$btp = new BodytextParser();
$t3data['bodytext'] = $btp->process($t3data['bodytext']);
$t3data[T3DATA_BODYTEXT] = $btp->process($t3data[T3DATA_BODYTEXT]);
$this->t3data = $t3data;
$bodytext = $this->t3data['bodytext'];
$bodytext = $this->t3data[T3DATA_BODYTEXT];
$this->session = Session::getInstance($phpUnit);
$this->store = Store::getInstance($bodytext, $phpUnit);
$this->store->setVar(TYPO3_TT_CONTENT_UID, $t3data['uid'], STORE_TYPO3);
$this->store->setVar(TYPO3_TT_CONTENT_UID, $t3data[T3DATA_UID], STORE_TYPO3);
$this->db = new Database();
$this->eval = new Evaluate($this->store, $this->db);
}
......@@ -364,7 +367,7 @@ class QuickFormQuery {
* @throws CodeException
* @throws UserFormException
*/
private function getFormName($mode, &$foundInStore = '') {
public function getFormName($mode, &$foundInStore = '') {
$dummy = array();
switch ($mode) {
......@@ -383,7 +386,7 @@ class QuickFormQuery {
$formName = $this->eval->parse($storeFormName, 0, $dummy, $foundInStore);
// If the formname is '': no formname name.
if ($formName === '')
if ($formName === '' || $foundInStore === '')
return false;
// If the formname is surrounded by single ticks: the token (typically 'form') has not been replaced by a value.
......
......@@ -11,6 +11,7 @@
require_once(__DIR__ . '/../../qfq/Constants.php');
require_once(__DIR__ . '/../../qfq/QuickFormQuery.php');
require_once(__DIR__ . '/../../qfq/store/Store.php');
require_once(__DIR__ . '/../../qfq/store/Sip.php');
class QuickFormQueryTest extends \PHPUnit_Framework_TestCase {
......@@ -20,6 +21,77 @@ class QuickFormQueryTest extends \PHPUnit_Framework_TestCase {
public function testProcess() {
$form = new qfq\QuickFormQuery(['bodytext' => "\n; some comment\n" . TYPO3_FORM . "=testformnameDoNotChange\n"]);
// $this->assertEquals("", $form->process());
}
//
//* FORM_LOAD:
//* Specified in T3 body text with form=<formname> Returned Store:Typo3
//* Specified in T3 body text with form={{form}} ':FSRD' Returned Store:SIP
//* Specified in T3 body text with form={{form:C:ALNUMX}} Returned Store:Client
//* Specified in T3 body text with form={{SELECT registrationFormName FROM Conference WHERE id={{conferenceId:S0}} }}
// * Specified in T3 body text with form={{SELECT registrationFormName FROM Conference WHERE id={{conferenceId:C0:DIGIT}} }}
// * Specified in SIP
//*
// * FORM_SAVE:
// * Specified in SIP
//*
// *
// * @param string $mode FORM_LOAD|FORM_SAVE|FORM_UPDATE
//* @param string $foundInStore
//* @return array|bool|mixed|null|string Formname (Form.name) or FALSE, if no formname found.
// * @throws CodeException
//* @throws UserFormException
//*/
public function testGetFormName() {
// <empty> bodytext
$t3data[T3DATA_BODYTEXT] = "\n \n \n";
$t3data[T3DATA_UID] = "123";
$qfq = new qfq\QuickFormQuery($t3data, true);
$result = $qfq->getFormName(FORM_LOAD, $foundInStore);
$this->assertEquals('', $result);
// form=
$t3data[T3DATA_BODYTEXT] = "\n \n" . TYPO3_FORM . "=\n";
$t3data[T3DATA_UID] = "123";
$qfq = new qfq\QuickFormQuery($t3data, true);
$result = $qfq->getFormName(FORM_LOAD, $foundInStore);
$this->assertEquals('', $result);
// form=<formname>
$t3data[T3DATA_BODYTEXT] = "\n \n" . TYPO3_FORM . "=myForm\n";
$t3data[T3DATA_UID] = "123";
$qfq = new qfq\QuickFormQuery($t3data, true);
$result = $qfq->getFormName(FORM_LOAD, $foundInStore);
$this->assertEquals('myForm', $result);
// form={{SELECT 'nextForm'}}
$t3data[T3DATA_BODYTEXT] = "\n \n" . TYPO3_FORM . "={{SELECT 'nextForm'}}\n";
$t3data[T3DATA_UID] = "123";
$qfq = new qfq\QuickFormQuery($t3data, true);
$result = $qfq->getFormName(FORM_LOAD, $foundInStore);
$this->assertEquals('nextForm', $result);
// form={{form:C:alnumx}}
$t3data[T3DATA_BODYTEXT] = "\n \n" . TYPO3_FORM . "={{form:C:alnumx}}\n";
$t3data[T3DATA_UID] = "123";
$_SERVER['form'] = 'formNameViaGet';
$qfq = new qfq\QuickFormQuery($t3data, true);
$result = $qfq->getFormName(FORM_LOAD, $foundInStore);
$this->assertEquals('formNameViaGet', $result);
// form={{form}}
// $sip = new qfq\Sip('fakesessionname', true);
// $sip->sipUniqId('badcaffee1234');
// $t3data[T3DATA_BODYTEXT] = "\n \n" . TYPO3_FORM . "={{form}}\n";
// $t3data[T3DATA_UID] = "123";
// $_SERVER[CLIENT_SIP]='badcaffee1234';
// $dummy = $sip->queryStringToSip("http://example.com/index.php?id=input&r=1&form=person", RETURN_URL);
// $qfq = new qfq\QuickFormQuery($t3data, true);
// $result = $qfq->getFormName(FORM_LOAD, $foundInStore);
// $this->assertEquals('person', $result);
}
}
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