Extension:External Data/Local files/de

You can get data from a file on the server on which the wiki resides, using the parser function #get_file_data. This parser function is called in a similar manner to #get_web_data - the set of allowed formats is the same, as are most of the other parameters. Unlike with #get_web_data, however, you cannot retrieve the data from any file; rather, the set of allowed files, and/or directories, must be set beforehand in LocalSettings.php, with an alias for each one, so that the actual file paths remain private.

Verwendung
It is called in the following way:

All of the parsing-related parameters that #get_web_data supports (format, delimiter, use xpath, etc.) can be used for #get_file_data as well; see.

Either "file=", or the combination of "directory=" and "file name=", should be set, but not both. If you want to give the wiki access to one or a small number of files, you could add one or more lines like the following to LocalSettings.php:

You would then set "file=" to the ID for that file.

And if there are any directories that you want the wiki to be able to access all files from, you could add one or more lines like the following to LocalSettings.php:

You would then set "directory=" to the ID of that directory, and "file name=" to the name of the file you want to access in this #get_file_data call. Note that the External Data code ensures that users cannot do tricks like adding "../.." and so on to the file name to access directories outside of the specified one.

Examples
To give an example, let's say that a lab wants to publish test results on their wiki. The results are all in CSV files in one directory on a server. So, they might add the following to LocalSettings.php:

Then, a #get_file_data call on the wiki might look like this:

Below that, there would presumably be a call to #for_external_table or #display_external_table to display the resulting data.

Directory iteration
It is also possible to process all files, optionally, with names matching a mask, in a directory. For example, to get a table of all files within the "ExternalData/includes" directory, and the name of the class defined in each one, you could add the following to :

Then call the following:

The external variable  will hold the file name, relative to.