3 * StatusNet, the distributed open-source microblogging tool
5 * Form for posting a notice from within the Facebook App.
7 * This is a stripped down version of the normal NoticeForm (sans
8 * location stuff and media upload stuff). I'm not sure we can share the
9 * location (from FB) and they don't allow posting multipart form data
10 * to Facebook canvas pages, so that won't work anyway. --Zach
14 * LICENCE: This program is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Affero General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Affero General Public License for more details.
24 * You should have received a copy of the GNU Affero General Public License
25 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 * @author Evan Prodromou <evan@status.net>
30 * @author Sarven Capadisli <csarven@status.net>
31 * @author Zach Copley <zach@status.net>
32 * @copyright 2009 StatusNet, Inc.
33 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
34 * @link http://status.net/
37 if (!defined('STATUSNET') && !defined('LACONICA')) {
41 require_once INSTALLDIR . '/lib/form.php';
44 * Form for posting a notice from within the Facebook app
48 * @author Evan Prodromou <evan@status.net>
49 * @author Sarven Capadisli <csarven@status.net>
50 * @author Zach Copey <zach@status.net>
51 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
52 * @link http://status.net/
56 class FacebookNoticeForm extends Form
59 * Current action, used for returning to this page.
64 * Pre-filled content of the form
74 * The notice being replied to
76 var $inreplyto = null;
81 * @param HTMLOutputter $out output channel
82 * @param string $action action to return to, if any
83 * @param string $content content to pre-fill
85 function __construct($out=null, $action=null, $content=null, $post_action=null, $user=null, $inreplyto=null)
87 parent::__construct($out);
89 $this->action = $action;
90 $this->post_action = $post_action;
91 $this->content = $content;
92 $this->inreplyto = $inreplyto;
97 $this->user = common_current_user();
100 // Note: Facebook doesn't allow multipart/form-data posting to
101 // canvas pages, so don't try to set it--no file uploads, at
102 // least not this way. It can be done using multiple servers
103 // and iFrames, but it's a pretty hacky process.
109 * @return string ID of the form
113 return 'form_notice';
119 * @return string class of the form
123 return 'form_notice';
129 * @return string URL of the action
133 return $this->post_action;
141 function formLegend()
144 $this->out->element('legend', null, _m('Send a notice'));
154 if (Event::handle('StartShowNoticeFormData', array($this))) {
155 $this->out->element('label', array('for' => 'notice_data-text'),
156 // TRANS: Field label.
157 sprintf(_m('What\'s up, %s?'), $this->user->nickname));
158 // XXX: vary by defined max size
159 $this->out->element('textarea', array('id' => 'notice_data-text',
162 'name' => 'status_textarea'),
163 ($this->content) ? $this->content : '');
165 $contentLimit = Notice::maxContent();
167 if ($contentLimit > 0) {
168 $this->out->elementStart('dl', 'form_note');
169 $this->out->element('dt', null, _m('Available characters'));
170 $this->out->element('dd', array('id' => 'notice_text-count'),
172 $this->out->elementEnd('dl');
176 $this->out->hidden('notice_return-to', $this->action, 'returnto');
178 $this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto');
180 Event::handle('StartShowNoticeFormData', array($this));
189 function formActions()
191 $this->out->element('input', array('id' => 'notice_action-submit',
193 'name' => 'status_submit',
195 // TRANS: Button text.
196 'value' => _m('BUTTON','Send')));