Commit 165ccf68 authored by Marc Egger's avatar Marc Egger
Browse files

replace cwdToApi with appToApi

parent 5f0995be
Pipeline #3889 failed with stages
in 2 minutes and 6 seconds
......@@ -633,7 +633,7 @@ abstract class AbstractBuildForm {
*/
public function getActionUrl() {
return Path::cwdToApi(API_SAVE_PHP);
return Path::appToApi(API_SAVE_PHP);
}
/**
......@@ -2595,7 +2595,7 @@ abstract class AbstractBuildForm {
$sip = $this->store->getSipInstance();
return $sip->queryStringToSip($queryString, $mode, Path::cwdToApi(API_DELETE_PHP));
return $sip->queryStringToSip($queryString, $mode, Path::appToApi(API_DELETE_PHP));
}
/**
......@@ -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::cwdToApi(API_DOWNLOAD_PHP) . '?' . KeyValueStringParser::unparse($param, '=', '&'), RETURN_URL);
$url = $this->sip->queryStringToSip(Path::appToApi(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::cwdToApi(API_DELETE_PHP);
$apiDeletePhp = Path::appToApi(API_DELETE_PHP);
$dirtyAction = ($this->formSpec[F_DIRTY_MODE] == DIRTY_MODE_NONE) ? '' : "dirtyUrl: '" . Path::cwdToApi(API_DIRTY_PHP) . "',";
$dirtyAction = ($this->formSpec[F_DIRTY_MODE] == DIRTY_MODE_NONE) ? '' : "dirtyUrl: '" . Path::appToApi(API_DIRTY_PHP) . "',";
$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;
$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;
$html .= '</form>'; // <form class="form-horizontal" ...
$html .= <<<EOF
......
......@@ -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::cwdToApi(API_DRAG_AND_DROP_PHP) . '?s=' . $s . '"';
return DND_DATA_DND_API . '="' . Path::appToApi(API_DRAG_AND_DROP_PHP) . '?s=' . $s . '"';
}
/**
......
......@@ -115,14 +115,14 @@ class HelperFile {
return $vars;
}
$pathFileNameRelToApp = Path::cwdToApp($pathFileNameRelToApp);
$pathFileNameRelToCwd = Path::cwdToApp($pathFileNameRelToApp);
if (!file_exists($pathFileNameRelToApp)) {
if (!file_exists($pathFileNameRelToCwd)) {
return $vars;
}
$vars[VAR_FILE_MIME_TYPE] = self::getMimeType($pathFileNameRelToApp);
$vars[VAR_FILE_SIZE] = filesize($pathFileNameRelToApp);
$vars[VAR_FILE_MIME_TYPE] = self::getMimeType($pathFileNameRelToCwd);
$vars[VAR_FILE_SIZE] = filesize($pathFileNameRelToCwd);
if ($vars[VAR_FILE_SIZE] === false) {
$vars[VAR_FILE_SIZE] = '-';
......
......@@ -47,7 +47,7 @@ class Path
const PROJECT_DIR_TO_REPORT = 'report';
// Config
const APP_TO_TYPO3_CONFIG = 'typo3conf';
const APP_TO_TYPO3_CONF = 'typo3conf';
// Log files
private static $cwdToLog = null; // TODO: does it make sense to have it rel to CWD? to broad?
......@@ -153,7 +153,7 @@ class Path
*/
public static function cwdToLog(/* path parts to append */): string
{
self::enforcePathIsSet(self::$cwdToApp);
self::enforcePathIsSet(self::$cwdToLog);
return self::join(self::$cwdToLog, func_get_args());
}
......@@ -208,9 +208,9 @@ class Path
* @return string
* @throws \UserFormException
*/
public static function cwdToApi(/* path parts to append */): string
public static function appToApi(/* path parts to append */): string
{
return self::cwdToExt(self::extToApi(func_get_args()));
return self::join(self::APP_TO_EXT, self::EXT_TO_API, func_get_args());
}
/**
......@@ -363,16 +363,16 @@ class Path
*/
private static function findAndSetLogPath()
{
// search log dir in project
// search log dir qfqProject/log
$cwdToLog = self::cwdToProject(self::PROJECT_TO_LOG_DEFAULT);
if (file_exists($cwdToLog)) {
self::setCwdToLog($cwdToLog);
// search log dir in fileadmin/protected
// search log dir fileadmin/protected/log
} elseif (file_exists(self::cwdToApp(self::APP_TO_LOG_DEPRECATED))) {
self::setCwdToLog(self::cwdToApp(self::APP_TO_LOG_DEPRECATED));
// create default log dir
// create default log dir qfqProject/log
} else {
HelperFile::createPathRecursive($cwdToLog);
self::setCwdToLog($cwdToLog);
......@@ -393,7 +393,7 @@ class Path
self::setAppToProject(HelperFile::include($cwdToProjectPathFile));
// does the deprecated config.qfq.php exist? => migrate to qfq.json
} elseif (HelperFile::isReadableException(self::cwdToApp(self::APP_TO_TYPO3_CONFIG, CONFIG_QFQ_PHP))) {
} elseif (HelperFile::isReadableException(self::cwdToApp(self::APP_TO_TYPO3_CONF, CONFIG_QFQ_PHP))) {
self::setAppToProject(self::APP_TO_PROJECT_MIGRATE);
self::writeProjectPathPhp();
Config::migrateConfigPhpToJson();
......
......@@ -1780,7 +1780,7 @@ class QuickFormQuery {
$form = join(' ', [$headerBar, $codeBox]);
$sipObj = new Sip;
$action = $sipObj->queryStringToSip(Path::cwdToApi(API_SAVE_PHP) . "?uid=$uid&" . REPORT_SAVE . "=1&" . REPORT_SAVE_FILE . "=" . (is_null($reportPathFileNameFull) ? 0 : 1));
$action = $sipObj->queryStringToSip(Path::appToApi(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') .
......
......@@ -1667,7 +1667,7 @@ EOF;
onclick="$('#qfqModalTitle101').text($(this).data('title')); $('#qfqModalText101').text($(this).data('text'));"
EOF;
$vars[NAME_URL] = Path::cwdToApi(API_DOWNLOAD_PHP);
$vars[NAME_URL] = Path::appToApi(API_DOWNLOAD_PHP);
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
$vars[NAME_EXTRA_CONTENT_WRAP] = '<span ' . $attributes . $onClick . '>';
......@@ -1729,7 +1729,7 @@ EOF;
$vars[NAME_TOOL_TIP] .= PHP_EOL . PHP_EOL . $this->sip->debugSip($paramArray);
}
$source = json_encode(['uri' => Path::cwdToApi(API_DOWNLOAD_PHP) . '?s=' . $paramArray[SIP_SIP]]);
$source = json_encode(['uri' => Path::appToApi(API_DOWNLOAD_PHP) . '?s=' . $paramArray[SIP_SIP]]);
} else {
throw new \UserReportException("Missing content for 'copy to clipboard'", ERROR_MISSING_CONTENT);
}
......@@ -1850,7 +1850,7 @@ EOF;
}
if ($vars[NAME_URL] == '') {
$vars[NAME_URL] = Path::cwdToApi(API_DELETE_PHP);
$vars[NAME_URL] = Path::appToApi(API_DELETE_PHP);
}
if (!isset($vars[NAME_LINK_CLASS])) {
......
......@@ -289,7 +289,7 @@ class Thumbnail {
*/
private function buildSecureDownloadLink($pathFilenameThumbnail, $str) {
$urlParam = Path::cwdToApi(API_DOWNLOAD_PHP) . '?' . DOWNLOAD_MODE . '=' . DOWNLOAD_MODE_THUMBNAIL;
$urlParam = Path::appToApi(API_DOWNLOAD_PHP) . '?' . DOWNLOAD_MODE . '=' . DOWNLOAD_MODE_THUMBNAIL;
$urlParam .= '&' . SIP_DOWNLOAD_PARAMETER . '=' . base64_encode(TOKEN_FILE . ':' . $pathFilenameThumbnail . '|' . $str);
$sip = $this->store->getSipInstance();
......
......@@ -168,7 +168,7 @@ class Config {
public static function migrateConfigPhpToJson(): void
{
// read old config.qfq.php
$cwdToOldConfigFile = Path::cwdToApp(Path::APP_TO_TYPO3_CONFIG, CONFIG_QFQ_PHP);
$cwdToOldConfigFile = Path::cwdToApp(Path::APP_TO_TYPO3_CONF, CONFIG_QFQ_PHP);
HelperFile::enforce_writable($cwdToOldConfigFile); // so we can delete it.
$config = include($cwdToOldConfigFile);
......@@ -194,8 +194,8 @@ class Config {
$configT3qfq = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][EXT_KEY]);
$configT3qfq[SYSTEM_DB_NAME_T3] = self::getDbName($GLOBALS['TYPO3_CONF_VARS']['DB']);
} elseif (is_readable(Path::cwdToApp(Path::APP_TO_TYPO3_CONFIG, CONFIG_T3))) {
$cwdToTypo3ConfigFile = Path::cwdToApp(Path::APP_TO_TYPO3_CONFIG, CONFIG_T3);
} elseif (is_readable(Path::cwdToApp(Path::APP_TO_TYPO3_CONF, CONFIG_T3))) {
$cwdToTypo3ConfigFile = Path::cwdToApp(Path::APP_TO_TYPO3_CONF, CONFIG_T3);
$configT3 = HelperFile::include($cwdToTypo3ConfigFile);
$configT3qfq = unserialize($configT3['EXT']['extConf'][EXT_KEY]);
if (!is_array($configT3qfq)) {
......
......@@ -21,7 +21,7 @@ require_once(__DIR__ . '/Database/AbstractDatabaseTest.php');
*/
class DeleteTest extends AbstractDatabaseTest {
private static $previousCwdToApp = '';
private $previousCwdToApp = '';
/**
* @expectedException CodeException
......@@ -77,7 +77,7 @@ class DeleteTest extends AbstractDatabaseTest {
$this->store->setVar('form', 'TestFormName', STORE_TYPO3);
self::$previousCwdToApp = Path::cwdToApp();
$this->previousCwdToApp = Path::cwdToApp();
Path::setMainPaths('/tmp');
// The above replaces the following line with a Path:: function. Probably won't work.
// $this->store->setVar(SYSTEM_SITE_PATH_ABSOLUTE, '/tmp', STORE_SYSTEM, true);
......@@ -88,7 +88,7 @@ class DeleteTest extends AbstractDatabaseTest {
protected function tearDown()
{
parent::tearDown();
Path::setMainPaths(self::$previousCwdToApp);
Path::setMainPaths($this->previousCwdToApp);
}
}
......@@ -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::cwdToApi(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::appToApi(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::cwdToApi(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::appToApi(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::cwdToApi(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::appToApi(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::cwdToApi(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::appToApi(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::cwdToApi(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::appToApi(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::cwdToApi(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::appToApi(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::cwdToApi(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::appToApi(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");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment