1<?php
2/**
3 * Google +1 Plugin: Embeds +1 button into page
4 *
5 * @license    GPLv3 (http://www.gnu.org/licenses/gpl.html)
6 * @link       http://www.dokuwiki.org/plugin:googleplusone
7 * @author     Markus Birth <markus@birth-online.de>
8 */
9
10if ( !defined( 'DOKU_INC' ) ) die();
11if ( !defined( 'DOKU_PLUGIN' ) ) define( 'DOKU_PLUGIN', DOKU_INC.'lib/plugins/' );
12require_once( DOKU_PLUGIN.'action.php' );
13
14class action_plugin_googleplusone extends DokuWiki_Action_Plugin {
15
16    /**
17     * return some info
18     */
19    function getInfo() {
20        return confToHash( dirname(__FILE__).'/INFO.txt' );
21    }
22
23    /*
24     * plugin should use this method to register its handlers with the dokuwiki's event controller
25     */
26    function register(&$controller) {
27        $controller->register_hook( 'JQUERY_READY', 'BEFORE', $this, '_addjs' );
28        $controller->register_hook( 'TPL_METAHEADER_OUTPUT', 'BEFORE', $this, '_addscript' );
29    }
30
31    function _addjs(&$event, $param) {
32        global $ID;
33        $event->data[] = 'jQuery( \'DIV.pagename\' ).append( \'<div id="googleplusone" class="no"><g:plusone size="small"></g:plusone></div>\' );';
34    }
35
36    function _addscript( &$event, $param ) {
37        $event->data['script'][] = array(
38            'type' => 'text/javascript',
39            'charset' => 'utf-8',
40            '_data' => '{lang: \'en\'}',
41            'src' => 'https://apis.google.com/js/plusone.js',
42        );
43    }
44}