[ Index ] |
|
Code source de Dotclear 2.0-beta6 |
1 <?php 2 # ***** BEGIN LICENSE BLOCK ***** 3 # This file is part of DotClear. 4 # Copyright (c) 2005 Olivier Meunier and contributors. All rights 5 # reserved. 6 # 7 # DotClear is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # DotClear is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with DotClear; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 # 21 # ***** END LICENSE BLOCK ***** 22 23 #if (isset($_GET['dcxd'])) { 24 # $_COOKIE['dcxd'] = $_GET['dcxd']; 25 #} 26 27 require dirname(__FILE__).'/../inc/admin/prepend.php'; 28 29 $core->rest->addFunction('getPostById',array('dcRestMethods','getPostById')); 30 $core->rest->addFunction('getCommentById',array('dcRestMethods','getCommentById')); 31 32 $core->rest->serve(); 33 34 /* Common REST methods */ 35 class dcRestMethods 36 { 37 public static function getPostById(&$core,$get) 38 { 39 if (empty($get['id'])) { 40 throw new Exception('No post ID'); 41 } 42 43 $rs = $core->blog->getPosts(array('post_id' => (integer) $get['id'])); 44 45 if ($rs->isEmpty()) { 46 throw new Exception('No post for this ID'); 47 } 48 49 $rsp = new xmlTag('post'); 50 $rsp->id = $rs->post_id; 51 52 $rsp->blog_id($rs->blog_id); 53 $rsp->user_id($rs->user_id); 54 $rsp->cat_id($rs->cat_id); 55 $rsp->post_dt($rs->post_dt); 56 $rsp->post_creadt($rs->post_creadt); 57 $rsp->post_upddt($rs->post_upddt); 58 $rsp->post_format($rs->post_format); 59 $rsp->post_url($rs->post_url); 60 $rsp->post_lang($rs->post_lang); 61 $rsp->post_title($rs->post_title); 62 $rsp->post_excerpt($rs->post_excerpt); 63 $rsp->post_excerpt_xhtml($rs->post_excerpt_xhtml); 64 $rsp->post_content($rs->post_content); 65 $rsp->post_content_xhtml($rs->post_content_xhtml); 66 $rsp->post_notes($rs->post_notes); 67 $rsp->post_status($rs->post_status); 68 $rsp->post_selected($rs->post_selected); 69 $rsp->post_open_comment($rs->post_open_comment); 70 $rsp->post_open_tb($rs->post_open_tb); 71 $rsp->nb_comment($rs->nb_comment); 72 $rsp->nb_trackback($rs->nb_trackback); 73 $rsp->user_name($rs->user_name); 74 $rsp->user_firstname($rs->user_firstname); 75 $rsp->user_displayname($rs->user_displayname); 76 $rsp->user_email($rs->user_email); 77 $rsp->user_url($rs->user_url); 78 $rsp->cat_title($rs->cat_title); 79 $rsp->cat_url($rs->cat_url); 80 81 $rsp->post_display_content($rs->getContent(true)); 82 $rsp->post_display_excerpt($rs->getExcerpt(true)); 83 84 $metaTag = new xmlTag('meta'); 85 if (($meta = @unserialize($rs->post_meta)) !== false) 86 { 87 foreach ($meta as $K => $V) 88 { 89 foreach ($V as $v) { 90 $metaTag->$K($v); 91 } 92 } 93 } 94 $rsp->post_meta($metaTag); 95 96 return $rsp; 97 } 98 99 public static function getCommentById(&$core,$get) 100 { 101 if (empty($get['id'])) { 102 throw new Exception('No comment ID'); 103 } 104 105 $rs = $core->blog->getComments(array('comment_id' => (integer) $get['id'])); 106 107 if ($rs->isEmpty()) { 108 throw new Exception('No comment for this ID'); 109 } 110 111 $rsp = new xmlTag('post'); 112 $rsp->id = $rs->comment_id; 113 114 $rsp->comment_dt($rs->comment_dt); 115 $rsp->comment_upddt($rs->comment_upddt); 116 $rsp->comment_author($rs->comment_author); 117 $rsp->comment_site($rs->comment_site); 118 $rsp->comment_content($rs->comment_content); 119 $rsp->comment_trackback($rs->comment_trackback); 120 $rsp->comment_status($rs->comment_status); 121 $rsp->post_title($rs->post_title); 122 $rsp->post_url($rs->post_url); 123 $rsp->post_id($rs->post_id); 124 $rsp->post_dt($rs->post_dt); 125 $rsp->user_id($rs->user_id); 126 127 $rsp->comment_display_content($rs->getContent(true)); 128 129 if ($core->auth->userID()) { 130 $rsp->comment_ip($rs->comment_ip); 131 $rsp->comment_email($rs->comment_email); 132 # --BEHAVIOR-- adminAfterCommentDesc 133 $rsp->comment_spam_disp($core->callBehavior('adminAfterCommentDesc', $rs)); 134 } 135 136 return $rsp; 137 } 138 } 139 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Feb 23 22:16:06 2007 | par Balluche grâce à PHPXref 0.7 |