3 class SubscribedAction extends Action {
5 # Who is subscribed to a given user?
7 function handle($args) {
9 $nickname = $this->arg('nickname');
10 $profile = Profile::staticGet('nickname', $nickname);
12 $this->no_such_user();
14 $user = User::staticGet($profile->id);
16 $this->no_such_user();
19 $page = $this->arg('page') || 1;
20 $this->show_subscribed($profile, $page);
23 function show_subscribed($profile, $page) {
25 $sub = DB_DataObject::factory('subscriptions');
26 $sub->subscribed = $profile->id;
28 # We ask for an extra one to know if we need to do another page
30 $sub->limit((($page-1)*SUBSCRIPTIONS_PER_PAGE)+1, SUBSCRIPTIONS_PER_PAGE + 1);
32 $subs_count = $subs->find();
34 common_start_element('div', 'subscriptions');
38 while ($subs->fetch()) {
40 if ($idx % SUBSCRIPTIONS_PER_ROW == 1) {
41 common_start_element('div', 'row');
44 common_start_element('a', array('title' => $subs->fullname ||
46 'href' => $subs->profileurl,
47 'class' => 'subscription'));
48 common_element('img', array('src' => $subs->avatar,
49 'class' => 'avatar'));
50 common_end_element('a');
52 if ($idx % SUBSCRIPTIONS_PER_ROW == 0) {
53 common_end_element('div');
56 if ($idx == SUBSCRIPTIONS_PER_PAGE) {
62 common_element('a', array('href' =>
63 common_local_url('subscriptions',
64 array('nickname' => $profile->nickname,
65 'page' => $page - 1)),
70 if ($subs_count > SUBSCRIPTIONS_PER_PAGE) {
71 common_element('a', array('href' =>
72 common_local_url('subscriptions',
73 array('nickname' => $profile->nickname,
74 'page' => $page + 1)),
78 common_end_element('div');