code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Show a question
 *
 * PHP version 5
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  QnA
 * @package   StatusNet
 * @author    Zach Copley <zach@status.net>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET')) {
    // This check helps protect against security problems;
    // your code file can't be executed directly from the web.
    exit(1);
}

/**
 * Show a question
 *
 * @category  QnA
 * @package   StatusNet
 * @author    Zach Copley <zach@status.net>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */
class QnashowquestionAction extends ShownoticeAction
{
    protected $question = null;

    /**
     * For initializing members of the class.
     *
     * @param array $args misc. arguments
     *
     * @return boolean true
     * @throws ClientException
     * @throws ServerException
     */
    function prepare(array $args = [])
    {
        Action::prepare($args);

        $this->id = $this->trimmed('id');

        $this->question = QnA_Question::getKV('id', $this->id);

        if (empty($this->question)) {
            // TRANS: Client exception thrown trying to view a non-existing question.
            throw new ClientException(_m('No such question.'), 404);
        }

        $this->notice = $this->question->getNotice();

        if (empty($this->notice)) {
            // Did we used to have it, and it got deleted?
            // TRANS: Client exception thrown trying to view a non-existing question notice.
            throw new ClientException(_m('No such question notice.'), 404);
        }

        $this->user = User::getKV('id', $this->question->profile_id);

        if (empty($this->user)) {
            // TRANS: Client exception thrown trying to view a question of a non-existing user.
            throw new ClientException(_m('No such user.'), 404);
        }

        $this->profile = $this->user->getProfile();

        if (empty($this->profile)) {
            // TRANS: Server exception thrown trying to view a question for a user for which the profile could not be loaded.
            throw new ServerException(_m('User without a profile.'));
        }

        try {
            $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
        } catch (Exception $e) {
            $this->avatar = null;
        }

        return true;
    }

    function showContent()
    {
        $this->elementStart('div', 'qna-full-question');
        $this->raw($this->question->asHTML());

        $answer = $this->question->getAnswers();

        $this->elementStart('div', 'qna-full-question-answers');

        $answerIds = array();

        // @fixme use a filtered stream!

        if (!empty($answer)) {
            while ($answer->fetch()) {
                $answerIds[] = $answer->getNotice()->id;
            }
        }

        if (count($answerIds) > 0) {
            $notice = Notice::multiGet('id', $answerIds);

            $nli = new NoticeList($notice, $this);
            $nli->show();
        }

        $user = common_current_user();

        if (!empty($user)) {
            $profile = $user->getProfile();
            $answer = QnA_Question::getAnswer($profile);
            if (empty($answer)) {
                $form = new QnanewanswerForm($this, $this->question, false);
                $form->show();
            }
        }

        $this->elementEnd('div');
        $this->elementEnd('div');
    }

    /**
     * Title of the page
     *
     * Used by Action class for layout.
     *
     * @return string page tile
     */
    function title()
    {
        return sprintf(
        // TRANS: Page title for a question.
        // TRANS: %1$s is the nickname of the user who asked the question, %2$s is the question.
            _m('%1$s\'s question: %2$s'),
            $this->user->nickname,
            $this->question->title
        );
    }

    /**
     * @fixme combine the notice time with question update time
     */
    function lastModified()
    {
        return Action::lastModified();
    }

    /**
     * @fixme combine the notice time with question update time
     */
    function etag()
    {
        return Action::etag();
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Vote on a question or answer
 *
 * PHP version 5
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  QnA
 * @package   StatusNet
 * @author    Zach Copley <zach@status.net>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */
if (!defined('STATUSNET')) {
    // This check helps protect against security problems;
    // your code file can't be executed directly from the web.
    exit(1);
}

/**
 * Vote on a question or answer
 *
 * @category  QnA
 * @package   StatusNet
 * @author    Zach Copley <zach@status.net>
 * @copyright 2010 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */
class Qnavote extends Action
{
    protected $user = null;
    protected $error = null;
    protected $complete = null;

    protected $question = null;
    protected $answer = null;

    /**
     * Returns the title of the action
     *
     * @return string Action title
     */
    function title()
    {
        // TRANS: Page title for and answer to a question.
        return _m('Answer');
    }

    /**
     * For initializing members of the class.
     *
     * @param array $args misc. arguments
     *
     * @return boolean true
     * @throws ClientException
     */
    function prepare(array $args = [])
    {
        parent::prepare($args);
        if ($this->boolean('ajax')) {
            GNUsocial::setApi(true);
        }

        $this->user = common_current_user();

        if (empty($this->user)) {
            // TRANS: Client exception thrown trying to answer a question while not logged in.
            throw new ClientException(_m('You must be logged in to answer to a question.'),
                403);
        }

        if ($this->isPost()) {
            $this->checkSessionToken();
        }

        $id = $this->trimmed('id');
        $this->question = QnA_Question::getKV('id', $id);
        if (empty($this->question)) {
            // TRANS: Client exception thrown trying to respond to a non-existing question.
            throw new ClientException(_m('Invalid or missing question.'), 404);
        }

        $answer = $this->trimmed('answer');

        return true;
    }

    /**
     * Handler method
     *
     * @return void
     */
    function handle()
    {
        parent::handle();

        if ($this->isPost()) {
            $this->answer();
        } else {
            $this->showPage();
        }

        return;
    }

    /**
     * Add a new answer
     *
     * @return void
     */
    function answer()
    {
        try {
            $notice = Answer::saveNew(
                $this->user->getProfile(),
                $this->question,
                $this->answer
            );
        } catch (ClientException $ce) {
            $this->error = $ce->getMessage();
            $this->showPage();
            return;
        }

        if ($this->boolean('ajax')) {
            $this->startHTML('text/xml;charset=utf-8');
            $this->elementStart('head');
            // TRANS: Page title after sending in a vote for a question or answer.
            $this->element('title', null, _m('Answers'));
            $this->elementEnd('head');
            $this->elementStart('body');
            $form = new QnA_Answer($this->question, $this);
            $form->show();
            $this->elementEnd('body');
            $this->endHTML();
        } else {
            common_redirect($this->question->getUrl(), 303);
        }
    }

    /**
     * Show the Answer form
     *
     * @return void
     */
    function showContent()
    {
        if (!empty($this->error)) {
            $this->element('p', 'error', $this->error);
        }

        $form = new QnaanswerForm($this->question, $this);

        $form->show();

        return;
    }

    /**
     * Return true if read only.
     *
     * MAY override
     *
     * @param array $args other arguments
     *
     * @return boolean is read only action?
     */
    function isReadOnly($args)
    {
        if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
            $_SERVER['REQUEST_METHOD'] == 'HEAD') {
            return true;
        } else {
            return false;
        }
    }
}

repo_name: andremichelle/gnu

license: mit


code:
<?php
/**
 * Data class to save answers to questions
 *
 * PHP version 5
 *
 * @category QnA
 * @package  StatusNet
 * @author   Zach Copley <zach@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 *
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

if (!defined('STATUSNET')) {
    exit(1);
}

/**
 * For storing answers
 *
 * @category QnA
 * @package  StatusNet
 * @author   Zach Copley <zach@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 *
 * @see      DB_DataObject
 */
class QnA_Answer extends Managed_DataObject
{
    const  OBJECT_TYPE = 'http://activityschema.org/object/answer';

    public $__table = 'qna_answer'; // table name
    public $id;          // char(36) primary key not null -> UUID
    public $uri;         // varchar(191)   not 255 because utf8mb4 takes more space
    public $question_id; // char(36) -> question.id UUID
    public $profile_id;  // int -> question.id
    public $best;        // (boolean) int -> whether the question asker has marked this as the best answer
    public $revisions;   // int -> count of revisions to this answer
    public $content;     // text -> response text
    public $created;     // datetime

    /**
     * The One True Thingy that must be defined and declared.
     */
    public static function schemaDef()
    {
        return array(
            'description' => 'Record of answers to questions',
            'fields' => array(
                'id' => array(
                    'type'     => 'char',
                    'length'   => 36,
                    'not null' => true, 'description' => 'UUID of the response',
                ),
                'uri'      => array(
                    'type'        => 'varchar',
                    'length'      => 191,
                    'not null'    => true,
                    'description' => 'UUID to the answer notice',
                ),
                'question_id' => array(
                    'type'        => 'char',
                    'length'      => 36,
                    'not null'    => true,
                    'description' => 'UUID of question being responded to',
                ),
                'content'    => array('type' => 'text'), // got a better name?
                'best'       => array('type' => 'int', 'size' => 'tiny'),
                'revisions'  => array('type' => 'int'),
                'profile_id' => array('type' => 'int'),
                'created'    => array('type' => 'datetime', 'not null' => true),
            ),
            'primary key' => array('id'),
            'unique keys' => array(
                'question_uri_key' => array('uri'),
                'question_id_profile_id_key' => array('question_id', 'profile_id'),
            ),
            'indexes' => array(
                'profile_id_question_id_index' => array('profile_id', 'question_id'),
            )
        );
    }

