]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
QnA - Rework output for notice stream
authorZach Copley <zach@status.net>
Mon, 4 Apr 2011 22:08:47 +0000 (15:08 -0700)
committerZach Copley <zach@status.net>
Mon, 4 Apr 2011 22:08:47 +0000 (15:08 -0700)
plugins/QnA/QnAPlugin.php
plugins/QnA/classes/QnA_Answer.php
plugins/QnA/classes/QnA_Question.php

index cc70cb7aeb46ed59ebf974e22b0503907bcb3d85..35811a309a742d6849685e789a0df86d7900c7f4 100644 (file)
@@ -384,7 +384,7 @@ class QnAPlugin extends MicroAppPlugin
         $nli = new NoticeListItem($notice, $out);
         $nli->showNotice();
 
-        $out->elementStart('div', array('class' => 'entry-content question-desciption'));
+        $out->elementStart('div', array('class' => 'entry-content question-description'));
 
         $question = QnA_Question::getByNotice($notice);
 
index a2333be6dcbccfc6d0bc58a876ae9720eed77e44..c8dcd43162fd9d8c6c9ec6117ed03d811fa93500 100644 (file)
@@ -205,31 +205,31 @@ class QnA_Answer extends Managed_DataObject
     {
         $notice = $question->getNotice();
 
-        $fmt = '';
+        $out = new XMLStringer();
 
+        $cls = array('qna_answer');
         if (!empty($answer->best)) {
-            $fmt  = '<p class="qna_answer best">';
-        } else {
-            $fmt  = '<p class="qna_answer">';
+            $cls[] = 'best';
         }
 
-        $fmt .= '<span class="answer_author"><a href="%1$s">answer</a> by <a href="%2$s">%3$s</a></span>';
-        $fmt .= '<span class="answer_content">%4$s</span>';
+        $out->elementStart('p', array('class' => implode(' ', $cls)));
+        $out->elementStart('span', 'answer-content');
+        $out->raw(QnAPlugin::shorten($answer->content, $notice));
+        $out->elementEnd('span');
+
         if (!empty($answer->revisions)) {
-            $fmt .= '<span class="answer_revisions">'
-                 . $answer->revisions
-                 . _m('revisions')
-                 . '</span>';
+            $out->elementstart('span', 'answer-revisions');
+            $out->text(
+                htmlspecialchars(
+                    sprintf(_m('%s revisions'), $answer->revisions)
+                )
+            );
+            $out->elementEnd('span');
         }
-        $fmt .= '</p>';
 
-        return sprintf(
-            $fmt,
-            htmlspecialchars($notice->bestUrl()),
-            htmlspecialchars($profile->profileurl),
-            htmlspecialchars($profile->getBestName()),
-            htmlspecialchars($answer->content)
-        );
+        $out->elementEnd('p');
+
+        return $out->getString();
     }
 
     static function toString($profile, $question, $answer)
index 93d45c56c8909463308fde0ccd45c56c7a8695d7..3f1a33d33cc3c95acaa64e68fb376b6e35fd4d3c 100644 (file)
@@ -213,14 +213,12 @@ class QnA_Question extends Managed_DataObject
     {
         $notice = $question->getNotice();
 
-        $fmt = '<span class="question_description">%s</span>';
+        $out = new XMLStringer();
+        $out->elementStart('span', 'question_description');
+        $out->raw(QnAPlugin::shorten($question->description, $notice));
+        $out->elementEnd('span');
 
-        $q = sprintf(
-            $fmt,
-            htmlspecialchars($question->description)
-        );
-
-        return $q;
+        return $out->getString();
     }
 
     static function toString($profile, $question, $answers)