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 | |
---|
28 | if (!defined('DC_RC_PATH')) {return;} |
---|
29 | |
---|
30 | $core->addBehavior('templateBeforeValue',array('AtReplyTpl','templateBeforeValue')); |
---|
31 | $core->addBehavior('templateAfterValue',array('AtReplyTpl','templateAfterValue')); |
---|
32 | |
---|
33 | $core->blog->settings->addNamespace('atreply'); |
---|
34 | |
---|
35 | if ($core->blog->settings->atreply->atreply_active) |
---|
36 | { |
---|
37 | $core->addBehavior('publicHeadContent',array('AtReplyTpl','publicHeadContent')); |
---|
38 | $core->addBehavior('publicCommentBeforeContent',array('AtReplyTpl','publicCommentBeforeContent')); |
---|
39 | } |
---|
40 | |
---|
41 | class AtReplyTpl |
---|
42 | { |
---|
43 | public static function templateBeforeValue($core,$v,$attr) |
---|
44 | { |
---|
45 | if ($v == 'CommentAuthorLink') |
---|
46 | { |
---|
47 | return('<span class="commentAuthor" '. |
---|
48 | 'id="atreply_<?php echo $_ctx->comments->comment_id; ?>" '. |
---|
49 | 'title="<?php echo(html::escapeHTML($_ctx->comments->comment_author)); ?>">'); |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | public static function templateAfterValue($core,$v,$attr) |
---|
54 | { |
---|
55 | if ($v == 'CommentAuthorLink') |
---|
56 | { |
---|
57 | return('</span>'); |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | public static function publicHeadContent($core) |
---|
62 | { |
---|
63 | $set = $core->blog->settings->atreply; |
---|
64 | |
---|
65 | $QmarkURL = $core->blog->getQmarkURL(); |
---|
66 | |
---|
67 | # personalized image |
---|
68 | if ((strlen($set->atreply_color) > 1) |
---|
69 | && (file_exists($core->blog->public_path.'/atReply/reply.png'))) |
---|
70 | { |
---|
71 | $image_url = $core->blog->settings->system->public_url. |
---|
72 | '/atReply/reply.png'; |
---|
73 | } |
---|
74 | else |
---|
75 | { |
---|
76 | # default image |
---|
77 | $image_url = $QmarkURL.'pf=atReply/img/reply.png'; |
---|
78 | } |
---|
79 | |
---|
80 | $entry_url = ''; |
---|
81 | |
---|
82 | # simple and efficient test on entry, from dcTemplate::SysIf()) |
---|
83 | if ($GLOBALS['_ctx']->posts !== null) |
---|
84 | { |
---|
85 | $entry_url = $GLOBALS['_ctx']->posts->getURL(); |
---|
86 | } |
---|
87 | |
---|
88 | $title = (($set->atreply_display_title) ? '1' : '0'); |
---|
89 | |
---|
90 | # Javascript |
---|
91 | echo( |
---|
92 | '<script type="text/javascript">'."\n". |
---|
93 | '//<![CDATA['."\n". |
---|
94 | 'var atReplyEntryURL = \''. |
---|
95 | html::escapeHTML($entry_url).'\';'."\n". |
---|
96 | 'var atReplyDisplayTitle = '.$title.';'."\n". |
---|
97 | 'var atReplyTitle = \''. |
---|
98 | html::escapeHTML(__('Reply to this comment by {author}')).'\';'."\n". |
---|
99 | 'var atReplyImage = \''.$image_url.'\';'."\n". |
---|
100 | 'var atReply_switch_text = \''. |
---|
101 | html::escapeHTML(__('Threaded comments')).'\';'."\n". |
---|
102 | 'var atReplyLink = \' <a href="#" title="\'+atReplyTitle+\'" class="at_reply_link">\'+'. |
---|
103 | '\'<img src="\'+atReplyImage+\'" alt="\'+atReplyTitle+\'" /> \'+'. |
---|
104 | '\'<span class="at_reply_title" style="display:none;">\'+'. |
---|
105 | 'atReplyTitle+\'</span></a>\';'."\n". |
---|
106 | 'var atreply_append = '.($set->atreply_append ? '1' : '0').';'."\n". |
---|
107 | 'var atreply_show_switch = '.($set->atreply_show_switch ? '1' : '0').';'."\n". |
---|
108 | '//]]>'."\n". |
---|
109 | '</script>'."\n" |
---|
110 | ); |
---|
111 | |
---|
112 | if ($set->atreply_append) |
---|
113 | { |
---|
114 | echo ( |
---|
115 | '<script type="text/javascript" src="'.$QmarkURL. |
---|
116 | 'pf=atReply/js/atReplyThread.js'.'"></script>'."\n". |
---|
117 | '<style type="text/css"> |
---|
118 | <!-- |
---|
119 | #atReplySwitch { |
---|
120 | margin:20px 10px 0 0; |
---|
121 | padding:0; |
---|
122 | float:right; |
---|
123 | color:#999999; |
---|
124 | font-style:italic; |
---|
125 | } |
---|
126 | .repliedCmt, .replyCmt { |
---|
127 | border-left: 1px solid #666; |
---|
128 | } |
---|
129 | dd.repliedCmt, dd.replyCmt { |
---|
130 | border-bottom: 1px solid #666; |
---|
131 | } |
---|
132 | --> |
---|
133 | </style>'."\n" |
---|
134 | ); |
---|
135 | } |
---|
136 | |
---|
137 | echo('<script type="text/javascript" src="'.$QmarkURL. |
---|
138 | 'pf=atReply/js/atReply.js'.'"></script>'."\n"); |
---|
139 | } |
---|
140 | |
---|
141 | public static function publicCommentBeforeContent($core,$ctx) |
---|
142 | { |
---|
143 | echo '<span id="atReplyComment'.$ctx->comments->f('comment_id'). |
---|
144 | '" style="display:none;"></span>'; |
---|
145 | } |
---|
146 | } |
---|
147 | |
---|
148 | ?> |
---|