1<?php 2/** 3 * Plugin Goole+1 4 * 5 * @author Enrico Croce & Simona Burzio (staff@eiroca.net) 6 * @copyright Copyright (C) 2013-2019 eIrOcA - Enrico Croce & Simona Burzio 7 * @license GPL >=3 (http://www.gnu.org/licenses/) 8 * @version 19.02 9 * @link http://www.eiroca.net/doku_gplusone 10 */ 11if (!defined('DOKU_INC')) die(); 12if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); 13if (!defined('DOKU_PLUGIN_GPLUSONE')) define('DOKU_PLUGIN_GPLUSONE', DOKU_PLUGIN . 'gplusone/'); 14require_once (DOKU_PLUGIN . 'action.php'); 15 16class action_plugin_gplusone extends DokuWiki_Action_Plugin { 17 18 function register(Doku_Event_Handler $controller) { 19 $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'toolbar_add_button_gplusone', array ()); 20 $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'gplus_script'); 21 } 22 23 function toolbar_add_button_gplusone(&$event, $param) { 24 $event->data[] = array ( 25 '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' => '~~' 26 ); 27 } 28 29 function gplus_script(&$event, $param) { 30 global $ID; 31 global $conf; 32 $end_date = mktime(0, 0, 0, 3, 1, 2019); 33 if (($end_date - time()) > 0) { 34 if (plugin_isdisabled('translation') || (!$translation = plugin_load('helper', 'translation'))) { 35 $lang = $conf['lang']; 36 } 37 else { 38 $lang = $translation->getLangPart($ID); 39 } 40 $event->data['script'][] = array ( 41 '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);})();" 42 ); 43 } 44 } 45 46} 47?> 48