]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/QnA/QnAPlugin.php
Merge branch 'master' into testing
[quix0rs-gnu-social.git] / plugins / QnA / QnAPlugin.php
index 6841ec9873204e7d8e82001838ae9a20c19f3cf8..4908e93dd0e250caa7326e4911b2a67fcb937d92 100644 (file)
@@ -167,13 +167,15 @@ class QnAPlugin extends MicroAppPlugin
             'author'      => 'Zach Copley',
             'homepage'    => 'http://status.net/wiki/Plugin:QnA',
             'description' =>
+             // TRANS: Plugin description.
              _m('Question and Answers micro-app.')
         );
         return true;
     }
 
     function appTitle() {
-        return _m('Question');
+        // TRANS: Application title.
+        return _m('TITLE','Question');
     }
 
     function tag() {
@@ -200,13 +202,15 @@ class QnAPlugin extends MicroAppPlugin
     function saveNoticeFromActivity($activity, $actor, $options=array())
     {
         if (count($activity->objects) != 1) {
-            throw new Exception('Too many activity objects.');
+            // TRANS: Exception thrown when there are too many activity objects.
+            throw new Exception(_m('Too many activity objects.'));
         }
 
         $questionObj = $activity->objects[0];
 
         if ($questionObj->type != QnA_Question::OBJECT_TYPE) {
-            throw new Exception('Wrong type for object.');
+            // TRANS: Exception thrown when an incorrect object type is encountered.
+            throw new Exception(_m('Wrong type for object.'));
         }
 
         $notice = null;
@@ -224,12 +228,14 @@ class QnAPlugin extends MicroAppPlugin
             $question = QnA_Question::staticGet('uri', $questionObj->id);
             if (empty($question)) {
                 // FIXME: save the question
-                throw new Exception("Answer to unknown question.");
+                // TRANS: Exception thrown when answering a non-existing question.
+                throw new Exception(_m('Answer to unknown question.'));
             }
             $notice = QnA_Answer::saveNew($actor, $question, $options);
             break;
         default:
-            throw new Exception("Unknown object type received by QnA Plugin");
+            // TRANS: Exception thrown when an object type is encountered that cannot be handled.
+            throw new Exception(_m('Unknown object type.'));
         }
 
         return $notice;
@@ -258,13 +264,15 @@ class QnAPlugin extends MicroAppPlugin
         }
 
         if (empty($question)) {
-            throw new Exception("Unknown object type.");
+            // TRANS: Exception thrown when an object type is encountered that cannot be handled.
+            throw new Exception(_m('Unknown object type.'));
         }
 
         $notice = $question->getNotice();
 
         if (empty($notice)) {
-            throw new Exception("Unknown question notice.");
+            // TRANS: Exception thrown when requesting a non-existing question notice.
+            throw new Exception(_m('Unknown question notice.'));
         }
 
         $obj = new ActivityObject();
@@ -299,6 +307,13 @@ class QnAPlugin extends MicroAppPlugin
             if ($nli->notice->scope != 0 && $nli->notice->scope != 1) {
                 $class .= ' limited-scope';
             }
+
+            $question = QnA_Question::staticGet('uri', $nli->notice->uri);
+
+            if (!empty($question->closed)) {
+                $class .= ' closed';
+            }
+
             $nli->out->elementStart(
                 'li', array(
                     'class' => $class,
@@ -342,7 +357,6 @@ class QnAPlugin extends MicroAppPlugin
      * @param Notice $notice
      * @param HTMLOutputter $out
      */
-
     function showNotice($notice, $out)
     {
         switch ($notice->object_type) {
@@ -351,12 +365,11 @@ class QnAPlugin extends MicroAppPlugin
         case QnA_Answer::OBJECT_TYPE:
             return $this->showNoticeAnswer($notice, $out);
         default:
-            // TRANS: Exception thrown when performing an unexpected action on a question.
-            // TRANS: %s is the unpexpected object type.
             throw new Exception(
-                sprintf(
-                    _m('Unexpected type for QnA plugin: %s.'),
-                    $notice->object_type
+                // 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
                 )
             );
         }
@@ -380,6 +393,7 @@ class QnAPlugin extends MicroAppPlugin
             $form->show();
 
         } else {
+            // TRANS: Error message displayed when question data is not present.
             $out->text(_m('Question data is missing.'));
         }
         $out->elementEnd('div');
@@ -388,7 +402,6 @@ class QnAPlugin extends MicroAppPlugin
         $out->elementStart('div', array('class' => 'entry-content'));
     }
 
-
     /**
      * Output the HTML for this kind of object in a list
      *
@@ -396,7 +409,7 @@ class QnAPlugin extends MicroAppPlugin
      *
      * @return boolean hook value
      *
-     * @fixme WARNING WARNING WARNING this closes a 'div' that is implicitly opened in BookmarkPlugin's showNotice implementation
+     * @todo FIXME: WARNING WARNING WARNING this closes a 'div' that is implicitly opened in BookmarkPlugin's showNotice implementation
      */
     function onStartShowNoticeItem($nli)
     {
@@ -420,12 +433,10 @@ class QnAPlugin extends MicroAppPlugin
         $nli->showNoticeOptions();
 
         if ($notice->object_type == QnA_Question::OBJECT_TYPE) {
-
             $user = common_current_user();
             $question = QnA_Question::getByNotice($notice);
 
             if (!empty($user)) {
-
                 $profile = $user->getProfile();
                 $answer = $question->getAnswer($profile);
 
@@ -440,6 +451,8 @@ class QnAPlugin extends MicroAppPlugin
                         'input',
                         array(
                             'class' => 'placeholder',
+                            // TRANS: Placeholder value for a possible answer to a question
+                            // TRANS: by the logged in user.
                             'value' => _m('Your answer...')
                         )
                     );
@@ -452,7 +465,6 @@ class QnAPlugin extends MicroAppPlugin
         return false;
     }
 
-
     function showNoticeAnswer($notice, $out)
     {
         $user = common_current_user();
@@ -469,12 +481,13 @@ class QnAPlugin extends MicroAppPlugin
             $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');
 
-        // @fixme
+        // @todo FIXME
         $out->elementStart('div', array('class' => 'entry-content'));
     }
 
@@ -485,12 +498,15 @@ class QnAPlugin extends MicroAppPlugin
         if (Notice::contentTooLong($content)) {
             common_debug("content too long");
             $max = Notice::maxContent();
+            // TRANS: Link description for link to full notice text if it is longer than
+            // TRANS: what will be dispplayed.
+            $ellipsis = _m('…');
             $short = mb_substr($content, 0, $max - 1);
-            $short .= sprintf(
-                '<a href="%s" rel="more" title="%s">…</a>',
-                $notice->uri,
-                _m('more')
-            );
+            $short .= sprintf('<a href="%1$s" rel="more" title="%2$s">%3$s</a>',
+                              $notice->uri,
+                              // TRANS: Title for link that is an ellipsis in English.
+                              _m('more...'),
+                              $ellipsis);
         } else {
             $short = $content;
         }
@@ -504,7 +520,6 @@ class QnAPlugin extends MicroAppPlugin
      * @param HTMLOutputter $out
      * @return Widget
      */
-
     function entryForm($out)
     {
         return new QnanewquestionForm($out);
@@ -515,7 +530,6 @@ class QnAPlugin extends MicroAppPlugin
      *
      * @param Notice $notice
      */
-
     function deleteRelated($notice)
     {
         switch ($notice->object_type) {