Commit 6b4ce59f authored by Marc Egger's avatar Marc Egger

ColumnScript.php: change parameter names src => F, f => c

parent 1dd08a42
Pipeline #3830 passed with stages
in 6 minutes and 52 seconds
......@@ -1412,20 +1412,20 @@ Run a php function defined in an external script.
* The second argument (here called $qfq) is an object which acts as an interface to QFQ functionality.
* The script has access to the following qfq functions using this interface:
* $qfq::apiCall($method, $url, $data = '', $header = [], $timeout = 5)
* string $method can be PUT/POST/GET/DELETE
* string $method: can be PUT/POST/GET/DELETE
* string $url
* array $data a json string which will be added as GET parameters or as POST fields respectively.
* array $header is of the form ['Content-type: text/plain', 'Content-length: 100']
* int $timeout is the number of seconds to wait until call is aborted.
* string $data: a json string which will be added as GET parameters or as POST fields respectively.
* array $header: is of the form ['Content-type: text/plain', 'Content-length: 100']
* int $timeout: is the number of seconds to wait until call is aborted.
* $qfq::getVar($key, $useStores = 'FSRVD', $sanitizeClass = '', &$foundInStore = '', $typeMessageViolate = 'c')
* string $key is the name of qfq variable
* string $useStores are the stores in which variable is searched (in order from left to right). see :ref:`store`.
* string $sanitizeClass (see :ref:`sanitize-class`)
* string $foundInStore is filled with the name of the store in which the variable was found.
* string $typeMessageViolate defines what to return if the sanitize class was violated:
* 'c': return '!!<sanitize class>!!'
* '0': return '0'
* 'e': return ''
* string $key: is the name of qfq variable
* string $useStores: are the stores in which variable is searched (in order from left to right). see :ref:`store`.
* string $sanitizeClass: (see :ref:`sanitize-class`)
* string $foundInStore: is filled with the name of the store in which the variable was found.
* string $typeMessageViolate: defines what to return if the sanitize class was violated:
* 'c' : returns '!!<sanitize class>!!'
* '0' : returns '0'
* 'e' : returns ''
* The current working directory is the current web instance (e.g. ``/var/www/html``) .
* All output (e.g. using echo) will be returned by the special column as is.
* If the function returns an associative array, then the key-value pairs will be accessible via the Client store.
......@@ -1436,11 +1436,11 @@ Run a php function defined in an external script.
+-------------------+----------------------------------------------------+------------------------------------------------------------------+
| Token | Example | Comment |
+===================+====================================================+==================================================================+
| scr | scr:fileadmin/scripts/my_script.php | Path to the custom script relative to the current web instance |
| F | F:fileadmin/scripts/my_script.php | Path to the custom script relative to the current web instance |
+-------------------+----------------------------------------------------+------------------------------------------------------------------+
| f | f:my_function | Function name |
| c | c:my_function | PHP function to call |
+-------------------+----------------------------------------------------+------------------------------------------------------------------+
| <whatever> | myParameter:something | All parameters are passed on in an associative array |
| <whatever> | myParameter:something | all parameters are passed on as an array to the function |
+-------------------+----------------------------------------------------+------------------------------------------------------------------+
**Example**
......@@ -1467,13 +1467,13 @@ Run a php function defined in an external script.
* QFQ report ::
5.sql = SELECT "IAmInRecordStore" AS _savedInRecordStore
10.sql = SELECT "scr:fileadmin/scripts/my_script.php|f:my_function|a1:Hello|a2:World" AS _script
10.sql = SELECT "F:fileadmin/scripts/my_script.php|c:my_function|a1:Hello|a2:World" AS _script
20.sql = SELECT "<br><br>Returened value: {{IAmInClientStore:C:alnumx}}"
* Output ::
The first argument contains all attributes including "src" and "f":
Array ( [scr] => fileadmin/scripts/my_script.php [f] => my_function [a1] => Hello [a2] => World )
Array ( [F] => fileadmin/scripts/my_script.php [c] => my_function [a1] => Hello [a2] => World )
get variable from record store:
IAmInRecordStore
......
......@@ -1763,7 +1763,7 @@ const TOKEN_COPY_TO_CLIPBOARD = 'y';
const TOKEN_DROPDOWN = 'z';
const TOKEN_WEBSOCKET = 'w';
const TOKEN_REST_CLIENT = 'n';
const TOKEN_SCRIPT = 'scr';
const TOKEN_SCRIPT = 'F';
const TOKEN_TEXT = 't';
const TOKEN_ALT_TEXT = 'a';
......@@ -1791,7 +1791,7 @@ const TOKEN_FILE = 'F';
const TOKEN_FILE_DEPRECATED = 'f'; // since 5.12.17
const TOKEN_DOWNLOAD_MODE = 'M';
const TOKEN_ATTRIBUTE = 'A';
const TOKEN_FUNCTION = 'f';
const TOKEN_FUNCTION_CALL = 'c';
const TOKEN_THUMBNAIL = 'T';
const TOKEN_THUMBNAIL_DIMENSION = 'W';
......
......@@ -25,7 +25,7 @@ class ColumnScript {
if (empty($param[TOKEN_SCRIPT])) {
throw new \UserReportException("Missing script path.", ERROR_MISSING_VALUE);
}
if (empty($param[TOKEN_FUNCTION])) {
if (empty($param[TOKEN_FUNCTION_CALL])) {
throw new \UserReportException("Missing function name.", ERROR_MISSING_VALUE);
}
......@@ -46,18 +46,18 @@ class ColumnScript {
}
// execute function, write output to buffer
if (!function_exists($param[TOKEN_FUNCTION])) {
if (!function_exists($param[TOKEN_FUNCTION_CALL])) {
throw new \UserReportException("Function doesn't exist.", ERROR_IO_READ_FILE);
}
ob_start();
try {
$return = call_user_func_array($param[TOKEN_FUNCTION], [$param, new ScriptFunctions()]);
$return = call_user_func_array($param[TOKEN_FUNCTION_CALL], [$param, new ScriptFunctions()]);
$output = ob_get_clean();
} catch (\Exception | \Error $e) {
ob_end_clean();
throw new \UserReportException(json_encode([
ERROR_MESSAGE_TO_USER => 'Function execution failed.',
ERROR_MESSAGE_TO_DEVELOPER => "Error message:\n" . $e->getMessage() . "\n\nFunction: " . $param[TOKEN_FUNCTION] . "\n\nParameters:\n" . print_r($param,true)]));
ERROR_MESSAGE_TO_DEVELOPER => "Error message:\n" . $e->getMessage() . "\n\nFunction: " . $param[TOKEN_FUNCTION_CALL] . "\n\nParameters:\n" . print_r($param,true)]));
}
// return buffer output and fill store
......
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