UploadsMarkup
Motivation
- To make links to uploaded files using their natural directory path within the upload root dir (storage-oriented way of referencing the target), as opposed to the method that is underlying the "Attach:" markup(*). This is useful in case multiple
$UploadPrefixFmt
settings exist within one wiki, as it will be possible to directly address a location in the upload dir (independently of the$UploadPrefixFmt
setting). - Resulting from the discussion at http://thread.gmane.org/gmane.comp.web.wiki.pmwiki.user/40273/focus=40734
Releases
see below
Installation
Include as usual in your local/config.php by
include_once("cookbook/UploadsMarkup.php");
Usage
Sensible arguments to "Uploads:" look like:
Uploads:myfile.txt Uploads:./myfile.txt Uploads:../MyOtherPage/myfile.txt Uploads:../../MyOtherGroup/MyOtherPage/myfile.txt Uploads:/MyOtherGroup/MyOtherPage/myfile.txt a.s.o
Here absolute paths are interpreted relative to the upload root dir (usually uploads/
). Relative paths are interpreted relative to the page's respective upload dir, as given by the new config variable $UploadPrefixPathFmt
, which behaves like $UploadPrefixFmt
, i.e. /$Group/$Name
or /$Group
or similar would be suitable settings. If no value is configured it defaults to the $UploadPrefixFmt
setting.
There is no restriction on how deep or where exactly the file is located in the directory tree, only references trying to reach outside the overall upload dir are prevented.
Notes
- Honors authorization restrictions (files will be downloadable using the usual download mechanism)
- For files stored in the upload root dir, permission must have been granted for the
$DefaultGroup
.$DefaultName
page. - For files stored in a group upload dir, permission must have been granted for the
$DefaultName
page in that group. - For files stored in subdirectories below a page upload dir, the permissions for that page must be have been granted.
- For files stored in the upload root dir, permission must have been granted for the
Release Notes
- UploadsMarkup1.1-beta2.phpΔ (2007-12-19)
- introduced $UploadPrefixPathFmt to separate settings better from the default "Attach:" mechanism
- UploadsMarkup1.1-beta1.phpΔ (2007-12-15)
- now working
- not yet tested in windows environment (cf. backslashes)
See Also
Contributors
Comments
(*) The referencing of uploaded files with the Attach:
markup can be understood as two-stage process: first the argument provided to Attach:
is mapped to a pagename that the attachment will be associated with, then this pagename is "translated" to the corresponding storage location using $UploadPrefixFmt
. Thus the targeted file will have to lie within the scope determined by $UploadPrefixFmt
.
In the Uploads:
markup on the other side, the $UploadPrefixPathFmt setting is used only to determine the initial path ("current working dir"), starting from which the given file path argument is interpreted.
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.