]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Echo/EchoPlugin.php
Update translator documentation.
[quix0rs-gnu-social.git] / plugins / Echo / EchoPlugin.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Plugin to add Echo/JS-Kit commenting to notice pages
6  *
7  * PHP version 5
8  *
9  * LICENCE: This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Affero General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @category  Plugin
23  * @package   StatusNet
24  * @author    Zach Copley <zach@status.net>
25  * @copyright 2010 StatusNet, Inc.
26  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27  * @link      http://status.net/
28  */
29
30 if (!defined('STATUSNET')) {
31     exit(1);
32 }
33
34 /**
35  * Plugin to use Echo (formerly JS-Kit)
36  *
37  * This plugin adds an Echo commenting widget to each notice page on
38  * your site.  To get it to work, first you'll have to sign up for Echo
39  * (a for-pay service) and register your site's URL.
40  *
41  *     http://aboutecho.com/
42  *
43  * Once you've done that it's pretty straight forward to turn the
44  * plugin on; just add this to your config.php:
45  *
46  *     addPlugin(
47  *        'Echo',
48  *        array('div_style' => 'width:675px; padding-top:10px; position:relative; float:left;')
49  *     );
50  *
51  * NOTE: the 'div_style' in an optional parameter that passes in some
52  * inline CSS when creating the Echo widget. It's a shortcut to make
53  * the widget look OK with the default StatusNet theme. If you leave
54  * it out you'll have to edit your theme CSS files to make the widget
55  * look good. You can also control the way the widget looks by
56  * adding style rules to your theme.
57  *
58  * See: http://wiki.js-kit.com/Skinning-Guide#UsingCSSnbsptocustomizefontsandcolors
59  *
60  * @category Plugin
61  * @package  StatusNet
62  * @author   Zach Copley <zach@status.net>
63  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
64  * @link     http://status.net/
65  *
66  * @see      Event
67  */
68 class EchoPlugin extends Plugin
69 {
70     // NOTE: The Echo documentation says that this script will change on
71     // a per site basis, but I think that's incorrect. It always seems to
72     // be the same.
73     public $script = 'http://cdn.js-kit.com/scripts/comments.js';
74
75     function onEndShowScripts($action)
76     {
77         if (get_class($action) == 'ShownoticeAction') {
78             $action->script($this->script);
79         }
80
81         return true;
82     }
83
84     function onEndShowContentBlock($action)
85     {
86         if (get_class($action) == 'ShownoticeAction') {
87
88             $attrs = array();
89             $attrs['class'] = 'js-kit-comments';
90             $attrs['permalink'] = $action->notice->uri;
91             $attrs['uniq'] = $action->notice->id;
92
93             // NOTE: there are some other attributes that could be useful
94             // http://wiki.js-kit.com/Echo-Behavior
95
96             if (!empty($this->div_style)) {
97                 $attrs['style'] = $this->div_style;
98             }
99
100             $action->element('div', $attrs, null);
101         }
102     }
103
104     function onPluginVersion(&$versions)
105     {
106         $versions[] = array('name' => 'Echo',
107                             'version' => STATUSNET_VERSION,
108                             'author' => 'Zach Copley',
109                             'homepage' => 'http://status.net/wiki/Plugin:Echo',
110                             'rawdescription' =>
111                             // TRANS: Plugin description.
112                             _m('Use <a href="http://aboutecho.com/">Echo</a>'.
113                                ' to add commenting to notice pages.'));
114         return true;
115     }
116 }