1 | <?php |
---|
2 | # ***** BEGIN LICENSE BLOCK ***** |
---|
3 | # |
---|
4 | # This file is part of Contribute, a plugin for Dotclear 2 |
---|
5 | # Copyright (C) 2008,2009,2010 Moe (http://gniark.net/) |
---|
6 | # |
---|
7 | # Contribute is free software; you can redistribute it and/or |
---|
8 | # modify it under the terms of the GNU General Public License v2.0 |
---|
9 | # as published by the Free Software Foundation. |
---|
10 | # |
---|
11 | # Contribute is distributed in the hope that it will be useful, |
---|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | # GNU General Public License for more details. |
---|
15 | # |
---|
16 | # You should have received a copy of the GNU General Public License |
---|
17 | # along with this program; if not, see <http://www.gnu.org/licenses/>. |
---|
18 | # |
---|
19 | # Icon (icon.png) is from Silk Icons : |
---|
20 | # <http://www.famfamfam.com/lab/icons/silk/> |
---|
21 | # |
---|
22 | # ***** END LICENSE BLOCK ***** |
---|
23 | |
---|
24 | if (!defined('DC_RC_PATH')) {return;} |
---|
25 | |
---|
26 | $core->addBehavior('initWidgets',array('contributeWidget','initWidgets')); |
---|
27 | |
---|
28 | /** |
---|
29 | @ingroup Contribute |
---|
30 | @brief Widget |
---|
31 | */ |
---|
32 | class contributeWidget |
---|
33 | { |
---|
34 | /** |
---|
35 | widget |
---|
36 | @param w <b>object</b> Widget |
---|
37 | */ |
---|
38 | public static function initWidgets($w) |
---|
39 | { |
---|
40 | $w->create('contribute',__('Contribute'),array('contributeWidget','show')); |
---|
41 | |
---|
42 | $w->contribute->setting('title',__('Title:').' ('.__('optional').')', |
---|
43 | __('Contribute'),'text'); |
---|
44 | |
---|
45 | $w->contribute->setting('text',__('Text:').' ('.__('optional').')', |
---|
46 | __('Write a post for this blog'),'text'); |
---|
47 | |
---|
48 | $w->contribute->setting('homeonly',__('Home page only'),false,'check'); |
---|
49 | } |
---|
50 | |
---|
51 | /** |
---|
52 | show widget |
---|
53 | @param w <b>object</b> Widget |
---|
54 | @return <b>string</b> XHTML |
---|
55 | */ |
---|
56 | public static function show(&$w) |
---|
57 | { |
---|
58 | global $core; |
---|
59 | |
---|
60 | if ($w->homeonly && $core->url->type != 'default') { |
---|
61 | return; |
---|
62 | } |
---|
63 | |
---|
64 | # output |
---|
65 | $header = (strlen($w->title) > 0) |
---|
66 | ? '<h2>'.html::escapeHTML($w->title).'</h2>' : null; |
---|
67 | $text = (strlen($w->text) > 0) |
---|
68 | ? '<p><a href="'.$core->blog->url.$core->url->getBase('contribute'). |
---|
69 | '">'.html::escapeHTML($w->text).'</a></p>' : null; |
---|
70 | |
---|
71 | return '<div class="contribute">'.$header.$text.'</div>'; |
---|
72 | } |
---|
73 | } |
---|
74 | ?> |
---|