]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Bookmark/newbookmark.php
Merge commit 'refs/merge-requests/164' of git://gitorious.org/statusnet/mainline...
[quix0rs-gnu-social.git] / plugins / Bookmark / newbookmark.php
index 8c60fc159681b9da422343aacc71e166956d62fd..57be783b3805003ad8d4ba8941ded6ae75bc77c2 100644 (file)
@@ -75,6 +75,10 @@ class NewbookmarkAction extends Action
     {
         parent::prepare($argarray);
 
+        if ($this->boolean('ajax')) {
+            StatusNet::setApi(true);
+        }
+
         $this->user = common_current_user();
 
         if (empty($this->user)) {
@@ -87,10 +91,10 @@ class NewbookmarkAction extends Action
             $this->checkSessionToken();
         }
 
-        $this->title       = $this->trimmed('bookmark-title');
-        $this->url         = $this->trimmed('bookmark-url');
-        $this->tags        = $this->trimmed('bookmark-tags');
-        $this->description = $this->trimmed('bookmark-description');
+        $this->title       = $this->trimmed('title');
+        $this->url         = $this->trimmed('url');
+        $this->tags        = $this->trimmed('tags');
+        $this->description = $this->trimmed('description');
 
         return true;
     }
@@ -122,9 +126,6 @@ class NewbookmarkAction extends Action
      */
     function newBookmark()
     {
-        if ($this->boolean('ajax')) {
-            StatusNet::setApi(true);
-        }
         try {
             if (empty($this->title)) {
                 // TRANS: Client exception thrown when trying to create a new bookmark without a title.
@@ -148,9 +149,24 @@ class NewbookmarkAction extends Action
                                        $options);
 
         } catch (ClientException $ce) {
-            $this->error = $ce->getMessage();
-            $this->showPage();
-            return;
+            if ($this->boolean('ajax')) {
+                header('Content-Type: text/xml;charset=utf-8');
+                $this->xw->startDocument('1.0', 'UTF-8');
+                $this->elementStart('html');
+                $this->elementStart('head');
+                // TRANS: Page title after an AJAX error occurs
+                $this->element('title', null, _('Ajax Error'));
+                $this->elementEnd('head');
+                $this->elementStart('body');
+                $this->element('p', array('id' => 'error'), $ce->getMessage());
+                $this->elementEnd('body');
+                $this->elementEnd('html');
+                return;
+            } else {
+                $this->error = $ce->getMessage();
+                $this->showPage();
+                return;
+            }
         }
 
         if ($this->boolean('ajax')) {