xref: /plugin/approve/action/revisions.php (revision b81b11283adb1dcdb0fe36d5f4bdac1021fa065b)
1<?php
2
3use dokuwiki\plugin\approve\meta\ApproveConst;
4
5if(!defined('DOKU_INC')) die();
6
7class action_plugin_approve_revisions extends DokuWiki_Action_Plugin {
8
9    /** @var DokuWiki_PluginInterface */
10    protected $hlp;
11
12    function __construct(){
13        $this->hlp = plugin_load('helper', 'approve');
14    }
15
16
17    function register(Doku_Event_Handler $controller) {
18		$controller->register_hook('HTML_REVISIONSFORM_OUTPUT', 'BEFORE', $this, 'handle_revisions', array());
19		$controller->register_hook('HTML_RECENTFORM_OUTPUT', 'BEFORE', $this, 'handle_revisions', array());
20	}
21
22	function handle_revisions(Doku_Event $event, $param) {
23		global $ID;
24
25		if ($this->hlp->in_namespace($this->getConf('no_apr_namespaces'), $ID)) return;
26
27		$member = NULL;
28		foreach ($event->data->_content as $key => $ref) {
29
30			if (is_array($ref) && isset($ref['_elem']) && $ref['_elem'] == 'opentag' && $ref['_tag'] == 'div' && $ref['class'] == 'li') {
31			    $member = $key;
32            } elseif (is_string($ref) && strstr($ref, ApproveConst::APPROVED)) {
33                $event->data->_content[$member]['class'] .= ' plugin__approve_green';
34            }
35
36		}
37
38		return true;
39	}
40
41}
42