Skip to content

Commit

Permalink
feat: added possibility to remove bookmarks (#2644)
Browse files Browse the repository at this point in the history
* feat: added trash-icon for bookmarks

* feat: added delete-bookmark request

* fix: added class

* fix: line length (PHPCS)
  • Loading branch information
modelrailroader authored Sep 17, 2023
1 parent bb0ec6b commit d377444
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions phpmyfaq/api.service.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

const IS_VALID_PHPMYFAQ = null;

use phpMyFAQ\Bookmark;
use phpMyFAQ\Captcha\Captcha;
use phpMyFAQ\Category;
use phpMyFAQ\Comments;
Expand Down Expand Up @@ -1005,6 +1006,12 @@
$response->setData(['error' => Translation::get('err_sendMail')]);
}
break;

case 'delete-bookmark':
$id = Filter::filterVar($postData['faqId'], FILTER_VALIDATE_INT);
$bookmark = new Bookmark($faqConfig, $user);
$status = $bookmark->remove($id);
$response->setData(['success' => $status]);
}

$response->send();
6 changes: 4 additions & 2 deletions phpmyfaq/src/phpMyFAQ/Bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,15 @@ public function buildBookmarkList(): string
$html .= sprintf(
'<li class="list-group-item d-flex justify-content-between align-items-start">'
. '<div class="ms-2 me-auto">'
. '<div class="fw-bold">%s</div>'
. '<div class="fw-bold"><span onclick="handleDeleteBookmark(%d)">'
. '<i class="fa fa-trash me-5"></i></span>%s</div>'
. '<div class="small">%s</div>'
. '</div>'
. '<span id="viewsPerRecord" class="badge bg-primary rounded-pill">%s</span>'
. '</li>',
$faqData['id'],
$link->toHtmlAnchor(),
strip_tags($faqData['content']),
htmlspecialchars_decode($faqData['content']),
$plurals->getMsg('plmsgViews', $visitsFaq)
);
}
Expand Down

0 comments on commit d377444

Please sign in to comment.