    /**
     * Get an answer based on a notice
     *
     * @param Notice $notice Notice to check for
     *
     * @return QnA_Answer found response or null
     */
    static function getByNotice($notice)
    {
        $answer = self::getKV('uri', $notice->uri);
        if (empty($answer)) {
            throw new Exception("No answer with URI {$notice->uri}");
        }
        return $answer;
    }

    /**
     * Get the notice that belongs to this answer
     *
     * @return Notice
     */
    function getNotice()
    {
        return Notice::getKV('uri', $this->uri);
    }

    static function fromNotice($notice)
    {
        return QnA_Answer::getKV('uri', $notice->uri);
    }

    function getUrl()
    {
        return $this->getNotice()->getUrl();
    }

    /**
     * Get the Question this is an answer to
     *
     * @return QnA_Question
     */
    function getQuestion()
    {
        $question = QnA_Question::getKV('id', $this->question_id);
        if (empty($question)) {
            // TRANS: Exception thown when getting a question with a non-existing ID.
            // TRANS: %s is the non-existing question ID.
            throw new Exception(sprintf(_m('No question with ID %s'),$this->question_id));
        }
        return $question;
    }

    function getProfile()
    {
        $profile = Profile::getKV('id', $this->profile_id);
        if (empty($profile)) {
            // TRANS: Exception thown when getting a profile with a non-existing ID.
            // TRANS: %s is the non-existing profile ID.
            throw new Exception(sprintf(_m('No profile with ID %s'),$this->profile_id));
        }
        return $profile;
    }

    function asHTML()
    {
        return self::toHTML(
            $this->getProfile(),
            $this->getQuestion(),
            $this
        );
    }

    function asString()
    {
        return self::toString(
            $this->getProfile(),
            $this->getQuestion(),
            $this
        );
    }

    static function toHTML($profile, $question, $answer)
    {
        $notice = $question->getNotice();

        $out = new XMLStringer();

        $cls = array('qna_answer');
        if (!empty($answer->best)) {
            $cls[] = 'best';
        }

        $out->elementStart('p', array('class' => implode(' ', $cls)));
        $out->elementStart('span', 'answer-content');
        $out->raw(common_render_text($answer->content));
        $out->elementEnd('span');

        if (!empty($answer->revisions)) {
            $out->elementstart('span', 'answer-revisions');
            $out->text(
                htmlspecialchars(
                    // Notification of how often an answer was revised.
                    // TRANS: %s is the number of answer revisions.
                    sprintf(_m('%s revision','%s revisions',$answer->revisions), $answer->revisions)
                )
            );
            $out->elementEnd('span');
        }

        $out->elementEnd('p');

        return $out->getString();
    }

    static function toString($profile, $question, $answer)
    {
        // @todo FIXME: unused variable?
        $notice = $question->getNotice();

        return sprintf(
            // TRANS: Text for a question that was answered.
            // TRANS: %1$s is the user that answered, %2$s is the question title,
            // TRANS: %2$s is the answer content.
            _m('%1$s answered the question "%2$s": %3$s'),
            htmlspecialchars($profile->getBestName()),
            htmlspecialchars($question->title),
            htmlspecialchars($answer->content)
        );
    }

    /**
     * Save a new answer notice
     *
     * @param Profile  $profile
     * @param Question $Question the question being answered
     * @param array
     *
     * @return Notice saved notice
     */
    static function saveNew($profile, $question, $text, $options = null)
    {
        if (empty($options)) {
            $options = array();
        }

        $answer              = new QnA_Answer();
        $answer->id          = UUID::gen();
        $answer->profile_id  = $profile->id;
        $answer->question_id = $question->id;
        $answer->revisions   = 0;
        $answer->best        = 0;
        $answer->content     = $text;
        $answer->created     = common_sql_now();
        $answer->uri         = common_local_url(
            'qnashowanswer',
            array('id' => $answer->id)
        );

        common_log(LOG_DEBUG, "Saving answer: $answer->id, $answer->uri");
        $answer->insert();

        $content  = sprintf(
            // TRANS: Text for a question that was answered.
            // TRANS: %s is the question title.
            _m('answered "%s"'),
            $question->title
        );

        $link = 'uri) . '">' . htmlspecialchars($question->title) . '';
        // TRANS: Rendered version of the notice content answering a question.
        // TRANS: %s a link to the question with question title as the link content.
        $rendered = sprintf(_m('answered "%s"'), $link);

        $tags    = array();
        $replies = array();

        $options = array_merge(
            array(
                'urls'        => array(),
                'content'     => $content,
                'rendered'    => $rendered,
                'tags'        => $tags,
                'replies'     => $replies,
                'reply_to'    => $question->getNotice()->id,
                'object_type' => self::OBJECT_TYPE
            ),
            $options
        );

        if (!array_key_exists('uri', $options)) {
            $options['uri'] = $answer->uri;
        }

        $saved = Notice::saveNew(
            $profile->id,
            $content,
            array_key_exists('source', $options) ?
            $options['source'] : 'web',
            $options
        );

        return $saved;
    }
}


code:
<?php
/**
 * Data class to mark a notice as a question
 *
 * PHP version 5
 *
 * @category QnA
 * @package  StatusNet
 * @author   Zach Copley <zach@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 *
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

if (!defined('STATUSNET')) {
    exit(1);
}

/**
 * For storing a question
 *
 * @category QnA
 * @package  StatusNet
 * @author   Zach Copley <zach@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 *
 * @see      DB_DataObject
 */
class QnA_Question extends Managed_DataObject
{
    const OBJECT_TYPE = 'http://activityschema.org/object/question';

    public $__table = 'qna_question'; // table name
    public $id;          // char(36) primary key not null -> UUID
    public $uri;         // varchar(191)   not 255 because utf8mb4 takes more space
    public $profile_id;  // int -> profile.id
    public $title;       // text
    public $description; // text
    public $closed;      // int (boolean) whether a question is closed
    public $created;     // datetime

    /**
     * The One True Thingy that must be defined and declared.
     */
    public static function schemaDef()
    {
        return array(
            'description' => 'Per-notice question data for QNA plugin',
            'fields' => array(
                'id' => array(
                    'type'        => 'char',
                    'length'      => 36,
                    'not null'    => true,
                    'description' => 'UUID'
                ),
                'uri' => array(
                    'type'     => 'varchar',
                    'length'   => 191,
                    'not null' => true
                ),
                'profile_id'  => array('type' => 'int'),
                'title'       => array('type' => 'text'),
                'closed'      => array('type' => 'int', 'size' => 'tiny'),
                'description' => array('type' => 'text'),
                'created'     => array(
                    'type'     => 'datetime',
                    'not null' => true
                ),
            ),
            'primary key' => array('id'),
            'unique keys' => array(
                'question_uri_key' => array('uri'),
            ),
        );
    }

    /**
     * Get a question based on a notice
     *
     * @param Notice $notice Notice to check for
     *
     * @return Question found question or null
     */
    static function getByNotice($notice)
    {
        return self::getKV('uri', $notice->uri);
    }

    function getNotice()
    {
        return Notice::getKV('uri', $this->uri);
    }

    function getUrl()
    {
        return $this->getNotice()->getUrl();
    }

    function getProfile()
    {
        $profile = Profile::getKV('id', $this->profile_id);
        if (empty($profile)) {
            // TRANS: Exception trown when getting a profile for a non-existing ID.
            // TRANS: %s is the provided profile ID.
            throw new Exception(sprintf(_m('No profile with ID %s'),$this->profile_id));
        }
        return $profile;
    }

    /**
     * Get the answer from a particular user to this question, if any.
     *
     * @param Profile $profile
     *
     * @return Answer object or null
     */
    function getAnswer(Profile $profile)
    {
        $a = new QnA_Answer();
        $a->question_id = $this->id;
        $a->profile_id = $profile->id;
        $a->find();
        if ($a->fetch()) {
            return $a;
        } else {
            return null;
        }
    }

    function getAnswers()
    {
        $a = new QnA_Answer();
        $a->question_id = $this->id;
        $cnt = $a->find();
        if (!empty($cnt)) {
            return $a;
        } else {
            return null;
        }
    }

    function countAnswers()
    {
        $a = new QnA_Answer();

        $a->question_id = $this->id;

        return $a->count();
    }

    static function fromNotice($notice)
    {
        return QnA_Question::getKV('uri', $notice->uri);
    }

    function asHTML()
    {
        return self::toHTML($this->getProfile(), $this);
    }

    function asString()
    {
        return self::toString($this->getProfile(), $this);
    }

