[pmwiki-users] PmWiki 2.2.6 released

Petko Yotov 5ko at 5ko.fr
Wed Oct 14 01:23:54 CDT 2009


On Monday 12 October 2009 13:21:53 David Pilling wrote:
> >> 2009/10/5 Petko Yotov <5ko at 5ko.fr>
> >>
> >> > Hello. I have released pmwiki-2.2.6 today, available at :
> 
> Are there any examples of the use of the new:
> 
> $MakeUploadNamePatterns
> 
> variable?

Hello. This variable allows to configure some substitutions on the names of 
uploaded files. It works identically to the $MakePageNamePatterns array which 
produces valid wiki pagenames.

Default is the following :

  $UploadNameChars = "-\\w. "; # only allow a-z, 0-9, dash, space and dot
  $MakeUploadNamePatterns = array(
    "/[^$UploadNameChars]/" => '',          # stip all not-allowed characters
    '/\\.[^.]*$/e' => 'strtolower("$0")',   # convert extension to lowercase
    '/^[^[:alnum:]_]+/' => '',        # strip initial spaces, dashes, dots
    '/[^[:alnum:]_]+$/' => ''));      # strip trailing spaces, dashes, dots


A wiki could need to convert spaces to underscores, and accented French 
letters to ASCII. In that case, it could use in config.php :

  $MakeUploadNamePatterns = array(

    # convert é->e, à->a... (provided that you have the iconv() function)
    '/^.*$/e' => 'iconv("UTF-8", "ASCII//TRANSLIT", "$0")',

    '/\\s+/' => '_',                      # space(s) to a single '_'
    "/[^$UploadNameChars]/" => '',        # stip all not-allowed characters
    '/\\.[^.]*$/e' => 'strtolower("$0")', # convert extension to lowercase
    '/^[^[:alnum:]_]+/' => '',        # strip initial spaces, dashes, dots
    '/[^[:alnum:]_]+$/' => ''));      # strip trailing spaces, dashes, dots

Note that if you start to convert spaces to underscores, but you already have 
uploaded files with names containing spaces, they may become invisible to the 
wiki (in [[Attach:file with spaces.odt]] links).

Petko



More information about the pmwiki-users mailing list