. * * @category Form * @package StatusNet * @author Zach Copley * @copyright 2011 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ if (!defined('STATUSNET')) { exit(1); } require_once INSTALLDIR . '/lib/util/form.php'; /** * Form for showing / revising an answer * * @category Form * @package StatusNet * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ * */ class QnashowanswerForm extends Form { /** * The answer to show */ protected $answer = null; /** * The question this is an answer to */ protected $question = null; /** * Constructor * * @param HTMLOutputter $out output channel * @param QnA_Answer $answer answer to revise */ function __construct($out = null, $answer = null) { parent::__construct($out); $this->answer = $answer; $this->question = $answer->getQuestion(); } /** * ID of the form * * @return int ID of the form */ function id() { return 'show-' . $this->answer->id; } /** * Action of the form * * @return string URL of the action */ function action() { return common_local_url('qnareviseanswer'); } /** * Include a session token for CSRF protection * * @return void */ function sessionToken() { $this->out->hidden( 'token', common_session_token() ); } /** * Legend of the Form * * @return void */ function formLegend() { // TRANS: Form legend for showing the answer. $this->out->element('legend', null, _m('Answer')); } /** * Data elements * * @return void */ function formData() { $this->out->hidden( 'qna-answer-id', 'answer-' . $this->answer->id, 'id' ); $this->out->raw($this->answer->asHTML()); } /** * Action elements * * @return void */ function formActions() { $user = common_current_user(); if (empty($user)) { return; } if (empty($this->question->closed)) { if ($user->id == $this->question->profile_id) { if (empty($this->answer->best)) { $this->out->submit( 'qna-best-answer', // TRANS: Button text for marking an answer as "best". _m('BUTTON', 'Best'), 'submit', 'best', // TRANS: Title for button text marking an answer as "best". _m('Mark this answer as the best answer.') ); } } /* * @todo FIXME: Revise is disabled until we figure out the * Ostatus bits This comment is just a reminder * that the UI for this works. */ /* if ($user->id == $this->answer->profile_id) { $this->out->submit( 'revise', // TRANS: Button text for revising an answer. _m('BUTTON', 'Revise'), 'submit', null, // TRANS: Title for button text for revising an answer. _m('Revise your answer.') ); } */ } } /** * Class of the form. * * @return string the form's class */ function formClass() { return 'form_answer_show ajax'; } }