    static function toHTML($profile, $question)
    {
        $notice = $question->getNotice();

        $out = new XMLStringer();

        $cls = array('qna_question');

        if (!empty($question->closed)) {
            $cls[] = 'closed';
        }

        $out->elementStart('p', array('class' => implode(' ', $cls)));

        if (!empty($question->description)) {
            $out->elementStart('span', 'question-description');
            $out->raw(common_render_text($question->description));
            $out->elementEnd('span');
        }

        $cnt = $question->countAnswers();

        if (!empty($cnt)) {
            $out->elementStart('span', 'answer-count');
            // TRANS: Number of given answers to a question.
            // TRANS: %s is the number of given answers.
            $out->text(sprintf(_m('%s answer','%s answers',$cnt), $cnt));
            $out->elementEnd('span');
        }

        if (!empty($question->closed)) {
            $out->elementStart('span', 'question-closed');
            // TRANS: Notification that a question cannot be answered anymore because it is closed.
            $out->text(_m('This question is closed.'));
            $out->elementEnd('span');
        }

        $out->elementEnd('p');

        return $out->getString();
    }

    static function toString($profile, $question, $answers)
    {
        return sprintf(htmlspecialchars($question->description));
    }

    /**
     * Save a new question notice
     *
     * @param Profile $profile
     * @param string  $question
     * @param string  $title
     * @param string  $description
     * @param array   $option // and whatnot
     *
     * @return Notice saved notice
     */
    static function saveNew($profile, $title, $description, $options = array())
    {
        $q = new QnA_Question();

        $q->id          = UUID::gen();
        $q->profile_id  = $profile->id;
        $q->title       = $title;
        $q->description = $description;

        if (array_key_exists('created', $options)) {
            $q->created = $options['created'];
        } else {
            $q->created = common_sql_now();
        }

        if (array_key_exists('uri', $options)) {
            $q->uri = $options['uri'];
        } else {
            $q->uri = common_local_url(
                'qnashowquestion',
                array('id' => $q->id)
            );
        }

        common_log(LOG_DEBUG, "Saving question: $q->id $q->uri");
        $q->insert();

        if (Notice::contentTooLong($q->title . ' ' . $q->uri)) {
            $max       = Notice::maxContent();
            $uriLen    = mb_strlen($q->uri);
            $targetLen = $max - ($uriLen + 15);
            $title = mb_substr($q->title, 0, $targetLen) . '…';
        }

        $content = $title . ' ' . $q->uri;

        $link = 'uri) . '">' . htmlspecialchars($q->title) . '';
        // TRANS: Rendered version of the notice content creating a question.
        // TRANS: %s a link to the question as link description.
        $rendered = sprintf(_m('Question: %s'), $link);

        $tags    = array('question');
        $replies = array();

        $options = array_merge(
            array(
                'urls'        => array(),
                'rendered'    => $rendered,
                'tags'        => $tags,
                'replies'     => $replies,
                'object_type' => self::OBJECT_TYPE
            ),
            $options
        );

        if (!array_key_exists('uri', $options)) {
            $options['uri'] = $q->uri;
        }

        $saved = Notice::saveNew(
            $profile->id,
            $content,
            array_key_exists('source', $options) ?
            $options['source'] : 'web',
            $options
        );

        return $saved;
    }
}


code:
<?php
/**
 * Data class to save users votes for
 *
 * PHP version 5
 *
 * @category QnA
 * @package  StatusNet
 * @author   Zach Copley <zach@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 *
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

if (!defined('STATUSNET')) {
    exit(1);
}

/**
 * For storing votes on question and answers
 *
 * @category QnA
 * @package  StatusNet
 * @author   Zach Copley <zach@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
 * @link     http://status.net/
 *
 * @see      DB_DataObject
 */
class QnA_Vote extends Managed_DataObject
{
    const UP   = 'http://activitystrea.ms/schema/1.0/like';
    const DOWN = 'http://activityschema.org/object/dislike'; // Gar!

    public $__table = 'qna_vote'; // table name
    public $id;          // char(36) primary key not null -> UUID
    public $question_id; // char(36) -> question.id UUID
    public $answer_id;   // char(36) -> question.id UUID
    public $type;        // tinyint -> vote: up (1) or down (-1)
    public $profile_id;  // int -> question.id
    public $created;     // datetime

    /**
     * The One True Thingy that must be defined and declared.
     */
    public static function schemaDef()
    {
        return array(
            'description' => 'For storing votes on questions and answers',
            'fields' => array(
                'id' => array(
                    'type'        => 'char',
                    'length'      => 36,
                    'not null'    => true,
                    'description' => 'UUID of the vote'
                ),
                'question_id' => array(
                    'type'        => 'char',
                    'length'      => 36,
                    'not null'    => true,
                    'description' => 'UUID of question being voted on'
                ),
                'answer_id' => array(
                    'type'        => 'char',
                    'length'      => 36,
                    'not null'    => true,
                    'description' => 'UUID of answer being voted on'
                ),
                'vote'       => array('type' => 'int', 'size' => 'tiny'),
                'profile_id' => array('type' => 'int'),
                'created'    => array('type' => 'datetime', 'not null' => true),
            ),
            'primary key' => array('id'),
            'indexes' => array(
                'profile_id_question_Id_index' => array(
                    'profile_id',
                    'question_id'
                ),
                'profile_id_question_Id_index' => array(
                    'profile_id',
                    'answer_id'
                )
            )
        );
    }

    /**
     * Save a vote on a question or answer
     *
     * @param Profile  $profile
     * @param QnA_Question the question being voted on
     * @param QnA_Answer   the answer being voted on
     * @param vote
     * @param array
     *
     * @return Void
     */
    static function save($profile, $question, $answer, $vote)
    {
        $v = new QnA_Vote();
        $v->id          = UUID::gen();
        $v->profile_id  = $profile->id;
        $v->question_id = $question->id;
        $v->answer_id   = $answer->id;
        $v->vote        = $vote;
        $v->created     = common_sql_now();

        common_log(LOG_DEBUG, "Saving vote: $v->id $v->vote");

        $v->insert();
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Form for answering a question
 *
 * PHP version 5
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  QnA
 * @package   StatusNet
 * @author    Zach Copley <zach@status.net>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET')) {
    // This check helps protect against security problems;
    // your code file can't be executed directly from the web.
    exit(1);
}

/**
 * Form to add a new answer to a question
 *
 * @category  QnA
 * @package   StatusNet
 * @author    Zach Copley <zach@status.net>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */
class QnanewanswerForm extends Form
{
    protected $question;
    protected $showQuestion;

    /**
     * Construct a new answer form
     *
     * @param QnA_Question $question
     * @param HTMLOutputter $out output channel
     *
     * @return void
     */
    function __construct(HTMLOutputter $out, QnA_Question $question, $showQuestion = false)
    {
        parent::__construct($out);
        $this->question = $question;
        $this->showQuestion = $showQuestion;
    }

    /**
     * ID of the form
     *
     * @return int ID of the form
     */
    function id()
    {
        return 'answer-form';
    }

    /**
     * class of the form
     *
     * @return string class of the form
     */
    function formClass()
    {
        return 'form_settings qna_answer_form ajax-notice';
    }

    /**
     * Action of the form
     *
     * @return string URL of the action
     */
    function action()
    {
        return common_local_url('qnanewanswer');
    }

    /**
     * Data elements of the form
     *
     * @return void
     */
    function formData()
    {
        $question = $this->question;
        $out      = $this->out;
        $id       = "question-" . $question->id;

        if ($this->showQuestion) {
            $out->raw($this->question->asHTML());
        }

        $out->hidden('qna-question-id', $id, 'id');
        // TRANS: Field label.
        $out->textarea('qna-answer', _m('Enter your answer'), null, null, 'answer', true);
    }

    /**
     * Action elements
     *
     * @return void
     */
    function formActions()
    {
        // TRANS: Button text for submitting a poll response.
        $this->out->submit('qna-answer-submit', _m('BUTTON', 'Answer'), 'submit', 'submit');
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Form for adding a new question
 *
 * PHP version 5
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  QnA
 * @package   StatusNet
 * @author    Zach Copley <zach@copley.name>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET')) {
    // This check helps protect against security problems;
    // your code file can't be executed directly from the web.
    exit(1);
}

/**
 * Form to add a new question
 *
 * @category  QnA
 * @package   StatusNet
 * @author    Zach Copley <zach@copley.name>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */
class QnanewquestionForm extends Form
{
    protected $title;
    protected $description;

    /**
     * Construct a new question form
     *
     * @param HTMLOutputter $out output channel
     *
     * @return void
     */
    function __construct($out = null, $title = null, $description = null, $options = null)
    {
        parent::__construct($out);
        $this->title       = $title;
        $this->description = $description;
    }

    /**
     * ID of the form
     *
     * @return int ID of the form
     */
    function id()
    {
        return 'newquestion-form';
    }

    /**
     * class of the form
     *
     * @return string class of the form
     */
    function formClass()
    {
        return 'form_settings ajax-notice';
    }

    /**
     * Action of the form
     *
     * @return string URL of the action
     */
    function action()
    {
        return common_local_url('qnanewquestion');
    }

