]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/FacebookLike.php
Initialize $html
[SourceForge/phpwiki.git] / lib / plugin / FacebookLike.php
1 <?php
2
3 /*
4  * Copyright 2010 Reini Urban
5  *
6  * This file is part of PhpWiki.
7  *
8  * PhpWiki is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * PhpWiki is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 /**
24 Optional opengraph page meta data to be added to head.tmpl:
25 og:title - The title of your page; if not specified, the title element will be used.
26 og:site_name - The name of your web site, e.g., "CNN" or "IMDb".
27 og:image - The URL of the best picture for this page. The image must be at least
28 50px by 50px and have a maximum aspect ratio of 3:1.
29  */
30
31 class WikiPlugin_FacebookLike
32     extends WikiPlugin
33 {
34     function getDescription()
35     {
36         return _("Display a Facebook Like button.");
37     }
38
39     function getDefaultArguments()
40     {
41         return array('width' => 450,
42             'height' => 35,
43             //'title'       => '',    // override $TITLE (i.e. pagename)
44             'colorscheme' => 'light', // or "dark"
45             'show_faces' => "false",
46             'layout' => "standard", // or "button_count"
47             'action' => "like", // or "recommend"
48         );
49     }
50
51     function run($dbi, $argstr, &$request, $basepage)
52     {
53         $args = $this->getArgs($argstr, $request);
54         extract($args);
55
56         //$iframe = "<iframe src=\"http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fexample.com%2Fpage%2Fto%2Flike&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;\" allowTransparency=\"true\"></iframe>";
57         $urlargs = array(
58             "layout" => $layout,
59             "show_faces" => $show_faces,
60             "width" => $width,
61             "action" => "like", // or "recommend"
62             "colorscheme" => $colorscheme,
63             "height" => $height
64         );
65         $pagename = $request->getArg('pagename');
66         $url = "http://www.facebook.com/plugins/like.php?"
67             . "href=" . urlencode(WikiUrl($pagename, $urlargs, true));
68         $url = str_replace("%3D", "=", $url);
69         $params = array("src" => $url,
70             "scrolling" => 'no',
71             "frameborder" => '0',
72             "style" => "border:none; overflow:hidden; "
73                 . "width:$width" . "px; height:$height" . "px;",
74             "allowtransparency" => "true");
75         return HTML::iframe($params);
76     }
77 }
78
79 // Local Variables:
80 // mode: php
81 // tab-width: 8
82 // c-basic-offset: 4
83 // c-hanging-comment-ender-p: nil
84 // indent-tabs-mode: nil
85 // End: