X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FBookmark%2Fnewbookmark.php;h=ebfdb6cb95c1818209a1574eb477fb3328c8cc2a;hb=4e1ce4e5bbc43869dc7c85463f9a733da9f5fda4;hp=a0cf3fffb297c2e33efa77ab68142783f1547126;hpb=63933265572429e2cc465e745ab1fc5b9993d6b3;p=quix0rs-gnu-social.git diff --git a/plugins/Bookmark/newbookmark.php b/plugins/Bookmark/newbookmark.php index a0cf3fffb2..ebfdb6cb95 100644 --- a/plugins/Bookmark/newbookmark.php +++ b/plugins/Bookmark/newbookmark.php @@ -125,6 +125,9 @@ class NewbookmarkAction extends Action function newBookmark() { + if ($this->boolean('ajax')) { + StatusNet::setApi(true); + } try { if (empty($this->title)) { throw new ClientException(_('Bookmark must have a title.')); @@ -147,7 +150,37 @@ class NewbookmarkAction extends Action return; } - common_redirect($saved->bestUrl(), 303); + 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 sending a notice. + $this->element('title', null, _('Notice posted')); + $this->elementEnd('head'); + $this->elementStart('body'); + $this->showNotice($saved); + $this->elementEnd('body'); + $this->elementEnd('html'); + } else { + common_redirect($saved->bestUrl(), 303); + } + } + + /** + * Output a notice + * + * Used to generate the notice code for Ajax results. + * + * @param Notice $notice Notice that was saved + * + * @return void + */ + function showNotice($notice) + { + class_exists('NoticeList'); // @fixme hack for autoloader + $nli = new NoticeListItem($notice, $this); + $nli->show(); } /**