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

Merge branch 'S12159Typo3V9QfqHtaccessEinschubRaus' into 'develop'

S12159 typo3 v9 qfq htaccess einschub raus

See merge request !344
parents 095f0173 a056c7ad
Pipeline #5214 passed with stages
in 3 minutes and 12 seconds
......@@ -107,17 +107,19 @@ fi
### Write config files ###
# QFQ config
echo "
<?php
return [
'DB_1_USER' => '${MYSQL_USER}',
'DB_1_SERVER' => 'db',
'DB_1_PASSWORD' => '${MYSQL_PASSWORD}',
'DB_1_NAME' => '${QFQ_DATABASE}',
];" > config.qfq.php
docker cp config.qfq.php ${T3_CONTAINER}:/var/www/html/typo3conf/config.qfq.php
rm config.qfq.php
docker exec ${T3_CONTAINER} chown www-data:www-data /var/www/html/typo3conf/config.qfq.php
cat <<EOT >> qfq.json
{
"DB_1_USER": "${MYSQL_USER}",
"DB_1_SERVER": "db",
"DB_1_PASSWORD": "${MYSQL_PASSWORD}",
"DB_1_NAME": "${QFQ_DATABASE}",
"baseUrl": " "
}
EOT
docker exec ${T3_CONTAINER} mkdir -p "/var/www/html/fileadmin/protected/qfqProject/conf"
docker cp qfq.json ${T3_CONTAINER}:/var/www/html/fileadmin/protected/qfqProject/conf/qfq.json
rm qfq.json
docker exec ${T3_CONTAINER} chown -R www-data:www-data /var/www/html/fileadmin/protected
# Typo3 config
docker exec ${T3_CONTAINER} sed -i -e "s/<MYSQL_USER>/${MYSQL_USER}/g" /var/www/html/typo3conf/LocalConfiguration.php
......
......@@ -641,7 +641,7 @@ abstract class AbstractBuildForm {
*/
public function getActionUrl() {
return Path::appToApi(API_SAVE_PHP);
return Path::urlApi(API_SAVE_PHP);
}
/**
......@@ -2567,7 +2567,7 @@ abstract class AbstractBuildForm {
}
if (isset($control[SUBRECORD_COLUMN_ICON][$columnName])) {
$cell = ($cell === '') ? '' : "<image src='" . Path::appToExt(Path::EXT_TO_PATH_ICONS) . "/$cell'>";
$cell = ($cell === '') ? '' : "<image src='" . Path::urlExt(Path::EXT_TO_PATH_ICONS, $cell) . "'>";
}
if (isset($control[SUBRECORD_COLUMN_MAILTO][$columnName])) {
......@@ -2617,7 +2617,7 @@ abstract class AbstractBuildForm {
$sip = $this->store->getSipInstance();
return $sip->queryStringToSip($queryString, $mode, Path::appToApi(API_DELETE_PHP));
return $sip->queryStringToSip($queryString, $mode, Path::urlApi(API_DELETE_PHP));
}
/**
......@@ -2905,8 +2905,8 @@ abstract class AbstractBuildForm {
$attributeFabric = Support::doAttribute('class', ANNOTATE_GRAPHIC_CSS_CLASS);
$attributeFabric .= Support::doAttribute('data-background-image', $this->fileToSipUrl($formElement[FE_IMAGE_SOURCE]));
$attributeFabric .= Support::doAttribute('data-control-name', $formElement[FE_HTML_ID]);
$attributeFabric .= Support::doAttribute('data-buttons', Path::appToExt('Resources/Public/Json/fabric.buttons.json'));
$attributeFabric .= Support::doAttribute('data-emojis', Path::appToExt('Resources/Public/Json/qfq.emoji.json'));
$attributeFabric .= Support::doAttribute('data-buttons', Path::urlExt('Resources/Public/Json/fabric.buttons.json'));
$attributeFabric .= Support::doAttribute('data-emojis', Path::urlExt('Resources/Public/Json/qfq.emoji.json'));
$attributeFabric .= Support::doAttribute('data-fabric-color', HelperFormElement::penColorToHex($formElement));
$attributeFabric .= HelperFormElement::getAttributeFeMode($formElement[FE_MODE]);
if ($formElement[FE_MODE] == FE_MODE_READONLY) {
......@@ -2971,7 +2971,7 @@ abstract class AbstractBuildForm {
// data-image-output="target-png">
// </div>
$attributeFabric = Support::doAttribute('class', ANNOTATE_GRAPHIC_CSS_CLASS);
$attributeFabric .= Support::doAttribute('data-buttons', Path::appToExt('Resources/Public/Json/fabric.editor.buttons.json'));
$attributeFabric .= Support::doAttribute('data-buttons', Path::urlExt('Resources/Public/Json/fabric.editor.buttons.json'));
$attributeFabric .= Support::doAttribute('data-edit-image', 'true');
$attributeFabric .= Support::doAttribute('data-background-image', $imageFileName);
$attributeFabric .= Support::doAttribute('data-control-name', $htmlFabricId);
......@@ -3017,7 +3017,7 @@ abstract class AbstractBuildForm {
$param[DOWNLOAD_MODE] = DOWNLOAD_MODE_FILE;
$param[SIP_DOWNLOAD_PARAMETER] = base64_encode(TOKEN_FILE . PARAM_TOKEN_DELIMITER . $pathFileName);
$url = $this->sip->queryStringToSip(Path::appToApi(API_DOWNLOAD_PHP) . '?' . KeyValueStringParser::unparse($param, '=', '&'), RETURN_URL);
$url = $this->sip->queryStringToSip(Path::urlApi(API_DOWNLOAD_PHP) . '?' . KeyValueStringParser::unparse($param, '=', '&'), RETURN_URL);
return $url;
}
......
......@@ -657,14 +657,14 @@ class BuildFormBootstrap extends AbstractBuildForm {
$actionUpload = FILE_ACTION . '=' . FILE_ACTION_UPLOAD;
$actionDelete = FILE_ACTION . '=' . FILE_ACTION_DELETE;
$apiDeletePhp = Path::appToApi(API_DELETE_PHP);
$apiDeletePhp = Path::urlApi(API_DELETE_PHP);
$dirtyAction = ($this->formSpec[F_DIRTY_MODE] == DIRTY_MODE_NONE) ? '' : "dirtyUrl: '" . Path::appToApi(API_DIRTY_PHP) . "',";
$dirtyAction = ($this->formSpec[F_DIRTY_MODE] == DIRTY_MODE_NONE) ? '' : "dirtyUrl: '" . Path::urlApi(API_DIRTY_PHP) . "',";
$submitTo = Path::appToApi(API_SAVE_PHP);
$refreshUrl = Path::appToApi(API_LOAD_PHP);
$fileUploadTo = Path::appToApi(API_FILE_PHP) . '?' . $actionUpload;
$fileDeleteUrl = Path::appToApi(API_FILE_PHP) . '?' . $actionDelete;
$submitTo = Path::urlApi(API_SAVE_PHP);
$refreshUrl = Path::urlApi(API_LOAD_PHP);
$fileUploadTo = Path::urlApi(API_FILE_PHP) . '?' . $actionUpload;
$fileDeleteUrl = Path::urlApi(API_FILE_PHP) . '?' . $actionDelete;
$html .= '</form>'; // <form class="form-horizontal" ...
$html .= <<<EOF
......
......@@ -318,7 +318,7 @@ class Evaluate {
$this->store::setVar(SYSTEM_DRAG_AND_DROP_JS, 'true', STORE_SYSTEM);
// data-dnd-api="typo3conf/ext/qfq/qfq/Api/dragAndDrop.php?s={{'U:form=<form name>[&paramX=<any value>]|s|r:8' AS _link}}"
return DND_DATA_DND_API . '="' . Path::appToApi(API_DRAG_AND_DROP_PHP) . '?s=' . $s . '"';
return DND_DATA_DND_API . '="' . Path::urlApi(API_DRAG_AND_DROP_PHP) . '?s=' . $s . '"';
}
/**
......
......@@ -457,7 +457,7 @@ class HelperFile {
}
if (isset($extToFileType[$ext])) {
return Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/' . $extToFileType[$ext];
return Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/' . $extToFileType[$ext];
}
return '';
......
......@@ -9,8 +9,11 @@ namespace IMATHUZH\Qfq\Core\Helper;
* - Ext: directory in which the QFQ extension is loacted. e.g. the folder Classes is in there.
* - API: api folder of qfq extension
*
* Naming convention of path constants/functions/variables:
* 1) name a path by its origin and its destination separated by 'to'. E.g. APP_TO_SYSTEM_LOG, $appToProject.
* Conventions of Path class:
* 1) naming conventions of of path constants/functions/variables:
* a) name a path by its origin and its destination separated by 'to'. E.g. APP_TO_SYSTEM_LOG, $appToProject.
* b) Or only by its destination and prefix "absolute" if the path is absolute e.g. absoluteApp().
* c) Or by its destination and prefix "url" if the path returns a fully qualified url using the base path e.g. urlExt().
* 2) if the destination is a file, append "File". E.g. APP_TO_SYSTEM_QFQ_LOG_FILE.
* 3) if a path has to be variable, create a setter and getter. E.g. self::setAbsoluteApp(), self::absoluteApp(), private static $absoluteApp.
* 4) a path getter appends the given arguments to the requested path using self::join(..., func_get_args()). E.g. see absoluteApp().
......@@ -25,8 +28,8 @@ use IMATHUZH\Qfq\Core\Store\Config;
class Path
{
// App
// This is manually set in self::setMainPaths()
private static $absoluteApp = null;
private static $absoluteApp = null; // This is manually set in self::setMainPaths()
private static $urlApp = null;
// Extension
const APP_TO_EXT = 'typo3conf/ext/qfq';
......@@ -221,14 +224,28 @@ class Path
return self::join(self::APP_TO_EXT, $pathPartsToAppend);
}
/**
* @param mixed ...$pathPartsToAppend
* @return string
* @throws \UserFormException
*/
public static function urlApp(...$pathPartsToAppend): string
{
// ensure base url is configured
if (is_null(self::$urlApp) || self::$urlApp === '') {
Thrower::userFormException('Base url not configured.', 'Go to QFQ extension configuration in the Typo3 backend and fill in a value for config.baseUrl');
}
return self::join(self::$urlApp, $pathPartsToAppend);
}
/**
* @param array $pathPartsToAppend
* @return string
* @throws \UserFormException
*/
public static function extToApi(...$pathPartsToAppend): string
public static function urlExt(...$pathPartsToAppend): string
{
return self::join(self::EXT_TO_API, $pathPartsToAppend);
return self::urlApp(self::appToExt($pathPartsToAppend));
}
/**
......@@ -241,6 +258,16 @@ class Path
return self::join(self::APP_TO_EXT, self::EXT_TO_API, $pathPartsToAppend);
}
/**
* @param array $pathPartsToAppend
* @return string
* @throws \UserFormException
*/
public static function urlApi(...$pathPartsToAppend): string
{
return self::urlApp(self::appToApi($pathPartsToAppend));
}
/**
* @param mixed ...$pathPartsToAppend
* @return string
......@@ -307,6 +334,14 @@ class Path
self::$overloadAbsoluteMailLogFile = $newPath;
}
/**
* @param $urlApp
*/
public static function setUrlApp($urlApp)
{
self::$urlApp = $urlApp;
}
/**
* Override the paths of sql.log, qfq.log, mail.log using the values from the config file or Typo3.
*
......@@ -390,8 +425,16 @@ class Path
}
});
// remove multiple occurrences of '/'
return preg_replace('/\/{2,}/','/', $path);
// remove multiple occurrences of '/' (but keep http://)
if (preg_match('/^\w*:\/\//', $path, $match) ) {
$protocol = $match[0];
$path = substr($path, strlen($protocol));
} else {
$protocol = '';
}
$path = preg_replace('/\/{2,}/','/', $path);
return $protocol . $path;
}
/////////////////////////////////////////////////// Private //////////////////////////////////////////////////////
......@@ -414,7 +457,6 @@ class Path
/**
* @param string $newPath
* @return string
*/
private static function setAbsoluteLog(string $newPath)
{
......
......@@ -233,10 +233,11 @@ class Support {
*
* @return string
* @throws \CodeException
* @throws \UserFormException
*/
public static function doTooltip($htmlId, $tooltipText) {
return "<img " . self::doAttribute('id', $htmlId) . " src='" . Path::appToExt(Path::EXT_TO_GFX_INFO_FILE) . "' title=\"" . htmlentities($tooltipText) . "\">";
return "<img " . self::doAttribute('id', $htmlId) . " src='" . Path::urlExt(Path::EXT_TO_GFX_INFO_FILE) . "' title=\"" . htmlentities($tooltipText) . "\">";
}
/**
......
......@@ -1772,7 +1772,7 @@ class QuickFormQuery {
$form = join(' ', [$headerBar, $codeBox]);
$sipObj = new Sip;
$action = $sipObj->queryStringToSip(Path::appToApi(API_SAVE_PHP) . "?uid=$uid&" . REPORT_SAVE . "=1&" . REPORT_SAVE_FILE . "=" . (is_null($reportPathFileNameFull) ? 0 : 1));
$action = $sipObj->queryStringToSip(Path::urlApi(API_SAVE_PHP) . "?uid=$uid&" . REPORT_SAVE . "=1&" . REPORT_SAVE_FILE . "=" . (is_null($reportPathFileNameFull) ? 0 : 1));
$formAttributes = Support::doAttribute('id', "tt-content-edit-$uid") .
Support::doAttribute('class', 'hidden') .
Support::doAttribute('method', 'post') .
......@@ -2193,7 +2193,7 @@ class QuickFormQuery {
*/
private function getModalCode() {
$iconGearRelToApp = Path::appToExt('Resources/Public/icons/gear.svg');
$iconGearRelToApp = Path::urlExt('Resources/Public/icons/gear.svg');
$code = <<<EOF
<!-- Modal -->
......
......@@ -1675,7 +1675,7 @@ EOF;
// Check for SIP encoded download link or persistent download link
if ($vars[NAME_SIP] == '1') {
// SIP encoded.
$vars[NAME_URL] = Path::appToApi(API_DOWNLOAD_PHP);
$vars[NAME_URL] = Path::urlApi(API_DOWNLOAD_PHP);
} else {
// Persistent Download Link
if ($vars[NAME_DOWNLOAD] == '') {
......@@ -1684,7 +1684,8 @@ EOF;
// Check if there is a shortcut version defined like d:dl.php/123.
if (strstr($vars[NAME_DOWNLOAD], '.php/') === false) {
// Set the default: API_DOWNLOAD_PHP
$vars[NAME_URL] = Path::appToApi(API_DOWNLOAD_PHP) . '/' . $vars[NAME_DOWNLOAD];
// example.com/typo3conf/ext/qfq/api/download.php/file1
$vars[NAME_URL] = Path::urlApi(API_DOWNLOAD_PHP, $vars[NAME_DOWNLOAD]);
} else {
// Take given shortcut
$vars[NAME_URL] = $vars[NAME_DOWNLOAD];
......@@ -1746,7 +1747,7 @@ EOF;
$vars[NAME_TOOL_TIP] .= PHP_EOL . PHP_EOL . $this->sip->debugSip($paramArray);
}
$source = json_encode(['uri' => Path::appToApi(API_DOWNLOAD_PHP) . '?s=' . $paramArray[SIP_SIP]]);
$source = json_encode(['uri' => Path::urlApi(API_DOWNLOAD_PHP) . '?s=' . $paramArray[SIP_SIP]]);
} else {
throw new \UserReportException("Missing content for 'copy to clipboard'", ERROR_MISSING_CONTENT);
}
......@@ -1798,7 +1799,7 @@ EOF;
$vars[NAME_ALT_TEXT] = "Bullet " . $value;
}
$vars[NAME_IMAGE] = Path::appToExt(Path::EXT_TO_PATH_ICONS) . "/bullet-" . $value . '.gif';
$vars[NAME_IMAGE] = Path::urlExt(Path::EXT_TO_PATH_ICONS) . "/bullet-" . $value . '.gif';
$vars[NAME_IMAGE_TITLE] = $value;
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
......@@ -1823,7 +1824,7 @@ EOF;
$vars[NAME_ALT_TEXT] = "Checked " . $value;
}
$vars[NAME_IMAGE] = Path::appToExt(Path::EXT_TO_PATH_ICONS) . "/checked-" . $value . '.gif';
$vars[NAME_IMAGE] = Path::urlExt(Path::EXT_TO_PATH_ICONS) . "/checked-" . $value . '.gif';
$vars[NAME_IMAGE_TITLE] = $value;
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
......@@ -1859,7 +1860,7 @@ EOF;
private function buildActionDelete($vars, $value) {
if ($vars[NAME_URL] == '') {
$vars[NAME_URL] = Path::appToApi(API_DELETE_PHP);
$vars[NAME_URL] = Path::urlApi(API_DELETE_PHP);
}
if (!isset($vars[NAME_LINK_CLASS])) {
......
......@@ -74,14 +74,14 @@ class Monitor {
'&' . TOKEN_L_TAIL . '=' . $vars[TOKEN_L_TAIL] .
'&' . TOKEN_L_APPEND . '=' . $vars[TOKEN_L_APPEND];
// $url = store::getSipInstance()->queryStringToSip(API_DIR . '/' . API_DOWNLOAD_PHP . '?' . $queryString, RETURN_URL);
$arr = store::getSipInstance()->queryStringToSip(Path::join(Path::JAVASCRIPT_TO_EXT, Path::extToApi(API_DOWNLOAD_PHP)) . '?' . $queryString, RETURN_ARRAY);
$arr = store::getSipInstance()->queryStringToSip(Path::join(Path::JAVASCRIPT_TO_EXT, Path::EXT_TO_API, API_DOWNLOAD_PHP) . '?' . $queryString, RETURN_ARRAY);
$url = $arr[SIP_SIP_URL];
// On page reload, take care to remove optional existing old seek position.
$key = $this->getSeekSessionKey($arr[CLIENT_SIP]);
$this->session::unsetItem($key);
$webworker = Path::appToExt(Path::EXT_TO_JAVASCRIPT, 'GetFileContent.js');
$webworker = Path::urlExt(Path::EXT_TO_JAVASCRIPT, 'GetFileContent.js');
$code = <<<EOF
<script type="text/javascript">
......
......@@ -289,7 +289,7 @@ class Thumbnail {
*/
private function buildSecureDownloadLink($pathFilenameThumbnail, $str) {
$urlParam = Path::appToApi(API_DOWNLOAD_PHP) . '?' . DOWNLOAD_MODE . '=' . DOWNLOAD_MODE_THUMBNAIL;
$urlParam = Path::urlApi(API_DOWNLOAD_PHP) . '?' . DOWNLOAD_MODE . '=' . DOWNLOAD_MODE_THUMBNAIL;
$urlParam .= '&' . SIP_DOWNLOAD_PARAMETER . '=' . base64_encode(TOKEN_FILE . ':' . $pathFilenameThumbnail . '|' . $str);
$sip = $this->store->getSipInstance();
......
......@@ -113,6 +113,8 @@ class Config {
self::$config = $config;
Path::setUrlApp(self::get(SYSTEM_BASE_URL));
// Set log paths
Path::overrideLogPathsFromConfig();
}
......
......@@ -478,7 +478,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
// _id: 1, icon: bullet-green.gif
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", "bullet-green.gif" AS "Status|icon" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" id="1-123" ><thead><tr><th>Status</th></tr></thead><tbody ><tr class="record" ><td><image src=\'typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif\'></td></tr><tr class="record" ><td><image src=\'typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif\'></td></tr></tbody></table>', $result);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" id="1-123" ><thead><tr><th>Status</th></tr></thead><tbody ><tr class="record" ><td><image src=\'http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif\'></td></tr><tr class="record" ><td><image src=\'http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif\'></td></tr></tbody></table>', $result);
// _id: 1, mailto: john@doe.com
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", "john@doe.com" AS "EMail|mailto" FROM Person ORDER BY id LIMIT 2');
......
......@@ -33,21 +33,21 @@ class HelperFileTest extends TestCase {
$this->assertEquals('', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO,''));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,''));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ,''));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON,''));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB,''));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,'fileadmin/test.js'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ, 'fileadmin/test.js'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON, 'fileadmin/test.js'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB, 'fileadmin/test.js'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.js'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.php.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.php'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.qfq'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.py'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.m'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,''));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ,''));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON,''));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB,''));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,'fileadmin/test.js'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ, 'fileadmin/test.js'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON, 'fileadmin/test.js'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB, 'fileadmin/test.js'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.js'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.php.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.php'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.qfq'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.py'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.m'));
}
public function testJoinPathFilename() {
......
......@@ -181,15 +181,15 @@ class ReportTest extends AbstractDatabaseTest {
// link, checked
$result = $this->report->process("10.sql = SELECT 'u:http://www.example.com|C' AS _link FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="http://www.example.com" ><img alt="Checked green" src="typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif" title="green" ></a>', $result);
$this->assertEquals('<a href="http://www.example.com" ><img alt="Checked green" src="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif" title="green" ></a>', $result);
// linck, checked, text
$result = $this->report->process("10.sql = SELECT 'u:http://www.example.com|C|t:Hello World' AS _link FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="http://www.example.com" ><img alt="Checked green" src="typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif" title="green" > Hello World</a>', $result);
$this->assertEquals('<a href="http://www.example.com" ><img alt="Checked green" src="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif" title="green" > Hello World</a>', $result);
// link, checked, text, tooltip
$result = $this->report->process("10.sql = SELECT 'u:http://www.example.com|C|t:Hello World|o:more information' AS _link FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="http://www.example.com" title="more information" ><img alt="Checked green" src="typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif" title="more information" > Hello World</a>', $result);
$this->assertEquals('<a href="http://www.example.com" title="more information" ><img alt="Checked green" src="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif" title="more information" > Hello World</a>', $result);
}
/**
......@@ -418,17 +418,17 @@ EOF;
// 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);
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" ><img alt="Bullet green" src="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/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);
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" ><img alt="Bullet green" src="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/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);
$this->assertEquals("<a href=\"index.php?id=form&s=badcaffee1234\" ><img alt=\"Bullet $color\" src=\"http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/typo3conf/ext/qfq/Resources/Public/icons/bullet-$color.gif\" title=\"$color\" ></a>", $result);
}
}
......@@ -449,17 +449,17 @@ EOF;
// 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);
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" ><img alt="Checked green" src="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/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);
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" ><img alt="Checked green" src="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/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);
$this->assertEquals("<a href=\"index.php?id=form&s=badcaffee1234\" ><img alt=\"Checked $color\" src=\"http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/typo3conf/ext/qfq/Resources/Public/icons/checked-$color.gif\" title=\"$color\" ></a>", $result);
}
}
......@@ -540,15 +540,15 @@ EOF;
// 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);
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" ><img src="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/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);
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" ><img src="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/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);
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" ><img alt="Hello World" src="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif" title="green" > Person</a>', $result);
}
/**
......@@ -704,7 +704,7 @@ EOF;
// 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);
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" >Person <img alt="Bullet green" src="http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/typo3conf/ext/qfq/Resources/Public/icons/bullet-green.gif" title="green" ></a>', $result);
}
......@@ -932,7 +932,7 @@ EOF;
// _paged: incl. alert
$result = $this->report->process("10.sql = SELECT 'U:table=Person&r=123' AS _paged FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="' . Path::appToApi(API_DELETE_PHP) . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
$this->assertEquals('<a href="' . Path::urlApi(API_DELETE_PHP) . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
// Check das via '_paged' SIP_MODE_ANSWER and SIP_TARGET_URL has been set.
$result = Session::get('badcaffee1234');
......@@ -940,7 +940,7 @@ EOF;
// _paged: incl. alert
$result = $this->report->process("10.sql = SELECT 'U:form=Person&r=123' AS _paged FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="' . Path::appToApi(API_DELETE_PHP) . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
$this->assertEquals('<a href="' . Path::urlApi(API_DELETE_PHP) . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
// _paged: other than defaults for the alert.
$js = str_replace('Do you really want to delete the record?', 'Move to trash?', $js);
......@@ -951,11 +951,11 @@ EOF;
$js = str_replace('modal: true', 'modal: false', $js);
$js = str_replace("type: 'warning'", "type: 'success'", $js);
$result = $this->report->process("10.sql = SELECT 'U:table=Person&r=123|q:Move to trash?:success:yes:no:10:0' AS _paged FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="' . Path::appToApi(API_DELETE_PHP) . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
$this->assertEquals('<a href="' . Path::urlApi(API_DELETE_PHP) . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
$result = $this->report->process("10.sql = SELECT 'U:table=Person&r=123|q:Move to trash?:success:yes:no:10:0|t:click me' AS _paged FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="' . Path::appToApi(API_DELETE_PHP) . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span> click me</a>', $result);
$this->assertEquals('<a href="' . Path::urlApi(API_DELETE_PHP) . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span> click me</a>', $result);
}
/**
......@@ -988,7 +988,7 @@ EOF;
// _Paged: incl. alert
$result = $this->report->process("10.sql = SELECT 'table=Person&r=123' AS _Paged FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="' . Path::appToApi(API_DELETE_PHP) . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
$this->assertEquals('<a href="' . Path::urlApi(API_DELETE_PHP) . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
// _Paged: other than defaults for the alert.
$js = str_replace('Do you really want to delete the record?', 'Move to trash?', $js);
......@@ -999,11 +999,11 @@ EOF;
$js = str_replace('modal: true', 'modal: false', $js);
$js = str_replace("type: 'warning'", "type: 'success'", $js);
$result = $this->report->process("10.sql = SELECT 'table=Person&r=123|||Move to trash?:success:yes:no:10:0' AS _Paged FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="' . Path::appToApi(API_DELETE_PHP) . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
$this->assertEquals('<a href="' . Path::urlApi(API_DELETE_PHP) . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
$result = $this->report->process("10.sql = SELECT 'table=Person&r=123|click me||Move to trash?:success:yes:no:10:0' AS _Paged FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="' . Path::appToApi(API_DELETE_PHP) . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span> click me</a>', $result);
$this->assertEquals('<a href="' . Path::urlApi(API_DELETE_PHP) . '?s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span> click me</a>', $result);
// Empty string is ok
$result = $this->report->process("10.sql = SELECT '' AS _Paged FROM Person ORDER BY id LIMIT 1");
......@@ -1345,7 +1345,7 @@ EOF;
foreach ($arr as $color) {
// bullet $color
$result = $this->report->process("10.sql = SELECT '$color' AS _bullet FROM Person ORDER BY id LIMIT 1");
$this->assertEquals("<img alt=\"Bullet $color\" src=\"typo3conf/ext/qfq/Resources/Public/icons/bullet-$color.gif\" title=\"$color\" >", $result);
$this->assertEquals("<img alt=\"Bullet $color\" src=\"http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/typo3conf/ext/qfq/Resources/Public/icons/bullet-$color.gif\" title=\"$color\" >", $result);
}
}
......@@ -1368,7 +1368,7 @@ EOF;
foreach ($arr as $color) {
// check $color
$result = $this->report->process("10.sql = SELECT '$color' AS _check FROM Person ORDER BY id LIMIT 1");
$this->assertEquals("<img alt=\"Checked $color\" src=\"typo3conf/ext/qfq/Resources/Public/icons/checked-$color.gif\" title=\"$color\" >", $result);
$this->assertEquals("<img alt=\"Checked $color\" src=\"http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx/qfq/typo3conf/ext/qfq/Resources/Public/icons/checked-$color.gif\" title=\"$color\" >", $result);
}
}
......