diff --git a/extension/Classes/Controller/QfqController.php b/extension/Classes/Controller/QfqController.php index 0e3b92b6f62f5971f6f68f0ebc5cc648a604e0ea..e9d5583327103f34b6227cef337701f74c4eccdf 100644 --- a/extension/Classes/Controller/QfqController.php +++ b/extension/Classes/Controller/QfqController.php @@ -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(); diff --git a/extension/Documentation/Settings.yml b/extension/Documentation/Settings.yml index 5c435c011cc00008f4298d45de006ade0c1374b5..6a6bcfe032b9d209ffbe1535f15d38b98eb2e60f 100644 --- a/extension/Documentation/Settings.yml +++ b/extension/Documentation/Settings.yml @@ -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 diff --git a/extension/Documentation/UsersManual/Index.rst b/extension/Documentation/UsersManual/Index.rst index 46bbe8e0e73fd01d3037757177bd406ae56ebd10..5eb8d2639595e1579ba819262e73654a5019fc66 100644 --- a/extension/Documentation/UsersManual/Index.rst +++ b/extension/Documentation/UsersManual/Index.rst @@ -46,9 +46,10 @@ QFQ Keywords (Bodytext) | | * by SIP: **form = {{form}}** | | | * by SQL: **form = {{SELECT c.form FROM conference AS c WHERE c.id={{a:C}} }}** | +-----------------+---------------------------------------------------------------------------------+ - | <level>.db | Select a DB. Only necessary if a different than the standard DB should be used. | + | r | recordId. If specified, the form will load the record with the specified id | + | | * Fix. E.g.: **r = 123**, by SQL: **r = {{SELECT ...}}** | +-----------------+---------------------------------------------------------------------------------+ - | <level>.debug | Debug Level for *report* | + | <level>.db | Select a DB. Only necessary if a different than the standard DB should be used. | +-----------------+---------------------------------------------------------------------------------+ | <level>.fbeg | Start token for every field (=column) | +-----------------+---------------------------------------------------------------------------------+ @@ -75,29 +76,35 @@ QFQ Keywords (Bodytext) | <level>.althead | If <level>.sql is empty, these token will be rendered | +-----------------+---------------------------------------------------------------------------------+ +.. _debug: + Debug ^^^^^ * config.ini: *SHOW_DEBUG_INFO = yes|no|auto* - * 'yes': + * *yes*: - * Show tooltips in forms filled with decoded SIP. - * Shows 'Edit form' button in every form. + * Form: - * 'no': No debug info rendered in the output. + * For every internal link/button, show tooltips with decoded SIP on mouseover. + * Shows 'Edit form' (wrench symbol) button on a form. - * 'auto': + * Report: Will be configured per tt-content record. - * checks if there is a Typo3 BE Session. + *debugShowBodyText = 1* - * yes: *SHOW_DEBUG_INFO = 'yes'* - * no: *SHOW_DEBUG_INFO = 'no'* + * *no*: No debug info. + + * *auto*: Depending if there is a Typo3 BE session, set internally: + + * *SHOW_DEBUG_INFO = yes* (BE session exist) + * *SHOW_DEBUG_INFO = no* (no BE session) Form ---- -* Forms will be created by using the *Form editor*. The Formeditor itself consist of two regular QFQ forms: *form* and *formElement* +* Forms will be created by using the *Form editor* (HTML form). The Formeditor itself consist of two regular QFQ forms: *form* and *formElement* * Every form consist of a) a *Form* record and b) multiple *FormElement* records. * A form is assigned to a *table*. Such a table is called the *primary table* for this form. * There are three types of forms: @@ -139,15 +146,16 @@ Most fields of a form specification might contain: *{{SELECT name FROM person WHERE id={{recordid}} }}* - *{{SELECT name FROM person WHERE id={{key1:C:ALNUMX}} }}* + *{{SELECT name FROM person WHERE id={{key1:C:alnumx}} }}* * Leading and trailing spaces inside curly braces are removed. * *{{ SELECT "Hello World" }}* acts as *{{SELECT "Hello World"}}* * *{{ varname }}* acts as *{{varname}}* -* There are several stores, from where to retrieve the value. If a value is not found in one store, the next store is searched, and so on, - until a value is found. +* There are several stores, from where to retrieve the value. If a value is not found in one store, the next store is searched, + until a value is found or there are no more stores available. +* sdkf * If anywhere along the line an empty string is found, this **is** a value: therefore, the search will stop. * If no value is found, the value is an <empty string>. @@ -155,21 +163,26 @@ URL Parameter ------------- * URL (=GET) Parameter can be used in *forms* and *reports* as variables. -* If a value a parameter sanitize class, an exception is thrown. +* If a value violates a parameter sanitize class, an exception is thrown. Sanitize class -------------- -* All values in Store *C* (Client) and store *F* (Form) will be sanitized with one of three classes: +* All values in Store *C* (Client) and store *F* (Form) will be sanitized: +* All :ref:`predefined-variable-names` have a specific default sanitize class. For these variables, it's not necessary + to specify a sanitize class. +* All other variables (Store: C, F) get by default the sanitize class defined in the corresponding form. If not defined + the default class is 'digit'. +* A default sanitize class can be overwritten by individual definition: *{{a:C:all}}* + * **alnumx**: [A-Za-z][0-9]@-_.,;: /() * **digit**: [0-9].-+ - * **alnumx**: [A-Za-z][0-9]@-_.,; /() + * **email**: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} + * **min|max**: only usable in forms. Compares the value against an lower and upper limit (numeric or string). + * **min|max date**: only usable in forms. Compares the value against an lower and upper date or datetime. + * **pattern**: only usable in forms. Compares the value against a regexp. * **all**: no sanitizing -* All :ref:`predefined-variable-names` have a specific default sanitize class. For these variables, it's not necessary - to specify a sanitize class. -* All other variables (Store: C, F) get by default the sanitize class 'digit'. -* A default sanitize class can be overwritten by individual definition: *{{a:C:all}}* Store / prio ------------ @@ -261,12 +274,6 @@ Store: *TYPO3* (Bodytext) - T | | * Fix. E.g. *form = person* | | | * via SIP. E.g. *form = {{form}}* | +---------------+-------------------------------------------------------------------+ - | debugShowStack| Any exception will show the call stack. E.g. *debugShowStack = 1* | - +---------------+-------------------------------------------------------------------+ - | debugLoad | Debug Level for 'load', defined in ttcontent record bodytext | - +---------------+-------------------------------------------------------------------+ - | debugSave | Debug Level for 'save', defined in ttcontent record bodytext | - +---------------+-------------------------------------------------------------------+ | feUser | Logged in Typo3 FE User | +---------------+-------------------------------------------------------------------+ | feUserUid | Logged in Typo3 FE User uid | @@ -286,6 +293,7 @@ Store: *FORM* - F * Formelements who will be rerendered, after a parent element has been changed by the user. * Formelement actions, before saving the form. + * Values will be sanatized by the class configured in corresponding the formelement. By default, the sanitize class is `alnumx`. +--------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ | Name | Explanation | @@ -418,17 +426,19 @@ FormElements * Each *form* contains one or more *FormElement*. * The *FormElements* are divided in three categories: - * *native* - * *container* - * *action* + * :ref:`class-container` + * :ref:`class-native` + * :ref:`class-action` * Ordering and grouping: Native Form-Elements and Container-Elements (both with feIdContainer=0) will be ordered by 'ord'. * Inside of a container, all nested elements will be displayed. +.. _class-container: + Class: Container ---------------- -* Pills are containers for 'fieldset' and 'native' Form-Elements. +* Pills are containers for 'fieldset' *and* 'native' Form-Elements. * Fieldsets are containers for 'native' Form-Elements Type: fieldset @@ -454,6 +464,8 @@ Type: pill * FormElement.'''feIdContainer''': 0 # Pill's can't be nested. * Form.'''Parameter''': *maxVisiblePill=<nr>* Number of Pill-Buttons shown. Undefined means unlimited. Excess Pill buttons will be displayed as a dropdown menu. +.. _class-native: + Class: Native ------------- @@ -469,6 +481,7 @@ Class: Native |enabled | enum('yes'|'no') | | +--------------+-----------------------------+---------------------------------------------------------------------------------------------------+ |dynamicUpdate | enum('yes'|'no') | In the browser, formelements with "dynamicUpdate='yes'" will be updated depending on user input. | +| | | :ref:`dynamic-update` | +--------------+-----------------------------+---------------------------------------------------------------------------------------------------+ |name | string | | +--------------+-----------------------------+---------------------------------------------------------------------------------------------------+ @@ -616,10 +629,6 @@ Class: Native * 2: Any number >1 makes the 'select' input 'multiple' ready. * See: https://www.w3.org/TR/html5/forms.html#file-upload-state-(type=file) - -Class: native -^^^^^^^^^^^^^ - * All 'native' Formelements like 'input', 'checkbox', ... Type: checkbox @@ -792,6 +801,8 @@ Type: upload * See: https://www.w3.org/TR/html5/forms.html#file-upload-state-(type=file) * parameter:accept: *image/*,video/*,audio/*,.doc,.docx,.pdf,<mime type>* +.. _class-action: + Class: Action ------------- @@ -852,13 +863,29 @@ Type: sendmail * Send mail(s) on request. * respects 'processRow' +.. _dynamic-update: + +Dynamic Update +-------------- + +Depending of the form requirements, it's necessary to update FormElements depending on the recent user input. E.g. a user +activates a checkbox and therefore the content of a select list should change. + +Make a form dynamic: + +* Mark all FormElements with {dynamic update}=enabled, which should send **or** receive a 'do update' signal. +* Define the receiving FormElements in a way, that they will interpret the recent user change. In the example, the FormElement + 'carPriceRange' is the sender and the receiving FormElement might be of type 'radio' or 'selectList'. + + [receiving formElement].parameter: itemList={{ SELECT IF({{carPriceRange}}='expensive','Ferrari,Tesla,Jaguar','General Motors,Honda,Seat,Fiat') }} + Report ====== -How to create a report ----------------------- +General +------- To display a report on any given TYPO3 page, create a content element of type 'QFQ Element' (plugin) on that page. @@ -926,7 +953,7 @@ Syntax Only SELECT and SHOW queries will fire subqueries. -* Processing of the resulting rows and columns: + * Processing of the resulting rows and columns: * In general, all columns of all rows will be printed out sequentially. @@ -938,10 +965,22 @@ Syntax There are extensive ways to wrap columns and rows automatically. See :ref:`wrapping-rows-and-columns` +Debug the bodytext +------------------ +The parsed bodytext could be displayed by activating 'showDebugInfo' (:ref:`debug`) and specifying + +:: + + debugShowBodyText = 1 + +A small symbol with a tooltip will be shown, where the content record will be displayed on the webpage. + Structure --------- -A report can be divided into several levels. This can make report definitions more readable because it allows for splitting of otherwise excessively long SQL queries. For example, if your SQL query on the root level selects a number of person records from your person table, you can use the SQL query on the second level to look up the city where each person lives. +A report can be divided into several levels. This can make report definitions more readable because it allows for +splitting of otherwise excessively long SQL queries. For example, if your SQL query on the root level selects a number +of person records from your person table, you can use the SQL query on the second level to look up the city where each person lives. See the example below: @@ -998,11 +1037,13 @@ Nesting of levels Levels can be nested by using curly brackets:: 10.sql = SELECT 'hello world' + 20 { sql = SELECT 'a new query' head = <h1> tail = </h1> } + 30 { sql = SELECT 'a third query' head = <h1> @@ -1020,6 +1061,7 @@ Levels can be nested by using curly brackets:: sql = SELECT 'A query with braces on their own' } + Columns of the upper level result can be accessed via variables, eg. {{10.person_id}} will be replaced by the value in the person_id column. +-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ @@ -1037,13 +1079,8 @@ Columns of the upper level result can be accessed via variables, eg. {{10.person +-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ |**Parent** |The level 20.25 has a parent **20** | +-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -<<<<<<< HEAD |**Example |**10** and **20** are root level and will be executed independently. **10** don't have a sub level. **20.25** will be executed as many times as **20** has row numbers. **20.30.10** won't be executed because there isn't | |explanation**|any **20.30** level | -======= -|**Example |**10** and **20** is a root level and will be executed independently. **10** doesn't have a sub level. **20.20** will be executed as many times as **20** has row numbers. **20.30.10** won't be executed because there | -|explanation**|is no **20.30** level | ->>>>>>> origin/elvill_work +-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ @@ -1120,19 +1157,16 @@ Column: link {{url | display | **i (internal)**, e(external) | **- (same)**,n (new), p (parent), t(top) | **-**, (e(edit), c(copy), n(new), d(delete), i(insert) , f(file)) }} - Most of URLs will be rendered via link. - - Column names like pagee, mailto,... are wrapper to link. +* Most URLs will be rendered via class link. +* Column names like pagee, mailto,... are wrapper to class link. +* The parameters for link contains a prefix to make them position-independet. +* For fewer conflicts: - The parameters for link contains a prefix to make them position-independet. + A:u|m|p:url|mail|page (A=Anchor) -* For fewer conflicts: + G:E|N|T|I|M|C (G=Grafic) - A:<u|m|p>:<url|mail|page> (A=Anchor) - - G:<ENTIMC> (G=Grafic) - - G:<PbC>:<color|Text> (G=Grafic) + G:P|b|C:<Color>|<Text> (G=Grafic) +---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ |URL|IMG|Meaning |Qualifier |Example |Description | @@ -1145,13 +1179,13 @@ Column: link +---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ |x | |Mail |m:<email> |m:info@example.com |Default link class: email | +---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ -|x | |Page |p:<pageId> |p:impressum |'?' is prepended, no hostname qualifier (will be set automatically by the browser), default link class: internal | +|x | |Page |p:<pageId> |p:impressum |Prepend '?' or '?id=', no hostname qualifier (automatically set by browser), default link class: internal, default value: {{pageId}} | +---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ | | |Text |t:<text> |t:Firstname Lastname |- | +---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ -| | |Render |r:<mode> |r:[0-5] |Rendering mode: see below. Default: 0 | +| | |Render |r:<mode> |r:[0-5] |`render-mode`_ Default: 0 | +---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ -| |x |Picture |P:<filename> |P:bullet-red.gif |Picture '<imgsrc="bullet-red.gif"alt="....">', default link class: internal. | +| |x |Picture |P:<filename> |P:bullet-red.gif |Picture '<img src="bullet-red.gif"alt="....">', default link class: internal. | +---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ | |x |Edit |E |E |Show 'edit' icon as image | +---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ @@ -1179,7 +1213,7 @@ Column: link +---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ | | |Target |g:<text> |g:_blank |target=_blank, Default: no target | +---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ -| | |Question |q:<text> |q:please confirm |Link will be executed only if user clicks ok | +| | |Question |q:<text> |q:please confirm |Link will be executed only if user clicks ok, default: 'Please confirm' | +---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ | | |Encryption|e:0|1|... |e:1 |Encryption of the e-mail: 0: no encryption, 1:via Javascript (default) | +---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ @@ -1188,7 +1222,10 @@ Column: link | | |Hash |h |h |A hash entry is generated with all Parameters. No other URL parameter than 'S_hash' (=hash) | +---+---+----------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+ -**Render mode** +.. _render-mode: + +Render mode +^^^^^^^^^^^ +-----------+--------------------+-------------------+----------+-------------------------------------------------------------------+ |Mode |Both: url & text |Only: url |Only: text|Description | @@ -1201,7 +1238,7 @@ Column: link +-----------+--------------------+-------------------+----------+-------------------------------------------------------------------+ |3 |text |url |text |no link, only text or image | +-----------+--------------------+-------------------+----------+-------------------------------------------------------------------+ -|4 |url |url |url |no link, show text, if text is empty, show url | +|4 |url |url |text |no link, show text, if text is empty, show url | +-----------+--------------------+-------------------+----------+-------------------------------------------------------------------+ |5 | | | |nothing at all | +-----------+--------------------+-------------------+----------+-------------------------------------------------------------------+ @@ -1323,8 +1360,7 @@ below. +-------------+-------------------------------------------------------------------------------------------------+----------------------------------------------------------+---------------------------------------------------------------+ |<target> |Parameter for HTML 'target='. F.e.: Opens a new window |empty |P | +-------------+-------------------------------------------------------------------------------------------------+----------------------------------------------------------+---------------------------------------------------------------+ -|<rendermode> |Easy way not to show/render a link at all. Render modes (0-5) are defined in table **Render |0 |5 | -| |mode** in section `column-link`_ | | | +|<rendermode> |Easy way (not) to show/render a link at all. See `render-mode`_ 0-5 | | | +-------------+-------------------------------------------------------------------------------------------------+----------------------------------------------------------+---------------------------------------------------------------+ |<createhash> |h |see below |'h': create a hash, 'H': create no hash. Specify only if | | | | |default is not suitable | @@ -2068,3 +2104,4 @@ Two queries: nested with variables * Columns starting with a '_' won't be printed but can be accessed as regular columns. + diff --git a/extension/Documentation/_make/conf.py b/extension/Documentation/_make/conf.py index b420fa44210ec1dd18b32b968ce3a23653e72140..5d2cb556c6c9150abb9f703da61667189fac02b5 100644 --- a/extension/Documentation/_make/conf.py +++ b/extension/Documentation/_make/conf.py @@ -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. diff --git a/extension/ext_emconf.php b/extension/ext_emconf.php index 0a9bfe5dde95af67aefd62b58da1f81b7a340294..9a139688219679f670298873425b4ac36b1f6998 100644 --- a/extension/ext_emconf.php +++ b/extension/ext_emconf.php @@ -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 diff --git a/extension/qfq/api/delete.php b/extension/qfq/api/delete.php index 1be600e2b849b9a6c07a7ab479608ca6bb94aac0..707fce1f45f324d97257a14ea0867901f1dbcdd2 100644 --- a/extension/qfq/api/delete.php +++ b/extension/qfq/api/delete.php @@ -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(); diff --git a/extension/qfq/api/load.php b/extension/qfq/api/load.php index 65c1699bf8b9a622da1dc17eaa0365725c8e8dee..c1ed3c1ba4559db9373e501ba3a26276429945bd 100644 --- a/extension/qfq/api/load.php +++ b/extension/qfq/api/load.php @@ -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); diff --git a/extension/qfq/api/save.php b/extension/qfq/api/save.php index 4a5e894bd30bb2e47f664246486294d9a18399c0..f58dc9270b5f056d03ed256b7b3b3d9c5f9e5570 100644 --- a/extension/qfq/api/save.php +++ b/extension/qfq/api/save.php @@ -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); diff --git a/extension/qfq/qfq/AbstractBuildForm.php b/extension/qfq/qfq/AbstractBuildForm.php index 4b0ffc927b70a4cdb983824c63a32b99ced8d4af..c2363b61b582f529b0ed3c59aae667448fd4953f 100644 --- a/extension/qfq/qfq/AbstractBuildForm.php +++ b/extension/qfq/qfq/AbstractBuildForm.php @@ -9,13 +9,13 @@ namespace qfq; use qfq; use qfq\Store; -use qfq\UserException; +use qfq\UserFormException; 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'); @@ -116,7 +116,7 @@ abstract class AbstractBuildForm { * @return string|array $mode=LOAD_FORM: The whole form as HTML, $mode=FORM_UPDATE: array of all formElement.dynamicUpdate-yes values/states * @throws CodeException * @throws DbException - * @throws \qfq\UserException + * @throws \qfq\UserFormException */ public function process($mode) { $htmlHead = ''; @@ -160,7 +160,7 @@ abstract class 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), ':', ', ', "'"); @@ -175,21 +175,6 @@ abstract class AbstractBuildForm { return $html; } - /** - * Format's an attribute: $type=$value. If $flagOmitEmpty==true && $value=='': return ''. - * - * @param $type - * @param $value - * @param bool|false $flagOmitEmpty - * @return string - */ - public function getAttribute($type, $value, $flagOmitEmpty = true) { - if ($flagOmitEmpty && $value === "") - return ''; - - return $type . '="' . trim($value) . '" '; - } - /** * If SHOW_DEBUG_INFO=yes: create a link (incl. SIP) to edit the current form. Show also the hidden content of the SIP. * @@ -312,7 +297,7 @@ abstract class AbstractBuildForm { * @return string * @throws CodeException * @throws DbException - * @throws \qfq\UserException + * @throws \qfq\UserFormException */ public function elements($recordId, $filter = FORM_ELEMENTS_NATIVE, $feIdContainer = 0, &$json) { $html = ''; @@ -390,7 +375,7 @@ abstract class AbstractBuildForm { * Takes the current SIP ('form' and additional parameter), set SIP_RECORD_ID=0 and create a new 'NewRecordUrl'. * * @throws CodeException - * @throws \qfq\UserException + * @throws \qfq\UserFormException */ public function deriveNewRecordUrlFromExistingSip(&$toolTipNew) { $urlParam = $this->store->getStore(STORE_SIP); @@ -404,7 +389,9 @@ abstract class AbstractBuildForm { $url = $sip->queryStringToSip(OnArray::toString($urlParam)); - $toolTipNew .= "New" . PHP_EOL . PHP_EOL . OnArray::toString($urlParam, ' = ', PHP_EOL, "'"); + if ($this->showDebugInfo) { + $toolTipNew .= PHP_EOL . PHP_EOL . OnArray::toString($urlParam, ' = ', PHP_EOL, "'"); + } return $url; } @@ -441,12 +428,12 @@ abstract class AbstractBuildForm { * @param $htmlFormElementId * @param $value * @return string - * @throws UserException + * @throws UserFormException */ public function buildInput(array $formElement, $htmlFormElementId, $value, &$json) { $textarea = ''; - $attribute = $this->getAttribute('name', $htmlFormElementId); + $attribute = Support::doAttribute('name', $htmlFormElementId); // Check for input type 'textarea' $colsRows = explode(',', $formElement['size'], 2); @@ -454,8 +441,8 @@ abstract class AbstractBuildForm { // <textarea> $htmlTag = '<textarea'; - $attribute .= $this->getAttribute('cols', $colsRows[0]); - $attribute .= $this->getAttribute('rows', $colsRows[1]); + $attribute .= Support::doAttribute('cols', $colsRows[0]); + $attribute .= Support::doAttribute('rows', $colsRows[1]); $textarea = htmlentities($value) . '</textarea>'; } else { @@ -471,13 +458,13 @@ abstract class AbstractBuildForm { // 'maxLength' needs an upper 'L': naming convention for DB tables! $attribute .= $this->getAttributeList($formElement, ['type', 'size', 'maxLength']); - $attribute .= $this->getAttribute('value', htmlentities($value), false); + $attribute .= Support::doAttribute('value', htmlentities($value), false); } } $attribute .= $this->getAttributeList($formElement, ['autocomplete', 'autofocus', 'placeholder']); - $attribute .= $this->getAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : ''); - $attribute .= $this->getAttribute('title', $formElement['tooltip']); + $attribute .= Support::doAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : ''); + $attribute .= Support::doAttribute('title', $formElement['tooltip']); $attribute .= $this->getInputCheckPattern($formElement['checkType'], $formElement['checkPattern']); $attribute .= $this->getAttributeMode($formElement); @@ -541,7 +528,7 @@ abstract class AbstractBuildForm { $attribute = ''; foreach ($attributeList as $item) { if (isset($formElement[$item])) - $attribute .= $this->getAttribute(strtolower($item), $formElement[$item]); + $attribute .= Support::doAttribute(strtolower($item), $formElement[$item]); } return $attribute; } @@ -562,7 +549,7 @@ abstract class AbstractBuildForm { * @param $type * @param $data * @return string - * @throws \qfq\UserException + * @throws \qfq\UserFormException */ private function getInputCheckPattern($type, $data) { $attribute = ''; @@ -576,7 +563,7 @@ abstract class AbstractBuildForm { case SANITIZE_ALLOW_MIN_MAX_DATE: $arrData = explode("|", $data); if (count($arrData) != 2 || $arrData[0] == '' || $arrData[1] == '') - throw new UserException("Missing MIN|MAX values", ERROR_MISSING_MIN_MAX); + throw new UserFormException("Missing MIN|MAX values", ERROR_MISSING_MIN_MAX); $attribute = 'min="' . $arrData[0] . '" '; $attribute .= 'max="' . $arrData[1] . '" '; @@ -602,7 +589,7 @@ abstract class AbstractBuildForm { * * @param array $formElement * @return string - * @throws UserException + * @throws UserFormException */ private function getAttributeMode(array $formElement) { $attribute = ''; @@ -611,20 +598,20 @@ abstract class AbstractBuildForm { case 'show': break; case 'readonly': - $attribute .= $this->getAttribute('readonly', 'readonly'); + $attribute .= Support::doAttribute('readonly', 'readonly'); break; case 'required': - $attribute .= $this->getAttribute('required', 'required'); + $attribute .= Support::doAttribute('required', 'required'); break; case 'lock': break; case 'disabled': - $attribute .= $this->getAttribute('disabled', 'disabled'); + $attribute .= Support::doAttribute('disabled', 'disabled'); break; default: $this->store->setVar(SYSTEM_FORM_ELEMENT, $formElement['name'] . ' / ' . $formElement['id'], STORE_SYSTEM); $this->store->setVar(SYSTEM_FORM_ELEMENT_COLUMN, 'mode', STORE_SYSTEM); - throw new UserException("Unknown mode '" . $formElement['mode'] . "'", ERROR_UNKNOWN_MODE); + throw new UserFormException("Unknown mode '" . $formElement['mode'] . "'", ERROR_UNKNOWN_MODE); break; } return $attribute; @@ -660,7 +647,7 @@ abstract class AbstractBuildForm { * @param $htmlFormElementId * @param $value * @return string - * @throws UserException + * @throws UserFormException */ public function buildCheckbox(array $formElement, $htmlFormElementId, $value, &$json) { $itemKey = array(); @@ -683,7 +670,7 @@ abstract class AbstractBuildForm { } $attributeBase = $this->getAttributeMode($formElement); - $attributeBase .= $this->getAttribute('type', $formElement['type']); + $attributeBase .= Support::doAttribute('type', $formElement['type']); switch ($formElement['checkBoxMode']) { case 'single': @@ -693,7 +680,7 @@ abstract class AbstractBuildForm { $html = $this->buildCheckboxMulti($formElement, $htmlFormElementId, $attributeBase, $value, $itemKey, $itemValue); break; default: - throw new UserException('checkBoxMode: \'' . $formElement['checkBoxMode'] . '\' is unknown.', ERROR_CHECKBOXMODE_UNKNOWN); + throw new UserFormException('checkBoxMode: \'' . $formElement['checkBoxMode'] . '\' is unknown.', ERROR_CHECKBOXMODE_UNKNOWN); } $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement['mode']); @@ -714,7 +701,7 @@ abstract class AbstractBuildForm { * @param $itemKey * @param $itemValue * @throws CodeException - * @throws \qfq\UserException + * @throws \qfq\UserFormException */ public function getKeyValueListFromSqlEnumSpec(array $formElement, &$itemKey, &$itemValue) { $fieldType = ''; @@ -750,7 +737,7 @@ abstract class AbstractBuildForm { } elseif ($fieldType === 'enum' || $fieldType === 'set') { // already done at the beginning with '$this->getItemsForEnumOrSet($formElement['name'], $fieldType);' } else { - throw new UserException("Missing definition (- nothing found in 'sql1', 'parameter:itemValues', 'enum-' or 'set-definition'", ERROR_MISSING_ITEM_VALUES); + throw new UserFormException("Missing definition (- nothing found in 'sql1', 'parameter:itemValues', 'enum-' or 'set-definition'", ERROR_MISSING_ITEM_VALUES); } if (count($itemKey) === 0) { @@ -782,7 +769,7 @@ abstract class AbstractBuildForm { * @param $column * @param $fieldType * @return array - * @throws UserException + * @throws UserFormException */ private function getItemsForEnumOrSet($column, &$fieldType) { @@ -790,7 +777,7 @@ abstract class AbstractBuildForm { $fieldTypeDefinition = $this->store->getVar($column, STORE_TABLE_COLUMN_TYPES); if ($fieldTypeDefinition === false) { - throw new UserException("Column '$column' unknown in table '" . $this->formSpec['tableName'] . "'", ERROR_DB_UNKNOWN_COLUMN); + throw new UserFormException("Column '$column' unknown in table '" . $this->formSpec['tableName'] . "'", ERROR_DB_UNKNOWN_COLUMN); } $length = strlen($fieldTypeDefinition); @@ -824,7 +811,7 @@ abstract class AbstractBuildForm { * * @param array $itemKey * @param array $formElement - * @throws UserException + * @throws UserFormException */ private function prepareCheckboxCheckedUncheckedValue(array $itemKey, array &$formElement) { @@ -848,7 +835,7 @@ abstract class AbstractBuildForm { } if ($formElement[CHECKBOX_VALUE_CHECKED] === $formElement[CHECKBOX_VALUE_UNCHECKED]) { - throw new UserException('FormElement: type=checkbox - checked and unchecked can\'t be the same: ' . $formElement[CHECKBOX_VALUE_CHECKED], ERROR_CHECKBOX_EQUAL); + throw new UserFormException('FormElement: type=checkbox - checked and unchecked can\'t be the same: ' . $formElement[CHECKBOX_VALUE_CHECKED], ERROR_CHECKBOX_EQUAL); } } @@ -865,12 +852,12 @@ abstract class AbstractBuildForm { public function buildCheckboxSingle(array $formElement, $htmlFormElementId, $attribute, $value) { $html = ''; - $attribute .= $this->getAttribute('name', $htmlFormElementId); - $attribute .= $this->getAttribute('value', $formElement['checked'], false); - $attribute .= $this->getAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : ''); + $attribute .= Support::doAttribute('name', $htmlFormElementId); + $attribute .= Support::doAttribute('value', $formElement['checked'], false); + $attribute .= Support::doAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : ''); if ($formElement['checked'] === $value) { - $attribute .= $this->getAttribute('checked', 'checked'); + $attribute .= Support::doAttribute('checked', 'checked'); } $attribute .= $this->getAttributeList($formElement, ['autofocus']); @@ -917,8 +904,8 @@ abstract class AbstractBuildForm { // Defines which of the checkboxes will be checked. $values = explode(',', $value); - $attributeBase .= $this->getAttribute('name', $htmlFormElementId); - $attributeBase .= $this->getAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : ''); + $attributeBase .= Support::doAttribute('name', $htmlFormElementId); + $attributeBase .= Support::doAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : ''); $html = $this->buildNativeHidden($htmlFormElementId, ''); @@ -933,14 +920,14 @@ abstract class AbstractBuildForm { if ($flagFirst) { $flagFirst = false; if (isset($formElement['autofocus'])) - $attribute .= $this->getAttribute('autofocus', $formElement['autofocus']); + $attribute .= Support::doAttribute('autofocus', $formElement['autofocus']); } - $attribute .= $this->getAttribute('value', $itemKey[$ii]); + $attribute .= Support::doAttribute('value', $itemKey[$ii]); // Check if the given key is found in field. if (false !== array_search($itemKey[$ii], $values)) { - $attribute .= $this->getAttribute('checked', 'checked'); + $attribute .= Support::doAttribute('checked', 'checked'); } $htmlCheckbox = '<input ' . $attribute . '>'; @@ -988,7 +975,7 @@ abstract class AbstractBuildForm { * @param $htmlFormElementId * @param $value * @return string - * @throws UserException + * @throws UserFormException */ public function buildRadio(array $formElement, $htmlFormElementId, $value, &$json) { $itemKey = array(); @@ -998,9 +985,9 @@ abstract class AbstractBuildForm { $this->getKeyValueListFromSqlEnumSpec($formElement, $itemKey, $itemValue); $attributeBase = $this->getAttributeMode($formElement); - $attributeBase .= $this->getAttribute('name', $htmlFormElementId); - $attributeBase .= $this->getAttribute('type', $formElement['type']); - $attributeBase .= $this->getAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : ''); + $attributeBase .= Support::doAttribute('name', $htmlFormElementId); + $attributeBase .= Support::doAttribute('type', $formElement['type']); + $attributeBase .= Support::doAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : ''); $jj = 0; $flagFirst = true; @@ -1012,12 +999,12 @@ abstract class AbstractBuildForm { if ($flagFirst) { $flagFirst = false; if (isset($formElement['autofocus'])) - $attribute .= $this->getAttribute('autofocus', $formElement['autofocus']); + $attribute .= Support::doAttribute('autofocus', $formElement['autofocus']); } - $attribute .= $this->getAttribute('value', $itemKey[$ii]); + $attribute .= Support::doAttribute('value', $itemKey[$ii]); if ($itemKey[$ii] === $value) { - $attribute .= $this->getAttribute('checked', 'checked'); + $attribute .= Support::doAttribute('checked', 'checked'); } $element = '<input ' . $attribute . '>' . $itemValue[$ii]; @@ -1057,13 +1044,13 @@ abstract class AbstractBuildForm { $this->getKeyValueListFromSqlEnumSpec($formElement, $itemKey, $itemValue); $attribute = $this->getAttributeMode($formElement); - $attribute .= $this->getAttribute('name', $htmlFormElementId); + $attribute .= Support::doAttribute('name', $htmlFormElementId); $attribute .= $this->getAttributeList($formElement, ['autofocus']); - $attribute .= $this->getAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : ''); + $attribute .= Support::doAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : ''); if (isset($formElement['size']) && $formElement['size'] > 1) { - $attribute .= $this->getAttribute('size', $formElement['size']); - $attribute .= $this->getAttribute('multiple', 'multiple'); + $attribute .= Support::doAttribute('size', $formElement['size']); + $attribute .= Support::doAttribute('multiple', 'multiple'); } $option = ''; @@ -1072,7 +1059,7 @@ abstract class AbstractBuildForm { for ($ii = 0; $ii < count($itemValue); $ii++) { $option .= '<option '; - $option .= $this->getAttribute('value', $itemKey[$ii]); + $option .= Support::doAttribute('value', $itemKey[$ii]); $jsonValues[] = [ 'value' => $itemKey[$ii], @@ -1101,7 +1088,7 @@ abstract class AbstractBuildForm { * @param $htmlFormElementId * @param $value * @return string - * @throws UserException + * @throws UserFormException */ public function buildSubrecord(array $formElement, $htmlFormElementId, $value, &$json) { $rcText = false; @@ -1176,17 +1163,17 @@ abstract class AbstractBuildForm { * @param $rcText * @param $nameColumnId * @return bool - * @throws \qfq\UserException + * @throws \qfq\UserFormException */ private function prepareSubrecod(array $formElement, array $primaryRecord, &$rcText, &$nameColumnId) { if (!isset($primaryRecord['id'])) { - $rcText = 'Please save record fist.'; + $rcText = 'Please save record first.'; return false; } if (!is_array($formElement['sql1'])) { - throw new UserException('Missing \'sql1\' Query', ERROR_MISSING_SQL1); + throw new UserFormException('Missing \'sql1\' Query', ERROR_MISSING_SQL1); } // No records? @@ -1199,7 +1186,7 @@ abstract class AbstractBuildForm { $nameColumnId = '_id'; if (!isset($formElement['sql1'][0][$nameColumnId])) { - throw new UserException('Missing column \'id\' (or "@_id") in \'sql1\' Query', ERROR_DB_MISSING_COLUMN_ID); + throw new UserFormException('Missing column \'id\' (or "@_id") in \'sql1\' Query', ERROR_DB_MISSING_COLUMN_ID); } return true; @@ -1223,7 +1210,7 @@ abstract class AbstractBuildForm { * @param $targetRecordId * @param $record * @return string - * @throws UserException + * @throws UserFormException */ private function createFormLink(array $formElement, $targetRecordId, array $record, $symbol, $toolTip) { @@ -1301,7 +1288,7 @@ abstract class AbstractBuildForm { * * @param $titleRaw * @return array - * @throws UserException + * @throws UserFormException */ private function getSubrecordColumnControl(array $titleRaw) { $control = array(); @@ -1411,15 +1398,15 @@ abstract class AbstractBuildForm { * @param $htmlFormElementId * @param $value * @return string - * @throws UserException + * @throws UserFormException */ public function buildFile(array $formElement, $htmlFormElementId, $value, &$json) { $attribute = $this->getAttributeMode($formElement); - $attribute .= $this->getAttribute('type', 'file'); - $attribute .= $this->getAttribute('name', $htmlFormElementId); + $attribute .= Support::doAttribute('type', 'file'); + $attribute .= Support::doAttribute('name', $htmlFormElementId); $attribute .= $this->getAttributeList($formElement, ['autofocus', 'accept']); - $attribute .= $this->getAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : ''); + $attribute .= Support::doAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : ''); $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement['mode']); @@ -1432,11 +1419,11 @@ abstract class AbstractBuildForm { * @param array $formElement * @param $htmlFormElementId * @param $value - * @throws UserException + * @throws UserFormException */ public function buildDateJQW(array $formElement, $htmlFormElementId, $value) { // TODO: implement - throw new UserException("Not implemented yet: buildDateJQW()", ERROR_NOT_IMPLEMENTED); + throw new UserFormException("Not implemented yet: buildDateJQW()", ERROR_NOT_IMPLEMENTED); } /** @@ -1445,11 +1432,11 @@ abstract class AbstractBuildForm { * @param array $formElement * @param $htmlFormElementId * @param $value - * @throws UserException + * @throws UserFormException */ public function buildGridJQW(array $formElement, $htmlFormElementId, $value) { // TODO: implement - throw new UserException("Not implemented yet: buildGridJQW()", ERROR_NOT_IMPLEMENTED); + throw new UserFormException("Not implemented yet: buildGridJQW()", ERROR_NOT_IMPLEMENTED); } /** @@ -1490,8 +1477,8 @@ abstract class AbstractBuildForm { // save parent processed FE's $tmpStore = $this->feSpecNative; - $attribute .= $this->getAttribute('name', $htmlFormElementId); - $attribute .= $this->getAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : ''); + $attribute .= Support::doAttribute('name', $htmlFormElementId); + $attribute .= Support::doAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : ''); // <fieldset> $html = '<fieldset ' . $attribute . '>'; diff --git a/extension/qfq/qfq/BodytextParser.php b/extension/qfq/qfq/BodytextParser.php index 8b881ecf873a2b43b955e6dbff9e437e1a46058f..44e8bb99677228c57d7e4e6ce6e356066ca16f3a 100644 --- a/extension/qfq/qfq/BodytextParser.php +++ b/extension/qfq/qfq/BodytextParser.php @@ -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); diff --git a/extension/qfq/qfq/BuildFormBootstrap.php b/extension/qfq/qfq/BuildFormBootstrap.php index 7cdb865ce825c7289ced54eea2e90798609bfb07..aa94e679507767362759fb403546eb92d223fd27 100644 --- a/extension/qfq/qfq/BuildFormBootstrap.php +++ b/extension/qfq/qfq/BuildFormBootstrap.php @@ -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 diff --git a/extension/qfq/qfq/BuildFormTable.php b/extension/qfq/qfq/BuildFormTable.php index 32189dd3a9e1bb0f114053a1792bcab942416e50..f97880371f27f03eff25a203e8cfe37a838e451f 100644 --- a/extension/qfq/qfq/BuildFormTable.php +++ b/extension/qfq/qfq/BuildFormTable.php @@ -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), ':', ', ', "'"); diff --git a/extension/qfq/qfq/Constants.php b/extension/qfq/qfq/Constants.php index 5d57c5dafbb491bd12c2fb3f7157425ca9a37d1c..a9a9f97b9e0130f1d9eb9a3bafbcb591be9eaa8a 100644 --- a/extension/qfq/qfq/Constants.php +++ b/extension/qfq/qfq/Constants.php @@ -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'; + diff --git a/extension/qfq/qfq/Database.php b/extension/qfq/qfq/Database.php index c8f8c5d91bde70ecd7e6df480a8d0772d1e3e82d..0ab2685ca8408899ce89e6ba4a8d7d930ac50297 100644 --- a/extension/qfq/qfq/Database.php +++ b/extension/qfq/qfq/Database.php @@ -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') . ']['; diff --git a/extension/qfq/qfq/Evaluate.php b/extension/qfq/qfq/Evaluate.php index a81fba006bf35343ddc05bc712a76af87820c144..3638b75bbbbb1f19e07cc934b864ecf2cc3a9020 100644 --- a/extension/qfq/qfq/Evaluate.php +++ b/extension/qfq/qfq/Evaluate.php @@ -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); diff --git a/extension/qfq/qfq/QuickFormQuery.php b/extension/qfq/qfq/QuickFormQuery.php index f7fcd48618d383ff08d62abd5361430e63cae4b2..01cf3c7c9534050523b2ec60fbea4aab4f1ef386 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'); @@ -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]); diff --git a/extension/qfq/qfq/Save.php b/extension/qfq/qfq/Save.php index e0bd552f56e98287529e8265f3e1babada8de555..1b16095bdd5f5703170436982fbb009f397a6cd8 100644 --- a/extension/qfq/qfq/Save.php +++ b/extension/qfq/qfq/Save.php @@ -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) { diff --git a/extension/qfq/qfq/exceptions/UserException.php b/extension/qfq/qfq/exceptions/UserFormException.php similarity index 83% rename from extension/qfq/qfq/exceptions/UserException.php rename to extension/qfq/qfq/exceptions/UserFormException.php index 0693f1e08dc44a508f5785f88dba7a1be3e527ed..92c90779b4e058cceef6863dc264ee7369fa8d1d 100644 --- a/extension/qfq/qfq/exceptions/UserException.php +++ b/extension/qfq/qfq/exceptions/UserFormException.php @@ -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); diff --git a/extension/qfq/qfq/exceptions/UserReportExtension.php b/extension/qfq/qfq/exceptions/UserReportExtension.php new file mode 100644 index 0000000000000000000000000000000000000000..2d7035db35c820977b10bfe91a07d28706053f17 --- /dev/null +++ b/extension/qfq/qfq/exceptions/UserReportExtension.php @@ -0,0 +1,36 @@ +<?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 diff --git a/extension/qfq/qfq/helper/HelperFormElement.php b/extension/qfq/qfq/helper/HelperFormElement.php index 3a196b4051a213bc67a8de10b50b812b9457fbcb..0d2bf4fc944b04c6a827c8d28469e77f8c1ab011 100644 --- a/extension/qfq/qfq/helper/HelperFormElement.php +++ b/extension/qfq/qfq/helper/HelperFormElement.php @@ -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) { - self::explodeParameter($element); - $elements[$key] = $element; - } - } - /** * @param $field * @param $id diff --git a/extension/qfq/qfq/helper/KeyValueStringParser.php b/extension/qfq/qfq/helper/KeyValueStringParser.php index 8c6e7a1fab5aeae56dd65ca9ad7756c9bc6b7d57..690e8911a458c4409ba99c3f4481528b98cb99a0 100644 --- a/extension/qfq/qfq/helper/KeyValueStringParser.php +++ b/extension/qfq/qfq/helper/KeyValueStringParser.php @@ -11,9 +11,9 @@ namespace qfq; use qfq; -use qfq\UserException; +use qfq\UserFormException; -require_once(__DIR__ . '/../exceptions/UserException.php'); +require_once(__DIR__ . '/../exceptions/UserFormException.php'); require_once(__DIR__ . '/../../qfq/Constants.php'); /** @@ -85,7 +85,7 @@ class KeyValueStringParser { * * VALUE_GIVEN: If only a key is given, the value is ''. E.G. 'a,b' >> [ 'a' => '', 'b' => '' ] * * IF_VALUE_EMPTY_COPY_KEY: If only a key is given, the value is the same as the key. E.G. 'a,b' >> [ 'a' => 'a', 'b' => 'b' ]. * @return array associative array indexed by keys - * @throws UserException Thrown if there is a value but no key. + * @throws UserFormException Thrown if there is a value but no key. */ public static function parse($keyValueString, $keyValueDelimiter = ":", $listDelimiter = ",", $valueMode = KVP_VALUE_GIVEN) { @@ -116,7 +116,7 @@ class KeyValueStringParser { if ($key === '') { // ":", ":1" - throw new UserException("Value has no key: '$keyValuePairString'", ERROR_KVP_VALUE_HAS_NO_KEY); + throw new UserFormException("Value has no key: '$keyValuePairString'", ERROR_KVP_VALUE_HAS_NO_KEY); } if (count($keyValueArray) === 2) { diff --git a/extension/qfq/qfq/helper/Logger.php b/extension/qfq/qfq/helper/Logger.php index 28ad30007fe9f82d55593644191da2121d4cb336..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 { @@ -18,17 +18,17 @@ class Logger { * * @param $msg * @param $filename - * @throws UserException + * @throws UserFormException */ public static function logMessage($msg, $filename) { if (!$handle = fopen($filename, 'a')) { - throw new UserException("Error - cannot open. File: " . $filename . " ( CWD: " . getcwd() . ")", ERROR_IO_OPEN); + throw new UserFormException("Error - cannot open. File: " . $filename . " ( CWD: " . getcwd() . ")", ERROR_IO_OPEN); } if (fwrite($handle, $msg . PHP_EOL) === FALSE) { - throw new UserException("Error - cannot write. File: " . $filename . " ( CWD: " . getcwd() . ")", ERROR_IO_WRITE); + throw new UserFormException("Error - cannot write. File: " . $filename . " ( CWD: " . getcwd() . ")", ERROR_IO_WRITE); } fclose($handle); diff --git a/extension/qfq/qfq/helper/Sanitize.php b/extension/qfq/qfq/helper/Sanitize.php index afb1290f38e1db460d9b35dc78c489ab14e6494e..ed1349d2762bb3f605e26472575e36bccf46592e 100644 --- a/extension/qfq/qfq/helper/Sanitize.php +++ b/extension/qfq/qfq/helper/Sanitize.php @@ -33,7 +33,7 @@ class Sanitize { * @param string $patternOrRange Pattern as regexp or MIN|MAX values * @param string $mode SANATIZE_EXCEPTION | SANATIZE_EMPTY_STRING * @return string - * @throws UserException + * @throws UserFormException * @throws \qfq\CodeException */ public static function sanitize($value, $sanatizeClass = SANITIZE_DEFAULT, $patternOrRange = '', $mode = SANATIZE_EMPTY_STRING) { @@ -67,7 +67,7 @@ class Sanitize { case SANITIZE_ALLOW_MIN_MAX_DATE: if ($minMax[0] === '' || $minMax[1] === '') { - throw new UserException('Missing definition of value for min or max.', ERROR_MISSING_MIN_MAX); + throw new UserFormException('Missing definition of value for min or max.', ERROR_MISSING_MIN_MAX); } $errorText = "Value '$value' is out of range of '$patternOrRange'."; @@ -104,7 +104,7 @@ class Sanitize { } if ($mode === SANATIZE_EXCEPTION) { - throw new UserException($errorText, $errorCode); + throw new UserFormException($errorText, $errorCode); } // check failed: return empty string @@ -115,10 +115,11 @@ class Sanitize { * @return array */ public static function inputCheckPatternArray() { + //EMail Regex: http://www.regular-expressions.info/email.html return [ - SANITIZE_ALLOW_ALNUMX => '^(@|-|_|\.|,|;|:| |\/|\(|\)|[[:alnum:]])*$', + SANITIZE_ALLOW_ALNUMX => '^[@\-_\.,;: \/\(\)[:alnum:]]*$', SANITIZE_ALLOW_DIGIT => '^[\d]*$', - SANITIZE_ALLOW_EMAIL => '^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', + SANITIZE_ALLOW_EMAIL => '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$', SANITIZE_ALLOW_MIN_MAX => '', SANITIZE_ALLOW_MIN_MAX_DATE => '', SANITIZE_ALLOW_PATTERN => '', diff --git a/extension/qfq/qfq/helper/Support.php b/extension/qfq/qfq/helper/Support.php index 6827cc05fb11a7080ef847745ef93ea4d1b44def..598e7ecb49af8f1abb7e2e14ef2bd551d8095cec 100644 --- a/extension/qfq/qfq/helper/Support.php +++ b/extension/qfq/qfq/helper/Support.php @@ -70,18 +70,36 @@ class Support { return $tag . $value . $closing; } + /** + * Format's an attribute: $type=$value. If $flagOmitEmpty==true && $value=='': return ''. + * + * @param $type + * @param $value + * @param bool $flagOmitEmpty + * @return string + */ + public static function doAttribute($type, $value, $flagOmitEmpty = true) { + if ($flagOmitEmpty && $value === "") + return ''; + + return $type . '="' . trim($value) . '" '; + } + /** * Wraps some $inner fragment with a CSS styled $tooltipText . CSS is configured in 'Resources/Public/qfq-jqw.css'. * * Based on: http://www.w3schools.com/howto/howto_css_tooltip.asp * - * @param $inner + * @param $before * @param $tooltipText * @return string */ - public static function appendTooltip($inner, $tooltipText) { + public static function appendTooltip($before, $tooltipText) { + + // addslashes, htmlentities & htmlspecialchars + // str_replace('"', '"', $tooltipText) - return $inner . "<img src='" . GFX_INFO . "' title='$tooltipText'>"; + return $before . "<img src='" . GFX_INFO . "' title=\"" . htmlentities($tooltipText) . "\">"; } /** @@ -108,7 +126,7 @@ class Support { * * @param $dateTimeString * @return string - * @throws UserException + * @throws UserFormException */ public static function dateTime2mysql($dateTimeString) { $dateRaw = ''; @@ -133,7 +151,7 @@ class Support { break; default: - throw new UserException('Date/time format not recognised.', ERROR_DATE_TIME_FORMAT_NOT_RECOGNISED); + throw new UserFormException('Date/time format not recognised.', ERROR_DATE_TIME_FORMAT_NOT_RECOGNISED); break; } @@ -161,7 +179,7 @@ class Support { $time = sprintf("%02d:%02d:%02d", $tmpArr[0], $tmpArr[1], $tmpArr[2]); break; default: - throw new UserException('Date/time format not recognised.', ERROR_DATE_TIME_FORMAT_NOT_RECOGNISED); + throw new UserFormException('Date/time format not recognised.', ERROR_DATE_TIME_FORMAT_NOT_RECOGNISED); break; } } diff --git a/extension/qfq/qfq/report/Error.php b/extension/qfq/qfq/report/Error.php index 64697451b9ec69d27d214d4061399227e3a9e5cd..5e0a52fa83d311ffe194bfb178024254da576198 100644 --- a/extension/qfq/qfq/report/Error.php +++ b/extension/qfq/qfq/report/Error.php @@ -41,12 +41,13 @@ class SyntaxReportException extends \Exception { /** * @param string $message * @param int $code - * @param \Exception $file + * @param \Exception $previous + * @param $file * @param $line * @param array $customMessage * @param array $fr_error */ - public function __construct($message, $code, $file, $line, $customMessage = array(), $fr_error = array()) { + public function __construct($message, $code, $previous, $file, $line, $customMessage = array(), $fr_error = array()) { parent::__construct($message); $this->code = $code; $this->file = $file; @@ -60,13 +61,15 @@ class SyntaxReportException extends \Exception { * @return string */ public function errorMessage() { -// global $BE_USER; TA: Du sollst kein global verwenden!! + $store = Store::getInstance(); + // If '$this->customMessage' is a string, convert it to an array. - if ($this->customMessage && !is_array($this->customMessage)) $this->customMessage = array($this->customMessage); + if ($this->customMessage && !is_array($this->customMessage)) + $this->customMessage = [$this->customMessage]; //error message -// if ($BE_USER->user["uid"]>0) { TA: Du sollst kein global verwenden!! - if ($GLOBALS['BE_USER']->user["uid"] > 0 || $_SESSION[FORMREPORT]['be_user_uid'] > 0) { + if ($store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes') { + $errorMsg = nl2br("<hr />Error: <strong>" . htmlentities($this->getMessage()) . "</strong><br />"); $errorMsg .= "Formreport statement: <strong>" . htmlentities($this->fr_error["row"]) . "</strong><br />"; @@ -185,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 97ddde3627a6f4d6ad0ddb2a2d162a2ae7867da1..5ae9e55f8d6eb518276c30c8946019489d87e14a 100644 --- a/extension/qfq/qfq/report/Link.php +++ b/extension/qfq/qfq/report/Link.php @@ -30,6 +30,7 @@ require_once(__DIR__ . '/Define.php'); require_once(__DIR__ . '/Utils.php'); require_once(__DIR__ . '/../store/Store.php'); require_once(__DIR__ . '/../store/Sip.php'); +require_once(__DIR__ . '/../exceptions/UserReportExtension.php'); /* * u:url @@ -42,7 +43,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 * @@ -62,13 +63,36 @@ require_once(__DIR__ . '/../store/Sip.php'); * G: G:[N|..] */ + +const NAME_URL = 'url'; +const NAME_MAIL = 'mail'; +const NAME_PAGE = 'page'; +const NAME_TEXT = 'text'; +const NAME_ALT_TEXT = 'altText'; +const NAME_TOOL_TIP = 'toolTip'; +const NAME_IMAGE = 'image'; +const NAME_IMAGE_TITLE = 'imageTitle'; +const NAME_GLYPH = 'glyph'; +const NAME_GLYPH_TITLE = 'glyphTitle'; +const NAME_DELETE = 'delete'; +const NAME_RENDER = 'render'; +const NAME_TARGET = 'target'; +const NAME_LINK_CLASS = 'linkClass'; +const NAME_LINK_CLASS_DEFAULT = 'linkClassDefault'; +const NAME_QUESTION = 'question'; +const NAME_ENCRYPTION = 'encryption'; +const NAME_HASH = 'hash'; +const NAME_URL_PARAM = 'param'; +const NAME_RIGHT_PICTURE_POSITION = 'picturePosition'; + +/** + * Class Link + * @package qfq + */ class Link { - private $mailto = "", $url = "", $image = "", $text = "", $altText = "", $imageTitle = "", $question = "", $target = "", $additionalUrlParams = ""; - private $toolTip = array(), $modeRender = 0, $picturePosition = "l", $modeHash = false, $encryption = 1; - private $linkClass = "", $defaultLinkClass = ""; - private $linkClassSelector = array("i" => "internal", "e" => "external"); - private $renderControl, $link = ""; + //TODO: delete muss noch implementiert werden + private $delete = ''; /** * @var Sip @@ -83,53 +107,83 @@ class Link { // Simulate global variable: will be set much earlier in other functions. Will be shown in error messages. private $fr_error; - private $exceptionBody = ""; /** * @var Utils */ private $utils; /** - * @var string + * @var array */ - private $pageAlias = ''; - + private $renderControl = array(); + private $linkClassSelector = array("i" => "internal", "e" => "external"); private $cssLinkClassInternal = ''; private $cssLinkClassExternal = ''; + private $callTable = [ + 'u' => 'buildUrl', + 'm' => 'buildMail', + 'p' => 'buildPage', + 'P' => 'buildPicture', + 'B' => 'buildBullet', + 'C' => 'buildCheck', + 'D' => 'buildDelete', + 'E' => 'buildEdit', + 'H' => 'buildHelp', + 'I' => 'buildInfo', + 'N' => 'buildNew', + 'S' => 'buildShow', + ]; + + private $tableVarName = [ + 'u' => NAME_URL, + 'm' => NAME_MAIL, + 'p' => NAME_PAGE, + 't' => NAME_TEXT, + 'a' => NAME_ALT_TEXT, + 'o' => NAME_TOOL_TIP, + 'P' => NAME_IMAGE, + 'B' => NAME_IMAGE, + 'C' => NAME_IMAGE, + 'D' => NAME_IMAGE, + 'E' => NAME_IMAGE, + 'H' => NAME_IMAGE, + 'I' => NAME_IMAGE, + 'N' => NAME_IMAGE, + 'S' => NAME_IMAGE, + 'r' => NAME_RENDER, + 'g' => NAME_TARGET, + 'c' => NAME_LINK_CLASS, + 'q' => NAME_QUESTION, + 'e' => NAME_ENCRYPTION, + 'h' => NAME_HASH, + 'U' => NAME_URL_PARAM, + 'R' => NAME_RIGHT_PICTURE_POSITION, + ]; + + private $varsDefault = array(); + /** * __construct * - * @param string $fullLevel Recent processed level, f.e.: '10.20.sql' - * @param string $sql Recent processed query, f.e.: SELECT p.name FROM person AS p - * @param string $columnValue Definition of link - * @param int $count - * @param int $columnIndex - * @param string $fr_error - * @param string $dbAlias + * @param $fr_error + * @param Sip $sip + * @param bool $phpUnit */ - public function __construct($fullLevel, $sql, $columnValue, $count, $columnIndex, $fr_error, $dbAlias = '', $sip) { - $this->exceptionBody = "Level: " . $fullLevel . ".sql = " . $sql . "\nRow: " . $count . " , Column: " . $columnIndex . " , Bad link: " . $columnValue . "\n"; + public function __construct($fr_error, Sip $sip, $phpUnit = false) { $this->fr_error = $fr_error; - $this->dbAlias = $dbAlias; $this->sip = $sip; - $this->store = Store::getInstance(); - + $this->store = Store::getInstance('', $phpUnit); $this->cssLinkClassInternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_INTERNAL, STORE_SYSTEM); $this->cssLinkClassExternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_EXTERNAL, STORE_SYSTEM); - $this->initRenderControl(); - - } - - /** - * Initializes RenderControl Array - * - * @param void - * @return void - */ - private function initRenderControl() { - $this->utils = new Utils(); + $this->varsDefault[NAME_QUESTION] = 'Please confirm'; + $this->varsDefault[NAME_PAGE] = $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3); + $this->varsDefault[NAME_ENCRYPTION] = '0'; + $this->varsDefault[NAME_RIGHT_PICTURE_POSITION] = 'l'; + $this->varsDefault[NAME_RENDER] = 0; + $this->varsDefault[NAME_HASH] = 0; + /* * mode: * 0: no output @@ -172,279 +226,272 @@ class Link { $this->renderControl[5][0][1] = 0; $this->renderControl[5][1][0] = 0; $this->renderControl[5][1][1] = 0; + } /** * 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" - * @param string $count - * @param string &$hash hash used by the link, and maybe created for the link if count=1 - * - * @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 UserReportException */ - public function renderLink($str, $count, &$hash) { + public function renderLink($str) { + $link = ''; + + $vars = $this->initVars(); // str="u:http://www.example.com|c:i|t:delete" - $parm = explode("|", $str); + $param = explode("|", $str); // Parse all parameter, fill variables - foreach ($parm as $item) { - $arr = explode(":", $item, 2); - $this->parseItem($arr[0], $arr[1]); + 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 (!$this->url && !$this->mailto) $this->url = "?" . $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3); + $necessaryDefaults = [NAME_RENDER, NAME_RIGHT_PICTURE_POSITION, NAME_HASH, NAME_ENCRYPTION]; + foreach ($necessaryDefaults AS $keyName) { + if ($vars[$keyName] == '') { + $vars[$keyName] = $this->varsDefault[$keyName]; + } + } - $this->doCssClass(); - $htmlUrl = $this->doUrl($count, $hash); - $htmlImage = $this->doImage(); + // if there is no url or mailto definition: {{global.pageId}} +// if ($vars[NAME_URL] == '' && $vars[NAME_MAIL] == '') { +// $vars[NAME_URL] = "?" . $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3); +// } + + $this->doCssClass($vars); - // One space distance - if ($this->text) $distance = " "; + $htmlUrl = $this->doHtmlUrl($vars); + $htmlImage = $this->doHtmlImageGlyph($vars); - // Compose Image & Text - $distance = ' '; - $this->text = ($this->picturePosition == "l") ? $htmlImage . $distance . $this->text : $this->text . $distance . $htmlImage; +// Compose Image & Text + if ($htmlImage != '') { + $distance = ' '; + $vars[NAME_TEXT] = ($vars[NAME_RIGHT_PICTURE_POSITION] == "l") ? $htmlImage . $distance . $vars[NAME_TEXT] : $vars[NAME_TEXT] . $distance . $htmlImage; + } - // ToolTip - $extraSpan = array(); - if ($this->toolTip) { - $extraSpan[0] = "<span " . $this->toolTip[0] . ">" . $this->toolTip[1]; +// ToolTip + $extraSpan = ['', '']; + if ($vars[NAME_TOOL_TIP]) { + $extraSpan[0] = "<span " . $vars[NAME_TOOL_TIP][0] . ">" . $vars[NAME_TOOL_TIP][1]; $extraSpan[1] = "</span>"; } - // Create 'fake' modes for encrypted 'mailto' +// Create 'fake' modes for encrypted 'mailto' $prefix = ""; - if ($this->mailto) { + if ($vars[NAME_MAIL] != '') { $prefix = "1"; - $this->url = "dummy"; + $vars[NAME_URL] = "dummy"; } - // Create 'fake' mode for ajax delete - if ($this->delete) { +// Create 'fake' mode for ajax delete + if ($vars[NAME_DELETE]) { $prefix = "2"; } - // Compose URL - // get Render Mode via Array renderControl - $mode = $prefix . $this->renderControl[$this->modeRender][$this->url ? 1 : 0][$this->text ? 1 : 0]; - // 0-4 URL, plain email - // 10-14 encrypted email +// Compose URL +// get Render Mode via Array renderControl + $modeRender = $vars[NAME_RENDER]; + $modeUrl = $vars[NAME_URL] ? 1 : 0; + $modeText = $vars[NAME_TEXT] ? 1 : 0; + + if (isset($this->renderControl[$modeRender][$modeUrl][$modeText])) { + $mode = $prefix . $this->renderControl[$modeRender][$modeUrl][$modeText]; + } else { + throw new UserReportException ("Undefined combination of 'rendering mode' / 'url' / 'text': " . + $modeRender . ' / ' . $modeUrl . ' / ' . $modeText, ERROR_UNDEFINED_RENDER_CONTROL_COMBINATION); + } + +// 0-4 URL, plain email +// 10-14 encrypted email switch ($mode) { // 0: No Output case '0': case '10': case '20': - $this->link = ""; + $link = ""; break; // 1: 'text' case '1': - $this->link = $extraSpan[0] . $this->text . $extraSpan[1]; + $link = $extraSpan[0] . $vars[NAME_TEXT] . $extraSpan[1]; break; case '11': - $this->link = $extraSpan[0] . $this->encryptMailtoJS($this->mailto, $this->text, $this->linkClass, false) . $extraSpan[1]; + $link = $extraSpan[0] . $this->encryptMailtoJS($vars, false) . $extraSpan[1]; break; // 2: 'url' case '2': - $this->link = $extraSpan[0] . $this->url . $extraSpan[1]; + $link = $extraSpan[0] . $vars[NAME_URL] . $extraSpan[1]; break; case '12': - $this->link = $extraSpan[0] . $this->encryptMailtoJS($this->mailto, $this->text, $this->linkClass, false) . $extraSpan[1]; + $link = $extraSpan[0] . $this->encryptMailtoJS($vars, false) . $extraSpan[1]; break; // 3: <a href=url>url</a> case '3': - $this->link = $htmlUrl . $this->url . '</a>' . $this->toolTip[1]; + $link = $htmlUrl . $vars[NAME_URL] . '</a>' . $vars[NAME_TOOL_TIP][1]; break; case '13': - $this->link = $this->encryptMailtoJS($this->mailto, $this->mailto, $this->linkClass, TRUE); + $vars[NAME_TEXT] = $vars[NAME_MAIL]; + $link = $this->encryptMailtoJS($vars, TRUE); break; // 4: <a href=url>Text</a> case '4': - $this->link = $htmlUrl . $this->text . '</a>' . $this->toolTip[1]; + $link = $htmlUrl . $vars[NAME_TEXT] . '</a>' . $vars[NAME_TOOL_TIP][1]; break; case '14': - $this->link = $this->encryptMailtoJS($this->mailto, $this->text, $this->linkClass, TRUE); + $link = $this->encryptMailtoJS($vars, TRUE); break; case '21': case '22': case '23': case '24': - $this->link = "<a href=\"javascript: void(0);\" onClick=\"var del = new FR.Delete({recordId:'" . $count . "',hash:'" . $hash . "',forward:'" . $this->pageAlias . "'});\" " . $this->linkClass . ">" . $this->text . "</a>"; + //TODO: Alter Code, umstellen auf JS Client von RO. Vorlage koennte 'Delete' in Subrecord sein. + $link = "<a href=\"javascript: void(0);\" onClick=\"var del = new FR.Delete({recordId:'',hash:'',forward:'" . + $vars[NAME_PAGE] . "'});\" " . $vars[NAME_LINK_CLASS] . ">" . $vars[NAME_TEXT] . "</a>"; } - return $this->link; + return $link; } + /** + * Cleans the standard vars used every time to render a link. + * + * @return array + */ + private function initVars() { + + $vars = array(); + + $vars[NAME_MAIL] = ''; + $vars[NAME_URL] = ''; + $vars[NAME_PAGE] = ''; + + $vars[NAME_TEXT] = ''; + $vars[NAME_ALT_TEXT] = ''; + $vars[NAME_IMAGE] = ''; + $vars[NAME_IMAGE_TITLE] = ''; + $vars[NAME_GLYPH] = ''; + $vars[NAME_GLYPH_TITLE] = ''; + $vars[NAME_QUESTION] = ''; + $vars[NAME_TARGET] = ''; + $vars[NAME_TOOL_TIP] = ['', '']; + $vars[NAME_URL_PARAM] = ''; + + $vars[NAME_RENDER] = ''; + $vars[NAME_RIGHT_PICTURE_POSITION] = ''; + $vars[NAME_HASH] = ''; + $vars[NAME_ENCRYPTION] = ''; + $vars[NAME_DELETE] = ''; + + $vars[NAME_LINK_CLASS] = ''; // class name + $vars[NAME_LINK_CLASS_DEFAULT] = ''; // Depending of 'as page' or 'as url'. Only used if class is not explizit set. + + return $vars; + } + /** * Parse Item of link string, fill class global variables. * - * @param string $key : F.e.: 'u' - * @param string $value : F.e.: 'http://www.nzz.ch' - * @throws SyntaxReportException + * @param array $vars + * @param $item + * @throws CodeException + * @throws UserReportException */ - private function parseItem($key, $value) { - - switch ($key) { - // URL - case "u": - if ($this->url || $this->mailto) throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->url = $value; - $this->defaultLinkClass = $this->cssLinkClassExternal; - break; - case "m": - if ($this->url || $this->mailto) throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->mailto = $value; - $this->defaultLinkClass = $this->cssLinkClassExternal; - break; - case "p": - if ($this->url || $this->mailto) throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->pageAlias = $value ? $value : $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3); // If no pageid|pagealias is defined, take current page -// $this->url = "?" . $this->pageAlias; - $this->defaultLinkClass = $this->cssLinkClassInternal; - break; - // Text - case "t": - $this->text = $value; - break; - case "a": - $this->altText = $value; - break; - case "o": - $this->toolTip = $this->utils->createToolTip($value); - break; + private function parseItem(array &$vars, $item) { - // Image - case "P": - if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->image = $value; - $this->AltText = "Grafic: " . $value; - $this->imageTitle = $value; - break; - case "B": - if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->image = PATH_ICONS . "bullet-" . ($value ? $value : "green") . '.gif'; - $this->defaultAltText = "Bullet: " . $value; - $this->imageTitle = $value; - break; - case "C": - if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->image = PATH_ICONS . "checked-" . ($value ? $value : "green") . '.gif'; - $this->defaultAltText = "Checked: " . $value; - $this->imageTitle = $value; - break; - case "D": - if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->image = PATH_ICONS . 'delete.gif'; - $this->defaultAltText = "Delete"; - $this->imageTitle = "Delete"; - $this->delete = true; - // Include Extjs library - $this->utils->loadJSlib($this->fr_error); - break; - case "E": - if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->image = PATH_ICONS . 'edit.gif'; - $this->defaultAltText = "Edit"; - $this->imageTitle = "Edit"; - break; - case "H": - if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->image = PATH_ICONS . 'help.gif'; - $this->defaultAltText = "Help"; - $this->imageTitle = "Help"; - break; - case "I": - if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->image = PATH_ICONS . 'info.gif'; - $this->defaultAltText = "Information"; - $this->imageTitle = "Information"; - break; - case "N": - if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->image = PATH_ICONS . 'new.gif'; - $this->defaultAltText = "New"; - $this->imageTitle = "New"; - break; - case "S": - if ($this->image) throw new SyntaxReportException ("Multiple images defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->image = PATH_ICONS . 'show.gif'; - $this->defaultAltText = "Details"; - $this->imageTitle = "Details"; - break; + $arr = explode(":", $item, 2); + $key = isset($arr[0]) ? $arr[0] : ''; + $value = isset($arr[1]) ? $arr[1] : ''; - // Misc - case "r": - if ($this->modeRender) throw new SyntaxReportException ("Multiple render modes defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->modeRender = $value; - break; - case "g": - if ($this->target) throw new SyntaxReportException ("Multiple 'target' defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->target = $value; - break; - case "c": - if ($this->linkClass) throw new SyntaxReportException ("Multiple linkClass defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->linkClass = $value; - break; - case "q": - if ($this->question) throw new SyntaxReportException ("Multiple question defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->question = $value ? $value : "Please confirm"; - break; - case "e": - if ($this->encryption != 1) throw new SyntaxReportException ("Multiple encryption defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->encryption = $value ? $value : "1"; - break; - case "h": - if ($this->modeHash) throw new SyntaxReportException ("Multiple modeHash defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->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); - $this->additionalUrlParams = $value; - break; - case "R": - if ($this->picturePosition != "l") throw new SyntaxReportException ("Multiple picturePosition defined: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); - $this->picturePosition = "r"; - break; + // Superclass + if ($key === 'A' || $key === 'G') { + $this->parseItem($vars, $value); + return; + } - // A,G - case "G": - case "A": - $arr = explode(":", $value, 2); - $this->parseItem($arr[0], $arr[1]); - break; - case "" : - break; - default: - throw new SyntaxReportException ("Unknown link qualifier: '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + if (!isset($this->tableVarName[$key])) { + throw new UserReportException ("Unknown link qualifier: '$key'", ERROR_UNKNOWN_LINK_QUALIFIER); + } + $keyName = $this->tableVarName[$key]; + + // A few keys do not have necessarily a value: fake the definition by manual assigning the default + if ($value == '') { + switch ($key) { + case 'R': + $value = 'r'; + break; + case 'h': + $value = '1'; + break; + case 'p': + $value = $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3); // If no pageid|pagealias is defined, take current page + break; + default: + break; + } + } + + // Take defaults + if ($value === '' && isset($this->varsDefault[$keyName])) { + $value = $this->varsDefault[$keyName]; } + // Check for empty values. Some keys are allowed to be empty. + if ($value === '' && strpos('uENDHIS', $key) === false) { + throw new UserReportException ("Missing value for '$key'", ERROR_MISSING_VALUE); + } + + // Value already defined? + if ($vars[$keyName] !== '') { + throw new UserReportException ("Multiple definitions for key '$key'", ERROR_MULTIPLE_DEFINITION); + } + + // Store value + $vars[$keyName] = $value; + + if ($vars[NAME_URL] && $vars[NAME_MAIL]) { + throw new UserReportException ("Multiple URL / PAGE and MAILTO definition", ERROR_MULTIPLE_URL_PAGE_MAILTO_DEFINITION); + } + + // Call special function + if (isset($this->callTable[$key])) { + $call = $this->callTable[$key]; + $this->$call($vars, $keyName, $value); + } } /** * Parse CSS Class Settings * - * @param void - * + * @param array $vars * @return void */ - private function doCssClass() { - - // class: i|e|n|<custom name> - if ($this->linkClass != 'n') { - if (!$this->linkClass) $this->linkClass = $this->defaultLinkClass; - - if ($this->linkClassSelector[$this->linkClass]) - $this->linkClass = $this->linkClassSelector[$this->linkClass]; + private function doCssClass(array &$vars) { + $class = ''; - $this->linkClass = ' class="' . $this->linkClass . '"'; - } else { - $this->linkClass = ""; + switch ($vars[NAME_LINK_CLASS]) { + case 'n': + $vars[NAME_LINK_CLASS] = ''; + break; + case 'i': + case 'e': + $vars[NAME_LINK_CLASS] = $this->linkClassSelector[$vars[NAME_LINK_CLASS]]; + break; + default: + $vars[NAME_LINK_CLASS] = ($vars[NAME_LINK_CLASS] == '') ? $vars[NAME_LINK_CLASS_DEFAULT] : $vars[NAME_LINK_CLASS]; + break; } } @@ -454,75 +501,99 @@ 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 + * @throws UserReportException */ - private function doUrl() { + private function doHtmlUrl(array &$vars) { + $tags = ''; // build URL $htmlUrl = ""; + $anchorTitle = ''; - if ($this->url) { + if ($vars[NAME_URL] !== '') { - if ($this->modeHash) { + if ($vars[NAME_HASH] === "1") { - $this->url = $this->sip->queryStringToSip('id=' . $this->pageAlias . '&' . $this->additionalUrlParams); + $vars[NAME_URL] = $this->sip->queryStringToSip($vars[NAME_PAGE] . '&' . $vars[NAME_URL_PARAM]); } else { - if ($this->additionalUrlParams) { + if ($vars[NAME_URL_PARAM] != '') { // Append '&' or '?' depending if there is already a '?' - $this->url .= (strpos($this->url, '?') >= 0) ? '&' : '?'; + $vars[NAME_URL] .= (strpos($vars[NAME_URL], '?') >= 0) ? '&' : '?'; // Append all additional params. - $this->url .= $this->additionalUrlParams; + $vars[NAME_URL] .= $vars[NAME_URL_PARAM]; } } } // If there is no encryption: handle the mailto as an ordinary URL - if ($this->mailto) { + if ($vars[NAME_MAIL] !== '') { - if ($this->encryption == 0) { - $this->url = "mailto:" . $this->mailto; - $this->mailto = ""; + if ($vars[NAME_ENCRYPTION] === '0') { + $vars[NAME_URL] = "mailto:" . $vars[NAME_MAIL]; + $vars[NAME_MAIL] = ""; } else { - throw new SyntaxReportException ("Oops, sorry: encrypted mail not implemented ...", "", __FILE__, __LINE__, - "Column: " . $this->fr_error["columnIndex"], $this->fr_error); + throw new UserReportException ("Oops, sorry: encrypted mail not implemented ...", ERROR_NOT_IMPLEMENTED); } } - // target - if ($this->target) $this->target = ' target="' . $this->target . '"'; + if ($vars[NAME_GLYPH] !== '') { + $vars[NAME_LINK_CLASS] .= ' btn btn-default '; + + if ($vars[NAME_GLYPH_TITLE] !== '') { + $anchorTitle = $vars[NAME_GLYPH_TITLE]; + } + } - // question - if ($this->question) $this->question = ' onclick="return confirm(\'' . $this->question . '\')"'; + $tags .= Support::doAttribute('href', $vars[NAME_URL]); + $tags .= Support::doAttribute('class', $vars[NAME_LINK_CLASS]); + $tags .= Support::doAttribute('target', $vars[NAME_TARGET]); + $tags .= Support::doAttribute('title', $anchorTitle); + if ($vars[NAME_QUESTION]) { + $tags .= Support::doAttribute('onclick', 'confirm(\'' . $vars[NAME_QUESTION] . '\')'); + } - $htmlUrl = '<a href="' . $this->url . '"' . $this->linkClass . $this->target . $this->question . $this->toolTip[0] . '>'; + $htmlUrl = '<a ' . $tags . $vars[NAME_TOOL_TIP][0] . '>'; return ($htmlUrl); } + // +//<a class="btn btn-default" href="index.php?id=2&s=56fbdd30a0cd2" title='comment'> +// <span class='glyphicon glyphicon-plus'></span> +//</a> +// +//<a href="index.php?id=2&s=56fb7f7703692" class="internal" > +// <img src="typo3conf/ext/qfq/Resources/Public/icons/edit.gif" title="Edit" > +//</a> + + /** * Create Image HTML Tag - * @return string $htmlImage - * @internal param $void * + * @param array $vars + * @return string */ - private function doImage() { - $htmlImage = ""; + private function doHtmlImageGlyph(array $vars) { + $tags = ''; + $html = ''; // Build Image - if ($this->image) { - - if ($this->altText) $this->altText = ' alttext="' . $this->altText . '"'; - - if ($this->image) $this->image = ' src="' . $this->image . '"'; - - if ($this->imageTitle) $this->imageTitle = ' title="' . $this->imageTitle . '"'; + if ($vars[NAME_IMAGE] !== '') { + $tags .= Support::doAttribute('alt', $vars[NAME_ALT_TEXT]); + $tags .= Support::doAttribute('src', $vars[NAME_IMAGE]); + $tags .= Support::doAttribute('title', $vars[NAME_IMAGE_TITLE]); + $html .= '<img ' . $tags . '>'; + } - $htmlImage = '<img' . $this->image . $this->altText . $this->imageTitle . ' />'; + if ($vars[NAME_GLYPH] !== '') { + $tags = Support::doAttribute('class', 'glyphicon ' . $vars[NAME_GLYPH]); + $html .= Support::wrapTag('<span ' . $tags . '>', '', false); } - return ($htmlImage); + return $html; } /** @@ -538,20 +609,14 @@ 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($mailto, $text, $class = "", $href = TRUE) { - - // Prepare CSS Definition - if ($class) $class = str_replace('"', "'", $class); + private function encryptMailtoJS(array $vars, $href = TRUE) { // Split $mailto - $tmp = $this->splitAndAddDelimter($mailto, "@"); + $tmp = $this->splitAndAddDelimter($vars[NAME_MAIL], "@"); $arr = array_merge($this->splitAndAddDelimter($tmp[0], "."), $this->splitAndAddDelimter($tmp[1], ".")); $tt = "<script language=javascript><!--" . chr(10); @@ -564,7 +629,7 @@ class Link { // Compose $dw (documentwrite statement) $dw .= ' + mm' . $ii++; } - $dw .= ' + "' . $class . str_replace('"', '\\"', $this->toolTip[0]) . '>"'; + $dw .= ' + "' . $vars[NAME_LINK_CLASS] . str_replace('"', '\\"', $vars[NAME_TOOL_TIP][0]) . '>"'; $closeDw = '"</a>")'; } else { $dw = 'document.write('; @@ -572,7 +637,7 @@ class Link { } // Wrap mailto around text - if ($mailto == $text) { + if ($vars[NAME_MAIL] == $vars[NAME_TEXT]) { // Text is an email: wrap every single part of mailto. $ii = 0; foreach ($arr as $value) { @@ -580,11 +645,11 @@ class Link { } } else { // Single wrap text - $tt .= $dw . ' + "' . $text . '" + ' . $closeDw . chr(10); + $tt .= $dw . ' + "' . $vars[NAME_TEXT] . '" + ' . $closeDw . chr(10); } $tt .= '//--></script>'; - if ($href) $tt .= $this->toolTip[1]; + if ($href) $tt .= $vars[NAME_TOOL_TIP][1]; return ($tt); } @@ -599,6 +664,7 @@ class Link { * @return array */ private function splitAndAddDelimter($mailto, $delimiter) { + //TODO: Ich verstehe die Funktion nicht - funktioniert das hier wirklich? $value = ''; $arr = explode($delimiter, $mailto); // split string @@ -612,4 +678,180 @@ class Link { return ($arr); } + + /** + * Called by $this->callTable + * + * @param $vars + * @param $key + * @param $value + */ + private function buildUrl(&$vars, $key, $value) { + $vars[NAME_LINK_CLASS_DEFAULT] = $this->cssLinkClassExternal; + } + + /** + * Called by $this->callTable + * + * @param $vars + * @param $key + * @param $value + */ + private function buildMail(&$vars, $key, $value) { + $vars[NAME_LINK_CLASS_DEFAULT] = $this->cssLinkClassExternal; + } + + /** + * Called by $this->callTable + * + * @param $vars + * @param $key + * @param $value + * @throws UserReportException + */ + private function buildPage(&$vars, $key, $value) { + + if ($vars[NAME_URL] != '') { + throw new UserReportException ("Multiple definitions for key 'p'", ERROR_MULTIPLE_DEFINITION); + } + + if (substr($value, 0, 3) !== 'id=') { + $value = 'id=' . $value; + } + + $vars[NAME_URL] = "?" . $value; + $vars[NAME_LINK_CLASS_DEFAULT] = $this->cssLinkClassInternal; + } + + /** + * Called by $this->callTable + * + * @param $vars + * @param $key + * @param $value + */ + private function buildPicture(&$vars, $key, $value) { + $vars[NAME_ALT_TEXT] = "Grafic: " . $value; + $vars[NAME_IMAGE_TITLE] = $value; + } + + /** + * Called by $this->callTable + * + * @param $vars + * @param $key + * @param $value + */ + private function buildBullet(&$vars, $key, $value) { + $vars[NAME_IMAGE] = PATH_ICONS . "bullet-" . $value . '.gif'; + $vars[NAME_IMAGE_TITLE] = $value; + } + + /** + * Called by $this->callTable + * + * @param $vars + * @param $key + * @param $value + */ + private function buildCheck(&$vars, $key, $value) { + $vars[NAME_IMAGE] = PATH_ICONS . "checked-" . $value . '.gif'; + $vars[NAME_IMAGE_TITLE] = $value; + } + + /** + * Called by $this->callTable + * + * @param $vars + * @param $key + * @param $value + */ + private function buildDelete(&$vars, $key, $value) { +// $vars[NAME_IMAGE] = PATH_ICONS . 'delete.gif'; +// $vars[NAME_IMAGE_TITLE] = "Delete"; + $vars[NAME_DELETE] = true; + + $vars[NAME_GLYPH] = GLYPH_ICON_DELETE; + $vars[NAME_GLYPH_TITLE] = "Delete"; + + // Include Extjs library + $this->utils->loadJSlib($this->fr_error); + } + + /** + * Called by $this->callTable + * + * @param $vars + * @param $key + * @param $value + */ + private function buildEdit(&$vars, $key, $value) { +// $vars[NAME_IMAGE] = PATH_ICONS . 'edit.gif'; +// $vars[NAME_IMAGE_TITLE] = "Edit"; + $vars[NAME_GLYPH] = GLYPH_ICON_EDIT; + $vars[NAME_GLYPH_TITLE] = "Edit"; + } + + + /** + * Called by $this->callTable + * + * @param $vars + * @param $key + * @param $value + */ + private function buildHelp(&$vars, $key, $value) { +// $vars[NAME_IMAGE] = PATH_ICONS . 'help.gif'; +// $vars[NAME_IMAGE_TITLE] = "Help"; + $vars[NAME_GLYPH] = GLYPH_ICON_HELP; + $vars[NAME_GLYPH_TITLE] = "Help"; + } + + /** + * Called by $this->callTable + * + * @param $vars + * @param $key + * @param $value + */ + private function buildInfo(&$vars, $key, $value) { +// $vars[NAME_IMAGE] = PATH_ICONS . 'info.gif'; +// $vars[NAME_IMAGE_TITLE] = "Information"; + + $vars[NAME_GLYPH] = GLYPH_ICON_INFO; + $vars[NAME_GLYPH_TITLE] = "Information"; + + } + + /** + * Called by $this->callTable + * + * @param $vars + * @param $key + * @param $value + */ + private function buildNew(&$vars, $key, $value) { +// $vars[NAME_IMAGE] = PATH_ICONS . 'new.gif'; +// $vars[NAME_IMAGE_TITLE] = "New"; + + $vars[NAME_GLYPH] = GLYPH_ICON_NEW; + $vars[NAME_GLYPH_TITLE] = "New"; + + } + + /** + * Called by $this->callTable + * + * @param $vars + * @param $key + * @param $value + */ + private function buildShow(&$vars, $key, $value) { +// $vars[NAME_IMAGE] = PATH_ICONS . 'show.gif'; +// $vars[NAME_IMAGE_TITLE] = "Details"; + + $vars[NAME_GLYPH] = GLYPH_ICON_SHOW; + $vars[NAME_GLYPH_TITLE] = "Details"; + + } } \ No newline at end of file diff --git a/extension/qfq/qfq/report/Report.php b/extension/qfq/qfq/report/Report.php index b3a684a6636d70e784d72b480b55efb3ef788d17..62f3f5fc7495a837fa1ee9261433dbf8508f14fb 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 */ @@ -76,6 +82,8 @@ class Report { private $phpUnit = false; + private $showDebugInfo = false; + /** * Report constructor. * @@ -87,6 +95,9 @@ class Report { $this->t3data = $t3data; $this->sip = new Sip($sessionName, $phpUnit); + $this->store = Store::getInstance(); + + $this->showDebugInfo = ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes'); $this->page_control["msgbox"]["pagec"] = "Please confirm!"; @@ -145,12 +156,6 @@ class Report { // Report $content = $this->triggerReport(); - - if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) { -// debug($this->frArray); -// debug($_SESSION); - } - return $content; } @@ -162,10 +167,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 +205,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 +228,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 +282,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 +316,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 +356,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 +401,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 +456,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 +484,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 +517,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; @@ -583,8 +527,8 @@ class Report { $content = ""; switch ($columnName) { case "link": - $link = new Link($full_level, $this->frArray[$full_level . ".sql"], $columnValue, $rowIndex, $columnIndex, $this->fr_error, $this->sip); - $content .= $link->renderLink($columnValue, $rowIndex, $this->frArray[$full_level . "." . "hash." . "$columnIndex"]); + $link = new Link($this->fr_error, $this->dbAlias, $this->sip); + $content .= $link->renderLink($columnValue); # unset $link; break; case "exec": @@ -601,8 +545,8 @@ class Report { case "Pages": $linkValue = $this->doFixColPosPage($columnName, $columnValue); - $link = new Link($full_level, $this->frArray[$full_level . ".sql"], $linkValue, $rowIndex, $columnIndex, $this->fr_error, $this->dbAlias, $this->sip); - $content .= $link->renderLink($linkValue, $rowIndex, $this->frArray[$full_level . "." . "hash." . "$columnIndex"]); + $link = new Link($this->fr_error, $this->sip); + $content .= $link->renderLink($linkValue); break; case "page": @@ -617,8 +561,8 @@ class Report { $linkValue = $this->doPage($columnName, $columnValue); // debug($linkValue); - $link = new Link($full_level, $this->frArray[$full_level . ".sql"], $linkValue, $rowIndex, $columnIndex, $this->fr_error, $this->dbAlias, $this->sip); - $content .= $link->renderLink($linkValue, $rowIndex, $this->frArray[$full_level . "." . "hash." . "$columnIndex"]); + $link = new Link($this->fr_error, $this->sip); + $content .= $link->renderLink($linkValue); break; case "img": @@ -776,10 +720,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); @@ -811,7 +751,7 @@ class Report { * ------------- * [<page id|alias>[¶m=value&...]] | [record id] | [text] | [tooltip] | [msgbox] | [class] | [target] | [render mode] | [create hash] * - * param[0]: <page id|alias>[¶m=value&.. + * param[0]: <page id|alias>[¶m=value&...] * param[1]: record id * param[2]: text * param[3]: tooltip @@ -823,16 +763,13 @@ 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 = ""; // Split definition $param = explode('|', $columnValue); - if (count($param) > 9) throw new SyntaxReportException ("Too many parameter (max=9): $columnValue", "", __FILE__, __LINE__, $this->fr_error); + if (count($param) > 9) + throw new SyntaxReportException ("Too many parameter (max=9): $columnValue", "", __FILE__, __LINE__, $this->fr_error); // make first 'P' lowercase $columnName = 'p' . substr($columnName, 1); @@ -854,7 +791,8 @@ class Report { if (!$param[8]) $param[8] = $this->page_control["hash"][$columnName]; // if no hash behaviour defined, use default if ($param[8] == "h") $link .= "h|"; - if ($this->page_control["icon"][$columnName]) $link .= $this->page_control["icon"][$columnName] . "|"; + if ($this->page_control["icon"][$columnName]) + $link .= $this->page_control["icon"][$columnName] . "|"; return ($link); } @@ -879,11 +817,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) @@ -903,11 +836,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 @@ -958,10 +886,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; @@ -982,10 +906,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) . "]"; @@ -998,10 +918,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]) { @@ -1017,10 +933,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/qfq/store/FillStoreForm.php b/extension/qfq/qfq/store/FillStoreForm.php index 3e8b3eff21ab0fecd60953ab453b69a30d476bf1..9e69e47e627b83b52528ea18ba29b2a92852beac 100644 --- a/extension/qfq/qfq/store/FillStoreForm.php +++ b/extension/qfq/qfq/store/FillStoreForm.php @@ -44,7 +44,7 @@ class FillStoreForm { * * @throws CodeException * @throws DbException - * @throws UserException + * @throws UserFormException */ private function loadFormElementsBasedOnSIP() { $form = $this->store->getVar(SIP_FORM, STORE_SIP); @@ -52,7 +52,7 @@ class FillStoreForm { $feSpecNative = $this->db->sql(SQL_FORM_ELEMENT_SIMPLE_ALL_CONTAINER, ROW_REGULAR, [$form]); if (count($feSpecNative) === 0) { - throw new UserException('Form not found or multiple forms with the same name.', ERROR_FORM_NOT_FOUND); + throw new UserFormException('Form not found or multiple forms with the same name.', ERROR_FORM_NOT_FOUND); } return $feSpecNative; @@ -63,7 +63,7 @@ class FillStoreForm { * definition and throws an exception if check fails. FormElements.type=hidden will be taken from STORE_SIP. * * @throws CodeException - * @throws UserException + * @throws UserFormException */ public function process() { $html = ''; diff --git a/extension/qfq/qfq/store/Sip.php b/extension/qfq/qfq/store/Sip.php index 1b387abadfd1b68600ded95923936669408da9ac..a747f2ac2db0a6f12793151a32de862d844a2e5f 100644 --- a/extension/qfq/qfq/store/Sip.php +++ b/extension/qfq/qfq/store/Sip.php @@ -9,7 +9,7 @@ namespace qfq; use qfq\CodeException; -use qfq\UserException; +use qfq\UserFormException; use qfq\OnArray; use qfq\KeyValueStringParser; @@ -42,7 +42,7 @@ class Sip { if ($phpUnit) { $_SESSION = null; - @session_start(); +// @session_start(); } else { // session_name($sessionname); @@ -68,7 +68,7 @@ class Sip { * * mode=RETURN_URL: return complete URL * * mode=RETURN_SIP: returns only the sip * @throws CodeException - * @throws UserException + * @throws UserFormException */ public function queryStringToSip($queryString, $mode = RETURN_URL, $scriptName = 'index.php') { @@ -213,26 +213,26 @@ class Sip { * * @param $s * @return array Parameter Array - * @throws UserException - * @throws \qfq\UserException + * @throws UserFormException + * @throws \qfq\UserFormException */ public function getVarsFromSip($s) { # Check if parameter is manipulated if (strlen($s) != 13) { - throw new UserException("Broken Parameter", ERROR_BROKEN_PARAMETER); + throw new UserFormException("Broken Parameter", ERROR_BROKEN_PARAMETER); } # Check if still the same fe_user is logged in. if (isset($GLOBALS["TSFE"]->fe_user->user["uid"])) { if ($_SESSION[SESSION_FE_USER_UID] != $GLOBALS["TSFE"]->fe_user->user["uid"]) { - throw new UserException("No user logged in or user changed - please reload the previous site.", ERROR_FE_USER_UID_CHANGED); + throw new UserFormException("No user logged in or user changed - please reload the previous site.", ERROR_FE_USER_UID_CHANGED); } } # Check if index 's' exists. if (!isset($_SESSION[$s])) { - throw new UserException("SIP '$s' not registered - please reload the previous site and try again.", ERROR_SIP_NOT_FOUND); + throw new UserFormException("SIP '$s' not registered - please reload the previous site and try again.", ERROR_SIP_NOT_FOUND); } // Decode parameter diff --git a/extension/qfq/qfq/store/Store.php b/extension/qfq/qfq/store/Store.php index 120808234bc215e3bc0565c1cd729ceccd438977..f4fc7e2cd4b1277f6a0757dee384abe22360ac3a 100644 --- a/extension/qfq/qfq/store/Store.php +++ b/extension/qfq/qfq/store/Store.php @@ -71,6 +71,8 @@ class Store { */ private static $sanitizeStore = array(); + private static $phpUnit = false; + /** * @param string $bodytext */ @@ -150,7 +152,7 @@ class Store { /** * @throws CodeException - * @throws qfq\UserException + * @throws qfq\UserFormException */ private function fillSystemStore() { try { @@ -162,10 +164,10 @@ class Store { // $config['SQLLOG'] = Support::ifRelativePathPrependExtensionPath($config['SQLLOG']); } catch (\Exception $e) { - throw new qfq\UserException ("Error read file " . CONFIG_INI . ": " . $e->getMessage(), ERROR_IO_READ_FILE); + throw new qfq\UserFormException ("Error read file " . CONFIG_INI . ": " . $e->getMessage(), ERROR_IO_READ_FILE); } - if(!isset($config['SHOW_DEBUG_INFO']) || $config['SHOW_DEBUG_INFO'] === 'auto') { + if (!isset($config['SHOW_DEBUG_INFO']) || $config['SHOW_DEBUG_INFO'] === 'auto') { $config['SHOW_DEBUG_INFO'] = (isset($GLOBALS["TSFE"]->beUserLogin) && $GLOBALS["TSFE"]->beUserLogin === true) ? 'yes' : 'no'; } @@ -176,7 +178,8 @@ class Store { // If we are called through AJAX API (e.g. api/save.php), there is no TYPO3 environment. if (isset($_SERVER['SCRIPT_FILENAME'])) { $pos = strpos($_SERVER['SCRIPT_FILENAME'], $relExtDir); - if ($pos === false) { + if ($pos === false && isset($GLOBALS['TYPO3_LOADED_EXT'][EXT_KEY]['ext_localconf.php'])) { + // probably: index.php - THERE should be a TYPO3 environment. $config[SYSTEM_PATH_EXT] = dirname($GLOBALS['TYPO3_LOADED_EXT'][EXT_KEY]['ext_localconf.php']); } else { @@ -198,13 +201,13 @@ class Store { * @param array $dataArray * @param $store * @param bool|false $flagOverwrite - * @throws UserException + * @throws UserFormException * @throws \qfq\CodeException */ public function setVarArray(array $dataArray, $store, $flagOverwrite = false) { // Check valid Storename if (!isset(self::$sanitizeStore)) - throw new UserException("Unknown Store: $store", ERROR_UNNOWN_STORE); + throw new UserFormException("Unknown Store: $store", ERROR_UNNOWN_STORE); if ($store === STORE_ZERO) @@ -258,7 +261,7 @@ class Store { /** * @throws CodeException - * @throws UserException + * @throws UserFormException */ private function fillStoreSip() { @@ -351,6 +354,8 @@ class Store { // Design Pattern: Singleton if (self::$instance === null) { + self::$phpUnit = $phpUnit; + self::$instance = new self($bodytext); } else { // Class Store seems to be presistent over multiple QFQ instantiation. Set bodytext again, with every new request (if bodytext is given). @@ -361,13 +366,14 @@ class Store { return self::$instance; } + /** * @param $store */ public static function unsetStore($store) { // Check valid Storename if (!isset(self::$sanitizeStore)) - throw new UserException("Unknown Store: $store", ERROR_UNNOWN_STORE); + throw new UserFormException("Unknown Store: $store", ERROR_UNNOWN_STORE); if ($store === STORE_ZERO) throw new CodeException("unsetStore() for STORE_ZERO is impossible - there are no values.", ERROR_SET_STORE_ZERO); @@ -416,18 +422,18 @@ class Store { * @param $value * @param $store * @param bool|true $overWrite - * @throws UserException + * @throws UserFormException */ public static function setVar($key, $value, $store, $overWrite = true) { // Check valid Storename if (!isset(self::$sanitizeStore)) - throw new UserException("Unknown Store: $store", ERROR_UNNOWN_STORE); + throw new UserFormException("Unknown Store: $store", ERROR_UNNOWN_STORE); if ($store === STORE_ZERO) throw new CodeException("setVar() for STORE_ZERO is impossible - there are no values.", ERROR_SET_STORE_ZERO); if ($overWrite === false && isset(self::$raw[$store][$key])) { - throw new UserException("Value of '$key' already be set in store '$store'.", ERROR_STORE_KEY_EXIST); + throw new UserFormException("Value of '$key' already be set in store '$store'.", ERROR_STORE_KEY_EXIST); } self::$raw[$store][$key] = $value; @@ -440,7 +446,7 @@ class Store { public static function getStore($store) { // Check valid Storename if (!isset(self::$sanitizeStore[$store])) - throw new UserException("Unknown Store: $store", ERROR_UNNOWN_STORE); + throw new UserFormException("Unknown Store: $store", ERROR_UNNOWN_STORE); if ($store === STORE_ZERO) throw new CodeException("getStore() for STORE_ZERO is impossible - there are no values saved.", ERROR_GET_STORE_ZERO); diff --git a/extension/qfq/tests/phpunit/AbstractDatabaseTest.php b/extension/qfq/tests/phpunit/AbstractDatabaseTest.php index 808fd8f30a84668e8e04918752170b8e51e8e91a..07d2dc72bd9579f55a465296532ceaf8ff4953df 100644 --- a/extension/qfq/tests/phpunit/AbstractDatabaseTest.php +++ b/extension/qfq/tests/phpunit/AbstractDatabaseTest.php @@ -56,7 +56,7 @@ abstract class AbstractDatabaseTest extends PHPUnit_Framework_TestCase { protected function setUp() { // Init the store also reads db credential configuration - $this->store = \qfq\Store::getInstance(); + $this->store = \qfq\Store::getInstance('', true); // SWITCH to TestDB $this->store->setVar(SYSTEM_DB_NAME, $this->store->getVar(SYSTEM_DB_NAME_TEST, STORE_SYSTEM), STORE_SYSTEM); diff --git a/extension/qfq/tests/phpunit/BodytextParserTest.php b/extension/qfq/tests/phpunit/BodytextParserTest.php index c483f144d8e18d8fb40f31a488168244c7c5fb4a..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 { @@ -92,7 +92,7 @@ class BodytextParserTest extends \PHPUnit_Framework_TestCase { } /** - * @expectedException \qfq\UserException + * @expectedException \qfq\UserFormException * */ public function testProcessException() { diff --git a/extension/qfq/tests/phpunit/BuildFormPlainTest.php b/extension/qfq/tests/phpunit/BuildFormPlainTest.php index 7d3e91d97125896b98a6271c27a93d9f45e68fe3..081d024ac072b849ca28c3e165ef55813928a9b6 100644 --- a/extension/qfq/tests/phpunit/BuildFormPlainTest.php +++ b/extension/qfq/tests/phpunit/BuildFormPlainTest.php @@ -122,7 +122,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest { $formElement['checkType'] = SANITIZE_ALLOW_EMAIL; $formElement['checkPattern'] = ''; $result = $build->buildInput($formElement, 'name:1', '', $json); - $this->assertEquals('<input name="name:1" type="input" maxlength="255" value="" pattern="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$" >', $result); + $this->assertEquals('<input name="name:1" type="input" maxlength="255" value="" pattern="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$" >', $result); $this->assertEquals(['form-element' => 'name:1', 'value' => '', 'disabled' => false, 'readonly' => false], $json); $formElement['checkType'] = ''; @@ -215,7 +215,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest { } /** - * @expectedException \qfq\UserException + * @expectedException \qfq\UserFormException * */ public function testBuildInputException() { @@ -334,7 +334,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest { } /** - * @expectedException \qfq\UserException + * @expectedException \qfq\UserFormException * */ public function testGetKeyValueListFromSqlEnumSpecException() { diff --git a/extension/qfq/tests/phpunit/HelperFormElementTest.php b/extension/qfq/tests/phpunit/HelperFormElementTest.php index 8a23f9d7aab82e20c5081dbdddfaf6e75eb02ea5..ee6a0c25dcc093ef01dbf9fb7615205da73dd568 100644 --- a/extension/qfq/tests/phpunit/HelperFormElementTest.php +++ b/extension/qfq/tests/phpunit/HelperFormElementTest.php @@ -43,7 +43,7 @@ class HelperFormElementTest extends \PHPUnit_Framework_TestCase { /** - * @expectedException \qfq\UserException + * @expectedException \qfq\UserFormException * */ public function testExplodeFieldParameterException() { diff --git a/extension/qfq/tests/phpunit/KeyValueStringParserTest.php b/extension/qfq/tests/phpunit/KeyValueStringParserTest.php index 7f61b69e4a66ddb3c9a2f5c9452988b294824d53..bebcb8339347d42fe821179e75c2c71a767a4098 100644 --- a/extension/qfq/tests/phpunit/KeyValueStringParserTest.php +++ b/extension/qfq/tests/phpunit/KeyValueStringParserTest.php @@ -36,7 +36,7 @@ class KeyValueStringParserTest extends \PHPUnit_Framework_TestCase { } /** - * @expectedException \qfq\UserException + * @expectedException \qfq\UserFormException */ public function testNoKey() { keyValueStringParser::parse(":value,key:value"); diff --git a/extension/qfq/tests/phpunit/LinkTest.php b/extension/qfq/tests/phpunit/LinkTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e2c7dce6135c779f0fc000c2ee9ee5cee0f43ced --- /dev/null +++ b/extension/qfq/tests/phpunit/LinkTest.php @@ -0,0 +1,514 @@ +<?php +/** + * Created by PhpStorm. + * User: crose + * Date: 3/31/16 + * Time: 10:06 PM + */ + +namespace qfq; + +require_once(__DIR__ . '/../../qfq/report/Link.php'); +require_once(__DIR__ . '/../../qfq/store/Store.php'); +require_once(__DIR__ . '/../../qfq/store/Sip.php'); + + +class LinkTest extends \PHPUnit_Framework_TestCase { + + /** + * @var Sip + */ + private $sip = null; + + /** + * @var Store + */ + private $store = null; + + + /** + * @throws SyntaxReportException + */ + public function testLinkUrlBasic() { + $link = new Link(null, $this->sip, true); + + $result = $link->renderLink(''); + $this->assertEquals('', $result); + + $result = $link->renderLink('u'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com'); + $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result); + + $result = $link->renderLink('u:http://example.com|t:Hello world'); + $this->assertEquals('<a href="http://example.com" class="external" >Hello world</a>', $result); + } + + /** + * @expectedException \qfq\UserReportException + * + */ + public function testLinkUrlBasicExceptionDouble() { + $link = new Link(null, $this->sip, true); + + $result = $link->renderLink('u:http://example.com|u:http://new.org'); + } + + + /** + * @throws SyntaxReportException + */ + public function testLinkPageBasic() { + $link = new Link(null, $this->sip, true); + Store::setVar(TYPO3_PAGE_ID, 'firstPage', STORE_TYPO3); + + $result = $link->renderLink('p'); + $this->assertEquals('<a href="?id=firstPage" class="internal" >?id=firstPage</a>', $result); + + $result = $link->renderLink('p:'); + $this->assertEquals('<a href="?id=firstPage" class="internal" >?id=firstPage</a>', $result); + + $result = $link->renderLink('p:secondPage'); + $this->assertEquals('<a href="?id=secondPage" class="internal" >?id=secondPage</a>', $result); + + $result = $link->renderLink('p:id=secondPage'); + $this->assertEquals('<a href="?id=secondPage" class="internal" >?id=secondPage</a>', $result); + + $result = $link->renderLink('p:secondPage|t:Hello world'); + $this->assertEquals('<a href="?id=secondPage" class="internal" >Hello world</a>', $result); + } + + /** + * @throws SyntaxReportException + */ + public function testLinkMailBasic() { + $link = new Link(null, $this->sip, true); + + $result = $link->renderLink('m:john@doe.com'); + $this->assertEquals('<a href="mailto:john@doe.com" class="external" >mailto:john@doe.com</a>', $result); + + $result = $link->renderLink('m:john@doe.com|t:John Doe'); + $this->assertEquals('<a href="mailto:john@doe.com" class="external" >John Doe</a>', $result); + } + + /** + * @expectedException \qfq\UserReportException + * + */ + public function testLinkMailBasicExceptionMissing1() { + $link = new Link(null, $this->sip, true); + + $result = $link->renderLink('m'); + } + + /** + * @expectedException \qfq\UserReportException + * + */ + public function testLinkMailBasicExceptionMissing2() { + $link = new Link(null, $this->sip, true); + + $result = $link->renderLink('m:'); + } + + public function testRenderModeUrl() { + $link = new Link(null, $this->sip, true); + + // r: default (0) + $result = $link->renderLink('u'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com'); + $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result); + + $result = $link->renderLink('t:Example'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|t:Example'); + $this->assertEquals('<a href="http://example.com" class="external" >Example</a>', $result); + + // r: 0 + $result = $link->renderLink('u|r:0'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|r:0'); + $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result); + + $result = $link->renderLink('t:Example|r:0'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|t:Example|r:0'); + $this->assertEquals('<a href="http://example.com" class="external" >Example</a>', $result); + + // r: 1 + $result = $link->renderLink('u|r:1'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|r:1'); + $this->assertEquals('<a href="http://example.com" class="external" >http://example.com</a>', $result); + + $result = $link->renderLink('t:Example|r:1'); + $this->assertEquals('<span >Example</span>', $result); + + $result = $link->renderLink('u:http://example.com|t:Example|r:1'); + $this->assertEquals('<a href="http://example.com" class="external" >Example</a>', $result); + + // r: 2 + $result = $link->renderLink('u|r:2'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|r:2'); + $this->assertEquals('', $result); + + $result = $link->renderLink('t:Example|r:2'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|t:Example|r:2'); + $this->assertEquals('<a href="http://example.com" class="external" >Example</a>', $result); + + // r: 3 + $result = $link->renderLink('u|r:3'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|r:3'); + $this->assertEquals('<span >http://example.com</span>', $result); + + $result = $link->renderLink('t:Example|r:3'); + $this->assertEquals('<span >Example</span>', $result); + + $result = $link->renderLink('u:http://example.com|t:Example|r:3'); + $this->assertEquals('<span >Example</span>', $result); + + // r: 4 + $result = $link->renderLink('u|r:4'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|r:4'); + $this->assertEquals('<span >http://example.com</span>', $result); + + $result = $link->renderLink('t:Example|r:4'); + $this->assertEquals('<span >Example</span>', $result); + + $result = $link->renderLink('u:http://example.com|t:Example|r:4'); + $this->assertEquals('<span >http://example.com</span>', $result); + + // r: 5 + $result = $link->renderLink('u|r:5'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|r:5'); + $this->assertEquals('', $result); + + $result = $link->renderLink('t:Example|r:5'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|t:Example|r:5'); + $this->assertEquals('', $result); + } + + public function testRenderModePage() { + $link = new Link(null, $this->sip, true); + Store::setVar(TYPO3_PAGE_ID, 'firstPage', STORE_TYPO3); + + // r: default (0) + $result = $link->renderLink('p'); + $this->assertEquals('<a href="?id=firstPage" class="internal" >?id=firstPage</a>', $result); + + $result = $link->renderLink('p:secondPage'); + $this->assertEquals('<a href="?id=secondPage" class="internal" >?id=secondPage</a>', $result); + + $result = $link->renderLink('t:Example'); + $this->assertEquals('', $result); + + $result = $link->renderLink('p:secondPage|t:Example'); + $this->assertEquals('<a href="?id=secondPage" class="internal" >Example</a>', $result); + + // r: 0 + $result = $link->renderLink('p|r:0'); + $this->assertEquals('<a href="?id=firstPage" class="internal" >?id=firstPage</a>', $result); + + $result = $link->renderLink('p:secondPage|r:0'); + $this->assertEquals('<a href="?id=secondPage" class="internal" >?id=secondPage</a>', $result); + + $result = $link->renderLink('t:Example|r:0'); + $this->assertEquals('', $result); + + $result = $link->renderLink('p:secondPage|t:Example|r:0'); + $this->assertEquals('<a href="?id=secondPage" class="internal" >Example</a>', $result); + + // r: 1 + $result = $link->renderLink('p|r:1'); + $this->assertEquals('<a href="?id=firstPage" class="internal" >?id=firstPage</a>', $result); + + $result = $link->renderLink('p:secondPage|r:1'); + $this->assertEquals('<a href="?id=secondPage" class="internal" >?id=secondPage</a>', $result); + + $result = $link->renderLink('t:Example|r:1'); + $this->assertEquals('<span >Example</span>', $result); + + $result = $link->renderLink('p:secondPage|t:Example|r:1'); + $this->assertEquals('<a href="?id=secondPage" class="internal" >Example</a>', $result); + + // r: 2 + $result = $link->renderLink('p|r:2'); + $this->assertEquals('', $result); + + $result = $link->renderLink('p:secondPage|r:2'); + $this->assertEquals('', $result); + + $result = $link->renderLink('t:Example|r:2'); + $this->assertEquals('', $result); + + $result = $link->renderLink('p:secondPage|t:Example|r:2'); + $this->assertEquals('<a href="?id=secondPage" class="internal" >Example</a>', $result); + + // r: 3 + $result = $link->renderLink('p|r:3'); + $this->assertEquals('<span >?id=firstPage</span>', $result); + + $result = $link->renderLink('p:secondPage|r:3'); + $this->assertEquals('<span >?id=secondPage</span>', $result); + + $result = $link->renderLink('t:Example|r:3'); + $this->assertEquals('<span >Example</span>', $result); + + $result = $link->renderLink('p:secondPage|t:Example|r:3'); + $this->assertEquals('<span >Example</span>', $result); + + // r: 4 + $result = $link->renderLink('p|r:4'); + $this->assertEquals('<span >?id=firstPage</span>', $result); + + $result = $link->renderLink('p:secondPage|r:4'); + $this->assertEquals('<span >?id=secondPage</span>', $result); + + $result = $link->renderLink('t:Example|r:4'); + $this->assertEquals('<span >Example</span>', $result); + + $result = $link->renderLink('p:secondPage|t:Example|r:4'); + $this->assertEquals('<span >?id=secondPage</span>', $result); + + // r: 5 + $result = $link->renderLink('p|r:5'); + $this->assertEquals('', $result); + + $result = $link->renderLink('p:secondPage|r:5'); + $this->assertEquals('', $result); + + $result = $link->renderLink('t:Example|r:5'); + $this->assertEquals('', $result); + + $result = $link->renderLink('p:secondPage|t:Example|r:5'); + $this->assertEquals('', $result); + } + + public function testRenderModeMail() { + $link = new Link(null, $this->sip, true); + + // r: default (0) + $result = $link->renderLink('u'); + $this->assertEquals('', $result); + + $result = $link->renderLink('m:john@doe.com'); + $this->assertEquals('<a href="mailto:john@doe.com" class="external" >mailto:john@doe.com</a>', $result); + + $result = $link->renderLink('t:Example'); + $this->assertEquals('', $result); + + $result = $link->renderLink('m:john@doe.com|t:Example'); + $this->assertEquals('<a href="mailto:john@doe.com" class="external" >Example</a>', $result); + + // r: 0 + $result = $link->renderLink('u|r:0'); + $this->assertEquals('', $result); + + $result = $link->renderLink('m:john@doe.com|r:0'); + $this->assertEquals('<a href="mailto:john@doe.com" class="external" >mailto:john@doe.com</a>', $result); + + $result = $link->renderLink('t:Example|r:0'); + $this->assertEquals('', $result); + + $result = $link->renderLink('m:john@doe.com|t:Example|r:0'); + $this->assertEquals('<a href="mailto:john@doe.com" class="external" >Example</a>', $result); + + // r: 1 + $result = $link->renderLink('u|r:1'); + $this->assertEquals('', $result); + + $result = $link->renderLink('m:john@doe.com|r:1'); + $this->assertEquals('<a href="mailto:john@doe.com" class="external" >mailto:john@doe.com</a>', $result); + + $result = $link->renderLink('t:Example|r:1'); + $this->assertEquals('<span >Example</span>', $result); + + $result = $link->renderLink('m:john@doe.com|t:Example|r:1'); + $this->assertEquals('<a href="mailto:john@doe.com" class="external" >Example</a>', $result); + + // r: 2 + $result = $link->renderLink('u|r:2'); + $this->assertEquals('', $result); + + $result = $link->renderLink('m:john@doe.com|r:2'); + $this->assertEquals('', $result); + + $result = $link->renderLink('t:Example|r:2'); + $this->assertEquals('', $result); + + $result = $link->renderLink('m:john@doe.com|t:Example|r:2'); + $this->assertEquals('<a href="mailto:john@doe.com" class="external" >Example</a>', $result); + + // r: 3 + $result = $link->renderLink('u|r:3'); + $this->assertEquals('', $result); + + $result = $link->renderLink('m:john@doe.com|r:3'); + $this->assertEquals('<span >mailto:john@doe.com</span>', $result); + + $result = $link->renderLink('t:Example|r:3'); + $this->assertEquals('<span >Example</span>', $result); + + $result = $link->renderLink('m:john@doe.com|t:Example|r:3'); + $this->assertEquals('<span >Example</span>', $result); + + // r: 4 + $result = $link->renderLink('u|r:4'); + $this->assertEquals('', $result); + + $result = $link->renderLink('m:john@doe.com|r:4'); + $this->assertEquals('<span >mailto:john@doe.com</span>', $result); + + $result = $link->renderLink('t:Example|r:4'); + $this->assertEquals('<span >Example</span>', $result); + + $result = $link->renderLink('m:john@doe.com|t:Example|r:4'); + $this->assertEquals('<span >mailto:john@doe.com</span>', $result); + + // r: 5 + $result = $link->renderLink('u|r:5'); + $this->assertEquals('', $result); + + $result = $link->renderLink('m:john@doe.com|r:5'); + $this->assertEquals('', $result); + + $result = $link->renderLink('t:Example|r:5'); + $this->assertEquals('', $result); + + $result = $link->renderLink('m:john@doe.com|t:Example|r:5'); + $this->assertEquals('', $result); + } + + public function testRenderModeUrlPicture() { + $link = new Link(null, $this->sip, true); + + // r: default (0) + $result = $link->renderLink('u|P:picture.gif'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|P:picture.gif'); + $this->assertEquals('<a href="http://example.com" class="external" ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > </a>', $result); + + $result = $link->renderLink('t:Example|P:picture.gif'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|t:Example|P:picture.gif'); + $this->assertEquals('<a href="http://example.com" class="external" ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > Example</a>', $result); + + // r: 0 + $result = $link->renderLink('u|r:0|P:picture.gif'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|r:0|P:picture.gif'); + $this->assertEquals('<a href="http://example.com" class="external" ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > </a>', $result); + + $result = $link->renderLink('t:Example|r:0|P:picture.gif'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|t:Example|r:0|P:picture.gif'); + $this->assertEquals('<a href="http://example.com" class="external" ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > Example</a>', $result); + + // r: 1 + $result = $link->renderLink('u|r:1|P:picture.gif'); + $this->assertEquals('<span ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > </span>', $result); + + $result = $link->renderLink('u:http://example.com|r:1|P:picture.gif'); + $this->assertEquals('<a href="http://example.com" class="external" ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > </a>', $result); + + $result = $link->renderLink('t:Example|r:1|P:picture.gif'); + $this->assertEquals('<span ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > Example</span>', $result); + + $result = $link->renderLink('u:http://example.com|t:Example|r:1|P:picture.gif'); + $this->assertEquals('<a href="http://example.com" class="external" ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > Example</a>', $result); + + // r: 2 + $result = $link->renderLink('u|r:2|P:picture.gif'); + $this->assertEquals('', $result); + + //TODO: no link if text is empty - image is linked here: this is not what the user expects. + $result = $link->renderLink('u:http://example.com|r:2|P:picture.gif'); + $this->assertEquals('<a href="http://example.com" class="external" ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > </a>', $result); + + $result = $link->renderLink('t:Example|r:2|P:picture.gif'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|t:Example|r:2|P:picture.gif'); + $this->assertEquals('<a href="http://example.com" class="external" ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > Example</a>', $result); + + // r: 3: + $result = $link->renderLink('u|r:3|P:picture.gif'); + $this->assertEquals('<span ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > </span>', $result); + + $result = $link->renderLink('u:http://example.com|r:3|P:picture.gif'); + $this->assertEquals('<span ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > </span>', $result); + + $result = $link->renderLink('t:Example|r:3|P:picture.gif'); + $this->assertEquals('<span ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > Example</span>', $result); + + $result = $link->renderLink('u:http://example.com|t:Example|r:3|P:picture.gif'); + $this->assertEquals('<span ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > Example</span>', $result); + + // r: 4 + $result = $link->renderLink('u|r:4|P:picture.gif'); + $this->assertEquals('<span ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > </span>', $result); + + $result = $link->renderLink('u:http://example.com|r:4|P:picture.gif'); + $this->assertEquals('<span >http://example.com</span>', $result); + + $result = $link->renderLink('t:Example|r:4|P:picture.gif'); + $this->assertEquals('<span ><img alt="Grafic: picture.gif" src="picture.gif" title="picture.gif" > Example</span>', $result); + + $result = $link->renderLink('u:http://example.com|t:Example|r:4|P:picture.gif'); + $this->assertEquals('<span >http://example.com</span>', $result); + + // r: 5 + $result = $link->renderLink('u|r:5|P:picture.gif'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|r:5|P:picture.gif'); + $this->assertEquals('', $result); + + $result = $link->renderLink('t:Example|r:5|P:picture.gif'); + $this->assertEquals('', $result); + + $result = $link->renderLink('u:http://example.com|t:Example|r:5|P:picture.gif'); + $this->assertEquals('', $result); + } + + + + + public function testLinkClass() { + } + + protected function setUp() { + parent::setUp(); + + $this->store = Store::getInstance('', true); + $this->sip = new Sip('fakesessionname', true); + $this->sip->sipUniqId('badcaffee1234'); + + } +} diff --git a/extension/qfq/tests/phpunit/QuickFormQueryTest.php b/extension/qfq/tests/phpunit/QuickFormQueryTest.php index 48df481783b1903e66f0ecd93dfd13361933cafb..1914a2b717903388994dc430e9f214d20b7ff2a5 100644 --- a/extension/qfq/tests/phpunit/QuickFormQueryTest.php +++ b/extension/qfq/tests/phpunit/QuickFormQueryTest.php @@ -18,7 +18,7 @@ class QuickFormQueryTest extends \PHPUnit_Framework_TestCase { public function testProcess() { - $form = new qfq\QuickFormQuery(['bodytext' => "\n; some comment\n" . TYPO3_FORM . "=testformnameDoNotChange\n" . TYPO3_DEBUG_SAVE . "=6\n" . TYPO3_DEBUG_LOAD . "=7\n"]); + $form = new qfq\QuickFormQuery(['bodytext' => "\n; some comment\n" . TYPO3_FORM . "=testformnameDoNotChange\n"]); // $this->assertEquals("", $form->process()); } diff --git a/extension/qfq/tests/phpunit/SanitizeTest.php b/extension/qfq/tests/phpunit/SanitizeTest.php index 154dc334e3487012eba19c5b15dc7bbda238b017..1ce2343bd97683349dbadd6cba0e7f1159278a20 100644 --- a/extension/qfq/tests/phpunit/SanitizeTest.php +++ b/extension/qfq/tests/phpunit/SanitizeTest.php @@ -149,7 +149,7 @@ class SanitizeTest extends \PHPUnit_Framework_TestCase { $this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails"); $val = 'jo%hn@doe.com'; - $this->assertEquals('', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails"); + $this->assertEquals('jo%hn@doe.com', Sanitize::sanitize($val, SANITIZE_ALLOW_EMAIL), "SANITIZE_ALLOW_EMAIL fails"); } public function testSanitizePattern() { @@ -172,35 +172,35 @@ class SanitizeTest extends \PHPUnit_Framework_TestCase { } /** - * @expectedException \qfq\UserException + * @expectedException \qfq\UserFormException */ public function testSanitizeExceptionMinMaxMissing() { Sanitize::sanitize(56, SANITIZE_ALLOW_MIN_MAX); } /** - * @expectedException \qfq\UserException + * @expectedException \qfq\UserFormException */ public function testSanitizeExceptionMinMaxMissingMin() { Sanitize::sanitize(56, SANITIZE_ALLOW_MIN_MAX, '|45'); } /** - * @expectedException \qfq\UserException + * @expectedException \qfq\UserFormException */ public function testSanitizeExceptionMinMaxMissingMax() { Sanitize::sanitize(56, SANITIZE_ALLOW_MIN_MAX, '45|'); } /** - * @expectedException \qfq\UserException + * @expectedException \qfq\UserFormException */ public function testSanitizeExceptionMinMaxDateMissing() { Sanitize::sanitize(56, SANITIZE_ALLOW_MIN_MAX); } /** - * @expectedException \qfq\UserException + * @expectedException \qfq\UserFormException */ public function testSanitizeExceptionCheckFailed() { Sanitize::sanitize('string', SANITIZE_ALLOW_DIGIT, '', SANATIZE_EXCEPTION); diff --git a/extension/qfq/tests/phpunit/SipTest.php b/extension/qfq/tests/phpunit/SipTest.php index b072f1cc2ffaf82b7ec4bf7bad90d352df97bdf9..530d1c09d735ee28b4ccfaea921bde434773224b 100644 --- a/extension/qfq/tests/phpunit/SipTest.php +++ b/extension/qfq/tests/phpunit/SipTest.php @@ -5,7 +5,7 @@ namespace qfq; //use qfq\Sip; require_once(__DIR__ . '/../../qfq/Constants.php'); -require_once(__DIR__ . '/../../qfq/QuickFormQuery.php'); +//require_once(__DIR__ . '/../../qfq/QuickFormQuery.php'); require_once(__DIR__ . '/../../qfq/store/Sip.php'); /** diff --git a/extension/qfq/tests/phpunit/StoreTest.php b/extension/qfq/tests/phpunit/StoreTest.php index 4f6927866fa71d9563eec2c37f1f07720b9a40a9..072fe85ec04dcd7998abff18903a4548dc6c7b8c 100644 --- a/extension/qfq/tests/phpunit/StoreTest.php +++ b/extension/qfq/tests/phpunit/StoreTest.php @@ -37,7 +37,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase { $_GET['key04'] = '4567'; $_POST['key04'] = '5678'; - $this->store = Store::getInstance("\n; some comment\n" . TYPO3_FORM . "=testformnameDoNotChange\n" . TYPO3_DEBUG_SAVE . "=6\n" . TYPO3_DEBUG_LOAD . "=7\n", true); + $this->store = Store::getInstance("\n; some comment\n" . TYPO3_FORM . "=testformnameDoNotChange\n", true); } @@ -55,14 +55,6 @@ class StoreTest extends \PHPUnit_Framework_TestCase { $this->store->setVar(TYPO3_FORM, "testformnameDoNotChange", STORE_TYPO3); $this->assertEquals('testformnameDoNotChange', $this->store->getVar(TYPO3_FORM, STORE_TYPO3), "System: " . TYPO3_FORM); - // T3 Bodytext - $this->store->setVar(TYPO3_DEBUG_SAVE, "6", STORE_TYPO3); - $this->assertEquals('6', $this->store->getVar(TYPO3_DEBUG_SAVE, STORE_TYPO3), "System: " . TYPO3_DEBUG_SAVE); - - // T3 Bodytext - $this->store->setVar(TYPO3_DEBUG_LOAD, "7", STORE_TYPO3); - $this->assertEquals('7', $this->store->getVar(TYPO3_DEBUG_LOAD, STORE_TYPO3), "System: " . TYPO3_DEBUG_LOAD); - } public function testGetVarStoreSystem() { @@ -180,7 +172,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase { } /** - * @expectedException \qfq\UserException + * @expectedException \qfq\UserFormException * */ public function testGetStore() { diff --git a/t3/qfq.php b/t3/qfq.php index 1f84ef2fc49339aeda0971f0df06c7056cc1fc50..db5e087893aecac5bfddc9e0e420e8a1048cb88c 100644 --- a/t3/qfq.php +++ b/t3/qfq.php @@ -36,7 +36,7 @@ function renderForm($bodytext = "") { echo "test"; - } catch (UserException $e) { + } catch (UserFormException $e) { echo $e->formatMessage(); } catch (CodeException $e) { echo $e->formatMessage();