    /**
     * Data elements of the form
     *
     * @return void
     */
    function formData()
    {
        $this->out->elementStart('fieldset', array('id' => 'newquestion-data'));
        $this->out->elementStart('ul', 'form_data');

        $this->li();
        $this->out->input(
            'qna-question-title',
            // TRANS: Field label for a new question.
            _m('LABEL','Title'),
            $this->title,
            // TRANS: Field title for a new question.
            _m('The title of your question.'),
            'title',
            true    // HTML5 "required" attribute
        );
        $this->unli();
        $this->li();
        $this->out->textarea(
            'qna-question-description',
            // TRANS: Field label for question details.
            _m('LABEL','Description'),
            $this->description,
            // TRANS: Field title for question details.
            _m('Your question in detail.'),
            'description',
            true    // HTML5 "required" attribute
        );
        $this->unli();

        $this->out->elementEnd('ul');
        $toWidget = new ToSelector(
            $this->out,
            common_current_user(),
            null
        );
        $toWidget->show();
        $this->out->elementEnd('fieldset');
    }

    /**
     * Action elements
     *
     * @return void
     */
    function formActions()
    {
        // TRANS: Button text for saving a new question.
        $this->out->submit('qna-question-submit', _m('BUTTON', 'Save'), 'submit', 'submit');
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Form for revising a question
 *
 * PHP version 5
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  QnA
 * @package   StatusNet
 * @author    Zach Copley <zach@status.net>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET')) {
    // This check helps protect against security problems;
    // your code file can't be executed directly from the web.
    exit(1);
}

/**
 * Form to revise a question
 *
 * @category  QnA
 * @package   StatusNet
 * @author    Zach Copley <zach@status.net>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */
class QnareviseanswerForm extends Form
{
    protected $question;
    protected $answer;

    /**
     * Construct a new answer form
     *
     * @param QnA_Answer $answer
     * @param HTMLOutputter $out output channel
     *
     * @return void
     */
    function __construct(QnA_Answer $answer, HTMLOutputter $out)
    {
        parent::__construct($out);
        $this->question = $answer->getQuestion();
        $this->answer   = $answer;
    }

    /**
     * ID of the form
     *
     * @return int ID of the form
     */
    function id()
    {
        return 'answered-form';
    }

    /**
     * class of the form
     *
     * @return string class of the form
     */
    function formClass()
    {
        return 'form_settings ajax';
    }

    /**
     * Action of the form
     *
     * @return string URL of the action
     */
    function action()
    {
        return common_local_url('qnareviseanswer');
    }

    /**
     * Data elements of the form
     *
     * @return void
     */
    function formData()
    {
        $out = $this->out;
        $out->element('p', 'revise-answer', 'Your answer');
        $id = "answer-" . $this->answer->id;
        $out->hidden('id', $id);
        $out->textarea('answer', 'answer', $this->answer->content);
    }

    /**
     * Action elements
     *
     * @return void
     */
    function formActions()
    {
        // TRANS: Button text for submitting a revised answer.
        $this->out->submit('submit', _m('BUTTON', 'Submit'));
    }
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * Form for showing / revising an answer
 *
 * PHP version 5
 *
 * LICENCE: This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  Form
 * @package   StatusNet
 * @author    Zach Copley <zach@status.net>
 * @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/form.php';

/**
 * Form for showing / revising an answer
 *
 * @category Form
 * @package  StatusNet
 * @author   Zach Copley <zach@status.net>
 * @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';
    }
}


code:
<?php
/**
 * StatusNet, the distributed open-source microblogging tool
 *
 * Form for showing / revising an answer
 *
 * PHP version 5
 *
 * LICENCE: This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  Form
 * @package   StatusNet
 * @author    Zach Copley <zach@status.net>
 * @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/form.php';

/**
 * Form for showing a question
 *
 * @category Form
 * @package  StatusNet
 * @author   Zach Copley <zach@status.net>
 * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 * @link     http://status.net/
 *
 */
class QnashowquestionForm extends Form
{
    /**
     * The question to show
     */
    var $question = null;

    /**
     * Constructor
     *
     * @param HTMLOutputter $out      output channel
     * @param QnA_Question  $question the question to show
     */
    function __construct($out = null, $question = null)
    {
        parent::__construct($out);
        $this->question = $question;
    }

    /**
     * ID of the form
     *
     * @return int ID of the form
     */
    function id()
    {
        return 'question-' . $this->question->id;
    }

    /**
     * Action of the form
     *
     * @return string URL of the action
     */
    function action()
    {
        return common_local_url('qnaclosequestion');
    }

    /**
     * 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 revising the answer.
        $this->out->element('legend', null, _m('LEGEND','Question'));
    }

    /**
     * Data elements
     *
     * @return void
     */
    function formData()
    {
        $this->out->hidden(
            'qna-question-id',
            'question-' . $this->question->id,
            'id'
        );

        $this->out->hidden(
            'answer-action',
            common_local_url(
                'qnanewanswer',
                null,
                array('id' => 'question-' . $this->question->id)
            )
        );

        $this->out->raw($this->question->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) {
             $this->out->submit(
                'qna-question-close',
                // TRANS: Button text for closing a question.
                _m('BUTTON', 'Close'),
                'submit',
                'submit',
                // TRANS: Title for button text for closing a question.
                _m('Close the question to no one can answer it anymore.')
             );
            }
        }
    }

    /**
     * Class of the form.
     *
     * @return string the form's class
     */
    function formClass()
    {
        return 'form_question_show ajax';
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Form for answering a question
 *
 * PHP version 5
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  QnA
 * @package   StatusNet
 * @author    Zach Copley <zach@status.net>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET')) {
    // This check helps protect against security problems;
    // your code file can't be executed directly from the web.
    exit(1);
}

/**
 * Form to add a new answer to a question
 *
 * @category  QnA
 * @package   StatusNet
 * @author    Zach Copley <zach@status.net>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */
class QnavoteForm extends Form
{
    protected $question;

    /**
     * Construct a new answer form
     *
     * @param QnA_Question $question
     * @param HTMLOutputter $out output channel
     *
     * @return void
     */
    function __construct(QnA_Question $question, HTMLOutputter $out)
    {
        parent::__construct($out);
        $this->question = $question;
    }

    /**
     * ID of the form
     *
     * @return int ID of the form
     */
    function id()
    {
        return 'answer-form';
    }

    /**
     * class of the form
     *
     * @return string class of the form
     */
    function formClass()
    {
        return 'form_settings ajax';
    }

    /**
     * Action of the form
     *
     * @return string URL of the action
     */
    function action()
    {
        return common_local_url('qnavote', array('id' => $this->question->id));
    }

    /**
     * Data elements of the form
     *
     * @return void
     */
    function formData()
    {
        $question = $this->question;
        $out      = $this->out;
        $id       = "question-" . $question->id;

        $out->element('p', 'answer', $question->question);
        $out->element('input', array('type' => 'text', 'name' => 'vote'));
    }

    /**
     * Action elements
     *
     * @return void
     */
    function formActions()
    {
        // TRANS: Button text for submitting a poll response.
        $this->out->submit('submit', _m('BUTTON', 'Submit'));
    }
}


code:
<?php
/**
 * StatusNet - the distributed open-source microblogging tool
 * Copyright (C) 2011, StatusNet, Inc.
 *
 * Adapter to show QnA in a nicer way
 *
 * PHP version 5
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @category  QnA
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */

if (!defined('STATUSNET')) {
    // This check helps protect against security problems;
    // your code file can't be executed directly from the web.
    exit(1);
}

/**
 * An adapter to show QnA in a nicer way
 *
 * @category  QnA
 * @package   StatusNet
 * @author    Evan Prodromou <evan@status.net>
 * @copyright 2011 StatusNet, Inc.
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
 * @link      http://status.net/
 */

class QnAListItem extends NoticeListItemAdapter
{
    /**
     * Custom HTML output for our notices
     *
     * @param Notice $notice
     * @param HTMLOutputter $out
     */
    function showNotice(Notice $notice, $out)
    {
        switch ($notice->object_type) {
        case QnA_Question::OBJECT_TYPE:
            return $this->showNoticeQuestion($notice, $out);
        case QnA_Answer::OBJECT_TYPE:
            return $this->showNoticeAnswer($notice, $out);
        default:
            throw new Exception(
                // TRANS: Exception thrown when performing an unexpected action on a question.
                // TRANS: %s is the unpexpected object type.
                sprintf(_m('Unexpected type for QnA plugin: %s.'),
                        $notice->object_type
                )
            );
        }
    }

    function showNoticeQuestion(Notice $notice, $out)
    {
        $user = common_current_user();

        // @hack we want regular rendering, then just add stuff after that
        $nli = new NoticeListItem($notice, $out);
        $nli->showNotice();

        $out->elementStart('div', array('class' => 'e-content question-description'));

        $question = QnA_Question::getByNotice($notice);

        if (!empty($question)) {

            $form = new QnashowquestionForm($out, $question);
            $form->show();

        } else {
            // TRANS: Error message displayed when question data is not present.
            $out->text(_m('Question data is missing.'));
        }
        $out->elementEnd('div');

        // @fixme
        $out->elementStart('div', array('class' => 'e-content'));
    }

