devel:event:common_wikipage_save
Table of Contents
COMMON_WIKIPAGE_SAVE
- Description:
- Intercept or modify saving of a wiki page
- DefaultAction:
- save the given content and create a new revision
- Preventable:
- yes
- Added:
- 2016-02-24
This event is signalled by saveWikiText() in inc/common.php when a page is saved, handlers can use it to:
- prevent saves by either preventing the default action or overwriting the contentChanged field in a BEFORE hook
- enforce saves even when no content changed by overwriting the contentChanged field in a BEFORE hook
- adjust the saved content by modifying the newContent field in a BEFORE hook
- adjust the stored change log information (summary, type, extras) in an AFTER hook
- easily know if a page was deleted, created or edited by inspecting the changeType field
- do whatever they want before or after a wiki page is saved
Passed Data
The passed Doku_Event has the field $data
.
$data
is an array with the following keys:
id
– the page ID of the page to savefile
– the path to the corresponding file of that pagerevertFrom
– if this save is a revert to an older version, that older version is in here. falsy otherwiseoldRevision
– this is the revision date (timestamp) of the page before the savenewRevision
– this is the revision date (timestamp) of the page after the save (only available in the AFTER event)newContent
– the new page content to be savedoldContent
– the page's content before savingsummary
– the edit summarycontentChanged
– a boolean comparing newContent and oldContent. The default action is only executed when this is true. A BEFORE hook could change it to true to force saving even when the page content did not changechangeInfo
– additional info to be stored with the changelog. usually empty. ContainsrevertFrom
for reverts.changeType
– one of the following constants:DOKU_CHANGE_TYPE_EDIT
DOKU_CHANGE_TYPE_REVERT
DOKU_CHANGE_TYPE_CREATE
DOKU_CHANGE_TYPE_DELETE
DOKU_CHANGE_TYPE_MINOR_EDIT
sizechange
– contains after saving the size (in bytes) of the saved change
See also
- Code related to this event used in any DokuWiki's files, plugins and templates
devel/event/common_wikipage_save.txt · Last modified: 2018-12-08 15:08 by torpedo