-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.php
74 lines (63 loc) · 2 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
<?php
/**
* Table2Csv Action Plugin
*
* Provides export of table to csv
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Tom Cafferty <[email protected]>
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once DOKU_PLUGIN.'action.php';
class action_plugin_table2csv extends DokuWiki_Action_Plugin {
function getInfo() {
return array(
'author' => 'Tom Cafferty',
'email' => '[email protected]',
'date' => '2012-07-22',
'name' => 'table2csv',
'desc' => 'export table on page to csv file',
'url' => 'http://www.dokuwiki.org/plugin:table2csv'
);
}
/**
* Register its handlers with the DokuWiki's event controller
*/
function register(&$controller) {
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'convert2csv',array());
}
/**
* convert script for csv file output.
*
* @author Tom Cafferty <[email protected]>
*/
function convert2csv(&$event, $param) {
global $ACT;
global $ID;
global $conf;
// our event?
if ($ACT != 'export_csv' ) return false;
// check user's rights
if ( auth_quickaclcheck($ID) < AUTH_READ ) {
msg(sprintf('Forbidden access to page ' . $ID));
return false;
}
// it's ours, no one else's
require_once ('getTableData.php');
$event->preventDefault();
//get start marker
$sm = p_get_metadata($ID,'table2csv');
// get page data
$fileext = $this->getConf('filepath');
$html = scrapeTable2Csv($ID,$fileext,$sm);
if ($html === false) {
return false;
} else {
// remain on current page
header("HTTP/1.1 204 No Content");
exit();
}
}
}