Commit 1eac8e30 authored by Marc Egger's avatar Marc Egger
Browse files

Refs #9600 Edit report file using frontend editor.

parent 00d02c9d
Pipeline #3686 failed with stages
in 4 minutes and 35 seconds
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace IMATHUZH\Qfq\Core\Exception; namespace IMATHUZH\Qfq\Core\Exception;
use IMATHUZH\Qfq\Core\QuickFormQuery;
use IMATHUZH\Qfq\Core\Store\Store; use IMATHUZH\Qfq\Core\Store\Store;
use IMATHUZH\Qfq\Core\Store\Sip; use IMATHUZH\Qfq\Core\Store\Sip;
use IMATHUZH\Qfq\Core\Store\T3Info; use IMATHUZH\Qfq\Core\Store\T3Info;
...@@ -168,6 +169,11 @@ class AbstractException extends \Exception { ...@@ -168,6 +169,11 @@ class AbstractException extends \Exception {
$arrMerged[$key] = str_replace("\n", "<br>", $arrMerged[$key]); $arrMerged[$key] = str_replace("\n", "<br>", $arrMerged[$key]);
} }
// Render inline report editor
$arrMerged[ERROR_MESSAGE_TO_DEVELOPER] = QuickFormQuery::buildInlineReport(\UserReportException::$report_uid,
\UserReportException::$report_pathFileName, \UserReportException::$report_bodytext,
\UserReportException::$report_header) . $arrMerged[ERROR_MESSAGE_TO_DEVELOPER];
$htmlDebug = OnArray::arrayToHtmlTable( $htmlDebug = OnArray::arrayToHtmlTable(
array_merge($arrForm, $arrMerged), array_merge($arrForm, $arrMerged),
'Debug', EXCEPTION_TABLE_CLASS); 'Debug', EXCEPTION_TABLE_CLASS);
......
...@@ -30,6 +30,13 @@ use IMATHUZH\Qfq\Core\Store\Store; ...@@ -30,6 +30,13 @@ use IMATHUZH\Qfq\Core\Store\Store;
*/ */
class UserReportException extends AbstractException { class UserReportException extends AbstractException {
// SUPER HACK: to render inline editor when an exception is thrown
// Can't use store, since store needs bodytext to be parsed, which might throw exceptions if there is a syntax error.
public static $report_uid = null;
public static $report_bodytext = '';
public static $report_pathFileName = '';
public static $report_header = '';
/** /**
* $this->getMessage() might give a) a simple string or b) an JSON String. * $this->getMessage() might give a) a simple string or b) an JSON String.
* *
......
...@@ -152,6 +152,13 @@ class QuickFormQuery { ...@@ -152,6 +152,13 @@ class QuickFormQuery {
$t3data[T3DATA_BODYTEXT] = ReportAsFile::read_report_file($reportPathFileNameFull); $t3data[T3DATA_BODYTEXT] = ReportAsFile::read_report_file($reportPathFileNameFull);
} }
// SUPER HACK: to render inline editor when an exception is thrown
// Can't use store, since store needs bodytext to be parsed, which might throw exceptions if there is a syntax error.
\UserReportException::$report_uid = $t3data[T3DATA_UID];
\UserReportException::$report_bodytext = $t3data[T3DATA_BODYTEXT];
\UserReportException::$report_header = t3data[T3DATA_HEADER];
\UserReportException::$report_pathFileName = $reportPathFileNameFull;
$btp = new BodytextParser(); $btp = new BodytextParser();
$t3data[T3DATA_BODYTEXT_RAW] = $t3data[T3DATA_BODYTEXT]; $t3data[T3DATA_BODYTEXT_RAW] = $t3data[T3DATA_BODYTEXT];
$t3data[T3DATA_BODYTEXT] = $btp->process($t3data[T3DATA_BODYTEXT]); $t3data[T3DATA_BODYTEXT] = $btp->process($t3data[T3DATA_BODYTEXT]);
...@@ -1724,7 +1731,8 @@ class QuickFormQuery { ...@@ -1724,7 +1731,8 @@ class QuickFormQuery {
$beUserLoggedIn = $this->store->getVar(TYPO3_BE_USER, STORE_TYPO3, SANITIZE_ALLOW_ALNUMX); $beUserLoggedIn = $this->store->getVar(TYPO3_BE_USER, STORE_TYPO3, SANITIZE_ALLOW_ALNUMX);
if ($beUserLoggedIn && $this->inlineReport) { if ($beUserLoggedIn && $this->inlineReport) {
$html .= $this->buildInlineReport(); $html .= $this->buildInlineReport($this->t3data[T3DATA_UID], $this->t3data[T3DATA_REPORT_PATH_FILENAME],
$this->t3data[T3DATA_BODYTEXT_RAW], $this->t3data[T3DATA_HEADER]);
} }
$html .= $report->process($this->t3data[T3DATA_BODYTEXT]); $html .= $report->process($this->t3data[T3DATA_BODYTEXT]);
...@@ -1734,16 +1742,19 @@ class QuickFormQuery { ...@@ -1734,16 +1742,19 @@ class QuickFormQuery {
/** /**
* Constructs a form to directly edit qfq content elements inline. * Constructs a form to directly edit qfq content elements inline.
* *
* @param int|null $uid
* @param string $reportPathFileNameFull
* @param string $bodytext
* @param string $header
* @return string - the html code * @return string - the html code
* @throws \CodeException * @throws \CodeException
* @throws \UserFormException * @throws \UserFormException
*/ */
private function buildInlineReport() { public static function buildInlineReport(?int $uid, string $reportPathFileNameFull, string $bodytext, string $header): string
$uid = $this->t3data[T3DATA_UID]; {
$reportPathFileNameFull = $this->t3data[T3DATA_REPORT_PATH_FILENAME]; if ($uid === null) {
$bodytext = $this->t3data[T3DATA_BODYTEXT_RAW]; return '';
$header = $this->t3data[T3DATA_HEADER]; }
$icon = Support::renderGlyphIcon(GLYPH_ICON_TASKS); $icon = Support::renderGlyphIcon(GLYPH_ICON_TASKS);
$showFormJs = '$("#tt-content-edit-' . $uid . '").toggleClass("hidden")'; $showFormJs = '$("#tt-content-edit-' . $uid . '").toggleClass("hidden")';
$toggleBtn = Support::wrapTag("<a href='#' onclick='$showFormJs' style='float:right;'>", $icon); $toggleBtn = Support::wrapTag("<a href='#' onclick='$showFormJs' style='float:right;'>", $icon);
......
<?php <?php
// TODO: fix unittests run by gitlab runner.
// TODO: ?CR: QuickFormQuery.php L138: Why fallback $t3data[T3DATA_UID] = 0; and $t3data[T3DATA_BODYTEXT] = ''; ? When does this happen?
// TODO: ?CR: alle ?CR suchen und durchgehen.
//// FRONTEND EDITOR ////
// ====================//
// TODO: show frontend editor even when an exception occured during report rendering // TODO: show frontend editor even when an exception occured during report rendering
// Solution: in rendering of exception, add the editor to the html. // Solution: in rendering of exception, add the editor to the html.
// TODO: frontend edit komplett auschalten koennen (CR) // TODO: frontend edit komplett auschalten koennen (CR)
// TODO: volle kontrolle ueber code, dass der nicht pauschal ausgeliefert wird. (CR) // TODO: frontend editor wird nicht pauschal ausgeliefert, sondern nur wenn auch angezeigt. (CR)
// TODO: zentrale konfig, ob es angezeigt wird. (sekreteaerin soll nicht sehen obwohl BE login) (CR) // TODO: zentrale konfig, ob es angezeigt wird. (sekreteaerin soll nicht sehen obwohl BE login) (CR)
// TODO: pro user option, ob gezeigt wird. (CR) // TODO: pro user option, ob gezeigt wird. (CR)
// TODO: fix unittests run by gitlab runner.
// TODO: ?CR: QuickFormQuery.php L138: Why fallback $t3data[T3DATA_UID] = 0; and $t3data[T3DATA_BODYTEXT] = ''; ? When does this happen?
// TODO: ?CR: alle ?CR suchen und durchgehen.
namespace IMATHUZH\Qfq\Core\Report; namespace IMATHUZH\Qfq\Core\Report;
......
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