1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
12 | if (!defined('DC_RC_PATH')) { return; } |
---|
13 | |
---|
14 | $core->addBehavior('xmlrpcGetPostInfo',array('tagsXMLRPCbehaviors','getPostInfo')); |
---|
15 | $core->addBehavior('xmlrpcAfterNewPost',array('tagsXMLRPCbehaviors','editPost')); |
---|
16 | $core->addBehavior('xmlrpcAfterEditPost',array('tagsXMLRPCbehaviors','editPost')); |
---|
17 | |
---|
18 | class tagsXMLRPCbehaviors |
---|
19 | { |
---|
20 | public static function getPostInfo($x,$type,$res) |
---|
21 | { |
---|
22 | $res =& $res[0]; |
---|
23 | |
---|
24 | $rs = $x->core->meta->getMetadata(array( |
---|
25 | 'meta_type' => 'tag', |
---|
26 | 'post_id' => $res['postid'])); |
---|
27 | |
---|
28 | $m = array(); |
---|
29 | while($rs->fetch()) { |
---|
30 | $m[] = $rs->meta_id; |
---|
31 | } |
---|
32 | |
---|
33 | $res['mt_keywords'] = implode(', ',$m); |
---|
34 | } |
---|
35 | |
---|
36 | # Same function for newPost and editPost |
---|
37 | public static function editPost($x,$post_id,$cur,$content,$struct,$publish) |
---|
38 | { |
---|
39 | # Check if we have mt_keywords in struct |
---|
40 | if (isset($struct['mt_keywords'])) |
---|
41 | { |
---|
42 | $x->core->meta->delPostMeta($post_id,'tag'); |
---|
43 | |
---|
44 | foreach ($x->core->meta->splitMetaValues($struct['mt_keywords']) as $m) { |
---|
45 | $x->core->meta->setPostMeta($post_id,'tag',$m); |
---|
46 | } |
---|
47 | } |
---|
48 | } |
---|
49 | } |
---|
50 | ?> |
---|