]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/FacebookLike.php
New FSF address
[SourceForge/phpwiki.git] / lib / plugin / FacebookLike.php
1 <?php // -*-php-*-
2 // $Id$
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         return _("Display a Facebook Like button. See http://developers.facebook.com/docs/reference/plugins/like");
36     }
37
38     function getDefaultArguments() {
39         return array('width'       => 450,
40                      'height'      => 35,
41                      //'title'       => '',    // override $TITLE (i.e. pagename)
42                      'colorscheme' => 'light', // or "dark"
43                      'show_faces'  => "false",
44                      'layout'      => "standard", // or "button_count"
45                      'action'      => "like",   // or "recommend"
46                      );
47     }
48
49     function run($dbi, $argstr, &$request, $basepage) {
50         $args = $this->getArgs($argstr, $request);
51         extract($args);
52         
53         //$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>";
54         $urlargs = array(
55                          "layout"     => $layout,
56                          "show_faces" => $show_faces,
57                          "width"      => $width,
58                          "action"     => "like", // or "recommend"
59                          "colorscheme"=> $colorscheme,
60                          "height"     => $height
61                          );
62         $pagename = $request->getArg('pagename');
63         $url = "http://www.facebook.com/plugins/like.php?"
64              . "href=" . urlencode(WikiUrl($pagename,$urlargs,true));
65         $url = str_replace("%3D","=",$url);
66         $params = array("src"               => $url,
67                         "scrolling"         => 'no',
68                         "frameborder"       => '0',
69                         "style"             => "border:none; overflow:hidden; "
70                                              . "width:$width"."px; height:$height"."px;",
71                         "allowtransparency" => "true");
72         return HTML::iframe($params);
73     }
74 };
75
76 // Local Variables:
77 // mode: php
78 // tab-width: 8
79 // c-basic-offset: 4
80 // c-hanging-comment-ender-p: nil
81 // indent-tabs-mode: nil
82 // End:
83 ?>