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

Refs #11035 replace all paths from Constans.php with Path:: functions

parent 4abb17bd
Pipeline #3707 failed with stages
in 2 minutes and 57 seconds
......@@ -17,9 +17,13 @@ require_once(__DIR__ . '/../../vendor/autoload.php');
use http\Exception;
use IMATHUZH\Qfq\Core\QuickFormQuery;
// TODO: use Path:: for paths that are defined in config
// TODO: replace the above change of constants with better method
// TODO: replace all paths with typo3conf/ and /../ and fileadmin/ with correct path computing function.
// TODO: replace HelperFile::correctRelativePathFileName() everywhere with the corresponding path function.
// TODO: replace Logger::makePathAbsolute()
// TODO: rename extRelToCwd() to extRelToApp() ?? or extRelToIndex() ?? extRelToUrl ??
// TODO: Compare Support::joinPath with Path::join
// TODO: Read code in Core/Typo3
// TODO: comment out autoloader in T3Handler::t3AutoloadIfNotRunning() and test if this file still runs without exception.
// TODO: create filePathToQfqConfig() and replace config references with this
......@@ -29,6 +33,7 @@ use IMATHUZH\Qfq\Core\QuickFormQuery;
// TODO: Check if there are other javascript files which have to be included in qfq/Resources/Public/JavaScript
// TODO: BuildFormBootstrap.php Zeile 666 ff. : API pfad automatisch anpassen
// TODO: Link.php 1776: API pfad automatisch anpassen
// TODO: Monitor.php 77: Wird path. I don't know relativ to what it should be
// Misc.
// TODO: TablesorterController.js: pass API url as data attribute instead of hardcode (this.tablesorterApiUrl = 'typo3conf/ext/qfq/Classes/Api/setting.php';)
......
......@@ -16,6 +16,7 @@ use IMATHUZH\Qfq\Core\Helper\KeyValueStringParser;
use IMATHUZH\Qfq\Core\Helper\Ldap;
use IMATHUZH\Qfq\Core\Helper\Logger;
use IMATHUZH\Qfq\Core\Helper\OnArray;
use IMATHUZH\Qfq\Core\Helper\Path;
use IMATHUZH\Qfq\Core\Helper\Sanitize;
use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Report\Link;
......@@ -632,7 +633,7 @@ abstract class AbstractBuildForm {
*/
public function getActionUrl() {
return API_DIR . '/save.php';
return Path::apiRelToCwd(API_SAVE_PHP);
}
/**
......@@ -2544,7 +2545,7 @@ abstract class AbstractBuildForm {
}
if (isset($control[SUBRECORD_COLUMN_ICON][$columnName])) {
$cell = ($cell === '') ? '' : "<image src='" . PATH_ICONS . "/$cell'>";
$cell = ($cell === '') ? '' : "<image src='" . Path::extRelToCwd(PATH_ICONS_REL_TO_EXT) . "/$cell'>";
}
if (isset($control[SUBRECORD_COLUMN_MAILTO][$columnName])) {
......@@ -2594,7 +2595,7 @@ abstract class AbstractBuildForm {
$sip = $this->store->getSipInstance();
return $sip->queryStringToSip($queryString, $mode, API_DIR . '/' . API_DELETE_PHP);
return $sip->queryStringToSip($queryString, $mode, Path::apiRelToCwd(API_DELETE_PHP));
}
/**
......@@ -2994,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(API_DIR . '/' . API_DOWNLOAD_PHP . '?' . KeyValueStringParser::unparse($param, '=', '&'), RETURN_URL);
$url = $this->sip->queryStringToSip(Path::apiRelToCwd(API_DOWNLOAD_PHP) . '?' . KeyValueStringParser::unparse($param, '=', '&'), RETURN_URL);
return $url;
}
......
......@@ -11,6 +11,7 @@ namespace IMATHUZH\Qfq\Core;
use IMATHUZH\Qfq\Core\Helper\HelperFormElement;
use IMATHUZH\Qfq\Core\Helper\Logger;
use IMATHUZH\Qfq\Core\Helper\OnArray;
use IMATHUZH\Qfq\Core\Helper\Path;
use IMATHUZH\Qfq\Core\Helper\Support;
......@@ -656,10 +657,14 @@ class BuildFormBootstrap extends AbstractBuildForm {
$actionUpload = FILE_ACTION . '=' . FILE_ACTION_UPLOAD;
$actionDelete = FILE_ACTION . '=' . FILE_ACTION_DELETE;
$apiDir = API_DIR;
$apiDeletePhp = API_DIR . '/' . API_DELETE_PHP;
$apiDeletePhp = Path::apiRelToCwd(API_DELETE_PHP);
$dirtyAction = ($this->formSpec[F_DIRTY_MODE] == DIRTY_MODE_NONE) ? '' : "dirtyUrl: '$apiDir/dirty.php',";
$dirtyAction = ($this->formSpec[F_DIRTY_MODE] == DIRTY_MODE_NONE) ? '' : "dirtyUrl: '" . Path::apiRelToCwd(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;
$html .= '</form>'; // <form class="form-horizontal" ...
$html .= <<<EOF
......@@ -671,12 +676,12 @@ class BuildFormBootstrap extends AbstractBuildForm {
var qfqPage = new QfqNS.QfqPage({
tabsId: '$tabId',
formId: '$formId',
submitTo: '$apiDir/save.php',
submitTo: '$submitTo',
$dirtyAction
deleteUrl: '$deleteUrl',
refreshUrl: '$apiDir/load.php',
fileUploadTo: '$apiDir/file.php?$actionUpload',
fileDeleteUrl: '$apiDir/file.php?$actionDelete'
refreshUrl: '$refreshUrl',
fileUploadTo: '$fileUploadTo',
fileDeleteUrl: '$fileDeleteUrl'
});
......
......@@ -11,11 +11,13 @@ const CONFIG_QFQ_INI = "config.qfq.ini"; // QFQ configuration file: db access -
const CONFIG_QFQ_PHP = "config.qfq.php"; // QFQ configuration file: db access
const CONFIG_T3 = 'LocalConfiguration.php'; // T3 config file
const GFX_INFO = 'typo3conf/ext/qfq/Resources/Public/icons/note.gif';
const API_DIR = 'typo3conf/ext/qfq/Classes/Api';
const API_DIR_EXT = 'Classes/Api';
const GFX_INFO = 'typo3conf/ext/qfq/Resources/Public/icons/note.gif'; // Deprecated! Use Path::extRelToCwd(GFX_INFO_REL_TO_EXT) instead!
const GFX_INFO_REL_TO_EXT = 'Resources/Public/icons/note.gif';
const API_DIR = 'typo3conf/ext/qfq/Classes/Api'; // Deprecated! Use Path::apiRelToCwd() instead!
const API_DIR_EXT = 'Classes/Api'; // Deprecated! Use Path::apiRelToExt() instead!
const PATH_ICONS = 'typo3conf/ext/qfq/Resources/Public/icons';
const PATH_ICONS = 'typo3conf/ext/qfq/Resources/Public/icons'; // Deprecated! Use Path::extRelToCwd(PATH_ICONS_REL_TO_EXT) instead!
const PATH_ICONS_REL_TO_EXT = 'Resources/Public/icons';
const QFQ_TEMP_FILE_PATTERN = 'qfq.split.XXXXX';
const QFQ_TEMP_SOURCE = '.temp.source';
......@@ -490,7 +492,8 @@ const SYSTEM_DB_INDEX_QFQ = "indexQfq";
//const SYSTEM_DB_INDEX_DATA_DEPRECATED = "DB_INDEX_DATA";
//const SYSTEM_DB_INDEX_QFQ_DEPRECATED = "DB_INDEX_QFQ";
const SYSTEM_FILEADMIN_PROTECTED_LOG = 'fileadmin/protected/log';
const SYSTEM_FILEADMIN_PROTECTED_LOG = 'fileadmin/protected/log'; // Deprecated! Use: Path::appRelToCwd(SYSTEM_FILEADMIN_PROTECTED_LOG_REL_TO_APP)
const SYSTEM_FILEADMIN_PROTECTED_LOG_REL_TO_APP = 'fileadmin/protected/log';
// Automatically filled by QFQ
const SYSTEM_DB_NAME_DATA = 'dbNameData';
......@@ -498,13 +501,16 @@ const SYSTEM_DB_NAME_QFQ = 'dbNameQfq';
const SYSTEM_DB_NAME_T3 = 'dbNameT3';
const SYSTEM_QFQ_LOG = 'qfqLog'; // Logging to file
const SYSTEM_QFQ_LOG_FILE = 'fileadmin/protected/log/qfq.log';
const SYSTEM_QFQ_LOG_FILE = 'fileadmin/protected/log/qfq.log'; // Deprecated! Use: Path::appRelToCwd(SYSTEM_QFQ_LOG_FILE_REL_TO_APP)
const SYSTEM_QFQ_LOG_FILE_REL_TO_APP = 'fileadmin/protected/log/qfq.log';
const SYSTEM_MAIL_LOG = 'mailLog';
const SYSTEM_MAIL_LOG_FILE = 'fileadmin/protected/log/mail.log';
const SYSTEM_MAIL_LOG_FILE = 'fileadmin/protected/log/mail.log'; // Deprecated! Use: Path::appRelToCwd(SYSTEM_MAIL_LOG_FILE_REL_TO_APP)
const SYSTEM_MAIL_LOG_FILE_REL_TO_APP = 'fileadmin/protected/log/mail.log';
const SYSTEM_SQL_LOG = 'sqlLog'; // Logging to file
const SYSTEM_SQL_LOG_FILE = 'fileadmin/protected/log/sql.log';
const SYSTEM_SQL_LOG_FILE = 'fileadmin/protected/log/sql.log'; // Deprecated! Use: Path::appRelToCwd(SYSTEM_SQL_LOG_FILE_REL_TO_APP)
const SYSTEM_SQL_LOG_FILE_REL_TO_APP = 'fileadmin/protected/log/sql.log';
const SYSTEM_SQL_LOG_MODE = 'sqlLogMode'; // Mode, which statements to log.
const SYSTEM_SQL_LOG_MODE_AUTOCRON = 'sqlLogModeAutoCron'; // Mode, which statements to log in AutoCron Environments.
......@@ -653,9 +659,11 @@ const SYSTEM_CMD_PDFUNITE = 'cmdPdfunite';
// Thumbnail
const SYSTEM_THUMBNAIL_DIR_SECURE = 'thumbnailDirSecure';
const SYSTEM_THUMBNAIL_DIR_SECURE_DEFAULT = 'fileadmin/protected/qfqThumbnail';
const SYSTEM_THUMBNAIL_DIR_SECURE_DEFAULT = 'fileadmin/protected/qfqThumbnail'; // Deprecated! Use: Path::appRelToCwd(SYSTEM_THUMBNAIL_DIR_SECURE_DEFAULT_REL_TO_APP)
const SYSTEM_THUMBNAIL_DIR_SECURE_DEFAULT_REL_TO_APP = 'fileadmin/protected/qfqThumbnail';
const SYSTEM_THUMBNAIL_DIR_PUBLIC = 'thumbnailDirPublic';
const SYSTEM_THUMBNAIL_DIR_PUBLIC_DEFAULT = 'typo3temp/qfqThumbnail';
const SYSTEM_THUMBNAIL_DIR_PUBLIC_DEFAULT = 'typo3temp/qfqThumbnail'; // Deprecated! Use: Path::appRelToCwd(SYSTEM_THUMBNAIL_DIR_PUBLIC_DEFAULT_REL_TO_APP)
const SYSTEM_THUMBNAIL_DIR_PUBLIC_DEFAULT_REL_TO_APP = 'typo3temp/qfqThumbnail';
// Form/Report as file
const SYSTEM_QFQ_PROJECT_DIR_SECURE = 'qfqProjectDir'; // where form and report files are saved
......@@ -804,6 +812,10 @@ const MODE_LDAP_MULTI = 'ldapMulti';
// api/save.php, api/delete.php, api/load.php
const API_DELETE_PHP = 'delete.php';
const API_DIRTY_PHP = 'dirty.php';
const API_SAVE_PHP = 'save.php';
const API_LOAD_PHP = 'load.php';
const API_FILE_PHP = 'file.php';
const API_DOWNLOAD_PHP = 'download.php';
const API_DRAG_AND_DROP_PHP = 'dragAndDrop.php';
......@@ -1472,7 +1484,8 @@ const COLUMN_PATH_FILE_NAME = 'pathFileName';
const EXISTING_PATH_FILE_NAME = '_existingPathFileName';
const THUMBNAIL_WIDTH_DEFAULT = '150x';
const THUMBNAIL_UNKNOWN_TYPE = 'typo3/sysext/frontend/Resources/Public/Icons/FileIcons/';
const THUMBNAIL_UNKNOWN_TYPE = 'typo3/sysext/frontend/Resources/Public/Icons/FileIcons/'; // Deprecated! Use: Path::appRelToCwd(THUMBNAIL_UNKNOWN_TYPE_REL_TO_APP)
const THUMBNAIL_UNKNOWN_TYPE_REL_TO_APP = 'typo3/sysext/frontend/Resources/Public/Icons/FileIcons/';
const THUMBNAIL_MAX_SECONDS = 60;
const THUMBNAIL_PREPARE = 'prepare';
const THUMBNAIL_VIA_DOWNLOAD = 'secureFile';
......@@ -1889,7 +1902,8 @@ const AUTOCRON_COUNT = 'count';
// Annotate
const ANNOTATE_GRAPHIC_CSS_CLASS = 'annotate-graphic'; // Ex 'fabric'
const ANNOTATE_TEXT_CSS_CLASS = 'annotate-text'; // Ex 'codeCorrection
const DIR_HIGHLIGHT_JSON = 'typo3conf/ext/qfq/Resources/Public/Json';
const DIR_HIGHLIGHT_JSON = 'typo3conf/ext/qfq/Resources/Public/Json'; // Deprecated! Use: Path::appRelToCwd(DIR_HIGHLIGHT_JSON_REL_TO_APP)
const DIR_HIGHLIGHT_JSON_REL_TO_APP = 'typo3conf/ext/qfq/Resources/Public/Json';
// DataImport
const IMPORT_MODE_APPEND = 'append';
......
......@@ -1044,7 +1044,7 @@ class Database {
* @throws \UserFormException
*/
public function getQfqLogFile() {
return ($this->store == null) ? SYSTEM_QFQ_LOG_FILE : $this->store->getVar(SYSTEM_QFQ_LOG, STORE_SYSTEM);
return ($this->store == null) ? Path::appRelToCwd(SYSTEM_QFQ_LOG_FILE_REL_TO_APP) : $this->store->getVar(SYSTEM_QFQ_LOG, STORE_SYSTEM);
}
/**
......
......@@ -10,6 +10,7 @@ namespace IMATHUZH\Qfq\Core\Database;
use IMATHUZH\Qfq\Core\Form\FormAsFile;
use IMATHUZH\Qfq\Core\Helper\Logger;
use IMATHUZH\Qfq\Core\Helper\Path;
use IMATHUZH\Qfq\Core\Store\Store;
use IMATHUZH\Qfq\Core\Typo3\T3Handler;
......@@ -293,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, SYSTEM_FILEADMIN_PROTECTED_LOG . '/' . date("YmdHi") . '_special_columns_auto_update.html');
Logger::logMessage($message, Path::appRelToCwd(SYSTEM_FILEADMIN_PROTECTED_LOG_REL_TO_APP) . '/' . date("YmdHi") . '_special_columns_auto_update.html');
} elseif ($actionSpecialColumn === ACTION_SPECIAL_COLUMN_DO_SKIP_REPLACE) {
// do nothing
} else {
......@@ -305,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 ' . SYSTEM_FILEADMIN_PROTECTED_LOG . ' after the automatic replacement.'
. ' This report will be saved in ' . Path::appRelToCwd(SYSTEM_FILEADMIN_PROTECTED_LOG_REL_TO_APP) . ' 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>'
......
......@@ -11,6 +11,7 @@ namespace IMATHUZH\Qfq\Core;
use IMATHUZH\Qfq\Core\Database\Database;
use IMATHUZH\Qfq\Core\Helper\KeyValueStringParser;
use IMATHUZH\Qfq\Core\Helper\OnString;
use IMATHUZH\Qfq\Core\Helper\Path;
use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Report\Link;
use IMATHUZH\Qfq\Core\Report\Tablesorter;
......@@ -292,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 . '="' . API_DIR . '/' . API_DRAG_AND_DROP_PHP . '?s=' . $s . '"';
return DND_DATA_DND_API . '="' . Path::apiRelToCwd(API_DRAG_AND_DROP_PHP) . '?s=' . $s . '"';
}
/**
......
......@@ -8,6 +8,7 @@
namespace IMATHUZH\Qfq\Core\Exception;
use IMATHUZH\Qfq\Core\Helper\Path;
use IMATHUZH\Qfq\Core\QuickFormQuery;
use IMATHUZH\Qfq\Core\Store\Store;
use IMATHUZH\Qfq\Core\Store\Sip;
......@@ -189,7 +190,7 @@ class AbstractException extends \Exception {
}
}
$qfqLog = ($store == null) ? SYSTEM_QFQ_LOG_FILE : $store->getVar(SYSTEM_QFQ_LOG, STORE_SYSTEM);
$qfqLog = ($store == null) ? Path::appRelToCwd(SYSTEM_QFQ_LOG_FILE_REL_TO_APP) : $store->getVar(SYSTEM_QFQ_LOG, STORE_SYSTEM);
$arrDebugHidden[EXCEPTION_STACKTRACE] = PHP_EOL . implode($arrTrace, PHP_EOL);
$arrLogAll = array_merge($arrMsg, $arrShow, $arrDebugShow, $arrDebugHidden);
$logAll = OnArray::arrayToLog($arrLogAll);
......
......@@ -145,65 +145,14 @@ class HelperFile {
return $pathFileName;
}
$length = strlen('/' . API_DIR_EXT);
if (substr(getcwd(), -$length) == '/' . API_DIR_EXT) {
$length = strlen('/' . Path::apiRelToExt());
if (substr(getcwd(), -$length) == '/' . Path::apiRelToExt()) {
return '../../../../../' . $pathFileName;
}
return $pathFileName;
}
public static function overrideExtPath(string $path)
{
// const QFQ_EXT_DOMAIN_PATH_GLOBALS_KEY = "qfq_path_to_extension_directory_relative_to_domain_root";
// const QFQ_EXT_FILE_PATH_GLOBALS_KEY = "qfq_absolute_file_path_to_extension_directory";
// const APPLICATION_DOMAIN_PATH_GLOBALS_KEY = "qfq_absolute_file_path_to_application_root_directory";
// const APPLICATION_FILE_PATH_GLOBALS_KEY = "qfq_absolute_file_path_to_application_root_directory";
// $GLOBALS[];
// TODO: if global with key not exists, then set path to global. Only the first time this function is called it has en effect.
}
private static function pathRelToExt(string $path, bool $urlPath): string
{
if (empty($path) || $path === './') {
// TODO: return path to ext
}
// TODO: get path from global or constant
// TODO: join path
}
private static function pathRelToApp(string $path, bool $urlPath): 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);
}
/**
* Split $pathFileName into it's components and fill an array, with array keys like used in STORE_VAR.
*
......@@ -526,7 +475,7 @@ class HelperFile {
}
if (isset($extToFileType[$ext])) {
return DIR_HIGHLIGHT_JSON . '/' . $extToFileType[$ext];
return Path::appRelToCwd(DIR_HIGHLIGHT_JSON_REL_TO_APP) . '/' . $extToFileType[$ext];
}
return '';
......
......@@ -112,7 +112,7 @@ class Logger {
if (self::$systemSitePath == '') {
if (defined('PHPUNIT_QFQ')) {
if (strpos(getcwd(), 'qfq/' . API_DIR_EXT) !== false) {
if (strpos(getcwd(), 'qfq/' . Path::apiRelToExt()) !== false) {
return ('../../../../../' . $filename);
}
return $filename;
......
<?php
namespace IMATHUZH\Qfq\Core\Helper;
/*
Path::apiRelToCwd(API_SAVE_PHP) === API_DIR . '/save.php'
Path::apiRelToCwd(API_LOAD_PHP) === API_DIR . '/load.php'
Path::apiRelToCwd(API_FILE_PHP) . '?' . $actionUpload === API_DIR . '/file.php?' . $actionUpload
Path::apiRelToCwd(API_FILE_PHP) . '?' . $actionDelete === API_DIR . '/file.php?' . $actionDelete
Path::apiRelToCwd(API_DIRTY_PHP) === API_DIR . "/" . API_DIRTY_PHP
Path::apiRelToCwd(API_DRAG_AND_DROP_PHP) === API_DIR . '/' . API_DRAG_AND_DROP_PHP
Path::apiRelToCwd(API_SAVE_PHP) === API_DIR . "/" . "save.php"
Path::apiRelToCwd(API_DOWNLOAD_PHP) === API_DIR . '/' . API_DOWNLOAD_PHP
Path::apiRelToCwd(API_DELETE_PHP) === API_DIR . '/' . API_DELETE_PHP
Path::apiRelToExt() === API_DIR_EXT
Path::apiRelToExt(API_DOWNLOAD_PHP) === API_DIR_EXT . '/' . API_DOWNLOAD_PHP
Path::extRelToCwd(GFX_INFO_REL_TO_EXT) === GFX_INFO
Path::extRelToCwd(PATH_ICONS_REL_TO_EXT) === PATH_ICONS
Path::appRelToCwd(SYSTEM_FILEADMIN_PROTECTED_LOG_REL_TO_APP) === SYSTEM_FILEADMIN_PROTECTED_LOG
Path::appRelToCwd(SYSTEM_QFQ_LOG_FILE_REL_TO_APP) === SYSTEM_QFQ_LOG_FILE
Path::appRelToCwd(SYSTEM_THUMBNAIL_DIR_SECURE_DEFAULT_REL_TO_APP) === SYSTEM_THUMBNAIL_DIR_SECURE_DEFAULT
Path::appRelToCwd(SYSTEM_THUMBNAIL_DIR_PUBLIC_DEFAULT_REL_TO_APP) === SYSTEM_THUMBNAIL_DIR_PUBLIC_DEFAULT
Path::appRelToCwd(THUMBNAIL_UNKNOWN_TYPE_REL_TO_APP) === THUMBNAIL_UNKNOWN_TYPE
Path::appRelToCwd(DIR_HIGHLIGHT_JSON_REL_TO_APP) === DIR_HIGHLIGHT_JSON
*/
class Path
{
/*
public static function overrideExtPath(string $path)
{
// const QFQ_EXT_DOMAIN_PATH_GLOBALS_KEY = "qfq_path_to_extension_directory_relative_to_domain_root";
// const QFQ_EXT_FILE_PATH_GLOBALS_KEY = "qfq_absolute_file_path_to_extension_directory";
// const APPLICATION_DOMAIN_PATH_GLOBALS_KEY = "qfq_absolute_file_path_to_application_root_directory";
// const APPLICATION_FILE_PATH_GLOBALS_KEY = "qfq_absolute_file_path_to_application_root_directory";
// $GLOBALS[];
// TODO: if global with key not exists, then set path to global. Only the first time this function is called it has en effect.
}
*/
/**
* Return path relative to CWD
*
* Path::pathRelToExt("Classes/Api")
* Path::relToExt("Classes/Api")
* Path::extRelToCwd("Classes/Api")
*
*
* @param string $pathRelToExt
* @return string
*/
public static function extRelToCwd(string $pathRelToExt = ''): string
{
$extPathRelToCwd = 'typo3conf/ext/qfq';
return self::join($extPathRelToCwd, $pathRelToExt);
}
public static function apiRelToExt(string $pathRelToApi = ''): string
{
$apiPathRelToExt = 'Classes/Api';
return self::join($apiPathRelToExt, $pathRelToApi);
}
public static function apiRelToCwd(string $pathRelToApi = ''): string
{
return self::extRelToCwd(self::apiRelToExt($pathRelToApi));
}
public static function appRelToCwd(string $pathRelToExt = ''): string
{
$appPathRelToCwd = '';
return self::join($appPathRelToCwd, $pathRelToExt);
}
public static function join(): string
{
// Filter out empty string and null arguments
$pieces = array_filter(func_get_args(), function($value) { return !is_null($value) && $value !== ''; });
if (empty($pieces)) {
return '';
}
$firstPiece = array_shift($pieces);
if (empty($pieces)) {
return $firstPiece;
}
return $firstPiece . '/' . implode($pieces,'/');
}
/*
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 = SYSTEM_FILEADMIN_PROTECTED_LOG . '/' . $formName . "." . $perBeSession . "log";
$filename = Path::appRelToCwd(SYSTEM_FILEADMIN_PROTECTED_LOG_REL_TO_APP) . '/' . $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='" . GFX_INFO . "' title=\"" . htmlentities($tooltipText) . "\">";
return "<img " . self::doAttribute('id', $htmlId) . " src='" . Path::extRelToCwd(GFX_INFO_REL_TO_EXT) . "' title=\"" . htmlentities($tooltipText) . "\">";
}
/**
......
......@@ -21,6 +21,7 @@ use IMATHUZH\Qfq\Core\Helper\HelperFormElement;
use IMATHUZH\Qfq\Core\Helper\KeyValueStringParser;
use IMATHUZH\Qfq\Core\Helper\Logger;
use IMATHUZH\Qfq\Core\Helper\OnArray;
use IMATHUZH\Qfq\Core\Helper\Path;
use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Report\Monitor;
use IMATHUZH\Qfq\Core\Report\Report;
......@@ -1778,7 +1779,7 @@ class QuickFormQuery {
$form = join(' ', [$headerBar, $codeBox]);
$sipObj = new Sip;
$action = $sipObj->queryStringToSip(API_DIR . "/save.php?uid=$uid&" . REPORT_SAVE . "=1");
$action = $sipObj->queryStringToSip(Path::apiRelToCwd(API_SAVE_PHP) . "?uid=$uid&" . REPORT_SAVE . "=1");
$formAttributes = Support::doAttribute('id', "tt-content-edit-$uid") .
Support::doAttribute('class', 'hidden') .
Support::doAttribute('method', 'post') .
......
......@@ -26,6 +26,7 @@ namespace IMATHUZH\Qfq\Core\Report;
use IMATHUZH\Qfq\Core\Helper\KeyValueStringParser;
use IMATHUZH\Qfq\Core\Helper\OnArray;
use IMATHUZH\Qfq\Core\Helper\Path;
use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Helper\Token;
use IMATHUZH\Qfq\Core\Helper\Sanitize;
......@@ -1590,7 +1591,7 @@ EOF;
onclick="$('#qfqModalTitle101').text($(this).data('title')); $('#qfqModalText101').text($(this).data('text'));"
EOF;
$vars[NAME_URL] = API_DIR . '/' . API_DOWNLOAD_PHP;
$vars[NAME_URL] = Path::apiRelToCwd(API_DOWNLOAD_PHP);
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
$vars[NAME_EXTRA_CONTENT_WRAP] = '<span ' . $attributes . $onClick . '>';
......@@ -1652,7 +1653,7 @@ EOF;
$vars[NAME_TOOL_TIP] .= PHP_EOL . PHP_EOL . $this->sip->debugSip($paramArray);
}
$source = json_encode(['uri' => API_DIR . '/' . API_DOWNLOAD_PHP . '?s=' . $paramArray[SIP_SIP]]);
$source = json_encode(['uri' => Path::apiRelToCwd(API_DOWNLOAD_PHP) . '?s=' . $paramArray[SIP_SIP]]);
} else {
throw new \UserReportException("Missing content for 'copy to clipboard'", ERROR_MISSING_CONTENT);
}
......@@ -1704,7 +1705,7 @@ EOF;
$vars[NAME_ALT_TEXT] = "Bullet " . $value;
}
$vars[NAME_IMAGE] = PATH_ICONS . "/bullet-" . $value . '.gif';
$vars[NAME_IMAGE] = Path::extRelToCwd(PATH_ICONS_REL_TO_EXT) . "/bullet-" . $value . '.gif';
$vars[NAME_IMAGE_TITLE] = $value;
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
......@@ -1729,7 +1730,7 @@ EOF;
$vars[NAME_ALT_TEXT] = "Checked " . $value;
}
$vars[NAME_IMAGE] = PATH_ICONS . "/checked-" . $value . '.gif';
$vars[NAME_IMAGE] = Path::extRelToCwd(PATH_ICONS_REL_TO_EXT) . "/checked-" . $value . '.gif';
$vars[NAME_IMAGE_TITLE] = $value;
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
......@@ -1773,7 +1774,7 @@ EOF;
}
if ($vars[NAME_URL] == '') {
$vars[NAME_URL] = API_DIR . '/' . API_DELETE_PHP;
$vars[NAME_URL] = Path::apiRelToCwd(API_DELETE_PHP);
}
if (!isset($vars[NAME_LINK_CLASS])) {
......
......@@ -11,6 +11,7 @@
namespace IMATHUZH\Qfq\Core\Report;
use IMATHUZH\Qfq\Core\Helper\Path;
use IMATHUZH\Qfq\Core\Store\Session;
use IMATHUZH\Qfq\Core\Store\Store;
use IMATHUZH\Qfq\Core\Helper\Support;
......@@ -73,7 +74,7 @@ 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('../../../'. API_DIR_EXT . '/' . API_DOWNLOAD_PHP . '?' . $queryString, RETURN_ARRAY);
$arr = store::getSipInstance()->queryStringToSip('../../../'. Path::apiRelToExt(API_DOWNLOAD_PHP) . '?' . $queryString, RETURN_ARRAY);
$url = $arr[SIP_SIP_URL];
// On page reload, take care to remove optional existing old seek position.
......
......@@ -12,6 +12,7 @@ namespace IMATHUZH\Qfq\Core\Report;
use IMATHUZH\Qfq\Core\Helper\HelperFile;
use IMATHUZH\Qfq\Core\Helper\Path;
use IMATHUZH\Qfq\Core\Store\Store;