From d08f752cca110d5484ddaadd67e89b5d110b862a Mon Sep 17 00:00:00 2001 From: Carsten Rose <carsten.rose@math.uzh.ch> Date: Tue, 2 Feb 2016 21:16:01 +0100 Subject: [PATCH] AbstractException: dump arrays too. DbException: minor renaming. HelpFormElement: New buildFormElementId. Support: New log(). --- qfq/exceptions/AbstractException.php | 3 +++ qfq/exceptions/DbException.php | 2 +- qfq/helper/HelperFormElement.php | 4 ++++ qfq/helper/Support.php | 19 +++++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/qfq/exceptions/AbstractException.php b/qfq/exceptions/AbstractException.php index e50054b32..ebaaa9e29 100644 --- a/qfq/exceptions/AbstractException.php +++ b/qfq/exceptions/AbstractException.php @@ -46,6 +46,9 @@ class AbstractException extends \Exception { // Layout $html = '<tr bgcolor="#dddddd"><td colspan="2">Exception</td></tr>'; foreach ($this->messageArray as $key => $value) { + if(is_array($value)) { + $value = var_export($value, true); + } $html .= "<tr>" . "<td>$key</td>" . "<td>$value</td>" . "</tr>"; } diff --git a/qfq/exceptions/DbException.php b/qfq/exceptions/DbException.php index 47562938f..88c838496 100644 --- a/qfq/exceptions/DbException.php +++ b/qfq/exceptions/DbException.php @@ -30,7 +30,7 @@ class DbException extends AbstractException { $this->messageArray['Form Element'] = Store::getVar(SYSTEM_FORM_ELEMENT, STORE_SYSTEM); $this->messageArray['Form Element Column'] = Store::getVar(SYSTEM_FORM_ELEMENT_COLUMN, STORE_SYSTEM); $this->messageArray['SQL before evaluation'] = Store::getVar(SYSTEM_SQL_RAW, STORE_SYSTEM); - $this->messageArray['SQL after evaluation'] = Store::getVar(SYSTEM_SQL_FINAL, STORE_SYSTEM); + $this->messageArray['SQL final'] = Store::getVar(SYSTEM_SQL_FINAL, STORE_SYSTEM); $this->messageArray['SQL Params'] = Store::getVar(SYSTEM_SQL_PARAM_ARRAY, STORE_SYSTEM); return parent::formatException(); diff --git a/qfq/helper/HelperFormElement.php b/qfq/helper/HelperFormElement.php index aaa156f51..14ee1afe0 100644 --- a/qfq/helper/HelperFormElement.php +++ b/qfq/helper/HelperFormElement.php @@ -50,4 +50,8 @@ class HelperFormElement { } } + public static function buildFormElementId($field, $id) { + return($field . ':' . $id); + } + } \ No newline at end of file diff --git a/qfq/helper/Support.php b/qfq/helper/Support.php index f1fa8b8bd..0d3b0d56f 100644 --- a/qfq/helper/Support.php +++ b/qfq/helper/Support.php @@ -60,4 +60,23 @@ class Support { return implode('&', $items); } + + /** + * @throws CodeException + */ + public static function log($text) { + + if (!is_writable(QFQ_LOG)) { + throw new CodeException ("The file (" . dirname($_SERVER['SCRIPT_FILENAME']) . '/) ' . QFQ_LOG . " is not writable ()", ERROR_LOG_NOT_WRITABLE); + } + + if (!$handle = fopen(QFQ_LOG, 'a')) { + throw new CodeException ("Cannot open file to apped: " . QFQ_LOG, ERROR_LOG_NOT_WRITABLE); + } + + if (fwrite($handle, $text . chr(10)) === FALSE) { + throw new CodeException ("Cannot write to file: " . QFQ_LOG, ERROR_LOG_NOT_WRITABLE); + } + fclose($handle); + } } \ No newline at end of file -- GitLab