]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/shownotice.php
Merge branch '1.0.x' of git://gitorious.org/statusnet/mainline
[quix0rs-gnu-social.git] / actions / shownotice.php
index 91b0901bf464a7548eec6f2ea55cd65645066034..b8927372bb10d1c72e83da54ab66ec052d4944b3 100644 (file)
@@ -78,6 +78,9 @@ class ShownoticeAction extends OwnerDesignAction
     function prepare($args)
     {
         parent::prepare($args);
+        if ($this->boolean('ajax')) {
+            StatusNet::setApi(true);
+        }
 
         $id = $this->arg('notice');
 
@@ -188,22 +191,26 @@ class ShownoticeAction extends OwnerDesignAction
     {
         parent::handle($args);
 
-        if ($this->notice->is_local == Notice::REMOTE_OMB) {
-            if (!empty($this->notice->url)) {
-                $target = $this->notice->url;
-            } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) {
-                // Old OMB posts saved the remote URL only into the URI field.
-                $target = $this->notice->uri;
-            } else {
-                // Shouldn't happen.
-                $target = false;
-            }
-            if ($target && $target != $this->selfUrl()) {
-                common_redirect($target, 301);
-                return false;
+        if ($this->boolean('ajax')) {
+            $this->showAjax();
+        } else {
+            if ($this->notice->is_local == Notice::REMOTE_OMB) {
+                if (!empty($this->notice->url)) {
+                    $target = $this->notice->url;
+                } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) {
+                    // Old OMB posts saved the remote URL only into the URI field.
+                    $target = $this->notice->uri;
+                } else {
+                    // Shouldn't happen.
+                    $target = false;
+                }
+                if ($target && $target != $this->selfUrl()) {
+                    common_redirect($target, 301);
+                    return false;
+                }
             }
+            $this->showPage();
         }
-        $this->showPage();
     }
 
     /**
@@ -232,6 +239,21 @@ class ShownoticeAction extends OwnerDesignAction
         $this->elementEnd('ol');
     }
 
+    function showAjax()
+    {
+        header('Content-Type: text/xml;charset=utf-8');
+        $this->xw->startDocument('1.0', 'UTF-8');
+        $this->elementStart('html');
+        $this->elementStart('head');
+        $this->element('title', null, _('Notice'));
+        $this->elementEnd('head');
+        $this->elementStart('body');
+        $nli = new NoticeListItem($this->notice, $this);
+        $nli->show();
+        $this->elementEnd('body');
+        $this->elementEnd('html');
+    }
+
     /**
      * Don't show page notice
      *
@@ -338,7 +360,7 @@ class SingleNoticeItem extends DoFollowListItem
      * show the avatar of the notice's author
      *
      * We use the larger size for single notice page.
-     * 
+     *
      * @return void
      */