Commit 0c2d11fb authored by Carsten  Rose's avatar Carsten Rose
Browse files

Documentation/UsersManual/index.rst: example for page 'person search'

Store.php, Constants.php: Var {{random:T}} implemented.
parent ba863ff6
......@@ -203,14 +203,16 @@ Only variables that are known in a specified store can be substituted.
+-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
| P | Parent record. E.g.: on multi forms the current record of the outer query | All columns of the MultiSQL Statement from the table for the current row |
+-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
| D | The *table.column* specified *default value*. | |
| D | Default values column : The *table.column* specified *default value*. | |
+-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
| M | The *table.column* specified *type* | |
| M | Column type: The *table.column* specified *type* | |
+-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
| C | Client: POST variable, if not found: GET variable | Parameter sent from the Client (=Browser). |
+-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
| T | Typo3: a) Bodytext (ttcontent record), b) Typo3 internal varibles like fe_user_uid, ...| See Typo3 tt_content record configuration |
+-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
| V | Vars - Generic variables | |
+-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
| 0 | Value: 0, might be helpful if variable is empty but used in an SQL statement, which | All possible keys |
| | might produce a SQL error otherwise if substituted with an empty string | |
+-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
......@@ -307,6 +309,14 @@ Store: *RECORD* - R
| record column name | Name of a column of the primary table (as defined in the current form). To get, exactly and only, the specified form element: *{{p_id:R}}* |
+--------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
Store: *VARS* - V
^^^^^^^^^^^^^^^^^
+--------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| Name | Explanation |
+====================+============================================================================================================================================+
| random | random string with length of 32 chars, alphanum |
+--------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
SQL
---
......@@ -772,7 +782,7 @@ Type: subrecord
* *<number>*: any 'digit only' will be treated as '''width'''.
* *width=<number>*: max. number of chars displayed per cell in the column.
* *nostrip*: by default, html tags will be stripped off the cell content before rendering. This protects the table layout. 'nostrip' deactivates the cleaning to make links, images, ... possible.
* *icon*: the cell value contains the name of an icon in *fileadmin/icons*. Empty cell values will omit an html image tag (=nothing renderd in the cell).
* *icon*: the cell value contains the name of an icon in *typo3conf/ext/qfq/Resources/Public/icons*. Empty cell values will omit an html image tag (=nothing renderd in the cell).
* *mailto*: value will be rendered as a mailto link.
* *url*: value will be rendered as a link.
* *title=<text>* or '<none of the above>': column '''title'''.
......@@ -1274,17 +1284,17 @@ Link Examples
+-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
|SELECT "p:form_person&S_person=Text|t:Person" AS link |<a class="internal" href="?form_person&S_person=Text">Person</a> |
+-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
|SELECT "p:form_person|e" AS link |<a class="internal" href="?form_person"><img alttext="Edit" src="fileadmin/typo3conf/ext/formreport/icons/edit.gif"></a> |
|SELECT "p:form_person|e" AS link |<a class="internal" href="?form_person"><img alttext="Edit" src="typo3conf/ext/qfq/Resources/Public/icons/edit.gif"></a> |
+-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
|SELECT "p:form_person|e|g:_blank" AS link |<a target="_blank" class="internal" href="?form_person"><img alttext="Edit" src="fileadmin/typo3conf/ext/formreport/icons/edit.gif"></a>|
|SELECT "p:form_person|e|g:_blank" AS link |<a target="_blank" class="internal" href="?form_person"><img alttext="Edit" src="typo3conf/ext/qfq/Resources/Public/icons/edit.gif"></a>|
+-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
|SELECT "p:form_person|C" AS link |<a class="internal" href="?form_person"><img alttext="Check" src="fileadmin/typo3conf/ext/formreport/icons/checked-green.gif"></a> |
|SELECT "p:form_person|C" AS link |<a class="internal" href="?form_person"><img alttext="Check" src="typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif"></a> |
+-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
|SELECT "p:form_person|C:green" AS link |<a class="internal" href="?form_person"><img alttext="Check" src="fileadmin/typo3conf/ext/formreport/icons/checked-green.gif"></a> |
|SELECT "p:form_person|C:green" AS link |<a class="internal" href="?form_person"><img alttext="Check" src="typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif"></a> |
+-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
|SELECT "A:p:form_person|G:C" AS link |<a class="internal" href="?form_person"><img alttext="Check" src="fileadmin/typo3conf/ext/formreport/icons/checked-green.gif"></a> |
|SELECT "A:p:form_person|G:C" AS link |<a class="internal" href="?form_person"><img alttext="Check" src="typo3conf/ext/qfq/Resources/Public/icons/checked-green.gif"></a> |
+-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
|SELECT "A:u:www.example.com|G:P:home.gif|t:Home" AS link |<a class="internal" href="?form_person"><img alttext="Check" src="ffileadmin/typo3conf/ext/formreport/icons/home.gif">Home</a> |
|SELECT "A:u:www.example.com|G:P:home.gif|t:Home" AS link |<a class="internal" href="?form_person"><img alttext="Check" src="typo3conf/ext/qfq/Resources/Public/icons/home.gif">Home</a> |
+-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
......@@ -1505,7 +1515,7 @@ Send simple plain text emails. Every mail will be logged in the mail log. The lo
::
10.sql = SELECT "john.doe@example.com|company@example.com|Latest News|The new version of FormReport is now available." AS sendmail
10.sql = SELECT "john.doe@example.com|company@example.com|Latest News|The new version is now available." AS sendmail
..
......@@ -1518,7 +1528,7 @@ This will send an email with subject *Latest News* from company@example.com to j
::
10.sql = SELECT "customer1@example.com, customer2@example.com|company@example.com|Latest News|The new version of FormReport is now available." AS sendmail
10.sql = SELECT "customer1@example.com, customer2@example.com|company@example.com|Latest News|The new version is now available." AS sendmail
..
......@@ -2150,4 +2160,24 @@ If *SHOW_DEBUG_INFO* is enabled, a full stacktrace and variable contents are dis
Person search form
------------------
QFQ content record
\ No newline at end of file
QFQ content record::
# Creates a small form that redirects back to this page
10 {
sql = SELECT '_'
head = <form action='{{pageId:T}}'>Search for person by name: <input type='text' name='search' vaue='{{search:C0:all}}'><input type='submit' value='Search'></form>
}
# SQL statement will find and list all the relevant persons
20 {
sql = SELECT CONCAT('persondetail&form=person&r=', p.id) AS Pagee, CONCAT(p.lastName, ', ', p.firstName)
FROM person AS p WHERE CONCAT(p.lastName, ', ', p.firstName, ' ' , p.lastName) LIKE '%{{search:C0:all}}%'
head = <table>
tail = </table>
rbeg = <tr>
rend = </tr>
fbeg = <td>
fend = </td>
}
......@@ -171,6 +171,7 @@ const STORE_TABLE_DEFAULT = "D"; // definition of primary table.
const STORE_TABLE_COLUMN_TYPES = "M"; // column types of primary table.
const STORE_CLIENT = "C"; // Client: POST variable, if not found: GET variable
const STORE_TYPO3 = "T"; // Typo3 > Page content record > bodytext
const STORE_VAR = "V"; // Generic Vars
const STORE_ZERO = "0"; // value: 0, might helpfull if variable is empty but used in an SQL statement, which might produce a SQL error otherwise if substituted with an empty string
const STORE_SYSTEM = "Y"; // various system values like db connection credentials
......@@ -261,6 +262,12 @@ const SIP_TABLE = 'table'; // delete a record from 'table'
const SIP_URLPARAM = 'urlparam';
// FURTHER: all extracted params from 'urlparam
const VAR_RANDOM = 'random';
const RANDOM_LENGTH = 32;
// FORM - copy from table 'form' of processed form
//const DEF_FORM_NAME = CLIENT_FORM;
......
......@@ -314,16 +314,24 @@ class Store {
$useStores = substr($useStores, 1); // shift left remaining stores
if (!isset(self::$raw[$store][$key])) {
if ($store === STORE_ZERO) {
return 0;
} else {
continue; // no value provided
switch ($store) {
case STORE_ZERO:
return 0;
case STORE_VAR:
if ($key === VAR_RANDOM) {
return self::randomAlphaNum(RANDOM_LENGTH);
} else {
continue 2; // no value provided, continue with while loop
}
break;
default:
continue 2; // no value provided, continue with while loop
break;
}
}
$rawVal = isset(self::$raw[$store][$key]) ? self::$raw[$store][$key] : null;
if (self::$sanitizeStore[$store] && $sanitizeClass != '') {
// return \qfq\Sanitize::sanitize($rawVal, $sanitizeClass);
if ($sanitizeClass == SANITIZE_ALLOW_PATTERN || $sanitizeClass == SANITIZE_ALLOW_MIN_MAX || $sanitizeClass == SANITIZE_ALLOW_MIN_MAX_DATE) {
// We do not have any pattern or min|max values at this point. For those who be affected, they already checked earlier. So set 'no check'
$sanitizeClass = SANITIZE_ALLOW_ALL;
......@@ -337,6 +345,22 @@ class Store {
return false;
}
/**
* Creates a random string, with lenght of $length
*
* @param $length
* @return string
*/
private static function randomAlphaNum($length) {
//srand(date("s")); seit PHP 4.2.0 nicht mehr noetig und war auch falsch falls mehrere Aufrufe in gleicher Sekunde
$possible_charactors = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$string = "";
while (strlen($string) < $length) {
$string .= substr($possible_charactors, rand() % (strlen($possible_charactors)), 1);
}
return ($string);
}
/**
* @param string $bodytext
* @param bool|false $phpUnit
......@@ -391,8 +415,7 @@ class Store {
* @param $formName
* @throws CodeException
*/
public
static function createSipAfterFormLoad($formName) {
public static function createSipAfterFormLoad($formName) {
$recordId = self::getVar(CLIENT_RECORD_ID, STORE_TYPO3 . STORE_CLIENT);
if ($recordId === false) {
$recordId = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment