FoxTextReplace

Summary: replace text strings on multiple pages
Version: 2008-12-08
Prerequisites: Pmwiki 2.2.0, Fox, PowerTools
Status: experimental
Maintainer: HansB

Questions answered by this recipe

This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.

Description

This recipe uses a Fox form to let you replace text strings on multiple pages.

Prerequisites: install Fox and PowerTools.
PowerTools is needed to let the user enter target pages with wiki wildcards (see PowerTools#plist for details).

Create a page with this Fox form:

(:foxmessage:)
(:fox frm foxaction=replace put=all target='{$$(plist {$$pat})}' foxtemplate="{$$new}" mark='{$$mk}':)
||table width=600px
|| Replace text string:||(:input text mk size=40:) ||
|| With this string:||(:input text new size=40:) ||
|| On Target Pages:||(:input text pat size=40:) ||
|| ||(:input submit post 'Replace Now':) ||
Notes: you can specify several target pages,\\
or use wiki wildcards (* and ?) in target page names.\\
Example:\\
'''Test.*''' to replace string on all pages in ''Test'' group. 
(:foxend frm:)

The form will look somewhat like this (non-functional example):

Replace text string:
With this string:
On Target Pages:
 
Notes: you can specify several target pages,
or use wiki wildcards (* and ?) in target page names.
Example:
Test.* to replace string on all pages in Test group.

The target field accepts wiki wildcard target names. Make sure not too many pages are targeted, because otherwise Fox will be stopped before ending with an PHP timeout error.

Make sure Fox is permitted to perform a replace foxaction on the target pages. You may need to set $FoxPagePermissions for this in config.php (see Fox#security). Be aware of the security risks of allowing such action.

All occurences of the text string found will be replaced. If you only wish to replace the first occurence in a page, you should replace in the form put=all with put=string

Notes

Release Notes

  • 2008-12-08: initial release

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See Also

Contributors

Comments

See discussion at FoxTextReplace-Talk

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.