[pmwiki-users] Attachlist and nice uploading
Petko Yotov
5ko at free.fr
Wed Jan 24 11:06:15 CST 2007
On Wednesday 24 January 2007 17:33, Patrick R. Michaud wrote:
> > B) the ability (with an enhanced attachlist?) to list all uploaded
> > files that match a given pattern.
>
> There are a number of features that people have wanted for
> (:attachlist:). If we can develop a list of desired features,
> perhaps I can get a basic implementation put together in the core
> that others can flesh out.
Patrick,
There is some pattern-matching code in the ThumbList recipe [1] that can be
used directly in attachlist, I believe. The name and skip patterns:
* name="paris_*.jpg|france*.jpg" - display only some files
* skip="*.gif|*.png" - skip some files
The code is roughly this [2] :
function ThumbFilePattern($x)
{return '/^'.str_replace(array("\\*","\\?","\\|"),array(".*",".","|"),preg_quote($x)).'$/i';}
inside the main function:
if (@$opt['skip']) $skipmatch=ThumbFilePattern($opt['skip']);
if (@$opt['name']) $pattern = ThumbFilePattern($opt['name']);
later, opening the directory:
while (($file=readdir($dirp)) !== false){
if ($file{0} == '.') continue;
if (@$skipmatch && preg_match(@$skipmatch, $file)) continue;
if (@$pattern && !preg_match($pattern, $file)) continue;
...
Greetings,
Petko
[1] http://pmwiki.org/wiki/Cookbook/ThumbList
[2] http://pmwiki.org/pmwiki/uploads/Cookbook/thumblist.php
More information about the pmwiki-users
mailing list