Commit 4ebbc618 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Documentation/UsersManual/index.rst: added SIP Parameter.

Link.php: fixed bug that '0' as parameter for a token was equal to 'take default'.
Report.php: fixed two bugs with 'uninitialized variable'
Sip.php: index.php replaced by a constant.
parent f704ea81
......@@ -1314,7 +1314,7 @@ Column: link
+---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |Right |R |R |Defines picture position: Default is 'left' (no definition) of the 'text'. 'R' means 'right' of the 'text' |
+---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |SIP |s |s |A SIP entry is generated with all non Typo 3 Parameters. The URL contains only parameter 's' and Typo 3 parameter |
| | |SIP |s[:0|1] |s, s:0, s:1 |If 's' or 's:1' a SIP entry is generated with all non Typo 3 Parameters. The URL contains only parameter 's' and Typo 3 parameter |
+---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
.. _render-mode:
......
......@@ -1919,8 +1919,8 @@ abstract class AbstractBuildForm {
// $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement[FE_MODE]);
$element = Support::wrapTag("<div $attribute>", '', false);
return $element . $this->getHelpBlock();
return $element . $this->getHelpBlock();
}
/**
......
......@@ -439,4 +439,6 @@ const DB_NUM_ROWS = 'numRows';
const DB_AFFECTED_ROWS = 'affectedRows';
const DB_INSERT_ID = 'insertId';
const COLUMN_CREATED = 'created';
\ No newline at end of file
const COLUMN_CREATED = 'created';
const INDEX_PHP = 'index.php';
\ No newline at end of file
......@@ -402,7 +402,7 @@ class Link {
}
$keyName = $this->tableVarName[$key]; // convert token to name
if (empty($value)) {
if ($value === '') {
switch ($key) {
case TOKEN_URL:
throw new UserReportException ("Missing value for token '$key'", ERROR_MISSING_VALUE);
......@@ -569,6 +569,11 @@ class Link {
$urlNParam = '';
if ($vars[NAME_MAIL] === '') {
if (substr($vars[NAME_URL], 0, 1) === '?') {
$vars[NAME_URL] = INDEX_PHP . $vars[NAME_URL];
}
// Either NAME_URL is empty or NAME_PAGE is empty
$urlNParam = Support::concatUrlParam($vars[NAME_URL] . $vars[NAME_PAGE], $vars[NAME_URL_PARAM]);
......
......@@ -122,6 +122,10 @@ class Report {
Support::setIfNotSet($t3data, "uid", 0);
$this->sip = new Sip($sessionName, $phpUnit);
if ($phpUnit) {
$this->sip->sipUniqId('badcaffee1234');
}
$this->store = Store::getInstance();
$this->showDebugInfo = ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes');
......@@ -902,7 +906,7 @@ class Report {
}
foreach ($param as $key) {
switch ($key[0]) {
switch (substr($key, 0, 1)) {
case TOKEN_PICTURE:
case TOKEN_EDIT:
case TOKEN_NEW:
......@@ -920,6 +924,8 @@ class Report {
case TOKEN_QUESTION:
$defaultQuestion = ''; // if a question is given: no default
break;
default:
break;
}
}
......
......@@ -72,7 +72,7 @@ class Sip {
* @throws CodeException
* @throws UserFormException
*/
public function queryStringToSip($queryString, $mode = RETURN_URL, $scriptName = 'index.php') {
public function queryStringToSip($queryString, $mode = RETURN_URL, $phpScriptName = INDEX_PHP) {
// Validate: Check if still the same fe_user is logged in.
$this->checkFeUserUid();
......@@ -111,7 +111,7 @@ class Sip {
$clientArray[CLIENT_SIP] = $s;
if ($script[0] === '?')
$script = $scriptName . $script;
$script = $phpScriptName . $script;
$clientArray['_url'] = $script . OnArray::toString($clientArray);
......
......@@ -626,6 +626,25 @@ class LinkTest extends \PHPUnit_Framework_TestCase {
$result = $link->renderLink('u:http://www.example.com|C|B');
}
/**
* @expectedException \qfq\UserReportException
*/
public function testPictureException3() {
$link = new Link(null, $this->sip, true);
// r: default (0)
$result = $link->renderLink('u:http://www.example.com|B:green|B:red');
}
/**
* @expectedException \qfq\UserReportException
*/
public function testPictureException4() {
$link = new Link(null, $this->sip, true);
// r: default (0)
$result = $link->renderLink('u:http://www.example.com|C:green|C:red');
}
/**
* @throws SyntaxReportException
......@@ -830,13 +849,29 @@ class LinkTest extends \PHPUnit_Framework_TestCase {
public function testSip() {
$link = new Link(null, $this->sip, true);
// Sip: URL
// Sip: URL, s
$result = $link->renderLink('u:?form&r=12&xId=2345&L=1&type=99&gId=55|s');
$this->assertEquals('<a href="index.php?id=form&L=1&type=99&s=badcaffee1234" class="external" >index.php?id=form&L=1&type=99&s=badcaffee1234</a>', $result);
// Sip: Page
// Sip: URL, s:0
$result = $link->renderLink('u:?form&r=12&xId=2345&L=1&type=99&gId=55|s:0');
$this->assertEquals('<a href="index.php?form&r=12&xId=2345&L=1&type=99&gId=55" class="external" >index.php?form&r=12&xId=2345&L=1&type=99&gId=55</a>', $result);
// Sip: URL, s:1
$result = $link->renderLink('u:?form&r=12&xId=2345&L=1&type=99&gId=55|s:1');
$this->assertEquals('<a href="index.php?id=form&L=1&type=99&s=badcaffee1234" class="external" >index.php?id=form&L=1&type=99&s=badcaffee1234</a>', $result);
// Sip: Page, s
$result = $link->renderLink('p:form&r=12&xId=2345&L=1&type=99&gId=55|s');
$this->assertEquals('<a href="index.php?id=form&L=1&type=99&s=badcaffee1234" class="internal" >index.php?id=form&L=1&type=99&s=badcaffee1234</a>', $result);
// Sip: Page, s:0
$result = $link->renderLink('p:form&r=12&xId=2345&L=1&type=99&gId=55|s:0');
$this->assertEquals('<a href="?id=form&r=12&xId=2345&L=1&type=99&gId=55" class="internal" >?id=form&r=12&xId=2345&L=1&type=99&gId=55</a>', $result);
// Sip: Page, s:1
$result = $link->renderLink('p:form&r=12&xId=2345&L=1&type=99&gId=55|s:1');
$this->assertEquals('<a href="index.php?id=form&L=1&type=99&s=badcaffee1234" class="internal" >index.php?id=form&L=1&type=99&s=badcaffee1234</a>', $result);
}
......
......@@ -185,20 +185,257 @@ class ReportTest extends AbstractDatabaseTest {
/**
*
*/
public function testReportPageToken() {
public function testReportPageTokenSip() {
//
// $result = $this->report->process("10.sql = SELECT 'p:form&r=123&a=hello&type=5&L=3&final=world|t:Person' AS _page FROM Person ORDER BY id LIMIT 1");
// $this->assertEquals('', $result);
// page with sip (default, without explizit definition)
$result = $this->report->process("10.sql = SELECT 'p:form&r=123&a=hello&type=5&L=3&final=world|t:Person' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&type=5&L=3&s=badcaffee1234" class="internal" >Person</a>', $result);
// page with sip (explizit definition via 's')
$result = $this->report->process("10.sql = SELECT 'p:form&r=123&a=hello&type=5&L=3&final=world|t:Person|s' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&type=5&L=3&s=badcaffee1234" class="internal" >Person</a>', $result);
// page without sip (explizit definition via 's:0')
$result = $this->report->process("10.sql = SELECT 'p:form&r=123&a=hello&type=5&L=3&final=world|t:Person|s:0' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="?id=form&r=123&a=hello&type=5&L=3&final=world" class="internal" >Person</a>', $result);
// page with sip (explizit definition via 's:1')
$result = $this->report->process("10.sql = SELECT 'p:form&r=123&a=hello&type=5&L=3&final=world|t:Person|s:1' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&type=5&L=3&s=badcaffee1234" class="internal" >Person</a>', $result);
// page with sip (explizit definition via 's:1')
$result = $this->report->process("10.sql = SELECT 'p:form&r=123&a=hello&type=5&L=3&final=world' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&type=5&L=3&s=badcaffee1234" class="internal" >index.php?id=form&type=5&L=3&s=badcaffee1234</a>', $result);
}
/**
*
*/
public function testReportPageFix() {
public function testReportPageTokenPicture() {
// page & picture
$result = $this->report->process("10.sql = SELECT 'p:form&r=123&a=hello&type=5&L=3&final=world|P:picture.gif' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&type=5&L=3&s=badcaffee1234" ><img alt="picture.gif" src="picture.gif" title="picture.gif" ></a>', $result);
// page & Edit
$result = $this->report->process("10.sql = SELECT 'p:form&r=123&a=hello&type=5&L=3&final=world|E' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&type=5&L=3&s=badcaffee1234" class="btn btn-default" title="Edit" ><span class="glyphicon glyphicon-pencil" ></span></a>', $result);
// page & New
$result = $this->report->process("10.sql = SELECT 'p:form&r=123&a=hello&type=5&L=3&final=world|N' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&type=5&L=3&s=badcaffee1234" class="btn btn-default" title="New" ><span class="glyphicon glyphicon-plus" ></span></a>', $result);
// page & Delete
$result = $this->report->process("10.sql = SELECT 'p:form&r=123&a=hello&type=5&L=3&final=world|D' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&type=5&L=3&s=badcaffee1234" class="btn btn-default" title="Delete" ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
// page & Help
$result = $this->report->process("10.sql = SELECT 'p:form&r=123&a=hello&type=5&L=3&final=world|H' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&type=5&L=3&s=badcaffee1234" class="btn btn-default" title="Help" ><span class="glyphicon glyphicon glyphicon-question-sign" ></span></a>', $result);
// page & Information
$result = $this->report->process("10.sql = SELECT 'p:form&r=123&a=hello&type=5&L=3&final=world|I' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&type=5&L=3&s=badcaffee1234" class="btn btn-default" title="Information" ><span class="glyphicon glyphicon glyphicon-info-sign" ></span></a>', $result);
// page & Show
$result = $this->report->process("10.sql = SELECT 'p:form&r=123&a=hello&type=5&L=3&final=world|S' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&type=5&L=3&s=badcaffee1234" class="btn btn-default" title="Details" ><span class="glyphicon glyphicon glyphicon-search" ></span></a>', $result);
// page & Show & Text
$result = $this->report->process("10.sql = SELECT 'p:form&r=123&a=hello&type=5&L=3&final=world|S|t:Person' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&type=5&L=3&s=badcaffee1234" class="btn btn-default" title="Details" ><span class="glyphicon glyphicon glyphicon-search" ></span> Person</a>', $result);
}
/**
*
*/
public function testReportPageTokenBullet() {
// page & bullet (green)
$result = $this->report->process("10.sql = SELECT 'p:form|B' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" ><img alt="Bullet green" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif" title="green" ></a>', $result);
// page & bullet (green)
$result = $this->report->process("10.sql = SELECT 'p:form|B||t:Person' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" ><img alt="Bullet green" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif" title="green" > Person</a>', $result);
$arr = ['blue', 'gray', 'green', 'pink', 'red', 'yellow', 'fake'];
foreach ($arr as $color) {
// page & bullet $color
$result = $this->report->process("10.sql = SELECT 'p:form|B:$color' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals("<a href=\"index.php?id=form&s=badcaffee1234\" ><img alt=\"Bullet $color\" src=\"typo3conf/ext/qfq/Resources/Public/icons/bullet-$color.gif\" title=\"$color\" ></a>", $result);
}
}
/**
*
*/
public function testReportPageTokenCheck() {
// page & bullet (green)
$result = $this->report->process("10.sql = SELECT 'p:form|C' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" ><img alt="Checked green" src="typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif" title="green" ></a>', $result);
// page & bullet (green)
$result = $this->report->process("10.sql = SELECT 'p:form|C|t:Person' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" ><img alt="Checked green" src="typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif" title="green" > Person</a>', $result);
$arr = ['blue', 'gray', 'green', 'pink', 'red', 'yellow', 'fake'];
foreach ($arr as $color) {
// page & bullet $color
$result = $this->report->process("10.sql = SELECT 'p:form|C:$color' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals("<a href=\"index.php?id=form&s=badcaffee1234\" ><img alt=\"Checked $color\" src=\"typo3conf/ext/qfq/Resources/Public/icons/checked-$color.gif\" title=\"$color\" ></a>", $result);
}
}
/**
*
*/
public function testReportPageTokenUrlParam() {
// page & Url Param
$result = $this->report->process("10.sql = SELECT 'p:form|U:r=234|s:0|t:Person' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="?id=form&r=234" class="internal" >Person</a>', $result);
// page & Url Param=''
$result = $this->report->process("10.sql = SELECT 'p:form|U|s:0|t:Person' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="?id=form" class="internal" >Person</a>', $result);
}
/**
*
*/
public function testReportPageTokenToolTip() {
// page & Tooltip=Tool Tip
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|o:Tool Tip' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" title="Tool Tip" >Person</a>', $result);
// page & Tooltip=''
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|o' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" >Person</a>', $result);
}
/**
*
*/
public function testReportPageTokenAltText() {
// page & AltText - no image
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|a' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" >Person</a>', $result);
// page & AltText - no image
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|a:' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" >Person</a>', $result);
// page & AltText - no image
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|a:Hello World' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" >Person</a>', $result);
// page & AltText - image
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|B|a' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" ><img src="typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif" title="green" > Person</a>', $result);
// page & AltText - image
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|B|a:' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" ><img src="typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif" title="green" > Person</a>', $result);
// page & AltText - image
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|B|a:Hello World' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" ><img alt="Hello World" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif" title="green" > Person</a>', $result);
}
/**
*
*/
public function testReportPageTokenClass() {
// page & class (empty)
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|c' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" >Person</a>', $result);
// page & class (empty)
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|c:' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" >Person</a>', $result);
// page & class (empty)
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|c:n' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" >Person</a>', $result);
// page & class (empty)
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|c:i' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" >Person</a>', $result);
// page & class (empty)
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|c:e' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="external" >Person</a>', $result);
// page & class (empty)
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|c:myclass' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="myclass" >Person</a>', $result);
}
/**
*
*/
public function testReportPageTokenTarget() {
// page & target (empty)
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|g' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" >Person</a>', $result);
// page & target (empty)
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|g:' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" >Person</a>', $result);
// page & target (empty)
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|g:_blank' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" target="_blank" >Person</a>', $result);
// page & target (empty)
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|g:_nextframe' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" target="_nextframe" >Person</a>', $result);
}
/**
*
*/
public function testReportPageTokenQuestion() {
// TODO: implement
}
/**
*
*/
public function testReportPageTokenEncryption() {
// TODO: implement
}
/**
*
*/
public function testReportPageTokenRight() {
// page & target (empty)
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|R' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" >Person</a>', $result);
// page & target (empty)
$result = $this->report->process("10.sql = SELECT 'p:form|t:Person|R|B' AS _page FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" >Person <img alt="Bullet green" src="typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif" title="green" ></a>', $result);
}
/**
*
*/
public function testReportPageFix() {
// TODO: implement
//
// $result = $this->report->process("10.sql = SELECT 'form|r=123&a=hello&type=5&L=3&final=world|Person' AS _Page FROM Person ORDER BY id LIMIT 1");
// $this->assertEquals('', $result);
......@@ -206,6 +443,22 @@ class ReportTest extends AbstractDatabaseTest {
}
/**
*
*/
public function testReportPageTokenMail() {
// TODO: implement
}
/**
*
*/
public function testReportPageTokenRender() {
// TODO: implement
}
/**
* @throws Exception
......
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