1<?php 2 3if(!defined('DOKU_INC')) die(); 4 5class action_plugin_outdated_banner extends DokuWiki_Action_Plugin { 6 7 /** 8 * @var helper_plugin_outdated 9 */ 10 private $hlp; 11 12 function __construct() { 13 $this->hlp = plugin_load('helper','outdated'); 14 } 15 16 function register(Doku_Event_Handler $controller) { 17 $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'handle_display_banner', array()); 18 } 19 20 function handle_display_banner(&$event, $param) { 21 global $INFO; 22 23 if ($event->data != 'show') { 24 return; 25 } 26 27 if (!$INFO['exists']) { 28 return; 29 } 30 31 $meta = $INFO['meta']; 32 33 if (!$this->hlp->isActive() && !isset($meta['plugin_outdated'])) { 34 return; 35 } 36 37 if (!$this->hlp->isCurrentRevisionOutdated()) { 38 return; 39 } 40 41 $this->showBanner(); 42 return; 43 } 44 45 function showBanner() { 46 echo '<div class="outdated">'; 47 $this->showOutdatedBanner(); 48 49 echo '</div>'; 50 } 51 52 function showOutdatedBanner() { 53 printf('<span>%s</span>', $this->render_text($this->hlp->getOutdatedMessageForCurrentPage())); 54 } 55} 56 57