1<?php
2
3/* Facebook Like-Button Plugin for Dokuwiki
4 *
5 * Copyright (C) 2012 Marvin Thomas Rabe (marvinrabe.de)
6 *
7 * This program is free software; you can redistribute it and/or modify it under the terms
8 * of the GNU General Public License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along with this program;
16 * if not, see <http://www.gnu.org/licenses/>. */
17
18/**
19 * Embed facebook javascript onto any page
20 * @license GNU General Public License 3 <http://www.gnu.org/licenses/>
21 * @author Marvin Thomas Rabe <mrabe@marvinrabe.de>
22 */
23
24if(!defined('DOKU_INC')) die();
25if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
26require_once(DOKU_PLUGIN.'action.php');
27
28class action_plugin_facebooklike extends DokuWiki_Action_Plugin {
29
30	/**
31	 * General information about the plugin.
32	 */
33	function getInfo(){
34		return array(
35			'author' => 'Marvin Thomas Rabe',
36			'email'  => 'mrabe@marvinrabe.de',
37			'date'	 => '2012-06-06',
38			'name'	 => 'Facebook Like-Button',
39			'desc'	 => 'Adds Facebook like-buttons',
40			'url'	 => 'https://github.com/marvinrabe/dokuwiki-facebook',
41		);
42	}
43
44	/**
45	 * Register its handlers.
46	 */
47	function register(&$controller) {
48	    $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE',  $this, '_addHeaders');
49	}
50
51	/**
52	 * Adds the FBML JavaScript file to the header.
53	 */
54	function _addHeaders (&$event, $param) {
55		global $lang;
56
57		$event->data["script"][] = array (
58		  "type" => "text/javascript",
59		  "src" => '//connect.facebook.net/'.$this->getLang('fbml_language').'/all.js#xfbml=1',
60		);
61	}
62
63}
64