Commit 56e397a6 authored by Elias Villiger's avatar Elias Villiger
Browse files

Feature #6255 - Finalize Inline Report Editing

parent ee0c6718
Pipeline #713 passed with stage
in 1 minute and 40 seconds
......@@ -466,6 +466,9 @@ config.qfq.php
| LDAP_1_RDN | LDAP_1_RDN='ou=Admin,ou=example,dc=com' | Credentials for non-anonymous LDAP access. At the moment only one set of |
| LDAP_1_PASSWORD | LDAP_1_PASSWORD=mySecurePassword | |
+-------------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+
| T3_DB_NAME | T3_DB_NAME=specialt3dbname | Only necessary for inline report editing if the t3 database is not |
| | | anologous to the Data db name (but ending in _t3) - see `inline-report`_. |
+-------------------------------+-------------------------------------------------------+----------------------------------------------------------------------------+
......@@ -497,11 +500,11 @@ Example: *typo3conf/config.qfq.php*: ::
After parsing the configuration, the following variables will be set automatically in STORE_SYSTEM:
+----------------+-----------------------------------------------------------------------------------+
| _dbNameData | Can be used to dynamically access the current selected database: {{dbNameData:Y}} |
+----------------+-----------------------------------------------------------------------------------+
| _dbNameQfq | Can be used to dynamically access the current selected database: {{dbNameQfq:Y}} |
+----------------+-----------------------------------------------------------------------------------+
+----------------+------------------------------------------------------------------------------------+
| _dbNameData | Can be used to dynamically access the current selected database: {{_dbNameData:Y}} |
+----------------+------------------------------------------------------------------------------------+
| _dbNameQfq | Can be used to dynamically access the current selected database: {{_dbNameQfq:Y}} |
+----------------+------------------------------------------------------------------------------------+
.. _`CustomVariables`:
......@@ -4825,6 +4828,29 @@ The parsed bodytext could be displayed by activating 'showDebugInfo' (:ref:`debu
A small symbol with a tooltip will be shown, where the content record will be displayed on the webpage.
Note: :ref:`debug` information will only be shown with *showDebugInfo: yes* in configuration_.
.. _`inline-report`:
Inline Report editing
---------------------
For quick changes it might be bothersome to go to the TYPO3 backend to update the page content and reload the page.
For this reason, QFQ offers an inline report editing feature whenever there is a TYPO3 BE user logged in. A small
link symbol will appear on the right-hand side of each report record. Please note that the TYPO3 Frontend cache
is also deleted upon each inline report save.
In order for the inline report editing to work, QFQ needs to be able to access the T3 database. By default this database
is assumed to be accessible with the same credentials as specified with indexData and is assumed to be named similarly to
the indexData db name, but ending in _t3 instead of _db (e.g., mydb_db and mydb_t3).
For a standard installation and db setup, this should be the case.
You can however specify a custom T3 db name in config-qfq-php_:
::
T3_DB_NAME = customT3DbName
Structure
---------
......
......@@ -400,6 +400,8 @@ const SYSTEM_DB_1_SERVER = 'DB_1_SERVER';
const SYSTEM_DB_1_PASSWORD = 'DB_1_PASSWORD';
const SYSTEM_DB_1_NAME = 'DB_1_NAME';
const SYSTEM_T3_DB_NAME = 'T3_DB_NAME';
const SYSTEM_DB_INIT = 'init';
const SYSTEM_DB_INDEX_DATA = "indexData";
......@@ -1189,7 +1191,7 @@ const INDEX_PHP = 'index.php';
const T3DATA_BODYTEXT = 'bodytext';
const T3DATA_BODYTEXT_RAW = 'bodytext-raw';
const T3DATA_UID = 'uid';
const T3DATA_PID = 'pid';
const T3DATA_HEADER = 'header';
const REPORT_INLINE_BODYTEXT = 'bodytext';
// Special Column to check for uploads
......
......@@ -1353,36 +1353,39 @@ class QuickFormQuery {
*/
private function buildInlineReport() {
$uid = $this->t3data[T3DATA_UID];
$pid = $this->t3data[T3DATA_PID];
$bodytext = $this->t3data[T3DATA_BODYTEXT_RAW];
$header = $this->t3data[T3DATA_HEADER];
$icon = Support::wrapTag('<span class="' . GLYPH_ICON . ' ' . GLYPH_ICON_TASKS . '">', '');
$hiddenInput = "<input type='hidden' name='uid' value='$uid'>";
$icon = Support::renderGlyphIcon(GLYPH_ICON_TASKS);
$showFormJs = '$("#tt-content-edit-' . $uid . '").toggleClass("hidden")';
$toggleBtn = Support::wrapTag("<a href='#' onclick='$showFormJs' style='float:right;'>", $icon);
$saveBtnAttributes = Support::doAttribute('class', 'btn btn-default btn-block');
$saveBtnAttributes .= Support::doAttribute('id', "tt-content-save-$uid");
$saveBtnAttributes .= Support::doAttribute('type', 'submit');
$saveBtn = Support::wrapTag("<button $saveBtnAttributes>", 'Save & Reload');
$ttContentCode = Support::htmlEntityEncodeDecode(MODE_ENCODE, $this->t3data[T3DATA_BODYTEXT_RAW]);
$codeBoxAttributes = Support::doAttribute('style', "width:100%; height:200px;");
$codeBoxAttributes .= Support::doAttribute('id', "tt-content-code-$uid");
$codeBoxAttributes .= Support::doAttribute('name', REPORT_INLINE_BODYTEXT);
$saveBtnAttributes = Support::doAttribute('class', 'btn btn-default') .
Support::doAttribute('id', "tt-content-save-$uid") .
Support::doAttribute('type', 'submit') .
Support::doAttribute('style', 'float:right; margin:-5px;') .
Support::doAttribute('title', 'Save & Reload');
$saveBtnIcon = Support::renderGlyphIcon(GLYPH_ICON_CHECK);
$saveBtn = Support::wrapTag("<button $saveBtnAttributes>", $saveBtnIcon);
$header = "QFQ Page Content '$header'";
$headerBar = Support::wrapTag("<div class='col-md-12 qfq-form-title'>", $header . $saveBtn);
$ttContentCode = Support::htmlEntityEncodeDecode(MODE_ENCODE, $bodytext);
$codeBoxAttributes = Support::doAttribute('style', "width:100%;") .
Support::doAttribute('id', "tt-content-code-$uid") .
Support::doAttribute('rows',20) .
Support::doAttribute('name', REPORT_INLINE_BODYTEXT);
$codeBox = Support::wrapTag("<textarea $codeBoxAttributes>", $ttContentCode);
$hiddenInput = "<input type='hidden' name='uid' value='$uid'>".
"<input type='hidden' name='pid' value='$pid'>";
$form = join(' ', [$saveBtn, $codeBox, $hiddenInput]);
$formAttributes = Support::doAttribute('id', "tt-content-edit-$uid");
$formAttributes .= Support::doAttribute('class', 'hidden');
$formAttributes .= Support::doAttribute('method', 'post');
$formAttributes .= Support::doAttribute('action', API_DIR . '/saveReport.php');
$form = join(' ', [$headerBar, $codeBox, $hiddenInput]);
$formAttributes = Support::doAttribute('id', "tt-content-edit-$uid") .
Support::doAttribute('class', 'hidden') .
Support::doAttribute('method', 'post') .
Support::doAttribute('action', API_DIR . '/saveReport.php');
$form = Support::wrapTag("<form $formAttributes>", $form);
// $this->store->setStore(['form' => 'ReportForm', 'r' => $uid], STORE_TYPO3, true);
// $reportForm = $this->doForm(FORM_LOAD);
return $toggleBtn . $form;
}
......@@ -1395,17 +1398,20 @@ class QuickFormQuery {
public function saveReport() {
$bodytext = Support::htmlEntityEncodeDecode(MODE_DECODE, $_POST[REPORT_INLINE_BODYTEXT]);
$uid = $_POST['uid'];
$pid = $_POST['pid'];
$db = 'elvill_qfq_t3';
$dbT3 = $this->store->getVar(SYSTEM_T3_DB_NAME, STORE_SYSTEM . STORE_EMPTY, SANITIZE_ALLOW_ALNUMX);
if ($dbT3 == '') {
$dbData = $this->store->getVar(SYSTEM_DB_NAME_DATA, STORE_SYSTEM, SANITIZE_ALLOW_ALNUMX);
$dbT3 = substr($dbData, 0, strrpos($dbData, "_") + 1) . 't3';
}
// Update bodytext
$sql = "UPDATE $db.tt_content SET bodytext = ?, tstamp = UNIX_TIMESTAMP(NOW()) WHERE uid = ?";
$res = $this->dbArray[$this->dbIndexQfq]->sql($sql, ROW_REGULAR, [$bodytext, $uid]);
$sql = "UPDATE $dbT3.tt_content SET bodytext = ?, tstamp = UNIX_TIMESTAMP(NOW()) WHERE uid = ?";
$this->dbArray[$this->dbIndexData]->sql($sql, ROW_REGULAR, [$bodytext, $uid]);
// Clear cache
$sql = "DELETE FROM $db.cf_cache_pagesection WHERE identifier LIKE '$pid%'";
$this->dbArray[$this->dbIndexQfq]->sql($sql);
// Need to truncate cf_cache_pages because it is used to restore page-specific cache
$sql = "DELETE FROM $dbT3.cf_cache_pages WHERE 1";
$this->dbArray[$this->dbIndexData]->sql($sql);
return '';
}
......
......@@ -146,6 +146,10 @@ class Support {
return $tag . $value . $closing;
}
public static function renderGlyphIcon($glyphIcon, $value = '') {
return Support::wrapTag("<span class='" . GLYPH_ICON . " $glyphIcon'>", $value);
}
/**
* Removes '$tag' and closing $tag from $value, if they are the outermost.
* E.g. unWrapTag('<p>', '<p>Hello World</p>') returns 'Hello World'
......
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