OSDN Git Service

5b8a1d0c38cde0d38774ad17a35c1b7ed67e73d0
[embrj/master.git] / ajax / status.php
1 <?php
2         // ver 0.2 by @Chris_Ys
3         if(!isset($_SESSION)){
4                 session_start();
5         }
6         include_once("../lib/twitese.php");
7
8         if(isset($_GET['id']) && isset($_GET['uid'])){
9                 $t = getTwitter();
10                 $user_id = $_GET['uid'];
11                 $reply_to_id = "";
12                 $html = '<div class="ajax_form round">';
13                 $html .= "<a class=\"close\" title=\"Close\" onclick=\"$(this).parent().slideToggle(300);\" href=\"#\"></a>";
14                 $html .= '<ol>';
15                 $html .= formatConversation($_GET['id']);
16                 $html .= '</ol></div>';
17                 echo $html;
18         }else{
19                 echo 'error';
20         }
21
22         function formatConversation($status_id){
23                 GLOBAL $t;
24                 GLOBAL $user_id;
25                 GLOBAL $reply_to_id;
26                 $status = $t->showStatus($status_id);
27                 if(!isset($status->user)){
28                         return "";
29                 }
30                 $user = $status->user;
31                 if($reply_to_id == ""){
32                         $reply_to_id = $user->id;
33                 }
34                 $date = format_time($status->created_at);
35                 $text = formatEntities($status->entities,$status->text);
36                 $end = (!isset($status->in_reply_to_user_id) || ($user_id != $status->in_reply_to_user_id && $reply_to_id != $status->in_reply_to_user_id));
37                 $html = '<li class="round">
38                         <span class="status_author">
39                         <a href="user.php?id='.$user->screen_name.'" target="_blank"><img src="'.getAvatar($user->profile_image_url).'" style="height: 30px; width: 30px;"></a>
40                         </span>
41                         <span class="status_body">
42                         <span class="status_id">'.$status_id.'</span>
43                         <span class="status_word" style="font-size: 12px;"><a class="user_name" href="user.php?id='.$user->screen_name.'">'.$user->screen_name.'</a> <span class="tweet">'.$text.'</span></span>
44                         <span class="status_info" style="font-size: 11px; margin: 0px;">';
45                 if($end && isset($status->in_reply_to_user_id)){
46                         $html .= '<span class="in_reply_to"> <a class="ajax_reply" href="ajax/status.php?id='.$status->in_reply_to_status_id_str.'&uid='.$user->id.'">in reply to '.$status->in_reply_to_screen_name.'</a></span>';
47                 }
48                 $html .= '<span class="source">via '.$status->source.'</span>
49                         <span class="date"><a href="status.php?id='.$status->id_str.'" id="'.$date.'" target="_blank">'.date('Y-m-d H:i:s', $date).'</a></span>
50                         </span>
51                         </span>
52                         </li>';
53                 if(!$end){
54                         $html .= formatConversation($status->in_reply_to_status_id_str);
55                 }
56                 return $html;
57         }
58 ?>