Commit c0afbe31 authored by Marc Egger's avatar Marc Egger
Browse files

Refs #11035 rename Path:: functions and constants from {a}relTo{b} to {b}to{a}.

parent 611d0131
Pipeline #3716 failed with stages
in 2 minutes and 41 seconds
......@@ -633,7 +633,7 @@ abstract class AbstractBuildForm {
*/
public function getActionUrl() {
return Path::apiRelToCwd(API_SAVE_PHP);
return Path::cwdToApi(API_SAVE_PHP);
}
/**
......@@ -2545,7 +2545,7 @@ abstract class AbstractBuildForm {
}
if (isset($control[SUBRECORD_COLUMN_ICON][$columnName])) {
$cell = ($cell === '') ? '' : "<image src='" . Path::extRelToCwd(Path::PATH_ICONS_REL_TO_EXT) . "/$cell'>";
$cell = ($cell === '') ? '' : "<image src='" . Path::cwdToExt(Path::EXT_TO_PATH_ICONS) . "/$cell'>";
}
if (isset($control[SUBRECORD_COLUMN_MAILTO][$columnName])) {
......@@ -2595,7 +2595,7 @@ abstract class AbstractBuildForm {
$sip = $this->store->getSipInstance();
return $sip->queryStringToSip($queryString, $mode, Path::apiRelToCwd(API_DELETE_PHP));
return $sip->queryStringToSip($queryString, $mode, Path::cwdToApi(API_DELETE_PHP));
}
/**
......@@ -2883,8 +2883,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', 'typo3conf/ext/qfq/Resources/Public/Json/fabric.buttons.json');
$attributeFabric .= Support::doAttribute('data-emojis', 'typo3conf/ext/qfq/Resources/Public/Json/qfq.emoji.json');
$attributeFabric .= Support::doAttribute('data-buttons', Path::cwdToExt('Resources/Public/Json/fabric.buttons.json'));
$attributeFabric .= Support::doAttribute('data-emojis', Path::cwdToExt('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) {
......@@ -2949,7 +2949,7 @@ abstract class AbstractBuildForm {
// data-image-output="target-png">
// </div>
$attributeFabric = Support::doAttribute('class', ANNOTATE_GRAPHIC_CSS_CLASS);
$attributeFabric .= Support::doAttribute('data-buttons', 'typo3conf/ext/qfq/Resources/Public/Json/fabric.editor.buttons.json');
$attributeFabric .= Support::doAttribute('data-buttons', Path::cwdToExt('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);
......@@ -2995,7 +2995,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::apiRelToCwd(API_DOWNLOAD_PHP) . '?' . KeyValueStringParser::unparse($param, '=', '&'), RETURN_URL);
$url = $this->sip->queryStringToSip(Path::cwdToApi(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::apiRelToCwd(API_DELETE_PHP);
$apiDeletePhp = Path::cwdToApi(API_DELETE_PHP);
$dirtyAction = ($this->formSpec[F_DIRTY_MODE] == DIRTY_MODE_NONE) ? '' : "dirtyUrl: '" . Path::apiRelToCwd(API_DIRTY_PHP) . "',";
$dirtyAction = ($this->formSpec[F_DIRTY_MODE] == DIRTY_MODE_NONE) ? '' : "dirtyUrl: '" . Path::cwdToApi(API_DIRTY_PHP) . "',";
$submitTo = Path::apiRelToCwd(API_SAVE_PHP);
$refreshUrl = Path::apiRelToCwd(API_LOAD_PHP);
$fileUploadTo = Path::apiRelToCwd(API_FILE_PHP) . '?' . $actionUpload;
$fileDeleteUrl = Path::apiRelToCwd(API_FILE_PHP) . '?' . $actionDelete;
$submitTo = Path::cwdToApi(API_SAVE_PHP);
$refreshUrl = Path::cwdToApi(API_LOAD_PHP);
$fileUploadTo = Path::cwdToApi(API_FILE_PHP) . '?' . $actionUpload;
$fileDeleteUrl = Path::cwdToApi(API_FILE_PHP) . '?' . $actionDelete;
$html .= '</form>'; // <form class="form-horizontal" ...
$html .= <<<EOF
......
......@@ -549,7 +549,7 @@ const SYSTEM_EDIT_FORM_PAGE = 'editFormPage';
// computed automatically during runtime
const SYSTEM_EXT_PATH_ABSOLUTE = 'extPath';
const SYSTEM_SITE_PATH_ABSOLUTE = 'sitePath';
const SYSTEM_SITE_PATH_ABSOLUTE = 'sitePath'; // Path of the App
const SYSTEM_LDAP_1_RDN = 'LDAP_1_RDN'; // Credentials to access LDAP
const SYSTEM_LDAP_1_PASSWORD = 'LDAP_1_PASSWORD'; // Credentials to access LDAP
......
......@@ -1045,7 +1045,7 @@ class Database {
* @throws \UserFormException
*/
public function getQfqLogFile() {
return ($this->store == null) ? Path::appRelToCwd(Path::SYSTEM_QFQ_LOG_FILE_REL_TO_APP) : $this->store->getVar(SYSTEM_QFQ_LOG_ABSOLUTE, STORE_SYSTEM);
return ($this->store == null) ? Path::cwdToApp(Path::APP_TO_SYSTEM_QFQ_LOG_FILE) : $this->store->getVar(SYSTEM_QFQ_LOG_ABSOLUTE, STORE_SYSTEM);
}
/**
......
......@@ -294,7 +294,7 @@ class DatabaseUpdate {
if ($actionSpecialColumn === ACTION_SPECIAL_COLUMN_DO_REPLACE) {
// save log file
$message = '<h1>Special column names replaced</h1>The following special column names were replaced.<hr>' . $message;
Logger::logMessage($message, Path::appRelToCwd(Path::SYSTEM_LOG_REL_TO_APP) . '/' . date("YmdHi") . '_special_columns_auto_update.html');
Logger::logMessage($message, Path::cwdToApp(Path::APP_TO_SYSTEM_LOG) . '/' . date("YmdHi") . '_special_columns_auto_update.html');
} elseif ($actionSpecialColumn === ACTION_SPECIAL_COLUMN_DO_SKIP_REPLACE) {
// do nothing
} else {
......@@ -306,7 +306,7 @@ class DatabaseUpdate {
. 'Click <a href="?' . http_build_query(array_merge($_GET, array(ACTION_SPECIAL_COLUMN_UPDATE => ACTION_SPECIAL_COLUMN_DO_REPLACE))) . '">Auto-Replace</a>'
. ' to automatically prepend the found column names with an underscore.'
. ' In the report below the missing underscores are marked by "<span style="font-weight: bold; color: red;">>>>_</span>".'
. ' This report will be saved in ' . Path::appRelToCwd(Path::SYSTEM_LOG_REL_TO_APP) . ' after the automatic replacement.'
. ' This report will be saved in ' . Path::cwdToApp(Path::APP_TO_SYSTEM_LOG) . ' after the automatic replacement.'
. ' <br><br>To update qfq without changing the special columns (your app will probably be broken): '
. '<a href="?' . http_build_query(array_merge($_GET, array(ACTION_SPECIAL_COLUMN_UPDATE => ACTION_SPECIAL_COLUMN_DO_SKIP_REPLACE))) . '">Skip Auto-Replace</a>'
. '<h2>Report</h2>'
......@@ -365,6 +365,8 @@ class DatabaseUpdate {
$functionsHashTest = null;
}
$qfqFunctionSqlRelToApp = Path::cwdToExt('Classes/Sql/' . QFQ_FUNCTION_SQL);
if ($functionHash !== null AND $functionsHashTest === $functionHash) {
return $functionHash;
} else {
......@@ -374,7 +376,7 @@ class DatabaseUpdate {
"Possible solutions: <ul>" .
'<li>Grant SUPER, CREATE ROUTINE, ALTER ROUTINE privileges to qfq mysql user temporarily.</li>' .
'<li>Play the following file manually on the database: ' .
'<a href="typo3conf/ext/qfq/Classes/Sql/' . QFQ_FUNCTION_SQL . '">typo3conf/ext/qfq/Classes/Sql/' . QFQ_FUNCTION_SQL . '</a><br>and grant the qfq mysql user execution privileges on the sql functions.</li>' .
'<a href="' . $qfqFunctionSqlRelToApp . '">' . $qfqFunctionSqlRelToApp . '</a><br>and grant the qfq mysql user execution privileges on the sql functions.</li>' .
'<li><a href="?' . http_build_query(array_merge($_GET, array(ACTION_FUNCTION_UPDATE => ACTION_FUNCTION_UPDATE_NEXT_UPDATE))) . '">Click here</a> to skip the sql functions update until next qfq release update</li>' .
'<li><a href="?' . http_build_query(array_merge($_GET, array(ACTION_FUNCTION_UPDATE => ACTION_FUNCTION_UPDATE_NEVER))) . '">Click here</a> to skip the sql functions update forever</li>' .
'</ul>' .
......
......@@ -293,7 +293,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::apiRelToCwd(API_DRAG_AND_DROP_PHP) . '?s=' . $s . '"';
return DND_DATA_DND_API . '="' . Path::cwdToApi(API_DRAG_AND_DROP_PHP) . '?s=' . $s . '"';
}
/**
......
......@@ -190,7 +190,7 @@ class AbstractException extends \Exception {
}
}
$qfqLog = ($store == null) ? Path::appRelToCwd(Path::SYSTEM_QFQ_LOG_FILE_REL_TO_APP) : $store->getVar(SYSTEM_QFQ_LOG_ABSOLUTE, STORE_SYSTEM);
$qfqLog = ($store == null) ? Path::cwdToApp(Path::APP_TO_SYSTEM_QFQ_LOG_FILE) : $store->getVar(SYSTEM_QFQ_LOG_ABSOLUTE, STORE_SYSTEM);
$arrDebugHidden[EXCEPTION_STACKTRACE] = PHP_EOL . implode($arrTrace, PHP_EOL);
$arrLogAll = array_merge($arrMsg, $arrShow, $arrDebugShow, $arrDebugHidden);
$logAll = OnArray::arrayToLog($arrLogAll);
......@@ -260,7 +260,7 @@ class AbstractException extends \Exception {
$trace = $this->getTraceAsString();
$arrTrace = explode(PHP_EOL, $trace);
return OnArray::filterValueSubstring($arrTrace, '/typo3conf/ext/' . EXT_KEY . '/');
return OnArray::filterValueSubstring($arrTrace, Path::APP_TO_EXT);
}
/**
......
......@@ -610,8 +610,8 @@ class FormAsFile
*/
private static function formPath(Database $database): string
{
$qfqProjectDirRelToCwd = Path::appRelToCwd(Store::getInstance()->getVar(SYSTEM_QFQ_PROJECT_DIR_SECURE_REL_TO_APP, STORE_SYSTEM));
$formPath = Path::join($qfqProjectDirRelToCwd, Path::FORM_REL_TO_PROJECT_DIR);
$qfqProjectDirRelToCwd = Path::cwdToApp(Store::getInstance()->getVar(SYSTEM_QFQ_PROJECT_DIR_SECURE_REL_TO_APP, STORE_SYSTEM));
$formPath = Path::join($qfqProjectDirRelToCwd, Path::PROJECT_DIR_TO_FORM);
if (!is_dir($formPath)) {
// create path
......
......@@ -102,25 +102,25 @@ class HelperFile {
/**
* Returns an array with filestat information to $pathFileName
*
* @param $pathFileName
* @param $pathFileNameRelToApp
* @return array
* @throws \UserFormException
*/
public static function getFileStat($pathFileName) {
public static function getFileStat($pathFileNameRelToApp) {
$vars = [VAR_FILE_MIME_TYPE => '-', VAR_FILE_SIZE => '-'];
if (empty($pathFileName)) {
if (empty($pathFileNameRelToApp)) {
return $vars;
}
$pathFileName = self::correctRelativePathFileName($pathFileName);
$pathFileNameRelToApp = Path::cwdToApp($pathFileNameRelToApp);
if (!file_exists($pathFileName)) {
if (!file_exists($pathFileNameRelToApp)) {
return $vars;
}
$vars[VAR_FILE_MIME_TYPE] = self::getMimeType($pathFileName);
$vars[VAR_FILE_SIZE] = filesize($pathFileName);
$vars[VAR_FILE_MIME_TYPE] = self::getMimeType($pathFileNameRelToApp);
$vars[VAR_FILE_SIZE] = filesize($pathFileNameRelToApp);
if ($vars[VAR_FILE_SIZE] === false) {
$vars[VAR_FILE_SIZE] = '-';
......@@ -129,30 +129,6 @@ class HelperFile {
return $vars;
}
/**
* Correct $pathFilename, if the cwd is .../qfq/Api'
*
* @param $pathFileName
* @return string
*/
public static function correctRelativePathFileName($pathFileName) {
if (empty($pathFileName)) {
return '';
}
if ($pathFileName[0] == '/') {
return $pathFileName;
}
$length = strlen('/' . Path::apiRelToExt());
if (substr(getcwd(), -$length) == '/' . Path::apiRelToExt()) {
return '../../../../../' . $pathFileName;
}
return $pathFileName;
}
/**
* Split $pathFileName into it's components and fill an array, with array keys like used in STORE_VAR.
*
......@@ -475,7 +451,7 @@ class HelperFile {
}
if (isset($extToFileType[$ext])) {
return Path::appRelToCwd(Path::DIR_HIGHLIGHT_JSON_REL_TO_APP) . '/' . $extToFileType[$ext];
return Path::cwdToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/' . $extToFileType[$ext];
}
return '';
......
......@@ -26,7 +26,7 @@ class Logger {
*
* @param $path
*/
public static function setSystemSitePath($path) {
public static function setSystemSitePathAbsolute($path) {
self::$systemSitePath = $path;
}
......@@ -34,25 +34,25 @@ class Logger {
* Append $msg to $filename. Create the file it it not exist.
*
* @param $msg
* @param $filename
* @param $pathFileNameRelToCwd
*
* @param string $mode
* @param bool $recursion
* @throws \CodeException
* @throws \UserFormException
*/
public static function logMessage($msg, $filename, $mode = FILE_MODE_APPEND, $recursion = false) {
public static function logMessage($msg, $pathFileNameRelToCwd, $mode = FILE_MODE_APPEND, $recursion = false) {
$handle = false;
if ($filename == '') {
if ($pathFileNameRelToCwd == '') {
return;
}
$filename = self::makePathAbsolute($filename);
$pathFileNameRelToCwd = self::makePathAbsolute($pathFileNameRelToCwd);
try {
$handle = fopen($filename, $mode);
$handle = fopen($pathFileNameRelToCwd, $mode);
} catch (\Exception $e) {
$dummy = 1;
}
......@@ -64,21 +64,21 @@ class Logger {
if ($recursion) {
throw new \UserFormException(
json_encode([ERROR_MESSAGE_TO_USER => 'Error: cannot open file',
ERROR_MESSAGE_TO_DEVELOPER => "Error - cannot open. File: " . $filename .
ERROR_MESSAGE_TO_DEVELOPER => "Error - cannot open. File: " . $pathFileNameRelToCwd .
" ( CWD: " . getcwd() . ") - " . HelperFile::errorGetLastAsString()]),
ERROR_IO_OPEN);
}
// If open fails, maybe the directory does not exist. Create it:
HelperFile::mkDirParent($filename);
self::logMessage($msg, $filename, $mode, true);
HelperFile::mkDirParent($pathFileNameRelToCwd);
self::logMessage($msg, $pathFileNameRelToCwd, $mode, true);
return;
}
if (fwrite($handle, $msg . PHP_EOL) === false) {
throw new \UserFormException(
json_encode([ERROR_MESSAGE_TO_USER => 'Error: cannot write file',
ERROR_MESSAGE_TO_DEVELOPER => "Error - cannot open. File: " . $filename .
ERROR_MESSAGE_TO_DEVELOPER => "Error - cannot open. File: " . $pathFileNameRelToCwd .
" ( CWD: " . getcwd() . ") - " . HelperFile::errorGetLastAsString()]),
ERROR_IO_WRITE);
}
......@@ -100,33 +100,17 @@ class Logger {
}
/**
* In case $filename is not absolute and if we're in the API directory: Check if we're in api - update relative filename
* In case $pathFileNameRelToCwd is not absolute, make it absolute
*
* @param $filename
* @param $pathFileNameRelToCwd
* @return string
*/
private static function makePathAbsolute($filename) {
if (isset($filename[0]) && $filename[0] != '/') {
if (self::$systemSitePath == '') {
private static function makePathAbsolute($pathFileNameRelToCwd) {
if (defined('PHPUNIT_QFQ')) {
if (strpos(getcwd(), 'qfq/' . Path::apiRelToExt()) !== false) {
return ('../../../../../' . $filename);
}
return $filename;
}
// In case of attack detection, the config is not available - extract the installation directory from the server vars.
return dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR . $filename;
// throw new \CodeException('SystemSitePath is not set and the given logfile should be made absolute.', ERROR_MISSING_VALUE);
}
return self::$systemSitePath . DIRECTORY_SEPARATOR . $filename;
if (isset($pathFileNameRelToCwd[0]) && $pathFileNameRelToCwd[0] != '/') {
return realpath($pathFileNameRelToCwd);
}
return $filename;
return $pathFileNameRelToCwd;
}
/**
......@@ -182,7 +166,7 @@ class Logger {
foreach ([FORM_LOG_FILE_ALL, FORM_LOG_FILE_SESSION] as $filename) {
if (!empty($form[$filename])) {
Logger::logMessage($line, $form[$filename]);
Logger::logMessage($line, Path::cwdToApp($form[$filename]));
}
}
}
......
......@@ -37,66 +37,64 @@ Path::join($qfqProjectDirRelToCwd, Path::REPORT_REL_TO_PROJECT_DIR) === "../../.
class Path
{
// Default path relative to CWD
private static $appRelToCwd = '';
// Path from CWD.
// This should be manually overwritten (using Path::setCwdToApp()) if the CWD is not the one containing the typo3 index.php.
private static $cwdToApp = '';
// Extension
const EXT_REL_TO_APP = 'typo3conf/ext/qfq';
const APP_TO_EXT = 'typo3conf/ext/qfq';
// QFQ Project dir
const FORM_REL_TO_PROJECT_DIR = 'form';
const REPORT_REL_TO_PROJECT_DIR = 'report';
const PROJECT_DIR_TO_FORM = 'form';
const PROJECT_DIR_TO_REPORT = 'report';
// API
const API_REL_TO_EXT = 'Classes/Api';
const EXT_TO_API = 'Classes/Api';
// Icons
const GFX_INFO_REL_TO_EXT = 'Resources/Public/icons/note.gif';
const PATH_ICONS_REL_TO_EXT = 'Resources/Public/icons';
const EXT_TO_GFX_INFO = 'Resources/Public/icons/note.gif';
const EXT_TO_PATH_ICONS = 'Resources/Public/icons';
// Log files
const SYSTEM_LOG_REL_TO_APP = 'fileadmin/protected/log';
const SYSTEM_QFQ_LOG_FILE_REL_TO_APP = 'fileadmin/protected/log/qfq.log';
const SYSTEM_MAIL_LOG_FILE_REL_TO_APP = 'fileadmin/protected/log/mail.log';
const SYSTEM_SQL_LOG_FILE_REL_TO_APP = 'fileadmin/protected/log/sql.log';
const APP_TO_SYSTEM_LOG = 'fileadmin/protected/log';
const APP_TO_SYSTEM_QFQ_LOG_FILE = 'fileadmin/protected/log/qfq.log';
const APP_TO_SYSTEM_MAIL_LOG_FILE = 'fileadmin/protected/log/mail.log';
const APP_TO_SYSTEM_SQL_LOG_FILE = 'fileadmin/protected/log/sql.log';
// Thumbnail
const SYSTEM_THUMBNAIL_DIR_SECURE_DEFAULT_REL_TO_APP = 'fileadmin/protected/qfqThumbnail';
const SYSTEM_THUMBNAIL_DIR_PUBLIC_DEFAULT_REL_TO_APP = 'typo3temp/qfqThumbnail';
const THUMBNAIL_UNKNOWN_TYPE_REL_TO_APP = 'typo3/sysext/frontend/Resources/Public/Icons/FileIcons/';
const APP_TO_SYSTEM_THUMBNAIL_DIR_SECURE_DEFAULT = 'fileadmin/protected/qfqThumbnail';
const APP_TO_SYSTEM_THUMBNAIL_DIR_PUBLIC_DEFAULT = 'typo3temp/qfqThumbnail';
const APP_TO_THUMBNAIL_UNKNOWN_TYPE = 'typo3/sysext/frontend/Resources/Public/Icons/FileIcons/';
// Annotate
const DIR_HIGHLIGHT_JSON_REL_TO_APP = 'typo3conf/ext/qfq/Resources/Public/Json';
const EXT_TO_HIGHLIGHT_JSON_DIR = 'Resources/Public/Json';
public static function setAppRelToCwd(string $newPath)
// Twig
const EXT_TO_TWIG_TEMPLATES = 'Resources/Public/twig_templates';
public static function setCwdToApp(string $newPath)
{
self::$appRelToCwd = $newPath;
self::$cwdToApp = $newPath;
}
/**
* Return path relative to CWD
*
* @param string $pathRelToExt
* @return string
*/
public static function extRelToCwd(string $pathRelToExt = ''): string
public static function cwdToExt(string $pathRelToExt = ''): string
{
return self::join(self::appRelToCwd(self::EXT_REL_TO_APP), $pathRelToExt);
return self::join(self::cwdToApp(self::APP_TO_EXT), $pathRelToExt);
}
public static function apiRelToExt(string $pathRelToApi = ''): string
public static function extToApi(string $pathRelToApi = ''): string
{
return self::join(self::API_REL_TO_EXT, $pathRelToApi);
return self::join(self::EXT_TO_API, $pathRelToApi);
}
public static function apiRelToCwd(string $pathRelToApi = ''): string
public static function cwdToApi(string $pathRelToApi = ''): string
{
return self::extRelToCwd(self::apiRelToExt($pathRelToApi));
return self::cwdToExt(self::extToApi($pathRelToApi));
}
public static function appRelToCwd(string $pathRelToExt = ''): string
public static function cwdToApp(string $pathRelToExt = ''): string
{
return self::join(self::$appRelToCwd, $pathRelToExt);
return self::join(self::$cwdToApp, $pathRelToExt);
}
public static function join(/* path parts */): string
......@@ -127,36 +125,4 @@ class Path
// remove multiple occurances of '/'
return preg_replace('/\/{2,}/','/', $path);
}
/*
public static function appRelToCwd(string $path): string
{
if (empty($path) || $path === './') {
// TODO: return path to ext
}
// TODO: get path from global or constant
// TODO: join path
}
public static function urlPathRelToExt(string $path = ''): string
{
return self::pathRelToExt($path, true);
}
public static function filePathRelToExt(string $path = ''): string
{
return self::pathRelToExt($path, false);
}
public static function urlPathRelToApp(string $path = ''): string
{
return self::pathRelToApp($path, true);
}
public static function filePathRelToApp(string $path = ''): string
{
return self::pathRelToApp($path, false);
}
*/
}
\ No newline at end of file
......@@ -123,7 +123,7 @@ class Support {
throw new \CodeException('Unknown mode: ' . $formLogMode, ERROR_UNKNOWN_TOKEN);
}
$filename = Path::appRelToCwd(Path::SYSTEM_LOG_REL_TO_APP) . '/' . $formName . "." . $perBeSession . "log";
$filename = Path::cwdToApp(Path::APP_TO_SYSTEM_LOG) . '/' . $formName . "." . $perBeSession . "log";
return sanitize::safeFilename($filename, false, true);
}
......@@ -236,7 +236,7 @@ class Support {
*/
public static function doTooltip($htmlId, $tooltipText) {
return "<img " . self::doAttribute('id', $htmlId) . " src='" . Path::extRelToCwd(Path::GFX_INFO_REL_TO_EXT) . "' title=\"" . htmlentities($tooltipText) . "\">";
return "<img " . self::doAttribute('id', $htmlId) . " src='" . Path::cwdToExt(Path::EXT_TO_GFX_INFO) . "' title=\"" . htmlentities($tooltipText) . "\">";
}
/**
......
......@@ -1779,7 +1779,7 @@ class QuickFormQuery {
$form = join(' ', [$headerBar, $codeBox]);
$sipObj = new Sip;
$action = $sipObj->queryStringToSip(Path::apiRelToCwd(API_SAVE_PHP) . "?uid=$uid&" . REPORT_SAVE . "=1");
$action = $sipObj->queryStringToSip(Path::cwdToApi(API_SAVE_PHP) . "?uid=$uid&" . REPORT_SAVE . "=1");
$formAttributes = Support::doAttribute('id', "tt-content-edit-$uid") .
Support::doAttribute('class', 'hidden') .
Support::doAttribute('method', 'post') .
......@@ -2085,6 +2085,8 @@ class QuickFormQuery {
*/
private function getModalCode() {
$iconGearRelToCwd = Path::cwdToExt('Resources/Public/icons/gear.svg');
$code = <<<EOF
<!-- Modal -->
<div class="modal fade" id="qfqModal101" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
......@@ -2095,7 +2097,7 @@ class QuickFormQuery {
<h4 class="modal-title" id="qfqModalTitle101">Loading Document</h4>
</div>
<div class="modal-body" style="text-align: center;">
<img class="qfq-icon-gear glyphicon-spin" src="typo3conf/ext/qfq/Resources/Public/icons/gear.svg">
<img class="qfq-icon-gear glyphicon-spin" src="$iconGearRelToCwd">
<p id="qfqModalText101">Document is being generated. Please wait.</p>
</div>
<div class="modal-footer">
......
......@@ -1591,7 +1591,7 @@ EOF;
onclick="$('#qfqModalTitle101').text($(this).data('title')); $('#qfqModalText101').text($(this).data('text'));"
EOF;
$vars[NAME_URL] = Path::apiRelToCwd(API_DOWNLOAD_PHP);
$vars[NAME_URL] = Path::cwdToApi(API_DOWNLOAD_PHP);
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
$vars[NAME_EXTRA_CONTENT_WRAP] = '<span ' . $attributes . $onClick . '>';
......@@ -1653,7 +1653,7 @@ EOF;
$vars[NAME_TOOL_TIP] .= PHP_EOL . PHP_EOL . $this->sip->debugSip($paramArray);
}
$source = json_encode(['uri' => Path::apiRelToCwd(API_DOWNLOAD_PHP) . '?s=' . $paramArray[SIP_SIP]]);
$source = json_encode(['uri' => Path::cwdToApi(API_DOWNLOAD_PHP) . '?s=' . $paramArray[SIP_SIP]]);
} else {
throw new \UserReportException("Missing content for 'copy to clipboard'", ERROR_MISSING_CONTENT);
}
......@@ -1705,7 +1705,7 @@ EOF;
$vars[NAME_ALT_TEXT] = "Bullet " . $value;
}
$vars[NAME_IMAGE] = Path::extRelToCwd(Path::PATH_ICONS_REL_TO_EXT) . "/bullet-" . $value . '.gif';
$vars[NAME_IMAGE] = Path::cwdToExt(Path::EXT_TO_PATH_ICONS) . "/bullet-" . $value . '.gif';
$vars[NAME_IMAGE_TITLE] = $value;
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
......@@ -1730,7 +1730,7 @@ EOF;
$vars[NAME_ALT_TEXT] = "Checked " . $value;
}
$vars[NAME_IMAGE] = Path::extRelToCwd(Path::PATH_ICONS_REL_TO_EXT) . "/checked-" . $value . '.gif';
$vars[NAME_IMAGE] = Path::cwdToExt(Path::EXT_TO_PATH_ICONS) . "/checked-" . $value . '.gif';
$vars[NAME_IMAGE_TITLE] = $value;
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
......@@ -1774,7 +1774,7 @@ EOF;
}
if ($vars[NAME_URL] == '') {
$vars[NAME_URL] = Path::apiRelToCwd(API_DELETE_PHP);
$vars[NAME_URL] = Path::cwdToApi(API_DELETE_PHP);
}
if (!isset($vars[NAME_LINK_CLASS])) {
......