Commit bcdb2b1c authored by Elias Villiger's avatar Elias Villiger
Browse files

Feature #6596 Initial POC for uid ExcelExport / refs #6596

parent 31d0fb76
Pipeline #902 passed with stage
in 1 minute and 44 seconds
......@@ -1438,6 +1438,7 @@ const PARAM_TOKEN_DELIMITER = ':';
const TOKEN_URL = 'u';
const TOKEN_MAIL = 'm';
const TOKEN_PAGE = 'p';
const TOKEN_UID = 'uid';
const TOKEN_DOWNLOAD = 'd';
const TOKEN_COPY_TO_CLIPBOARD = 'y';
......
......@@ -87,13 +87,18 @@ class QuickFormQuery {
/**
* @var array
*/
private $t3data = array(); // FormEelement Definition: all formElement.class='native' of the loaded form
private $t3data = array(); // FormElement Definition: all formElement.class='native' of the loaded form
/**
* @var bool
*/
private $phpUnit = false;
/**
* @var bool
*/
private $inlineReport = false;
/**
* @var Session
*/
......@@ -122,15 +127,17 @@ class QuickFormQuery {
*
* @param array $t3data
* @param bool $phpUnit
* @param bool $inlineReport
*
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public function __construct(array $t3data = array(), $phpUnit = false) {
public function __construct(array $t3data = array(), $phpUnit = false, $inlineReport = true) {
//TODO EV move $inlineReport to config (temporarily unset for generating excel export data)
$this->phpUnit = $phpUnit;
$this->inlineReport = $inlineReport;
mb_internal_encoding("UTF-8");
......@@ -1369,7 +1376,8 @@ class QuickFormQuery {
$report = new Report($this->t3data, $this->eval, $this->phpUnit);
$html = '';
if ($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) {
$html .= $this->buildInlineReport();
}
$html .= $report->process($this->t3data[T3DATA_BODYTEXT]);
......@@ -1435,11 +1443,7 @@ class QuickFormQuery {
}
$bodytext = Support::htmlEntityEncodeDecode(MODE_DECODE, $_POST[REPORT_INLINE_BODYTEXT]);
$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';
}
$dbT3 = $this->store->getDbT3Name();
// Update bodytext
$sql = "UPDATE $dbT3.tt_content SET bodytext = ?, tstamp = UNIX_TIMESTAMP(NOW()) WHERE uid = ?";
......
......@@ -27,6 +27,7 @@ require_once(__DIR__ . '/Monitor.php');
require_once(__DIR__ . '/../exceptions/DownloadException.php');
require_once(__DIR__ . '/Excel.php');
require_once(__DIR__ . '/../helper/DownloadPage.php');
require_once(__DIR__ . '/../QuickFormQuery.php');
//require_once(__DIR__ . '/../Evaluate.php');
//require_once(__DIR__ . '/../helper/KeyValueStringParser.php');
......@@ -214,9 +215,13 @@ class Download {
* @param string $rcData - With $downloadMode=DOWNLOAD_MODE_EXCEL, this contains the rendered code from the given T3 page.
* @return string filename - already ready or fresh exported. Fresh exported needs to be deleted later.
* @throws CodeException
* @throws DbException
* @throws DownloadException
* @throws UserFormException
* @throws UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
private function getElement($element, $downloadMode, &$rcData) {
......@@ -237,6 +242,7 @@ class Download {
case TOKEN_URL:
case TOKEN_URL_PARAM:
case TOKEN_PAGE:
case TOKEN_UID:
if ($downloadMode == DOWNLOAD_MODE_EXCEL) {
$urlParam = OnString::splitParam($value, $rcArgs, $rcSipEncode);
......@@ -246,9 +252,22 @@ class Download {
$urlParamString = $sip->queryStringToSip($urlParamString, RETURN_URL);
}
$baseUrl = $this->store->getVar(SYSTEM_BASE_URL, STORE_SYSTEM);
$rcData = DownloadPage::getContent($urlParamString, $baseUrl);
if ($token === TOKEN_UID) {
$dbT3 = $this->store->getDbT3Name();
$uid = $value; // TODO EV extract uid and pass parameters as SIP parameters to qfq store
$sql = "SELECT bodytext FROM $dbT3.tt_content WHERE uid = ?";
$tt_content = $this->db->sql($sql, ROW_EXPECT_1, [$uid]);
$qfq = new QuickFormQuery([T3DATA_BODYTEXT => $tt_content[T3DATA_BODYTEXT]], false,false);
$rcData = $qfq->process();
} else {
$baseUrl = $this->store->getVar(SYSTEM_BASE_URL, STORE_SYSTEM);
$rcData = DownloadPage::getContent($urlParamString, $baseUrl);
}
} else {
// TODO EV get evaluated bodytext like above
// create tmp html document with bodytext
// convert to pdf
$filename = $this->html2pdf->page2pdf($token, $value);
}
break;
......
......@@ -74,6 +74,7 @@ require_once(__DIR__ . '/Thumbnail.php');
const NAME_URL = 'url';
const NAME_MAIL = 'mail';
const NAME_PAGE = 'page';
const NAME_UID = 'uid';
const NAME_TEXT = 'text';
const NAME_DOWNLOAD = DOWNLOAD_EXPORT_FILENAME;
const NAME_COLLECT_ELEMENTS = 'downloadElements'; // array with element sources
......@@ -190,6 +191,7 @@ class Link {
TOKEN_URL => NAME_URL,
TOKEN_MAIL => NAME_MAIL,
TOKEN_PAGE => NAME_PAGE,
TOKEN_UID => NAME_UID,
TOKEN_DOWNLOAD => NAME_DOWNLOAD,
TOKEN_DOWNLOAD_MODE => NAME_DOWNLOAD_MODE,
TOKEN_TEXT => NAME_TEXT,
......@@ -235,6 +237,7 @@ class Link {
TOKEN_URL => LINK_ANCHOR,
TOKEN_MAIL => LINK_ANCHOR,
TOKEN_PAGE => LINK_ANCHOR,
TOKEN_UID => LINK_ANCHOR,
TOKEN_DOWNLOAD => LINK_ANCHOR,
TOKEN_FILE => NAME_FILE,
TOKEN_COPY_TO_CLIPBOARD => LINK_ANCHOR,
......@@ -542,7 +545,8 @@ class Link {
// Store value
if ((isset($rcTokenGiven[TOKEN_DOWNLOAD]) || isset($rcTokenGiven[TOKEN_COPY_TO_CLIPBOARD])) &&
($key == TOKEN_PAGE || $key == TOKEN_URL || $key == TOKEN_URL_PARAM || $key == TOKEN_FILE || $key == TOKEN_FILE_DEPRECATED)) {
($key == TOKEN_PAGE || $key == TOKEN_URL || $key == TOKEN_URL_PARAM || $key == TOKEN_UID ||
$key == TOKEN_FILE || $key == TOKEN_FILE_DEPRECATED)) {
$vars[NAME_COLLECT_ELEMENTS][] = $key . ':' . $value;
......
......@@ -949,4 +949,27 @@ class Store {
$store->setStore(array_merge($store->getStore($storeName), $append), $storeName, true);
}
/**
* Gets the db T3 name:
* - if defined by T3_DB_NAME in config
* - else: construct databasename_t3 from databasename_db
*
* @return string
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public static function getDbT3Name() {
$dbT3Name = self::getVar(SYSTEM_T3_DB_NAME, STORE_SYSTEM . STORE_EMPTY, SANITIZE_ALLOW_ALNUMX);
if (!$dbT3Name) {
$dbIndexData = self::getVar(SYSTEM_DB_INDEX_DATA, STORE_SYSTEM);
$dbData = new Database($dbIndexData);
$dbDataName = $dbData->getDbName();
$dbT3Name = substr($dbDataName, 0, strrpos($dbDataName, "_") + 1) . 't3';
}
return $dbT3Name;
}
}
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