3 * StatusNet, the distributed open-source microblogging tool
6 * LICENCE: This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @copyright 2010 StatusNet, Inc.
21 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
22 * @link http://status.net/
25 if (!defined('STATUSNET') && !defined('LACONICA')) {
29 class EditMirrorForm extends Form
31 function __construct($action, $profile)
33 parent::__construct($action);
35 $this->profile = clone($profile);
36 $this->user = common_current_user();
37 $this->mirror = SubMirror::pkeyGet(array('subscriber' => $this->user->id,
38 'subscribed' => $this->profile->id));
44 * Sub-classes should overload this with the name of their form.
53 * Visible or invisible data elements
55 * Display the form fields that make up the data of the form.
56 * Sub-classes should overload this to show their data.
62 $this->out->elementStart('fieldset');
64 $this->out->hidden('profile', $this->profile->id);
66 $this->out->elementStart('div', array('style' => 'float: left; width: 80px;'));
67 $img = $this->getAvatar($this->profile);
68 $feed = $this->getFeed($this->profile);
69 $this->out->elementStart('a', array('href' => $this->profile->profileurl));
70 $this->out->element('img', array('src' => $img, 'style' => 'float: left'));
71 $this->out->elementEnd('a');
72 $this->out->elementEnd('div');
75 $this->out->elementStart('div', array('style' => 'margin-left: 80px; margin-right: 20px'));
76 $this->out->elementStart('p');
77 $this->out->elementStart('div');
78 $this->out->element('a', array('href' => $this->profile->profileurl), $this->profile->getBestName());
79 $this->out->elementEnd('div');
80 $this->out->elementStart('div');
82 // XXX: Why the hard coded space?
83 $this->out->text(_m('LABEL', 'Remote feed:') . ' ');
84 //$this->out->element('a', array('href' => $feed), $feed);
85 $this->out->element('input', array('value' => $feed, 'readonly' => 'readonly', 'style' => 'width: 100%'));
87 $this->out->text(_m('LABEL', 'Local user'));
89 $this->out->elementEnd('div');
90 $this->out->elementEnd('p');
92 $this->out->elementStart('fieldset', array('style' => 'margin-top: 20px'));
93 $this->out->element('legend', false, _m("Mirroring style"));
95 $styles = array('repeat' => _m("Repeat: reference the original user's post (sometimes shows as 'RT @blah')"),
96 'copy' => _m("Repost the content under my account"));
97 foreach ($styles as $key => $label) {
98 $this->out->elementStart('div');
99 $attribs = array('type' => 'radio',
102 'id' => $this->id() . '-style');
103 if ($key == $this->mirror->style || ($key == 'repeat' && empty($this->mirror->style))) {
104 $attribs['checked'] = 'checked';
106 $this->out->element('input', $attribs);
107 $this->out->element('span', false, $label); // @fixme should be label, but the styles muck it up for now
108 $this->out->elementEnd('div');
111 $this->out->elementEnd('fieldset');
114 $this->out->elementStart('div');
115 $this->out->submit($this->id() . '-save', _m('Save'));
116 $this->out->element('input', array('type' => 'submit',
117 'value' => _m('Stop mirroring'),
119 'class' => 'submit'));
120 $this->out->elementEnd('div');
122 $this->out->elementEnd('div');
123 $this->out->elementEnd('fieldset');
126 private function getAvatar($profile)
128 $avatar = $this->profile->getAvatar(48);
130 return $avatar->displayUrl();
132 return Avatar::defaultImage(48);
136 private function getFeed($profile)
138 // Ok this is a bit of a hack. ;)
139 if (class_exists('Ostatus_profile')) {
140 $oprofile = Ostatus_profile::staticGet('profile_id', $profile->id);
142 return $oprofile->feeduri;
152 * Should be unique on the page. Sub-classes should overload this
153 * to show their own IDs.
155 * @return string ID of the form
159 return 'edit-mirror-form-' . $this->profile->id;
163 * Action of the form.
165 * URL to post to. Should be overloaded by subclasses to give
166 * somewhere to post to.
168 * @return string URL to post to
172 return common_local_url('editmirror');
178 * @return string the form's class
182 return 'form_settings';