diff --git a/extension/Classes/Core/AbstractBuildForm.php b/extension/Classes/Core/AbstractBuildForm.php index 833dd891a251ced1db5cb531296cbcce2ada6489..786522b25a1682a2afc6706e2db0f9b8e197eed2 100644 --- a/extension/Classes/Core/AbstractBuildForm.php +++ b/extension/Classes/Core/AbstractBuildForm.php @@ -2545,7 +2545,7 @@ abstract class AbstractBuildForm { } if (isset($control[SUBRECORD_COLUMN_ICON][$columnName])) { - $cell = ($cell === '') ? '' : "<image src='" . Path::cwdToExt(Path::EXT_TO_PATH_ICONS) . "/$cell'>"; + $cell = ($cell === '') ? '' : "<image src='" . Path::appToExt(Path::EXT_TO_PATH_ICONS) . "/$cell'>"; } if (isset($control[SUBRECORD_COLUMN_MAILTO][$columnName])) { @@ -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', 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-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-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', Path::cwdToExt('Resources/Public/Json/fabric.editor.buttons.json')); + $attributeFabric .= Support::doAttribute('data-buttons', Path::appToExt('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); diff --git a/extension/Classes/Core/Database/DatabaseUpdate.php b/extension/Classes/Core/Database/DatabaseUpdate.php index a8408d72bc6a3a7fc4fb8fbdb2cd6e6f9bb01883..0194bf2ced16532643f52b2e382aac208848821e 100644 --- a/extension/Classes/Core/Database/DatabaseUpdate.php +++ b/extension/Classes/Core/Database/DatabaseUpdate.php @@ -365,7 +365,7 @@ class DatabaseUpdate { $functionsHashTest = null; } - $qfqFunctionSqlRelToApp = Path::cwdToExt('Classes/Sql/' . QFQ_FUNCTION_SQL); + $qfqFunctionSqlRelToApp = Path::appToExt('Classes/Sql/' . QFQ_FUNCTION_SQL); if ($functionHash !== null AND $functionsHashTest === $functionHash) { return $functionHash; diff --git a/extension/Classes/Core/Helper/HelperFile.php b/extension/Classes/Core/Helper/HelperFile.php index 29c99b4dc20ea9e318e299d915cc1c709e847cd6..8622218ae79697bbac7c78ea7df1cf4fe25630f3 100644 --- a/extension/Classes/Core/Helper/HelperFile.php +++ b/extension/Classes/Core/Helper/HelperFile.php @@ -453,7 +453,7 @@ class HelperFile { } if (isset($extToFileType[$ext])) { - return Path::cwdToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/' . $extToFileType[$ext]; + return Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/' . $extToFileType[$ext]; } return ''; diff --git a/extension/Classes/Core/Helper/Path.php b/extension/Classes/Core/Helper/Path.php index a75100a99569669e6a7f6ade82c50c77ff3c0cef..19fa8cab3fc2331e87f2474ac2d9df4b62943e3f 100644 --- a/extension/Classes/Core/Helper/Path.php +++ b/extension/Classes/Core/Helper/Path.php @@ -4,6 +4,12 @@ namespace IMATHUZH\Qfq\Core\Helper; /* + * Glossar: + * - App: directory in which the index.php file is located. All urls should be relative to this. + * - Ext: directory in which the QFQ extension is loacted. e.g. the folder Classes is in there. + * - CWD: current working directory + * - 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. * 2) if the destination is a file, append "File". E.g. APP_TO_SYSTEM_QFQ_LOG_FILE. @@ -186,6 +192,15 @@ class Path return self::cwdToApp(self::appToProject(func_get_args())); } + /** + * @return string + * @throws \UserFormException + */ + public static function appToExt(/* path parts to append */): string + { + return self::join(self::APP_TO_EXT, func_get_args()); + } + /** * @return string * @throws \UserFormException diff --git a/extension/Classes/Core/Helper/Support.php b/extension/Classes/Core/Helper/Support.php index cdfe705fb16d2f8d422aac2056e7116004d3d91b..e96cb15ce4c32da4ceda4b05e58a934e2024735b 100644 --- a/extension/Classes/Core/Helper/Support.php +++ b/extension/Classes/Core/Helper/Support.php @@ -236,7 +236,7 @@ class Support { */ public static function doTooltip($htmlId, $tooltipText) { - return "<img " . self::doAttribute('id', $htmlId) . " src='" . Path::cwdToExt(Path::EXT_TO_GFX_INFO_FILE) . "' title=\"" . htmlentities($tooltipText) . "\">"; + return "<img " . self::doAttribute('id', $htmlId) . " src='" . Path::appToExt(Path::EXT_TO_GFX_INFO_FILE) . "' title=\"" . htmlentities($tooltipText) . "\">"; } /** diff --git a/extension/Classes/Core/QuickFormQuery.php b/extension/Classes/Core/QuickFormQuery.php index a9f44f3695d2b20cdd11fb5e993054874483c230..d09d00fa8b893ffab5facbd2f16438b24b2b6a8e 100644 --- a/extension/Classes/Core/QuickFormQuery.php +++ b/extension/Classes/Core/QuickFormQuery.php @@ -2139,7 +2139,7 @@ class QuickFormQuery { */ private function getModalCode() { - $iconGearRelToCwd = Path::cwdToExt('Resources/Public/icons/gear.svg'); + $iconGearRelToApp = Path::appToExt('Resources/Public/icons/gear.svg'); $code = <<<EOF <!-- Modal --> @@ -2151,7 +2151,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="$iconGearRelToCwd"> + <img class="qfq-icon-gear glyphicon-spin" src="$iconGearRelToApp"> <p id="qfqModalText101">Document is being generated. Please wait.</p> </div> <div class="modal-footer"> diff --git a/extension/Classes/Core/Report/Link.php b/extension/Classes/Core/Report/Link.php index f739b38b0881a70e5f6425e71a4ff45622e08a8a..5134b3a3dd83f6461e7dfc69a2daa604137cd0d1 100644 --- a/extension/Classes/Core/Report/Link.php +++ b/extension/Classes/Core/Report/Link.php @@ -1781,7 +1781,7 @@ EOF; $vars[NAME_ALT_TEXT] = "Bullet " . $value; } - $vars[NAME_IMAGE] = Path::cwdToExt(Path::EXT_TO_PATH_ICONS) . "/bullet-" . $value . '.gif'; + $vars[NAME_IMAGE] = Path::appToExt(Path::EXT_TO_PATH_ICONS) . "/bullet-" . $value . '.gif'; $vars[NAME_IMAGE_TITLE] = $value; $vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS; @@ -1806,7 +1806,7 @@ EOF; $vars[NAME_ALT_TEXT] = "Checked " . $value; } - $vars[NAME_IMAGE] = Path::cwdToExt(Path::EXT_TO_PATH_ICONS) . "/checked-" . $value . '.gif'; + $vars[NAME_IMAGE] = Path::appToExt(Path::EXT_TO_PATH_ICONS) . "/checked-" . $value . '.gif'; $vars[NAME_IMAGE_TITLE] = $value; $vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS; diff --git a/extension/Classes/Core/Report/Monitor.php b/extension/Classes/Core/Report/Monitor.php index 4d666020e68554467c2f53f660932256b8e3c81f..5048ee7e2bdb523d777cb2d546111dbcf88e0cfd 100644 --- a/extension/Classes/Core/Report/Monitor.php +++ b/extension/Classes/Core/Report/Monitor.php @@ -81,7 +81,7 @@ class Monitor { $key = $this->getSeekSessionKey($arr[CLIENT_SIP]); $this->session::unsetItem($key); - $webworker = Path::cwdToExt('Resources/Public/JavaScript/GetFileContent.js'); + $webworker = Path::appToExt('Resources/Public/JavaScript/GetFileContent.js'); $code = <<<EOF <script type="text/javascript"> diff --git a/extension/Tests/Unit/Core/Helper/HelperFileTest.php b/extension/Tests/Unit/Core/Helper/HelperFileTest.php index bc12425b1bc1c7d2498aa5ed7ffb2ec9313d3b33..d8c68cdd71434360bf1f34daa6850278e4350b86 100644 --- a/extension/Tests/Unit/Core/Helper/HelperFileTest.php +++ b/extension/Tests/Unit/Core/Helper/HelperFileTest.php @@ -33,21 +33,21 @@ class HelperFileTest extends TestCase { $this->assertEquals('', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO,'')); - $this->assertEquals(Path::cwdToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,'')); - $this->assertEquals(Path::cwdToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ,'')); - $this->assertEquals(Path::cwdToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON,'')); - $this->assertEquals(Path::cwdToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB,'')); - - $this->assertEquals(Path::cwdToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,'fileadmin/test.js')); - $this->assertEquals(Path::cwdToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ, 'fileadmin/test.js')); - $this->assertEquals(Path::cwdToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON, 'fileadmin/test.js')); - $this->assertEquals(Path::cwdToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB, 'fileadmin/test.js')); - - $this->assertEquals(Path::cwdToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.js')); - $this->assertEquals(Path::cwdToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.php.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.php')); - $this->assertEquals(Path::cwdToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.qfq')); - $this->assertEquals(Path::cwdToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.py')); - $this->assertEquals(Path::cwdToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.m')); + $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,'')); + $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ,'')); + $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON,'')); + $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB,'')); + + $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,'fileadmin/test.js')); + $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ, 'fileadmin/test.js')); + $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON, 'fileadmin/test.js')); + $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB, 'fileadmin/test.js')); + + $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.js')); + $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.php.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.php')); + $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.qfq')); + $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.py')); + $this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON_DIR) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.m')); } public function testJoinPathFilename() {