Extension:External Data/Local files/de

You can get data from files on the server on which the wiki resides, for any files that are of the formats CSV, GFF, HTML, INI, JSON, XML or YAML.

As of version 3.2, the recommended way to retrieve file data is to use one of the display functions (#external_value, #for_external_table, etc.), passing in the necessary parameters for the data retrieval, most notably "source=". You can also retrieve web data by calling the #get_file_data function, or (for version 3.0 and higher) #get_external_data. In any of these cases, you cannot (for privacy reasons) simply specify the local path of the file; you must instead set its information (or information about its directory) in the variable $wgExternalDataSources in LocalSettings.php.

For any of these parser functions, you can also call its corresponding Lua function.

The examples below all refer to #get_file_data. To retrieve file data using any of the other parser (or Lua) functions, you can use all of the same parameters, but specify "source=", instead of "file=" or "directory=", for the ID stored in LocalSettings.php.

Verwendung

 * 1) get_file_data 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.