From 10e4a0e4a01d3d2ba9f78e038716759fca335d3c Mon Sep 17 00:00:00 2001 From: Carsten Rose <carsten.rose@math.uzh.ch> Date: Sun, 12 Nov 2017 21:37:44 +0100 Subject: [PATCH] Feature 4901 / PDF Split: Preparation - new STORE_VAR variable {{filenameBase:V}}, {{filenameExt:V}} --- extension/Documentation/Manual.rst | 6 +++++- extension/qfq/qfq/Constants.php | 2 ++ extension/qfq/qfq/Save.php | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/extension/Documentation/Manual.rst b/extension/Documentation/Manual.rst index 49abd8ab3..91db1d74e 100644 --- a/extension/Documentation/Manual.rst +++ b/extension/Documentation/Manual.rst @@ -1307,7 +1307,11 @@ Store: *VARS* - V +-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ | filename | Original filename of an uploaded file via an 'upload'-FormElement. Valid only during processing of the current 'upload'-formElement. | +-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ - | fileDestinaton | Destination (path & filename) for an uploaded file. Defined in an 'upload'-FormElement.parameter. Valid: same as 'filename'. | + | fileDestination | Destination (path & filename) for an uploaded file. Defined in an 'upload'-FormElement.parameter. Valid: same as 'filename'. | + +-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ + | filenameBase | Like 'filename', but without the extension (if there is one) | + +-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ + | filenameExt | Only the extension of 'filename' (if there is one) | +-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+ .. _STORE_LDAP: diff --git a/extension/qfq/qfq/Constants.php b/extension/qfq/qfq/Constants.php index 3b80fce8f..2beb28f3c 100644 --- a/extension/qfq/qfq/Constants.php +++ b/extension/qfq/qfq/Constants.php @@ -532,6 +532,8 @@ const VAR_RANDOM = 'random'; const VAR_FILE_DESTINATION = 'fileDestination'; const VAR_SLAVE_ID = ACTION_KEYWORD_SLAVE_ID; const VAR_FILENAME = 'filename'; // Original filename of an uploaded file. +const VAR_FILENAME_BASE = 'filenameBase'; // Original filename of an uploaded file, without the extension. +const VAR_FILENAME_EXT = 'filenameExt'; // Extension of the original filename of an uploaded file, . // PHP class Typeahead const TYPEAHEAD_API_QUERY = 'query'; // Name of parameter in API call of typeahead.php?query=...&s=... - See also FE_TYPE_AHEAD_SQL diff --git a/extension/qfq/qfq/Save.php b/extension/qfq/qfq/Save.php index 9a2e3de5b..acafc78d8 100644 --- a/extension/qfq/qfq/Save.php +++ b/extension/qfq/qfq/Save.php @@ -402,7 +402,14 @@ class Save { // Provide variable 'filename'. Might be substituted in $formElement[FE_PATH_FILE_NAME]. $origFilename = Sanitize::safeFilename($statusUpload[FILES_NAME]); + $pathParts = pathinfo($origFilename); $this->store->setVar(VAR_FILENAME, $origFilename, STORE_VAR); + if (isset($pathParts['filename'])) { + $this->store->setVar(VAR_FILENAME_BASE, $pathParts['filename'], STORE_VAR); + } + if (isset($pathParts['extension'])) { + $this->store->setVar(VAR_FILENAME_EXT, $pathParts['extension'], STORE_VAR); + } $pathFileName = $this->evaluate->parse($formElement[FE_FILE_DESTINATION]); -- GitLab