Learn about DokuWiki
Learn about DokuWiki
Compatible with DokuWiki
This plugin allows to move pages and namespaces including media files and automatically adjusts all links and media references that point to these pages. Unlike the old pagemove plugin this plugin uses the DokuWiki parser which allows it to correctly identify all links and nothing else.
Parts of this plugin, like some of the translated strings, some parts of the structure of the code and parts of the user interface have been taken from the old pagemove plugin by Gary Owen, Arno Puschmann and Christoph Jähnigen.
This plugin moves files inside your DokuWiki data directory and can automatically change a lot of pages. Even though the plugin has been successfully tested it is always possible that something doesn't work as expected in your case and your wiki might be left in an inconsistent state. This plugin is also still rather new and might behave incorrectly in certain cases.
Please make a backup before using this plugin, especially if you plan to make larger changes!
Warning: This plugin does not update ACL rules. For example if you had an ACL rule that read-protected a certain wiki page this rule won't have any effect anymore after moving that page.
When updating an existing installation of this plugin in DokuWiki versions older than Release Summer 2015 “Detritus” it might be necessary to de-install the old plugin version first and re-install the new version thereafter. Severe problems (e.g. inconsistent application menues with the old plugin screen combined with several unlogical [admin] buttons) have been observed after upating the plugin. For instance when originally installed on Dokuwiki release 2014-09-29 “Hrun” and updated onto Dokuwiki release 2015-08-10 “Detritus”.
If, for any reason, you used an FTP client to upload pages, you should “hit” (open) them in a browser to be sure the index is refreshed, otherwise the move plugins will fail to work on the page, or worse, forget to update link on those page.
Except for the single page rename, the plugin requires manager privileges to use it.
This is the main part of the plugin. To use it navigate to the page (or page in namespace) you want to change, then open the Admin menu and select the Move plugin from the list of additional plugins.
In the box switch between the current page or namespace and give a new location. Clicking start will preview your changes and you can start the move operation. To move a namespace with some pages in subspaces but none directly under the namespace, use the tree based move method.
To plan more complicated restructuring of your wiki, the move plugin comes with a tree-based Move Manager. Open it by clicking on the link in the Move screen, pictured above.
The Move Manager allows you to plan all moves and renames to be executed by drag'n'drop operations. Simply move pages, media files and namespaces to their desired locations until the tree represents the new layout you want to have. Starting from version 2017-01-07, multiple pages, media files or namespaces can be selected using checkboxes. When one of the selected items is moved, all selected items are moved to the target. The move fails (i.e., nothing is changed) if any of the selected items cannot be moved to the target (due to a naming conflict).
As of version 2017-01-07, new namespaces can be created by clicking on the “+”-icon next to the root namespace. Newly created namespaces can then be moved to the desired target location and can also be renamed. Note that only namespaces which contain a page, media file or (non-empty) namespace will be saved.
This feature is available to users and groups that have been configured through the
allowrename option in the config manager. It is automatically available on all templates that implement the
TEMPLATE_PAGETOOLS_DISPLAY event and can be disabled in the config manager.
Users can simply rename (or move) the page they are currently on.
The move plugin allows plugins to move their own data and to adapt their syntax when a page or media file is moved. Currently the following plugins support this:
Plugins not explicitly stating their compatibility are most probably not adjusted.
The move plugin emits the following events:
$IDand it can add additional pages whose syntax needs to be adjusted because of this move.
opts⇒ array – compatibility to old plugins, shouldn't be used
affected_pages⇒ array – page ids that are (possibly) affected by this move, initially populated from the
relation_referencesmetadata index. can be adjusted
src_id⇒ string – the original ID of the page
dst_id⇒ string – the new ID of the page
id– the id of the page that shall be modified
moves– the page moves that might affect the page
media_moves– the media moves that might affect the page
handlers– the array of handlers, see below for more information
$handlersarray, the key is the plugin name as it is given to the handler. The handler needs to be a valid callback, it will get the following parameters:
$handler. The first three parameters are equivalent to the parameters of the
handle()-function of syntax plugins,
$pluginnameis just the plugin name again so handler functions that handle multiple plugins/plugin parts can distinguish for which the match is. The last parameter is the handler object. It has the following properties and functions that can be used:
ns: id and namespace of the old page
new_ns: new id and namespace (can be identical to id and ns)
moves: array of page moves, the same as
movesin the event
media_moves: array of media moves, the sames as
media_movesin the event
adaptRelativeId($id): adapts the relative
$idaccording to the moves
Have a look at the include plugin for a relatively simple case of a plugin that handles page moves. These events might be subject to change though I'll try to keep them as compatible as possible. If you add your plugin to the list of supported plugins I'll have a look if I could break it before changing anything that might affect plugins.
Feel free to open a bug report if your plugin needs additional support from the move plugin.
The move plugin uses the search index of DokuWiki to find pages that contain links to moved pages or media files and then uses DokuWiki's parser to identify all links to pages or media files in the affected pages and changes them if necessary. Whenever a page is modified, a new revision of the page is created (but changes are batched, so when you move many pages e.g. using the tree-based move manager you should still only see 1-2 new revisions per affected page).
In contrast to a simple search and replace this can identify much more complex situations e.g. when a link is [[Foo Bar]] it will be found if the page foo_bar is moved and using DokuWiki's parser makes sure that e.g. code blocks or special plugin syntax is not modified.
Plugins can also add support, so e.g. the syntax of the include plugin will also be adjusted accordingly.
When using the admin interface to move whole namespaces or multiple pages and media files, an option to show a preview of the changes is available. You are encouraged to have a look at the preview to check that the plugin will do what you intended. Changes to individual pages can be easily reverted later using the builtin revert functionality of DokuWiki.
Both pages and media files have a list of revisions and saved, old versions in attic/media_attic respectively. These files need to be moved, too. Pages also have other metadata. Further, the search index needs to be adjusted (e.g. by re-indexing the page at the new location). The move plugin takes care of all that when you rename or move a page or media file.
Depending on the plugins you are using there might be additional data to be moved. Plugins can add support for moving their data when a page is moved using the move plugin, e.g. the struct plugin adapts its database when a page is moved.
The plugin moves old revisions together with the page (and a new revision reflecting the move is added). In the recent changes, two changes are added, documenting both the deletion at the old name and the creation at the new name. As only one change per page is displayed in the recent changes, this means that older changes of the page won't be displayed in the recent changes, but can be seen on the page's individual “old revisions” view.