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_CONTEXT_ADMIN')) {return;} |
---|
29 | |
---|
30 | l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/admin'); |
---|
31 | |
---|
32 | $core->addBehavior('adminAfterCommentDesc', |
---|
33 | array('AtReplyAdmin','adminAfterCommentDesc')); |
---|
34 | $core->addBehavior('adminBeforeCommentCreate', |
---|
35 | array('AtReplyAdmin','adminBeforeCommentCreate')); |
---|
36 | |
---|
37 | $core->addBehavior('adminAfterCommentCreate', |
---|
38 | array('AtReplyAdmin','adminAfterCommentCreate')); |
---|
39 | |
---|
40 | $_menu['Plugins']->addItem(__('@ Reply'),'plugin.php?p=atReply', |
---|
41 | 'index.php?pf=atReply/icon.png',preg_match('/plugin.php\?p=atReply(&.*)?$/', |
---|
42 | $_SERVER['REQUEST_URI']),$core->auth->check('admin',$core->blog->id)); |
---|
43 | |
---|
44 | class AtReplyAdmin |
---|
45 | { |
---|
46 | /** |
---|
47 | adminAfterCommentDesc behavior |
---|
48 | display information on the admin comment form |
---|
49 | @param rs <b>recordset</b> Recordset |
---|
50 | @return <b>string</b> String |
---|
51 | */ |
---|
52 | public static function adminAfterCommentDesc($rs) |
---|
53 | { |
---|
54 | # ignore trackbacks |
---|
55 | if ($rs->comment_trackback == 1) {return;} |
---|
56 | |
---|
57 | # on comment.php, tell the user what to do |
---|
58 | if (strpos($_SERVER['REQUEST_URI'],'comment.php') !== false) |
---|
59 | { |
---|
60 | if (isset($_GET['at_reply_creaco'])) |
---|
61 | { |
---|
62 | return('<p class="message">'.__('@ Reply:').' '. |
---|
63 | __('Comment has been successfully created.').' '. |
---|
64 | __('Please edit and publish it.'). |
---|
65 | '</p>'); |
---|
66 | } |
---|
67 | # don't display the form on comment.php, it would break the <form> |
---|
68 | return; |
---|
69 | } |
---|
70 | |
---|
71 | global $core; |
---|
72 | |
---|
73 | $comment_content = '<p>@<a href="#c'. |
---|
74 | html::escapeHTML($rs->comment_id).'">'. |
---|
75 | html::escapeHTML($rs->comment_author).'</a>: </p>'; |
---|
76 | |
---|
77 | return( |
---|
78 | # from /dotclear/admin/post.php, modified |
---|
79 | '<form action="comment.php" method="post">'. |
---|
80 | form::hidden('comment_author',html::escapeHTML($core->auth->getInfo('user_cn'))). |
---|
81 | form::hidden('comment_email',html::escapeHTML($core->auth->getInfo('user_email'))). |
---|
82 | form::hidden('comment_site',html::escapeHTML($core->auth->getInfo('user_url'))). |
---|
83 | form::hidden('comment_content',html::escapeHTML($comment_content)). |
---|
84 | form::hidden('comment_atreply_comment_status',-1). |
---|
85 | form::hidden('post_id',$rs->post_id). |
---|
86 | form::hidden('go_to_the_comment',1). |
---|
87 | $core->formNonce(). |
---|
88 | '<p><strong>'.__('@ Reply:').'</strong> '. |
---|
89 | '<input type="submit" name="add" value="'. |
---|
90 | __('reply to this comment').'" /></p>'. |
---|
91 | '</form>' |
---|
92 | # /from /dotclear/admin/post.php, modified |
---|
93 | ); |
---|
94 | } |
---|
95 | |
---|
96 | /** |
---|
97 | adminBeforeCommentCreate behavior |
---|
98 | @param cur <b>cursor</b> Cursor |
---|
99 | */ |
---|
100 | public static function adminBeforeCommentCreate($cur) |
---|
101 | { |
---|
102 | if (isset($_POST['comment_atreply_comment_status'])) |
---|
103 | { |
---|
104 | $cur->comment_status = (integer) $_POST['comment_atreply_comment_status']; |
---|
105 | } |
---|
106 | } |
---|
107 | |
---|
108 | /** |
---|
109 | adminAfterCommentCreate behavior |
---|
110 | directly edit the comment |
---|
111 | @param cur <b>cursor</b> Cursor |
---|
112 | @param comment_id <b>integer</b> Comment id |
---|
113 | */ |
---|
114 | public static function adminAfterCommentCreate($cur,$comment_id) |
---|
115 | { |
---|
116 | if (isset($_POST['go_to_the_comment'])) |
---|
117 | { |
---|
118 | http::redirect('comment.php?id='.$comment_id.'&at_reply_creaco=1'); |
---|
119 | } |
---|
120 | } |
---|
121 | } |
---|
122 | |
---|
123 | ?> |
---|