Not logged in. · Lost password · Register
Forum: General Help and Support Development RSS
IO_WIKIPAGE_READ / BEFORE : need clarification
What happens if your hook modifies the namespace?
Avatar
clh #1
Member since May 2016 · 94 posts
Group memberships: Members
Show profile · Link to this post
Subject: IO_WIKIPAGE_READ / BEFORE : need clarification
The documentation for https://www.dokuwiki.org/devel:event:io_wikipage_read states:

The $data field is an array with the entries:

$data[0] – The raw arguments for io_readFile() as an array. Do not change.
$data[0][0] – the file path.
$data[0][1] – whether to convert line endings to unix format, default true.
$data[1] – ns: The colon separated namespace path minus the trailing page name. (false if root ns)
$data[2] – page_name: The wiki page name without the namespace.
$data[3] – rev: The page revision, false for current wiki pages.

In the BEFORE event handler the $data can be modified, to influence the read action.


I assume this means that in the BEFORE event handler, only $data[1]..$data[3] may be changed. What would be the effect of changing the ns and/or page_name?

The reason I ask is I'm writing a plugin that intercepts a command to edit a page in the "published" area of my namespace, and copy the page into a special "drafts" area and edit that instead. Maybe IO_WIKIPAGE_READ is too late in the sequence of events to do this, but I wanted to clarify this.
Avatar
turnermm (Moderator) #2
Member since Oct 2009 · 4785 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
It might be simplest to use the openas plugin, which has 3 syntax formats, one of which will copy the current page to a new page id and update the links as necessary. https://www.dokuwiki.org/plugin:openas.  The original page stays in place.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
clh #3
Member since May 2016 · 94 posts
Group memberships: Members
Show profile · Link to this post
I think it needs to be more dynamic than what SaveAS provides. One detail that I omitted is that the drafts space will be subdivided by project_id. Checking a page out will involve a dialog where you specify the project under which you want to check the page out.

I'm beginning to think that, rather than triggering checkout as a side-effect of trying to edit a published page, I may add a checkout pagetool. Hopefully the Move plugin will illustrate a lot of what I need to do.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2020-02-26, 14:44:54 (UTC +01:00)