Not logged in. · Lost password · Register
Forum: General Help and Support Development RSS
[solved]How to rewrite data of HTML_RECENTFORM_OUTPUT etc. via action plugins
solved
Page:  1  2  next 
Avatar
hokkaidoperson #1
Member since Apr 2018 · 57 posts · Location: Sapporo, Hokkaido, Japan
Group memberships: Members
Show profile · Link to this post
Subject: [solved]How to rewrite data of HTML_RECENTFORM_OUTPUT etc. via action plugins
In events such as HTML_RECENTFORM_OUTPUT and HTML_REVISIONSFORM_OUTPUT, I want to rewrite the data to be shown in order to display different things from the default.  Specifically I want to hide IP addresses of editors who didn't log in.

I'm not good at PHP programming, and even though I'm trying to make the plugin, it doesn't work.
Though it may have problems in elementary things, but I can't find the problems, so I'd like to ask you.

Here is the source code (I referred to the source code such as https://github.com/cosmocode/dokuwiki-plugin-publish/blob/…):

<?PHP

/**
 * Hiding IP address plugin
 */

if(!defined('DOKU_INC')) die();


class action_plugin_hidingip extends DokuWiki_Action_Plugin {

    /**
     * Run this plugin in:
     * 1. Recent Changes
     * 2. Old Revisions
     * 3. Last Modified (in progress)
     * 4. Locking Editing (in progress)
     */
    public function register(Doku_Event_Handler $controller) {
        $controller->register_hook('HTML_RECENTFORM_OUTPUT', 'BEFORE', $this, 'recentform', array());
        $controller->register_hook('HTML_REVISIONSFORM_OUTPUT', 'BEFORE', $this, 'revisionform', array());
    }

    /**
     * In recent changes
     */
    public function recentform(Doku_Event $event, $param) {
        global $lang;

        $display = $this->getLang('notloggedin');

        if(auth_ismanager() and !$event->data->_content['recents']['user']) {
            $event->data->_content['recents']['ip'] = $display . '(' . $event->data->_content['recents']['ip'] . ')';
        } else if(!auth_ismanager()) {
            $event->data->_content['recents']['ip'] = $display;
        }
    }


    /**
     * In old revisions
     */
    public function revisionform(Doku_Event $event, $param) {
        global $lang;

        $display = $this->getLang('notloggedin');

        if(auth_ismanager() and !$event->data->_content['revinfo']['user']) {
            $event->data->_content['revinfo']['ip'] = $display . '(' . $event->data->_content['revinfo']['ip'] . ')';
        } else if (!auth_ismanager()){
            $event->data->_content['revinfo']['ip'] = $display;
        }
    }

}
?>
This post was edited on 2018-06-01, 18:21 by hokkaidoperson.
Avatar
andi (Administrator) #2
User title: splitbrain
Member since May 2006 · 3471 posts · Location: Berlin Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Instead of just dumping your whole source and saying "it doesn't work" it would be more helpful if you would explain what you want to do, what exactly you tried and what your exact problem is you need help with.
Read this if you don't get any useful answers.
Lies dies wenn du keine hilfreichen Antworten bekommst.
Avatar
hokkaidoperson #3
Member since Apr 2018 · 57 posts · Location: Sapporo, Hokkaido, Japan
Group memberships: Members
Show profile · Link to this post
Subject: Additional explanations
Sorry, I'll explain more.

For example, old revisions are shown like:
2018/05/15 16:41  pagename – summary XXX.XXX.XXX.XXX +** B
2018/05/09 18:26  pagename – summary username +** B

But I want to avoid IP addresses to be shown to public, and display like this:
(when users that aren't admin see)
2018/05/15 16:41  pagename – summary An Anonymous User +** B
2018/05/09 18:26  pagename – summary username +** B

(when admin sees)
2018/05/15 16:41  pagename – summary An Anonymous User(XXX.XXX.XXX.XXX) +** B
2018/05/09 18:26  pagename – summary username(XXX.XXX.XXX.XXX) +** B


So that I want to control the action of HTML_REVISIONSFORM_OUTPUT.  Specifically, I want to change contents of the variable where holds IP addresses.
Then I researched how to do so, then tried like this:
.....
$event->data->_content['revinfo']['ip'] = $display;
.....
However, IP addresses are still shown.  I want to know what I should enter instead of "$event->data->_content['revinfo']['ip']".

Now are these enough for you?
Avatar
turnermm (Moderator) #4
Member since Oct 2009 · 4688 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
$event->data->_content['revinfo']['ip'] = $display;

Where did you find this?
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
hokkaidoperson #5
Member since Apr 2018 · 57 posts · Location: Sapporo, Hokkaido, Japan
Group memberships: Members
Show profile · Link to this post
In inc/html.php :
459              $summary = $revinfo['sum'];
 460              if($revinfo['user']) {
 461                  $editor = $revinfo['user'];
 462              } else {
 463                  $editor = $revinfo['ip'];
 464              }
 465              $sizechange = $revinfo['sizechange'];

At first, I tried with $event->data->_content['revinfo']['ip'] , but it didn't work well.
Then I tried with $event->data->_content['revinfo']['ip'] , but it still doesn't work.
Avatar
hokkaidoperson #6
Member since Apr 2018 · 57 posts · Location: Sapporo, Hokkaido, Japan
Group memberships: Members
Show profile · Link to this post
Quote by hokkaidoperson:
At first, I tried with $event->data->_content['revinfo']['ip'] , but it didn't work well.

Not $event->data->_content['revinfo']['ip'] but $event->data->_content['info']['ip']
Avatar
turnermm (Moderator) #7
Member since Oct 2009 · 4688 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
In reply to post #5
That function creates the form data which is the content of the $event in the event handlers, and it is that which has to be modified to remove the ips.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
hokkaidoperson #8
Member since Apr 2018 · 57 posts · Location: Sapporo, Hokkaido, Japan
Group memberships: Members
Show profile · Link to this post
Subject: I did it in old revisions
I could hide anonnymous users' IPs in old revisions.

I'll try same things in:
    * Recent Changes
    * Last Modified
    * Locking Editing
    * Showing Diff

Does DokuWiki have another function that will make anoonymous users' IPs be shown to public?
Avatar
turnermm (Moderator) #9
Member since Oct 2009 · 4688 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
There's an event for recents which can probably use the same Function as old rev. Last modifed might have to be handled in the template.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
hokkaidoperson #10
Member since Apr 2018 · 57 posts · Location: Sapporo, Hokkaido, Japan
Group memberships: Members
Show profile · Link to this post
I also did it in recent changes.

And you mean that there is no event that can handle "last modified"?
Avatar
hokkaidoperson #11
Member since Apr 2018 · 57 posts · Location: Sapporo, Hokkaido, Japan
Group memberships: Members
Show profile · Link to this post
…And does DokuWiki have events that can control Page Locking and Showing Diff?
Avatar
turnermm (Moderator) #12
Member since Oct 2009 · 4688 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
You have to check the events yourself for diffs, I don't recall one.  The function for Last Modified is hard-coded into the template, you would have to modify it there or use jQuery to hide the user name, though in the latter case it would still be available to anyone using  View Source.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
hokkaidoperson #13
Member since Apr 2018 · 57 posts · Location: Sapporo, Hokkaido, Japan
Group memberships: Members
Show profile · Link to this post
I see.
I will search for the event that can control diffs (Please notice me if you recall one.), and will tell users to custom the templates to hide IPs in last modified.
And does DokuWiki have the event that can touch the Page Locking? (Just I want to change what is displayed)
Avatar
turnermm (Moderator) #14
Member since Oct 2009 · 4688 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
If you simply want to change the locking text, see this:

  https://www.dokuwiki.org/localization#changing_some_locali…

The text file for locking is is locking.txt
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
hokkaidoperson #15
Member since Apr 2018 · 57 posts · Location: Sapporo, Hokkaido, Japan
Group memberships: Members
Show profile · Link to this post
I wanted to change where user name or IPs are shown, but I couldn't do so in this way.
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:
Page:  1  2  next 
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-08-21, 07:09:03 (UTC +02:00)