    function showNoticeAnswer(Notice $notice, $out)
    {
        $user = common_current_user();

        $answer   = QnA_Answer::getByNotice($notice);
        $question = $answer->getQuestion();

        $nli = new NoticeListItem($notice, $out);
        $nli->showNotice();

        $out->elementStart('div', array('class' => 'e-content answer-content'));

        if (!empty($answer)) {
            $form = new QnashowanswerForm($out, $answer);
            $form->show();
        } else {
            // TRANS: Error message displayed when answer data is not present.
            $out->text(_m('Answer data is missing.'));
        }

        $out->elementEnd('div');

        // @todo FIXME
        $out->elementStart('div', array('class' => 'e-content'));
    }
}


code:
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-08 18:20+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"

#. TRANS: Exception thrown when performing an unexpected action on a question.
#. TRANS: %s is the unpexpected object type.
#: lib/qnalistitem.php:67
#, php-format
msgid "Unexpected type for QnA plugin: %s."
msgstr ""

#. TRANS: Error message displayed when question data is not present.
#: lib/qnalistitem.php:93
msgid "Question data is missing."
msgstr ""

#. TRANS: Error message displayed when answer data is not present.
#. TRANS: Error message displayed when an answer has no content.
#: lib/qnalistitem.php:118 actions/qnanewanswer.php:338
msgid "Answer data is missing."
msgstr ""

#. TRANS: Page title for revising a question
#: actions/qnareviseanswer.php:62
msgid "Revise answer"
msgstr ""

#. TRANS: Client exception thrown trying to answer a question while not logged in.
#: actions/qnareviseanswer.php:85 actions/qnanewanswer.php:85
#: actions/qnavote.php:85
msgid "You must be logged in to answer to a question."
msgstr ""

#. TRANS: Client exception thrown trying to respond to a non-existing question.
#: actions/qnareviseanswer.php:98
msgid "Invalid or missing answer."
msgstr ""

#. TRANS: Form title for sending an answer.
#: actions/qnareviseanswer.php:162
msgctxt "TITLE"
msgid "Answer"
msgstr ""

#. TRANS: Page title after sending an answer.
#. TRANS: Page title for and answer to a question.
#. TRANS: Form legend for showing the answer.
#: actions/qnareviseanswer.php:201 actions/qnareviseanswer.php:237
#: actions/qnanewanswer.php:62 actions/qnavote.php:63
#: forms/qnashowanswer.php:113
msgid "Answer"
msgstr ""

#. TRANS: Client exception thrown trying to respond to a non-existing question.
#: actions/qnanewanswer.php:101 actions/qnaclosequestion.php:99
#: actions/qnavote.php:97
msgid "Invalid or missing question."
msgstr ""

#. TRANS: Page title after sending an answer.
#. TRANS: Page title after sending in a vote for a question or answer.
#: actions/qnanewanswer.php:156 actions/qnaclosequestion.php:152
#: actions/qnavote.php:147
msgid "Answers"
msgstr ""

#. TRANS: Page title after an AJAX error occurs on the post answer page.
#: actions/qnanewanswer.php:207
msgid "Ajax Error"
msgstr ""

#. TRANS: Title for form to send answer to a question.
#: actions/qnanewanswer.php:230
msgctxt "TITLE"
msgid "Your answer"
msgstr ""

#. TRANS: Client exception thrown trying to view a non-existing question.
#: actions/qnashowquestion.php:70
msgid "No such question."
msgstr ""

#. TRANS: Client exception thrown trying to view a non-existing question notice.
#: actions/qnashowquestion.php:78
msgid "No such question notice."
msgstr ""

#. TRANS: Client exception thrown trying to view a question of a non-existing user.
#. TRANS: Client exception thrown when requesting answer data for a non-existing user.
#: actions/qnashowquestion.php:85 actions/qnashowanswer.php:91
msgid "No such user."
msgstr ""

#. TRANS: Server exception thrown trying to view a question for a user for which the profile could not be loaded.
#. TRANS: Client exception thrown when requesting answer data for a user without a profile.
#: actions/qnashowquestion.php:92 actions/qnashowanswer.php:98
msgid "User without a profile."
msgstr ""

#. TRANS: Page title for a question.
#. TRANS: %1$s is the nickname of the user who asked the question, %2$s is the question.
#: actions/qnashowquestion.php:157
#, php-format
msgid "%1$s's question: %2$s"
msgstr ""

#. TRANS: Page title for close a question
#: actions/qnaclosequestion.php:63
msgid "Close question"
msgstr ""

#. TRANS: Client exception thrown trying to close a question when not logged in
#: actions/qnaclosequestion.php:86
msgid "You must be logged in to close a question."
msgstr ""

#. TRANS: Exception thrown trying to close another user's question.
#: actions/qnaclosequestion.php:135
msgid "You did not ask this question."
msgstr ""

#. TRANS: Title for Question page.
#: actions/qnanewquestion.php:62
msgid "New question"
msgstr ""

#. TRANS: Client exception thrown trying to create a Question while not logged in.
#: actions/qnanewquestion.php:82
msgid "You must be logged in to post a question."
msgstr ""

#. TRANS: Client exception thrown trying to create a question without a title.
#: actions/qnanewquestion.php:128
msgid "Question must have a title."
msgstr ""

#. TRANS: Page title after sending a notice.
#: actions/qnanewquestion.php:153
msgid "Question posted"
msgstr ""

#. TRANS: Client exception thrown when requesting a non-existing answer.
#. TRANS: Did we used to have it, and it got deleted?
#: actions/qnashowanswer.php:70 actions/qnashowanswer.php:84
msgid "No such answer."
msgstr ""

#. TRANS: Client exception thrown when requesting an answer that has no connected question.
#: actions/qnashowanswer.php:77
msgid "No question for this answer."
msgstr ""

#. TRANS: Page title.
#. TRANS: %1$s is the user who answered a question, %2$s is the question.
#: actions/qnashowanswer.php:124
#, php-format
msgid "%1$s's answer to \"%2$s\""
msgstr ""

#. TRANS: Exception thown when getting a question with a non-existing ID.
#. TRANS: %s is the non-existing question ID.
#: classes/QnA_Answer.php:148
#, php-format
msgid "No question with ID %s"
msgstr ""

#. TRANS: Exception thown when getting a profile with a non-existing ID.
#. TRANS: %s is the non-existing profile ID.
#. TRANS: Exception trown when getting a profile for a non-existing ID.
#. TRANS: %s is the provided profile ID.
#: classes/QnA_Answer.php:159 classes/QnA_Question.php:121
#, php-format
msgid "No profile with ID %s"
msgstr ""

#. TRANS: %s is the number of answer revisions.
#: classes/QnA_Answer.php:204
#, php-format
msgid "%s revision"
msgid_plural "%s revisions"
msgstr[0] ""
msgstr[1] ""

#. TRANS: Text for a question that was answered.
#. TRANS: %1$s is the user that answered, %2$s is the question title,
#. TRANS: %2$s is the answer content.
#: classes/QnA_Answer.php:224
#, php-format
msgid "%1$s answered the question \"%2$s\": %3$s"
msgstr ""

#. TRANS: Text for a question that was answered.
#. TRANS: %s is the question title.
#. TRANS: Rendered version of the notice content answering a question.
#. TRANS: %s a link to the question with question title as the link content.
#: classes/QnA_Answer.php:265 classes/QnA_Answer.php:272
#, php-format
msgid "answered \"%s\""
msgstr ""

#. TRANS: Number of given answers to a question.
#. TRANS: %s is the number of given answers.
#: classes/QnA_Question.php:208
#, php-format
msgid "%s answer"
msgid_plural "%s answers"
msgstr[0] ""
msgstr[1] ""

#. TRANS: Notification that a question cannot be answered anymore because it is closed.
#: classes/QnA_Question.php:215
msgid "This question is closed."
msgstr ""

#. TRANS: Rendered version of the notice content creating a question.
#. TRANS: %s a link to the question as link description.
#: classes/QnA_Question.php:279
#, php-format
msgid "Question: %s"
msgstr ""

#. TRANS: Plugin description.
#: QnAPlugin.php:137
msgid "Question and Answers micro-app."
msgstr ""

#. TRANS: Application title.
#: QnAPlugin.php:144
msgctxt "TITLE"
msgid "Question"
msgstr ""

#. TRANS: Exception thrown when there are too many activity objects.
#: QnAPlugin.php:172
msgid "Too many activity objects."
msgstr ""

#. TRANS: Exception thrown when an incorrect object type is encountered.
#: QnAPlugin.php:179
msgid "Wrong type for object."
msgstr ""

#. TRANS: Exception thrown when answering a non-existing question.
#: QnAPlugin.php:198
msgid "Answer to unknown question."
msgstr ""

#. TRANS: Exception thrown when an object type is encountered that cannot be handled.
#: QnAPlugin.php:204 QnAPlugin.php:234
msgid "Unknown object type."
msgstr ""

#. TRANS: Exception thrown when requesting a non-existing question notice.
#: QnAPlugin.php:241
msgid "Unknown question notice."
msgstr ""

#. TRANS: Placeholder value for a possible answer to a question
#. TRANS: by the logged in user.
#: QnAPlugin.php:368
msgid "Your answer..."
msgstr ""

#. TRANS: Link description for link to full notice text if it is longer than
#. TRANS: what will be dispplayed.
#: QnAPlugin.php:393
msgid "…"
msgstr ""

#. TRANS: Title for link that is an ellipsis in English.
#: QnAPlugin.php:398
msgid "more..."
msgstr ""

#. TRANS: Button text for submitting a revised answer.
#. TRANS: Button text for submitting a poll response.
#: forms/qnareviseanswer.php:119 forms/qnavote.php:118
msgctxt "BUTTON"
msgid "Submit"
msgstr ""

#. TRANS: Field label.
#: forms/qnanewanswer.php:114
msgid "Enter your answer"
msgstr ""

#. TRANS: Button text for submitting a poll response.
#: forms/qnanewanswer.php:125
msgctxt "BUTTON"
msgid "Answer"
msgstr ""

#. TRANS: Form legend for revising the answer.
#: forms/qnashowquestion.php:106
msgctxt "LEGEND"
msgid "Question"
msgstr ""

#. TRANS: Button text for closing a question.
#: forms/qnashowquestion.php:151
msgctxt "BUTTON"
msgid "Close"
msgstr ""

#. TRANS: Title for button text for closing a question.
#: forms/qnashowquestion.php:155
msgid "Close the question to no one can answer it anymore."
msgstr ""

#. TRANS: Field label for a new question.
#: forms/qnanewquestion.php:110
msgctxt "LABEL"
msgid "Title"
msgstr ""

#. TRANS: Field title for a new question.
#: forms/qnanewquestion.php:113
msgid "The title of your question."
msgstr ""

#. TRANS: Field label for question details.
#: forms/qnanewquestion.php:122
msgctxt "LABEL"
msgid "Description"
msgstr ""

#. TRANS: Field title for question details.
#: forms/qnanewquestion.php:125
msgid "Your question in detail."
msgstr ""

#. TRANS: Button text for saving a new question.
#: forms/qnanewquestion.php:149
msgctxt "BUTTON"
msgid "Save"
msgstr ""

#. TRANS: Button text for marking an answer as "best".
#: forms/qnashowanswer.php:150
msgctxt "BUTTON"
msgid "Best"
msgstr ""

#. TRANS: Title for button text marking an answer as "best".
#: forms/qnashowanswer.php:154
msgid "Mark this answer as the best answer."
msgstr ""


code:
# Translation file for GNU social - the free software social networking platform
# Copyright (C) 2015 - 2019 Free Software Foundation, Inc http://www.fsf.org
# This file is under https://www.gnu.org/licenses/agpl v3 or later
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: GNU social\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-02-02 17:47+0100\n"
"PO-Revision-Date: 2015-02-05 16:28+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Afrikaans (http://www.transifex.com/gnu-social/gnu-social/language/af/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: af\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. TRANS: Button text for submitting a poll response.
#. TRANS: Button text for submitting a revised answer.
#: forms/qnavote.php:118 forms/qnareviseanswer.php:119
msgctxt "BUTTON"
msgid "Submit"
msgstr ""

#. TRANS: Form legend for showing the answer.
#. TRANS: Page title for and answer to a question.
#. TRANS: Page title after sending an answer.
#. TRANS: Page title for and answer to a question.
#: forms/qnashowanswer.php:113 actions/qnavote.php:63
#: actions/qnareviseanswer.php:161 actions/qnareviseanswer.php:203
#: actions/qnanewanswer.php:63
msgid "Answer"
msgstr ""

#. TRANS: Button text for marking an answer as "best".
#: forms/qnashowanswer.php:150
msgctxt "BUTTON"
msgid "Best"
msgstr ""

#. TRANS: Title for button text marking an answer as "best".
#: forms/qnashowanswer.php:154
msgid "Mark this answer as the best answer."
msgstr ""

#. TRANS: Field label for a new question.
#: forms/qnanewquestion.php:110
msgctxt "LABEL"
msgid "Title"
msgstr ""

#. TRANS: Field title for a new question.
#: forms/qnanewquestion.php:113
msgid "The title of your question."
msgstr ""

#. TRANS: Field label for question details.
#: forms/qnanewquestion.php:122
msgctxt "LABEL"
msgid "Description"
msgstr "Beskrywing"

#. TRANS: Field title for question details.
#: forms/qnanewquestion.php:125
msgid "Your question in detail."
msgstr ""

#. TRANS: Button text for saving a new question.
#: forms/qnanewquestion.php:149
msgctxt "BUTTON"
msgid "Save"
msgstr "Stoor"

#. TRANS: Form legend for revising the answer.
#: forms/qnashowquestion.php:106
msgctxt "LEGEND"
msgid "Question"
msgstr ""

#. TRANS: Button text for closing a question.
#: forms/qnashowquestion.php:151
msgctxt "BUTTON"
msgid "Close"
msgstr ""

#. TRANS: Title for button text for closing a question.
#: forms/qnashowquestion.php:155
msgid "Close the question to no one can answer it anymore."
msgstr ""

#. TRANS: Field label.
#: forms/qnanewanswer.php:114
msgid "Enter your answer"
msgstr ""

#. TRANS: Button text for submitting a poll response.
#: forms/qnanewanswer.php:125
msgctxt "BUTTON"
msgid "Answer"
msgstr ""

#. TRANS: Plugin description.
#: QnAPlugin.php:136
msgid "Question and Answers micro-app."
msgstr ""

#. TRANS: Application title.
#: QnAPlugin.php:143
msgctxt "TITLE"
msgid "Question"
msgstr ""

#. TRANS: Exception thrown when there are too many activity objects.
#: QnAPlugin.php:171
msgid "Too many activity objects."
msgstr ""

#. TRANS: Exception thrown when an incorrect object type is encountered.
#: QnAPlugin.php:178
msgid "Wrong type for object."
msgstr ""

#. TRANS: Exception thrown when answering a non-existing question.
#: QnAPlugin.php:197
msgid "Answer to unknown question."
msgstr ""

#. TRANS: Exception thrown when an object type is encountered that cannot be
#. handled.
#: QnAPlugin.php:203 QnAPlugin.php:233
msgid "Unknown object type."
msgstr ""

#. TRANS: Exception thrown when requesting a non-existing question notice.
#: QnAPlugin.php:240
msgid "Unknown question notice."
msgstr ""

#. TRANS: Placeholder value for a possible answer to a question
#. TRANS: by the logged in user.
#: QnAPlugin.php:368
msgid "Your answer..."
msgstr ""

#. TRANS: Link description for link to full notice text if it is longer than
#. TRANS: what will be dispplayed.
#: QnAPlugin.php:393
msgid "…"
msgstr ""

#. TRANS: Title for link that is an ellipsis in English.
#: QnAPlugin.php:398
msgid "more..."
msgstr ""

#. TRANS: Page title for close a question
#: actions/qnaclosequestion.php:63
msgid "Close question"
msgstr ""

#. TRANS: Client exception thrown trying to close a question when not logged
#. in
#: actions/qnaclosequestion.php:85
msgid "You must be logged in to close a question."
msgstr ""

#. TRANS: Client exception thrown trying to respond to a non-existing
#. question.
#: actions/qnaclosequestion.php:98 actions/qnavote.php:96
#: actions/qnanewanswer.php:101
msgid "Invalid or missing question."
msgstr ""

#. TRANS: Exception thrown trying to close another user's question.
#: actions/qnaclosequestion.php:136
msgid "You did not ask this question."
msgstr ""

#. TRANS: Page title after sending an answer.
#. TRANS: Page title after sending in a vote for a question or answer.
#. TRANS: Page title after sending an answer.
#: actions/qnaclosequestion.php:153 actions/qnavote.php:148
#: actions/qnanewanswer.php:158
msgid "Answers"
msgstr ""

#. TRANS: Client exception thrown trying to answer a question while not logged
#. in.
#: actions/qnavote.php:84 actions/qnareviseanswer.php:84
#: actions/qnanewanswer.php:85
msgid "You must be logged in to answer to a question."
msgstr ""

#. TRANS: Client exception thrown when requesting a non-existing answer.
#. TRANS: Did we used to have it, and it got deleted?
#: actions/qnashowanswer.php:68 actions/qnashowanswer.php:82
msgid "No such answer."
msgstr ""

#. TRANS: Client exception thrown when requesting an answer that has no
#. connected question.
#: actions/qnashowanswer.php:75
msgid "No question for this answer."
msgstr ""

#. TRANS: Client exception thrown when requesting answer data for a non-
#. existing user.
#. TRANS: Client exception thrown trying to view a question of a non-existing
#. user.
#: actions/qnashowanswer.php:89 actions/qnashowquestion.php:83
msgid "No such user."
msgstr "Onbekende gebruiker."

#. TRANS: Client exception thrown when requesting answer data for a user
#. without a profile.
#. TRANS: Server exception thrown trying to view a question for a user for
#. which the profile could not be loaded.
#: actions/qnashowanswer.php:96 actions/qnashowquestion.php:90
msgid "User without a profile."
msgstr ""

#. TRANS: Page title.
#. TRANS: %1$s is the user who answered a question, %2$s is the question.
#: actions/qnashowanswer.php:122
#, php-format
msgid "%1$s's answer to \"%2$s\""
msgstr ""

#. TRANS: Page title for revising a question
#: actions/qnareviseanswer.php:62
msgid "Revise answer"
msgstr ""

#. TRANS: Client exception thrown trying to respond to a non-existing
#. question.
#: actions/qnareviseanswer.php:97
msgid "Invalid or missing answer."
msgstr ""

#. TRANS: Form title for sending an answer.
#: actions/qnareviseanswer.php:241
msgctxt "TITLE"
msgid "Answer"
msgstr ""

#. TRANS: Title for Question page.
#: actions/qnanewquestion.php:62
msgid "New question"
msgstr ""

#. TRANS: Client exception thrown trying to create a Question while not logged
#. in.
#: actions/qnanewquestion.php:81
msgid "You must be logged in to post a question."
msgstr ""

#. TRANS: Client exception thrown trying to create a question without a title.
#: actions/qnanewquestion.php:129
msgid "Question must have a title."
msgstr ""

#. TRANS: Page title after sending a notice.
#: actions/qnanewquestion.php:154
msgid "Question posted"
msgstr ""

#. TRANS: Client exception thrown trying to view a non-existing question.
#: actions/qnashowquestion.php:68
msgid "No such question."
msgstr ""

#. TRANS: Client exception thrown trying to view a non-existing question
#. notice.
#: actions/qnashowquestion.php:76
msgid "No such question notice."
msgstr ""

#. TRANS: Page title for a question.
#. TRANS: %1$s is the nickname of the user who asked the question, %2$s is the
#. question.
#: actions/qnashowquestion.php:155
#, php-format
msgid "%1$s's question: %2$s"
msgstr ""

#. TRANS: Page title after an AJAX error occurs on the post answer page.
#: actions/qnanewanswer.php:224
msgid "Ajax Error"
msgstr "Ajax-fout"

#. TRANS: Title for form to send answer to a question.
#: actions/qnanewanswer.php:247
msgctxt "TITLE"
msgid "Your answer"
msgstr ""

#. TRANS: Error message displayed when an answer has no content.
#. TRANS: Error message displayed when answer data is not present.
#: actions/qnanewanswer.php:344 lib/qnalistitem.php:118
msgid "Answer data is missing."
msgstr ""

#. TRANS: Exception thown when getting a question with a non-existing ID.
#. TRANS: %s is the non-existing question ID.
#: classes/QnA_Answer.php:146
#, php-format
msgid "No question with ID %s"
msgstr ""

#. TRANS: Exception thown when getting a profile with a non-existing ID.
#. TRANS: %s is the non-existing profile ID.
#. TRANS: Exception trown when getting a profile for a non-existing ID.
#. TRANS: %s is the provided profile ID.
#: classes/QnA_Answer.php:157 classes/QnA_Question.php:121
#, php-format
msgid "No profile with ID %s"
msgstr ""

#. TRANS: %s is the number of answer revisions.
#: classes/QnA_Answer.php:202
#, php-format
msgid "%s revision"
msgid_plural "%s revisions"
msgstr[0] ""
msgstr[1] ""

#. TRANS: Text for a question that was answered.
#. TRANS: %1$s is the user that answered, %2$s is the question title,
#. TRANS: %2$s is the answer content.
#: classes/QnA_Answer.php:222
#, php-format
msgid "%1$s answered the question \"%2$s\": %3$s"
msgstr ""

#. TRANS: Text for a question that was answered.
#. TRANS: %s is the question title.
#. TRANS: Rendered version of the notice content answering a question.
#. TRANS: %s a link to the question with question title as the link content.
#: classes/QnA_Answer.php:263 classes/QnA_Answer.php:270
#, php-format
msgid "answered \"%s\""
msgstr ""

#. TRANS: Number of given answers to a question.
#. TRANS: %s is the number of given answers.
#: classes/QnA_Question.php:208
#, php-format
msgid "%s answer"
msgid_plural "%s answers"
msgstr[0] ""
msgstr[1] ""

#. TRANS: Notification that a question cannot be answered anymore because it
#. is closed.
#: classes/QnA_Question.php:215
msgid "This question is closed."
msgstr ""

#. TRANS: Rendered version of the notice content creating a question.
#. TRANS: %s a link to the question as link description.
#: classes/QnA_Question.php:279
#, php-format
msgid "Question: %s"
msgstr ""

#. TRANS: Exception thrown when performing an unexpected action on a question.
#. TRANS: %s is the unpexpected object type.
#: lib/qnalistitem.php:67
#, php-format
msgid "Unexpected type for QnA plugin: %s."
msgstr ""

#. TRANS: Error message displayed when question data is not present.
#: lib/qnalistitem.php:93
msgid "Question data is missing."
msgstr ""


code:
# Translation file for GNU social - the free software social networking platform
# Copyright (C) 2011 - 2019 Free Software Foundation, Inc http://www.fsf.org
# This file is under https://www.gnu.org/licenses/agpl v3 or later
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: GNU social\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-02-02 17:47+0100\n"
"PO-Revision-Date: 2015-02-07 14:33+0000\n"
"Last-Translator: digitaldreamer <digitaldreamer@email.cz>\n"
"Language-Team: Arabic (http://www.transifex.com/gnu-social/gnu-social/language/ar/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: ar\n"
"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n"

#. TRANS: Button text for submitting a poll response.
#. TRANS: Button text for submitting a revised answer.
#: forms/qnavote.php:118 forms/qnareviseanswer.php:119
msgctxt "BUTTON"
msgid "Submit"
msgstr "أرسل"

#. TRANS: Form legend for showing the answer.
#. TRANS: Page title for and answer to a question.
#. TRANS: Page title after sending an answer.
#. TRANS: Page title for and answer to a question.
#: forms/qnashowanswer.php:113 actions/qnavote.php:63
#: actions/qnareviseanswer.php:161 actions/qnareviseanswer.php:203
#: actions/qnanewanswer.php:63
msgid "Answer"
msgstr "إجابة"

#. TRANS: Button text for marking an answer as "best".
#: forms/qnashowanswer.php:150
msgctxt "BUTTON"
msgid "Best"
msgstr "الأفضل"

#. TRANS: Title for button text marking an answer as "best".
#: forms/qnashowanswer.php:154
msgid "Mark this answer as the best answer."
msgstr "علّم هذه الإجابة أفضل إجابة."

#. TRANS: Field label for a new question.
#: forms/qnanewquestion.php:110
msgctxt "LABEL"
msgid "Title"
msgstr "العنوان"

#. TRANS: Field title for a new question.
#: forms/qnanewquestion.php:113
msgid "The title of your question."
msgstr "عنوان سؤالك."

#. TRANS: Field label for question details.
#: forms/qnanewquestion.php:122
msgctxt "LABEL"
msgid "Description"
msgstr "الوصف"

#. TRANS: Field title for question details.
#: forms/qnanewquestion.php:125
msgid "Your question in detail."
msgstr "سؤالك بالتفصيل."

#. TRANS: Button text for saving a new question.
#: forms/qnanewquestion.php:149
msgctxt "BUTTON"
msgid "Save"
msgstr "احفظ"

#. TRANS: Form legend for revising the answer.
#: forms/qnashowquestion.php:106
msgctxt "LEGEND"
msgid "Question"
msgstr "سؤال"

#. TRANS: Button text for closing a question.
#: forms/qnashowquestion.php:151
msgctxt "BUTTON"
msgid "Close"
msgstr "أغلق"

#. TRANS: Title for button text for closing a question.
#: forms/qnashowquestion.php:155
msgid "Close the question to no one can answer it anymore."
msgstr ""

#. TRANS: Field label.
#: forms/qnanewanswer.php:114
msgid "Enter your answer"
msgstr "أدخل إجابتك"

#. TRANS: Button text for submitting a poll response.
#: forms/qnanewanswer.php:125
msgctxt "BUTTON"
msgid "Answer"
msgstr "أجب"

#. TRANS: Plugin description.
#: QnAPlugin.php:136
msgid "Question and Answers micro-app."
msgstr ""

#. TRANS: Application title.
#: QnAPlugin.php:143
msgctxt "TITLE"
msgid "Question"
msgstr "سؤال"

#. TRANS: Exception thrown when there are too many activity objects.
#: QnAPlugin.php:171
msgid "Too many activity objects."
msgstr ""

#. TRANS: Exception thrown when an incorrect object type is encountered.
#: QnAPlugin.php:178
msgid "Wrong type for object."
msgstr ""

#. TRANS: Exception thrown when answering a non-existing question.
#: QnAPlugin.php:197
msgid "Answer to unknown question."
msgstr ""

#. TRANS: Exception thrown when an object type is encountered that cannot be
#. handled.
#: QnAPlugin.php:203 QnAPlugin.php:233
msgid "Unknown object type."
msgstr ""

#. TRANS: Exception thrown when requesting a non-existing question notice.
#: QnAPlugin.php:240
msgid "Unknown question notice."
msgstr ""

#. TRANS: Placeholder value for a possible answer to a question
#. TRANS: by the logged in user.
#: QnAPlugin.php:368
msgid "Your answer..."
msgstr "إجابتك..."

#. TRANS: Link description for link to full notice text if it is longer than
#. TRANS: what will be dispplayed.
#: QnAPlugin.php:393
msgid "…"
msgstr "…"

#. TRANS: Title for link that is an ellipsis in English.
#: QnAPlugin.php:398
msgid "more..."
msgstr "مزيد..."

#. TRANS: Page title for close a question
#: actions/qnaclosequestion.php:63
msgid "Close question"
msgstr "أغلق السؤال"

#. TRANS: Client exception thrown trying to close a question when not logged
#. in
#: actions/qnaclosequestion.php:85
msgid "You must be logged in to close a question."
msgstr ""

#. TRANS: Client exception thrown trying to respond to a non-existing
#. question.
#: actions/qnaclosequestion.php:98 actions/qnavote.php:96
#: actions/qnanewanswer.php:101
msgid "Invalid or missing question."
msgstr ""

#. TRANS: Exception thrown trying to close another user's question.
#: actions/qnaclosequestion.php:136
msgid "You did not ask this question."
msgstr ""

#. TRANS: Page title after sending an answer.
#. TRANS: Page title after sending in a vote for a question or answer.
#. TRANS: Page title after sending an answer.
#: actions/qnaclosequestion.php:153 actions/qnavote.php:148
#: actions/qnanewanswer.php:158
msgid "Answers"
msgstr "الإجابات"

#. TRANS: Client exception thrown trying to answer a question while not logged
#. in.
#: actions/qnavote.php:84 actions/qnareviseanswer.php:84
#: actions/qnanewanswer.php:85
msgid "You must be logged in to answer to a question."
msgstr "يجب أن تلج لتجيب سؤالا."

#. TRANS: Client exception thrown when requesting a non-existing answer.
#. TRANS: Did we used to have it, and it got deleted?
#: actions/qnashowanswer.php:68 actions/qnashowanswer.php:82
msgid "No such answer."
msgstr ""

#. TRANS: Client exception thrown when requesting an answer that has no
#. connected question.
#: actions/qnashowanswer.php:75
msgid "No question for this answer."
msgstr ""

#. TRANS: Client exception thrown when requesting answer data for a non-
#. existing user.
#. TRANS: Client exception thrown trying to view a question of a non-existing
#. user.
#: actions/qnashowanswer.php:89 actions/qnashowquestion.php:83
msgid "No such user."
msgstr "لا يوجد مستخدم بهذا الاسم."

#. TRANS: Client exception thrown when requesting answer data for a user
#. without a profile.
#. TRANS: Server exception thrown trying to view a question for a user for
#. which the profile could not be loaded.
#: actions/qnashowanswer.php:96 actions/qnashowquestion.php:90
msgid "User without a profile."
msgstr ""

#. TRANS: Page title.
#. TRANS: %1$s is the user who answered a question, %2$s is the question.
#: actions/qnashowanswer.php:122
#, php-format
msgid "%1$s's answer to \"%2$s\""
msgstr "إجابة %1$s ل\"%2$s\""

#. TRANS: Page title for revising a question
#: actions/qnareviseanswer.php:62
msgid "Revise answer"
msgstr "راجع الإجابة"

#. TRANS: Client exception thrown trying to respond to a non-existing
#. question.
#: actions/qnareviseanswer.php:97
msgid "Invalid or missing answer."
msgstr ""

#. TRANS: Form title for sending an answer.
#: actions/qnareviseanswer.php:241
msgctxt "TITLE"
msgid "Answer"
msgstr "أجب"

#. TRANS: Title for Question page.
#: actions/qnanewquestion.php:62
msgid "New question"
msgstr "سؤال جديد"

#. TRANS: Client exception thrown trying to create a Question while not logged
#. in.
#: actions/qnanewquestion.php:81
msgid "You must be logged in to post a question."
msgstr "يجب أن تلج لتنشر سؤالا."

#. TRANS: Client exception thrown trying to create a question without a title.
#: actions/qnanewquestion.php:129
msgid "Question must have a title."
msgstr "يجب أن يكون للسؤال عنوان."

#. TRANS: Page title after sending a notice.
#: actions/qnanewquestion.php:154
msgid "Question posted"
msgstr "نُشر السؤال"

#. TRANS: Client exception thrown trying to view a non-existing question.
#: actions/qnashowquestion.php:68
msgid "No such question."
msgstr ""

#. TRANS: Client exception thrown trying to view a non-existing question
#. notice.
#: actions/qnashowquestion.php:76
msgid "No such question notice."
msgstr ""

#. TRANS: Page title for a question.
#. TRANS: %1$s is the nickname of the user who asked the question, %2$s is the
#. question.
#: actions/qnashowquestion.php:155
#, php-format
msgid "%1$s's question: %2$s"
msgstr "سؤال %1$s: %2$s"

#. TRANS: Page title after an AJAX error occurs on the post answer page.
#: actions/qnanewanswer.php:224
msgid "Ajax Error"
msgstr "خطأ أجاكس"

#. TRANS: Title for form to send answer to a question.
#: actions/qnanewanswer.php:247
msgctxt "TITLE"
msgid "Your answer"
msgstr "إجابتك"

#. TRANS: Error message displayed when an answer has no content.
#. TRANS: Error message displayed when answer data is not present.
#: actions/qnanewanswer.php:344 lib/qnalistitem.php:118
msgid "Answer data is missing."
msgstr ""

#. TRANS: Exception thown when getting a question with a non-existing ID.
#. TRANS: %s is the non-existing question ID.
#: classes/QnA_Answer.php:146
#, php-format
msgid "No question with ID %s"
msgstr ""

#. TRANS: Exception thown when getting a profile with a non-existing ID.
#. TRANS: %s is the non-existing profile ID.
#. TRANS: Exception trown when getting a profile for a non-existing ID.
#. TRANS: %s is the provided profile ID.
#: classes/QnA_Answer.php:157 classes/QnA_Question.php:121
#, php-format
msgid "No profile with ID %s"
msgstr ""

#. TRANS: %s is the number of answer revisions.
#: classes/QnA_Answer.php:202
#, php-format
msgid "%s revision"
msgid_plural "%s revisions"
msgstr[0] ""
msgstr[1] "مراجعة واحدة"
msgstr[2] "مراجعتين"
msgstr[3] "%s مراجعات"
msgstr[4] "%s مراجعة"
msgstr[5] ""

#. TRANS: Text for a question that was answered.
#. TRANS: %1$s is the user that answered, %2$s is the question title,
#. TRANS: %2$s is the answer content.
#: classes/QnA_Answer.php:222
#, php-format
msgid "%1$s answered the question \"%2$s\": %3$s"
msgstr ""

#. TRANS: Text for a question that was answered.
#. TRANS: %s is the question title.
#. TRANS: Rendered version of the notice content answering a question.
#. TRANS: %s a link to the question with question title as the link content.
#: classes/QnA_Answer.php:263 classes/QnA_Answer.php:270
#, php-format
msgid "answered \"%s\""
msgstr "أجاب \"%s\""

#. TRANS: Number of given answers to a question.
#. TRANS: %s is the number of given answers.
#: classes/QnA_Question.php:208
#, php-format
msgid "%s answer"
msgid_plural "%s answers"
msgstr[0] ""
msgstr[1] ""
msgstr[2] ""
msgstr[3] ""
msgstr[4] ""
msgstr[5] ""

#. TRANS: Notification that a question cannot be answered anymore because it
#. is closed.
#: classes/QnA_Question.php:215
msgid "This question is closed."
msgstr "هذا السؤال مغلق."

#. TRANS: Rendered version of the notice content creating a question.
#. TRANS: %s a link to the question as link description.
#: classes/QnA_Question.php:279
#, php-format
msgid "Question: %s"
msgstr "سؤال: %s"

#. TRANS: Exception thrown when performing an unexpected action on a question.
#. TRANS: %s is the unpexpected object type.
#: lib/qnalistitem.php:67
#, php-format
msgid "Unexpected type for QnA plugin: %s."
msgstr ""

#. TRANS: Error message displayed when question data is not present.
#: lib/qnalistitem.php:93
msgid "Question data is missing."
msgstr ""