]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/QnA/actions/qnanewquestion.php
Improved type-hint for following methods:
[quix0rs-gnu-social.git] / plugins / QnA / actions / qnanewquestion.php
index 3399c5eda8afee86a76b7fa50cc86225e0ca8d20..c7a126e703bf88c1976bd4952e201d8460ae8b66 100644 (file)
@@ -76,8 +76,8 @@ class QnanewquestionAction extends Action
         $this->user = common_current_user();
 
         if (empty($this->user)) {
-            // TRANS: Client exception thrown trying to create a Question while not logged in.
             throw new ClientException(
+                // TRANS: Client exception thrown trying to create a Question while not logged in.
                 _m('You must be logged in to post a question.'),
                 403
             );
@@ -88,7 +88,6 @@ class QnanewquestionAction extends Action
         }
 
         $this->title       = $this->trimmed('title');
-        common_debug("TITLE = " . $this->title);
         $this->description = $this->trimmed('description');
 
         return true;
@@ -149,9 +148,7 @@ class QnanewquestionAction extends Action
         }
 
         if ($this->boolean('ajax')) {
-            header('Content-Type: text/xml;charset=utf-8');
-            $this->xw->startDocument('1.0', 'UTF-8');
-            $this->elementStart('html');
+            $this->startHTML('text/xml;charset=utf-8');
             $this->elementStart('head');
             // TRANS: Page title after sending a notice.
             $this->element('title', null, _m('Question posted'));
@@ -159,9 +156,9 @@ class QnanewquestionAction extends Action
             $this->elementStart('body');
             $this->showNotice($saved);
             $this->elementEnd('body');
-            $this->elementEnd('html');
+            $this->endHTML();
         } else {
-            common_redirect($saved->bestUrl(), 303);
+            common_redirect($saved->getUrl(), 303);
         }
     }
 
@@ -176,8 +173,7 @@ class QnanewquestionAction extends Action
      */
     function showNotice($notice)
     {
-        class_exists('NoticeList'); // @fixme hack for autoloader
-        $nli = new NoticeListItem($notice, $this);
+        $nli = new NoticeQuestionListItem($notice, $this);
         $nli->show();
     }
 
@@ -212,7 +208,7 @@ class QnanewquestionAction extends Action
      *
      * @return boolean is read only action?
      */
-    function isReadOnly($args)
+    function isReadOnly(array $args=array())
     {
         if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
             $_SERVER['REQUEST_METHOD'] == 'HEAD') {
@@ -222,3 +218,24 @@ class QnanewquestionAction extends Action
         }
     }
 }
+
+class NoticeQuestionListItem extends NoticeListItem
+{
+    /**
+     * constructor
+     *
+     * Also initializes the profile attribute.
+     *
+     * @param Notice $notice The notice we'll display
+     */
+    function __construct($notice, $out=null)
+    {
+        parent::__construct($notice, $out);
+    }
+
+    function showEnd()
+    {
+        $this->out->element('ul', 'notices threaded-replies xoxo');
+        parent::showEnd();
+    }
+}