Commit 3f6fedaa authored by Carsten  Rose's avatar Carsten Rose
Browse files

UserReportException.php: Added field SYSTEM_REPORT_COLUMN_NAME to output....

UserReportException.php: Added field SYSTEM_REPORT_COLUMN_NAME to output. Array members renamed to SYSTEM_*.
Various files adjusted to inlcude renamed file `UserFormException.php`.
Link.php: Mamut switch() in parseItem() refactored to use $callTable.
Report.php: refactoring started to use UserReportException() instead of SyntaxReportException. Startet removing all fr_error usages.
parent 9040de60
......@@ -15,7 +15,7 @@ use qfq\OnArray;
require_once(__DIR__ . '/../qfq/store/Store.php');
require_once(__DIR__ . '/../qfq/Constants.php');
require_once(__DIR__ . '/../qfq/exceptions/DbException.php');
require_once(__DIR__ . '/../qfq/exceptions/UserException.php');
require_once(__DIR__ . '/../qfq/exceptions/UserFormException.php');
require_once(__DIR__ . '/../qfq/Database.php');
require_once(__DIR__ . '/../qfq/helper/HelperFormElement.php');
require_once(__DIR__ . '/../qfq/helper/Support.php');
......
......@@ -14,7 +14,7 @@ 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
......
......@@ -135,6 +135,9 @@ const ERROR_IO_READ_FILE = 1200;
const ERROR_IO_WRITE = 1203;
const ERROR_IO_OPEN = 1204;
//Report
const ERROR_UNKNOWN_LINK_QUALIFIER = 1300;
// KeyValueParser
const ERROR_KVP_VALUE_HAS_NO_KEY = 1900;
......@@ -238,7 +241,8 @@ 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_KEY = 'reportColumnKey'; // Keyname of SQL-column processed at the moment.
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.
......
......@@ -15,7 +15,7 @@ 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');
......
......@@ -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');
......
......@@ -17,8 +17,7 @@ require_once(__DIR__ . '/AbstractException.php');
*
* @package qfq\exceptions
*/
class UserFormException extends AbstractException {
class UserReportException extends AbstractException {
/*
* @return string HTML formatted error string
......@@ -26,10 +25,11 @@ class UserFormException extends AbstractException {
public function formatMessage() {
$this->messageArray['Type'] = 'User Report Exception';
$this->messageArray['SqlRaw'] = Store::getVar(SYSTEM_FORM, STORE_SYSTEM);
$this->messageArray['SqlFinal'] = Store::getVar(SYSTEM_SQL_FINAL, STORE_SYSTEM);
$this->messageArray['ColumnKey'] = Store::getVar(SYSTEM_REPORT_COLUMN_KEY, STORE_SYSTEM);
$this->messageArray['ColumnValue'] = Store::getVar(SYSTEM_REPORT_COLUMN_VALUE, STORE_SYSTEM);
$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();
}
......
......@@ -15,7 +15,7 @@ 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
{
......
......@@ -13,7 +13,7 @@ namespace qfq;
use qfq;
use qfq\UserFormException;
require_once(__DIR__ . '/../exceptions/UserException.php');
require_once(__DIR__ . '/../exceptions/UserFormException.php');
require_once(__DIR__ . '/../../qfq/Constants.php');
/**
......
......@@ -9,7 +9,7 @@
namespace qfq;
require_once(__DIR__ . '/../Constants.php');
require_once(__DIR__ . '/../exceptions/UserException.php');
require_once(__DIR__ . '/../exceptions/UserFormException.php');
class Logger {
......
......@@ -188,7 +188,7 @@ class CodeReportException extends \Exception {
* @param string $file
* @param string $line
*/
class UserReportException extends \Exception {
class UserReportExceptionUnused extends \Exception {
protected $file;
protected $line;
......
This diff is collapsed.
......@@ -19,6 +19,7 @@ require_once(__DIR__ . '/Error.php');
require_once(__DIR__ . '/../Database.php');
require_once(__DIR__ . '/Link.php');
require_once(__DIR__ . '/Sendmail.php');
require_once(__DIR__ . '/../exceptions/UserReportExtension.php');
class Report {
......@@ -28,6 +29,11 @@ class Report {
*/
private $sip = null;
/**
* @var Store
*/
private $store = null;
/**
* @var string
*/
......@@ -87,6 +93,7 @@ class Report {
$this->t3data = $t3data;
$this->sip = new Sip($sessionName, $phpUnit);
$this->store = Store::getInstance();
$this->page_control["msgbox"]["pagec"] = "Please confirm!";
......@@ -162,10 +169,6 @@ class Report {
* @return void
*/
private function parseFRLine($ttLine) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'parseFRLine'));
}
// 10.50.5.sql = select ...
$arr = explode("=", trim($ttLine), 2);
......@@ -204,10 +207,6 @@ class Report {
* @param $value
*/
private function setLine($level, $frCmd, $value) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'setLine'));
}
// store complete line reformatted in frArray
$this->frArray[$level . "." . $frCmd] = $value;
......@@ -231,10 +230,6 @@ class Report {
* @return The content that is displayed on the website
*/
private function sortIndexArray(array &$ary, $clause, $ascending = true) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'sortIndexArray'));
}
$clause = str_ireplace('order by', '', $clause);
$clause = preg_replace('/\s+/', ' ', $clause);
......@@ -289,10 +284,6 @@ class Report {
* @return string
*/
private function generateSortArg() {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'generateSortArg'));
}
$sortArg = "";
......@@ -327,10 +318,6 @@ class Report {
private function triggerReport($cur_level = 1, array $super_level_array = array(), $counter = 0) {
$keys = array();
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'triggerReport'));
}
$lineDebug = 0;
$content = "";
......@@ -371,37 +358,17 @@ class Report {
// Set debug, if one is specified else keep the parent one.
$lineDebug = $this->getValueParentDefault("debug", $full_super_level, $full_level, $cur_level, 0);
$this->fr_error["debug_level"] = max($lineDebug, $this->fr_error["debug_level"]); // collect the biggest debuglevel >> debug $_SESSION at the end.
// Prepare Error reporting
$this->fr_error["row"] = $full_level . ".sql = " . $this->frArray[$full_level . ".sql"];
$this->fr_error["full_level"] = $full_level . ".sql";
// Setter function to emulate global variables
//TODO implement logging
// $this->db->set_fr_error($this->fr_error);
$this->log->set_fr_error($this->fr_error);
// Debug
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('full_level' => $full_level));
}
$this->store->setVar(SYSTEM_SQL_RAW, $this->frArray[$full_level . ".sql"], STORE_SYSTEM);
$this->store->setVar(SYSTEM_REPORT_FULL_LEVEL, $full_level, STORE_SYSTEM);
// Prepare SQL: replace variables. Actual 'line.total' or 'line.count' will recalculated: don't replace them now!
unset($this->variables->resultArray[$full_level . ".line."]["total"]);
unset($this->variables->resultArray[$full_level . ".line."]["count"]);
$sql = $this->variables->doVariables($this->frArray[$full_level . ".sql"]);
// DEBUG
if ($this->fr_error["debug_level"] >= DEBUG_SQL) {
// T3 function: debug()
// debug(array("native" => $full_level . ".sql = " . $this->frArray[$full_level . ".sql"], "replaced" => $full_level . ".sql = " . $sql));
}
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug($this->variables->resultArray);
}
$this->store->setVar(SYSTEM_SQL_FINAL, $sql, STORE_SYSTEM);
//Execute SQL. All errors have been already catched.
unset($result);
......@@ -436,17 +403,11 @@ class Report {
$row[$ii] = str_replace("{{" . $full_level . ".line.total}}", $rowTotal, $row[$ii]);
}
// Create Assoc Array of result
// unset($rowAssoc);
// for ($i = 0; $i < count($row); $i++) {
// $rowAssoc[$keys[$i]] = $row[$i];
// }
// SEP set seperator (empty on first run)
$content .= $columnValueSeperator;
$columnValueSeperator = $this->variables->doVariables($this->frArray[$full_level . "." . "rsep"]);
// RBGD: gerade- ungerade- Zeilen/Rows
// RBGD: even/odd rows
$content .= str_replace("rbgd", $arrRbgd[$rowIndex % 2], $this->frArray[$full_level . "." . "rbeg"]);
//-----------------------------
......@@ -497,10 +458,6 @@ class Report {
* @return string The calculated value.
*/
private function getValueParentDefault($level_key, $full_super_level, $full_level, $cur_level, $default) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'getValueParentDefault'));
}
if ($this->frArray[$full_level . "." . $level_key]) {
$value = $this->frArray[$full_level . "." . $level_key];
......@@ -529,19 +486,12 @@ class Report {
private function collectRow(array $row, array $keys, $full_level, $rowIndex) {
$content = "";
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'collectRow'));
}
$fsep = '';
for ($ii = 0; $ii < count($keys); $ii++) {
$this->fr_error["columnIndex"] = $ii; // Debugging Information
// Setter Function to emulate global variables.
//TODO implement logging
// $this->db->set_fr_error($this->fr_error);
$this->log->set_fr_error($this->fr_error);
$this->store->setVar(SYSTEM_REPORT_COLUMN_INDEX, $ii + 1, STORE_SYSTEM);
$this->store->setVar(SYSTEM_REPORT_COLUMN_NAME, $keys[$ii], STORE_SYSTEM);
$this->store->setVar(SYSTEM_REPORT_COLUMN_VALUE, $row[$ii], STORE_SYSTEM);
$tmp = $this->renderColumn($ii, $keys[$ii], $row[$ii], $full_level, $rowIndex, $show);
if ($show) {
......@@ -569,11 +519,7 @@ class Report {
* @throws SyntaxReportException
*/
private function renderColumn($columnIndex, $columnName, $columnValue, $full_level, $rowIndex, &$show) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'renderColumn'));
}
#debug(array('columnIndex'=>$columnIndex, 'columnName'=>$columnName, 'columnValue'=>$columnValue,'full_level'=>$full_level,"rowIndex"=>$rowIndex));
$show = TRUE;
if (substr($columnName, 0, 1) == "_") {
$show = false;
......@@ -776,10 +722,6 @@ class Report {
* @return string The content that is displayed on the website
*/
private function myExec($cmd) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'myExec'));
}
exec($cmd, $arr, $rc);
......@@ -823,10 +765,6 @@ class Report {
* @throws SyntaxReportException
*/
private function doFixColPosPage($columnName, $columnValue) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'doFixColPosPage'));
}
$link = "";
......@@ -881,11 +819,6 @@ class Report {
*/
private function composeLinkPart($qualifier, $value, $defaultValue = "") {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'composeLinkPart'));
}
if (!$value) $value = $defaultValue;
if ($value)
......@@ -905,11 +838,6 @@ class Report {
private function doPage($columnName, $columnValue) {
$defaultQuestion = '';
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'doPage'));
}
$param = explode('|', $columnValue);
# get all defaultvalues, depending on the columnname
......@@ -960,10 +888,6 @@ class Report {
* @return string
*/
private function form2hash($formName, $formRecordId) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'form2hash'));
}
$hash = $this->utils->randomAlphaNumUnique();
$_SESSION[FORMREPORT][$hash]['formName'][0] = $formName;
......@@ -984,10 +908,6 @@ class Report {
* @return string
*/
private function getResultArrayIndex($variable) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'getResultArrayIndex'));
}
$variable = substr($variable, 1, strlen($variable));
return "[" . preg_replace_callback("/[a-z]/", "replaceToIndex", $variable) . "][" . preg_replace_callback("/[^a-z]/", "replaceToIndex", $variable) . "]";
......@@ -1000,10 +920,6 @@ class Report {
* @return bool
*/
private function compareArraystart($arr1, $arr2) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'compareArraystart'));
}
for ($i = 0; $i < count($arr1); $i++) {
if ($arr1[$i] != $arr2[$i]) {
......@@ -1019,10 +935,6 @@ class Report {
* @return bool
*/
private function compareArraylength($arr1, $arr2) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'compareArraylength'));
}
if (count($arr1) + 1 == count($arr2)) {
return true;
......
......@@ -10,7 +10,7 @@ namespace qfq;
//use qfq;
require_once(__DIR__ . '/../../qfq/BodytextParser.php');
require_once(__DIR__ . '/../../qfq/exceptions/UserException.php');
require_once(__DIR__ . '/../../qfq/exceptions/UserFormException.php');
class BodytextParserTest extends \PHPUnit_Framework_TestCase {
......
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