Commit 50eb6102 authored by Marc Egger's avatar Marc Egger
Browse files

Refs #12159 make url paths absolute (relative to baseUrl)

parent 095f0173
Pipeline #5205 failed with stages
in 1 minute and 57 seconds
...@@ -641,7 +641,7 @@ abstract class AbstractBuildForm { ...@@ -641,7 +641,7 @@ abstract class AbstractBuildForm {
*/ */
public function getActionUrl() { public function getActionUrl() {
return Path::appToApi(API_SAVE_PHP); return Path::urlApi(API_SAVE_PHP);
} }
/** /**
...@@ -2567,7 +2567,7 @@ abstract class AbstractBuildForm { ...@@ -2567,7 +2567,7 @@ abstract class AbstractBuildForm {
} }
if (isset($control[SUBRECORD_COLUMN_ICON][$columnName])) { 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])) { if (isset($control[SUBRECORD_COLUMN_MAILTO][$columnName])) {
...@@ -2617,7 +2617,7 @@ abstract class AbstractBuildForm { ...@@ -2617,7 +2617,7 @@ abstract class AbstractBuildForm {
$sip = $this->store->getSipInstance(); $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 { ...@@ -2905,8 +2905,8 @@ abstract class AbstractBuildForm {
$attributeFabric = Support::doAttribute('class', ANNOTATE_GRAPHIC_CSS_CLASS); $attributeFabric = Support::doAttribute('class', ANNOTATE_GRAPHIC_CSS_CLASS);
$attributeFabric .= Support::doAttribute('data-background-image', $this->fileToSipUrl($formElement[FE_IMAGE_SOURCE])); $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-control-name', $formElement[FE_HTML_ID]);
$attributeFabric .= Support::doAttribute('data-buttons', Path::appToExt('Resources/Public/Json/fabric.buttons.json')); $attributeFabric .= Support::doAttribute('data-buttons', Path::urlExt('Resources/Public/Json/fabric.buttons.json'));
$attributeFabric .= Support::doAttribute('data-emojis', Path::appToExt('Resources/Public/Json/qfq.emoji.json')); $attributeFabric .= Support::doAttribute('data-emojis', Path::urlExt('Resources/Public/Json/qfq.emoji.json'));
$attributeFabric .= Support::doAttribute('data-fabric-color', HelperFormElement::penColorToHex($formElement)); $attributeFabric .= Support::doAttribute('data-fabric-color', HelperFormElement::penColorToHex($formElement));
$attributeFabric .= HelperFormElement::getAttributeFeMode($formElement[FE_MODE]); $attributeFabric .= HelperFormElement::getAttributeFeMode($formElement[FE_MODE]);
if ($formElement[FE_MODE] == FE_MODE_READONLY) { if ($formElement[FE_MODE] == FE_MODE_READONLY) {
...@@ -2971,7 +2971,7 @@ abstract class AbstractBuildForm { ...@@ -2971,7 +2971,7 @@ abstract class AbstractBuildForm {
// data-image-output="target-png"> // data-image-output="target-png">
// </div> // </div>
$attributeFabric = Support::doAttribute('class', ANNOTATE_GRAPHIC_CSS_CLASS); $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-edit-image', 'true');
$attributeFabric .= Support::doAttribute('data-background-image', $imageFileName); $attributeFabric .= Support::doAttribute('data-background-image', $imageFileName);
$attributeFabric .= Support::doAttribute('data-control-name', $htmlFabricId); $attributeFabric .= Support::doAttribute('data-control-name', $htmlFabricId);
...@@ -3017,7 +3017,7 @@ abstract class AbstractBuildForm { ...@@ -3017,7 +3017,7 @@ abstract class AbstractBuildForm {
$param[DOWNLOAD_MODE] = DOWNLOAD_MODE_FILE; $param[DOWNLOAD_MODE] = DOWNLOAD_MODE_FILE;
$param[SIP_DOWNLOAD_PARAMETER] = base64_encode(TOKEN_FILE . PARAM_TOKEN_DELIMITER . $pathFileName); $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; return $url;
} }
......
...@@ -657,14 +657,14 @@ class BuildFormBootstrap extends AbstractBuildForm { ...@@ -657,14 +657,14 @@ class BuildFormBootstrap extends AbstractBuildForm {
$actionUpload = FILE_ACTION . '=' . FILE_ACTION_UPLOAD; $actionUpload = FILE_ACTION . '=' . FILE_ACTION_UPLOAD;
$actionDelete = FILE_ACTION . '=' . FILE_ACTION_DELETE; $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); $submitTo = Path::urlApi(API_SAVE_PHP);
$refreshUrl = Path::appToApi(API_LOAD_PHP); $refreshUrl = Path::urlApi(API_LOAD_PHP);
$fileUploadTo = Path::appToApi(API_FILE_PHP) . '?' . $actionUpload; $fileUploadTo = Path::urlApi(API_FILE_PHP) . '?' . $actionUpload;
$fileDeleteUrl = Path::appToApi(API_FILE_PHP) . '?' . $actionDelete; $fileDeleteUrl = Path::urlApi(API_FILE_PHP) . '?' . $actionDelete;
$html .= '</form>'; // <form class="form-horizontal" ... $html .= '</form>'; // <form class="form-horizontal" ...
$html .= <<<EOF $html .= <<<EOF
......
...@@ -318,7 +318,7 @@ class Evaluate { ...@@ -318,7 +318,7 @@ class Evaluate {
$this->store::setVar(SYSTEM_DRAG_AND_DROP_JS, 'true', STORE_SYSTEM); $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}}" // 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 { ...@@ -457,7 +457,7 @@ class HelperFile {
} }
if (isset($extToFileType[$ext])) { 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 ''; return '';
......
...@@ -9,8 +9,11 @@ namespace IMATHUZH\Qfq\Core\Helper; ...@@ -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. * - Ext: directory in which the QFQ extension is loacted. e.g. the folder Classes is in there.
* - API: api folder of qfq extension * - API: api folder of qfq extension
* *
* Naming convention of path constants/functions/variables: * Conventions of Path class:
* 1) name a path by its origin and its destination separated by 'to'. E.g. APP_TO_SYSTEM_LOG, $appToProject. * 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. * 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. * 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(). * 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; ...@@ -25,8 +28,8 @@ use IMATHUZH\Qfq\Core\Store\Config;
class Path class Path
{ {
// App // App
// This is manually set in self::setMainPaths() private static $absoluteApp = null; // This is manually set in self::setMainPaths()
private static $absoluteApp = null; private static $urlApp = null;
// Extension // Extension
const APP_TO_EXT = 'typo3conf/ext/qfq'; const APP_TO_EXT = 'typo3conf/ext/qfq';
...@@ -221,14 +224,25 @@ class Path ...@@ -221,14 +224,25 @@ class Path
return self::join(self::APP_TO_EXT, $pathPartsToAppend); return self::join(self::APP_TO_EXT, $pathPartsToAppend);
} }
/**
* If the base url is not set then use relative path.
*
* @param mixed ...$pathPartsToAppend
* @return string
*/
public static function urlApp(...$pathPartsToAppend): string
{
return self::join(self::$urlApp ?? '', $pathPartsToAppend);
}
/** /**
* @param array $pathPartsToAppend * @param array $pathPartsToAppend
* @return string * @return string
* @throws \UserFormException * @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 +255,16 @@ class Path ...@@ -241,6 +255,16 @@ class Path
return self::join(self::APP_TO_EXT, self::EXT_TO_API, $pathPartsToAppend); 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 * @param mixed ...$pathPartsToAppend
* @return string * @return string
...@@ -307,6 +331,14 @@ class Path ...@@ -307,6 +331,14 @@ class Path
self::$overloadAbsoluteMailLogFile = $newPath; 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. * Override the paths of sql.log, qfq.log, mail.log using the values from the config file or Typo3.
* *
...@@ -390,8 +422,16 @@ class Path ...@@ -390,8 +422,16 @@ class Path
} }
}); });
// remove multiple occurrences of '/' // remove multiple occurrences of '/' (but keep http://)
return preg_replace('/\/{2,}/','/', $path); 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 ////////////////////////////////////////////////////// /////////////////////////////////////////////////// Private //////////////////////////////////////////////////////
...@@ -414,7 +454,6 @@ class Path ...@@ -414,7 +454,6 @@ class Path
/** /**
* @param string $newPath * @param string $newPath
* @return string
*/ */
private static function setAbsoluteLog(string $newPath) private static function setAbsoluteLog(string $newPath)
{ {
......
...@@ -233,10 +233,11 @@ class Support { ...@@ -233,10 +233,11 @@ class Support {
* *
* @return string * @return string
* @throws \CodeException * @throws \CodeException
* @throws \UserFormException
*/ */
public static function doTooltip($htmlId, $tooltipText) { 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 { ...@@ -1772,7 +1772,7 @@ class QuickFormQuery {
$form = join(' ', [$headerBar, $codeBox]); $form = join(' ', [$headerBar, $codeBox]);
$sipObj = new Sip; $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") . $formAttributes = Support::doAttribute('id', "tt-content-edit-$uid") .
Support::doAttribute('class', 'hidden') . Support::doAttribute('class', 'hidden') .
Support::doAttribute('method', 'post') . Support::doAttribute('method', 'post') .
...@@ -2193,7 +2193,7 @@ class QuickFormQuery { ...@@ -2193,7 +2193,7 @@ class QuickFormQuery {
*/ */
private function getModalCode() { private function getModalCode() {
$iconGearRelToApp = Path::appToExt('Resources/Public/icons/gear.svg'); $iconGearRelToApp = Path::urlExt('Resources/Public/icons/gear.svg');
$code = <<<EOF $code = <<<EOF
<!-- Modal --> <!-- Modal -->
......
...@@ -1675,7 +1675,7 @@ EOF; ...@@ -1675,7 +1675,7 @@ EOF;
// Check for SIP encoded download link or persistent download link // Check for SIP encoded download link or persistent download link
if ($vars[NAME_SIP] == '1') { if ($vars[NAME_SIP] == '1') {
// SIP encoded. // SIP encoded.
$vars[NAME_URL] = Path::appToApi(API_DOWNLOAD_PHP); $vars[NAME_URL] = Path::urlApi(API_DOWNLOAD_PHP);
} else { } else {
// Persistent Download Link // Persistent Download Link
if ($vars[NAME_DOWNLOAD] == '') { if ($vars[NAME_DOWNLOAD] == '') {
...@@ -1684,7 +1684,8 @@ EOF; ...@@ -1684,7 +1684,8 @@ EOF;
// Check if there is a shortcut version defined like d:dl.php/123. // Check if there is a shortcut version defined like d:dl.php/123.
if (strstr($vars[NAME_DOWNLOAD], '.php/') === false) { if (strstr($vars[NAME_DOWNLOAD], '.php/') === false) {
// Set the default: API_DOWNLOAD_PHP // 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 { } else {
// Take given shortcut // Take given shortcut
$vars[NAME_URL] = $vars[NAME_DOWNLOAD]; $vars[NAME_URL] = $vars[NAME_DOWNLOAD];
...@@ -1746,7 +1747,7 @@ EOF; ...@@ -1746,7 +1747,7 @@ EOF;
$vars[NAME_TOOL_TIP] .= PHP_EOL . PHP_EOL . $this->sip->debugSip($paramArray); $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 { } else {
throw new \UserReportException("Missing content for 'copy to clipboard'", ERROR_MISSING_CONTENT); throw new \UserReportException("Missing content for 'copy to clipboard'", ERROR_MISSING_CONTENT);
} }
...@@ -1798,7 +1799,7 @@ EOF; ...@@ -1798,7 +1799,7 @@ EOF;
$vars[NAME_ALT_TEXT] = "Bullet " . $value; $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_IMAGE_TITLE] = $value;
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS; $vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
...@@ -1823,7 +1824,7 @@ EOF; ...@@ -1823,7 +1824,7 @@ EOF;
$vars[NAME_ALT_TEXT] = "Checked " . $value; $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_IMAGE_TITLE] = $value;
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS; $vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
...@@ -1859,7 +1860,7 @@ EOF; ...@@ -1859,7 +1860,7 @@ EOF;
private function buildActionDelete($vars, $value) { private function buildActionDelete($vars, $value) {
if ($vars[NAME_URL] == '') { 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])) { if (!isset($vars[NAME_LINK_CLASS])) {
......
...@@ -74,14 +74,14 @@ class Monitor { ...@@ -74,14 +74,14 @@ class Monitor {
'&' . TOKEN_L_TAIL . '=' . $vars[TOKEN_L_TAIL] . '&' . TOKEN_L_TAIL . '=' . $vars[TOKEN_L_TAIL] .
'&' . TOKEN_L_APPEND . '=' . $vars[TOKEN_L_APPEND]; '&' . TOKEN_L_APPEND . '=' . $vars[TOKEN_L_APPEND];
// $url = store::getSipInstance()->queryStringToSip(API_DIR . '/' . API_DOWNLOAD_PHP . '?' . $queryString, RETURN_URL); // $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]; $url = $arr[SIP_SIP_URL];
// On page reload, take care to remove optional existing old seek position. // On page reload, take care to remove optional existing old seek position.
$key = $this->getSeekSessionKey($arr[CLIENT_SIP]); $key = $this->getSeekSessionKey($arr[CLIENT_SIP]);
$this->session::unsetItem($key); $this->session::unsetItem($key);
$webworker = Path::appToExt(Path::EXT_TO_JAVASCRIPT, 'GetFileContent.js'); $webworker = Path::urlExt(Path::EXT_TO_JAVASCRIPT, 'GetFileContent.js');
$code = <<<EOF $code = <<<EOF
<script type="text/javascript"> <script type="text/javascript">
......
...@@ -289,7 +289,7 @@ class Thumbnail { ...@@ -289,7 +289,7 @@ class Thumbnail {
*/ */
private function buildSecureDownloadLink($pathFilenameThumbnail, $str) { 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); $urlParam .= '&' . SIP_DOWNLOAD_PARAMETER . '=' . base64_encode(TOKEN_FILE . ':' . $pathFilenameThumbnail . '|' . $str);
$sip = $this->store->getSipInstance(); $sip = $this->store->getSipInstance();
......
...@@ -113,6 +113,8 @@ class Config { ...@@ -113,6 +113,8 @@ class Config {
self::$config = $config; self::$config = $config;
Path::setUrlApp(self::get(SYSTEM_BASE_URL));
// Set log paths // Set log paths
Path::overrideLogPathsFromConfig(); Path::overrideLogPathsFromConfig();
} }
......
...@@ -33,21 +33,21 @@ class HelperFileTest extends TestCase { ...@@ -33,21 +33,21 @@ class HelperFileTest extends TestCase {
$this->assertEquals('', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO,'')); $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::urlExt(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::urlExt(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::urlExt(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::urlExt(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::urlExt(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::urlExt(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::urlExt(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::urlExt(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::urlExt(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::urlExt(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::urlExt(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::urlExt(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) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.m'));
} }
public function testJoinPathFilename() { public function testJoinPathFilename() {
......
...@@ -932,7 +932,7 @@ EOF; ...@@ -932,7 +932,7 @@ EOF;
// _paged: incl. alert // _paged: incl. alert
$result = $this->report->process("10.sql = SELECT 'U:table=Person&r=123' AS _paged FROM Person ORDER BY id LIMIT 1"); $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. // Check das via '_paged' SIP_MODE_ANSWER and SIP_TARGET_URL has been set.
$result = Session::get('badcaffee1234'); $result = Session::get('badcaffee1234');
...@@ -940,7 +940,7 @@ EOF; ...@@ -940,7 +940,7 @@ EOF;
// _paged: incl. alert // _paged: incl. alert
$result = $this->report->process("10.sql = SELECT 'U:form=Person&r=123' AS _paged FROM Person ORDER BY id LIMIT 1"); $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. // _paged: other than defaults for the alert.
$js = str_replace('Do you really want to delete the record?', 'Move to trash?', $js); $js = str_replace('Do you really want to delete the record?', 'Move to trash?', $js);
...@@ -951,11 +951,11 @@ EOF; ...@@ -951,11 +951,11 @@ EOF;
$js = str_replace('modal: true', 'modal: false', $js); $js = str_replace('modal: true', 'modal: false', $js);
$js = str_replace("type: 'warning'", "type: 'success'", $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"); $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"); $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; ...@@ -988,7 +988,7 @@ EOF;
// _Paged: incl. alert // _Paged: incl. alert
$result = $this->report->process("10.sql = SELECT 'table=Person&r=123' AS _Paged FROM Person ORDER BY id LIMIT 1"); $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. // _Paged: other than defaults for the alert.
$js = str_replace('Do you really want to delete the record?', 'Move to trash?', $js); $js = str_replace('Do you really want to delete the record?', 'Move to trash?', $js);
...@@ -999,11 +999,11 @@ EOF; ...@@ -999,11 +999,11 @@ EOF;
$js = str_replace('modal: true', 'modal: false', $js);