UploadsMarkup

Summary: Providing an "Uploads:" markup similar to "Attach:", but with a storage-oriented way of referencing
Version: 1.1-beta2 (2007-12-19)
Prerequisites:
Status: Freshly released, awaiting comments
Maintainer: ThomasP
Categories: Uploads

Motivation

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.

Release Notes

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.