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->profile->avatarUrl(AVATAR_STREAM_SIZE);
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 // TRANS: Field label (URL expectected).
84 $this->out->text(_m('LABEL', 'Remote feed:') . ' ');
85 //$this->out->element('a', array('href' => $feed), $feed);
86 $this->out->element('input', array('value' => $feed, 'readonly' => 'readonly', 'style' => 'width: 100%'));
88 // TRANS: Field label.
89 $this->out->text(_m('LABEL', 'Local user'));
91 $this->out->elementEnd('div');
92 $this->out->elementEnd('p');
94 $this->out->elementStart('fieldset', array('style' => 'margin-top: 20px'));
95 // TRANS: Fieldset legend for feed mirror setting.
96 $this->out->element('legend', false, _m('Mirroring style'));
98 // TRANS: Feed mirror style (radio button option).
99 $styles = array('repeat' => _m('Repeat: reference the original user\'s post (sometimes shows as "RT @blah")'),
100 // TRANS: Feed mirror style (radio button option).
101 'copy' => _m('Repost the content under my account'));
102 foreach ($styles as $key => $label) {
103 $this->out->elementStart('div');
104 $attribs = array('type' => 'radio',
107 'id' => $this->id() . '-style');
108 if ($key == $this->mirror->style || ($key == 'repeat' && empty($this->mirror->style))) {
109 $attribs['checked'] = 'checked';
111 $this->out->element('input', $attribs);
112 $this->out->element('span', false, $label); // @todo FIXME: should be label, but the styles muck it up for now
113 $this->out->elementEnd('div');
116 $this->out->elementEnd('fieldset');
119 $this->out->elementStart('div');
120 // TRANS: Button text to save feed mirror settings.
121 $this->out->submit($this->id() . '-save', _m('BUTTON','Save'));
122 $this->out->element('input', array('type' => 'submit',
123 // TRANS: Button text to stop mirroring a feed.
124 'value' => _m('BUTTON','Stop mirroring'),
126 'class' => 'submit'));
127 $this->out->elementEnd('div');
129 $this->out->elementEnd('div');
130 $this->out->elementEnd('fieldset');
133 private function getFeed($profile)
135 // Ok this is a bit of a hack. ;)
136 if (class_exists('Ostatus_profile')) {
137 $oprofile = Ostatus_profile::getKV('profile_id', $profile->id);
139 return $oprofile->feeduri;
149 * Should be unique on the page. Sub-classes should overload this
150 * to show their own IDs.
152 * @return string ID of the form
156 return 'edit-mirror-form-' . $this->profile->id;
160 * Action of the form.
162 * URL to post to. Should be overloaded by subclasses to give
163 * somewhere to post to.
165 * @return string URL to post to
169 return common_local_url('editmirror');
175 * @return string the form's class
179 return 'form_settings';