forked from calltella/dokuwiki-plugin-wikicalendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.php
80 lines (71 loc) · 3.15 KB
/
action.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* DokuWiki Action Plugin WikiCalendar
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Michael Klier <chi@chimeric.de>
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/');
if(!defined('DOKU_LF')) define('DOKU_LF', "\n");
require_once(DOKU_PLUGIN.'action.php');
/**
* All DokuWiki plugins to extend the admin function
* need to inherit from this class
*/
class action_plugin_wikicalendar extends DokuWiki_Action_Plugin {
function getInfo() {
return array(
'author' => 'Michael Klier',
'email' => 'chi@chimeric.de',
'date' => @file_get_contents(DOKU_PLUGIN.'wikicalendar/VERSION'),
'name' => 'WikiCalendar Plugin (action component)',
'desc' => 'Implements a simple Calendar with links to wikipages.',
'url' => 'http://dokuwiki.org/plugin:wikicalendar',
);
}
// register hook
function register(&$controller) {
$controller->register_hook('ACTION_SHOW_REDIRECT', 'BEFORE', $this, 'handle_redirect');
$controller->register_hook('HTML_EDITFORM_OUTPUT', 'BEFORE', $this, 'handle_form');
$controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'handle_started');
}
/**
* Checks for calendar values for proper redirects
*/
function handle_started(&$event, $param) {
if(is_array($_SESSION[DOKU_COOKIE])) {
if(array_key_exists('plugin_wikicalendar_month', $_SESSION[DOKU_COOKIE])) {
$_REQUEST['plugin_wikicalendar_month'] = $_SESSION[DOKU_COOKIE]['plugin_wikicalendar_month'];
$_REQUEST['plugin_wikicalendar_year'] = $_SESSION[DOKU_COOKIE]['plugin_wikicalendar_year'];
unset($_SESSION[DOKU_COOKIE]['plugin_wikicalendar_month']);
unset($_SESSION[DOKU_COOKIE]['plugin_wikicalendar_year']);
}
}
}
/**
* Inserts the hidden redirect id field into edit form
*/
function handle_form(&$event, $param) {
if(array_key_exists('plugin_wikicalendar_redirect_id', $_REQUEST)) {
$event->data->addHidden('plugin_wikicalendar_redirect_id', cleanID($_REQUEST['plugin_wikicalendar_redirect_id']));
$event->data->addHidden('plugin_wikicalendar_month', cleanID($_REQUEST['plugin_wikicalendar_month']));
$event->data->addHidden('plugin_wikicalendar_year', cleanID($_REQUEST['plugin_wikicalendar_year']));
}
}
/**
* Redirects to the calendar page
*/
function handle_redirect(&$event, $param) {
if(array_key_exists('plugin_wikicalendar_redirect_id', $_REQUEST)) {
@session_start();
$_SESSION[DOKU_COOKIE]['plugin_wikicalendar_month'] = $_REQUEST['plugin_wikicalendar_month'];
$_SESSION[DOKU_COOKIE]['plugin_wikicalendar_year'] = $_REQUEST['plugin_wikicalendar_year'];
@session_write_close();
$event->data['id'] = cleanID($_REQUEST['plugin_wikicalendar_redirect_id']);
$event->data['title'] = '';
}
}
}
// vim:ts=4:sw=4:et:enc=utf-8: