1<?php 2/** 3 * Poldek Plugin: query poldek for package info 4 * 5 * Add poldek tags to dokuwiki 6 * 7 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 8 * @author Elan Ruusamäe <glen@delfi.ee> 9 */ 10// must be run within Dokuwiki 11if(!defined('DOKU_INC')) die(); 12 13/** 14 * Poldek Action Plugin: Update poldek indexes 15 * 16 * @author Elan Ruusamäe <glen@delfi.ee> 17 */ 18class action_plugin_poldek extends DokuWiki_Action_Plugin { 19 20 /** 21 * if true our process is already running 22 */ 23 private $run = false; 24 25 /** 26 * Register its handlers with the dokuwiki's event controller 27 */ 28 function register(Doku_Event_Handler $controller) { 29 $controller->register_hook('INDEXER_TASKS_RUN', 'BEFORE', $this, 'cron', array()); 30 $controller->register_hook('PARSER_CACHE_USE','BEFORE', $this, 'cache'); 31 } 32 33 /** 34 * Update poldek indexes in the background 35 */ 36 function cron(&$event, $param) { 37 if ($this->run) { 38 return; 39 } 40 41 $this->run = true; 42 43 $helper = $this->loadHelper($this->getPluginName(), true); 44 $helper->sync(true); 45 } 46 47 /** 48 * Update page cache dependencies 49 */ 50 function cache(&$event, $param) { 51 global $ID; 52 53 $cache =& $event->data; 54 55 // we're only interested in wiki pages and supported render modes 56 if (!isset($cache->page)) return; 57 if (!isset($cache->mode) || $cache->mode != 'xhtml') return; 58 59 $packages = p_get_metadata($ID, "plugin_" . $this->getPluginName()); 60 if (empty($packages)) { 61 return; 62 } 63 64 $helper = $this->loadHelper($this->getPluginName(), true); 65 $cache->depends['files'][] = $helper->getCache(); 66 } 67} 68 69//Setup VIM: ex: noet ts=4 enc=utf-8 : 70