This repository has been archived by the owner on Feb 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.php
47 lines (42 loc) · 1.96 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
<?php
/**
* Plugin Goole+1
*
* @author Enrico Croce & Simona Burzio (staff@eiroca.net)
* @copyright Copyright (C) 2013-2019 eIrOcA - Enrico Croce & Simona Burzio
* @license GPL >=3 (http://www.gnu.org/licenses/)
* @version 19.02
* @link http://www.eiroca.net/doku_gplusone
*/
if (!defined('DOKU_INC')) die();
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
if (!defined('DOKU_PLUGIN_GPLUSONE')) define('DOKU_PLUGIN_GPLUSONE', DOKU_PLUGIN . 'gplusone/');
require_once (DOKU_PLUGIN . 'action.php');
class action_plugin_gplusone extends DokuWiki_Action_Plugin {
function register(Doku_Event_Handler $controller) {
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'toolbar_add_button_gplusone', array ());
$controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'gplus_script');
}
function toolbar_add_button_gplusone(&$event, $param) {
$event->data[] = array (
'type' => 'format', 'title' => $this->getLang('gplusone_editor'), 'icon' => '../../plugins/gplusone/editor/gplusone.png', 'open' => '~~GPLUSONE', 'sample' => @file_get_contents(DOKU_PLUGIN_GPLUSONE . 'editor/sample.txt'), 'close' => '~~'
);
}
function gplus_script(&$event, $param) {
global $ID;
global $conf;
$end_date = mktime(0, 0, 0, 3, 1, 2019);
if (($end_date - time()) > 0) {
if (plugin_isdisabled('translation') || (!$translation = plugin_load('helper', 'translation'))) {
$lang = $conf['lang'];
}
else {
$lang = $translation->getLangPart($ID);
}
$event->data['script'][] = array (
'type' => 'text/javascript', '_data' => "window.___gcfg = {lang: '$lang'};(function() {var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;po.src = 'https://apis.google.com/js/plusone.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);})();"
);
}
}
}
?>