123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <?php
- if (!defined('STATUSNET')) {
-
-
- exit(1);
- }
- class QnashowanswerAction extends ShownoticeAction
- {
- protected $answer = null;
-
- function prepare($argarray)
- {
- Action::prepare($argarray);
- $this->id = $this->trimmed('id');
- $this->answer = QnA_Answer::getKV('id', $this->id);
- if (empty($this->answer)) {
-
- throw new ClientException(_m('No such answer.'), 404);
- }
- $this->question = $this->answer->getQuestion();
- if (empty($this->question)) {
-
- throw new ClientException(_m('No question for this answer.'), 404);
- }
- $this->notice = Notice::getKV('uri', $this->answer->uri);
- if (empty($this->notice)) {
-
- throw new ClientException(_m('No such answer.'), 404);
- }
- $this->user = User::getKV('id', $this->answer->profile_id);
- if (empty($this->user)) {
-
- throw new ClientException(_m('No such user.'), 404);
- }
- $this->profile = $this->user->getProfile();
- if (empty($this->profile)) {
-
- 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 title()
- {
- $question = $this->answer->getQuestion();
- return sprintf(
-
-
- _m('%1$s\'s answer to "%2$s"'),
- $this->user->nickname,
- $question->title
- );
- }
-
- function showPageTitle()
- {
- $this->elementStart('h1');
- $this->element(
- 'a',
- array('href' => $this->answer->uri),
- $this->question->title
- );
- $this->elementEnd('h1');
- }
- function showContent()
- {
- $this->raw($this->answer->asHTML());
- }
- }
|