Commit 8810e80e authored by Marc Egger's avatar Marc Egger
Browse files

replace cwdToExt with appToExt where appropriate

parent 165ccf68
Pipeline #3890 failed with stages
in 1 minute and 57 seconds
......@@ -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);
......
......@@ -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;
......
......@@ -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 '';
......
......@@ -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
......
......@@ -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) . "\">";
}
/**
......
......@@ -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">
......
......@@ -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;
......
......@@ -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">
......
......@@ -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() {
......
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