3 class SubscriptionsAction extends Action {
5 function handle($args) {
7 $nickname = $this->arg('nickname');
8 $profile = Profile::staticGet('nickname', $nickname);
10 $this->no_such_user();
12 $user = User::staticGet($profile->id);
14 $this->no_such_user();
16 $page = $this->arg('page') || 1;
17 $this->show_subscriptions($profile, $page);
20 function show_subscriptions($profile, $page) {
22 $sub = DB_DataObject::factory('subscriptions');
23 $sub->subscriber = $profile->id;
25 # We ask for an extra one to know if we need to do another page
27 $sub->limit((($page-1)*SUBSCRIPTIONS_PER_PAGE)+1, SUBSCRIPTIONS_PER_PAGE + 1);
29 $subs_count = $subs->find();
31 common_start_element('div', 'subscriptions');
35 while ($subs->fetch()) {
37 if ($idx % SUBSCRIPTIONS_PER_ROW == 1) {
38 common_start_element('div', 'row');
41 common_start_element('a', array('title' => $subs->fullname ||
43 'href' => $subs->profileurl,
44 'class' => 'subscription'));
45 common_element('img', array('src' => $subs->avatar,
46 'class' => 'avatar'));
47 common_end_element('a');
49 if ($idx % SUBSCRIPTIONS_PER_ROW == 0) {
50 common_end_element('div');
53 if ($idx == SUBSCRIPTIONS_PER_PAGE) {
59 common_element('a', array('href' =>
60 common_local_url('subscriptions',
61 array('nickname' => $profile->nickname,
62 'page' => $page - 1)),
67 if ($subs_count > SUBSCRIPTIONS_PER_PAGE) {
68 common_element('a', array('href' =>
69 common_local_url('subscriptions',
70 array('nickname' => $profile->nickname,
71 'page' => $page + 1)),
75 common_end_element('div');