Dotclear

source: plugins/atReply/_public.php @ 2459

Revision 2459, 4.4 KB checked in by Moe, 13 years ago (diff)

@ Reply 1.4.5: fixed bug with Contribute (thanks to bebr)

Line 
1<?php 
2# ***** BEGIN LICENSE BLOCK *****
3#
4# This file is part of @ Reply, a plugin for Dotclear 2
5# Copyright (C) 2008,2009,2010 Moe (http://gniark.net/) and buns
6#
7# @ Reply 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# @ Reply 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
17# License along with this program. If not, see
18# <http://www.gnu.org/licenses/>.
19#
20# Icon (icon.png) and images are from Silk Icons :
21# <http://www.famfamfam.com/lab/icons/silk/>
22#
23# Inspired by @ Reply for WordPress :
24# <http://iyus.info/at-reply-petit-plugin-wordpress-inspire-par-twitter/>
25#
26# ***** END LICENSE BLOCK *****
27
28if (!defined('DC_RC_PATH')) {return;}
29
30$core->addBehavior('templateBeforeValue',array('AtReplyTpl','templateBeforeValue'));
31$core->addBehavior('templateAfterValue',array('AtReplyTpl','templateAfterValue'));
32
33if ($core->blog->settings->atreply_active)
34{
35     $core->addBehavior('publicHeadContent',array('AtReplyTpl','publicHeadContent'));
36     $core->addBehavior('publicCommentBeforeContent',array('AtReplyTpl','publicCommentBeforeContent'));
37}
38
39class AtReplyTpl
40{
41     public static function templateBeforeValue($core,$v,$attr)
42     {
43          if ($v == 'CommentAuthorLink')
44          {
45               return('<span class="commentAuthor" '.
46                    'id="atreply_<?php echo $_ctx->comments->comment_id; ?>" '.
47                    'title="<?php echo(html::escapeHTML($_ctx->comments->comment_author)); ?>">');
48          }
49     }
50
51     public static function templateAfterValue($core,$v,$attr)
52     {
53          if ($v == 'CommentAuthorLink')
54          {
55               return('</span>');
56          }
57     }
58     
59     public static function publicHeadContent($core)
60     {
61          $set = $core->blog->settings;
62         
63          $QmarkURL = $core->blog->getQmarkURL();
64         
65          # personalized image
66          if ((strlen($set->atreply_color) > 1)
67               && (file_exists($core->blog->public_path.'/atReply/reply.png')))
68          {
69               $image_url = $set->public_url.'/atReply/reply.png';
70          }
71          else
72          {
73               # default image
74               $image_url = $QmarkURL.'pf=atReply/img/reply.png';
75          }
76         
77          $entry_url = '';
78          # simple and effective test on entry, from dcTemplate::SysIf())
79          if (($GLOBALS['_ctx']->posts !== null)
80               # avoid errors with Contribute
81               && (method_exists($GLOBALS['_ctx']->posts,'getURL')))
82          {
83               $entry_url = $GLOBALS['_ctx']->posts->getURL();
84          }
85         
86          $title = (($set->atreply_display_title) ? 'true' : 'false');
87         
88          # Javascript
89          echo(
90               '<script type="text/javascript">'."\n".
91               '//<![CDATA['."\n".
92               'var atReplyEntryURL = \''.
93                    html::escapeHTML($entry_url).'\';'."\n".
94               'var atReplyDisplayTitle = new Boolean('.$title.');'."\n".
95               'var atReplyTitle = \''.
96                    html::escapeHTML(__('Reply to this comment')).'\';'."\n".
97               'var atReplyImage = \''.$image_url.'\';'."\n".
98               'var atReply_switch_text = \''.
99                    html::escapeHTML(__('Threaded comments')).'\';'."\n".
100               'var atReplyLink = \' <a href="#" title="\'+atReplyTitle+\'" class="at_reply_link">\'+'.
101               '\'<img src="\'+atReplyImage+\'" alt="\'+atReplyTitle+\'" /> \'+'.
102               '\'<span class="at_reply_title" style="display:none;">\'+'.
103                    'atReplyTitle+\'</span></a>\';'."\n".
104               'var atreply_append = '.($set->atreply_append ? '1' : '0').';'."\n".
105               'var atreply_show_switch = '.($set->atreply_show_switch ? '1' : '0').';'."\n".
106               '//]]>'."\n".
107               '</script>'."\n"
108          );
109         
110          if ($set->atreply_append)
111          {
112               echo ( 
113                    '<script type="text/javascript" src="'.$QmarkURL.
114                    'pf=atReply/js/atReplyThread.js'.'"></script>'."\n".
115                    '<style type="text/css">
116                    <!--
117                    #atReplySwitch {
118                         margin:20px 10px 0 0;
119                         padding:0;
120                         float:right;   
121                         color:#999999;
122                         font-style:italic;
123                    }
124                    .repliedCmt, .replyCmt {
125                         border-left: 1px solid #666;
126                    }
127                    dd.repliedCmt, dd.replyCmt  {
128                         border-bottom: 1px solid #666;
129                    }
130                    -->
131                    </style>'."\n"
132               );
133          }
134         
135          echo('<script type="text/javascript" src="'.$QmarkURL.
136               'pf=atReply/js/atReply.js'.'"></script>'."\n");
137     }
138     
139     public static function publicCommentBeforeContent($core,$ctx)
140     {
141               echo '<span id="atReplyComment'.$ctx->comments->f('comment_id').
142                    '" style="display:none;"></span>';
143     }
144}
145
146?>
Note: See TracBrowser for help on using the repository browser.

Sites map