1<?php
2/**
3 * BlogMeta plugin
4 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
5 * @author     Martin Plicka <mail@mplicka.cz>
6 */
7
8// must be run within Dokuwiki
9if (!defined('DOKU_INC')) die();
10
11if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
12if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
13if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
14
15require_once(DOKU_PLUGIN.'action.php');
16
17class action_plugin_blogmeta extends DokuWiki_Action_Plugin{
18
19    function getInfo() {
20        return array(
21                'author' => 'Martin Plicka',
22                'email'  => 'mail@mplicka.cz',
23                'date'   =>  @file_get_contents(DOKU_PLUGIN . 'blogmeta/VERSION'),
24                'name'   => 'BlogMeta Plugin (action plugin)',
25                'desc'   => 'Inserts some metadata after the dokuwiki page content on selected pages, always above Discussion plugin output. Suitable for people who hates metadata displayed far far below comments.',
26                'url'    => 'http://mplicka.cz/en/projects/dokuwiki_goodies',
27                );
28    }
29
30    function register(&$contr) {
31        $contr->register_hook('TPL_ACT_RENDER', 'AFTER', $this, 'printout', array() );
32
33
34        // HACK to make this plugin the first listener
35
36        //get array with listeners
37        $collection = &$contr->_hooks['TPL_ACT_RENDER_AFTER'];
38
39        if ( ($len = count($collection)) > 1) {//more than 1 listener
40          //save first listener
41          $save = $collection[0];
42          //exchange last registered listener with first one in array
43          $collection[0]=$collection[$len-1];
44          $collection[$len-1] = $save;
45        }
46    }
47
48
49    function printout(&$event, $param) {
50        global $ID;
51        global $INFO;
52        global $conf;
53        global $ACT;
54
55        //only when show action, page exists and its ID matches with settings
56        if ($ACT == 'show' && $INFO['exists'] && ereg( ($this->getConf('pages_regexp')) , $ID) ){
57          print "<div class=\"plugin_blogmeta\">";
58          print $this->getLang('posted')." ".strftime($conf['dformat'],$INFO['meta']['date']['created']);
59          if ($this->getConf('show_user')) print " &middot; ".$INFO['meta']['creator'];
60          print "</div>".DOKU_LF;
61        }
62    }
63
64}
65
66