Commit 50eb6102 authored by Marc Egger's avatar Marc Egger
Browse files

Refs #12159 make url paths absolute (relative to baseUrl)

parent 095f0173
Pipeline #5205 failed with stages
in 1 minute and 57 seconds
......@@ -641,7 +641,7 @@ abstract class AbstractBuildForm {
*/
public function getActionUrl() {
return Path::appToApi(API_SAVE_PHP);
return Path::urlApi(API_SAVE_PHP);
}
/**
......@@ -2567,7 +2567,7 @@ abstract class AbstractBuildForm {
}
if (isset($control[SUBRECORD_COLUMN_ICON][$columnName])) {
$cell = ($cell === '') ? '' : "<image src='" . Path::appToExt(Path::EXT_TO_PATH_ICONS) . "/$cell'>";
$cell = ($cell === '') ? '' : "<image src='" . Path::urlExt(Path::EXT_TO_PATH_ICONS, $cell) . "'>";
}
if (isset($control[SUBRECORD_COLUMN_MAILTO][$columnName])) {
......@@ -2617,7 +2617,7 @@ abstract class AbstractBuildForm {
$sip = $this->store->getSipInstance();
return $sip->queryStringToSip($queryString, $mode, Path::appToApi(API_DELETE_PHP));
return $sip->queryStringToSip($queryString, $mode, Path::urlApi(API_DELETE_PHP));
}
/**
......@@ -2905,8 +2905,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::appToExt('Resources/Public/Json/fabric.buttons.json'));
$attributeFabric .= Support::doAttribute('data-emojis', Path::appToExt('Resources/Public/Json/qfq.emoji.json'));
$attributeFabric .= Support::doAttribute('data-buttons', Path::urlExt('Resources/Public/Json/fabric.buttons.json'));
$attributeFabric .= Support::doAttribute('data-emojis', Path::urlExt('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) {
......@@ -2971,7 +2971,7 @@ abstract class AbstractBuildForm {
// data-image-output="target-png">
// </div>
$attributeFabric = Support::doAttribute('class', ANNOTATE_GRAPHIC_CSS_CLASS);
$attributeFabric .= Support::doAttribute('data-buttons', Path::appToExt('Resources/Public/Json/fabric.editor.buttons.json'));
$attributeFabric .= Support::doAttribute('data-buttons', Path::urlExt('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);
......@@ -3017,7 +3017,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::appToApi(API_DOWNLOAD_PHP) . '?' . KeyValueStringParser::unparse($param, '=', '&'), RETURN_URL);
$url = $this->sip->queryStringToSip(Path::urlApi(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::appToApi(API_DELETE_PHP);
$apiDeletePhp = Path::urlApi(API_DELETE_PHP);
$dirtyAction = ($this->formSpec[F_DIRTY_MODE] == DIRTY_MODE_NONE) ? '' : "dirtyUrl: '" . Path::appToApi(API_DIRTY_PHP) . "',";
$dirtyAction = ($this->formSpec[F_DIRTY_MODE] == DIRTY_MODE_NONE) ? '' : "dirtyUrl: '" . Path::urlApi(API_DIRTY_PHP) . "',";
$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;
$submitTo = Path::urlApi(API_SAVE_PHP);
$refreshUrl = Path::urlApi(API_LOAD_PHP);
$fileUploadTo = Path::urlApi(API_FILE_PHP) . '?' . $actionUpload;
$fileDeleteUrl = Path::urlApi(API_FILE_PHP) . '?' . $actionDelete;
$html .= '</form>'; // <form class="form-horizontal" ...
$html .= <<<EOF
......
......@@ -318,7 +318,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::appToApi(API_DRAG_AND_DROP_PHP) . '?s=' . $s . '"';
return DND_DATA_DND_API . '="' . Path::urlApi(API_DRAG_AND_DROP_PHP) . '?s=' . $s . '"';
}
/**
......
......@@ -457,7 +457,7 @@ class HelperFile {
}
if (isset($extToFileType[$ext])) {
return Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/' . $extToFileType[$ext];
return Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/' . $extToFileType[$ext];
}
return '';
......
......@@ -9,8 +9,11 @@ namespace IMATHUZH\Qfq\Core\Helper;
* - Ext: directory in which the QFQ extension is loacted. e.g. the folder Classes is in there.
* - 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.
* Conventions of Path class:
* 1) naming conventions of of path constants/functions/variables:
* a) name a path by its origin and its destination separated by 'to'. E.g. APP_TO_SYSTEM_LOG, $appToProject.
* b) Or only by its destination and prefix "absolute" if the path is absolute e.g. absoluteApp().
* c) Or by its destination and prefix "url" if the path returns a fully qualified url using the base path e.g. urlExt().
* 2) if the destination is a file, append "File". E.g. APP_TO_SYSTEM_QFQ_LOG_FILE.
* 3) if a path has to be variable, create a setter and getter. E.g. self::setAbsoluteApp(), self::absoluteApp(), private static $absoluteApp.
* 4) a path getter appends the given arguments to the requested path using self::join(..., func_get_args()). E.g. see absoluteApp().
......@@ -25,8 +28,8 @@ use IMATHUZH\Qfq\Core\Store\Config;
class Path
{
// App
// This is manually set in self::setMainPaths()
private static $absoluteApp = null;
private static $absoluteApp = null; // This is manually set in self::setMainPaths()
private static $urlApp = null;
// Extension
const APP_TO_EXT = 'typo3conf/ext/qfq';
......@@ -221,14 +224,25 @@ class Path
return self::join(self::APP_TO_EXT, $pathPartsToAppend);
}
/**
* If the base url is not set then use relative path.
*
* @param mixed ...$pathPartsToAppend
* @return string
*/
public static function urlApp(...$pathPartsToAppend): string
{
return self::join(self::$urlApp ?? '', $pathPartsToAppend);
}
/**
* @param array $pathPartsToAppend
* @return string
* @throws \UserFormException
*/
public static function extToApi(...$pathPartsToAppend): string
public static function urlExt(...$pathPartsToAppend): string
{
return self::join(self::EXT_TO_API, $pathPartsToAppend);
return self::urlApp(self::appToExt($pathPartsToAppend));
}
/**
......@@ -241,6 +255,16 @@ class Path
return self::join(self::APP_TO_EXT, self::EXT_TO_API, $pathPartsToAppend);
}
/**
* @param array $pathPartsToAppend
* @return string
* @throws \UserFormException
*/
public static function urlApi(...$pathPartsToAppend): string
{
return self::urlApp(self::appToApi($pathPartsToAppend));
}
/**
* @param mixed ...$pathPartsToAppend
* @return string
......@@ -307,6 +331,14 @@ class Path
self::$overloadAbsoluteMailLogFile = $newPath;
}
/**
* @param $urlApp
*/
public static function setUrlApp($urlApp)
{
self::$urlApp = $urlApp;
}
/**
* Override the paths of sql.log, qfq.log, mail.log using the values from the config file or Typo3.
*
......@@ -390,8 +422,16 @@ class Path
}
});
// remove multiple occurrences of '/'
return preg_replace('/\/{2,}/','/', $path);
// remove multiple occurrences of '/' (but keep http://)
if (preg_match('/^\w*:\/\//', $path, $match) ) {
$protocol = $match[0];
$path = substr($path, strlen($protocol));
} else {
$protocol = '';
}
$path = preg_replace('/\/{2,}/','/', $path);
return $protocol . $path;
}
/////////////////////////////////////////////////// Private //////////////////////////////////////////////////////
......@@ -414,7 +454,6 @@ class Path
/**
* @param string $newPath
* @return string
*/
private static function setAbsoluteLog(string $newPath)
{
......
......@@ -233,10 +233,11 @@ class Support {
*
* @return string
* @throws \CodeException
* @throws \UserFormException
*/
public static function doTooltip($htmlId, $tooltipText) {
return "<img " . self::doAttribute('id', $htmlId) . " src='" . Path::appToExt(Path::EXT_TO_GFX_INFO_FILE) . "' title=\"" . htmlentities($tooltipText) . "\">";
return "<img " . self::doAttribute('id', $htmlId) . " src='" . Path::urlExt(Path::EXT_TO_GFX_INFO_FILE) . "' title=\"" . htmlentities($tooltipText) . "\">";
}
/**
......
......@@ -1772,7 +1772,7 @@ class QuickFormQuery {
$form = join(' ', [$headerBar, $codeBox]);
$sipObj = new Sip;
$action = $sipObj->queryStringToSip(Path::appToApi(API_SAVE_PHP) . "?uid=$uid&" . REPORT_SAVE . "=1&" . REPORT_SAVE_FILE . "=" . (is_null($reportPathFileNameFull) ? 0 : 1));
$action = $sipObj->queryStringToSip(Path::urlApi(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') .
......@@ -2193,7 +2193,7 @@ class QuickFormQuery {
*/
private function getModalCode() {
$iconGearRelToApp = Path::appToExt('Resources/Public/icons/gear.svg');
$iconGearRelToApp = Path::urlExt('Resources/Public/icons/gear.svg');
$code = <<<EOF
<!-- Modal -->
......
......@@ -1675,7 +1675,7 @@ EOF;
// Check for SIP encoded download link or persistent download link
if ($vars[NAME_SIP] == '1') {
// SIP encoded.
$vars[NAME_URL] = Path::appToApi(API_DOWNLOAD_PHP);
$vars[NAME_URL] = Path::urlApi(API_DOWNLOAD_PHP);
} else {
// Persistent Download Link
if ($vars[NAME_DOWNLOAD] == '') {
......@@ -1684,7 +1684,8 @@ EOF;
// Check if there is a shortcut version defined like d:dl.php/123.
if (strstr($vars[NAME_DOWNLOAD], '.php/') === false) {
// Set the default: API_DOWNLOAD_PHP
$vars[NAME_URL] = Path::appToApi(API_DOWNLOAD_PHP) . '/' . $vars[NAME_DOWNLOAD];
// example.com/typo3conf/ext/qfq/api/download.php/file1
$vars[NAME_URL] = Path::urlApi(API_DOWNLOAD_PHP, $vars[NAME_DOWNLOAD]);
} else {
// Take given shortcut
$vars[NAME_URL] = $vars[NAME_DOWNLOAD];
......@@ -1746,7 +1747,7 @@ EOF;
$vars[NAME_TOOL_TIP] .= PHP_EOL . PHP_EOL . $this->sip->debugSip($paramArray);
}
$source = json_encode(['uri' => Path::appToApi(API_DOWNLOAD_PHP) . '?s=' . $paramArray[SIP_SIP]]);
$source = json_encode(['uri' => Path::urlApi(API_DOWNLOAD_PHP) . '?s=' . $paramArray[SIP_SIP]]);
} else {
throw new \UserReportException("Missing content for 'copy to clipboard'", ERROR_MISSING_CONTENT);
}
......@@ -1798,7 +1799,7 @@ EOF;
$vars[NAME_ALT_TEXT] = "Bullet " . $value;
}
$vars[NAME_IMAGE] = Path::appToExt(Path::EXT_TO_PATH_ICONS) . "/bullet-" . $value . '.gif';
$vars[NAME_IMAGE] = Path::urlExt(Path::EXT_TO_PATH_ICONS) . "/bullet-" . $value . '.gif';
$vars[NAME_IMAGE_TITLE] = $value;
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
......@@ -1823,7 +1824,7 @@ EOF;
$vars[NAME_ALT_TEXT] = "Checked " . $value;
}
$vars[NAME_IMAGE] = Path::appToExt(Path::EXT_TO_PATH_ICONS) . "/checked-" . $value . '.gif';
$vars[NAME_IMAGE] = Path::urlExt(Path::EXT_TO_PATH_ICONS) . "/checked-" . $value . '.gif';
$vars[NAME_IMAGE_TITLE] = $value;
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
......@@ -1859,7 +1860,7 @@ EOF;
private function buildActionDelete($vars, $value) {
if ($vars[NAME_URL] == '') {
$vars[NAME_URL] = Path::appToApi(API_DELETE_PHP);
$vars[NAME_URL] = Path::urlApi(API_DELETE_PHP);
}
if (!isset($vars[NAME_LINK_CLASS])) {
......
......@@ -74,14 +74,14 @@ 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(Path::join(Path::JAVASCRIPT_TO_EXT, Path::extToApi(API_DOWNLOAD_PHP)) . '?' . $queryString, RETURN_ARRAY);
$arr = store::getSipInstance()->queryStringToSip(Path::join(Path::JAVASCRIPT_TO_EXT, Path::EXT_TO_API, API_DOWNLOAD_PHP) . '?' . $queryString, RETURN_ARRAY);
$url = $arr[SIP_SIP_URL];
// On page reload, take care to remove optional existing old seek position.
$key = $this->getSeekSessionKey($arr[CLIENT_SIP]);
$this->session::unsetItem($key);
$webworker = Path::appToExt(Path::EXT_TO_JAVASCRIPT, 'GetFileContent.js');
$webworker = Path::urlExt(Path::EXT_TO_JAVASCRIPT, 'GetFileContent.js');
$code = <<<EOF
<script type="text/javascript">
......
......@@ -289,7 +289,7 @@ class Thumbnail {
*/
private function buildSecureDownloadLink($pathFilenameThumbnail, $str) {
$urlParam = Path::appToApi(API_DOWNLOAD_PHP) . '?' . DOWNLOAD_MODE . '=' . DOWNLOAD_MODE_THUMBNAIL;
$urlParam = Path::urlApi(API_DOWNLOAD_PHP) . '?' . DOWNLOAD_MODE . '=' . DOWNLOAD_MODE_THUMBNAIL;
$urlParam .= '&' . SIP_DOWNLOAD_PARAMETER . '=' . base64_encode(TOKEN_FILE . ':' . $pathFilenameThumbnail . '|' . $str);
$sip = $this->store->getSipInstance();
......
......@@ -113,6 +113,8 @@ class Config {
self::$config = $config;
Path::setUrlApp(self::get(SYSTEM_BASE_URL));
// Set log paths
Path::overrideLogPathsFromConfig();
}
......
......@@ -33,21 +33,21 @@ class HelperFileTest extends TestCase {
$this->assertEquals('', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO,''));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,''));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ,''));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON,''));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB,''));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,'fileadmin/test.js'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ, 'fileadmin/test.js'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON, 'fileadmin/test.js'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB, 'fileadmin/test.js'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.js'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.php.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.php'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.qfq'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.py'));
$this->assertEquals(Path::appToExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.m'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,''));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ,''));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON,''));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB,''));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_JAVASCRIPT,'fileadmin/test.js'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_QFQ, 'fileadmin/test.js'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_PYTHON, 'fileadmin/test.js'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_MATLAB, 'fileadmin/test.js'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/javascript.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.js'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.php.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.php'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.qfq.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.qfq'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.py.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.py'));
$this->assertEquals(Path::urlExt(Path::EXT_TO_HIGHLIGHT_JSON) . '/highlight.m.json', HelperFile::getFileTypeHighlight(FE_HIGHLIGHT_AUTO, 'fileadmin/test.m'));
}
public function testJoinPathFilename() {
......
......@@ -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::appToApi(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::urlApi(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::appToApi(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::urlApi(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::appToApi(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::urlApi(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::appToApi(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::urlApi(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::appToApi(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::urlApi(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::appToApi(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::urlApi(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::appToApi(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::urlApi(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");
......
Markdown is supported
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