Commit 1bb4cea6 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Multiple & Advanced Upload:

- fix problem when more than one file uploaded - there was only one variable {{_filename}}, which was not sufficient for more than one upload element per form. New: {{_filename_<FE_NAME>:FE:allbut}}.
- implemented {{_deleted_<FE_NAME>:F0}}: if exist and is '1', than this means that the previous uploaded file has been trashed through the user by clicking on the trash.

Index.rst: update doc. Some more notes are needed. See one of the upcomming commits.
Constants.php: Renamed CLIENT_UPLOAD_FILENAME and created CLIENT_FILE_DELETED.
Save.php: Set var CLIENT_FILE_DELETED and use renamed CLIENT_UPLOAD_FILENAME.
parent 6bb97e4c
......@@ -249,11 +249,11 @@ Only variables that are known in a specified store can be substituted.
+-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
| V | :ref:`STORE_VARS`: Generic variables | |
+-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
| 0 | Zero - allways value: 0, might be helpful if a variable is empty or undefined and will | All possible keys |
| | be used in an SQL statement. | |
| 0 | *Zero* - allways value: 0, might be helpful if a variable is empty or undefined and | Any key |
| | will be used in an SQL statement. | |
+-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
| E | Empty - allways value: 0, might be helpful if a variable is empty or undefined and will| All possible keys |
| | be used in an SQL statement | |
| E | *Empty* - allways an empty string, might be helpful if a variable is empty or undefined| Any key |
| | and will be used in an SQL statement | |
+-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------------+
| Y | :ref:`STORE_SYSTEM`: a) Database, b) helper vars for logging/debugging: | |
| | SYSTEM_SQL_RAW ... SYSTEM_FORM_ELEMENT_COLUMN, c) Any custom fields: CONTACT, HELP, .. | |
......@@ -283,11 +283,15 @@ Store: *FORM* - F
* *FormElement* actions, before saving the form.
* Values will be sanitized by the class configured in corresponding the *FormElement*. By default, the sanitize class is `alnumx`.
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
+---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| Name | Explanation |
+=========================+============================================================================================================================================+
| FormElement name | Name of native *FormElement*. To get, exactly and only, the specified *FormElement* (for 'p_id'): *{{p_id:F}}* |
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
+=================================+============================================================================================================================================+
| <FormElement name> | Name of native *FormElement*. To get, exactly and only, the specified *FormElement* (for 'p_id'): *{{p_id:F}}* |
+---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| _<FormElement name>_filename | Original filename of uploaded file |
+---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| _<FormElement name>_deleted='1' | If there was already a file uploaded and the user has clicked the trash, than this field becomes '1' |
+---------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
.. _STORE_SIP:
......@@ -513,55 +517,55 @@ SQL Statement
Form: main
----------
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
| Name | Type | Description |
+========================+==========================================================+=========================================================================================+
+=========================+==========================================================+=========================================================================================+
|id | int, autoincrement | created by by MySQL |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|name | string | unique and speaking name of the form. Form will be identified by this name |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|title | string | Title, shown on/above the form. |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|noteInternal | textarea | Internal notes: special functionality, used variables, ... |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|tableName | string | Primay table of the form |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|permitNew | enum('sip', 'logged_in', 'logged_out', 'always', 'never')| Default: sip |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|permitEdit | enum('sip', 'logged_in', 'logged_out', 'always', 'never')| Default: sip |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|render | enum('plain','table', 'bootstrap') | Default bootstrap |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|requiredParameter | string | Name of required SIP parameter, seperated by comma. '#' as comment delimiter |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|showButton | set('new', 'delete', 'close', 'save') | Default 'new,delete,close,save'. Shown buttons in the upper right corner of the form. |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|multiMode | enum('none','horizontal','vertical') | Default 'none' |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|multiSql | text | Optional. SQL Query which selects all records to edit. |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|multiDetailForm | string | Optional. Form to open, if a record is selected to edit (double click on record line) |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|multiDetailFormParameter| string | Optional. Translated Parameter submitted to detailform (like subrecord parameter) |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|forwardMode | string: 'auto|no|page'. | |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|multiDetailFormParameter | string | Optional. Translated Parameter submitted to detailform (like subrecord parameter) |
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|forwardMode | string: 'auto | no | page' | |
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|forwardPage | string / query | If $forward=="page": page to jump to |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|bsLabelColumns | string | The bootstrap grid system is based on 12 columns. The sum of *bsLabelColumns*, |
+------------------------+----------------------------------------------------------+ *bsInputColumns* and *bsNoteColumns* should be 12. These values here are the base values|
+-------------------------+----------------------------------------------------------+ *bsInputColumns* and *bsNoteColumns* should be 12. These values here are the base values|
|bsInputColumns | string | for all *FormElements*. Exceptions per *FormElement* can be specified per *FormElement*.|
+------------------------+----------------------------------------------------------+ Default: label=3, input=6, note=3 |
+-------------------------+----------------------------------------------------------+ Default: label=3, input=6, note=3 |
|bsNoteColumns | string | |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|parameter | text | Misc additional parameters. See :ref:`form-parameter` |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|deleted | string | 'yes'|'no'. |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|modified | timestamp | updated automatically through stored procedure |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|created | datetime | set once through QFQ |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
+-------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
showButton
^^^^^^^^^^
......@@ -1204,13 +1208,13 @@ current record, either to finalize the upload or to delete a previous uploaded f
* *fileDestination*: Destination where to copy the file. A good practice is to specify a relative `fileDestination` -
such an installation (filesystem and database) are moveable.
* If `fileDestination` should contain the original filename, the variable *{{_filename}}* can be used. Example ::
* If the original filename should be part of `fileDestination`, the variable *{{_filename}}* can be used. Example ::
fileDestination={{SELECT 'fileadmin/user/pictures/', p.name, '-{{_filename}}' FROM Person AS p WHERE p.id={{r}} }}
* If a file already exist under `fileDestination`, an error message is shown and 'save' is aborted.
The user has no possibility to overwrite the already existing file. If the whole workflow is correct, this situation
should no arise.
should no arise. Check also *fileReplace* below.
* All necessary subdirectories in `fileDestination` are automatically created.
......
......@@ -251,7 +251,8 @@ const CLIENT_UPLOAD_FE_NAME = 'name';
const CLIENT_SIP_FOR_FORM = '_sipForForm';
const CLIENT_FE_NAME = '_feName';
const CLIENT_UPLOAD_FILENAME = '_filename';
const CLIENT_UPLOAD_FILENAME = '_filename_'; // will be extended by 'formElement[FE_name]'. E.g. '_filename_pathFileName1'
const CLIENT_FILE_DELETED = '_deleted_'; // will be extended by 'formElement[FE_name]'. E.g. '_deleted_pathFileName1'=0|1
// ALL $_SERVER variables: http://php.net/manual/en/reserved.variables.server.php
// The following exist and might be the most used ones.
......
......@@ -272,6 +272,7 @@ class Save {
// Delete existing old file.
if (isset($statusUpload[FILES_FLAG_DELETE]) && $statusUpload[FILES_FLAG_DELETE] == '1') {
$this->store->setVar(CLIENT_FILE_DELETED . $formElement[FE_NAME], '1', STORE_FORM);
$arr = $sip->getVarsFromSip($sipUpload);
$oldFile = $arr[EXISTING_PATH_FILE_NAME];
if (file_exists($oldFile)) {
......@@ -315,7 +316,7 @@ class Save {
// Provide variable '_filename'. Might be substituted in $formElement[FE_PATH_FILE_NAME].
$origFilename = Sanitize::safeFilename($statusUpload[FILES_NAME]);
$this->store->setVar(CLIENT_UPLOAD_FILENAME, $origFilename, STORE_FORM);
$this->store->setVar(CLIENT_UPLOAD_FILENAME . $formElement[FE_NAME], $origFilename, STORE_FORM);
$pathFileName = $this->evaluate->parse($formElement[FE_FILE_DESTINATION]);
}
......
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