Commit b452306e authored by Carsten  Rose's avatar Carsten Rose

Plain implementation - functional. No support to easy usage.

parent 44c8b761
Pipeline #3685 passed with stages
in 5 minutes and 39 seconds
<?php
/**
* Created by PhpStorm.
* User: crose
* Date: 08/09/20
* Time: 6:17 PM
*/
namespace IMATHUZH\Qfq\Api;
require_once(__DIR__ . '/../../vendor/autoload.php');
use IMATHUZH\Qfq\Core\QuickFormQuery;
/**
* Return JSON encoded answer
*
* status: success|error
* message: <message>
* redirect: client|url|no
* redirect-url: <url>
*
* Description:
*
* Save successful.
*
*/
$answer = array();
$answer[API_REDIRECT] = API_ANSWER_REDIRECT_NO;
$answer[API_STATUS] = API_ANSWER_STATUS_ERROR;
$answer[API_MESSAGE] = '';
$status = HTTP_400_BAD_REQUEST;
try {
try {
$qfq = new QuickFormQuery(['bodytext' => '']);
$data = $qfq->dataReport();
$status = HTTP_200_OK;
} catch (\UserReportException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
} catch (\CodeException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
} catch (\DbException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
}
} catch (\Exception $e) {
$answer[API_MESSAGE] = "Generic Exception: " . $e->getMessage();
}
//header('HTTP/1.0 ' . $status);
//header("Content-Type: application/json");
//echo json_encode($answer);
echo $data;
\ No newline at end of file
......@@ -1939,6 +1939,55 @@ class QuickFormQuery {
}
}
/**
* Process given tt-content record triggered by AJAX Call
*
* @return string
* @throws \CodeException
* @throws \DbException
* @throws \DownloadException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
* @throws \UserFormException
* @throws \UserReportException
*/
public function dataReport() {
$uid = Store::getVar(NAME_UID, STORE_SIP . STORE_CLIENT . STORE_ZERO, SANITIZE_ALLOW_DIGIT);
return $this->getEvaluatedBodyText($uid);
}
/**
* @param $uid
*
* @return string
* @throws \CodeException
* @throws \DbException
* @throws \DownloadException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
* @throws \Twig\Error\LoaderError
* @throws \Twig\Error\RuntimeError
* @throws \Twig\Error\SyntaxError
* @throws \UserFormException
* @throws \UserReportException
*/
private function getEvaluatedBodyText($uid) {
$dbT3 = $this->store->getVar(SYSTEM_DB_NAME_T3, STORE_SYSTEM);
$sql = "SELECT `bodytext` FROM `$dbT3`.`tt_content` WHERE `uid` = ?";
$tt_content = $this->dbArray[$this->dbIndexQfq]->sql($sql, ROW_EXPECT_1, [$uid]);
$qfq = new QuickFormQuery([T3DATA_BODYTEXT => $tt_content[T3DATA_BODYTEXT]], false, false);
return $qfq->process();
}
/**
* Delete a record (tablename and recordid are given) or process a 'delete form'
*
......@@ -1956,7 +2005,6 @@ class QuickFormQuery {
* @throws \UserReportException
*/
public function delete() {
return $this->doForm(FORM_DELETE);
}
......
......@@ -461,7 +461,7 @@ class Download {
* @throws \UserFormException
* @throws \UserReportException
*/
private function getEvaluatedBodyText($uid, $urlParam) {
private function getEvaluatedBodyText($uid, array $urlParam) {
foreach ($urlParam as $key => $paramValue) {
$this->store->setVar($key, $paramValue, STORE_SIP);
}
......
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