1<?php 2/** 3 * DokuWiki Plugin dlcounter (Action Component) 4 * 5 * records and displays download counts for files with specified extensions in the media library 6 * 7 * @author Phil Ide <phil@pbih.eu> 8 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 9 */ 10 11// must be run within Dokuwiki 12if (!defined('DOKU_INC')) { 13 die(); 14} 15 16class action_plugin_toucher2 extends DokuWiki_Action_Plugin 17{ 18 19 /** 20 * Registers a callback function for a given event 21 * 22 * @param Doku_Event_Handler $controller DokuWiki's event controller object 23 * 24 * @return void 25 */ 26 public function register(Doku_Event_Handler $controller) 27 { 28 $controller->register_hook('COMMON_WIKIPAGE_SAVE', 'AFTER', $this, 'handle_wikipage_save'); 29 30 } 31 32 /** 33 * [Custom event handler which performs action] 34 * 35 * Called for event: 36 * 37 * @param Doku_Event $event event object by reference 38 * @param mixed $param [the parameters passed as fifth argument to register_hook() when this 39 * handler was registered] 40 * 41 * @return void 42 */ 43 public function handle_wikipage_save(Doku_Event $event, $param) 44 { 45 global $INFO; 46 $act = false; 47 48 // only do this if enabled for page saves 49 if( $this->getConf('on_demand') ){ 50 // manager and plugin isn't enabled for admins only 51 if( $INFO['ismanager'] && !$this->getConf('admin_only') ){ 52 $act = true; 53 } 54 else if( $INFO['isadmin'] ){ 55 $act = true; 56 } 57 58 if( $act ){ 59 touch(DOKU_CONF."local.php"); 60 } 61 } 62 } 63 64} 65 66