DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:batchedit

BatchEdit Plugin

Compatible with DokuWiki

  • 2024-02-06 "Kaos" yes
  • 2023-04-04 "Jack Jackrum" yes
  • 2022-07-31 "Igor" yes
  • 2020-07-29 "Hogfather" yes

plugin Edit wiki pages using regular expressions

Last updated on
2024-11-24
Provides
Admin
Repository
Source

Tagged with editing, regexp, replace, search

BatchEdit is an admin plugin that allows you to use regular expressions to search and replace text on DokuWiki pages. As it works with raw DokuWiki text, the plugin can be also used to modify markup of the pages. This can be very helpful when there are multiple pages with similar markup. For example, you can update pages created from a namespace template if you decide to change the template.

Download and Installation

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

User Interface

After installation BatchEdit shows up on the Administration page. When started, the plugin displays a form with four primary edit fields:

Main UI

  • Namespace – allows you to select a top level namespace that contains pages to search in. All the namespaces below the selected one will be included in the search as well. Multiple namespaces may be specified separated by a comma. Standard name resolution of the namespaces applies here (e.g. “.” stands for the current namespace, etc.). Namespaces preceded with a hyphen are excluded from the search. If no namespaces are not provided, BatchEdit will search through the entire wiki.
  • Search for – depending on selected options this can be plain text string, regular expression, or fully qualified regular expression including delimiters and modifiers. BatchEdit uses Perl-compatible syntax of regular expression as defined by PHP PCRE extension.
  • Replace with – the replacement text or pattern. For the syntax see preg_replace documentation.
  • Edit summary – summary of the replacement. This field has the same purpose as the Edit summary field of the DokuWiki text editor.

Below the edit fields there are two buttons:

  • Preview – shows the search results with corresponding replacements but does not do the replacement itself.
  • Apply – replaces selected (see below) matches. If there are no selected matches it acts identical to the Preview button.

Match box

BatchEdit displays search matches in separate boxes, which are grouped per page. Next to the page identifier and on every match box there is a check box, which is used to mark matches for replacement. In order to prevent unexpected results the check box is unchecked by default requiring the user to confirm every replacement. The match box is split in two parts: matched text with some context on the left side; and the same fragment with applied replacement on the right. Both the matched text and the replacement are highlighted.

After the replacement, the matches show up with no check box in the caption and replaced text is highlighted with green.

Configuration

BatchEdit uses two types of configuration options:

  • User-specific options – all options available on BatchEdit page are individual for each user. These options are stored in a browser cookie, so strictly speaking they are browser-specific.
  • Global options – can be modified on DokuWiki configuration page. They control aspects of BatchEdit operation, which are rarely (if ever) to be changed.

Technical details

Performance

BatchEdit performs caching of the search results to avoid repeating the search when replacement is applied. Yet on every preview attempt the DokuWiki server reads all the pages from a hard drive. To reduce the server load and search time use Namespace field that limits the search scope or limit the number of search results in Advanced options.

Concurrent page edits

Because of two-staged approach of Preview&Apply, there is a possibility that while one user verifies and marks matches for replacement some other user modifies one of the involved pages. To prevent any data corruption BatchEdit locks pages during replacement and verifies that matched text is still located at the match offset. If any of the marked matches cannot be found at expected offsets, replacement for that page is rejected.

This verification still leaves a possibility that replacement will be applied to a different instance of the original text that happened to be at the exactly right offset after the edit, but likelihood of that is rather small. Anyway, it's recommended that administrators take care to minimize DokuWiki activity when BatchEdit is used.

Page lookup

BatchEdit uses DokuWiki page index to get the list of existing pages instead of going through the data directories. Because of the missing or incomplete index BatchEdit may show less search results than expected. This is often the case for a freshly migrated wiki. You can use Searchindex Manager plugin to get the index up to date.

This limitation also applies to the “special” pages (e.g. namespace templates), which are not listed in the index and therefore cannot be edited by BatchEdit.

Version History

2024-11-24

  • Added Brazilian Portuguese localization
  • Minor localization fixes

2024-02-12

  • Fixed compatibility with DokuWiki 2024-02-06 “Kaos”

2023-06-16

  • Added support for replacement in multiple namespaces
  • Fixed compatibility with DokuWiki Jack Jackrum

2022-02-20

  • Added option to replace namespace template patterns
  • Added Portuguese localization
  • Added Dutch localization
  • Fixed Bootstrap conflict with jQuery tooltip
  • Minor localization updates

2021-04-17

  • Fixed PHP 8.0 compatibility issues
  • Fixed admin UI layout in Safari browser
  • Fixed support of DokuWiki hosted in proxied subfolder
  • Updated French translation
  • Updated Russian translation

2020-07-31

  • Fixed compatibility with DokuWiki Hogfather
  • Russian translation update

2019-06-02

  • Added Russian translation
  • German translation update

2018-11-25

  • French translation update
  • Minor fixes

2018-08-18

  • Major UI update
  • Added global and per page check boxes to mark multiple matches
  • Added various configuration options
  • Added progress bar for long operations
  • Performance optimizations for massive edits
  • Added Chinese(Simplified) translation

2018-02-11

  • Added German language translation

2017-12-09

  • Added examples for regular expression and replacement pattern fields
  • Added French language translation
  • Minor style fixes for new DokuWiki default template

2014-05-24

  • Support common special characters in replacement string
  • Minor fixes

2009-02-14

  • Added View and Edit links to matched pages.

2008-12-07

  • Fixes in regular expression validation

2008-10-27

  • First public release

Bugs and Feature Requests

Please report bugs or feature requests at the bug tracker.

plugin/batchedit.txt · Last modified: by dwp-forge

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki