michitux/dokuwiki-plugin-move — pull request #6 by splitbrain (2014-04-29 13:01:52+00:00)
Title: Major refactoring and multiple new features

This is a major refactoring of the move plugin. This is the first "final" version. The plugin will be installed and used at CosmoCode internally over the next weeks and there will probably be some more bugfixes. I'll add them either to this PR (if not yet merged) or create new PRs.

Instead of having nearly all the functionality in one single helper plugin, the plugin was split up into several components.

There is no longer a distinction between renames and moves as they are essentially the same. Thus operations no longer work with names + namespaces, but work on full page or namespace IDs only.

The interface to start a page or namespace move was redone accordingly and simply lets you enter the new ID. A change that hopefully should make the interface much easier to understand.

![admin](https://cloud.githubusercontent.com/assets/86426/2829053/251df0a6-cf9e-11e3-88d7-76c991483538.png)

The mechanism to handle complex moves was extended from moving a single namespace to cover an arbitrary number of move operations. This is called a "plan" internally.

A new interface allows the creation of more complex move plans using a drag'n'drop interface with a tree like representation of pages and media files.

![tree](https://cloud.githubusercontent.com/assets/86426/2829055/2e6d9ba2-cf9e-11e3-8e8c-f8f43fff468f.png)

Before starting the execution of a move, a preview of all operations and affected pages is shown.

![progress](https://cloud.githubusercontent.com/assets/86426/2829057/38675436-cf9e-11e3-988a-f0af4baaa4be.png)

In addition all operations are logged to a logfile in the cache directory. There is currently no interface to view these logfiles though - they have to be accessed via file system.

Execution of the move plan was overhauled and simplified. Error handling should be a little bit simpler now (by directly accessing the global $MSG array instead of using output buffering), though ideally it should be redone using Exception in another refactoring.

The code for the custom indexing mechanism has been removed as it is now part of DokuWiki core. All other code has been updated to use new DokuWiki features like the $INPUT handler.

Options have been added to skip error on plan execution and to have links adjusted in all affected pages immediately after the move.

Initially the idea was to temporarily disable page subscriptions when links are adjusted. However this proved to be difficult. The simpler solution is to mark link adjustments as "minor" changes which excludes them from automatic mailing automatically. This can be done by a new config option of the plugin.

A simple page rename function can be enabled for non-managers. Access to this feature can be controlled via a group/user setting in the config. It also automatically integrates into the page tools menu of the default DokuWiki template.

![rename](https://cloud.githubusercontent.com/assets/86426/2829067/4b7ad5a2-cf9e-11e3-98e8-f6de80ac7277.png)
![renamedialog](https://cloud.githubusercontent.com/assets/86426/2829070/4ec6c932-cf9e-11e3-8583-b046bd45c081.png)

Metadata was adjusted to keep a proper stack of link changes and keeping track of the page's original name before all pending move operations. This allows to add more move info without the need to apply previous move rewrites first. This is done automatically now during the execution of page moves which should avoid multiple rewrites of pages during a move.

The plugin now also tries to rewrite links to non existing pages if their target is pointing to a moved namespace. There are some edge cases where that might fail as described in cosmocode/dokuwiki-plugin-move@d791aa26159b5c061bbe4fc5328d5b6db9e343d3 - but for the majority of moves this should not be a problem.

Tests are still minimal. The original tests succeed and a few small new ones were added but more tests would definitively help. A Travis config was added to the repository, so it's ready for automated testing.

This plugin makes use of DokuWiki's include_once for JavaScript which is broken until splitbrain/dokuwiki@969df2f1a2855988cc9c14870869d05fd42037ad this fix needs to be applied manually to current stable releases or it has to be taken care that no other plugin includes JSON2.js (currently known: edittable).

Note: because some files were moved into sub directories previous installations should be deleted before reinstalling this version to get rid of any old files (this does not apply when updating via git of course).