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.
54 * Visible or invisible data elements
56 * Display the form fields that make up the data of the form.
57 * Sub-classes should overload this to show their data.
64 $this->out->elementStart('fieldset');
66 $this->out->hidden('profile', $this->profile->id);
68 $this->out->elementStart('div', array('style' => 'float: left; width: 80px;'));
69 $img = $this->getAvatar($this->profile);
70 $feed = $this->getFeed($this->profile);
71 $this->out->elementStart('a', array('href' => $this->profile->profileurl));
72 $this->out->element('img', array('src' => $img, 'style' => 'float: left'));
73 $this->out->elementEnd('a');
74 $this->out->elementEnd('div');
77 $this->out->elementStart('div', array('style' => 'margin-left: 80px; margin-right: 20px'));
78 $this->out->elementStart('p');
79 $this->out->elementStart('div');
80 $this->out->element('a', array('href' => $this->profile->profileurl), $this->profile->getBestName());
81 $this->out->elementEnd('div');
82 $this->out->elementStart('div');
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 $this->out->text(_m('LABEL', 'Local user'));
90 $this->out->elementEnd('div');
91 $this->out->elementEnd('p');
93 $this->out->elementStart('fieldset', array('style' => 'margin-top: 20px'));
94 $this->out->element('legend', false, _m("Mirroring style"));
96 $styles = array('repeat' => _m("Repeat: reference the original user's post (sometimes shows as 'RT @blah')"),
97 'copy' => _m("Repost the content under my account"));
98 foreach ($styles as $key => $label) {
99 $this->out->elementStart('div');
100 $attribs = array('type' => 'radio',
103 'id' => $this->id() . '-style');
104 if ($key == $this->mirror->style || ($key == 'repeat' && empty($this->mirror->style))) {
105 $attribs['checked'] = 'checked';
107 $this->out->element('input', $attribs);
108 $this->out->element('span', false, $label); // @fixme should be label, but the styles muck it up for now
109 $this->out->elementEnd('div');
112 $this->out->elementEnd('fieldset');
115 $this->out->elementStart('div');
116 $this->out->submit($this->id() . '-save', _m('Save'));
117 $this->out->element('input', array('type' => 'submit',
118 'value' => _m('Stop mirroring'),
120 'class' => 'submit'));
121 $this->out->elementEnd('div');
123 $this->out->elementEnd('div');
124 $this->out->elementEnd('fieldset');
127 private function getAvatar($profile)
129 $avatar = $this->profile->getAvatar(48);
131 return $avatar->displayUrl();
133 return Avatar::defaultImage(48);
137 private function getFeed($profile)
139 // Ok this is a bit of a hack. ;)
140 if (class_exists('Ostatus_profile')) {
141 $oprofile = Ostatus_profile::staticGet('profile_id', $profile->id);
143 return $oprofile->feeduri;
153 * Should be unique on the page. Sub-classes should overload this
154 * to show their own IDs.
156 * @return string ID of the form
161 return 'edit-mirror-form-' . $this->profile->id;
165 * Action of the form.
167 * URL to post to. Should be overloaded by subclasses to give
168 * somewhere to post to.
170 * @return string URL to post to
175 return common_local_url('editmirror');
181 * @return string the form's class
186 return 'form_settings';