OSDN Git Service

embrj
[embrj/master.git] / lists.php
1 <?php 
2         include ('lib/twitese.php');
3         $title = "Lists";
4         include ('inc/header.php');
5         
6         if (!loginStatus()) header('location: login.php');
7 ?>
8
9 <script src="js/lists.js"></script>
10
11 <div id="statuses">
12         <?php 
13                 $t = getTwitter();
14
15                 $isSelf = true;
16                 if (isset($_GET['id'])) {
17                         $id = $_GET['id'];
18                         $isSelf = false;
19                 } else {
20                         $id = $t->username;
21                 }
22                 $type = isset($_GET['t'])? $_GET['t'] : 1;
23                 $c = isset($_GET['c'])? $_GET['c'] : -1;   // cursor
24                 switch ($type) {
25                         case 0:
26                                 $lists = $t->followedLists($id, $c);
27                                 break;
28                         case 1:
29                                 $lists = $t->myLists($id);
30                                 break;
31                         case 2:
32                                 $lists = $t->beAddedLists($id, $c);
33                                 break;
34                         default:
35                                 $lists = false;
36                 }
37                 $nextlist = $lists->next_cursor;
38                 $prelist = $lists->previous_cursor;
39                 $lists = $lists->lists; 
40                 if ($lists === false) {
41                         header('location: error.php');exit();
42                 } 
43                 
44                 
45         ?>
46         <div id="subnav">
47         <?php if ($isSelf) {
48                 if ($type == 0) {?>
49                 <span class="subnavNormal">Lists you follow</span><span class="subnavLink"><a href="lists.php?t=1">Lists you created</a></span><span class="subnavLink"><a href="lists.php?t=2">Lists following you</a></span>
50                 <?php } else if ($type == 1) {?>
51                 <span class="subnavLink"><a href="lists.php?t=0">Lists you follow</a></span><span class="subnavNormal">Lists you created</span><span class="subnavLink"><a href="lists.php?t=2">Lists following you</a></span>
52                 <?php } else {?>
53                         <span class="subnavLink"><a href="lists.php?t=0">Lists you follow</a></span><span class="subnavLink"><a href="lists.php?t=1">All your lists</a></span><span class="subnavNormal">Lists following you</span>
54                 <?php }
55         } else {
56                 if ($type == 0) {?>
57                 <span class="subnavNormal">Following Lists</span><span class="subnavLink"><a href="lists.php?id=<?php echo $id?>&t=1">All Lists</a></span><span class="subnavLink"><a href="lists.php?id=<?php echo $id?>&t=2">Lists Following @<?php echo $id?></a></span>
58                 <?php } else if ($type == 1) {?>
59                 <span class="subnavLink"><a href="lists.php?t=0&id=<?php echo $id?>">Following Lists</a></span><span class="subnavNormal">All Lists</span><span class="subnavLink"><a href="lists.php?id=<?php echo $id?>&t=2">Lists Following @<?php echo $id?></a></span>
60                 <?php } else {?>
61                         <span class="subnavLink"><a href="lists.php?t=0&id=<?php echo $id?>">Following Lists</a></span><span class="subnavLink"><a href="lists.php?id=<?php echo $id?>&t=1">All Lists</a></span><span class="subnavNormal">Lists Following @<?php echo $id?></span>
62                 <?php }
63         } ?>
64     </div>
65     
66         <?php 
67                 
68                 $empty = count($lists) == 0? true: false;
69                 if ($empty) {
70                         echo "<div id=\"empty\">No Tweet To Display</div>";
71                 } else {
72                         $output = '<ol class="rank_list">';                     
73                         foreach ($lists as $list) {
74                 
75                                 $listurl = substr($list->uri,1);
76                                 $user = $list->user;
77                                 $listname = explode('/',$list->full_name);
78                                 $mode = $list->mode == 'private' ? "Private" : "Public";
79                                 
80                                 $output .= "
81                                 <li>
82                                         <span class=\"rank_img\"><img src=\"".getAvatar($user->profile_image_url)."\" /></span>
83                                         <div class=\"rank_content\" id=\"list{$list->id_str}\">
84                                                 <span class=\"rank_num\"><span class=\"rank_name\"><a href=\"list.php?id=$listurl\"><em>$listname[0]/</em>$listname[1]</a></span></span>
85                                                 <span class=\"rank_count\">Followers: {$list->subscriber_count}&nbsp;&nbsp;Members: {$list->member_count}&nbsp;&nbsp;$mode</span> 
86                                 ";
87                                 if ($list->description != '') $output .= "<span class=\"rank_description\">Description: $list->description</span>";
88                                 if ($type == 0) $output .= "<span id=\"list_action\"><a id=\"btn\" href=\"javascript:void()\" class=\"unfollow_list\">Unfollow</a></span>";
89                                 if ($type == 1 && $isSelf) $output .= "<span id=\"list_action\"><a id=\"btn\" href=\"javascript:void()\" class=\"edit_list\">Edit</a> <a id=\"btn\" href=\"javascript:void()\" class=\"delete_list\">Delete</a> <a id=\"btn\" href=\"javascript:void()\" class=\"add_member\">Add Members</a></span>";
90                                 $output .= "
91                                         </div>
92                                 </li>
93                                 ";
94                         }
95                         
96                         $output .= "</ol>";
97                         
98                         echo $output;
99                 }
100                 
101         ?>
102         
103         <?php if ($isSelf && $type == 1) {?>
104             <a href="#" class="more round" id="list_create_btn" style="margin: 20px auto;">Create a new list</a>
105             <form method="POST" action="./lists.php?t=1" id="list_form">
106                 <input type="hidden" name="list_spanid" value="" id="list_spanid" />
107                 <input type="hidden" name="pre_list_name" value="" id="pre_list_name" />
108                 <input type="hidden" name="is_edit" value="0" id="is_edit" />
109                 <span><label for="list_name">List name</label><input type="text" name="list_name" id="list_name" /></span>
110                 <span><label for="list_description">Description</label><textarea type="text" name="list_description" id="list_description"></textarea></span>
111                 <span><label for="list_protect">Private</label><input type="checkbox" name="list_protect" id="list_protect"  />
112                         <a style="background: transparent url(img/sprite-icons.png) no-repeat scroll -272px -16px; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; text-decoration: none; height: 10px; float: right; position: relative; width: 9px; left: 3px; top: -160px;" title="Close" onclick="$('#list_form').slideToggle(300)" href="#"></a>
113                         <input type="submit" class="btn" id="list_submit" value="" />
114                         
115                         </span>
116                 <span></span>
117             </form>
118             
119             
120         <?php }?>
121         
122         <div id="pagination">
123         <?php 
124             if ($type == 0 || $type == 2) {
125                 if ($isSelf) {
126                                 if ($prelist != 0) echo "<a id=\"less\" class=\"round more\" style=\"float: left;\" href=\"lists.php?t=$type&c=$prelist\">Back</a>";
127                                 if ($nextlist != 0) echo "<a id=\"more\" class=\"round more\" style=\"float: right;\" href=\"lists.php?t=$type&c=$nextlist\">Next</a>";
128                 } else {
129                                 if ($prelist != 0) echo "<a id=\"less\" class=\"round more\" style=\"float: left;\" href=\"lists.php?id=$id&t=$type&c=$prelist\">Back</a>";
130                                 if ($nextlist != 0) echo "<a id=\"more\" class=\"round more\" style=\"float: right;\" href=\"lists.php?id=$id&t=$type&c=$nextlist\">Next</a>";
131                 }
132                 }
133         ?>
134         </div>
135 </div>
136
137 <?php 
138         include ('inc/sidebar.php');
139         include ('inc/footer.php');
140 ?>