1<?php 2 3if(!defined('DOKU_INC')) die(); 4 5class action_plugin_publish_revisions extends DokuWiki_Action_Plugin { 6 7 /** 8 * @var helper_plugin_publish 9 */ 10 private $hlp; 11 12 function __construct() { 13 $this->hlp = plugin_load('helper','publish'); 14 } 15 16 function register(Doku_Event_Handler $controller) { 17 $controller->register_hook('FORM_REVISIONS_OUTPUT', 'AFTER', $this, 'handle_revisions', array()); 18 } 19 20 function handle_revisions(Doku_Event &$event, $param) { 21 global $ID; 22 global $INFO; 23 24 if (!$this->hlp->isActive()) { 25 return; 26 } 27 28 $meta = p_get_metadata($ID); 29 30 $member = null; 31 for ($pos = 0; $pos < $event->data->elementCount(); $pos++) { 32 $ref = $event->data->getElementAt($pos); 33 if ($ref->getType() != 'tagclose') { 34 if ($ref->val() == 'div' && $ref->attr('class') == 'li') 35 $member = $event->data->getElementAt($pos); 36 37 if ($member && $ref->attr('name') == 'rev2[]'){ 38 $revision = $ref->attr('value'); 39 if ($revision == 'current') { 40 // handle minor revisions and external edits 41 $revision = isset($meta['last_change']['date']) ? 42 $meta['last_change']['date'] : 43 $INFO['meta']['date']['modified']; 44 } 45 if ($this->hlp->isRevisionApproved($revision)) { 46 $member->addClass('approved_revision'); 47 } else { 48 $member->addClass('unapproved_revision'); 49 } 50 $member = null; 51 } 52 } 53 } 54 return true; 55 } 56 57} 58