1<?php
2/**
3 * OddEven Plugin
4 * @license Public Domain
5 * @author  Vladimir Uryvaev <az@vovanium.ru>
6 */
7// must be run within Dokuwiki
8if(!defined('DOKU_INC')) die();
9
10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
11require_once(DOKU_PLUGIN.'action.php');
12
13class action_plugin_oddeven extends DokuWiki_Action_Plugin {
14
15	function getInfo() {
16		return array(
17			'author' => 'Vladimir Uryvaev',
18			'email'  => 'az@vovanium.ru',
19			'date'   => '2009-03-24',
20			'name'   => 'OddEven',
21			'desc'   => 'Colorize table rows like zebra',
22			'url'    => 'http://vovanium.ru/set/oddeven',
23		);
24	}
25
26	function register(&$controller) {
27		$controller->register_hook(
28			'RENDERER_CONTENT_POSTPROCESS',
29			'AFTER',
30			$this,
31			'oddeven',
32			array());
33	}
34	function oddeven(&$event, $param) {
35		$event->data[1] = preg_replace (
36			'/<tr class="row([0-9]*[02468])">/si',
37			'<tr class="row\\1 roweven">',
38			$event->data[1]
39		);
40		$event->data[1] = preg_replace (
41			'/<tr class="row([0-9]*[13579])">/si',
42			'<tr class="row\\1 rowodd">',
43			$event->data[1]
44		);
45	}
46}
47
48?>
49