Commit 6afc0a1e authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

Merge remote-tracking branch 'origin/crose_work' into raos_work

parents 6da9e5f1 19e42393
......@@ -8,7 +8,8 @@ namespace IMATHUZH\Qfq\Controller;
use qfq;
require_once(__DIR__ . '/../../qfq/qfq/QuickFormQuery.php');
require_once(__DIR__ . '/../../qfq/qfq/exceptions/UserException.php');
require_once(__DIR__ . '/../../qfq/qfq/exceptions/UserFormException.php');
require_once(__DIR__ . '/../../qfq/qfq/exceptions/UserReportExtension.php');
require_once(__DIR__ . '/../../qfq/qfq/exceptions/CodeException.php');
require_once(__DIR__ . '/../../qfq/qfq/exceptions/DbException.php');
......@@ -21,7 +22,9 @@ class QfqController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
$qfq = new \qfq\QuickFormQuery($contentObject->data);
$html = $qfq->process();
} catch (qfq\UserException $e) {
} catch (qfq\UserFormException $e) {
$html = $e->formatMessage();
} catch (qfq\UserReportException $e) {
$html = $e->formatMessage();
} catch (qfq\CodeException $e) {
$html = $e->formatMessage();
......
......@@ -6,8 +6,8 @@
conf.py:
copyright: 2016
project: QFQ Extension
version: 0.2
release: 0.2.0
version: 0.3
release: 0.3.0
latex_documents:
- - Index
- qfq.tex
......
......@@ -57,9 +57,9 @@ copyright = u'2016, Carsten Rose'
# built documents.
#
# The short X.Y version.
version = '0.2'
version = '0.3'
# The full version, including alpha/beta/rc tags.
release = '0.2.0'
release = '0.3.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......
......@@ -10,5 +10,5 @@ $EM_CONF[$_EXTKEY] = array(
'dependencies' => 'fluid,extbase',
'clearcacheonload' => true,
'state' => 'alpha',
'version' => '0.1.2'
'version' => '0.3'
);
\ No newline at end of file
......@@ -60,7 +60,7 @@ try {
$answer[API_REDIRECT] = API_ANSWER_REDIRECT_CLIENT;
$answer[API_STATUS] = API_ANSWER_STATUS_SUCCESS;
} catch (qfq\UserException $e) {
} catch (qfq\UserFormException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
} catch (qfq\CodeException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
......
......@@ -66,7 +66,7 @@ try {
$answer[API_MESSAGE] = 'load: success';
$answer[API_FORM_UPDATE] = $data;
} catch (qfq\UserException $e) {
} catch (qfq\UserFormException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
$val = Store::getVar(SYSTEM_FORM_ELEMENT, STORE_SYSTEM);
......
......@@ -64,7 +64,7 @@ try {
$answer[API_STATUS] = API_ANSWER_STATUS_SUCCESS;
$answer[API_MESSAGE] = 'save: success';
} catch (qfq\UserException $e) {
} catch (qfq\UserFormException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
$val = Store::getVar(SYSTEM_FORM_ELEMENT, STORE_SYSTEM);
......
This diff is collapsed.
......@@ -61,7 +61,7 @@ class BodytextParser {
$full = '';
foreach ($bodytextArray as $row) {
// Valid 'new line' starts indicators: form, <level>, <level.sublevel>, <level>.<keyword>, {, <level> {, }
if ((1 === preg_match('/^\s*(\d*(\.)?)*\s*(head|althead|tail|sql|rbeg|rend|renr|rsep|fbeg|fend|fsep|form|debugShowStack|r) *=/', $row))
if ((1 === preg_match('/^\s*(\d*(\.)?)*\s*(head|althead|tail|sql|rbeg|rend|renr|rsep|fbeg|fend|fsep|form|debugShowBodyText|r) *=/', $row))
|| (1 === preg_match('/^\s*(\d*(\.)?)*\s*({|})\s*/', $row))
|| (1 === preg_match('/^\s*(\d+(\.)?)+/', $row))
) {
......@@ -90,7 +90,7 @@ class BodytextParser {
/**
* @param $bodytext
* @return mixed|string
* @throws UserException
* @throws UserFormException
*/
private function unNest($bodytext) {
// Replace '\{' | '\}' by internal token. All remaining '}' | '{' means: 'nested'
......@@ -106,7 +106,7 @@ class BodytextParser {
$posMatchOpen = strrpos(substr($result, 0, $posFirstClose), '{');
if ($posMatchOpen === false) {
throw new \qfq\UserException("Missing open delimiter: $result", ERROR_MISSING_OPEN_DELIMITER);
throw new \qfq\UserFormException("Missing open delimiter: $result", ERROR_MISSING_OPEN_DELIMITER);
}
$pre = substr($result, 0, $posMatchOpen);
......
......@@ -9,12 +9,12 @@
namespace qfq;
use qfq;
use qfq\UserException;
use qfq\UserFormException;
require_once(__DIR__ . '/../qfq/Constants.php');
require_once(__DIR__ . '/../qfq/helper/OnArray.php');
require_once(__DIR__ . '/../qfq/AbstractBuildForm.php');
require_once(__DIR__ . '/../qfq/exceptions/UserException.php');
require_once(__DIR__ . '/../qfq/exceptions/UserFormException.php');
/**
* Class BuildFormBootstrap
......@@ -94,7 +94,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
public function head() {
$html = '';
$html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything, Whole FORM; class="container" or class="container-fluid"
$html .= '<div ' . Support::doAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything, Whole FORM; class="container" or class="container-fluid"
$title = Support::wrapTag('<div class="hidden-xs col-sm-6 col-md-8">', Support::wrapTag('<h3>', $this->formSpec['title']));
$button = Support::wrapTag('<div class="col-xs-12 col-sm-6 col-md-4">', $this->buildButtons());
......@@ -180,7 +180,7 @@ BUTTON;
/**
* @param $pillArray
* @return string
* @throws UserException
* @throws UserFormException
*/
private function buildPillNavigation($pillArray) {
$pillButton = '';
......@@ -201,7 +201,7 @@ BUTTON;
if ($formElement['name'] === '' || $formElement['label'] === '') {
$this->store->setVar(SYSTEM_FORM_ELEMENT, $formElement['name'] . ' / ' . $formElement['id'], STORE_SYSTEM);
$this->store->setVar(SYSTEM_FORM_ELEMENT_COLUMN, 'name, label', STORE_SYSTEM);
throw new UserException("Field 'name' and/or 'label' are empty", ERROR_NAME_LABEL_EMPTY);
throw new UserFormException("Field 'name' and/or 'label' are empty", ERROR_NAME_LABEL_EMPTY);
}
// Anker for pill navigation
......
......@@ -67,7 +67,7 @@ class BuildFormTable extends AbstractBuildForm {
public function head() {
$html = '';
$html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything
$html .= '<div ' . Support::doAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything
// Logged in BE User will see a FormEdit Link
$sipParamString = OnArray::toString($this->store->getStore(STORE_SIP), ':', ', ', "'");
......
......@@ -43,9 +43,9 @@ const SQL_FORM_ELEMENT_SIMPLE_ALL_CONTAINER = "SELECT fe.id, fe.name, fe.type, f
// SANITIZE Classifier
const SANITIZE_ALLOW_ALNUMX = "alnumx";
const SANITIZE_ALLOW_DIGIT = "digit";
const SANITIZE_ALLOW_EMAIL = "email";
const SANITIZE_ALLOW_MIN_MAX = "min|max";
const SANITIZE_ALLOW_MIN_MAX_DATE = "min|max date";
const SANITIZE_ALLOW_EMAIL = "email";
const SANITIZE_ALLOW_PATTERN = "pattern";
const SANITIZE_ALLOW_ALL = "all";
const SANITIZE_DEFAULT = SANITIZE_ALLOW_DIGIT;
......@@ -135,6 +135,13 @@ const ERROR_IO_READ_FILE = 1200;
const ERROR_IO_WRITE = 1203;
const ERROR_IO_OPEN = 1204;
//Report
const ERROR_UNKNOWN_LINK_QUALIFIER = 1300;
const ERROR_UNDEFINED_RENDER_CONTROL_COMBINATION = 1301;
const ERROR_MISSING_VALUE = 1302;
const ERROR_MULTIPLE_DEFINITION = 1303;
const ERROR_MULTIPLE_URL_PAGE_MAILTO_DEFINITION = 1304;
// KeyValueParser
const ERROR_KVP_VALUE_HAS_NO_KEY = 1900;
......@@ -202,8 +209,6 @@ const CLIENT_PHP_SELF = 'PHP_SELF';
// T3 Bodytext Keywords
const TYPO3_FORM = CLIENT_FORM;
const TYPO3_DEBUG_LOAD = 'debugLoad';
const TYPO3_DEBUG_SAVE = 'debugSave';
const TYPO3_FE_USER = 'feUser';
const TYPO3_FE_USER_UID = 'feUserUid';
const TYPO3_FE_USER_GROUP = 'feUserGroup';
......@@ -238,6 +243,10 @@ const SYSTEM_FORM = CLIENT_FORM; // '<formName> / <formId
const SYSTEM_FORM_ELEMENT = 'formElement'; // '<formElementName> / <formElementeId>'
const SYSTEM_FORM_ELEMENT_COLUMN = 'formElementColumn'; // '<columnname of current processed formElement>'
const SYSTEM_FORM_ELEMENT_MESSAGE = 'formElementMessage'; // '<columnname of current processed formElement>'
const SYSTEM_REPORT_COLUMN_INDEX = 'reportColumnIndex'; // Keyname of SQL-column processed at the moment.
const SYSTEM_REPORT_COLUMN_NAME = 'reportColumnName'; // Keyname of SQL-column processed at the moment.
const SYSTEM_REPORT_COLUMN_VALUE = 'reportColumnValue'; // Keyname of SQL-column processed at the moment.
const SYSTEM_REPORT_FULL_LEVEL = 'reportFullLevel'; // Keyname of SQL-column processed at the moment.
// die folgenden Elemente sind vermutlich nicht noetig, wenn Store Klassen gloable Vars benutzt.
//const SYSTEM_FORM_DEF = 'formDefinition'; // Type: SANITIZE_ALNUMX / AssocArray. Final form to process. Useful for error reporting.
......@@ -297,4 +306,14 @@ const SUBRECORD_EDIT = SYMBOL_EDIT;
const SUBRECORD_DELETE = SYMBOL_DELETE;
const SUBRECORD_PARAMETER_FORM = CLIENT_FORM;
const SUBRECORD_PARAMETER_PAGE = 'page';
const SUBRECORD_PARAMETER_DETAIL = 'detail';
\ No newline at end of file
const SUBRECORD_PARAMETER_DETAIL = 'detail';
const GLYPH_ICON_EDIT = 'glyphicon-pencil';
const GLYPH_ICON_NEW = 'glyphicon-plus';
const GLYPH_ICON_DELETE = 'glyphicon-trash';
const GLYPH_ICON_HELP = 'glyphicon glyphicon-question-sign';
const GLYPH_ICON_INFO = 'glyphicon glyphicon-info-sign';
const GLYPH_ICON_SHOW = 'glyphicon glyphicon-search';
const GLYPH_ICON_TOOL = 'glyphicon-wrench';
const GLYPH_ICON_CHECK = 'glyphicon glyphicon-ok';
......@@ -11,11 +11,11 @@ namespace qfq;
use qfq;
use qfq\CodeException;
use qfq\DbException;
use qfq\UserException;
use qfq\UserFormException;
use qfq\Support;
use qfq\Store;
require_once(__DIR__ . '/exceptions/UserException.php');
require_once(__DIR__ . '/exceptions/UserFormException.php');
require_once(__DIR__ . '/exceptions/CodeException.php');
require_once(__DIR__ . '/exceptions/DbException.php');
......@@ -60,7 +60,7 @@ class Database {
* If not exists: open database and store the new dbh in Store[System][SYSTEM_DBH]
*
* @throws CodeException
* @throws UserException
* @throws UserFormException
*/
public function __construct() {
$this->store = Store::getInstance();
......@@ -76,7 +76,7 @@ class Database {
* Open mysqli database connection if not already done.
*
* @return \mysqli
* @throws UserException
* @throws UserFormException
*/
private function dbConnect() {
$mysqli = null;
......@@ -89,7 +89,7 @@ class Database {
$mysqli = new \mysqli($dbserver, $dbuser, $dbpw, $db);
if ($mysqli->connect_error) {
throw new UserException ("Error open Database 'mysql:host=" . $dbserver . ";dbname=" . $db . ";dbuser=" . $dbuser . "'': " . $mysqli->connect_errno . PHP_EOL . $mysqli->connect_error, ERROR_DB_OPEN);
throw new UserFormException ("Error open Database 'mysql:host=" . $dbserver . ";dbname=" . $db . ";dbuser=" . $dbuser . "'': " . $mysqli->connect_errno . PHP_EOL . $mysqli->connect_error, ERROR_DB_OPEN);
}
return $mysqli;
......@@ -117,7 +117,7 @@ class Database {
* @param string $table name of the table
* @param string $columnName name of the column
*
* @throws UserException if the table or column does not exist, or is not of type ENUM or SET
* @throws UserFormException if the table or column does not exist, or is not of type ENUM or SET
* @return array
*/
public function getEnumSetValueList($table, $columnName) {
......@@ -296,7 +296,7 @@ class Database {
* @return int|mixed
* @throws \qfq\CodeException
* @throws \qfq\DbException
* @throws \qfq\UserException
* @throws \qfq\UserFormException
*/
private function prepareExecute($sql, array $parameterArray = array()) {
$result = 0;
......@@ -364,7 +364,7 @@ class Database {
* @param $sql
* @param array $parameterArray
* @return string
* @throws \qfq\UserException
* @throws \qfq\UserFormException
*/
private function dbLog($sql, $parameterArray = array()) {
......@@ -380,7 +380,7 @@ class Database {
// nothing to log.
return;
default:
throw new UserException("Unknown SQL_LOG_MODE: $mode", ERROR_UNKNOWN_SQL_LOG_MODE);
throw new UserFormException("Unknown SQL_LOG_MODE: $mode", ERROR_UNKNOWN_SQL_LOG_MODE);
}
$msg = '[' . date('Y.m.d H:i:s O') . '][';
......
......@@ -67,13 +67,13 @@ class Evaluate {
* @param $line
* @param int $recursion
* @return array|mixed|null|string
* @throws UserException
* @throws UserFormException
*/
public function parse($line, $recursion = 0, &$debugStack = array(), &$foundInStore = '') {
$flagTokenReplaced = false;
if ($recursion > 4) {
throw new qfq\UserException("Recursion too deep ($recursion). Line: $line", ERROR_RECURSION_TOO_DEEP);
throw new qfq\UserFormException("Recursion too deep ($recursion). Line: $line", ERROR_RECURSION_TOO_DEEP);
}
$result = $line;
......@@ -88,7 +88,7 @@ class Evaluate {
$posMatchOpen = strrpos(substr($result, 0, $posFirstClose), $this->startDelimiter);
if ($posMatchOpen === false) {
throw new \qfq\UserException("Missing open delimiter: $result", ERROR_MISSING_OPEN_DELIMITER);
throw new \qfq\UserFormException("Missing open delimiter: $result", ERROR_MISSING_OPEN_DELIMITER);
}
$pre = substr($result, 0, $posMatchOpen);
......
......@@ -29,7 +29,7 @@ require_once(__DIR__ . '/../qfq/Constants.php');
require_once(__DIR__ . '/../qfq/Save.php');
require_once(__DIR__ . '/../qfq/helper/KeyValueStringParser.php');
require_once(__DIR__ . '/../qfq/helper/HelperFormElement.php');
require_once(__DIR__ . '/../qfq/exceptions/UserException.php');
require_once(__DIR__ . '/../qfq/exceptions/UserFormException.php');
require_once(__DIR__ . '/../qfq/exceptions/CodeException.php');
require_once(__DIR__ . '/../qfq/exceptions/DbException.php');
require_once(__DIR__ . '/../qfq/exceptions/ErrorHandler.php');
......@@ -156,8 +156,13 @@ class QuickFormQuery {
* @return string
*/
public function process() {
$html = '';
$html = $this->doForm(FORM_LOAD);
if ($this->store->getVar('debugShowBodyText', STORE_TYPO3) === '1') {
$html .= Support::appendTooltip('', $this->t3data['bodytext']);
}
$html .= $this->doForm(FORM_LOAD);
$html .= $this->doReport();
$class = $this->store->getVar(SYSTEM_CSS_CLASS_QFQ_CONTAINER, STORE_SYSTEM);
......@@ -172,7 +177,7 @@ class QuickFormQuery {
*
* @return string
* @throws CodeException
* @throws UserException
* @throws UserFormException
*/
private function doForm($mode) {
$data = '';
......@@ -239,7 +244,7 @@ class QuickFormQuery {
* @return bool|string if found the formName, else 'false'.
* @throws CodeException
* @throws DbException
* @throws UserException
* @throws UserFormException
*/
private function loadFormSpecification($mode, &$foundInStore = '') {
......@@ -249,6 +254,13 @@ class QuickFormQuery {
}
$this->store->setVar(SYSTEM_FORM, $formName, STORE_SYSTEM);
// Check if there is a recordId specified in Bodytext - as variable or query.
$rTmp = $this->store->getVar(CLIENT_RECORD_ID, STORE_TYPO3, SANITIZE_ALLOW_ALL);
if (false !== $rTmp && !is_int($rTmp)) {
$rTmp = $this->eval->parse($rTmp);
$this->store->setVar(CLIENT_RECORD_ID, $rTmp, STORE_TYPO3);
}
// Load form
$form = $this->db->sql("SELECT * FROM Form AS f WHERE f.name LIKE ? AND f.deleted='no'", ROW_EXPECT_1,
[$formName], 'Form not found or multiple forms with the same name.');
......@@ -309,7 +321,7 @@ class QuickFormQuery {
* @param string $foundInStore
* @return array|bool|mixed|null|string Formname (Form.name) or FALSE, if no formname found.
* @throws CodeException
* @throws UserException
* @throws UserFormException
*/
private function getFormName($mode, &$foundInStore = '') {
$dummy = array();
......@@ -327,7 +339,6 @@ class QuickFormQuery {
}
$storeFormName = $this->store->getVar(SIP_FORM, $store, '', $foundInStore);
$formName = $this->eval->parse($storeFormName, 0, $dummy, $foundInStore);
// If the formname is '': no formname name.
......@@ -348,13 +359,13 @@ class QuickFormQuery {
* @param $formNameFoundInStore
* @return bool 'true' if SIP exists, else 'false'
* @throws CodeException
* @throws UserException
* @throws UserFormException
* @internal param $foundInStore
*/
private function validateForm($formNameFoundInStore) {
// Retrieve record_id either from SIP (prefered) or via URL
$r = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_CLIENT, '', $recordIdFoundInStore);
$r = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_TYPO3 . STORE_CLIENT, '', $recordIdFoundInStore);
// If there is a record_id>0: EDIT else NEW: 'sip','logged_in','logged_out','always','never'
$permitMode = ($r > 0) ? $this->formSpec['permitEdit'] : $this->formSpec['permitNew'];
......@@ -365,37 +376,37 @@ class QuickFormQuery {
if ($sipFound) {
if (($formNameFoundInStore === STORE_CLIENT) || ($recordIdFoundInStore === STORE_CLIENT)) {
throw new UserException("SIP exist but FORM or RECORD_ID are given by CLIENT.", ERROR_SIP_EXIST_BUT_OTHER_PARAM_GIVEN_BY_CLIENT);
throw new UserFormException("SIP exist but FORM or RECORD_ID are given by CLIENT.", ERROR_SIP_EXIST_BUT_OTHER_PARAM_GIVEN_BY_CLIENT);
}
}
switch ($permitMode) {
case FORM_PERMISSION_SIP:
if (!$sipFound || $formNameFoundInStore !== STORE_SIP || $recordIdFoundInStore !== STORE_SIP) {
throw new UserException("SIP Parameter needed for this form.", ERROR_SIP_NEEDED_FOR_THIS_FORM);
throw new UserFormException("SIP Parameter needed for this form.", ERROR_SIP_NEEDED_FOR_THIS_FORM);
}
break;
case FORM_PERMISSION_LOGGED_IN:
if (!$feUserLoggedIn) {
throw new UserException("User not logged in.", ERROR_USER_NOT_LOGGED_IN);
throw new UserFormException("User not logged in.", ERROR_USER_NOT_LOGGED_IN);
}
break;
case FORM_PERMISSION_LOGGED_OUT:
if ($feUserLoggedIn) {
throw new UserException("User logged in.", ERROR_USER_LOGGED_IN);
throw new UserFormException("User logged in.", ERROR_USER_LOGGED_IN);
}
break;
case FORM_PERMISSION_ALWAYS:
break;
case FORM_PERMISSION_NEVER:
throw new UserException("Loading form forbidden.", ERROR_FORM_FORBIDDEN);
throw new UserFormException("Loading form forbidden.", ERROR_FORM_FORBIDDEN);
default:
throw new CodeException("Unknown permission mode: '" . $permitMode . "'", ERROR_FORM_UNKNOWN_PERMISSION_MODE);
}
// Form Definition valid?
if ($this->formSpec['multiMode'] !== 'none' && $this->formSpec['multiSql'] === '') {
throw new UserException("MultiMode selected, but MultiSQL missing", ERROR_MULTI_SQL_MISSING);
throw new UserFormException("MultiMode selected, but MultiSQL missing", ERROR_MULTI_SQL_MISSING);
}
return $sipFound;
......@@ -445,7 +456,7 @@ class QuickFormQuery {
*
* @throws CodeException
* @throws DbException
* @throws UserException
* @throws UserFormException
*/
public function delete() {
......@@ -456,7 +467,7 @@ class QuickFormQuery {
$table = $this->store->getVar(SIP_TABLE, STORE_SIP);
if ($recordId === false || $recordId < 1 || $table === false || $table === '') {
throw new UserException("Invalid or missing parameter: recordId=$recordId, table=$table", ERROR_INVALID_OR_MISSING_PARAMETER);
throw new UserFormException("Invalid or missing parameter: recordId=$recordId, table=$table", ERROR_INVALID_OR_MISSING_PARAMETER);
}
$this->db->sql("DELETE FROM $table WHERE id = ? LIMIT 1", ROW_REGULAR, [$recordId]);
......
......@@ -49,7 +49,7 @@ class Save {
*
* @throws CodeException
* @throws DbException
* @throws UserException
* @throws UserFormException
*/
public function process() {
......@@ -70,7 +70,7 @@ class Save {
* @return string
* @throws CodeException
* @throws DbException
* @throws UserException
* @throws UserFormException
*/
public function elements($recordId) {
......
......@@ -12,20 +12,20 @@ namespace qfq;
require_once(__DIR__ . '/AbstractException.php');
/**
* Class UserException
* Class UserFormException
*
* Thrown by Form or FormElement on User errors
*
* @package qfq\exceptions
*/
class UserException extends AbstractException {
class UserFormException extends AbstractException {
/*
* @return string HTML formatted error string
*/
public function formatMessage() {
$this->messageArray['Type'] = 'User Exception';
$this->messageArray['Type'] = 'User Form Exception';
$this->messageArray['Form'] = Store::getVar(SYSTEM_FORM, STORE_SYSTEM);
$this->messageArray['Form Element'] = Store::getVar(SYSTEM_FORM_ELEMENT, STORE_SYSTEM);
$this->messageArray['Form Element Column'] = Store::getVar(SYSTEM_FORM_ELEMENT_COLUMN, STORE_SYSTEM);
......
<?php
/**
* Created by PhpStorm.
* User: crose
* Date: 4/1/16
* Time: 11:28 PM
*/
namespace qfq;
require_once(__DIR__ . '/AbstractException.php');
/**
* Class UserReportException
*
* Thrown by Report on User errors
*
* @package qfq\exceptions
*/
class UserReportException extends AbstractException {
/*
* @return string HTML formatted error string
*/
public function formatMessage() {
$this->messageArray['Type'] = 'User Report Exception';
$this->messageArray[SYSTEM_SQL_RAW] = htmlentities(Store::getVar(SYSTEM_SQL_RAW, STORE_SYSTEM));
$this->messageArray[SYSTEM_SQL_FINAL] = htmlentities(Store::getVar(SYSTEM_SQL_FINAL, STORE_SYSTEM));
$this->messageArray[SYSTEM_REPORT_COLUMN_INDEX] = htmlentities(Store::getVar(SYSTEM_REPORT_COLUMN_INDEX, STORE_SYSTEM));
$this->messageArray[SYSTEM_REPORT_COLUMN_NAME] = htmlentities(Store::getVar(SYSTEM_REPORT_COLUMN_NAME, STORE_SYSTEM));
$this->messageArray[SYSTEM_REPORT_COLUMN_VALUE] = htmlentities(Store::getVar(SYSTEM_REPORT_COLUMN_VALUE, STORE_SYSTEM));
return parent::formatException();
}
}
\ No newline at end of file
......@@ -10,16 +10,27 @@ namespace qfq;
use qfq;
use qfq\Store;
use qfq\UserException;
use qfq\UserFormException;
require_once(__DIR__ . '/../../qfq/store/Store.php');
require_once(__DIR__ . '/../../qfq/Constants.php');
require_once(__DIR__ . '/../../qfq/helper/KeyValueStringParser.php');
require_once(__DIR__ . '/../../qfq/exceptions/UserException.php');
require_once(__DIR__ . '/../../qfq/exceptions/UserFormException.php');
class HelperFormElement
{
/**
* @param array $elements
* @throws \qfq\UserFormException
*/
public static function explodeParameterInArrayElements(array &$elements) {
foreach ($elements AS $key => $element) {
self::explodeParameter($element);
$elements[$key] = $element;
}
}
/**
* Take all rows from field $element['parameter'] and merge them with $element. '$element' grows in size.
*
......@@ -27,7 +38,7 @@ class HelperFormElement
* If $element['parameter'] exist and is filled: explode the content and append them to the current array.
*
* @param array $elements
* @throws UserException
* @throws UserFormException
*/
public static function explodeParameter(array &$element)
{
......@@ -42,25 +53,13 @@ class HelperFormElement
$store = Store::getInstance();
$store->setVar(SYSTEM_FORM_ELEMENT, $element['name'] . ' / ' . $element['id'], STORE_SYSTEM);
$store->setVar(SYSTEM_FORM_ELEMENT_COLUMN, 'parameter', STORE_SYSTEM);
throw new UserException("Found reserved keyname '$checkKey'", ERROR_RESERVED_KEY_NAME);
throw new UserFormException("Found reserved keyname '$checkKey'", ERROR_RESERVED_KEY_NAME);
}
}
$element = array_merge($element, $arr);
}
}
/**
* @param array $elements
* @throws \qfq\UserException
*/
public static function explodeParameterInArrayElements(array &$elements)
{
foreach ($elements AS $key => $element) {