Dotclear

source: plugins/contribute/_public.php @ 2176

Revision 2176, 6.1 KB checked in by Moe, 14 years ago (diff)

Contribute 1.0-alpha25 :

  • added a filter against Javascript injections
  • check installed and active plugins
  • display more info on post
  • removed unused code
  • switched to GPL v2 (previous commit [2172]])
Line 
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
24if (!defined('DC_RC_PATH')) {return;}
25
26l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/public');
27
28# template tags
29require_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->addValue('ContributeEntryMyMetaValue',
77     array('contributeTpl','ContributeEntryMyMetaValue'));
78
79$core->tpl->addBlock('ContributeEntryMyMetaValues',
80     array('contributeTpl','ContributeEntryMyMetaValues'));
81$core->tpl->addValue('ContributeEntryMyMetaValuesID',
82     array('contributeTpl','ContributeEntryMyMetaValuesID'));
83$core->tpl->addValue('ContributeEntryMyMetaValuesDescription',
84     array('contributeTpl','ContributeEntryMyMetaValuesDescription'));
85     
86$core->tpl->addValue('ContributeEntryMyMetaID',
87     array('contributeTpl','ContributeEntryMyMetaID'));
88$core->tpl->addValue('ContributeEntryMyMetaPrompt',
89     array('contributeTpl','ContributeEntryMyMetaPrompt'));
90     
91$core->tpl->addValue('ContributeEntryNotes',
92     array('contributeTpl','ContributeEntryNotes'));
93
94$core->addBehavior('coreBlogGetPosts',array('contributeBehaviors',
95     'coreBlogGetPosts'));
96
97/**
98@ingroup Contribute
99@brief Behaviors
100@see planet/public.php
101*/
102class contributeBehaviors
103{
104     public static function coreBlogGetPosts(&$rs)
105     {
106          if (!$GLOBALS['core']->blog->settings->contribute_active) {return;}
107          $rs->extend('rsExtContributePosts');
108     }
109}
110
111/**
112@ingroup Contribute
113@brief Extend posts
114
115EntryAuthorDisplayName and EntryAuthorURL can't be modified
116
117@see planet/public.php
118*/
119class rsExtContributePosts extends rsExtPostPublic
120{
121     /**
122     Get metadata of Contribute
123     @param    rs   <b>recordset</b>    Recordset
124     @param    info <b>str</b>     Information
125     @return   <b>string</b> Value
126     */
127     public static function contributeInfo(&$rs,$info)
128     {
129          $rs = dcMeta::getMetaRecord($rs->core,$rs->post_meta,'contribute_'.$info);
130          if (!$rs->isEmpty())
131          {
132               return $rs->meta_id;
133          }
134          # else
135          return;
136     }
137     
138     /**
139     getAuthorLink
140     @param    rs   <b>recordset</b>    Recordset
141     @return   <b>string</b> String
142     */
143     public static function getAuthorLink(&$rs)
144     {
145          $author = $rs->contributeInfo('author');
146          $site = $rs->contributeInfo('site');
147         
148          # default display
149          if (empty($author))
150          {
151               return(parent::getAuthorLink($rs));
152          }
153          else
154          {
155               $author_format = 
156                    $GLOBALS['core']->blog->settings->contribute_author_format;
157               
158               if (empty($author_format)) {$author_format = '%s';}
159               
160               if (!empty($site))
161               {
162                    $str = sprintf($author_format,'<a href="'.$site.'">'.$author.'</a>');
163               }
164               else
165               {
166                    $str = sprintf($author_format,$author);
167               }
168               return $str;
169          }
170     }
171     
172     /**
173     getAuthorCN
174     @param    rs   <b>recordset</b>    Recordset
175     @return   <b>string</b> String
176     */
177     public static function getAuthorCN(&$rs)
178     {
179          $author = $rs->contributeInfo('author');
180          if (empty($author))
181          {
182               # default display
183               return(parent::getAuthorCN($rs));
184          } else {
185               $author_format = $GLOBALS['core']->blog->settings->contribute_author_format;
186               
187               if (empty($author_format)) {$author_format = '%s';}
188               
189               return sprintf($author_format,$author);
190          }
191     }
192     
193     /**
194     getAuthorEmail
195     @param    rs   <b>recordset</b>    Recordset
196     @param    encoded   <b>boolean</b> Return encoded email address ?
197     @return   <b>string</b> String
198     */
199     public static function getAuthorEmail(&$rs,$encoded=true)
200     {
201          $mail = $rs->contributeInfo('mail');
202          if (empty($mail))
203          {
204               # default display
205               return(parent::getAuthorEmail($rs,$encoded));
206          } else {
207               if ($encoded) {
208                    return strtr($mail,array('@'=>'%40','.'=>'%2e'));
209               }
210               # else
211               return $email;
212          }
213     }
214     
215     /**
216     getAuthorURL
217     @param    rs   <b>recordset</b>    Recordset
218     @return   <b>string</b> String
219     */
220     public static function getAuthorURL(&$rs)
221     {
222          $mail = $rs->contributeInfo('site');
223          if (empty($mail))
224          {
225               # default display
226               return(parent::getAuthorEmail($rs,$encoded));
227          } else {
228               if ($encoded) {
229                    return strtr($mail,array('@'=>'%40','.'=>'%2e'));
230               }
231               # else
232               return $email;
233          }
234     }
235}
236?>
Note: See TracBrowser for help on using the repository browser.

Sites map