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 | l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/public'); |
---|
27 | |
---|
28 | # template tags |
---|
29 | require_once(dirname(__FILE__).'/inc/lib.contribute.tpl.php'); |
---|
30 | |
---|
31 | $core->tpl->addValue('ContributeMessage', |
---|
32 | array('contributeTpl','ContributeMessage')); |
---|
33 | |
---|
34 | $core->tpl->addValue('ContributeHelp', |
---|
35 | array('contributeTpl','ContributeHelp')); |
---|
36 | |
---|
37 | $core->tpl->addBlock('ContributePreview', |
---|
38 | array('contributeTpl','ContributePreview')); |
---|
39 | $core->tpl->addBlock('ContributeForm', |
---|
40 | array('contributeTpl','ContributeForm')); |
---|
41 | |
---|
42 | $core->tpl->addBlock('ContributeIf', |
---|
43 | array('contributeTpl','ContributeIf')); |
---|
44 | $core->tpl->addBlock('ContributeIfNameAndEmailAreNotRequired', |
---|
45 | array('contributeTpl','ContributeIfNameAndEmailAreNotRequired')); |
---|
46 | |
---|
47 | $core->tpl->addBlock('ContributeFormaters', |
---|
48 | array('contributeTpl','ContributeFormaters')); |
---|
49 | |
---|
50 | $core->tpl->addValue('ContributeFormat', |
---|
51 | array('contributeTpl','ContributeFormat')); |
---|
52 | |
---|
53 | $core->tpl->addValue('ContributeEntryExcerpt', |
---|
54 | array('contributeTpl','ContributeEntryExcerpt')); |
---|
55 | $core->tpl->addValue('ContributeEntryContent', |
---|
56 | array('contributeTpl','ContributeEntryContent')); |
---|
57 | |
---|
58 | $core->tpl->addBlock('ContributeIfSelected', |
---|
59 | array('contributeTpl','ContributeIfSelected')); |
---|
60 | |
---|
61 | $core->tpl->addValue('ContributeCategoryID', |
---|
62 | array('contributeTpl','ContributeCategoryID')); |
---|
63 | |
---|
64 | $core->tpl->addValue('ContributeCategorySpacer', |
---|
65 | array('contributeTpl','ContributeCategorySpacer')); |
---|
66 | |
---|
67 | $core->tpl->addBlock('ContributeEntryTagsFilter', |
---|
68 | array('contributeTpl','ContributeEntryTagsFilter')); |
---|
69 | |
---|
70 | $core->tpl->addBlock('ContributeEntryMyMeta', |
---|
71 | array('contributeTpl','ContributeEntryMyMeta')); |
---|
72 | |
---|
73 | $core->tpl->addBlock('ContributeEntryMyMetaIf', |
---|
74 | array('contributeTpl','ContributeEntryMyMetaIf')); |
---|
75 | |
---|
76 | $core->tpl->addBlock('ContributeEntryMyMetaIfChecked', |
---|
77 | array('contributeTpl','ContributeEntryMyMetaIfChecked')); |
---|
78 | |
---|
79 | |
---|
80 | $core->tpl->addValue('ContributeEntryMyMetaValue', |
---|
81 | array('contributeTpl','ContributeEntryMyMetaValue')); |
---|
82 | |
---|
83 | $core->tpl->addBlock('ContributeEntryMyMetaValues', |
---|
84 | array('contributeTpl','ContributeEntryMyMetaValues')); |
---|
85 | $core->tpl->addValue('ContributeEntryMyMetaValuesID', |
---|
86 | array('contributeTpl','ContributeEntryMyMetaValuesID')); |
---|
87 | $core->tpl->addValue('ContributeEntryMyMetaValuesDescription', |
---|
88 | array('contributeTpl','ContributeEntryMyMetaValuesDescription')); |
---|
89 | |
---|
90 | $core->tpl->addValue('ContributeEntryMyMetaID', |
---|
91 | array('contributeTpl','ContributeEntryMyMetaID')); |
---|
92 | $core->tpl->addValue('ContributeEntryMyMetaPrompt', |
---|
93 | array('contributeTpl','ContributeEntryMyMetaPrompt')); |
---|
94 | |
---|
95 | $core->tpl->addValue('ContributeEntryNotes', |
---|
96 | array('contributeTpl','ContributeEntryNotes')); |
---|
97 | |
---|
98 | $core->addBehavior('coreBlogGetPosts',array('contributeBehaviors', |
---|
99 | 'coreBlogGetPosts')); |
---|
100 | |
---|
101 | /** |
---|
102 | @ingroup Contribute |
---|
103 | @brief Behaviors |
---|
104 | @see planet/public.php |
---|
105 | */ |
---|
106 | class contributeBehaviors |
---|
107 | { |
---|
108 | public static function coreBlogGetPosts($rs) |
---|
109 | { |
---|
110 | if ($GLOBALS['core']->blog->settings->contribute->contribute_active) |
---|
111 | { |
---|
112 | $rs->extend('rsExtContributePosts'); |
---|
113 | } |
---|
114 | } |
---|
115 | } |
---|
116 | |
---|
117 | /** |
---|
118 | @ingroup Contribute |
---|
119 | @brief Extend posts |
---|
120 | |
---|
121 | EntryAuthorDisplayName and EntryAuthorURL can't be modified |
---|
122 | |
---|
123 | @see planet/public.php |
---|
124 | */ |
---|
125 | class rsExtContributePosts extends rsExtPostPublic |
---|
126 | { |
---|
127 | /** |
---|
128 | Get metadata of Contribute |
---|
129 | @param rs <b>recordset</b> Recordset |
---|
130 | @param info <b>str</b> Information |
---|
131 | @return <b>string</b> Value |
---|
132 | */ |
---|
133 | public static function contributeInfo($rs,$info) |
---|
134 | { |
---|
135 | $rs = dcMeta::getMetaRecord($rs->core,$rs->post_meta,'contribute_'.$info); |
---|
136 | if (!$rs->isEmpty()) |
---|
137 | { |
---|
138 | return $rs->meta_id; |
---|
139 | } |
---|
140 | # else |
---|
141 | return; |
---|
142 | } |
---|
143 | |
---|
144 | /** |
---|
145 | getAuthorLink |
---|
146 | @param rs <b>recordset</b> Recordset |
---|
147 | @return <b>string</b> String |
---|
148 | */ |
---|
149 | public static function getAuthorLink($rs) |
---|
150 | { |
---|
151 | $author = $rs->contributeInfo('author'); |
---|
152 | $site = $rs->contributeInfo('site'); |
---|
153 | |
---|
154 | # default display |
---|
155 | if (empty($author)) |
---|
156 | { |
---|
157 | return(parent::getAuthorLink($rs)); |
---|
158 | } |
---|
159 | else |
---|
160 | { |
---|
161 | $author_format = |
---|
162 | (string) $GLOBALS['core']->blog->settings->contribute->contribute_author_format; |
---|
163 | |
---|
164 | if (empty($author_format)) {$author_format = '%s';} |
---|
165 | |
---|
166 | if (!empty($site)) |
---|
167 | { |
---|
168 | $str = sprintf($author_format,'<a href="'.$site.'">'.$author.'</a>'); |
---|
169 | } |
---|
170 | else |
---|
171 | { |
---|
172 | $str = sprintf($author_format,$author); |
---|
173 | } |
---|
174 | return $str; |
---|
175 | } |
---|
176 | } |
---|
177 | |
---|
178 | /** |
---|
179 | getAuthorCN |
---|
180 | @param rs <b>recordset</b> Recordset |
---|
181 | @return <b>string</b> String |
---|
182 | */ |
---|
183 | public static function getAuthorCN($rs) |
---|
184 | { |
---|
185 | $author = $rs->contributeInfo('author'); |
---|
186 | if (empty($author)) |
---|
187 | { |
---|
188 | # default display |
---|
189 | return(parent::getAuthorCN($rs)); |
---|
190 | } else { |
---|
191 | $author_format = $GLOBALS['core']->blog->settings->contribute_author_format; |
---|
192 | |
---|
193 | if (empty($author_format)) {$author_format = '%s';} |
---|
194 | |
---|
195 | return sprintf($author_format,$author); |
---|
196 | } |
---|
197 | } |
---|
198 | |
---|
199 | /** |
---|
200 | getAuthorEmail |
---|
201 | @param rs <b>recordset</b> Recordset |
---|
202 | @param encoded <b>boolean</b> Return encoded email address ? |
---|
203 | @return <b>string</b> String |
---|
204 | */ |
---|
205 | public static function getAuthorEmail($rs,$encoded=true) |
---|
206 | { |
---|
207 | $mail = $rs->contributeInfo('mail'); |
---|
208 | if (empty($mail)) |
---|
209 | { |
---|
210 | # default display |
---|
211 | return(parent::getAuthorEmail($rs,$encoded)); |
---|
212 | } else { |
---|
213 | if ($encoded) { |
---|
214 | return strtr($mail,array('@'=>'%40','.'=>'%2e')); |
---|
215 | } |
---|
216 | # else |
---|
217 | return $email; |
---|
218 | } |
---|
219 | } |
---|
220 | |
---|
221 | /** |
---|
222 | getAuthorURL |
---|
223 | @param rs <b>recordset</b> Recordset |
---|
224 | @return <b>string</b> String |
---|
225 | */ |
---|
226 | public static function getAuthorURL($rs) |
---|
227 | { |
---|
228 | $mail = $rs->contributeInfo('site'); |
---|
229 | if (empty($mail)) |
---|
230 | { |
---|
231 | # default display |
---|
232 | return(parent::getAuthorEmail($rs,$encoded)); |
---|
233 | } else { |
---|
234 | if ($encoded) { |
---|
235 | return strtr($mail,array('@'=>'%40','.'=>'%2e')); |
---|
236 | } |
---|
237 | # else |
---|
238 | return $email; |
---|
239 | } |
---|
240 | } |
---|
241 | } |
---|
242 | ?> |
---|