[pmwiki-users] attachtable for PHP 5.5 ?
Petko Yotov
5ko at 5ko.fr
Tue Dec 9 19:38:06 CST 2014
I may have been not clear enough, you can use a single PPRA() call with
an array with multiple search-replace pairs:
$txt = PPRA(
array(
'/search1/' => 'replace1',
'/search2/' => PCCF("replace2"),
'/search3/' => PCCF("replace3"),
),
PHSC($pg['text'], ENT_NOQUOTES)
);
Otherwise, to evaluate individual search-replace pairs, using PPRE() is
shorter, it is also documented in the Functions page.
Here I'd use PPRA() with an array of the search-replace pairs, not
PPRE().
Petko
On 10.12.2014 01:54, Hans Bracker wrote:
> thank you so much, Petko, for the detailed tuition in use of those
> helper functions!
>
> I got it working, and uploaded to pmwiki.org
> http://www.pmwiki.org/wiki/Cookbook/Attachtable
>
> This is the rewritten section:
>
> foreach( $ls as $pn ) {
> $pg = RetrieveAuthPage( $pn, 'read', FALSE, READPAGE_CURRENT );
> if ($pg) {
> $txt = PHSC( $pg['text'], ENT_NOQUOTES );
> ## preserved text
> $txt =
> preg_replace("/(\n[^\\S\n]*)?\\[([=@])(.*?)\\2\\]/s", " ", $txt);
> ## links to attachments
> $txt = PPRA(
> array('/\[\[[^\]]*?\bAttach:([^"\]\|]*)/'
> => PCCF("return
> '[['.AttachtableCountUploadLinks('$pn','',\$m[1]);")), $txt);
> ## raw attachments
> $txt = PPRA(
> array("/\\bAttach:([^\\s$UrlExcludeChars]*[^\\s.,?!$UrlExcludeChars])/"
>
> => PCCF("return
> AttachtableCountUploadLinks('$pn','',\$m[1]);")), $txt);
>
> }
> }
>
> There was a note in the function:
> ## FIXME: these really ought to be cached
> Without caching whenever action=upload the references are getting
> pulled out of all the pages, which means usually all the pages of the
> wiki group, and each page is opened and read and the text processed.
> But I would not know how to do the caching.
> And sofar I have not found it greatly detrimental without caching.
> Mostly a user wants to upload a file, and the Attach Table list is
> secondary.
>
More information about the pmwiki-users
mailing list