-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathaction.php
49 lines (41 loc) · 1.56 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
<?php
class action_plugin_nspages extends DokuWiki_Action_Plugin {
/**
* Register its handlers with the dokuwiki's event controller
*/
function register(Doku_Event_Handler $controller) {
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array());
$controller->register_hook('PLUGIN_POPULARITY_DATA_SETUP', 'AFTER', $this, 'usage_data');
}
function insert_button(& $event, $param) {
$event->data[] = array (
'type' => 'insert',
'title' => 'nspages',
'icon' => '../../plugins/nspages/images/tb_nspages.png',
'insert' => $this->getConf('toolbar_inserted_markup')
);
}
function usage_data(&$event){
$plugin_info = $this->getInfo();
$event->data['nspages']['version'] = $plugin_info['date'];
$event->data['nspages']['legacyModificationDateSyntax'] = $this->used_legacy_syntax_not_too_long_ago() ? 'true' : 'false';
}
private function used_legacy_syntax_not_too_long_ago(){
$legacySyntax = io_readFile(action_plugin_nspages::legacySyntaxFilename());
if ($legacySyntax){
if ($legacySyntax > time() - 365 * 86400){
return true;
} else {
unlink(action_plugin_nspages::legacySyntaxFilename());
}
}
}
static function logUseLegacySyntax(){
$file = action_plugin_nspages::legacySyntaxFilename();
io_saveFile($file, time());
}
static function legacySyntaxFilename(){
global $conf;
return $conf['savedir'] . '/nspages_legacy_syntax.txt';
}
}