Commit eecfb808 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Report, Variables, Link, Documentation: Variable token '~' replaced by '{{ / }}'

parent 40259a20
......@@ -11,6 +11,21 @@
Administrator Manual
====================
Preparation
-----------
The QFQ extension needs the PHP MySQL native driver. The following functions are used and are only available with the
native driver (see also: http://dev.mysql.com/downloads/connector/php-mysqlnd/):
* mysqli::get_result (important),
* mysqli::fetch_all (nice to use)
Installation for Ubuntu::
sudo apt-get install php5-mysqlnd
sudo php5enmod mysqlnd
sudo service apache2 restart
Setup
-----
......@@ -56,42 +71,45 @@ Setup a *report* to manage all *forms*: Create a Typo3 page and insert a content
<ext_dir>/config.ini
--------------------
+------------------------+--------------+----------------------------------------------------------------------------+
| Keyword | Example | Description |
+========================+==============+============================================================================+
| DBUSER | qfqUser | Credentials configured in MySQL |
+------------------------+--------------+----------------------------------------------------------------------------+
| DBPW | 12345678 | Credentials configured in MySQL |
+------------------------+--------------+----------------------------------------------------------------------------+
| DBSERVER | localhost | Hostname of MySQL Server |
+------------------------+--------------+----------------------------------------------------------------------------+
| DB | qfq_db | Database name |
+------------------------+--------------+----------------------------------------------------------------------------+
| TESTDB | qfq_db_test | Used during development of QFQ |
+------------------------+--------------+----------------------------------------------------------------------------+
| SESSIONNAME | qfq | By default 'qfq' |
+------------------------+--------------+----------------------------------------------------------------------------+
| SQLLOG | sql.log | filename to log all SQL commands |
+------------------------+--------------+----------------------------------------------------------------------------+
| SHOW_DEBUG_INFO | auto | Possible values: auto|yes|no. For 'auto': If a BE User is logged in, |
| | | debug information will be shown on the fronend. |
+------------------------+--------------+----------------------------------------------------------------------------+
| CSS_LINK_CLASS_INTERNAL| internal | CSS class name of links which points to internal tagets |
+------------------------+--------------+----------------------------------------------------------------------------+
| CSS_LINK_CLASS_EXTERNAL| external | CSS class name of links which points to internal tagets |
+------------------------+--------------+----------------------------------------------------------------------------+
+------------------------+----------------------------------+----------------------------------------------------------------------------+
| Keyword | Example | Description |
+========================+==================================+============================================================================+
| DB_USER | DB_USER=qfqUser | Credentials configured in MySQL |
+------------------------+----------------------------------+----------------------------------------------------------------------------+
| DB_PASSWORD | DB_PASSWORD=12345678 | Credentials configured in MySQL |
+------------------------+----------------------------------+----------------------------------------------------------------------------+
| DB_SERVER | DB_SERVER=localhost | Hostname of MySQL Server |
+------------------------+----------------------------------+----------------------------------------------------------------------------+
| DB_NAME | DB_NAME=qfq_db | Database name |
+------------------------+----------------------------------+----------------------------------------------------------------------------+
| DB_NAME_TEST | DB_NAME_TEST=qfq_db_test | Used during development of QFQ |
+------------------------+----------------------------------+----------------------------------------------------------------------------+
| SESSION_NAME | SESSION_NAME=qfq | PHP Session name, by default 'qfq' |
+------------------------+----------------------------------+----------------------------------------------------------------------------+
| SQL_LOG | SQL_LOG=sql.log | Filename to log SQL commands: relative to <ext_dir> or absolute. |
+------------------------+----------------------------------+----------------------------------------------------------------------------+
| SQL_LOG_MODE | SQL_LOG_MODE=modify | *all*: every statement will be logged - this is a lot |
| | | *modify*: log only statements who change data |
+------------------------+----------------------------------+----------------------------------------------------------------------------+
| SHOW_DEBUG_INFO | SHOW_DEBUG_INFO=auto | Possible values: auto|yes|no. For 'auto': If a BE User is logged in, |
| | | debug information will be shown on the fronend. |
+------------------------+----------------------------------+----------------------------------------------------------------------------+
| CSS_LINK_CLASS_INTERNAL| CSS_LINK_CLASS_INTERNAL=internal | CSS class name of links which points to internal tagets |
+------------------------+----------------------------------+----------------------------------------------------------------------------+
| CSS_LINK_CLASS_EXTERNAL| CSS_LINK_CLASS_EXTERNAL=external | CSS class name of links which points to internal tagets |
+------------------------+----------------------------------+----------------------------------------------------------------------------+
Example: *<ext_dir>/config.ini*
::
DBUSER = qfqUser
DBSERVER = localhost
DBPW = 12345678
DB = qfq_db
TESTDB = qfq_db_test
SESSIONNAME = qfq
SQLLOG = sql.log
DB_USER = qfqUser
DB_SERVER = localhost
DB_PASSWORD = 12345678
DB_NAME = qfq_db
DB_NAME_TEST = qfq_db_test
SESSION_NAME = qfq
SQL_LOG = sql.log
SHOW_DEBUG_INFO = auto
CSS_LINK_CLASS_INTERNAL = internal
CSS_LINK_CLASS_EXT = external
\ No newline at end of file
......@@ -10,5 +10,5 @@ $EM_CONF[$_EXTKEY] = array(
'dependencies' => 'fluid,extbase',
'clearcacheonload' => true,
'state' => 'alpha',
'version' => '0.1.1'
'version' => '0.1.2'
);
\ No newline at end of file
......@@ -194,7 +194,7 @@ class Link {
$this->parseItem($arr[0], $arr[1]);
}
// if there is no url or mailto definition: ~global.pageId
// 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);
$this->doCssClass();
......
......@@ -430,10 +430,10 @@ class Report {
// record number counter
$this->variables->resultArray[$full_level . ".line."]["count"] = ++$rowIndex;
// replace ~<level>.line.count and ~<level>.line.total in __result__, if the variables specify their own full_level. This can't be replaced before firing the query.
// replace {{<level>.line.count}} and {{<level>.line.total}} in __result__, if the variables specify their own full_level. This can't be replaced before firing the query.
for ($ii = 0; $ii < count($row); $ii++) {
$row[$ii] = str_replace("~" . $full_level . ".line.count", $rowIndex, $row[$ii]);
$row[$ii] = str_replace("~" . $full_level . ".line.total", $rowTotal, $row[$ii]);
$row[$ii] = str_replace("{{" . $full_level . ".line.count}}", $rowIndex, $row[$ii]);
$row[$ii] = str_replace("{{" . $full_level . ".line.total}}", $rowTotal, $row[$ii]);
}
// Create Assoc Array of result
......
......@@ -44,13 +44,14 @@ class Variables {
}
/**
* Matches on the variables ~1.2name and substitutes them with the values
* Matches on the variables {{10.20.name}} and substitutes them with the values
*
* @param string $text
* @return mixed
*/
public function doVariables($text) {
$str = preg_replace_callback("/(~([a-zA-Z0-9._])*)/", array($this, 'replaceVariables'), $text);
// $str = preg_replace_callback("/(~([a-zA-Z0-9._])*)/", array($this, 'replaceVariables'), $text);
$str = preg_replace_callback("/{{(([a-zA-Z0-9._])*)}}/", array($this, 'replaceVariables'), $text);
return $str;
}
......@@ -65,15 +66,20 @@ class Variables {
*/
public function replaceVariables($matches) {
// variablename: ~10.20.column
$sqlVariable = $matches[1];
// $matches[0]: {{variablename: 10.20.<columnname>}}
// $matches[1]: variablename: 10.20.<columnname>
$data = $matches[0];
// index of last '.'
$pos = strrpos($sqlVariable, ".");
$pos = strrpos($matches[1], ".");
$replace = $this->resultArray[substr($sqlVariable, 1, $pos)][substr($sqlVariable, $pos + 1, strlen($sqlVariable))];
$fullLevel = substr($matches[1], 0, $pos + 1);
$varName = substr($matches[1], $pos + 1, strlen($matches[1]));
return (isset($this->resultArray[substr($sqlVariable, 1, $pos)][substr($sqlVariable, $pos + 1, strlen($sqlVariable))]) ? $replace : $sqlVariable);
if (isset($this->resultArray[$fullLevel][$varName]))
$data = $this->resultArray[$fullLevel][$varName];
return $data;
}
/**
......@@ -85,6 +91,7 @@ class Variables {
public function collectGlobalVariables() {
$arr = array();
//TODO: Variablen sollten vom STORE_TYPO3 genommen werden
$arr["REMOTE_ADDR"] = $_SERVER["REMOTE_ADDR"];
$arr["HTTP_HOST"] = $_SERVER["HTTP_HOST"];
$arr["REQUEST_URI"] = $_SERVER["REQUEST_URI"];
......@@ -112,7 +119,7 @@ class Variables {
$arr["url"] .= $arr["REQUEST_URI"];
// Add all variables from ext_localconf
// database aliases can be used in form sql queries (e.g. select * from "~global.t3_name".fe_users...)
// database aliases can be used in form sql queries (e.g. select * from "{{global.t3_name}}".fe_users...)
// localconf can be used to configure an application
$tmp = array();
if (isset($GLOBALS['TYPO3_CONF_VARS']))
......
Supports Markdown
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