]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/ModPlus/remoteprofileaction.php
More info for a proper, fancy-url lighttpd setup
[quix0rs-gnu-social.git] / plugins / ModPlus / remoteprofileaction.php
1 <?php
2 /*
3  * To change this template, choose Tools | Templates
4  * and open the template in the editor.
5  */
6
7 class RemoteProfileAction extends ShowstreamAction
8 {
9     function prepare($args)
10     {
11         Action::prepare($args); // skip the ProfileAction code and replace it...
12
13         $id = $this->arg('id');
14         $this->user = false;
15         $this->profile = Profile::getKV('id', $id);
16
17         if (!$this->profile) {
18             // TRANS: Error message displayed when referring to a user without a profile.
19             $this->serverError(_m('User has no profile.'));
20             return false;
21         }
22
23         $user = User::getKV('id', $this->profile->id);
24         if ($user) {
25             // This is a local user -- send to their regular profile.
26             $url = common_local_url('showstream', array('nickname' => $user->nickname));
27             common_redirect($url);
28             return false;
29         }
30
31         $this->tag = $this->trimmed('tag');
32         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
33         common_set_returnto($this->selfUrl());
34
35         $p = Profile::current();
36         if (empty($this->tag)) {
37             $stream = new ProfileNoticeStream($this->profile, $p);
38         } else {
39             $stream = new TaggedProfileNoticeStream($this->profile, $this->tag, $p);
40         }
41         $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
42
43         return true;
44     }
45
46     function handle($args)
47     {
48         // skip yadis thingy
49         $this->showPage();
50     }
51
52     function title()
53     {
54         $base = $this->profile->getBestName();
55         $host = parse_url($this->profile->profileurl, PHP_URL_HOST);
56         // TRANS: Remote profile action page title.
57         // TRANS: %1$s is a username, %2$s is a hostname.
58         return sprintf(_m('%1$s on %2$s'), $base, $host);
59     }
60
61     /**
62      * Instead of showing notices, link to the original offsite profile.
63      */
64     function showNotices()
65     {
66         $url = $this->profile->profileurl;
67         $host = parse_url($url, PHP_URL_HOST);
68         $markdown = sprintf(
69                 // TRANS: Message on remote profile page.
70                 // TRANS: This message contains Markdown links in the form [description](link).
71                 // TRANS: %1$s is a profile nickname, %2$s is a hostname, %3$s is a URL.
72                 _m('This remote profile is registered on another site; see [%1$s\'s original profile page on %2$s](%3$s).'),
73                 $this->profile->nickname,
74                 $host,
75                 $url);
76         $html = common_markup_to_html($markdown);
77         $this->raw($html);
78
79         if ($this->profile->hasRole(Profile_role::SILENCED)) {
80             // TRANS: Message on blocked remote profile page.
81             $markdown = _m('Site moderators have silenced this profile, which prevents delivery of new messages to any users on this site.');
82             $this->raw(common_markup_to_html($markdown));
83         }else{
84
85             $pnl = null;
86             if (Event::handle('ShowStreamNoticeList', array($this->notice, $this, &$pnl))) {
87                 $pnl = new ProfileNoticeList($this->notice, $this);
88             }
89             $cnt = $pnl->show();
90             if (0 == $cnt) {
91                 $this->showEmptyListMessage();
92             }
93
94             $args = array('id' => $this->profile->id);
95             if (!empty($this->tag))
96             {
97                 $args['tag'] = $this->tag;
98             }
99             $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
100                               'remoteprofile', $args);
101
102         }
103     }
104
105     function getFeeds()
106     {
107         // none
108     }
109
110     /**
111      * Don't do various extra stuff, and also trim some things to avoid crawlers.
112      */
113     function extraHead()
114     {
115         $this->element('meta', array('name' => 'robots',
116                                      'content' => 'noindex,nofollow'));
117     }
118
119     function showLocalNav()
120     {
121         // skip
122     }
123
124     function showSections()
125     {
126         // skip
127     }
128
129     function showStatistics()
130     {
131         // skip
132     }
133 }