diff --git a/extension/qfq/qfq/AbstractBuildForm.php b/extension/qfq/qfq/AbstractBuildForm.php index 7d9a713b19de72061aae8e6ccb716e3a7eb7feed..7d4dd0ae57008c7a48793ebdd1a80744cdd0eca5 100644 --- a/extension/qfq/qfq/AbstractBuildForm.php +++ b/extension/qfq/qfq/AbstractBuildForm.php @@ -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'); diff --git a/extension/qfq/qfq/BuildFormBootstrap.php b/extension/qfq/qfq/BuildFormBootstrap.php index d620366a68f0a07e0ed26275cc2629275d61d28f..aa94e679507767362759fb403546eb92d223fd27 100644 --- a/extension/qfq/qfq/BuildFormBootstrap.php +++ b/extension/qfq/qfq/BuildFormBootstrap.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 diff --git a/extension/qfq/qfq/Constants.php b/extension/qfq/qfq/Constants.php index fc134c283c302e62ec801375e5db6498f6ee28ea..5123df15e1a8fb6722689fb2a06945a1f22b9178 100644 --- a/extension/qfq/qfq/Constants.php +++ b/extension/qfq/qfq/Constants.php @@ -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. diff --git a/extension/qfq/qfq/Database.php b/extension/qfq/qfq/Database.php index 6b7b5830f4abacb63584abbaee5e08b0e629b931..0ab2685ca8408899ce89e6ba4a8d7d930ac50297 100644 --- a/extension/qfq/qfq/Database.php +++ b/extension/qfq/qfq/Database.php @@ -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'); diff --git a/extension/qfq/qfq/QuickFormQuery.php b/extension/qfq/qfq/QuickFormQuery.php index 0240671e4f41f1e741dee0bae68e28b6987a6f53..f9237e1233045f14ffc9ccffa143616d767f1e52 100644 --- a/extension/qfq/qfq/QuickFormQuery.php +++ b/extension/qfq/qfq/QuickFormQuery.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'); diff --git a/extension/qfq/qfq/exceptions/UserReportExtension.php b/extension/qfq/qfq/exceptions/UserReportExtension.php index 90f2f48221d70be73cce4e1c5088184264ab68eb..2d7035db35c820977b10bfe91a07d28706053f17 100644 --- a/extension/qfq/qfq/exceptions/UserReportExtension.php +++ b/extension/qfq/qfq/exceptions/UserReportExtension.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(); } diff --git a/extension/qfq/qfq/helper/HelperFormElement.php b/extension/qfq/qfq/helper/HelperFormElement.php index 7938a6603d4fccbaa86551a4c5863278d57d4dda..0d2bf4fc944b04c6a827c8d28469e77f8c1ab011 100644 --- a/extension/qfq/qfq/helper/HelperFormElement.php +++ b/extension/qfq/qfq/helper/HelperFormElement.php @@ -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 { diff --git a/extension/qfq/qfq/helper/KeyValueStringParser.php b/extension/qfq/qfq/helper/KeyValueStringParser.php index 9a56740545e7349fcba552c98ae321fe1f6edeb6..690e8911a458c4409ba99c3f4481528b98cb99a0 100644 --- a/extension/qfq/qfq/helper/KeyValueStringParser.php +++ b/extension/qfq/qfq/helper/KeyValueStringParser.php @@ -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'); /** diff --git a/extension/qfq/qfq/helper/Logger.php b/extension/qfq/qfq/helper/Logger.php index f9821dca8314c7215f69919d4718dbf070698c3d..4ea913a7a3450ca6fe15aef2e8480afa4cdc37ca 100644 --- a/extension/qfq/qfq/helper/Logger.php +++ b/extension/qfq/qfq/helper/Logger.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 { diff --git a/extension/qfq/qfq/report/Error.php b/extension/qfq/qfq/report/Error.php index 05cad47475331c7e4b007593c9de88feb5bce1f0..5e0a52fa83d311ffe194bfb178024254da576198 100644 --- a/extension/qfq/qfq/report/Error.php +++ b/extension/qfq/qfq/report/Error.php @@ -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; diff --git a/extension/qfq/qfq/report/Link.php b/extension/qfq/qfq/report/Link.php index e9abe0f4ef8d39346814bf19cfbb0e5623afb316..72dba60b82a093dc82bf4a13996966185971f604 100644 --- a/extension/qfq/qfq/report/Link.php +++ b/extension/qfq/qfq/report/Link.php @@ -42,7 +42,7 @@ require_once(__DIR__ . '/../store/Sip.php'); * * r:render * g:target - * c:class [n|i|e]:<class> + * c:class [n|i|e|<class>] * q:question <text> * e:encryption 0|1 * @@ -92,11 +92,40 @@ class Link { private $cssLinkClassInternal = ''; private $cssLinkClassExternal = ''; + private $callTable = [ + 'u' => 'buildUrl', + 'm' => 'buildMail', + 'p' => 'buildPage', + 't' => 'buildText', + 'a' => 'buildAltText', + 'o' => 'buildToolTip', + 'P' => 'buildPicture', + 'B' => 'buildBullet', + 'C' => 'buildCheck', + 'D' => 'buildDelete', + 'E' => 'buildEdit', + 'H' => 'buildHelp', + 'I' => 'buildInfo', + 'N' => 'buildNew', + 'S' => 'buildShow', + 'r' => 'buildRender', + 'g' => 'buildTarget', + 'c' => 'buildClass', + 'q' => 'buildQuestion', + 'e' => 'buildEncryption', + 'h' => 'buildHash', + 'U' => 'buildUrlParams', + 'R' => 'buildRightOfText', + 'G' => 'buildGrafic', + 'A' => 'buildAnchor', + ]; + /** * __construct * * @param $fr_error * @param Sip $sip + * @param bool $phpUnit */ public function __construct($fr_error, Sip $sip, $phpUnit = false) { $this->fr_error = $fr_error; @@ -165,9 +194,9 @@ class Link { /** * Build the whole link * - * @param string $str : Qualifier with params. 'report'-syntax. F.e.: A:u:www.example.com|G:P:home.gif|t:Home" - * - * @return string The complete Link + * @param string $str Qualifier with params. 'report'-syntax. F.e.: A:u:www.example.com|G:P:home.gif|t:Home" + * @return string The complete HTML encoded Link like <a href='http://example.com' class='external'><img src='iconf.gif' title='help text'>Description</a> + * @throws SyntaxReportException */ public function renderLink($str) { $link = ''; @@ -181,23 +210,29 @@ class Link { // Parse all parameter, fill variables foreach ($param as $item) { + if ($item == '') { + continue; + } + // set class defaults $this->parseItem($vars, $item); } // if there is no url or mailto definition: {{global.pageId}} - if ($vars['url'] == '' && $vars['mailto'] == '') { - $vars['url'] = "?" . $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3); - } +// if ($vars['url'] == '' && $vars['mailto'] == '') { +// $vars['url'] = "?" . $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3); +// } $this->doCssClass($vars); - $htmlUrl = $this->doUrl($vars); - $htmlImage = $this->doImage($vars); + $htmlUrl = $this->doHtmlUrl($vars); + $htmlImage = $this->doHtmlImage($vars); // Compose Image & Text - $distance = ' '; - $vars['text'] = ($vars['picturePosition'] == "l") ? $htmlImage . $distance . $vars['text'] : $vars['text'] . $distance . $htmlImage; + if ($htmlImage != '') { + $distance = ' '; + $vars['text'] = ($vars['picturePosition'] == "l") ? $htmlImage . $distance . $vars['text'] : $vars['text'] . $distance . $htmlImage; + } // ToolTip $extraSpan = ['', '']; @@ -218,7 +253,18 @@ class Link { } // Compose URL // get Render Mode via Array renderControl - $mode = $prefix . $this->renderControl[$vars['modeRender']][$vars['url'] ? 1 : 0][$vars['text'] ? 1 : 0]; + $modeRender = $vars['modeRender']; + $modeUrl = $vars['url'] ? 1 : 0; + $modeText = $vars['text'] ? 1 : 0; + + if (isset($this->renderControl[$modeRender][$modeUrl][$modeText])) { + $mode = $prefix . $this->renderControl[$modeRender][$modeUrl][$modeText]; + } else { + throw new SyntaxReportException ("Undefined combination of rendering mode / url given / text given: " . + $modeRender . ' / ' . $modeUrl . ' / ' . $modeText, "", null, __FILE__, __LINE__, + "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + // 0-4 URL, plain email // 10-14 encrypted email switch ($mode) { @@ -274,7 +320,12 @@ class Link { } - private function clearVars(&$vars) { + /** + * Cleans the standard vars used every time to render a link. + * + * @param array $vars + */ + private function clearVars(array &$vars) { $vars['mailto'] = ""; $vars['url'] = ""; $vars['pageAlias'] = ''; @@ -302,200 +353,39 @@ class Link { /** * Parse Item of link string, fill class global variables. * - * @param string $key : F.e.: 'u' - * @param string $value : F.e.: 'http://www.nzz.ch' + * @param array $vars + * @param $item + * @throws CodeException * @throws SyntaxReportException */ - private - function parseItem(&$vars, $item) { + private function parseItem(array &$vars, $item) { $key = ''; $value = ''; $arr = explode(":", $item, 2); - switch (count($arr)) { - case 0: - return; - break; - - case 1: - $key = $arr[0]; - break; - - case 2: - $key = $arr[0]; - $value = $arr[1]; - break; - - default: - throw new CodeException("This statement should never be reached", ERROR_CODE_SHOULD_NOT_HAPPEN); - + $key = isset($arr[0]) ? $arr[0] : ''; + $value = isset($arr[1]) ? $arr[1] : ''; + +// if($key == '') { +// return; +// } +// + if (!isset($this->callTable[$key])) { + throw new UserReportException ("Unknown link qualifier: '$key'", ERROR_UNKNOWN_LINK_QUALIFIER); } - switch ($key) { - // URL - case "u": - if ($vars['url'] || $vars['mailto']) - throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['url'] = $value; - $vars['defaultLinkClass'] = $this->cssLinkClassExternal; - break; - case "m": - if ($vars['url'] || $vars['mailto']) - throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['mailto'] = $value; - $vars['defaultLinkClass'] = $this->cssLinkClassExternal; - break; - case "p": - if ($vars['url'] || $vars['mailto']) - throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['pageAlias'] = $value ? $value : $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3); // If no pageid|pagealias is defined, take current page -// $this->url = "?" . $this->pageAlias; - $vars['defaultLinkClass'] = $this->cssLinkClassInternal; - break; - - // Text - case "t": - $vars['text'] = $value; - break; - case "a": - $vars['altText'] = $value; - break; - case "o": - $vars['toolTip'] = $this->utils->createToolTip($value); - break; - - // Image - case "P": - if ($vars['image']) - throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['image'] = $value; - $vars['AltText'] = "Grafic: " . $value; - $vars['imageTitle'] = $value; - break; - case "B": - if ($vars['image']) - throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['image'] = PATH_ICONS . "bullet-" . ($value ? $value : "green") . '.gif'; - $vars['defaultAltText'] = "Bullet: " . $value; - $vars['imageTitle'] = $value; - break; - case "C": - if ($vars['image']) - throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['image'] = PATH_ICONS . "checked-" . ($value ? $value : "green") . '.gif'; - $vars['defaultAltText'] = "Checked: " . $value; - $vars['imageTitle'] = $value; - break; - case "D": - if ($vars['image']) - throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['image'] = PATH_ICONS . 'delete.gif'; - $vars['defaultAltText'] = "Delete"; - $vars['imageTitle'] = "Delete"; - $vars['delete'] = true; - // Include Extjs library - $this->utils->loadJSlib($this->fr_error); - break; - case "E": - if ($vars['image']) - throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['image'] = PATH_ICONS . 'edit.gif'; - $vars['defaultAltText'] = "Edit"; - $vars['imageTitle'] = "Edit"; - break; - case "H": - if ($vars['image']) - throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['image'] = PATH_ICONS . 'help.gif'; - $vars['defaultAltText'] = "Help"; - $vars['imageTitle'] = "Help"; - break; - case "I": - if ($vars['image']) - throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['image'] = PATH_ICONS . 'info.gif'; - $vars['defaultAltText'] = "Information"; - $vars['imageTitle'] = "Information"; - break; - case "N": - if ($vars['image']) - throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['image'] = PATH_ICONS . 'new.gif'; - $vars['defaultAltText'] = "New"; - $vars['imageTitle'] = "New"; - break; - case "S": - if ($vars['image']) - throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['image'] = PATH_ICONS . 'show.gif'; - $vars['defaultAltText'] = "Details"; - $vars['imageTitle'] = "Details"; - break; - - // Misc - case "r": - if ($vars['modeRender']) - throw new SyntaxReportException ("Multiple render modes defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['modeRender'] = $value; - break; - case "g": - if ($vars['target']) - throw new SyntaxReportException ("Multiple 'target' defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['target'] = $value; - break; - case "c": - if ($vars['linkClass']) - throw new SyntaxReportException ("Multiple linkClass defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['linkClass'] = $value; - break; - case "q": - if ($vars['question']) - throw new SyntaxReportException ("Multiple question defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['question'] = $value ? $value : "Please confirm"; - break; - case "e": - if ($vars['encryption'] != 1) - throw new SyntaxReportException ("Multiple encryption defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['encryption'] = $value ? $value : "1"; - break; - case "h": - if ($vars['modeHash']) - throw new SyntaxReportException ("Multiple modeHash defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['modeHash'] = TRUE; - break; - case "U": //if($this->additionalUrlParams) throw new syntaxException ( "Multiple additionalUrlParams defined: '$key'","",__FILE__,__LINE__, "Column: " . $fthis->r_error["columnIndex"], $this->fr_error); - $vars['additionalUrlParams'] = $value; - break; - case "R": - if ($vars['picturePosition'] != "l") - throw new SyntaxReportException ("Multiple picturePosition defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $vars['picturePosition'] = "r"; - break; - - // A,G - case "G": - case "A": - // set class defaults - $this->parseItem($vars, $value); - break; - case "" : - break; - default: - throw new SyntaxReportException ("Unknown link qualifier: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - - } + $call = $this->callTable[$key]; + $this->$call($vars, $key, $value); } /** * Parse CSS Class Settings * - * @param void - * + * @param array $vars * @return void */ - private - function doCssClass(&$vars) { + private function doCssClass(array &$vars) { $class = ''; switch ($vars['linkClass']) { @@ -518,11 +408,11 @@ class Link { * - <a href="http://example.com:>http://example.com</a> * - If $this->modeHash is set, create a * + * @param array $vars * @return string * @throws SyntaxReportException */ - private - function doUrl(&$vars) { + private function doHtmlUrl(array &$vars) { $tags = ''; // build URL $htmlUrl = ""; @@ -574,8 +464,7 @@ class Link { * @internal param $void * */ - private - function doImage($vars) { + private function doHtmlImage(array $vars) { $tags = ''; // Build Image @@ -601,15 +490,11 @@ class Link { * document.write("<a href=" + "mail" + "to:" + mm1 + mm2 + ... + ">" + tld + "</a>") * //--></script>'; * - * @param string $mailto Email address to encrypt. - * @param string $text Text to wrap <a href..>, </a> around. - * @param string $class Optional class definition - * @param bool $href TRUE: create a '<a>', false: just encrypt or show the email, no link. - * - * @return string The complete Link + * @param array $vars + * @param bool|TRUE $href TRUE: create a '<a>', false: just encrypt or show the email, no link. + * @return string */ - private - function encryptMailtoJS($vars, $href = TRUE) { + private function encryptMailtoJS(array $vars, $href = TRUE) { // Split $mailto $tmp = $this->splitAndAddDelimter($vars['mailto'], "@"); @@ -659,8 +544,8 @@ class Link { * @param $delimiter * @return array */ - private - function splitAndAddDelimter($mailto, $delimiter) { + private function splitAndAddDelimter($mailto, $delimiter) { + //TODO: Ich verstehe die Funktion nicht - funktioniert das hier wirklich? $value = ''; $arr = explode($delimiter, $mailto); // split string @@ -674,4 +559,344 @@ class Link { return ($arr); } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildUrl(&$vars, $key, $value) { + if ($vars['url'] || $vars['mailto']) { + throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['url'] = $value; + $vars['defaultLinkClass'] = $this->cssLinkClassExternal; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildMail(&$vars, $key, $value) { + if ($vars['url'] || $vars['mailto']) { + throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['mailto'] = $value; + $vars['defaultLinkClass'] = $this->cssLinkClassExternal; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildPage(&$vars, $key, $value) { + if ($vars['url'] || $vars['mailto']) { + throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + + $vars['pageAlias'] = $value ? $value : $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3); // If no pageid|pagealias is defined, take current page + $vars['url'] = "?" . $vars['pageAlias']; + $vars['defaultLinkClass'] = $this->cssLinkClassInternal; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildText(&$vars, $key, $value) { + $vars['text'] = $value; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildAltText(&$vars, $key, $value) { + $vars['altText'] = $value; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildToolTip(&$vars, $key, $value) { + $vars['toolTip'] = $this->utils->createToolTip($value); + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildPicture(&$vars, $key, $value) { + if ($vars['image']) { + throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['image'] = $value; + $vars['AltText'] = "Grafic: " . $value; + $vars['imageTitle'] = $value; + } + + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildBullet(&$vars, $key, $value) { + if ($vars['image']) { + throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['image'] = PATH_ICONS . "bullet-" . ($value ? $value : "green") . '.gif'; + $vars['defaultAltText'] = "Bullet: " . $value; + $vars['imageTitle'] = $value; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildCheck(&$vars, $key, $value) { + if ($vars['image']) { + throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['image'] = PATH_ICONS . "checked-" . ($value ? $value : "green") . '.gif'; + $vars['defaultAltText'] = "Checked: " . $value; + $vars['imageTitle'] = $value; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildDelete(&$vars, $key, $value) { + if ($vars['image']) { + throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['image'] = PATH_ICONS . 'delete.gif'; + $vars['defaultAltText'] = "Delete"; + $vars['imageTitle'] = "Delete"; + $vars['delete'] = true; + // Include Extjs library + $this->utils->loadJSlib($this->fr_error); + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildEdit(&$vars, $key, $value) { + if ($vars['image']) { + throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['image'] = PATH_ICONS . 'edit.gif'; + $vars['defaultAltText'] = "Edit"; + $vars['imageTitle'] = "Edit"; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildHelp(&$vars, $key, $value) { + if ($vars['image']) { + throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['image'] = PATH_ICONS . 'help.gif'; + $vars['defaultAltText'] = "Help"; + $vars['imageTitle'] = "Help"; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildInfo(&$vars, $key, $value) { + if ($vars['image']) { + throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['image'] = PATH_ICONS . 'info.gif'; + $vars['defaultAltText'] = "Information"; + $vars['imageTitle'] = "Information"; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildNew(&$vars, $key, $value) { + if ($vars['image']) { + throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['image'] = PATH_ICONS . 'new.gif'; + $vars['defaultAltText'] = "New"; + $vars['imageTitle'] = "New"; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildShow(&$vars, $key, $value) { + if ($vars['image']) { + throw new SyntaxReportException ("Multiple images defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['image'] = PATH_ICONS . 'show.gif'; + $vars['defaultAltText'] = "Details"; + $vars['imageTitle'] = "Details"; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildRender(&$vars, $key, $value) { + if ($vars['modeRender']) { + throw new SyntaxReportException ("Multiple render modes defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['modeRender'] = $value; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildTarget(&$vars, $key, $value) { + if ($vars['target']) { + throw new SyntaxReportException ("Multiple 'target' defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['target'] = $value; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildClass(&$vars, $key, $value) { + if ($vars['linkClass']) { + throw new SyntaxReportException ("Multiple linkClass defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['linkClass'] = $value; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildQuestion(&$vars, $key, $value) { + if ($vars['question']) { + throw new SyntaxReportException ("Multiple question defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['question'] = $value ? $value : "Please confirm"; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildEncryption(&$vars, $key, $value) { + if ($vars['encryption'] != 1) { + throw new SyntaxReportException ("Multiple encryption defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['encryption'] = $value ? $value : "1"; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildHash(&$vars, $key, $value) { + if ($vars['modeHash']) { + throw new SyntaxReportException ("Multiple modeHash defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + } + $vars['modeHash'] = TRUE; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildUrlParams(&$vars, $key, $value) { + $vars['additionalUrlParams'] = $value; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildRightOfText(&$vars, $key, $value) { + if ($vars['picturePosition'] != "l") + throw new SyntaxReportException ("Multiple picturePosition defined: '$key'", "", null, __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + $vars['picturePosition'] = "r"; + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildGrafic(&$vars, $key, $value) { + //TODO: hier kann etwas nicht stimmen. Der Code ist identisch von buildAnchor & buildGrafic + + // set class defaults + $this->parseItem($vars, $value); + } + + /** + * @param $vars + * @param $key + * @param $value + * @throws SyntaxReportException + */ + private function buildAnchor(&$vars, $key, $value) { + //TODO: hier kann etwas nicht stimmen. Der Code ist identisch von buildAnchor & buildGrafic + + // set class defaults + $this->parseItem($vars, $value); + } + } \ No newline at end of file diff --git a/extension/qfq/qfq/report/Report.php b/extension/qfq/qfq/report/Report.php index 33b56180e362c93493a351cc8a80fbe8291e1b66..03973567ebcb1db15115eb11e3ec7951267539bc 100644 --- a/extension/qfq/qfq/report/Report.php +++ b/extension/qfq/qfq/report/Report.php @@ -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; diff --git a/extension/qfq/tests/phpunit/BodytextParserTest.php b/extension/qfq/tests/phpunit/BodytextParserTest.php index f761587ad2d6015ae1f961e5efbaaf98c1283b5d..f6e00a69f83e605a1d11f9926f84976793179ed4 100644 --- a/extension/qfq/tests/phpunit/BodytextParserTest.php +++ b/extension/qfq/tests/phpunit/BodytextParserTest.php @@ -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 {